From 3885dc5b9acf08dc90397ab02b814bc72d7b4ed5 Mon Sep 17 00:00:00 2001 From: Jorn Vernee Date: Thu, 26 Oct 2023 15:54:02 +0000 Subject: [PATCH 01/16] 8318737: Fallback linker passes bad JNI handle Reviewed-by: alanb --- src/hotspot/share/runtime/jniHandles.cpp | 8 ++----- .../foreign/abi/fallback/LibFallback.java | 9 +++++--- .../native/libfallbackLinker/fallbackLinker.c | 23 ++++++++++++++++--- test/jdk/java/foreign/TestDowncallScope.java | 2 +- test/jdk/java/foreign/TestDowncallStack.java | 2 +- test/jdk/java/foreign/TestUpcallScope.java | 2 +- test/jdk/java/foreign/TestUpcallStack.java | 2 +- 7 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/hotspot/share/runtime/jniHandles.cpp b/src/hotspot/share/runtime/jniHandles.cpp index feceec366a597..25c8aa8b10b6e 100644 --- a/src/hotspot/share/runtime/jniHandles.cpp +++ b/src/hotspot/share/runtime/jniHandles.cpp @@ -199,13 +199,9 @@ jobjectRefType JNIHandles::handle_type(JavaThread* thread, jobject handle) { default: ShouldNotReachHere(); } - } else { + } else if (is_local_handle(thread, handle) || is_frame_handle(thread, handle)) { // Not in global storage. Might be a local handle. - if (is_local_handle(thread, handle) || is_frame_handle(thread, handle)) { - result = JNILocalRefType; - } else { - ShouldNotReachHere(); - } + result = JNILocalRefType; } return result; } diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java index 7318c71b82fe2..8e3e29d6a4a78 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java @@ -43,11 +43,14 @@ private static boolean tryLoadLibrary() { public Boolean run() { try { System.loadLibrary("fallbackLinker"); - init(); - return true; } catch (UnsatisfiedLinkError ule) { return false; } + if (!init()) { + // library failed to initialize. Do not silently mark as unsupported + throw new ExceptionInInitializerError("Fallback library failed to initialize"); + } + return true; } }); } @@ -201,7 +204,7 @@ private static void checkStatus(int code) { } } - private static native void init(); + private static native boolean init(); private static native long sizeofCif(); diff --git a/src/java.base/share/native/libfallbackLinker/fallbackLinker.c b/src/java.base/share/native/libfallbackLinker/fallbackLinker.c index e99483adbd5d0..41f4edbe54e32 100644 --- a/src/java.base/share/native/libfallbackLinker/fallbackLinker.c +++ b/src/java.base/share/native/libfallbackLinker/fallbackLinker.c @@ -42,12 +42,29 @@ static jclass LibFallback_class; static jmethodID LibFallback_doUpcall_ID; static const char* LibFallback_doUpcall_sig = "(JJLjava/lang/invoke/MethodHandle;)V"; -JNIEXPORT void JNICALL +#define CHECK_NULL(expr) \ + if (expr == NULL) { \ + return JNI_FALSE; \ + } + +JNIEXPORT jboolean JNICALL Java_jdk_internal_foreign_abi_fallback_LibFallback_init(JNIEnv* env, jclass cls) { - (*env)->GetJavaVM(env, &VM); - LibFallback_class = (*env)->FindClass(env, "jdk/internal/foreign/abi/fallback/LibFallback"); + jint result = (*env)->GetJavaVM(env, &VM); + if (result != 0) { + return JNI_FALSE; + } + + jclass LibFallback_class_local = (*env)->FindClass(env, "jdk/internal/foreign/abi/fallback/LibFallback"); + CHECK_NULL(LibFallback_class_local) + + LibFallback_class = (*env)->NewGlobalRef(env, LibFallback_class_local); + CHECK_NULL(LibFallback_class) + LibFallback_doUpcall_ID = (*env)->GetStaticMethodID(env, LibFallback_class, "doUpcall", LibFallback_doUpcall_sig); + CHECK_NULL(LibFallback_doUpcall_ID) + + return JNI_TRUE; } JNIEXPORT jlong JNICALL diff --git a/test/jdk/java/foreign/TestDowncallScope.java b/test/jdk/java/foreign/TestDowncallScope.java index 9cd42f9050ffa..f988f7673de34 100644 --- a/test/jdk/java/foreign/TestDowncallScope.java +++ b/test/jdk/java/foreign/TestDowncallScope.java @@ -26,7 +26,7 @@ * @modules java.base/jdk.internal.foreign * @build NativeTestHelper CallGeneratorHelper TestDowncallBase * - * @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies + * @run testng/othervm -Xcheck:jni -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies * --enable-native-access=ALL-UNNAMED -Dgenerator.sample.factor=17 * TestDowncallScope * diff --git a/test/jdk/java/foreign/TestDowncallStack.java b/test/jdk/java/foreign/TestDowncallStack.java index 28e0aac19db93..a685365c040dc 100644 --- a/test/jdk/java/foreign/TestDowncallStack.java +++ b/test/jdk/java/foreign/TestDowncallStack.java @@ -26,7 +26,7 @@ * @modules java.base/jdk.internal.foreign * @build NativeTestHelper CallGeneratorHelper TestDowncallBase * - * @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies + * @run testng/othervm -Xcheck:jni -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies * --enable-native-access=ALL-UNNAMED -Dgenerator.sample.factor=17 * TestDowncallStack */ diff --git a/test/jdk/java/foreign/TestUpcallScope.java b/test/jdk/java/foreign/TestUpcallScope.java index e16dbb3435b65..d1bf55e8735c7 100644 --- a/test/jdk/java/foreign/TestUpcallScope.java +++ b/test/jdk/java/foreign/TestUpcallScope.java @@ -26,7 +26,7 @@ * @modules java.base/jdk.internal.foreign * @build NativeTestHelper CallGeneratorHelper TestUpcallBase * - * @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies + * @run testng/othervm -Xcheck:jni -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies * --enable-native-access=ALL-UNNAMED -Dgenerator.sample.factor=17 * TestUpcallScope */ diff --git a/test/jdk/java/foreign/TestUpcallStack.java b/test/jdk/java/foreign/TestUpcallStack.java index 81241b3a156a7..88d98a9fc8b7b 100644 --- a/test/jdk/java/foreign/TestUpcallStack.java +++ b/test/jdk/java/foreign/TestUpcallStack.java @@ -27,7 +27,7 @@ * @modules java.base/jdk.internal.foreign * @build NativeTestHelper CallGeneratorHelper TestUpcallBase * - * @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies + * @run testng/othervm -Xcheck:jni -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies * --enable-native-access=ALL-UNNAMED -Dgenerator.sample.factor=17 * TestUpcallStack */ From 40a3c35aa5614be4505013d4e92ddb1b556a3622 Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Thu, 26 Oct 2023 16:10:16 +0000 Subject: [PATCH 02/16] 8318723: RISC-V: C2 UDivL 8318224: RISC-V: C2 UDivI Reviewed-by: fyang, luhenry, aph --- .../cpu/riscv/c1_LIRAssembler_arith_riscv.cpp | 10 +++-- .../cpu/riscv/macroAssembler_riscv.cpp | 16 +++++-- .../cpu/riscv/macroAssembler_riscv.hpp | 4 +- src/hotspot/cpu/riscv/riscv.ad | 43 +++++++++++++++++-- src/hotspot/cpu/riscv/templateTable_riscv.cpp | 8 ++-- .../intrinsics/TestIntegerUnsignedDivMod.java | 6 +-- .../intrinsics/TestLongUnsignedDivMod.java | 6 +-- 7 files changed, 70 insertions(+), 23 deletions(-) diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_arith_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_arith_riscv.cpp index e80c926e1e06f..70731d46fb498 100644 --- a/src/hotspot/cpu/riscv/c1_LIRAssembler_arith_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_arith_riscv.cpp @@ -86,7 +86,7 @@ void LIR_Assembler::arithmetic_idiv(LIR_Code code, LIR_Opr left, LIR_Opr right, } } else { Register rreg = right->as_register(); - __ corrected_idivl(dreg, lreg, rreg, is_irem); + __ corrected_idivl(dreg, lreg, rreg, is_irem, /* is_signed */ true); } } @@ -172,8 +172,12 @@ void LIR_Assembler::arith_op_double_cpu(LIR_Code code, LIR_Opr left, LIR_Opr rig case lir_add: __ add(dest->as_register_lo(), lreg_lo, rreg_lo); break; case lir_sub: __ sub(dest->as_register_lo(), lreg_lo, rreg_lo); break; case lir_mul: __ mul(dest->as_register_lo(), lreg_lo, rreg_lo); break; - case lir_div: __ corrected_idivq(dest->as_register_lo(), lreg_lo, rreg_lo, false); break; - case lir_rem: __ corrected_idivq(dest->as_register_lo(), lreg_lo, rreg_lo, true); break; + case lir_div: __ corrected_idivq(dest->as_register_lo(), lreg_lo, rreg_lo, + /* want_remainder */ false, /* is_signed */ true); + break; + case lir_rem: __ corrected_idivq(dest->as_register_lo(), lreg_lo, rreg_lo, + /* want_remainder */ true, /* is_signed */ true); + break; default: ShouldNotReachHere(); } diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 7548408c9a35e..1b8f2ab63603b 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -2386,7 +2386,7 @@ void MacroAssembler::store_heap_oop_null(Address dst) { } int MacroAssembler::corrected_idivl(Register result, Register rs1, Register rs2, - bool want_remainder) + bool want_remainder, bool is_signed) { // Full implementation of Java idiv and irem. The function // returns the (pc) offset of the div instruction - may be needed @@ -2402,7 +2402,11 @@ int MacroAssembler::corrected_idivl(Register result, Register rs1, Register rs2, int idivl_offset = offset(); if (!want_remainder) { - divw(result, rs1, rs2); + if (is_signed) { + divw(result, rs1, rs2); + } else { + divuw(result, rs1, rs2); + } } else { remw(result, rs1, rs2); // result = rs1 % rs2; } @@ -2410,7 +2414,7 @@ int MacroAssembler::corrected_idivl(Register result, Register rs1, Register rs2, } int MacroAssembler::corrected_idivq(Register result, Register rs1, Register rs2, - bool want_remainder) + bool want_remainder, bool is_signed) { // Full implementation of Java ldiv and lrem. The function // returns the (pc) offset of the div instruction - may be needed @@ -2425,7 +2429,11 @@ int MacroAssembler::corrected_idivq(Register result, Register rs1, Register rs2, int idivq_offset = offset(); if (!want_remainder) { - div(result, rs1, rs2); + if (is_signed) { + div(result, rs1, rs2); + } else { + divu(result, rs1, rs2); + } } else { rem(result, rs1, rs2); // result = rs1 % rs2; } diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index c5df08f47fa85..6963cc7c21e2f 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -241,9 +241,9 @@ class MacroAssembler: public Assembler { // idiv variant which deals with MINLONG as dividend and -1 as divisor int corrected_idivl(Register result, Register rs1, Register rs2, - bool want_remainder); + bool want_remainder, bool is_signed); int corrected_idivq(Register result, Register rs1, Register rs2, - bool want_remainder); + bool want_remainder, bool is_signed); // interface method calling void lookup_interface_method(Register recv_klass, diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 0e20089ff8be0..15d142edfa66c 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -2443,7 +2443,15 @@ encode %{ Register dst_reg = as_Register($dst$$reg); Register src1_reg = as_Register($src1$$reg); Register src2_reg = as_Register($src2$$reg); - __ corrected_idivl(dst_reg, src1_reg, src2_reg, false); + __ corrected_idivl(dst_reg, src1_reg, src2_reg, /* want_remainder */ false, /* is_signed */ true); + %} + + enc_class riscv_enc_divuw(iRegI dst, iRegI src1, iRegI src2) %{ + C2_MacroAssembler _masm(&cbuf); + Register dst_reg = as_Register($dst$$reg); + Register src1_reg = as_Register($src1$$reg); + Register src2_reg = as_Register($src2$$reg); + __ corrected_idivl(dst_reg, src1_reg, src2_reg, /* want_remainder */ false, /* is_signed */ false); %} enc_class riscv_enc_div(iRegI dst, iRegI src1, iRegI src2) %{ @@ -2451,7 +2459,15 @@ encode %{ Register dst_reg = as_Register($dst$$reg); Register src1_reg = as_Register($src1$$reg); Register src2_reg = as_Register($src2$$reg); - __ corrected_idivq(dst_reg, src1_reg, src2_reg, false); + __ corrected_idivq(dst_reg, src1_reg, src2_reg, /* want_remainder */ false, /* is_signed */ true); + %} + + enc_class riscv_enc_divu(iRegI dst, iRegI src1, iRegI src2) %{ + C2_MacroAssembler _masm(&cbuf); + Register dst_reg = as_Register($dst$$reg); + Register src1_reg = as_Register($src1$$reg); + Register src2_reg = as_Register($src2$$reg); + __ corrected_idivq(dst_reg, src1_reg, src2_reg, /* want_remainder */ false, /* is_signed */ false); %} enc_class riscv_enc_modw(iRegI dst, iRegI src1, iRegI src2) %{ @@ -2459,7 +2475,7 @@ encode %{ Register dst_reg = as_Register($dst$$reg); Register src1_reg = as_Register($src1$$reg); Register src2_reg = as_Register($src2$$reg); - __ corrected_idivl(dst_reg, src1_reg, src2_reg, true); + __ corrected_idivl(dst_reg, src1_reg, src2_reg, /* want_remainder */ true, /* is_signed */ true); %} enc_class riscv_enc_mod(iRegI dst, iRegI src1, iRegI src2) %{ @@ -2467,7 +2483,7 @@ encode %{ Register dst_reg = as_Register($dst$$reg); Register src1_reg = as_Register($src1$$reg); Register src2_reg = as_Register($src2$$reg); - __ corrected_idivq(dst_reg, src1_reg, src2_reg, true); + __ corrected_idivq(dst_reg, src1_reg, src2_reg, /* want_remainder */ true, /* is_signed */ true); %} enc_class riscv_enc_tail_call(iRegP jump_target) %{ @@ -6673,6 +6689,15 @@ instruct divI(iRegINoSp dst, iRegIorL2I src1, iRegIorL2I src2) %{ ins_pipe(idiv_reg_reg); %} +instruct UdivI(iRegINoSp dst, iRegIorL2I src1, iRegIorL2I src2) %{ + match(Set dst (UDivI src1 src2)); + ins_cost(IDIVSI_COST); + format %{ "divuw $dst, $src1, $src2\t#@UdivI"%} + + ins_encode(riscv_enc_divuw(dst, src1, src2)); + ins_pipe(idiv_reg_reg); +%} + instruct signExtract(iRegINoSp dst, iRegIorL2I src1, immI_31 div1, immI_31 div2) %{ match(Set dst (URShiftI (RShiftI src1 div1) div2)); ins_cost(ALU_COST); @@ -6695,6 +6720,16 @@ instruct divL(iRegLNoSp dst, iRegL src1, iRegL src2) %{ ins_pipe(ldiv_reg_reg); %} +instruct UdivL(iRegLNoSp dst, iRegL src1, iRegL src2) %{ + match(Set dst (UDivL src1 src2)); + ins_cost(IDIVDI_COST); + + format %{ "divu $dst, $src1, $src2\t#@UdivL" %} + + ins_encode(riscv_enc_divu(dst, src1, src2)); + ins_pipe(ldiv_reg_reg); +%} + instruct signExtractL(iRegLNoSp dst, iRegL src1, immI_63 div1, immI_63 div2) %{ match(Set dst (URShiftL (RShiftL src1 div1) div2)); ins_cost(ALU_COST); diff --git a/src/hotspot/cpu/riscv/templateTable_riscv.cpp b/src/hotspot/cpu/riscv/templateTable_riscv.cpp index a0b3f037ab2a0..7f7930f51c67a 100644 --- a/src/hotspot/cpu/riscv/templateTable_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateTable_riscv.cpp @@ -1318,7 +1318,7 @@ void TemplateTable::idiv() { __ bind(no_div0); __ pop_i(x11); // x10 <== x11 idiv x10 - __ corrected_idivl(x10, x11, x10, /* want_remainder */ false); + __ corrected_idivl(x10, x11, x10, /* want_remainder */ false, /* is_signed */ true); } void TemplateTable::irem() { @@ -1331,7 +1331,7 @@ void TemplateTable::irem() { __ bind(no_div0); __ pop_i(x11); // x10 <== x11 irem x10 - __ corrected_idivl(x10, x11, x10, /* want_remainder */ true); + __ corrected_idivl(x10, x11, x10, /* want_remainder */ true, /* is_signed */ true); } void TemplateTable::lmul() { @@ -1350,7 +1350,7 @@ void TemplateTable::ldiv() { __ bind(no_div0); __ pop_l(x11); // x10 <== x11 ldiv x10 - __ corrected_idivq(x10, x11, x10, /* want_remainder */ false); + __ corrected_idivq(x10, x11, x10, /* want_remainder */ false, /* is_signed */ true); } void TemplateTable::lrem() { @@ -1363,7 +1363,7 @@ void TemplateTable::lrem() { __ bind(no_div0); __ pop_l(x11); // x10 <== x11 lrem x10 - __ corrected_idivq(x10, x11, x10, /* want_remainder */ true); + __ corrected_idivq(x10, x11, x10, /* want_remainder */ true, /* is_signed */ true); } void TemplateTable::lshl() { diff --git a/test/hotspot/jtreg/compiler/intrinsics/TestIntegerUnsignedDivMod.java b/test/hotspot/jtreg/compiler/intrinsics/TestIntegerUnsignedDivMod.java index 1b214c3239184..cbad7c729140f 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/TestIntegerUnsignedDivMod.java +++ b/test/hotspot/jtreg/compiler/intrinsics/TestIntegerUnsignedDivMod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -23,8 +23,8 @@ /** * @test -* @summary Test x86_64 intrinsic for divideUnsigned() and remainderUnsigned() methods for Integer -* @requires os.arch=="amd64" | os.arch=="x86_64" +* @summary Test intrinsic for divideUnsigned() and remainderUnsigned() methods for Integer +* @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="riscv64" * @library /test/lib / * @run driver compiler.intrinsics.TestIntegerUnsignedDivMod */ diff --git a/test/hotspot/jtreg/compiler/intrinsics/TestLongUnsignedDivMod.java b/test/hotspot/jtreg/compiler/intrinsics/TestLongUnsignedDivMod.java index ee9c6499902b6..796a3aa80690d 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/TestLongUnsignedDivMod.java +++ b/test/hotspot/jtreg/compiler/intrinsics/TestLongUnsignedDivMod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -23,8 +23,8 @@ /** * @test -* @summary Test x86_64 intrinsic for divideUnsigned() and remainderUnsigned() methods for Long -* @requires os.arch=="amd64" | os.arch=="x86_64" +* @summary Test intrinsic for divideUnsigned() and remainderUnsigned() methods for Long +* @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="riscv64" * @library /test/lib / * @run driver compiler.intrinsics.TestLongUnsignedDivMod */ From e1a458ee6436e5b572e376d8cb27cf2e6b3a2afc Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Thu, 26 Oct 2023 16:28:28 +0000 Subject: [PATCH 03/16] 8318834: s390x: Debug builds are missing debug helpers Reviewed-by: shade, lucy --- make/autoconf/flags-cflags.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index db31cb3581604..ae54bbde0f1b5 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -522,7 +522,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], # do this on s390x also for libjvm (where serviceability agent is not supported) if test "x$ENABLE_LINKTIME_GC" = xtrue; then TOOLCHAIN_CFLAGS_JDK="$TOOLCHAIN_CFLAGS_JDK -ffunction-sections -fdata-sections" - if test "x$OPENJDK_TARGET_CPU" = xs390x; then + if test "x$OPENJDK_TARGET_CPU" = xs390x && test "x$DEBUG_LEVEL" == xrelease; then TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -ffunction-sections -fdata-sections" fi fi From a9b31b587c7487b2222773debde1ce2227884959 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Thu, 26 Oct 2023 16:40:33 +0000 Subject: [PATCH 04/16] 8318689: jtreg is confused when folder name is the same as the test name Reviewed-by: mullan --- .../javax/security/auth/Subject/{DoAs.java => DoAsTest.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename test/jdk/javax/security/auth/Subject/{DoAs.java => DoAsTest.java} (95%) diff --git a/test/jdk/javax/security/auth/Subject/DoAs.java b/test/jdk/javax/security/auth/Subject/DoAsTest.java similarity index 95% rename from test/jdk/javax/security/auth/Subject/DoAs.java rename to test/jdk/javax/security/auth/Subject/DoAsTest.java index db89c8936cd4f..56183e06819b2 100644 --- a/test/jdk/javax/security/auth/Subject/DoAs.java +++ b/test/jdk/javax/security/auth/Subject/DoAsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -32,7 +32,7 @@ import java.util.Set; import javax.security.auth.Subject; -public class DoAs { +public class DoAsTest { public static void main(String[] args) throws Exception { final Set outer = new HashSet<>(Arrays.asList("Outer")); From 77fe0fd9e6f1e1f775a5191640411c37eb51b415 Mon Sep 17 00:00:00 2001 From: Aleksei Efimov Date: Thu, 26 Oct 2023 18:24:42 +0000 Subject: [PATCH 05/16] 8272215: Add InetAddress methods for parsing IP address literals Reviewed-by: dfuchs, michaelm --- .../share/classes/java/net/HostPortrange.java | 5 +- .../share/classes/java/net/Inet4Address.java | 83 ++++- .../share/classes/java/net/Inet6Address.java | 150 ++++++++- .../share/classes/java/net/InetAddress.java | 111 +++---- .../classes/sun/net/util/IPAddressUtil.java | 29 +- .../java/net/InetAddress/OfLiteralTest.java | 310 ++++++++++++++++++ 6 files changed, 606 insertions(+), 82 deletions(-) create mode 100644 test/jdk/java/net/InetAddress/OfLiteralTest.java diff --git a/src/java.base/share/classes/java/net/HostPortrange.java b/src/java.base/share/classes/java/net/HostPortrange.java index 7a0601011cd25..fd516b8d2d732 100644 --- a/src/java.base/share/classes/java/net/HostPortrange.java +++ b/src/java.base/share/classes/java/net/HostPortrange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -25,7 +25,6 @@ package java.net; -import java.net.*; import java.util.Formatter; import java.util.Locale; import sun.net.util.IPAddressUtil; @@ -137,7 +136,7 @@ public int hashCode() { } this.ipv4 = this.literal = ipv4; if (ipv4) { - byte[] ip = IPAddressUtil.validateNumericFormatV4(hoststr); + byte[] ip = IPAddressUtil.validateNumericFormatV4(hoststr, false); if (ip == null) { throw new IllegalArgumentException("illegal IPv4 address"); } diff --git a/src/java.base/share/classes/java/net/Inet4Address.java b/src/java.base/share/classes/java/net/Inet4Address.java index 9f0c783b82792..9f1def3d5f84a 100644 --- a/src/java.base/share/classes/java/net/Inet4Address.java +++ b/src/java.base/share/classes/java/net/Inet4Address.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, 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 @@ -25,7 +25,10 @@ package java.net; +import sun.net.util.IPAddressUtil; + import java.io.ObjectStreamException; +import java.util.Objects; /** * This class represents an Internet Protocol version 4 (IPv4) address. @@ -36,7 +39,7 @@ * and RFC 2365: * Administratively Scoped IP Multicast * - *

Textual representation of IP addresses

+ *

Textual representation of IPv4 addresses

* * Textual representation of IPv4 address used as input to methods * takes one of the following forms: @@ -55,7 +58,7 @@ *

When a three part address is specified, the last part is * interpreted as a 16-bit quantity and placed in the right most two * bytes of the network address. This makes the three part address - * format convenient for specifying Class B net- work addresses as + * format convenient for specifying Class B network addresses as * 128.net.host. * *

When a two part address is supplied, the last part is @@ -67,6 +70,29 @@ *

When only one part is given, the value is stored directly in * the network address without any byte rearrangement. * + *

These forms support parts specified in decimal format only. + * For example, the following forms are supported by methods capable + * of parsing textual representations of IPv4 addresses: + * {@snippet : + * // Dotted-decimal 'd.d.d.d' form with four part address literal + * InetAddress.getByName("007.008.009.010"); // ==> /7.8.9.10 + * InetAddress.getByName("127.0.1.1"); // ==> /127.0.1.1 + * + * // Dotted-decimal 'd.d.d' form with three part address literal, + * // the last part is placed in the right most two bytes + * // of the constructed address + * InetAddress.getByName("127.0.257"); // ==> /127.0.1.1 + * + * // Dotted-decimal 'd.d' form with two part address literal, + * // the last part is placed in the right most three bytes + * // of the constructed address + * Inet4Address.ofLiteral("127.257"); // ==> /127.0.1.1 + * + * // 'd' form with one decimal value that is stored directly in + * // the constructed address bytes without any rearrangement + * Inet4Address.ofLiteral("02130706689"); // ==> /127.0.1.1 + * } + * *

For methods that return a textual representation as output * value, the first form, i.e. a dotted-quad string, is used. * @@ -134,6 +160,57 @@ class Inet4Address extends InetAddress { holder().originalHostName = hostName; } + /** + * Creates an {@code Inet4Address} based on the provided {@linkplain + * Inet4Address##format textual representation} of an IPv4 address. + *

If the provided IPv4 address literal cannot represent a {@linkplain + * Inet4Address##format valid IPv4 address} an {@code IllegalArgumentException} is thrown. + *

This method doesn't block, i.e. no reverse lookup is performed. + * + * @param ipv4AddressLiteral the textual representation of an IPv4 address. + * @return an {@link Inet4Address} object with no hostname set, and constructed + * from the provided IPv4 address literal. + * @throws IllegalArgumentException if the {@code ipv4AddressLiteral} cannot be + * parsed as an IPv4 address literal. + * @throws NullPointerException if the {@code ipv4AddressLiteral} is {@code null}. + */ + public static Inet4Address ofLiteral(String ipv4AddressLiteral) { + Objects.requireNonNull(ipv4AddressLiteral); + return parseAddressString(ipv4AddressLiteral, true); + } + + /** + * Parses the given string as an IPv4 address literal. + * If the given {@code addressLiteral} string cannot be parsed as an IPv4 address literal + * and {@code throwIAE} is {@code false}, {@code null} is returned. + * If the given {@code addressLiteral} string cannot be parsed as an IPv4 address literal + * and {@code throwIAE} is {@code true}, an {@code IllegalArgumentException} is thrown. + * Otherwise, if it can be considered as {@linkplain IPAddressUtil#validateNumericFormatV4(String, + * boolean) an ambiguous literal} - {@code IllegalArgumentException} is thrown irrelevant to + * {@code throwIAE} value. + * + * @apiNote + * The given {@code addressLiteral} string is considered ambiguous if it cannot be parsed as + * a valid IPv4 address literal using decimal notation, but could be + * interpreted as an IPv4 address in some other representation (octal, hexadecimal, or mixed). + * @param addressLiteral IPv4 address literal to parse + * @param throwIAE whether to throw {@code IllegalArgumentException} if the + * given {@code addressLiteral} string cannot be parsed as + * an IPv4 address literal. + * @return {@code Inet4Address} object constructed from the address literal; + * or {@code null} if the literal cannot be parsed as an IPv4 address + * @throws IllegalArgumentException if the given {@code addressLiteral} string + * cannot be parsed as an IPv4 address literal and {@code throwIAE} is {@code true}, + * or if it is considered ambiguous, regardless of the value of {@code throwIAE}. + */ + static Inet4Address parseAddressString(String addressLiteral, boolean throwIAE) { + byte [] addrBytes= IPAddressUtil.validateNumericFormatV4(addressLiteral, throwIAE); + if (addrBytes == null) { + return null; + } + return new Inet4Address(null, addrBytes); + } + /** * Replaces the object to be serialized with an InetAddress object. * diff --git a/src/java.base/share/classes/java/net/Inet6Address.java b/src/java.base/share/classes/java/net/Inet6Address.java index 45d44e3fcbe9b..8e132cdf148c4 100644 --- a/src/java.base/share/classes/java/net/Inet6Address.java +++ b/src/java.base/share/classes/java/net/Inet6Address.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 @@ -25,6 +25,8 @@ package java.net; +import sun.net.util.IPAddressUtil; + import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectInputStream; @@ -32,13 +34,14 @@ import java.io.ObjectStreamField; import java.util.Enumeration; import java.util.Arrays; +import java.util.Objects; /** * This class represents an Internet Protocol version 6 (IPv6) address. * Defined by * RFC 2373: IP Version 6 Addressing Architecture. * - *

Textual representation of IP addresses

+ *

Textual representation of IPv6 addresses

* * Textual representation of IPv6 address used as input to methods * takes one of the following forms: @@ -116,7 +119,7 @@ * form because it is unambiguous when used in combination with other * textual data. * - *

Special IPv6 address

+ *

Special IPv6 address

* *
*
@@ -139,7 +142,8 @@ * *

The textual representation of IPv6 addresses as described above can be * extended to specify IPv6 scoped addresses. This extension to the basic - * addressing architecture is described in [draft-ietf-ipngwg-scoping-arch-04.txt]. + * addressing architecture is described in + * RFC 4007: IPv6 Scoped Address Architecture. * *

Because link-local and site-local addresses are non-global, it is possible * that different hosts may have the same destination address and may be @@ -170,8 +174,24 @@ * Inet6Address instances returned from the NetworkInterface class. This can be * used to find out the current scope ids configured on the system. * + *

Textual representation of IPv6 addresses as method inputs

+ * + *

Methods of {@code InetAddress} and {@code Inet6Address} that accept a + * textual representation of an IPv6 address allow for that representation + * to be enclosed in square brackets. For example, + * {@snippet : + * // The full IPv6 form + * InetAddress.getByName("1080:0:0:0:8:800:200C:417A"); // ==> /1080:0:0:0:8:800:200c:417a + * InetAddress.getByName("[1080:0:0:0:8:800:200C:417A]"); // ==> /1080:0:0:0:8:800:200c:417a + * + * // IPv6 scoped address with scope-id as string + * Inet6Address.ofLiteral("fe80::1%en0"); // ==> /fe80:0:0:0:0:0:0:1%en0 + * Inet6Address.ofLiteral("[fe80::1%en0]"); // ==> /fe80:0:0:0:0:0:0:1%en0 + * } * @spec https://www.rfc-editor.org/info/rfc2373 * RFC 2373: IP Version 6 Addressing Architecture + * @spec https://www.rfc-editor.org/info/rfc4007 + * RFC 4007: IPv6 Scoped Address Architecture * @since 1.4 */ @@ -477,6 +497,128 @@ public static Inet6Address getByAddress(String host, byte[] addr, throw new UnknownHostException("addr is of illegal length"); } + /** + * Creates an {@code InetAddress} based on the provided {@linkplain + * Inet6Address##format textual representation} of an IPv6 address. + *

If the provided address literal cannot represent {@linkplain Inet6Address##format + * a valid IPv6 address} an {@code IllegalArgumentException} is thrown. + * An {@code IllegalArgumentException} is also thrown if an IPv6 scoped address literal + * contains a scope-id that doesn't map to any network interface on the system, or + * if a scope-id is present in an IPv4-mapped IPv6 address literal. + *

This method doesn't block, i.e. no reverse lookup is performed. + *

Note that IPv6 address literal forms are also supported when enclosed in + * square brackets. + * Note also that if the supplied literal represents an {@linkplain + * Inet6Address##special-ipv6-address IPv4-mapped IPv6 address} an + * instance of {@code Inet4Address} is returned. + * + * @param ipv6AddressLiteral the textual representation of an IPv6 address. + * @return an {@link InetAddress} object with no hostname set, and constructed + * from the provided IPv6 address literal. + * @throws IllegalArgumentException if the {@code ipv6AddressLiteral} cannot be + * parsed as an IPv6 address literal. + * @throws NullPointerException if the {@code ipv6AddressLiteral} is {@code null}. + */ + public static InetAddress ofLiteral(String ipv6AddressLiteral) { + Objects.requireNonNull(ipv6AddressLiteral); + try { + InetAddress parsedAddress = parseAddressString(ipv6AddressLiteral, true); + if (parsedAddress != null) { + return parsedAddress; + } + } catch (UnknownHostException uhe) { + // Error constructing Inet6Address from address literal containing + // a network interface name + } + throw IPAddressUtil.invalidIpAddressLiteral(ipv6AddressLiteral); + } + + /** + * Method tries to parse supplied IP address literal as IPv6, IPv4-compatible IPv6 or + * IPv4-mapped IPv6 address. + * If address part of the literal string doesn't contain address in valid IPv6 form + * - {@code null} is returned. + * {@code UnknownHostException} is thrown if {@link InetAddress} cannot be constructed + * from parsed string due to: + * - incorrect zone-id specified in IPv6-scoped address literal that references + * non-existing interface name. + * - unexpected zone-id in IPv4-mapped address literal. + * + * @param addressLiteral literal IP address + * @param removeSqBrackets if {@code true} remove outer square brackets + * @return {@link Inet6Address} or {@link Inet4Address} object constructed from + * literal IP address string. + * @throws UnknownHostException if literal IP address string cannot be parsed + * as IPv6, IPv4-mapped IPv6 or IPv4-compatible IPv6 address literals. + */ + static InetAddress parseAddressString(String addressLiteral, boolean removeSqBrackets) + throws UnknownHostException { + // Remove trailing and leading square brackets if requested + if (removeSqBrackets && addressLiteral.charAt(0) == '[' && + addressLiteral.length() > 2 && + addressLiteral.charAt(addressLiteral.length() - 1) == ']') { + addressLiteral = addressLiteral.substring(1, addressLiteral.length() - 1); + } + int pos, numericZone = -1; + String ifname = null; + if ((pos = addressLiteral.indexOf('%')) != -1) { + numericZone = checkNumericZone(addressLiteral); + if (numericZone == -1) { + /* remainder of string must be an ifname */ + ifname = addressLiteral.substring(pos + 1); + } + } + byte[] addrBytes = IPAddressUtil.textToNumericFormatV6(addressLiteral); + if (addrBytes == null) { + return null; + } + // IPv4-mapped IPv6 address + if (addrBytes.length == Inet4Address.INADDRSZ) { + if (numericZone != -1 || ifname != null) { + // IPv4-mapped address must not contain zone-id + throw new UnknownHostException(addressLiteral + ": invalid IPv4-mapped address"); + } + return new Inet4Address(null, addrBytes); + } + if (ifname != null) { + return new Inet6Address(null, addrBytes, ifname); + } else { + return new Inet6Address(null, addrBytes, numericZone); + } + } + + /** + * Check if the literal address string has %nn appended + * returns -1 if not, or the numeric value otherwise. + *

+ * %nn may also be a string that represents the displayName of + * a currently available NetworkInterface. + */ + private static int checkNumericZone(String s) { + int percent = s.indexOf('%'); + int slen = s.length(); + int digit, zone = 0; + int multmax = Integer.MAX_VALUE / 10; // for int overflow detection + if (percent == -1) { + return -1; + } + for (int i = percent + 1; i < slen; i++) { + char c = s.charAt(i); + if ((digit = IPAddressUtil.parseAsciiDigit(c, 10)) < 0) { + return -1; + } + if (zone > multmax) { + return -1; + } + zone = (zone * 10) + digit; + if (zone < 0) { + return -1; + } + + } + return zone; + } + private void initstr(String hostName, byte[] addr, String ifname) throws UnknownHostException { diff --git a/src/java.base/share/classes/java/net/InetAddress.java b/src/java.base/share/classes/java/net/InetAddress.java index 5062671a1ab61..90d75144a08ab 100644 --- a/src/java.base/share/classes/java/net/InetAddress.java +++ b/src/java.base/share/classes/java/net/InetAddress.java @@ -136,7 +136,7 @@ * *

Global addresses are unique across the internet. * - *

Textual representation of IP addresses

+ *

Textual representation of IP addresses

* * The textual representation of an IP address is address family specific. * @@ -1417,7 +1417,7 @@ private String removeComments(String hostsEntry) { byte[] addrArray; // check if IPV4 address - most likely try { - addrArray = IPAddressUtil.validateNumericFormatV4(addrStr); + addrArray = IPAddressUtil.validateNumericFormatV4(addrStr, false); } catch (IllegalArgumentException iae) { return null; } @@ -1644,51 +1644,29 @@ public static InetAddress[] getAllByName(String host) // Check and try to parse host string as an IP address literal if (IPAddressUtil.digit(host.charAt(0), 16) != -1 || (host.charAt(0) == ':')) { - byte[] addr = null; - int numericZone = -1; - String ifname = null; - + InetAddress inetAddress = null; if (!ipv6Expected) { // check if it is IPv4 address only if host is not wrapped in '[]' try { - addr = IPAddressUtil.validateNumericFormatV4(host); + // Here we check the address string for ambiguity only + inetAddress = Inet4Address.parseAddressString(host, false); } catch (IllegalArgumentException iae) { var uhe = new UnknownHostException(host); uhe.initCause(iae); throw uhe; } } - if (addr == null) { - // Try to parse host string as an IPv6 literal - // Check if a numeric or string zone id is present first - int pos; - if ((pos = host.indexOf('%')) != -1) { - numericZone = checkNumericZone(host); - if (numericZone == -1) { /* remainder of string must be an ifname */ - ifname = host.substring(pos + 1); - } - } - if ((addr = IPAddressUtil.textToNumericFormatV6(host)) == null && + if (inetAddress == null) { + // This is supposed to be an IPv6 literal + // Check for presence of a numeric or string zone id + // is done in Inet6Address.parseAddressString + if ((inetAddress = Inet6Address.parseAddressString(host, false)) == null && (host.contains(":") || ipv6Expected)) { throw invalidIPv6LiteralException(host, ipv6Expected); } } - if(addr != null) { - InetAddress[] ret = new InetAddress[1]; - if (addr.length == Inet4Address.INADDRSZ) { - if (numericZone != -1 || ifname != null) { - // IPv4-mapped address must not contain zone-id - throw new UnknownHostException(host + ": invalid IPv4-mapped address"); - } - ret[0] = new Inet4Address(null, addr); - } else { - if (ifname != null) { - ret[0] = new Inet6Address(null, addr, ifname); - } else { - ret[0] = new Inet6Address(null, addr, numericZone); - } - } - return ret; + if (inetAddress != null) { + return new InetAddress[]{inetAddress}; } } else if (ipv6Expected) { // We were expecting an IPv6 Literal since host string starts @@ -1718,39 +1696,6 @@ public static InetAddress getLoopbackAddress() { return impl.loopbackAddress(); } - - /** - * check if the literal address string has %nn appended - * returns -1 if not, or the numeric value otherwise. - * - * %nn may also be a string that represents the displayName of - * a currently available NetworkInterface. - */ - private static int checkNumericZone (String s) throws UnknownHostException { - int percent = s.indexOf ('%'); - int slen = s.length(); - int digit, zone=0; - int multmax = Integer.MAX_VALUE / 10; // for int overflow detection - if (percent == -1) { - return -1; - } - for (int i=percent+1; i multmax) { - return -1; - } - zone = (zone * 10) + digit; - if (zone < 0) { - return -1; - } - - } - return zone; - } - /** * package private so SocketPermission can call it */ @@ -1759,6 +1704,38 @@ static InetAddress[] getAllByName0 (String host, boolean check) return getAllByName0(host, check, true); } + /** + * Creates an {@code InetAddress} based on the provided {@linkplain InetAddress##format + * textual representation} of an IP address. + *

The provided IP address literal is parsed as + * {@linkplain Inet4Address#ofLiteral(String) an IPv4 address literal} first. + * If it cannot be parsed as an IPv4 address literal, then the method attempts + * to parse it as {@linkplain Inet6Address#ofLiteral(String) an IPv6 address literal}. + * If neither attempts succeed an {@code IllegalArgumentException} is thrown. + *

This method doesn't block, i.e. no reverse lookup is performed. + * + * @param ipAddressLiteral the textual representation of an IP address. + * @return an {@link InetAddress} object with no hostname set, and constructed + * from the provided IP address literal. + * @throws IllegalArgumentException if the {@code ipAddressLiteral} cannot be parsed + * as an IPv4 or IPv6 address literal. + * @throws NullPointerException if the {@code ipAddressLiteral} is {@code null}. + * @see Inet4Address#ofLiteral(String) + * @see Inet6Address#ofLiteral(String) + */ + public static InetAddress ofLiteral(String ipAddressLiteral) { + Objects.requireNonNull(ipAddressLiteral); + InetAddress inetAddress; + try { + // First try to parse the input as an IPv4 address literal + inetAddress = Inet4Address.ofLiteral(ipAddressLiteral); + } catch (IllegalArgumentException iae) { + // If it fails try to parse the input as an IPv6 address literal + inetAddress = Inet6Address.ofLiteral(ipAddressLiteral); + } + return inetAddress; + } + /** * Designated lookup method. * diff --git a/src/java.base/share/classes/sun/net/util/IPAddressUtil.java b/src/java.base/share/classes/sun/net/util/IPAddressUtil.java index 28a819cc938b6..d6a182fa088e2 100644 --- a/src/java.base/share/classes/sun/net/util/IPAddressUtil.java +++ b/src/java.base/share/classes/sun/net/util/IPAddressUtil.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 @@ -134,22 +134,41 @@ public static byte[] textToNumericFormatV4(String src) * If string can't be parsed by following IETF IPv4 address string literals * formatting style rules (default one), but can be parsed by following BSD formatting * style rules, the IPv4 address string content is treated as ambiguous and - * {@code IllegalArgumentException} is thrown. + * either {@code IllegalArgumentException} is thrown, or {@code null} is returned. * * @param src input string + * @param throwIAE {@code true} - throw {@code IllegalArgumentException} when cannot be parsed + * as IPv4 address string; + * {@code false} - throw {@code IllegalArgumentException} only when IPv4 address + * string is ambiguous. * @return bytes array if string is a valid IPv4 address string * @throws IllegalArgumentException if "jdk.net.allowAmbiguousIPAddressLiterals" SP is set to - * "false" and IPv4 address string {@code "src"} is ambiguous + * {@code false}, IPv4 address string {@code src} is ambiguous, + * or when address string cannot be parsed as an IPv4 address + * string and {@code throwIAE} is set to {@code true}. */ - public static byte[] validateNumericFormatV4(String src) { + public static byte[] validateNumericFormatV4(String src, boolean throwIAE) { byte[] parsedBytes = textToNumericFormatV4(src); if (!ALLOW_AMBIGUOUS_IPADDRESS_LITERALS_SP_VALUE && parsedBytes == null && isBsdParsableV4(src)) { - throw new IllegalArgumentException("Invalid IP address literal: " + src); + throw invalidIpAddressLiteral(src); + } + if (parsedBytes == null && throwIAE) { + throw invalidIpAddressLiteral(src); } return parsedBytes; } + /** + * Creates {@code IllegalArgumentException} with invalid IP address literal message. + * + * @param src address literal string to include to the exception message + * @return an {@code IllegalArgumentException} instance + */ + public static IllegalArgumentException invalidIpAddressLiteral(String src) { + return new IllegalArgumentException("Invalid IP address literal: " + src); + } + /* * Convert IPv6 presentation level address to network order binary form. * credit: diff --git a/test/jdk/java/net/InetAddress/OfLiteralTest.java b/test/jdk/java/net/InetAddress/OfLiteralTest.java new file mode 100644 index 0000000000000..90148a786af65 --- /dev/null +++ b/test/jdk/java/net/InetAddress/OfLiteralTest.java @@ -0,0 +1,310 @@ +/* + * 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 8272215 + * @summary Test for ofLiteral API in InetAddress classes + * @run junit/othervm -Djdk.net.hosts.file=nonExistingHostsFile.txt + * OfLiteralTest + * @run junit/othervm -Djdk.net.hosts.file=nonExistingHostsFile.txt + * -Djava.net.preferIPv4Stack=true + * OfLiteralTest + * @run junit/othervm -Djdk.net.hosts.file=nonExistingHostsFile.txt + * -Djava.net.preferIPv6Addresses=true + * OfLiteralTest + * @run junit/othervm -Djdk.net.hosts.file=nonExistingHostsFile.txt + * -Djava.net.preferIPv6Addresses=false + * OfLiteralTest + */ + +import org.junit.Assert; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.function.Executable; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.MethodSource; + +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class OfLiteralTest { + + @ParameterizedTest + @MethodSource("validLiteralArguments") + public void validLiteral(InetAddressClass inetAddressClass, + String addressLiteral, + byte[] expectedAddressBytes) throws Exception { + InetAddress ofLiteralResult = switch (inetAddressClass) { + case INET_ADDRESS -> InetAddress.ofLiteral(addressLiteral); + case INET4_ADDRESS -> Inet4Address.ofLiteral(addressLiteral); + case INET6_ADDRESS -> Inet6Address.ofLiteral(addressLiteral); + }; + InetAddress getByNameResult = InetAddress.getByName(addressLiteral); + Assert.assertArrayEquals(expectedAddressBytes, ofLiteralResult.getAddress()); + Assert.assertEquals(getByNameResult, ofLiteralResult); + } + + private static Stream validLiteralArguments() throws Exception { + // 1080:0:0:0:8:800:200C:417A address bytes + byte[] ipv6AddressExpBytes = new byte[]{16, -128, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 0, 32, 12, 65, 122}; + + // ::129.144.52.38 address bytes + byte[] ipv4CompIpv6ExpBytes = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -127, -112, 52, 38}; + + // 222.173.190.239 address bytes + byte[] ipv4ExpBytes = new byte[]{(byte) 222, (byte) 173, + (byte) 190, (byte) 239}; + + // 222.173.190.39 address bytes + byte[] ipv4ExpBytes2 = new byte[]{(byte) 222, (byte) 173, + (byte) 190, 39}; + + // 1.2.3.4 address bytes + byte[] oneToFourAddressExpBytes = new byte[]{1, 2, 3, 4}; + + // 6.7.8.9 address bytes + byte[] sixtoNineAddressExpBytes = new byte[]{6, 7, 8, 9}; + + // ::FFFF:129.144.52.38 address bytes + byte[] ipv6Ipv4MappedAddressExpBytes = new byte[]{ + (byte) 129, (byte) 144, 52, 38}; + + Stream validLiterals = Stream.of( + // IPv6 address literals are parsable by Inet6Address.ofLiteral + // and InetAddress.ofLiteral methods + Arguments.of(InetAddressClass.INET6_ADDRESS, + "1080:0:0:0:8:800:200C:417A", ipv6AddressExpBytes), + Arguments.of(InetAddressClass.INET_ADDRESS, + "[1080:0:0:0:8:800:200C:417A]", ipv6AddressExpBytes), + // Compressed series of zeros with square brackets + Arguments.of(InetAddressClass.INET6_ADDRESS, + "[1080::8:800:200C:417A]", ipv6AddressExpBytes), + // Compressed series of zeros without square brackets + Arguments.of(InetAddressClass.INET_ADDRESS, + "1080::8:800:200C:417A", ipv6AddressExpBytes), + // IPv4-mapped IPv6 address literals are parsable by + // InetAddress.ofLiteral and Inet6Address.ofLiteral methods + Arguments.of(InetAddressClass.INET_ADDRESS, + "::FFFF:129.144.52.38", ipv6Ipv4MappedAddressExpBytes), + Arguments.of(InetAddressClass.INET_ADDRESS, + "[::ffff:1.2.3.4]", oneToFourAddressExpBytes), + Arguments.of(InetAddressClass.INET6_ADDRESS, + "::FFFF:129.144.52.38", ipv6Ipv4MappedAddressExpBytes), + Arguments.of(InetAddressClass.INET6_ADDRESS, + "[::ffff:1.2.3.4]", oneToFourAddressExpBytes), + + // IPv4-compatible IPv6 address literals are parsable by + // Inet6Address.ofLiteral and InetAddress.ofLiteral methods + Arguments.of(InetAddressClass.INET6_ADDRESS, + "::129.144.52.38", ipv4CompIpv6ExpBytes), + Arguments.of(InetAddressClass.INET6_ADDRESS, + "[::129.144.52.38]", ipv4CompIpv6ExpBytes), + Arguments.of(InetAddressClass.INET_ADDRESS, + "::129.144.52.38", ipv4CompIpv6ExpBytes), + Arguments.of(InetAddressClass.INET_ADDRESS, + "[::129.144.52.38]", ipv4CompIpv6ExpBytes), + + // Tests for IPv4 address literal forms + // form:'d.d.d.d' method:Inet4Address.ofLiteral + Arguments.of(InetAddressClass.INET4_ADDRESS, + "222.173.190.239", ipv4ExpBytes), + // form:'d.d.d.d' with decimal octet with leading zero + Arguments.of(InetAddressClass.INET4_ADDRESS, + "222.173.190.039", ipv4ExpBytes2), + Arguments.of(InetAddressClass.INET4_ADDRESS, + "06.07.08.09", sixtoNineAddressExpBytes), + // form:'d.d.d.d' method:InetAddress.ofLiteral + Arguments.of(InetAddressClass.INET_ADDRESS, + "222.173.190.239", ipv4ExpBytes), + // form:'d.d.d' method:Inet4Address.ofLiteral + Arguments.of(InetAddressClass.INET4_ADDRESS, + "222.173.48879", ipv4ExpBytes), + // form:'d.d.d' method:InetAddress.ofLiteral + Arguments.of(InetAddressClass.INET_ADDRESS, + "222.173.48879", ipv4ExpBytes), + // form:'d.d' method:Inet4Address.ofLiteral + Arguments.of(InetAddressClass.INET4_ADDRESS, + "222.11386607", ipv4ExpBytes), + // form:'d.d' method:InetAddress.ofLiteral + Arguments.of(InetAddressClass.INET_ADDRESS, + "222.11386607", ipv4ExpBytes), + // form:'d' method:Inet4Address.ofLiteral + Arguments.of(InetAddressClass.INET4_ADDRESS, + "3735928559", ipv4ExpBytes), + // form:'d' method:InetAddress.ofLiteral + Arguments.of(InetAddressClass.INET_ADDRESS, + "3735928559", ipv4ExpBytes), + // form:'d' method:InetAddress.ofLiteral - + // with leading 0 that is discarded and address + // parsed as decimal + Arguments.of(InetAddressClass.INET_ADDRESS, + "03735928559", ipv4ExpBytes) + ); + + // Generate addresses for loopback and wildcard address test cases + var loopbackAndWildcardAddresses = List.of( + // Loopback address + InetAddress.getLoopbackAddress(), + // IPv6 wildcard address + InetAddress.getByName("::"), + // IPv4 wildcard address + InetAddress.getByName("0.0.0.0")); + + // Get addresses for all network interfaces available, + // and construct a test case for each. And then combine + // them with loopback/wildcard test cases. + Stream hostAddressArguments = Stream.concat( + NetworkInterface.networkInterfaces() + .flatMap(NetworkInterface::inetAddresses), + loopbackAndWildcardAddresses.stream()) + .flatMap(OfLiteralTest::addressToValidTestCases); + return Stream.concat(validLiterals, hostAddressArguments); + } + + @ParameterizedTest + @MethodSource("invalidLiteralArguments") + public void invalidLiteral(InetAddressClass inetAddressClass, + String addressLiteral) { + var executable = constructExecutable(inetAddressClass, addressLiteral); + var exception = assertThrows(IllegalArgumentException.class, executable); + System.err.println("Expected exception observed: " + exception); + } + + @ParameterizedTest + @EnumSource(InetAddressClass.class) + public void nullLiteral(InetAddressClass inetAddressClass) { + var executable = constructExecutable(inetAddressClass, null); + assertThrows(NullPointerException.class, executable); + } + + private static Stream invalidLiteralArguments() { + Stream argumentsStream = Stream.of( + // IPv4 address wrapped in square brackets + Arguments.of(InetAddressClass.INET_ADDRESS, "[1.2.3.4]"), + Arguments.of(InetAddressClass.INET4_ADDRESS, "[1.2.3.4]"), + Arguments.of(InetAddressClass.INET6_ADDRESS, "[1.2.3.4]"), + + // IPv4 address literal with BSD-formatting + Arguments.of(InetAddressClass.INET_ADDRESS, "1.2.3.0256"), + Arguments.of(InetAddressClass.INET4_ADDRESS, "1.2.3.0256"), + + // Invalid IPv4-mapped IPv6 address forms + // ::FFFF:d.d.d + Arguments.of(InetAddressClass.INET_ADDRESS, "::FFFF:1.2.3"), + Arguments.of(InetAddressClass.INET6_ADDRESS, "::FFFF:1.2.3"), + + // ::FFFF:d.d + Arguments.of(InetAddressClass.INET_ADDRESS, "::FFFF:1.2"), + Arguments.of(InetAddressClass.INET6_ADDRESS, "::FFFF:1.2"), + // ::d.d.d + Arguments.of(InetAddressClass.INET_ADDRESS, "::1.2.3"), + Arguments.of(InetAddressClass.INET6_ADDRESS, "::1.2.3"), + // ::d.d + Arguments.of(InetAddressClass.INET_ADDRESS, "::1.2"), + Arguments.of(InetAddressClass.INET6_ADDRESS, "::1.2"), + + // IPv4-mapped IPv6 address with scope-id + Arguments.of(InetAddressClass.INET6_ADDRESS, + "::FFFF:129.144.52.38%1"), + + // IPv4-mapped IPv6 addresses cannot be parsed by Inet4Address.ofLiteral + Arguments.of(InetAddressClass.INET4_ADDRESS, + "::FFFF:129.144.52.38"), + Arguments.of(InetAddressClass.INET4_ADDRESS, + "[::ffff:1.2.3.4]"), + + // IPv4 literals in BSD form + Arguments.of(InetAddressClass.INET_ADDRESS, "0256.1.2.3"), + Arguments.of(InetAddressClass.INET4_ADDRESS, "1.2.0256.3"), + Arguments.of(InetAddressClass.INET_ADDRESS, "0x1.2.3.4"), + Arguments.of(InetAddressClass.INET4_ADDRESS, "1.2.0x3.4"), + Arguments.of(InetAddressClass.INET_ADDRESS, "0xFFFFFFFF"), + Arguments.of(InetAddressClass.INET4_ADDRESS, "0xFFFFFFFF") + ); + // Construct arguments for a test case with IPv6-scoped address with scope-id + // specified as a string with non-existing network interface name + String ifName = generateNonExistingIfName(); + Stream nonExistingIFinScope = ifName.isBlank() ? Stream.empty() : + Stream.of(Arguments.of(InetAddressClass.INET6_ADDRESS, + "2001:db8:a0b:12f0::1%" + ifName)); + return Stream.concat(argumentsStream, nonExistingIFinScope); + } + + private static Stream addressToValidTestCases(InetAddress inetAddress) { + String addressLiteral = inetAddress.getHostAddress(); + byte[] expectedAddressBytes = inetAddress.getAddress(); + + InetAddressClass addressClass = switch (inetAddress) { + case Inet4Address i4 -> InetAddressClass.INET4_ADDRESS; + case Inet6Address i6 -> InetAddressClass.INET6_ADDRESS; + case InetAddress ia -> InetAddressClass.INET_ADDRESS; + }; + return Stream.of( + Arguments.of(InetAddressClass.INET_ADDRESS, addressLiteral, expectedAddressBytes), + Arguments.of(addressClass, addressLiteral, expectedAddressBytes)); + } + + private static String generateNonExistingIfName() { + try { + // At least two network interfaces are required to generate + // a non-existing interface name + if (NetworkInterface.networkInterfaces().count() < 2) { + return ""; + } + return NetworkInterface + .networkInterfaces() + .map(NetworkInterface::getName) + .collect(Collectors.joining()) + .strip(); + } catch (SocketException e) { + return ""; + } + } + + private static Executable constructExecutable(InetAddressClass inetAddressClass, String input) { + return switch (inetAddressClass) { + case INET_ADDRESS -> () -> InetAddress.ofLiteral(input); + case INET4_ADDRESS -> () -> Inet4Address.ofLiteral(input); + case INET6_ADDRESS -> () -> Inet6Address.ofLiteral(input); + }; + } + + enum InetAddressClass { + INET_ADDRESS, + INET4_ADDRESS, + INET6_ADDRESS + } +} + From 4a142c3b0831d60b3d5540f58973e8ad3d1304bf Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Thu, 26 Oct 2023 21:06:01 +0000 Subject: [PATCH 06/16] 8274122: java/io/File/createTempFile/SpecialTempFile.java fails in Windows 11 Reviewed-by: lancea, djelinski, rriggs --- test/jdk/ProblemList.txt | 1 - .../io/File/createTempFile/SpecialTempFile.java | 17 +++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index e264d4344f06f..c14ab9b7c8e4b 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -502,7 +502,6 @@ java/lang/instrument/RetransformBigClass.sh 8065756 generic- # jdk_io java/io/pathNames/GeneralWin32.java 8180264 windows-all -java/io/File/createTempFile/SpecialTempFile.java 8274122 windows11 ############################################################################ diff --git a/test/jdk/java/io/File/createTempFile/SpecialTempFile.java b/test/jdk/java/io/File/createTempFile/SpecialTempFile.java index a2fa85524a094..efbdc21577c0c 100644 --- a/test/jdk/java/io/File/createTempFile/SpecialTempFile.java +++ b/test/jdk/java/io/File/createTempFile/SpecialTempFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 8013827 8011950 8017212 8025128 + * @modules java.base/jdk.internal.util * @summary Check whether File.createTempFile can handle special parameters * @author Dan Xu */ @@ -32,10 +33,11 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; -public class SpecialTempFile { +import jdk.internal.util.OperatingSystem; +import jdk.internal.util.OSVersion; +public class SpecialTempFile { private static void test(String name, String[] prefix, String[] suffix, boolean exceptionExpected) throws IOException { @@ -48,7 +50,7 @@ private static void test(String name, String[] prefix, String[] suffix, final String exceptionMsg = "Unable to create temporary file"; String[] dirs = { null, "." }; - Path testPath = Paths.get(System.getProperty("test.dir", ".")); + Path testPath = Path.of(System.getProperty("test.dir", ".")); for (int i = 0; i < prefix.length; i++) { boolean exceptionThrown = false; File f = null; @@ -99,12 +101,15 @@ public static void main(String[] args) throws Exception { test("SlashedName", slashPre, slashSuf, true); // Windows tests - if (!System.getProperty("os.name").startsWith("Windows")) + if (!OperatingSystem.isWindows()) return; // Test JDK-8013827 String[] resvPre = { "LPT1.package.zip", "com7.4.package.zip" }; String[] resvSuf = { ".temp", ".temp" }; - test("ReservedName", resvPre, resvSuf, true); + boolean exceptionExpected = + !(System.getProperty("os.name").endsWith("11") || + new OSVersion(10, 0).compareTo(OSVersion.current()) > 0); + test("ReservedName", resvPre, resvSuf, exceptionExpected); } } From 9123961aaa47aa58ec436640590d2cceedb8cbb1 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Thu, 26 Oct 2023 22:43:06 +0000 Subject: [PATCH 07/16] 8318096: Introduce AsymmetricKey interface with a getParams method Reviewed-by: darcy, mullan, ascarpino --- .../classes/java/security/AsymmetricKey.java | 52 ++++++++++++++++ .../classes/java/security/PrivateKey.java | 4 +- .../classes/java/security/PublicKey.java | 4 +- .../java/security/interfaces/DSAParams.java | 5 +- .../security/interfaces/DSAPrivateKey.java | 16 ++++- .../security/interfaces/DSAPublicKey.java | 16 ++++- .../security/interfaces/ECPrivateKey.java | 17 +++++- .../java/security/interfaces/ECPublicKey.java | 17 +++++- .../security/interfaces/EdECPrivateKey.java | 17 +++++- .../security/interfaces/EdECPublicKey.java | 17 +++++- .../security/interfaces/RSAPrivateKey.java | 17 +++++- .../security/interfaces/RSAPublicKey.java | 17 +++++- .../security/interfaces/XECPrivateKey.java | 17 +++++- .../security/interfaces/XECPublicKey.java | 16 ++++- .../javax/crypto/interfaces/DHPrivateKey.java | 17 +++++- .../javax/crypto/interfaces/DHPublicKey.java | 17 +++++- .../classes/sun/security/pkcs11/P11Key.java | 6 +- .../security/AsymmetricKey/GetParams.java | 61 +++++++++++++++++++ 18 files changed, 313 insertions(+), 20 deletions(-) create mode 100644 src/java.base/share/classes/java/security/AsymmetricKey.java create mode 100644 test/jdk/java/security/AsymmetricKey/GetParams.java diff --git a/src/java.base/share/classes/java/security/AsymmetricKey.java b/src/java.base/share/classes/java/security/AsymmetricKey.java new file mode 100644 index 0000000000000..e96aeb4d84c71 --- /dev/null +++ b/src/java.base/share/classes/java/security/AsymmetricKey.java @@ -0,0 +1,52 @@ +/* + * 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. 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.security; + +import java.security.spec.AlgorithmParameterSpec; + +/** + * An asymmetric key, which can be either a public key or a private key. + * This interface contains methods that are common to either a public key or + * a private key. + * + * @since 22 + */ +public interface AsymmetricKey extends Key { + /** + * Returns the parameters associated with this key. + * The parameters are optional and may be either + * explicitly specified or implicitly created during + * key pair generation. + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return the associated parameters, may be {@code null} + */ + default AlgorithmParameterSpec getParams() { + return null; + } +} diff --git a/src/java.base/share/classes/java/security/PrivateKey.java b/src/java.base/share/classes/java/security/PrivateKey.java index 5d15278cd482f..045670ca00894 100644 --- a/src/java.base/share/classes/java/security/PrivateKey.java +++ b/src/java.base/share/classes/java/security/PrivateKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,7 @@ * @since 1.1 */ -public interface PrivateKey extends Key, javax.security.auth.Destroyable { +public interface PrivateKey extends AsymmetricKey, javax.security.auth.Destroyable { // Declare serialVersionUID to be compatible with JDK1.1 /** diff --git a/src/java.base/share/classes/java/security/PublicKey.java b/src/java.base/share/classes/java/security/PublicKey.java index c44d0e7a2d9e0..e93efaf1c5b30 100644 --- a/src/java.base/share/classes/java/security/PublicKey.java +++ b/src/java.base/share/classes/java/security/PublicKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ * */ -public interface PublicKey extends Key { +public interface PublicKey extends AsymmetricKey { // Declare serialVersionUID to be compatible with JDK1.1 /** * The class fingerprint that is set to indicate serialization diff --git a/src/java.base/share/classes/java/security/interfaces/DSAParams.java b/src/java.base/share/classes/java/security/interfaces/DSAParams.java index c2572e984d780..020709dcc525b 100644 --- a/src/java.base/share/classes/java/security/interfaces/DSAParams.java +++ b/src/java.base/share/classes/java/security/interfaces/DSAParams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -26,6 +26,7 @@ package java.security.interfaces; import java.math.BigInteger; +import java.security.spec.AlgorithmParameterSpec; /** * Interface to a DSA-specific set of key parameters, which defines a @@ -40,7 +41,7 @@ * @author Josh Bloch * @since 1.1 */ -public interface DSAParams { +public interface DSAParams extends AlgorithmParameterSpec { /** * Returns the prime, {@code p}. diff --git a/src/java.base/share/classes/java/security/interfaces/DSAPrivateKey.java b/src/java.base/share/classes/java/security/interfaces/DSAPrivateKey.java index a9682cd5e89ad..ea842b6e12e27 100644 --- a/src/java.base/share/classes/java/security/interfaces/DSAPrivateKey.java +++ b/src/java.base/share/classes/java/security/interfaces/DSAPrivateKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,4 +62,18 @@ public interface DSAPrivateKey extends DSAKey, java.security.PrivateKey { * @return the value of the private key, {@code x}. */ BigInteger getX(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default DSAParams getParams() { + return null; + } } diff --git a/src/java.base/share/classes/java/security/interfaces/DSAPublicKey.java b/src/java.base/share/classes/java/security/interfaces/DSAPublicKey.java index 5b05ed09b50db..9ddf6d8406fee 100644 --- a/src/java.base/share/classes/java/security/interfaces/DSAPublicKey.java +++ b/src/java.base/share/classes/java/security/interfaces/DSAPublicKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -62,4 +62,18 @@ public interface DSAPublicKey extends DSAKey, java.security.PublicKey { * @return the value of the public key, {@code y}. */ BigInteger getY(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default DSAParams getParams() { + return null; + } } diff --git a/src/java.base/share/classes/java/security/interfaces/ECPrivateKey.java b/src/java.base/share/classes/java/security/interfaces/ECPrivateKey.java index 2dca546978def..1694f46d4ab7c 100644 --- a/src/java.base/share/classes/java/security/interfaces/ECPrivateKey.java +++ b/src/java.base/share/classes/java/security/interfaces/ECPrivateKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ import java.math.BigInteger; import java.security.PrivateKey; +import java.security.spec.ECParameterSpec; /** * The interface to an elliptic curve (EC) private key. @@ -56,4 +57,18 @@ public interface ECPrivateKey extends PrivateKey, ECKey { * @return the private value S. */ BigInteger getS(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default ECParameterSpec getParams() { + return null; + } } diff --git a/src/java.base/share/classes/java/security/interfaces/ECPublicKey.java b/src/java.base/share/classes/java/security/interfaces/ECPublicKey.java index 4fec62eb3df0c..5e8efb90db5c5 100644 --- a/src/java.base/share/classes/java/security/interfaces/ECPublicKey.java +++ b/src/java.base/share/classes/java/security/interfaces/ECPublicKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package java.security.interfaces; import java.security.PublicKey; +import java.security.spec.ECParameterSpec; import java.security.spec.ECPoint; /** @@ -58,4 +59,18 @@ public interface ECPublicKey extends PublicKey, ECKey { * @return the public point W. */ ECPoint getW(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default ECParameterSpec getParams() { + return null; + } } diff --git a/src/java.base/share/classes/java/security/interfaces/EdECPrivateKey.java b/src/java.base/share/classes/java/security/interfaces/EdECPrivateKey.java index 826b52650eaf4..b3522fec4fe51 100644 --- a/src/java.base/share/classes/java/security/interfaces/EdECPrivateKey.java +++ b/src/java.base/share/classes/java/security/interfaces/EdECPrivateKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package java.security.interfaces; import java.security.PrivateKey; +import java.security.spec.NamedParameterSpec; import java.util.Optional; /** @@ -52,4 +53,18 @@ public interface EdECPrivateKey extends EdECKey, PrivateKey { * If the key is not available, then an empty {@code Optional}. */ Optional getBytes(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default NamedParameterSpec getParams() { + return null; + } } diff --git a/src/java.base/share/classes/java/security/interfaces/EdECPublicKey.java b/src/java.base/share/classes/java/security/interfaces/EdECPublicKey.java index d2e2641165122..664e76b6971fe 100644 --- a/src/java.base/share/classes/java/security/interfaces/EdECPublicKey.java +++ b/src/java.base/share/classes/java/security/interfaces/EdECPublicKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ import java.security.PublicKey; import java.security.spec.EdECPoint; +import java.security.spec.NamedParameterSpec; /** * An interface for an elliptic curve public key as defined by @@ -47,4 +48,18 @@ public interface EdECPublicKey extends EdECKey, PublicKey { * @return the {@code EdECPoint} representing the public key. */ EdECPoint getPoint(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default NamedParameterSpec getParams() { + return null; + } } diff --git a/src/java.base/share/classes/java/security/interfaces/RSAPrivateKey.java b/src/java.base/share/classes/java/security/interfaces/RSAPrivateKey.java index 9d7823c84c149..6e4ea536e32f9 100644 --- a/src/java.base/share/classes/java/security/interfaces/RSAPrivateKey.java +++ b/src/java.base/share/classes/java/security/interfaces/RSAPrivateKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package java.security.interfaces; import java.math.BigInteger; +import java.security.spec.AlgorithmParameterSpec; /** * The interface to an RSA private key. @@ -59,4 +60,18 @@ public interface RSAPrivateKey extends java.security.PrivateKey, RSAKey * @return the private exponent */ BigInteger getPrivateExponent(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default AlgorithmParameterSpec getParams() { + return null; + } } diff --git a/src/java.base/share/classes/java/security/interfaces/RSAPublicKey.java b/src/java.base/share/classes/java/security/interfaces/RSAPublicKey.java index cd1c44393f9d5..2e1d89723e4f8 100644 --- a/src/java.base/share/classes/java/security/interfaces/RSAPublicKey.java +++ b/src/java.base/share/classes/java/security/interfaces/RSAPublicKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package java.security.interfaces; import java.math.BigInteger; +import java.security.spec.AlgorithmParameterSpec; /** * The interface to an RSA public key. @@ -56,4 +57,18 @@ public interface RSAPublicKey extends java.security.PublicKey, RSAKey * @return the public exponent */ BigInteger getPublicExponent(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default AlgorithmParameterSpec getParams() { + return null; + } } diff --git a/src/java.base/share/classes/java/security/interfaces/XECPrivateKey.java b/src/java.base/share/classes/java/security/interfaces/XECPrivateKey.java index 547677786ae55..b555f587fb67d 100644 --- a/src/java.base/share/classes/java/security/interfaces/XECPrivateKey.java +++ b/src/java.base/share/classes/java/security/interfaces/XECPrivateKey.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 @@ -25,6 +25,7 @@ package java.security.interfaces; import java.security.PrivateKey; +import java.security.spec.AlgorithmParameterSpec; import java.util.Optional; /** @@ -53,5 +54,19 @@ public interface XECPrivateKey extends XECKey, PrivateKey { * and the private key is not allowed to leave the crypto boundary). */ Optional getScalar(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default AlgorithmParameterSpec getParams() { + return null; + } } diff --git a/src/java.base/share/classes/java/security/interfaces/XECPublicKey.java b/src/java.base/share/classes/java/security/interfaces/XECPublicKey.java index 6ec200beeb921..6b1806df0ebf8 100644 --- a/src/java.base/share/classes/java/security/interfaces/XECPublicKey.java +++ b/src/java.base/share/classes/java/security/interfaces/XECPublicKey.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 @@ -26,6 +26,7 @@ import java.math.BigInteger; import java.security.PublicKey; +import java.security.spec.AlgorithmParameterSpec; /** * An interface for an elliptic curve public key as defined by RFC 7748. @@ -52,5 +53,18 @@ public interface XECPublicKey extends XECKey, PublicKey { */ BigInteger getU(); + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default AlgorithmParameterSpec getParams() { + return null; + } } diff --git a/src/java.base/share/classes/javax/crypto/interfaces/DHPrivateKey.java b/src/java.base/share/classes/javax/crypto/interfaces/DHPrivateKey.java index 67deb7245a1e4..fb7d2f83108b7 100644 --- a/src/java.base/share/classes/javax/crypto/interfaces/DHPrivateKey.java +++ b/src/java.base/share/classes/javax/crypto/interfaces/DHPrivateKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package javax.crypto.interfaces; +import javax.crypto.spec.DHParameterSpec; import java.math.BigInteger; /** @@ -56,4 +57,18 @@ public interface DHPrivateKey extends DHKey, java.security.PrivateKey { * @return the private value, x */ BigInteger getX(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default DHParameterSpec getParams() { + return null; + } } diff --git a/src/java.base/share/classes/javax/crypto/interfaces/DHPublicKey.java b/src/java.base/share/classes/javax/crypto/interfaces/DHPublicKey.java index f0799bcc402b3..8785b8dfec84c 100644 --- a/src/java.base/share/classes/javax/crypto/interfaces/DHPublicKey.java +++ b/src/java.base/share/classes/javax/crypto/interfaces/DHPublicKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package javax.crypto.interfaces; +import javax.crypto.spec.DHParameterSpec; import java.math.BigInteger; /** @@ -56,4 +57,18 @@ public interface DHPublicKey extends DHKey, java.security.PublicKey { * @return the public value, y */ BigInteger getY(); + + /** + * {@inheritDoc java.security.AsymmetricKey} + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return {@inheritDoc java.security.AsymmetricKey} + * @since 22 + */ + @Override + default DHParameterSpec getParams() { + return null; + } } diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java index 6d0e7f7353e78..4406a77eafee2 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Key.java @@ -899,7 +899,8 @@ private synchronized void fetchValues() { params = new DSAParameterSpec(res[0], res[1], res[2]); } - protected DSAParams getParams() { + @Override + public DSAParams getParams() { fetchValues(); return params; } @@ -1202,7 +1203,8 @@ private synchronized void fetchValues() { } } - protected ECParameterSpec getParams() { + @Override + public ECParameterSpec getParams() { fetchValues(); return params; } diff --git a/test/jdk/java/security/AsymmetricKey/GetParams.java b/test/jdk/java/security/AsymmetricKey/GetParams.java new file mode 100644 index 0000000000000..5864ddc2e2cae --- /dev/null +++ b/test/jdk/java/security/AsymmetricKey/GetParams.java @@ -0,0 +1,61 @@ +/* + * 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. + */ + +import jdk.test.lib.Asserts; + +import javax.crypto.spec.DHParameterSpec; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.interfaces.DSAParams; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.ECParameterSpec; +import java.security.spec.NamedParameterSpec; + +/** + * @test + * @bug 8318096 + * @summary Introduce AsymmetricKey interface with a getParams method + * @library /test/lib + */ + +public class GetParams { + public static void main(String[] args) throws Exception { + test("DSA", DSAParams.class); + test("RSA", AlgorithmParameterSpec.class); + test("RSASSA-PSS", AlgorithmParameterSpec.class); + test("EC", ECParameterSpec.class); + test("DH", DHParameterSpec.class); + test("EdDSA", NamedParameterSpec.class); + test("XDH", NamedParameterSpec.class); + } + + static void test(String alg, Class clazz) + throws Exception { + KeyPairGenerator g = KeyPairGenerator.getInstance(alg); + KeyPair kp = g.generateKeyPair(); + AlgorithmParameterSpec spec1 = kp.getPrivate().getParams(); + Asserts.assertTrue(spec1 == null || clazz.isAssignableFrom(spec1.getClass())); + AlgorithmParameterSpec spec2 = kp.getPublic().getParams(); + Asserts.assertTrue(spec2 == null || clazz.isAssignableFrom(spec2.getClass())); + } +} From abad0408e8317b43c2cd5bc3d324ff199aa289f5 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Fri, 27 Oct 2023 06:55:25 +0000 Subject: [PATCH 08/16] 8313781: Add regression tests for large page logging and user-facing error messages Reviewed-by: sjohanss, dholmes --- .../runtime/os/HugePageConfiguration.java | 107 ++++++++---- .../os/TestHugePageDecisionsAtVMStartup.java | 157 ++++++++++++++++++ 2 files changed, 235 insertions(+), 29 deletions(-) create mode 100644 test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java diff --git a/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java b/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java index a0590b7739d7d..f475af4c2de5c 100644 --- a/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java +++ b/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java @@ -30,17 +30,46 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +// This class allows us to parse system hugepage config from +// - a) the Operating System (the truth) +// - b) the JVM log (-Xlog:pagesize) +// This is used e.g. in TestHugePageDetection to determine if the JVM detects the correct settings from the OS. class HugePageConfiguration { - Set _staticHugePageSizes; - long _staticDefaultHugePageSize; + public static class StaticHugePageConfig implements Comparable { + public long pageSize = -1; + public long nr_hugepages = -1; + public long nr_overcommit_hugepages = -1; - enum THPMode {always, never, madvise, unknown} + @Override + public int hashCode() { + return Objects.hash(pageSize); + } + + @Override + public String toString() { + return "StaticHugePageConfig{" + + "pageSize=" + pageSize + + ", nr_hugepages=" + nr_hugepages + + ", nr_overcommit_hugepages=" + nr_overcommit_hugepages + + '}'; + } + + @Override + public int compareTo(StaticHugePageConfig o) { + return (int) (pageSize - o.pageSize); + } + } + + Set _staticHugePageConfigurations; + long _staticDefaultHugePageSize = -1; + + enum THPMode {always, never, madvise} THPMode _thpMode; long _thpPageSize; - public Set getStaticHugePageSizes() { - return _staticHugePageSizes; + public Set getStaticHugePageConfigurations() { + return _staticHugePageConfigurations; } public long getStaticDefaultHugePageSize() { @@ -55,8 +84,18 @@ public long getThpPageSize() { return _thpPageSize; } - public HugePageConfiguration(Set _staticHugePageSizes, long _staticDefaultHugePageSize, THPMode _thpMode, long _thpPageSize) { - this._staticHugePageSizes = _staticHugePageSizes; + // Returns true if the THP support is enabled + public boolean supportsTHP() { + return _thpMode == THPMode.always || _thpMode == THPMode.madvise; + } + + // Returns true if static huge pages are supported (whether or not we have configured the pools) + public boolean supportsStaticHugePages() { + return _staticDefaultHugePageSize > 0 && _staticHugePageConfigurations.size() > 0; + } + + public HugePageConfiguration(Set _staticHugePageConfigurations, long _staticDefaultHugePageSize, THPMode _thpMode, long _thpPageSize) { + this._staticHugePageConfigurations = _staticHugePageConfigurations; this._staticDefaultHugePageSize = _staticDefaultHugePageSize; this._thpMode = _thpMode; this._thpPageSize = _thpPageSize; @@ -65,7 +104,7 @@ public HugePageConfiguration(Set _staticHugePageSizes, long _staticDefault @Override public String toString() { return "Configuration{" + - "_staticHugePageSizes=" + _staticHugePageSizes + + "_staticHugePageConfigurations=" + _staticHugePageConfigurations + ", _staticDefaultHugePageSize=" + _staticDefaultHugePageSize + ", _thpMode=" + _thpMode + ", _thpPageSize=" + _thpPageSize + @@ -77,12 +116,8 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; HugePageConfiguration that = (HugePageConfiguration) o; - return _staticDefaultHugePageSize == that._staticDefaultHugePageSize && _thpPageSize == that._thpPageSize && Objects.equals(_staticHugePageSizes, that._staticHugePageSizes) && _thpMode == that._thpMode; - } - - @Override - public int hashCode() { - return Objects.hash(_staticHugePageSizes, _staticDefaultHugePageSize, _thpMode, _thpPageSize); + return _staticDefaultHugePageSize == that._staticDefaultHugePageSize && _thpPageSize == that._thpPageSize && + Objects.equals(_staticHugePageConfigurations, that._staticHugePageConfigurations) && _thpMode == that._thpMode; } private static long readDefaultHugePageSizeFromOS() { @@ -102,25 +137,36 @@ private static long readDefaultHugePageSizeFromOS() { return 0; } - private static Set readSupportedHugePagesFromOS() { - TreeSet pagesizes = new TreeSet<>(); + private static Set readSupportedHugePagesFromOS() throws IOException { + TreeSet hugePageConfigs = new TreeSet<>(); Pattern pat = Pattern.compile("hugepages-(\\d+)kB"); File[] subdirs = new File("/sys/kernel/mm/hugepages").listFiles(); if (subdirs != null) { - for (File f : subdirs) { - String name = f.getName(); + for (File subdir : subdirs) { + String name = subdir.getName(); Matcher mat = pat.matcher(name); if (mat.matches()) { - long pagesize = Long.parseLong(mat.group(1)) * 1024; - pagesizes.add(pagesize); + StaticHugePageConfig config = new StaticHugePageConfig(); + config.pageSize = Long.parseLong(mat.group(1)) * 1024; + try (FileReader fr = new FileReader(subdir.getAbsolutePath() + "/nr_hugepages"); + BufferedReader reader = new BufferedReader(fr)) { + String s = reader.readLine(); + config.nr_hugepages = Long.parseLong(s); + } + try (FileReader fr = new FileReader(subdir.getAbsolutePath() + "/nr_overcommit_hugepages"); + BufferedReader reader = new BufferedReader(fr)) { + String s = reader.readLine(); + config.nr_overcommit_hugepages = Long.parseLong(s); + } + hugePageConfigs.add(config); } } } - return pagesizes; + return hugePageConfigs; } private static THPMode readTHPModeFromOS() { - THPMode mode = THPMode.unknown; + THPMode mode = THPMode.never; String file = "/sys/kernel/mm/transparent_hugepage/enabled"; try (FileReader fr = new FileReader(file); BufferedReader reader = new BufferedReader(fr)) { @@ -136,7 +182,8 @@ private static THPMode readTHPModeFromOS() { } } catch (IOException e) { System.out.println("Failed to read " + file); - mode = THPMode.unknown; + // Happens when the kernel is not built to support THPs. + mode = THPMode.never; } return mode; } @@ -148,19 +195,19 @@ private static long readTHPPageSizeFromOS() { BufferedReader reader = new BufferedReader(fr)) { String s = reader.readLine(); pagesize = Long.parseLong(s); - } catch (IOException | NumberFormatException e) { /* ignored */ } + } catch (IOException | NumberFormatException e) { } // ignored return pagesize; } // Fill object with info read from proc file system - public static HugePageConfiguration readFromOS() { + public static HugePageConfiguration readFromOS() throws IOException { return new HugePageConfiguration(readSupportedHugePagesFromOS(), readDefaultHugePageSizeFromOS(), readTHPModeFromOS(), readTHPPageSizeFromOS()); } - private static long parseSIUnit(String num, String unit) { + public static long parseSIUnit(String num, String unit) { long n = Long.parseLong(num); return switch (unit) { case "K" -> n * 1024; @@ -180,7 +227,7 @@ public static HugePageConfiguration readFromJVMLog(OutputAnalyzer output) { // [0.001s][info][pagesize] Transparent hugepage (THP) support: // [0.001s][info][pagesize] THP mode: madvise // [0.001s][info][pagesize] THP pagesize: 2M - TreeSet hugepages = new TreeSet<>(); + TreeSet staticHugePageConfigs = new TreeSet<>(); long defaultHugepageSize = 0; THPMode thpMode = THPMode.never; long thpPageSize = 0; @@ -192,7 +239,9 @@ public static HugePageConfiguration readFromJVMLog(OutputAnalyzer output) { for (String s : lines) { Matcher mat = patternHugepageSize.matcher(s); if (mat.matches()) { - hugepages.add(parseSIUnit(mat.group(1), mat.group(2))); + StaticHugePageConfig config = new StaticHugePageConfig(); + config.pageSize = parseSIUnit(mat.group(1), mat.group(2)); + staticHugePageConfigs.add(config); continue; } if (defaultHugepageSize == 0) { @@ -215,7 +264,7 @@ public static HugePageConfiguration readFromJVMLog(OutputAnalyzer output) { } } - return new HugePageConfiguration(hugepages, defaultHugepageSize, thpMode, thpPageSize); + return new HugePageConfiguration(staticHugePageConfigs, defaultHugepageSize, thpMode, thpPageSize); } } diff --git a/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java b/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java new file mode 100644 index 0000000000000..e93309c0b0032 --- /dev/null +++ b/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 + * 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 id=Default + * @summary Test JVM large page setup (default options) + * @library /test/lib + * @requires os.family == "linux" + * @modules java.base/jdk.internal.misc + * java.management + * @run driver TestHugePageDecisionsAtVMStartup + */ + +/* + * @test id=LP_enabled + * @summary Test JVM large page setup (+LP) + * @library /test/lib + * @requires os.family == "linux" + * @modules java.base/jdk.internal.misc + * java.management + * @run driver TestHugePageDecisionsAtVMStartup -XX:+UseLargePages + */ + +/* + * @test id=THP_enabled + * @summary Test JVM large page setup (+THP) + * @library /test/lib + * @requires os.family == "linux" + * @modules java.base/jdk.internal.misc + * java.management + * @run driver TestHugePageDecisionsAtVMStartup -XX:+UseTransparentHugePages + */ + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +public class TestHugePageDecisionsAtVMStartup { + + // End user warnings, printing with Xlog:pagesize at warning level, should be unconditional + static final String warningNoTHP = "[warning][pagesize] UseTransparentHugePages disabled, transparent huge pages are not supported by the operating system."; + static final String warningNoLP = "[warning][pagesize] UseLargePages disabled, no large pages configured and available on the system."; + + static final String buildSizeString(long l) { + String units[] = { "K", "M", "G" }; + long factor = 1024 * 1024 * 1024; + for (int i = 2; i >= 0; i--) { + if (l >= factor) { + return Long.toString(l / factor) + units[i]; + } + factor /= 1024; + } + return Long.toString(l) + "B"; + } + + static void testOutput(boolean useLP, boolean useTHP, OutputAnalyzer out, HugePageConfiguration configuration) { + + // Note: If something goes wrong, the JVM warns but continues, so we should never see an exit value != 0 + out.shouldHaveExitValue(0); + + // Static hugepages: + // Let X = the default hugepage size of the system (the one in /proc/meminfo). + // The JVM will cycle through page sizes, starting at X, down to the smallest hugepage size. + // + // Example 1: a system with 1GB and 2MB pages, the default hugepage size is 1GB (can only be done + // via kernel parameter). the JVM should first attempt to use 1GB pages, failing that should try 2MB, failing + // that give up and disable -UseLargePages. + // + // Example 1: same system, but the default hugepage size is 2MB. The JVM should not attempt to use 1GB pages. + // + // This picture gets more complex with -XX:LargePageSizeInBytes, which overrides the default + // large page size; but we ignore this for now (feel free to extend the test to cover LBSiB too). + + boolean haveUsableStaticHugePages = false; + if (configuration.supportsStaticHugePages()) { + long defaultLargePageSize = configuration.getStaticDefaultHugePageSize(); + Set configs = configuration.getStaticHugePageConfigurations(); + for (HugePageConfiguration.StaticHugePageConfig config: configs) { + if (config.pageSize <= defaultLargePageSize) { + if (config.nr_hugepages > 0 || config.nr_overcommit_hugepages > 0) { + haveUsableStaticHugePages = true; break; + } + } + } + } + + if (useTHP && !useLP) { + useLP = true; // its implicit + } + + if (!useLP) { + out.shouldContain("[info][pagesize] Large page support disabled"); + } else if (useLP && !useTHP && + (!configuration.supportsStaticHugePages() || !haveUsableStaticHugePages)) { + out.shouldContain(warningNoLP); + } else if (useLP && useTHP && !configuration.supportsTHP()) { + out.shouldContain(warningNoTHP); + } else if (useLP && !useTHP && + configuration.supportsStaticHugePages() && haveUsableStaticHugePages) { + out.shouldContain("[info][pagesize] Using the default large page size: " + buildSizeString(configuration.getStaticDefaultHugePageSize())); + out.shouldContain("[info][pagesize] UseLargePages=1, UseTransparentHugePages=0"); + out.shouldContain("[info][pagesize] Large page support enabled"); + } else if (useLP && useTHP && configuration.supportsTHP()) { + String thpPageSizeString = buildSizeString(configuration.getThpPageSize()); + // We expect to see exactly two "Usable page sizes" : the system page size and the THP page size. The system + // page size differs, but its always in KB). + out.shouldContain("[info][pagesize] UseLargePages=1, UseTransparentHugePages=1"); + out.shouldMatch(".*\\[info]\\[pagesize] Large page support enabled. Usable page sizes: \\d+[kK], " + thpPageSizeString + ". Default large page size: " + thpPageSizeString + ".*"); + } + } + + public static void main(String[] extraOptions) throws Exception { + List allOptions = new ArrayList(); + if (extraOptions != null) { + allOptions.addAll(Arrays.asList(extraOptions)); + } + allOptions.add("-Xmx128m"); + allOptions.add("-Xlog:pagesize"); + allOptions.add("-version"); + + boolean useLP = allOptions.contains("-XX:+UseLargePages"); + boolean useTHP = allOptions.contains("-XX:+UseTransparentHugePages"); + System.out.println("useLP: " + useLP + " useTHP: " + useTHP); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(allOptions.toArray(new String[0])); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.reportDiagnosticSummary(); + HugePageConfiguration configuration = HugePageConfiguration.readFromOS(); + System.out.println("configuration read from OS:" + configuration); + + testOutput(useLP, useTHP, output, configuration); + } +} From 5b5fd3694ac6ef224af311a7ab62547dac976da4 Mon Sep 17 00:00:00 2001 From: William Kemper Date: Fri, 27 Oct 2023 08:18:38 +0000 Subject: [PATCH 09/16] 8316632: Shenandoah: Raise OOME when gc threshold is exceeded Reviewed-by: kdnilsen, ysr, shade --- .../gc/shenandoah/shenandoahControlThread.cpp | 11 +++++---- .../gc/shenandoah/shenandoahControlThread.hpp | 9 ++++---- .../share/gc/shenandoah/shenandoahHeap.cpp | 23 +++++++++++++++++-- .../share/gc/shenandoah/shenandoahHeap.hpp | 8 ++++--- .../gc/shenandoah/shenandoahHeap.inline.hpp | 12 ++++++++++ .../gc/shenandoah/shenandoah_globals.hpp | 5 ++++ test/jdk/com/sun/jdi/EATests.java | 22 +++++++++++++----- 7 files changed, 71 insertions(+), 19 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp index 3b755e4366a6e..80c9189e93814 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp @@ -524,7 +524,7 @@ void ShenandoahControlThread::handle_requested_gc(GCCause::Cause cause) { } } -void ShenandoahControlThread::handle_alloc_failure(ShenandoahAllocRequest& req) { +void ShenandoahControlThread::handle_alloc_failure(ShenandoahAllocRequest& req, bool block) { ShenandoahHeap* heap = ShenandoahHeap::heap(); assert(current()->is_Java_thread(), "expect Java thread here"); @@ -539,9 +539,12 @@ void ShenandoahControlThread::handle_alloc_failure(ShenandoahAllocRequest& req) heap->cancel_gc(GCCause::_allocation_failure); } - MonitorLocker ml(&_alloc_failure_waiters_lock); - while (is_alloc_failure_gc()) { - ml.wait(); + + if (block) { + MonitorLocker ml(&_alloc_failure_waiters_lock); + while (is_alloc_failure_gc()) { + ml.wait(); + } } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp index 782b134a4495f..544c504b4fa6c 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp @@ -121,12 +121,13 @@ class ShenandoahControlThread: public ConcurrentGCThread { ShenandoahControlThread(); ~ShenandoahControlThread(); - // Handle allocation failure from normal allocation. - // Blocks until memory is available. - void handle_alloc_failure(ShenandoahAllocRequest& req); + // Handle allocation failure from a mutator allocation. + // Optionally blocks while collector is handling the failure. If the GC + // threshold has been exceeded, the mutator allocation will not block so + // that the out of memory error can be raised promptly. + void handle_alloc_failure(ShenandoahAllocRequest& req, bool block = true); // Handle allocation failure from evacuation path. - // Optionally blocks while collector is handling the failure. void handle_alloc_failure_evac(size_t words); void request_gc(GCCause::Cause cause); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 13f9d430ca56a..3426aba9d94ad 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -503,6 +503,7 @@ ShenandoahHeap::ShenandoahHeap(ShenandoahCollectorPolicy* policy) : _num_regions(0), _regions(nullptr), _update_refs_iterator(this), + _gc_no_progress_count(0), _control_thread(nullptr), _shenandoah_policy(policy), _gc_mode(nullptr), @@ -873,7 +874,19 @@ HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req) { result = allocate_memory_under_lock(req, in_new_region); } - // Allocation failed, block until control thread reacted, then retry allocation. + // Check that gc overhead is not exceeded. + // + // Shenandoah will grind along for quite a while allocating one + // object at a time using shared (non-tlab) allocations. This check + // is testing that the GC overhead limit has not been exceeded. + // This will notify the collector to start a cycle, but will raise + // an OOME to the mutator if the last Full GCs have not made progress. + if (result == nullptr && !req.is_lab_alloc() && get_gc_no_progress_count() > ShenandoahNoProgressThreshold) { + control_thread()->handle_alloc_failure(req, false); + return nullptr; + } + + // Block until control thread reacted, then retry allocation. // // It might happen that one of the threads requesting allocation would unblock // way later after GC happened, only to fail the second allocation, because @@ -882,10 +895,16 @@ HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req) { // one full GC has completed). size_t original_count = shenandoah_policy()->full_gc_count(); while (result == nullptr - && (_progress_last_gc.is_set() || original_count == shenandoah_policy()->full_gc_count())) { + && (get_gc_no_progress_count() == 0 || original_count == shenandoah_policy()->full_gc_count())) { control_thread()->handle_alloc_failure(req); result = allocate_memory_under_lock(req, in_new_region); } + + if (log_is_enabled(Debug, gc, alloc)) { + ResourceMark rm; + log_debug(gc, alloc)("Thread: %s, Result: " PTR_FORMAT ", Request: %s, Size: " SIZE_FORMAT ", Original: " SIZE_FORMAT ", Latest: " SIZE_FORMAT, + Thread::current()->name(), p2i(result), req.type_string(), req.size(), original_count, get_gc_no_progress_count()); + } } else { assert(req.is_gc_alloc(), "Can only accept GC allocs here"); result = allocate_memory_under_lock(req, in_new_region); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index 9e837189de87f..f5030efa74879 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -287,9 +287,10 @@ class ShenandoahHeap : public CollectedHeap, public ShenandoahSpaceInfo { ShenandoahSharedFlag _degenerated_gc_in_progress; ShenandoahSharedFlag _full_gc_in_progress; ShenandoahSharedFlag _full_gc_move_in_progress; - ShenandoahSharedFlag _progress_last_gc; ShenandoahSharedFlag _concurrent_strong_root_in_progress; + size_t _gc_no_progress_count; + void set_gc_state_all_threads(char state); void set_gc_state_mask(uint mask, bool value); @@ -370,8 +371,9 @@ class ShenandoahHeap : public CollectedHeap, public ShenandoahSpaceInfo { void rendezvous_threads(); void recycle_trash(); public: - void notify_gc_progress() { _progress_last_gc.set(); } - void notify_gc_no_progress() { _progress_last_gc.unset(); } + void notify_gc_progress(); + void notify_gc_no_progress(); + size_t get_gc_no_progress_count() const; // // Mark support diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp index 4689e27477340..0c21fdd486b02 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp @@ -73,6 +73,18 @@ inline WorkerThreads* ShenandoahHeap::safepoint_workers() { return _safepoint_workers; } +inline void ShenandoahHeap::notify_gc_progress() { + Atomic::store(&_gc_no_progress_count, (size_t) 0); + +} +inline void ShenandoahHeap::notify_gc_no_progress() { + Atomic::inc(&_gc_no_progress_count); +} + +inline size_t ShenandoahHeap::get_gc_no_progress_count() const { + return Atomic::load(&_gc_no_progress_count); +} + inline size_t ShenandoahHeap::heap_region_index_containing(const void* addr) const { uintptr_t region_start = ((uintptr_t) addr); uintptr_t index = (region_start - (uintptr_t) base()) >> ShenandoahHeapRegion::region_size_bytes_shift(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp index 6b5519a92e1a2..1ac9047706dc3 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp @@ -294,6 +294,11 @@ "How many back-to-back Degenerated GCs should happen before " \ "going to a Full GC.") \ \ + product(uintx, ShenandoahNoProgressThreshold, 5, EXPERIMENTAL, \ + "After this number of consecutive Full GCs fail to make " \ + "progress, Shenandoah will raise out of memory errors. Note " \ + "that progress is determined by ShenandoahCriticalFreeThreshold") \ + \ product(bool, ShenandoahImplicitGCInvokesConcurrent, false, EXPERIMENTAL, \ "Should internally-caused GC requests invoke concurrent cycles, " \ "should they do the stop-the-world (Degenerated / Full GC)? " \ diff --git a/test/jdk/com/sun/jdi/EATests.java b/test/jdk/com/sun/jdi/EATests.java index 84ec23b263c65..67351e36cb77d 100644 --- a/test/jdk/com/sun/jdi/EATests.java +++ b/test/jdk/com/sun/jdi/EATests.java @@ -272,6 +272,7 @@ public static class TargetVMOptions { public final boolean DeoptimizeObjectsALot; public final boolean DoEscapeAnalysis; public final boolean ZGCIsSelected; + public final boolean ShenandoahGCIsSelected; public final boolean StressReflectiveCode; public TargetVMOptions(EATests env, ClassType testCaseBaseTargetClass) { @@ -287,6 +288,8 @@ public TargetVMOptions(EATests env, ClassType testCaseBaseTargetClass) { UseJVMCICompiler = ((PrimitiveValue) val).booleanValue(); val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("ZGCIsSelected")); ZGCIsSelected = ((PrimitiveValue) val).booleanValue(); + val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("ShenandoahGCIsSelected")); + ShenandoahGCIsSelected = ((PrimitiveValue) val).booleanValue(); val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("StressReflectiveCode")); StressReflectiveCode = ((PrimitiveValue) val).booleanValue(); } @@ -773,6 +776,7 @@ public static boolean unbox(Boolean value, boolean dflt) { public static final boolean EliminateAllocations = unbox(WB.getBooleanVMFlag("EliminateAllocations"), UseJVMCICompiler); public static final boolean DeoptimizeObjectsALot = WB.getBooleanVMFlag("DeoptimizeObjectsALot"); public static final boolean ZGCIsSelected = GC.Z.isSelected(); + public static final boolean ShenandoahGCIsSelected = GC.Shenandoah.isSelected(); public static final boolean StressReflectiveCode = unbox(WB.getBooleanVMFlag("StressReflectiveCode"), false); public String testMethodName; @@ -2450,8 +2454,9 @@ public boolean shouldSkip() { // And Graal currently doesn't provide all information about non-escaping objects in debug info return super.shouldSkip() || !env.targetVMOptions.EliminateAllocations || - // With ZGC the OOME is not always thrown as expected + // With ZGC or Shenandoah the OOME is not always thrown as expected env.targetVMOptions.ZGCIsSelected || + env.targetVMOptions.ShenandoahGCIsSelected || env.targetVMOptions.DeoptimizeObjectsALot || env.targetVMOptions.UseJVMCICompiler; } @@ -2495,8 +2500,9 @@ public boolean shouldSkip() { // And Graal currently doesn't provide all information about non-escaping objects in debug info return super.shouldSkip() || !EliminateAllocations || - // With ZGC the OOME is not always thrown as expected + // With ZGC or Shenandoah the OOME is not always thrown as expected ZGCIsSelected || + ShenandoahGCIsSelected || DeoptimizeObjectsALot || UseJVMCICompiler; } @@ -2548,8 +2554,9 @@ public boolean shouldSkip() { // And Graal currently doesn't provide all information about non-escaping objects in debug info return super.shouldSkip() || !env.targetVMOptions.EliminateAllocations || - // With ZGC the OOME is not always thrown as expected + // With ZGC or Shenandoah the OOME is not always thrown as expected env.targetVMOptions.ZGCIsSelected || + env.targetVMOptions.ShenandoahGCIsSelected || env.targetVMOptions.DeoptimizeObjectsALot || env.targetVMOptions.UseJVMCICompiler; } @@ -2609,8 +2616,9 @@ public boolean shouldSkip() { // And Graal currently doesn't provide all information about non-escaping objects in debug info return super.shouldSkip() || !EliminateAllocations || - // With ZGC the OOME is not always thrown as expected + // With ZGC or Shenandoah the OOME is not always thrown as expected ZGCIsSelected || + ShenandoahGCIsSelected || DeoptimizeObjectsALot || UseJVMCICompiler; } @@ -2815,8 +2823,9 @@ public boolean shouldSkip() { // And Graal currently doesn't support Force Early Return return super.shouldSkip() || !env.targetVMOptions.EliminateAllocations || - // With ZGC the OOME is not always thrown as expected + // With ZGC or Shenandoah the OOME is not always thrown as expected env.targetVMOptions.ZGCIsSelected || + env.targetVMOptions.ShenandoahGCIsSelected || env.targetVMOptions.DeoptimizeObjectsALot || env.targetVMOptions.UseJVMCICompiler; } @@ -2877,8 +2886,9 @@ public boolean shouldSkip() { // And Graal currently doesn't support Force Early Return return super.shouldSkip() || !EliminateAllocations || - // With ZGC the OOME is not always thrown as expected + // With ZGC or Shenandoah the OOME is not always thrown as expected ZGCIsSelected || + ShenandoahGCIsSelected || DeoptimizeObjectsALot || UseJVMCICompiler; } From 957703b1f960d739a4a95dd5d8fcb97d41907e5f Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Fri, 27 Oct 2023 08:37:19 +0000 Subject: [PATCH 10/16] 8307168: Inconsistent validation and handling of --system flag arguments Reviewed-by: jjg --- .../com/sun/tools/javac/file/Locations.java | 21 ++++++++---- .../options/smokeTests/OptionSmokeTest.java | 32 +++++++++++++++++-- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java index f64f19c305495..9da2052b9f3bf 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1906,9 +1906,12 @@ private List checkPaths(Iterable paths) throws IOException } private void update(Path p) { - if (!isCurrentPlatform(p) && !Files.exists(p.resolve("lib").resolve("jrt-fs.jar")) && - !Files.exists(systemJavaHome.resolve("modules"))) - throw new IllegalArgumentException(p.toString()); + if (!isCurrentPlatform(p)) { + var noJavaRuntimeFS = Files.notExists(resolveInJavaHomeLib(p, "jrt-fs.jar")); + var noModulesFile = Files.notExists(resolveInJavaHomeLib(p, "modules")); + if (noJavaRuntimeFS || noModulesFile) + throw new IllegalArgumentException(p.toString()); + } systemJavaHome = p; modules = null; } @@ -1921,6 +1924,10 @@ private boolean isCurrentPlatform(Path p) { } } + private static Path resolveInJavaHomeLib(Path javaHomePath, String name) { + return javaHomePath.resolve("lib").resolve(name); + } + @Override Location getLocationForModule(String name) throws IOException { initSystemModules(); @@ -1967,10 +1974,10 @@ private void initSystemModules() throws IOException { Collections.singletonMap("java.home", systemJavaHome.toString()); jrtfs = FileSystems.newFileSystem(jrtURI, attrMap); } catch (ProviderNotFoundException ex) { - URL javaHomeURL = systemJavaHome.resolve("jrt-fs.jar").toUri().toURL(); + URL jfsJar = resolveInJavaHomeLib(systemJavaHome, "jrt-fs.jar").toUri().toURL(); ClassLoader currentLoader = Locations.class.getClassLoader(); URLClassLoader fsLoader = - new URLClassLoader(new URL[] {javaHomeURL}, currentLoader); + new URLClassLoader(new URL[] {jfsJar}, currentLoader); jrtfs = FileSystems.newFileSystem(jrtURI, Collections.emptyMap(), fsLoader); @@ -1982,7 +1989,7 @@ private void initSystemModules() throws IOException { modules = jrtfs.getPath("/modules"); } catch (FileSystemNotFoundException | ProviderNotFoundException e) { - modules = systemJavaHome.resolve("modules"); + modules = resolveInJavaHomeLib(systemJavaHome, "modules"); if (!Files.exists(modules)) throw new IOException("can't find system classes", e); } diff --git a/test/langtools/tools/javac/options/smokeTests/OptionSmokeTest.java b/test/langtools/tools/javac/options/smokeTests/OptionSmokeTest.java index 238baf2a6140d..f128bf14f7fba 100644 --- a/test/langtools/tools/javac/options/smokeTests/OptionSmokeTest.java +++ b/test/langtools/tools/javac/options/smokeTests/OptionSmokeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test - * @bug 8196433 + * @bug 8196433 8307168 * @summary use the new error diagnostic approach at javac.Main * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api @@ -255,6 +255,34 @@ public void releaseAndBootclasspath(Path base) throws Exception { String.format("--release %s --upgrade-module-path any", Source.DEFAULT.name)); } + @Test + public void consistentSystemOptionHandlingWithAnEmptyDirectory(Path base) throws Exception { + tb.createDirectories(base); + doTestNoSource(base, "error: illegal argument for --system: %s".formatted(base), String.format("--system %s", base)); + } + + @Test + public void consistentSystemOptionHandlingWithLibJrtFsJar(Path base) throws Exception { + tb.createDirectories(base); + tb.writeFile(base.resolve("lib").resolve("jrt-fs.jar"), "this is not a JAR file"); + doTestNoSource(base, "error: illegal argument for --system: %s".formatted(base), String.format("--system %s", base)); + } + + @Test + public void consistentSystemOptionHandlingWithLibModules(Path base) throws Exception { + tb.createDirectories(base); + tb.writeFile(base.resolve("lib").resolve("modules"), "this is not a modules file"); + doTestNoSource(base, "error: illegal argument for --system: %s".formatted(base), String.format("--system %s", base)); + } + + @Test + public void consistentSystemOptionHandlingWithAlmostValidLibEntries(Path base) throws Exception { + tb.createDirectories(base); + tb.writeFile(base.resolve("lib").resolve("jrt-fs.jar"), "this is not a JAR file"); + tb.writeFile(base.resolve("lib").resolve("modules"), "this is not a modules file"); + doTestNoSource(base, "error: no source files", String.format("--system %s", base)); + } + void doTest(Path base, String output, String options) throws Exception { Path src = base.resolve("src"); tb.writeJavaFiles(src, "class Dummy { }"); From d52a995f35de26c2cc4074297a75141e4a363e1b Mon Sep 17 00:00:00 2001 From: Leo Korinth Date: Fri, 27 Oct 2023 08:47:26 +0000 Subject: [PATCH 11/16] 8315097: Rename createJavaProcessBuilder Reviewed-by: lmesnik, dholmes, rriggs, stefank --- .../applications/jcstress/JcstressRunner.java | 2 +- .../applications/jcstress/TestGenerator.java | 2 +- .../jtreg/applications/scimark/Scimark.java | 2 +- .../arguments/CheckCICompilerCount.java | 4 +- .../CheckCompileThresholdScaling.java | 4 +- .../arguments/TestCodeEntryAlignment.java | 4 +- .../arguments/TestOptoLoopAlignment.java | 4 +- .../TestPrintOptoAssemblyLineNumbers.java | 4 +- .../arraycopy/stress/TestStressArrayCopy.java | 2 +- ...BlackholeExistingIntrinsicWarningTest.java | 4 +- .../BlackholeExperimentalUnlockTest.java | 4 +- .../blackhole/BlackholeIntrinsicTest.java | 2 +- .../BlackholeNonEmptyWarningTest.java | 4 +- .../BlackholeNonStaticWarningTest.java | 4 +- .../BlackholeNonVoidWarningTest.java | 4 +- .../compiler/c1/TestRangeCheckEliminated.java | 8 +- test/hotspot/jtreg/compiler/c2/TestBit.java | 4 +- .../compiler/c2/aarch64/TestFarJump.java | 2 +- .../compiler/c2/aarch64/TestSVEWithJNI.java | 48 +++++----- .../compiler/c2/aarch64/TestTrampoline.java | 2 +- .../compiler/c2/aarch64/TestVolatiles.java | 4 +- .../jtreg/compiler/ciReplay/CiReplayBase.java | 8 +- .../compiler/ciReplay/DumpReplayBase.java | 4 +- .../jtreg/compiler/ciReplay/SABase.java | 4 +- .../ciReplay/TestInvalidReplayFile.java | 2 +- .../codecache/CheckCodeCacheInfo.java | 6 +- .../compiler/codecache/CheckLargePages.java | 2 +- ...kReservedInitialCodeCacheSizeArgOrder.java | 6 +- .../codecache/CheckSegmentedCodeCache.java | 88 +++++++++--------- .../compiler/codecache/CheckUpperLimit.java | 4 +- .../codecache/CodeCacheFullCountTest.java | 2 +- .../TestConflictInlineCommands.java | 4 +- .../jtreg/compiler/cpuflags/RestoreMXCSR.java | 4 +- .../debug/TestGenerateStressSeed.java | 4 +- .../jtreg/compiler/debug/TestStressCM.java | 4 +- .../compiler/debug/TestStressIGVNAndCCP.java | 4 +- .../compiler/debug/VerifyAdapterSharing.java | 4 +- .../escapeAnalysis/TestIterativeEA.java | 4 +- .../compiler/inlining/InlineAccessors.java | 4 +- .../compiler/inlining/PrintInlining.java | 4 +- .../compiler/inlining/ResolvedClassTest.java | 8 +- .../intrinsics/chacha/TestChaCha20.java | 4 +- .../ContinuousCallSiteTargetChange.java | 2 +- .../jtreg/compiler/jsr292/MHInlineTest.java | 4 +- .../compiler/jsr292/PollutedTrapCounts.java | 4 +- .../jvmci/TestEnableJVMCIProduct.java | 2 +- .../jvmci/TestInvalidJVMCIOption.java | 4 +- .../jvmci/TestJVMCIPrintProperties.java | 4 +- .../jvmci/TestJVMCISavedProperties.java | 2 +- .../TestUncaughtErrorInCompileMethod.java | 2 +- .../jvmci/compilerToVM/GetFlagValueTest.java | 4 +- .../hotspot/test/TestHotSpotJVMCIRuntime.java | 2 +- .../ir_framework/driver/TestVMProcess.java | 4 +- .../TestLinkageErrorInGenerateOopMap.java | 4 +- .../CheckLoopStripMiningIterShortLoop.java | 2 +- .../TestNoWarningLoopStripMiningIterSet.java | 2 +- .../compiler/onSpinWait/TestOnSpinWait.java | 4 +- .../onSpinWait/TestOnSpinWaitAArch64.java | 2 +- .../TestOnSpinWaitAArch64DefaultFlags.java | 4 +- .../compiler/onSpinWait/TestOnSpinWaitC1.java | 4 +- .../onSpinWait/TestOnSpinWaitNoneAArch64.java | 2 +- .../onSpinWait/TestOnSpinWaitRISCV64.java | 2 +- .../oracle/CheckCompileCommandOption.java | 6 +- .../compiler/oracle/TestCompileCommand.java | 4 +- .../oracle/TestInvalidCompileCommand.java | 2 +- .../TestRangeCheckHoistingScaledIV.java | 2 +- .../runtime/cr8015436/Driver8015436.java | 4 +- .../sharedstubs/SharedStubToInterpTest.java | 2 +- .../sharedstubs/SharedTrampolineTest.java | 2 +- .../startup/NumCompilerThreadsCheck.java | 4 +- .../startup/SmallCodeCacheStartup.java | 10 +- .../jtreg/compiler/startup/StartupOutput.java | 6 +- .../compiler/testlibrary/rtm/RTMTestBase.java | 6 +- .../compiler/types/correctness/OffTest.java | 4 +- .../TestBufferVectorization.java | 12 +-- .../jtreg/containers/cgroup/PlainRead.java | 4 +- test/hotspot/jtreg/gc/TestAgeOutput.java | 4 +- test/hotspot/jtreg/gc/TestAllocateHeapAt.java | 4 +- .../jtreg/gc/TestAllocateHeapAtError.java | 4 +- .../jtreg/gc/TestAllocateHeapAtMultiple.java | 4 +- .../jtreg/gc/TestCardTablePageCommits.java | 4 +- .../hotspot/jtreg/gc/TestNumWorkerOutput.java | 4 +- .../jtreg/gc/TestPLABAdaptToMinTLABSize.java | 4 +- test/hotspot/jtreg/gc/TestSmallHeap.java | 4 +- .../jtreg/gc/TestVerifyDuringStartup.java | 4 +- test/hotspot/jtreg/gc/TestVerifySilently.java | 4 +- test/hotspot/jtreg/gc/TestVerifySubSet.java | 2 +- .../jtreg/gc/arguments/GCArguments.java | 18 ++-- .../gc/arguments/TestAggressiveHeap.java | 2 +- .../arguments/TestCompressedClassFlags.java | 2 +- .../gc/arguments/TestDisableDefaultGC.java | 14 +-- .../TestG1ConcMarkStepDurationMillis.java | 2 +- .../TestG1ConcRefinementThreads.java | 2 +- .../gc/arguments/TestG1HeapRegionSize.java | 2 +- .../gc/arguments/TestG1PercentageOptions.java | 2 +- .../jtreg/gc/arguments/TestG1RemSetFlags.java | 2 +- .../jtreg/gc/arguments/TestHeapFreeRatio.java | 2 +- .../TestInitialTenuringThreshold.java | 4 +- .../gc/arguments/TestMaxHeapSizeTools.java | 6 +- .../TestMaxMinHeapFreeRatioFlags.java | 6 +- .../jtreg/gc/arguments/TestMaxNewSize.java | 2 +- .../jtreg/gc/arguments/TestMaxRAMFlags.java | 6 +- .../TestMinAndInitialSurvivorRatioFlags.java | 4 +- .../jtreg/gc/arguments/TestNewRatioFlag.java | 4 +- .../jtreg/gc/arguments/TestNewSizeFlags.java | 4 +- .../arguments/TestNewSizeThreadIncrease.java | 16 ++-- .../gc/arguments/TestObjectTenuringFlags.java | 4 +- .../gc/arguments/TestParallelGCThreads.java | 8 +- .../gc/arguments/TestParallelRefProc.java | 4 +- .../gc/arguments/TestSelectDefaultGC.java | 4 +- ...tSmallInitialHeapWithLargePageAndNUMA.java | 4 +- .../gc/arguments/TestSurvivorRatioFlag.java | 4 +- .../TestTargetSurvivorRatioFlag.java | 6 +- .../TestUnrecognizedVMOptionsHandling.java | 8 +- .../TestUseCompressedOopsErgoTools.java | 6 +- .../TestUseCompressedOopsFlagsWithUlimit.java | 4 +- .../gc/arguments/TestUseNUMAInterleaving.java | 4 +- .../TestVerifyBeforeAndAfterGCFlags.java | 4 +- .../TestG1ClassUnloadingHWM.java | 4 +- .../jtreg/gc/epsilon/TestDieDefault.java | 4 +- .../jtreg/gc/epsilon/TestDieWithHeapDump.java | 4 +- .../jtreg/gc/epsilon/TestDieWithOnError.java | 4 +- .../TestDynamicNumberOfGCThreads.java | 6 +- .../TestInitialGCThreadLogging.java | 4 +- test/hotspot/jtreg/gc/g1/Test2GbHeap.java | 4 +- .../g1/TestEagerReclaimHumongousRegions.java | 4 +- ...rReclaimHumongousRegionsClearMarkBits.java | 2 +- .../TestEagerReclaimHumongousRegionsLog.java | 4 +- ...tEagerReclaimHumongousRegionsWithRefs.java | 4 +- .../jtreg/gc/g1/TestEvacuationFailure.java | 20 ++-- .../jtreg/gc/g1/TestG1SkipCompaction.java | 2 +- ...stG1TraceEagerReclaimHumongousObjects.java | 18 ++-- .../jtreg/gc/g1/TestGCLogMessages.java | 92 +++++++++---------- .../g1/TestHumongousAllocConcurrentStart.java | 4 +- .../TestHumongousAllocNearlyFullRegion.java | 4 +- .../gc/g1/TestHumongousCodeCacheRoots.java | 4 +- .../g1/TestHumongousConcurrentStartUndo.java | 4 +- .../gc/g1/TestLargePageUseForAuxMemory.java | 6 +- .../jtreg/gc/g1/TestLargePageUseForHeap.java | 26 +++--- .../jtreg/gc/g1/TestMarkStackSizes.java | 4 +- .../jtreg/gc/g1/TestMixedGCLiveThreshold.java | 4 +- .../jtreg/gc/g1/TestOneEdenRegionAfterGC.java | 4 +- test/hotspot/jtreg/gc/g1/TestPLABOutput.java | 4 +- .../jtreg/gc/g1/TestPLABSizeBounds.java | 4 +- .../jtreg/gc/g1/TestPeriodicLogMessages.java | 22 ++--- .../g1/TestPrintRegionRememberedSetInfo.java | 4 +- .../jtreg/gc/g1/TestRemsetLoggingThreads.java | 14 +-- .../jtreg/gc/g1/TestRemsetLoggingTools.java | 4 +- .../gc/g1/TestSharedArchiveWithPreTouch.java | 6 +- .../jtreg/gc/g1/TestShrinkAuxiliaryData.java | 4 +- .../gc/g1/TestShrinkDefragmentedHeap.java | 4 +- .../gc/g1/TestSkipRebuildRemsetPhase.java | 22 ++--- .../hotspot/jtreg/gc/g1/TestVerifyGCType.java | 4 +- .../jtreg/gc/g1/mixedgc/TestLogging.java | 4 +- .../gc/g1/numa/TestG1NUMATouchRegions.java | 4 +- .../gc/logging/TestDeprecatedPrintFlags.java | 10 +- test/hotspot/jtreg/gc/logging/TestGCId.java | 4 +- .../jtreg/gc/logging/TestMetaSpaceLog.java | 4 +- .../jtreg/gc/logging/TestPrintReferences.java | 24 ++--- .../gc/metaspace/TestMetaspaceSizeFlags.java | 4 +- .../gc/metaspace/TestSizeTransitions.java | 4 +- .../jtreg/gc/serial/HeapChangeLogging.java | 4 +- .../jtreg/gc/shenandoah/TestEvilSyncBug.java | 2 +- .../gc/shenandoah/TestObjItrWithHeapDump.java | 2 +- .../jtreg/gc/shenandoah/TestPeriodicGC.java | 2 +- .../gc/shenandoah/oom/TestAllocLargeObj.java | 4 +- .../oom/TestAllocLargerThanHeap.java | 4 +- .../gc/shenandoah/oom/TestAllocSmallObj.java | 4 +- .../shenandoah/oom/TestClassLoaderLeak.java | 2 +- .../gc/shenandoah/oom/TestThreadFailure.java | 2 +- .../options/TestArgumentRanges.java | 14 +-- .../options/TestClassUnloadingArguments.java | 2 +- .../gc/shenandoah/options/TestExplicitGC.java | 10 +- .../options/TestExplicitGCNoConcurrent.java | 2 +- .../options/TestHeuristicsUnlock.java | 6 +- .../options/TestHumongousThresholdArgs.java | 6 +- .../options/TestLoopMiningArguments.java | 2 +- .../gc/shenandoah/options/TestModeUnlock.java | 6 +- .../options/TestRegionSizeArgs.java | 32 +++---- .../options/TestSelectiveBarrierFlags.java | 2 +- .../options/TestSoftMaxHeapSize.java | 6 +- .../shenandoah/options/TestThreadCounts.java | 2 +- .../options/TestThreadCountsOverride.java | 4 +- .../options/TestWrongBarrierDisable.java | 4 +- .../options/TestWrongBarrierEnable.java | 4 +- .../stress/TestReclaimStringsLeaksMemory.java | 4 +- .../gc/stress/TestStressG1Humongous.java | 4 +- .../jtreg/gc/stress/TestStressG1Uncommit.java | 4 +- .../TestStringDeduplicationTools.java | 2 +- test/hotspot/jtreg/gc/whitebox/TestWBGC.java | 4 +- .../jtreg/gc/x/TestAllocateHeapAt.java | 4 +- .../jtreg/gc/x/TestPageCacheFlush.java | 4 +- test/hotspot/jtreg/gc/x/TestSmallHeap.java | 4 +- .../jtreg/gc/z/TestAllocateHeapAt.java | 2 +- .../jtreg/gc/z/TestPageCacheFlush.java | 2 +- test/hotspot/jtreg/gc/z/TestSmallHeap.java | 2 +- ...stZForceDiscontiguousHeapReservations.java | 2 +- test/hotspot/jtreg/gc/z/TestZNMT.java | 2 +- .../jvmti/GetObjectSizeOverflow.java | 4 +- .../7162488/TestUnrecognizedVmOption.java | 4 +- .../jtreg/runtime/8176717/TestInheritFD.java | 8 +- .../BadObjectClass/BootstrapRedefine.java | 4 +- .../BootClassPathAppend.java | 4 +- .../BootstrapMethod/BSMCalledTwice.java | 4 +- .../TestLambdaExceptionInInitializer.java | 2 +- .../CDSCompressedKPtrs.java | 6 +- .../CDSCompressedKPtrs/XShareAuto.java | 6 +- .../runtime/ClassFile/FormatCheckingTest.java | 4 +- .../jtreg/runtime/ClassFile/JsrRewriting.java | 4 +- .../ClassFile/OomWhileParsingRepeatedJsr.java | 4 +- .../runtime/ClassFile/PreviewVersion.java | 8 +- .../ClassFile/TestCheckedExceptions.java | 4 +- .../UnsupportedClassFileVersion.java | 4 +- .../BooleanFlagWithInvalidValue.java | 4 +- .../CompilerConfigFileWarning.java | 4 +- .../CommandLine/ConfigFileParsing.java | 2 +- .../CommandLine/ConfigFileWarning.java | 4 +- .../DoubleFlagWithIntegerValue.java | 2 +- .../CommandLine/FlagWithInvalidValue.java | 2 +- .../IgnoreUnrecognizedVMOptions.java | 2 +- ...onBooleanFlagWithInvalidBooleanPrefix.java | 4 +- .../CommandLine/ObsoleteFlagErrorMessage.java | 4 +- .../OptionsValidation/TestJcmdOutput.java | 2 +- .../common/optionsvalidation/JVMOption.java | 4 +- .../optionsvalidation/JVMOptionsUtils.java | 4 +- .../runtime/CommandLine/TestHexArguments.java | 4 +- .../TestLongUnrecognizedVMOption.java | 2 +- .../CommandLine/TestNullTerminatedFlags.java | 2 +- .../runtime/CommandLine/TestVMOptions.java | 6 +- .../CommandLine/TraceExceptionsTest.java | 2 +- .../CommandLine/UnrecognizedVMOption.java | 2 +- .../CommandLine/VMDeprecatedOptions.java | 4 +- .../runtime/CommandLine/VMOptionWarning.java | 8 +- .../VMOptionsFile/TestVMOptionsFile.java | 2 +- .../CompressedClassPointers.java | 30 +++--- .../CompressedClassSpaceSize.java | 36 ++++---- .../CompressedKlassPointerAndOops.java | 4 +- .../CompressedOops/ObjectAlignment.java | 6 +- .../CompressedOops/UseCompressedOops.java | 4 +- .../Dictionary/CleanProtectionDomain.java | 4 +- .../Dictionary/ProtectionDomainCacheTest.java | 4 +- .../EnclosingMethodAttr/EnclMethodAttr.java | 4 +- .../BadNativeStackInErrorHandlingTest.java | 2 +- .../ErrorHandling/ClassPathEnvVar.java | 8 +- .../ErrorHandling/CreateCoredumpOnCrash.java | 4 +- .../ErrorHandling/ErrorFileOverwriteTest.java | 4 +- .../ErrorHandling/ErrorFileRedirectTest.java | 2 +- .../MachCodeFramesInErrorFile.java | 2 +- ...dThreadsListHandleInErrorHandlingTest.java | 2 +- .../ErrorHandling/ProblematicFrameTest.java | 2 +- .../ErrorHandling/ReattemptErrorTest.java | 2 +- .../ErrorHandling/ResourceMarkTest.java | 2 +- .../SafeFetchInErrorHandlingTest.java | 2 +- .../ErrorHandling/SecondaryErrorTest.java | 2 +- .../ShowRegistersOnAssertTest.java | 2 +- .../ErrorHandling/StackWalkNativeToJava.java | 4 +- .../ErrorHandling/TestAbortVmOnException.java | 4 +- .../TestCrashOnOutOfMemoryError.java | 2 +- .../runtime/ErrorHandling/TestDwarf.java | 2 +- .../TestExitOnOutOfMemoryError.java | 2 +- ...TestGZippedHeapDumpOnOutOfMemoryError.java | 2 +- .../TestHeapDumpOnOutOfMemoryError.java | 2 +- .../ErrorHandling/TestHeapDumpPath.java | 2 +- .../runtime/ErrorHandling/TestOnError.java | 2 +- .../ErrorHandling/TestOnOutOfMemoryError.java | 4 +- .../ErrorHandling/TestSigInfoInHsErrFile.java | 2 +- .../ThreadsListHandleInErrorHandlingTest.java | 2 +- .../TimeoutInErrorHandlingTest.java | 2 +- .../ErrorHandling/VeryEarlyAssertTest.java | 2 +- .../TestGenerateOopMapCrash.java | 4 +- .../InvocationTests/invocationC1Tests.java | 4 +- .../invocationOldCHATests.java | 4 +- .../InvocationTests/invokeinterfaceTests.java | 4 +- .../InvocationTests/invokespecialTests.java | 4 +- .../InvocationTests/invokevirtualTests.java | 4 +- .../runtime/LoadClass/LoadClassNegative.java | 4 +- .../jtreg/runtime/LoadClass/LongBCP.java | 14 +-- .../jtreg/runtime/LoadClass/TestResize.java | 10 +- .../runtime/LocalLong/LocalLongTest.java | 12 +-- .../runtime/LocalVariableTable/TestLVT.java | 8 +- .../runtime/MemberName/MemberNameLeak.java | 4 +- .../Metaspace/MaxMetaspaceSizeEnvVarTest.java | 8 +- .../Metaspace/MaxMetaspaceSizeTest.java | 4 +- test/hotspot/jtreg/runtime/MinimalVM/CDS.java | 8 +- .../jtreg/runtime/MinimalVM/CheckJNI.java | 4 +- .../runtime/MinimalVM/Instrumentation.java | 4 +- test/hotspot/jtreg/runtime/MinimalVM/JMX.java | 6 +- .../jtreg/runtime/MinimalVM/JVMTI.java | 4 +- test/hotspot/jtreg/runtime/MinimalVM/NMT.java | 8 +- .../Monitor/DeflationIntervalsTest.java | 2 +- .../MonitorUsedDeflationThresholdTest.java | 4 +- .../Monitor/SyncOnValueBasedClassTest.java | 8 +- .../NMT/CheckForProperDetailStackTrace.java | 2 +- .../jtreg/runtime/NMT/CommandLineDetail.java | 2 +- .../runtime/NMT/CommandLineEmptyArgument.java | 2 +- .../NMT/CommandLineInvalidArgument.java | 2 +- .../jtreg/runtime/NMT/CommandLineSummary.java | 2 +- .../runtime/NMT/CommandLineTurnOffNMT.java | 2 +- .../runtime/NMT/JcmdWithNMTDisabled.java | 4 +- .../jtreg/runtime/NMT/MallocLimitTest.java | 2 +- .../runtime/NMT/NMTInitializationTest.java | 2 +- .../jtreg/runtime/NMT/NMTJavaHeapTest.java | 2 +- .../hotspot/jtreg/runtime/NMT/NMTWithCDS.java | 4 +- .../jtreg/runtime/NMT/PrintNMTStatistics.java | 4 +- .../PrintNMTStatisticsWithNMTDisabled.java | 2 +- .../PerfMemDestroy/PerfMemDestroy.java | 4 +- .../PrintStringTableStatsTest.java | 4 +- .../ReservedStack/ReservedStackTest.java | 4 +- .../TestAbortOnVMOperationTimeout.java | 2 +- .../TestAbortVMOnSafepointTimeout.java | 6 +- .../runtime/StackTrace/LargeClassTest.java | 4 +- .../Thread/TestAlwaysPreTouchStacks.java | 4 +- .../Thread/TestBreakSignalThreadDump.java | 4 +- .../runtime/Thread/TooSmallStackSize.java | 6 +- .../runtime/Throwable/StackTraceLogging.java | 12 +-- .../Throwable/TestCatchThrowableOOM.java | 8 +- .../Throwable/TestMaxJavaStackTraceDepth.java | 12 +-- .../jtreg/runtime/Unsafe/RangeCheck.java | 4 +- .../runtime/XCheckJniJsig/XCheckJSig.java | 6 +- .../jtreg/runtime/cds/MaxMetaspaceSize.java | 4 +- .../jtreg/runtime/cds/SharedStrings.java | 6 +- .../jtreg/runtime/cds/TestCDSVMCrash.java | 2 +- .../cds/appcds/CommandLineFlagCombo.java | 2 +- .../cds/appcds/FillerObjectLoadTest.java | 4 +- .../jtreg/runtime/cds/appcds/TestCommon.java | 6 +- .../cds/appcds/TestDumpClassListSource.java | 14 +-- .../cds/appcds/VerifyWithDefaultArchive.java | 2 +- .../DynamicArchiveTestBase.java | 4 +- .../dynamicArchive/LambdasInTwoArchives.java | 2 +- .../cds/appcds/jcmd/JCmdTestDynamicDump.java | 4 +- .../ResolvedReferencesNotNullTest.java | 16 ++-- .../classFileParserBug/Bad_NCDFE_Msg.java | 4 +- .../ClassFileParserBug.java | 4 +- .../TestBadPackageWithInterface.java | 4 +- .../TestEmptyBootstrapMethodsAttr.java | 6 +- .../jtreg/runtime/condy/BadBSMUseTest.java | 6 +- .../jtreg/runtime/condy/CondyLDCTest.java | 14 +-- .../condy/CondyNewInvokeSpecialTest.java | 6 +- .../condy/escapeAnalysis/TestEscapeCondy.java | 4 +- .../condy/staticInit/TestInitException.java | 4 +- .../jtreg/runtime/contended/Options.java | 24 ++--- .../duplAttributes/DuplAttributesTest.java | 4 +- .../runtime/execstack/Testexecstack.java | 8 +- .../GetPackageXbootclasspath.java | 4 +- .../runtime/getSysPackage/GetSysPkgTest.java | 4 +- .../handshake/HandshakeTimeoutTest.java | 4 +- .../handshake/HandshakeTransitionTest.java | 4 +- .../SystemMembarHandshakeTransitionTest.java | 4 +- .../TestCheckedReleaseArrayElements.java | 8 +- ...estPrimitiveArrayCriticalWithBadParam.java | 2 +- test/hotspot/jtreg/runtime/jsig/Testjsig.java | 4 +- .../logging/ClassInitializationTest.java | 18 ++-- .../runtime/logging/ClassLoadUnloadTest.java | 4 +- .../runtime/logging/ClassResolutionTest.java | 12 +-- .../runtime/logging/CompressedOopsTest.java | 20 ++-- .../jtreg/runtime/logging/CondyIndyTest.java | 22 ++--- .../runtime/logging/DefaultMethodsTest.java | 6 +- .../jtreg/runtime/logging/ExceptionsTest.java | 20 ++-- .../runtime/logging/FoldMultilinesTest.java | 8 +- .../jtreg/runtime/logging/ItablesTest.java | 6 +- .../logging/LoaderConstraintsTest.java | 4 +- .../jtreg/runtime/logging/ModulesTest.java | 4 +- .../runtime/logging/MonitorInflationTest.java | 10 +- .../runtime/logging/MonitorMismatchTest.java | 18 ++-- .../jtreg/runtime/logging/MutexRankTest.java | 4 +- .../runtime/logging/OsCpuLoggingTest.java | 8 +- .../ProtectionDomainVerificationTest.java | 26 +++--- .../runtime/logging/SafepointCleanupTest.java | 10 +- .../jtreg/runtime/logging/SafepointTest.java | 6 +- .../jtreg/runtime/logging/StackWalkTest.java | 10 +- .../runtime/logging/StartupTimeTest.java | 10 +- .../runtime/logging/ThreadLoggingTest.java | 6 +- .../runtime/logging/VMOperationTest.java | 10 +- .../runtime/logging/VerificationTest.java | 14 +-- .../jtreg/runtime/logging/VtablesTest.java | 6 +- .../loadLibraryTest/LoadLibraryTest.java | 4 +- .../LargePages/TestLargePagesFlags.java | 4 +- .../runtime/memory/ReadFromNoaccessArea.java | 4 +- .../jtreg/runtime/memory/ReserveMemory.java | 4 +- .../ClassLoaderNoUnnamedModuleTest.java | 4 +- .../modules/IgnoreModulePropertiesTest.java | 6 +- .../runtime/modules/ModuleOptionsTest.java | 6 +- .../runtime/modules/ModuleOptionsWarn.java | 24 ++--- .../ModuleStress/ExportModuleStressTest.java | 4 +- .../modules/ModuleStress/ModuleStress.java | 10 +- .../modules/ModuleStress/ModuleStressGC.java | 4 +- .../modules/PatchModule/PatchModule2Dirs.java | 4 +- .../modules/PatchModule/PatchModuleCDS.java | 10 +- .../PatchModule/PatchModuleClassList.java | 8 +- .../PatchModule/PatchModuleDupJavaBase.java | 4 +- .../PatchModule/PatchModuleDupModule.java | 4 +- .../PatchModule/PatchModuleJavaBase.java | 4 +- .../modules/PatchModule/PatchModuleTest.java | 4 +- .../PatchModule/PatchModuleTestJar.java | 4 +- .../PatchModule/PatchModuleTestJarDir.java | 16 ++-- .../PatchModule/PatchModuleTraceCL.java | 6 +- .../Visibility/PatchModuleVisibility.java | 4 +- .../Visibility/XbootcpNoVisibility.java | 4 +- .../modules/Visibility/XbootcpVisibility.java | 4 +- .../jtreg/runtime/os/AvailableProcessors.java | 6 +- .../os/THPsInThreadStackPreventionTest.java | 4 +- .../runtime/os/TestHugePageDetection.java | 2 +- .../jtreg/runtime/os/TestTimerSlack.java | 8 +- .../jtreg/runtime/os/TestTrimNative.java | 2 +- .../jtreg/runtime/os/TestUseCpuAllocPath.java | 10 +- .../jtreg/runtime/posixSig/TestPosixSig.java | 4 +- .../jtreg/runtime/records/RedefineRecord.java | 4 +- .../RedefinePermittedSubclass.java | 4 +- .../sealedClasses/RedefineSealedClass.java | 4 +- .../stringtable/StringTableVerifyTest.java | 4 +- .../symboltable/ShortLivedSymbolCleanup.java | 12 +-- .../jtreg/runtime/verifier/OverriderMsg.java | 4 +- .../jtreg/runtime/verifier/TestANewArray.java | 8 +- .../runtime/verifier/TestMultiANewArray.java | 4 +- .../runtime/verifier/TestTableSwitch.java | 4 +- .../jtreg/runtime/verifier/TraceClassRes.java | 4 +- .../whitebox/TestWBDeflateIdleMonitors.java | 4 +- .../attach/AttachSetGetFlag.java | 2 +- .../attach/AttachWithStalePidFile.java | 4 +- .../serviceability/attach/ShMemLongName.java | 2 +- .../dcmd/gc/RunFinalizationTest.java | 4 +- .../dtrace/DTraceOptionsTest.java | 2 +- .../serviceability/jdwp/DebuggeeLauncher.java | 2 +- .../CanGenerateAllClassHook.java | 4 +- .../jvmti/GetObjectSizeClass.java | 4 +- .../jvmti/RedefineClasses/RedefineLeak.java | 4 +- .../RedefinePreviousVersions.java | 4 +- .../RedefineSharedClassJFR.java | 4 +- .../RetransformClassesZeroLength.java | 4 +- .../TransformerDeadlockTest.java | 4 +- .../vthread/premain/AgentWithVThreadTest.java | 2 +- .../logging/TestBasicLogOutput.java | 4 +- .../logging/TestDefaultLogOutput.java | 4 +- .../serviceability/logging/TestFullNames.java | 8 +- .../logging/TestLogRotation.java | 4 +- .../logging/TestMultipleXlogArgs.java | 16 ++-- .../logging/TestQuotedLogOutputs.java | 14 +-- .../serviceability/sa/ClhsdbCDSCore.java | 4 +- .../serviceability/sa/TestClassDump.java | 6 +- .../sa/TestCpoolForInvokeDynamic.java | 4 +- .../serviceability/sa/TestDefaultMethods.java | 4 +- .../serviceability/sa/TestG1HeapRegion.java | 4 +- .../sa/TestInstanceKlassSize.java | 4 +- .../sa/TestInstanceKlassSizeForInterface.java | 4 +- .../jtreg/serviceability/sa/TestJmapCore.java | 4 +- .../sa/TestObjectAlignment.java | 4 +- .../sa/TestObjectMonitorIterate.java | 2 +- .../sa/TestRevPtrsForInvokeDynamic.java | 4 +- .../serviceability/sa/UniqueVtableTest.java | 2 +- .../sa/jmap-hprof/JMapHProfLargeHeapTest.java | 2 +- .../src/sun/hotspot/tools/ctw/CtwRunner.java | 2 +- .../lib/jittester/jtreg/JitTesterDriver.java | 4 +- .../jtreg/testlibrary_tests/ctw/CtwTest.java | 4 +- .../ir_framework/tests/TestDScenarios.java | 4 +- .../tests/TestDTestAndExclude.java | 4 +- .../largeheap/MemOptions/MemOptionsTest.java | 6 +- .../TestMaxMetaspaceSize.java | 6 +- .../nsk/jvmti/Allocate/alloc001/alloc001.java | 4 +- .../retransform003/TestDriver.java | 4 +- .../SetNativeMethodPrefix002/TestDriver.java | 4 +- .../vm/compiler/CodeCacheInfo/Test.java | 6 +- .../CodeCacheInfoOnCompilation/Test.java | 4 +- test/jdk/com/sun/jdi/JITDebug.java | 4 +- test/jdk/com/sun/jdi/NoLaunchOptionTest.java | 4 +- .../jdk/com/sun/jdi/PrivateTransportTest.java | 4 +- test/jdk/com/sun/jdi/ProcessAttachTest.java | 2 +- test/jdk/com/sun/jdi/RunToExit.java | 4 +- test/jdk/com/sun/jdi/cds/CDSJDITest.java | 6 +- test/jdk/com/sun/jdi/lib/jdb/Debuggee.java | 2 +- .../HotSpotDiagnosticMXBean/CheckOrigin.java | 2 +- test/jdk/com/sun/tools/attach/RunnerUtil.java | 4 +- .../java/awt/MenuBar/TestNoScreenMenuBar.java | 4 +- .../java/awt/Robot/NonEmptyErrorStream.java | 4 +- .../ScreenInsetsDPIVariation.java | 4 +- .../MainKeyWindowTest/TestMainKeyWindow.java | 4 +- .../MinimumSizeDPIVariation.java | 4 +- .../MTTransformReplacedProfile.java | 4 +- .../font/JNICheck/FreeTypeScalerJNICheck.java | 4 +- test/jdk/java/foreign/UpcallTestHelper.java | 2 +- test/jdk/java/io/Console/RedirectTest.java | 2 +- test/jdk/java/io/File/MacPath.java | 4 +- .../class/NonSerializableTest.java | 4 +- .../RenamePackage/RenamePackageTest.java | 6 +- .../lang/ClassLoader/GetSystemPackage.java | 4 +- .../Object/InvalidFinalizationOption.java | 4 +- .../lang/ProcessBuilder/InheritIOTest.java | 4 +- .../ProcessBuilder/JspawnhelperProtocol.java | 24 ++--- .../lang/ProcessBuilder/ReaderWriterTest.java | 12 +-- .../shutdown/ShutdownInterruptedMain.java | 6 +- .../modules/CustomSecurityManagerTest.java | 4 +- .../java/lang/StackWalker/CallerFromMain.java | 4 +- .../java/lang/System/FileEncodingTest.java | 4 +- .../System/MacEncoding/MacJNUEncoding.java | 4 +- test/jdk/java/lang/System/i18nEnvArg.java | 4 +- .../lang/Thread/UncaughtExceptionsTest.java | 2 +- .../lang/Thread/virtual/ShutdownHook.java | 4 +- .../java/lang/annotation/LoaderLeakTest.java | 4 +- .../TestDaemonThreadLauncher.java | 4 +- .../lang/instrument/NegativeAgentRunner.java | 4 +- .../PremainClass/PremainClassTest.java | 4 +- .../condy/CondyNestedResolutionTest.java | 4 +- .../channels/Selector/LotsOfUpdatesTest.java | 4 +- .../charset/Charset/DefaultCharsetTest.java | 4 +- test/jdk/java/nio/file/Path/MacPathTest.java | 6 +- .../SignedJarWithCustomClassLoader.java | 6 +- .../util/Formatter/BasicTestLauncher.java | 4 +- .../Properties/StoreReproducibilityTest.java | 16 ++-- .../util/TimeZone/CustomTzIDCheckDST.java | 4 +- .../connection/DefaultAgentFilterTest.java | 2 +- .../security/HashedPasswordFileTest.java | 4 +- .../net/ssl/TLSCommon/interop/ProcUtils.java | 6 +- .../UnninstallUIMemoryLeaks.java | 4 +- .../javax/swing/text/html/CSS/bug8234913.java | 4 +- .../jdk/incubator/vector/LoadJsvmlTest.java | 4 +- .../internal/misc/VM/RuntimeArguments.java | 2 +- .../api/consumer/streaming/Application.java | 4 +- .../streaming/TestCrossProcessStreaming.java | 4 +- .../api/consumer/streaming/TestProcess.java | 4 +- ...onConfigurationEventWithMinAndMaxSize.java | 4 +- .../os/TestInitialEnvironmentVariable.java | 4 +- .../jdk/jfr/event/runtime/TestDumpReason.java | 4 +- .../jfr/event/runtime/TestShutdownEvent.java | 2 +- test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java | 2 +- test/jdk/jdk/jfr/jvm/TestEventWriterLog.java | 2 +- .../jfr/startupargs/TestBadOptionValues.java | 4 +- .../jdk/jfr/startupargs/TestDumpOnExit.java | 4 +- .../jdk/jfr/startupargs/TestJFCWarnings.java | 4 +- .../jfr/startupargs/TestMemoryOptions.java | 24 ++--- .../TestMultipleStartupRecordings.java | 10 +- .../startupargs/TestOptionsWithLocale.java | 2 +- .../startupargs/TestPreserveRepository.java | 2 +- .../startupargs/TestRetransformUsingLog.java | 4 +- .../jfr/startupargs/TestStartDuration.java | 6 +- .../jdk/jfr/startupargs/TestStartName.java | 4 +- .../jfr/startupargs/TestStartupMessage.java | 4 +- .../JavaDotSecurity/MakeJavaSecurityTest.java | 4 +- .../MonitoredVm/MonitorVmStartTerminate.java | 2 +- .../sun/management/jdp/DynamicLauncher.java | 2 +- .../bootstrap/AbstractFilePermissionTest.java | 2 +- .../bootstrap/CustomLauncherTest.java | 2 +- .../bootstrap/JMXInterfaceBindingTest.java | 2 +- .../bootstrap/LocalManagementTest.java | 4 +- .../bootstrap/RmiRegistrySslTest.java | 2 +- .../jmxremote/startstop/JMXStartStopTest.java | 2 +- .../startstop/JMXStatusPerfCountersTest.java | 2 +- .../jmxremote/startstop/JMXStatusTest.java | 2 +- test/jdk/sun/net/spi/SystemProxyDriver.java | 2 +- .../sun/security/krb5/auto/ModuleName.java | 4 +- .../security/provider/KeyStore/DKSTest.java | 2 +- .../ssl/SSLEngineImpl/SSLEngineKeyLimit.java | 2 +- .../ResumptionUpdateBoundValues.java | 4 +- .../ssl/SSLSocketImpl/SSLSocketKeyLimit.java | 2 +- test/jdk/sun/tools/jstat/JStatInterval.java | 2 +- test/jdk/tools/jimage/JImageToolTest.java | 4 +- .../launcher/modules/basic/BasicTest.java | 4 +- .../lib/process/ProcessToolsLastLineTest.java | 2 +- test/lib/jdk/test/lib/cds/CDSTestUtils.java | 4 +- .../test/lib/cli/CommandLineOptionTest.java | 8 +- .../jdk/test/lib/jfr/AppExecutorHelper.java | 4 +- .../jdk/test/lib/process/ProcessTools.java | 64 ++++++++++--- 560 files changed, 1564 insertions(+), 1530 deletions(-) diff --git a/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java b/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java index 37ce9e7df7055..d92dbdfe82d6f 100644 --- a/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java +++ b/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java @@ -69,7 +69,7 @@ public static void main(String[] args) throws Throwable { } Path out = Paths.get("jcstress.out").toAbsolutePath(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(getCmd(args)) + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(getCmd(args)) .redirectErrorStream(true) .redirectOutput(out.toFile()); OutputAnalyzer oa = ProcessTools.executeProcess(pb); diff --git a/test/hotspot/jtreg/applications/jcstress/TestGenerator.java b/test/hotspot/jtreg/applications/jcstress/TestGenerator.java index c497d2aeb59c3..1b8ff81c48ac8 100644 --- a/test/hotspot/jtreg/applications/jcstress/TestGenerator.java +++ b/test/hotspot/jtreg/applications/jcstress/TestGenerator.java @@ -109,7 +109,7 @@ public static void main(String[] args) throws IOException { Path output; try { output = Files.createTempFile("jcstress", ".out"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-jar", path.toAbsolutePath().toString(), "-l"); diff --git a/test/hotspot/jtreg/applications/scimark/Scimark.java b/test/hotspot/jtreg/applications/scimark/Scimark.java index 8aab97aa2bc02..ee4f6f7cef9f3 100644 --- a/test/hotspot/jtreg/applications/scimark/Scimark.java +++ b/test/hotspot/jtreg/applications/scimark/Scimark.java @@ -48,7 +48,7 @@ public static void main(String... args) throws Exception { System.setProperty("test.noclasspath", "true"); - OutputAnalyzer output = new OutputAnalyzer(ProcessTools.createTestJvm( + OutputAnalyzer output = new OutputAnalyzer(ProcessTools.createTestJavaProcessBuilder( "-cp", artifacts.get("gov.nist.math.scimark-2.0").toString(), "jnt.scimark2.commandline", "-large") .start()); diff --git a/test/hotspot/jtreg/compiler/arguments/CheckCICompilerCount.java b/test/hotspot/jtreg/compiler/arguments/CheckCICompilerCount.java index da007dd0da9d3..6f137e20261c1 100644 --- a/test/hotspot/jtreg/compiler/arguments/CheckCICompilerCount.java +++ b/test/hotspot/jtreg/compiler/arguments/CheckCICompilerCount.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -190,7 +190,7 @@ private static void verifyValidOption(String[] arguments, String expected_output ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder(arguments); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); out = new OutputAnalyzer(pb.start()); try { diff --git a/test/hotspot/jtreg/compiler/arguments/CheckCompileThresholdScaling.java b/test/hotspot/jtreg/compiler/arguments/CheckCompileThresholdScaling.java index fb9fe26179fc1..d03aced702ea9 100644 --- a/test/hotspot/jtreg/compiler/arguments/CheckCompileThresholdScaling.java +++ b/test/hotspot/jtreg/compiler/arguments/CheckCompileThresholdScaling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -338,7 +338,7 @@ private static void verifyValidOption(String[] arguments, String[] expected_outp ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder(arguments); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); out = new OutputAnalyzer(pb.start()); try { diff --git a/test/hotspot/jtreg/compiler/arguments/TestCodeEntryAlignment.java b/test/hotspot/jtreg/compiler/arguments/TestCodeEntryAlignment.java index 15a603822455f..465999eac7f6c 100644 --- a/test/hotspot/jtreg/compiler/arguments/TestCodeEntryAlignment.java +++ b/test/hotspot/jtreg/compiler/arguments/TestCodeEntryAlignment.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, Red Hat, Inc. All rights reserved. - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,7 @@ private static List cmdline(String[] args) { } public static void shouldPass(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/compiler/arguments/TestOptoLoopAlignment.java b/test/hotspot/jtreg/compiler/arguments/TestOptoLoopAlignment.java index 15f9bebc22994..3993c679441ff 100644 --- a/test/hotspot/jtreg/compiler/arguments/TestOptoLoopAlignment.java +++ b/test/hotspot/jtreg/compiler/arguments/TestOptoLoopAlignment.java @@ -62,14 +62,14 @@ private static List cmdline(String[] args) { } public static void shouldFail(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotHaveExitValue(0); output.shouldContain(MSG); } public static void shouldPass(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldNotContain(MSG); diff --git a/test/hotspot/jtreg/compiler/arguments/TestPrintOptoAssemblyLineNumbers.java b/test/hotspot/jtreg/compiler/arguments/TestPrintOptoAssemblyLineNumbers.java index 1d029aabc0f70..1fddeeb50e8e5 100644 --- a/test/hotspot/jtreg/compiler/arguments/TestPrintOptoAssemblyLineNumbers.java +++ b/test/hotspot/jtreg/compiler/arguments/TestPrintOptoAssemblyLineNumbers.java @@ -1,6 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ public static void main(String[] args) throws Throwable { CheckC2OptoAssembly.class.getName() }; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(procArgs); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/compiler/arraycopy/stress/TestStressArrayCopy.java b/test/hotspot/jtreg/compiler/arraycopy/stress/TestStressArrayCopy.java index 5153f85c9d709..55dfb0460a2cb 100644 --- a/test/hotspot/jtreg/compiler/arraycopy/stress/TestStressArrayCopy.java +++ b/test/hotspot/jtreg/compiler/arraycopy/stress/TestStressArrayCopy.java @@ -173,7 +173,7 @@ public static void main(String... args) throws Exception { for (String className : classNames) { // Start a new job { - ProcessBuilder pb = ProcessTools.createTestJvm(mix(c, "-Xmx256m", className)); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(mix(c, "-Xmx256m", className)); Process p = pb.start(); OutputAnalyzer oa = new OutputAnalyzer(p); forks.add(new Fork(p, oa)); diff --git a/test/hotspot/jtreg/compiler/blackhole/BlackholeExistingIntrinsicWarningTest.java b/test/hotspot/jtreg/compiler/blackhole/BlackholeExistingIntrinsicWarningTest.java index 8d43b1e85a31b..104e7661e7e17 100644 --- a/test/hotspot/jtreg/compiler/blackhole/BlackholeExistingIntrinsicWarningTest.java +++ b/test/hotspot/jtreg/compiler/blackhole/BlackholeExistingIntrinsicWarningTest.java @@ -65,14 +65,14 @@ private static List cmdline(String[] args) { } public static void shouldFail(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldContain(MSG); } public static void shouldPass(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldNotContain(MSG); diff --git a/test/hotspot/jtreg/compiler/blackhole/BlackholeExperimentalUnlockTest.java b/test/hotspot/jtreg/compiler/blackhole/BlackholeExperimentalUnlockTest.java index 226c28251f247..6597b2186f266 100644 --- a/test/hotspot/jtreg/compiler/blackhole/BlackholeExperimentalUnlockTest.java +++ b/test/hotspot/jtreg/compiler/blackhole/BlackholeExperimentalUnlockTest.java @@ -65,14 +65,14 @@ private static List cmdline(String[] args) { } public static void shouldFail(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldContain(MSG); } public static void shouldPass(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldNotContain(MSG); diff --git a/test/hotspot/jtreg/compiler/blackhole/BlackholeIntrinsicTest.java b/test/hotspot/jtreg/compiler/blackhole/BlackholeIntrinsicTest.java index a7a72a56ff179..8c8cbc5e88d17 100644 --- a/test/hotspot/jtreg/compiler/blackhole/BlackholeIntrinsicTest.java +++ b/test/hotspot/jtreg/compiler/blackhole/BlackholeIntrinsicTest.java @@ -134,7 +134,7 @@ public static void check(String test, String... args) throws IOException { cmdline.add("compiler.blackhole.BlackholeIntrinsicTest"); cmdline.add(test); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.stderrShouldBeEmpty(); diff --git a/test/hotspot/jtreg/compiler/blackhole/BlackholeNonEmptyWarningTest.java b/test/hotspot/jtreg/compiler/blackhole/BlackholeNonEmptyWarningTest.java index 43cbdfd773ba2..c07754b37ea5c 100644 --- a/test/hotspot/jtreg/compiler/blackhole/BlackholeNonEmptyWarningTest.java +++ b/test/hotspot/jtreg/compiler/blackhole/BlackholeNonEmptyWarningTest.java @@ -64,14 +64,14 @@ private static List cmdline(String[] args) { } public static void shouldFail(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldContain(MSG); } public static void shouldPass(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldNotContain(MSG); diff --git a/test/hotspot/jtreg/compiler/blackhole/BlackholeNonStaticWarningTest.java b/test/hotspot/jtreg/compiler/blackhole/BlackholeNonStaticWarningTest.java index f9e12ba3f9d6c..ff84070b4e164 100644 --- a/test/hotspot/jtreg/compiler/blackhole/BlackholeNonStaticWarningTest.java +++ b/test/hotspot/jtreg/compiler/blackhole/BlackholeNonStaticWarningTest.java @@ -64,14 +64,14 @@ private static List cmdline(String[] args) { } public static void shouldFail(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldContain(MSG); } public static void shouldPass(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldNotContain(MSG); diff --git a/test/hotspot/jtreg/compiler/blackhole/BlackholeNonVoidWarningTest.java b/test/hotspot/jtreg/compiler/blackhole/BlackholeNonVoidWarningTest.java index 555f677912494..c3a780576fe8e 100644 --- a/test/hotspot/jtreg/compiler/blackhole/BlackholeNonVoidWarningTest.java +++ b/test/hotspot/jtreg/compiler/blackhole/BlackholeNonVoidWarningTest.java @@ -64,14 +64,14 @@ private static List cmdline(String[] args) { } public static void shouldFail(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldContain(MSG); } public static void shouldPass(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmdline(args)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldNotContain(MSG); diff --git a/test/hotspot/jtreg/compiler/c1/TestRangeCheckEliminated.java b/test/hotspot/jtreg/compiler/c1/TestRangeCheckEliminated.java index 7d4dd350e0301..9da8a5390da13 100644 --- a/test/hotspot/jtreg/compiler/c1/TestRangeCheckEliminated.java +++ b/test/hotspot/jtreg/compiler/c1/TestRangeCheckEliminated.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ public static void main(String[] args) throws Throwable { test_constant_array.class.getName() }; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(procArgs); String output = new OutputAnalyzer(pb.start()).getOutput(); // should have 2 "can be fully eliminated" System.out.println(output); @@ -74,7 +74,7 @@ public static void main(String[] args) throws Throwable { test_multi_constant_array.class.getName() }; - pb = ProcessTools.createJavaProcessBuilder(procArgs); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(procArgs); output = new OutputAnalyzer(pb.start()).getOutput(); // should have 1 "can be fully eliminated" System.out.println(output); @@ -94,7 +94,7 @@ public static void main(String[] args) throws Throwable { test_multi_new_array.class.getName() }; - pb = ProcessTools.createJavaProcessBuilder(procArgs); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(procArgs); output = new OutputAnalyzer(pb.start()).getOutput(); // should have 2 "can be fully eliminated" System.out.println(output); diff --git a/test/hotspot/jtreg/compiler/c2/TestBit.java b/test/hotspot/jtreg/compiler/c2/TestBit.java index 02596b7ee55fc..a3c9421a3f910 100644 --- a/test/hotspot/jtreg/compiler/c2/TestBit.java +++ b/test/hotspot/jtreg/compiler/c2/TestBit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,7 @@ static void runTest(String testName) throws Exception { "-XX:CompileCommand=compileonly," + className + "::tst*", className, testName}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(procArgs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); String expectedTestBitInstruction = diff --git a/test/hotspot/jtreg/compiler/c2/aarch64/TestFarJump.java b/test/hotspot/jtreg/compiler/c2/aarch64/TestFarJump.java index f47331a6d8004..d461d56d8a390 100644 --- a/test/hotspot/jtreg/compiler/c2/aarch64/TestFarJump.java +++ b/test/hotspot/jtreg/compiler/c2/aarch64/TestFarJump.java @@ -95,7 +95,7 @@ static void runVM(boolean bigCodeHeap) throws Exception { "-XX:+PrintAssembly", className}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(procArgs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); List lines = output.asLines(); diff --git a/test/hotspot/jtreg/compiler/c2/aarch64/TestSVEWithJNI.java b/test/hotspot/jtreg/compiler/c2/aarch64/TestSVEWithJNI.java index eeb10e99547a6..81abcd27959b8 100644 --- a/test/hotspot/jtreg/compiler/c2/aarch64/TestSVEWithJNI.java +++ b/test/hotspot/jtreg/compiler/c2/aarch64/TestSVEWithJNI.java @@ -1,27 +1,27 @@ /* -* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. -* Copyright (c) 2020, Arm Limited. All rights reserved. -* 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. -* -*/ + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, Arm Limited. All rights reserved. + * 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 @@ -79,7 +79,7 @@ public static ProcessBuilder createProcessBuilder(String [] args, String mode) { Collections.addAll(vmopts, "-Dtest.jdk=" + testjdkPath); Collections.addAll(vmopts, args); Collections.addAll(vmopts, TestSVEWithJNI.class.getName(), mode); - return ProcessTools.createJavaProcessBuilder(vmopts.toArray(new String[vmopts.size()])); + return ProcessTools.createLimitedTestJavaProcessBuilder(vmopts.toArray(new String[vmopts.size()])); } public static void main(String [] args) throws Exception { diff --git a/test/hotspot/jtreg/compiler/c2/aarch64/TestTrampoline.java b/test/hotspot/jtreg/compiler/c2/aarch64/TestTrampoline.java index cf763555ebc5c..114f7f9bfab59 100644 --- a/test/hotspot/jtreg/compiler/c2/aarch64/TestTrampoline.java +++ b/test/hotspot/jtreg/compiler/c2/aarch64/TestTrampoline.java @@ -57,7 +57,7 @@ public static void main(String[] args) throws Exception { command.add("-XX:ReservedCodeCacheSize=130M"); command.add("-XX:+SegmentedCodeCache"); command.add(testClassName); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(command); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(command); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); analyzer.shouldHaveExitValue(0); System.out.println(analyzer.getOutput()); diff --git a/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java b/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java index 055d54ccb4fa7..10bc237f2be0f 100644 --- a/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java +++ b/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2018, 2020, Red Hat, Inc. All rights reserved. - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -132,7 +132,7 @@ public void runtest(String classname, String testType) throws Throwable { public void runtest(String classname, String testType, boolean useCompressedOops, String[] procArgs) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(procArgs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.stderrShouldBeEmptyIgnoreVMWarnings(); diff --git a/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java b/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java index a025962081cc3..6ad45edd26b3a 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java +++ b/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -177,11 +177,11 @@ public boolean generateReplay(boolean needCoreDump, String... vmopts) { options.add("'" + getTestClass() + "'"); crashOut = ProcessTools.executeProcess( CoreUtils.addCoreUlimitCommand( - ProcessTools.createTestJvm(options.toArray(new String[0])))); + ProcessTools.createTestJavaProcessBuilder(options.toArray(new String[0])))); } else { options.add("-XX:CompileOnly=" + getTestClass() + "::" + getTestMethod()); options.add(getTestClass()); - crashOut = ProcessTools.executeProcess(ProcessTools.createTestJvm(options)); + crashOut = ProcessTools.executeProcess(ProcessTools.createTestJavaProcessBuilder(options)); } crashOutputString = crashOut.getOutput(); Asserts.assertNotEquals(crashOut.getExitValue(), 0, "Crash JVM exits gracefully"); @@ -288,7 +288,7 @@ public void nonTieredTests(int compLevel) { private String[] getTestJvmCommandlineWithPrefix(String prefix, String... args) { try { - String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJvm(args)); + String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJavaProcessBuilder(args)); return new String[]{"sh", "-c", prefix + (Platform.isWindows() ? cmd.replace('\\', '/').replace(";", "\\;").replace("|", "\\|") : cmd)}; } catch(Throwable t) { diff --git a/test/hotspot/jtreg/compiler/ciReplay/DumpReplayBase.java b/test/hotspot/jtreg/compiler/ciReplay/DumpReplayBase.java index 4d78399357838..3597c0729a175 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/DumpReplayBase.java +++ b/test/hotspot/jtreg/compiler/ciReplay/DumpReplayBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -79,7 +79,7 @@ public boolean generateReplay(String... vmopts) { options.add("-XX:CompileCommand=compileonly," + getTestClass() + "::" + getTestMethod()); options.add("-Xbatch"); options.add(getTestClass()); - oa = ProcessTools.executeProcess(ProcessTools.createTestJvm(options)); + oa = ProcessTools.executeProcess(ProcessTools.createTestJavaProcessBuilder(options)); Asserts.assertEquals(oa.getExitValue(), 0, "Crash JVM exits gracefully"); replayFiles = Files.list(Paths.get(".")) .map(Path::toFile) diff --git a/test/hotspot/jtreg/compiler/ciReplay/SABase.java b/test/hotspot/jtreg/compiler/ciReplay/SABase.java index db576d73631d9..66f2eb1106fb2 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/SABase.java +++ b/test/hotspot/jtreg/compiler/ciReplay/SABase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,7 @@ public void testAction() { } ProcessBuilder pb; try { - pb = ProcessTools.createTestJvm("--add-modules", "jdk.hotspot.agent", + pb = ProcessTools.createTestJavaProcessBuilder("--add-modules", "jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "sun.jvm.hotspot.CLHSDB", JDKToolFinder.getTestJDKTool("java"), TEST_CORE_FILE_NAME); diff --git a/test/hotspot/jtreg/compiler/ciReplay/TestInvalidReplayFile.java b/test/hotspot/jtreg/compiler/ciReplay/TestInvalidReplayFile.java index 8112a7a43f69d..45a2e647c80f9 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/TestInvalidReplayFile.java +++ b/test/hotspot/jtreg/compiler/ciReplay/TestInvalidReplayFile.java @@ -54,7 +54,7 @@ public static void main(String[] args) throws Exception { w.flush(); w.close(); - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:+ReplayCompiles", "-XX:ReplayDataFile=./bogus-replay-file.txt"); diff --git a/test/hotspot/jtreg/compiler/codecache/CheckCodeCacheInfo.java b/test/hotspot/jtreg/compiler/codecache/CheckCodeCacheInfo.java index 53d555ee139dd..f6a2536515e8f 100644 --- a/test/hotspot/jtreg/compiler/codecache/CheckCodeCacheInfo.java +++ b/test/hotspot/jtreg/compiler/codecache/CheckCodeCacheInfo.java @@ -66,9 +66,9 @@ public class CheckCodeCacheInfo { public static void main(String[] args) throws Exception { ProcessBuilder pb; - pb = ProcessTools.createTestJvm("-XX:+PrintCodeCache", - "-XX:+Verbose", - "-version"); + pb = ProcessTools.createTestJavaProcessBuilder("-XX:+PrintCodeCache", + "-XX:+Verbose", + "-version"); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldHaveExitValue(0); out.stdoutShouldMatch(VERBOSE_REGEXP); diff --git a/test/hotspot/jtreg/compiler/codecache/CheckLargePages.java b/test/hotspot/jtreg/compiler/codecache/CheckLargePages.java index 8e2db5067d8c7..5e05a0fae57a1 100644 --- a/test/hotspot/jtreg/compiler/codecache/CheckLargePages.java +++ b/test/hotspot/jtreg/compiler/codecache/CheckLargePages.java @@ -50,7 +50,7 @@ public static void main(String[] args) throws Exception { final boolean largePages = WHITE_BOX.getBooleanVMFlag("UseLargePages"); final long largePageSize = WHITE_BOX.getVMLargePageSize(); if (largePages && (largePageSize == 1024 * 1024 * 1024)) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseLargePages", "-XX:+SegmentedCodeCache", "-XX:InitialCodeCacheSize=2g", diff --git a/test/hotspot/jtreg/compiler/codecache/CheckReservedInitialCodeCacheSizeArgOrder.java b/test/hotspot/jtreg/compiler/codecache/CheckReservedInitialCodeCacheSizeArgOrder.java index 63e7f83a303f5..f4a1cc3f0e700 100644 --- a/test/hotspot/jtreg/compiler/codecache/CheckReservedInitialCodeCacheSizeArgOrder.java +++ b/test/hotspot/jtreg/compiler/codecache/CheckReservedInitialCodeCacheSizeArgOrder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,8 +42,8 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb1, pb2; OutputAnalyzer out1, out2; - pb1 = ProcessTools.createJavaProcessBuilder("-XX:InitialCodeCacheSize=4m", "-XX:ReservedCodeCacheSize=8m", "-version"); - pb2 = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=8m", "-XX:InitialCodeCacheSize=4m", "-version"); + pb1 = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:InitialCodeCacheSize=4m", "-XX:ReservedCodeCacheSize=8m", "-version"); + pb2 = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ReservedCodeCacheSize=8m", "-XX:InitialCodeCacheSize=4m", "-version"); out1 = new OutputAnalyzer(pb1.start()); out2 = new OutputAnalyzer(pb2.start()); diff --git a/test/hotspot/jtreg/compiler/codecache/CheckSegmentedCodeCache.java b/test/hotspot/jtreg/compiler/codecache/CheckSegmentedCodeCache.java index ae884a1fa8c38..f79d7da769591 100644 --- a/test/hotspot/jtreg/compiler/codecache/CheckSegmentedCodeCache.java +++ b/test/hotspot/jtreg/compiler/codecache/CheckSegmentedCodeCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,80 +89,80 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb; // Disabled with ReservedCodeCacheSize < 240MB - pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=239m", - "-XX:+PrintCodeCache", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ReservedCodeCacheSize=239m", + "-XX:+PrintCodeCache", + "-version"); verifySegmentedCodeCache(pb, false); // Disabled without TieredCompilation - pb = ProcessTools.createJavaProcessBuilder("-XX:-TieredCompilation", - "-XX:+PrintCodeCache", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:-TieredCompilation", + "-XX:+PrintCodeCache", + "-version"); verifySegmentedCodeCache(pb, false); // Enabled with TieredCompilation and ReservedCodeCacheSize >= 240MB - pb = ProcessTools.createJavaProcessBuilder("-XX:+TieredCompilation", - "-XX:ReservedCodeCacheSize=240m", - "-XX:+PrintCodeCache", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+TieredCompilation", + "-XX:ReservedCodeCacheSize=240m", + "-XX:+PrintCodeCache", + "-version"); verifySegmentedCodeCache(pb, true); - pb = ProcessTools.createJavaProcessBuilder("-XX:+TieredCompilation", - "-XX:ReservedCodeCacheSize=400m", - "-XX:+PrintCodeCache", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+TieredCompilation", + "-XX:ReservedCodeCacheSize=400m", + "-XX:+PrintCodeCache", + "-version"); verifySegmentedCodeCache(pb, true); // Always enabled if SegmentedCodeCache is set - pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", - "-XX:-TieredCompilation", - "-XX:ReservedCodeCacheSize=239m", - "-XX:+PrintCodeCache", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+SegmentedCodeCache", + "-XX:-TieredCompilation", + "-XX:ReservedCodeCacheSize=239m", + "-XX:+PrintCodeCache", + "-version"); verifySegmentedCodeCache(pb, true); // The profiled and non-profiled code heaps should not be available in // interpreter-only mode - pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", - "-Xint", - "-XX:+PrintCodeCache", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+SegmentedCodeCache", + "-Xint", + "-XX:+PrintCodeCache", + "-version"); verifyCodeHeapNotExists(pb, PROFILED, NON_PROFILED); // If we stop compilation at CompLevel_none or CompLevel_simple we // don't need a profiled code heap. - pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", - "-XX:TieredStopAtLevel=0", - "-XX:+PrintCodeCache", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+SegmentedCodeCache", + "-XX:TieredStopAtLevel=0", + "-XX:+PrintCodeCache", + "-version"); verifyCodeHeapNotExists(pb, PROFILED); - pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", - "-XX:TieredStopAtLevel=1", - "-XX:+PrintCodeCache", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+SegmentedCodeCache", + "-XX:TieredStopAtLevel=1", + "-XX:+PrintCodeCache", + "-version"); verifyCodeHeapNotExists(pb, PROFILED); // Fails with too small non-nmethod code heap size - pb = ProcessTools.createJavaProcessBuilder("-XX:NonNMethodCodeHeapSize=100K", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:NonNMethodCodeHeapSize=100K", + "-version"); failsWith(pb, "Invalid NonNMethodCodeHeapSize"); // Fails if code heap sizes do not add up - pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", - "-XX:ReservedCodeCacheSize=10M", - "-XX:NonNMethodCodeHeapSize=5M", - "-XX:ProfiledCodeHeapSize=5M", - "-XX:NonProfiledCodeHeapSize=5M", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+SegmentedCodeCache", + "-XX:ReservedCodeCacheSize=10M", + "-XX:NonNMethodCodeHeapSize=5M", + "-XX:ProfiledCodeHeapSize=5M", + "-XX:NonProfiledCodeHeapSize=5M", + "-version"); failsWith(pb, "Invalid code heap sizes"); // Fails if not enough space for VM internal code long minUseSpace = WHITE_BOX.getUintxVMFlag("CodeCacheMinimumUseSpace"); // minimum size: CodeCacheMinimumUseSpace DEBUG_ONLY(* 3) long minSize = (Platform.isDebugBuild() ? 3 : 1) * minUseSpace; - pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", - "-XX:ReservedCodeCacheSize=" + minSize, - "-XX:InitialCodeCacheSize=100K", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+SegmentedCodeCache", + "-XX:ReservedCodeCacheSize=" + minSize, + "-XX:InitialCodeCacheSize=100K", + "-version"); failsWith(pb, "Not enough space in non-nmethod code heap to run VM"); } } diff --git a/test/hotspot/jtreg/compiler/codecache/CheckUpperLimit.java b/test/hotspot/jtreg/compiler/codecache/CheckUpperLimit.java index 9509da6cf32fc..7ec5e744dd645 100644 --- a/test/hotspot/jtreg/compiler/codecache/CheckUpperLimit.java +++ b/test/hotspot/jtreg/compiler/codecache/CheckUpperLimit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=2049m", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ReservedCodeCacheSize=2049m", "-version"); out = new OutputAnalyzer(pb.start()); out.shouldContain("Invalid ReservedCodeCacheSize="); out.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/compiler/codecache/CodeCacheFullCountTest.java b/test/hotspot/jtreg/compiler/codecache/CodeCacheFullCountTest.java index 577cb03a9397c..f3233bdaecab9 100644 --- a/test/hotspot/jtreg/compiler/codecache/CodeCacheFullCountTest.java +++ b/test/hotspot/jtreg/compiler/codecache/CodeCacheFullCountTest.java @@ -63,7 +63,7 @@ public static void wasteCodeCache() throws Throwable { } public static void runTest() throws Throwable { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:ReservedCodeCacheSize=2496k", "-XX:-UseCodeCacheFlushing", "-XX:-MethodFlushing", "CodeCacheFullCountTest", "WasteCodeCache"); OutputAnalyzer oa = ProcessTools.executeProcess(pb); // Ignore adapter creation failures diff --git a/test/hotspot/jtreg/compiler/compilercontrol/TestConflictInlineCommands.java b/test/hotspot/jtreg/compiler/compilercontrol/TestConflictInlineCommands.java index 2b33cbb5cefdf..bd4bde90b7f0c 100644 --- a/test/hotspot/jtreg/compiler/compilercontrol/TestConflictInlineCommands.java +++ b/test/hotspot/jtreg/compiler/compilercontrol/TestConflictInlineCommands.java @@ -39,7 +39,7 @@ public class TestConflictInlineCommands { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:CompileCommand=inline,*TestConflictInlineCommands::caller", "-XX:CompileCommand=dontinline,*TestConflictInlineCommands::caller", "-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly,*Launcher::main", @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { analyzer.shouldContain("disallowed by CompileCommand"); analyzer.shouldNotContain("force inline by CompileCommand"); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbatch", "-XX:CompileCommand=dontinline,*TestConflictInlineCommands::*caller", "-XX:CompileCommand=inline,*TestConflictInlineCommands::caller", diff --git a/test/hotspot/jtreg/compiler/cpuflags/RestoreMXCSR.java b/test/hotspot/jtreg/compiler/cpuflags/RestoreMXCSR.java index 176d23409afdb..fa748cb21ac5b 100644 --- a/test/hotspot/jtreg/compiler/cpuflags/RestoreMXCSR.java +++ b/test/hotspot/jtreg/compiler/cpuflags/RestoreMXCSR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder("-XX:+RestoreMXCSROnJNICalls", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+RestoreMXCSROnJNICalls", "-version"); out = new OutputAnalyzer(pb.start()); out.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/compiler/debug/TestGenerateStressSeed.java b/test/hotspot/jtreg/compiler/debug/TestGenerateStressSeed.java index 3020bf1df34ec..f03667a55cebd 100644 --- a/test/hotspot/jtreg/compiler/debug/TestGenerateStressSeed.java +++ b/test/hotspot/jtreg/compiler/debug/TestGenerateStressSeed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,7 @@ public static void main(String[] args) throws Exception { "-Xcomp", "-XX:-TieredCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:CompileOnly=" + className + "::sum", "-XX:+" + stressOpt, "-XX:+LogCompilation", "-XX:LogFile=" + log, className, "10"}; - new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(procArgs).start()) + new OutputAnalyzer(ProcessTools.createLimitedTestJavaProcessBuilder(procArgs).start()) .shouldHaveExitValue(0); new OutputAnalyzer(Paths.get(log)) .shouldContain("stress_test seed"); diff --git a/test/hotspot/jtreg/compiler/debug/TestStressCM.java b/test/hotspot/jtreg/compiler/debug/TestStressCM.java index 4b3bd7865950b..0fb624bc16f30 100644 --- a/test/hotspot/jtreg/compiler/debug/TestStressCM.java +++ b/test/hotspot/jtreg/compiler/debug/TestStressCM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ static String cmTrace(String stressOpt, int stressSeed) throws Exception { "-XX:CompileOnly=" + className + "::sum", "-XX:+TraceOptoPipelining", "-XX:+" + stressOpt, "-XX:StressSeed=" + stressSeed, className, "10"}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(procArgs); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldHaveExitValue(0); // Extract the trace of our method (the last one after those of all diff --git a/test/hotspot/jtreg/compiler/debug/TestStressIGVNAndCCP.java b/test/hotspot/jtreg/compiler/debug/TestStressIGVNAndCCP.java index 242c6f69fb101..3ec49daa0eab4 100644 --- a/test/hotspot/jtreg/compiler/debug/TestStressIGVNAndCCP.java +++ b/test/hotspot/jtreg/compiler/debug/TestStressIGVNAndCCP.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ static String phaseTrace(String stressOption, String traceOption, "-XX:CompileOnly=" + className + "::sum", "-XX:+" + traceOption, "-XX:+" + stressOption, "-XX:StressSeed=" + stressSeed, className, "10"}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(procArgs); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldHaveExitValue(0); return out.getStdout(); diff --git a/test/hotspot/jtreg/compiler/debug/VerifyAdapterSharing.java b/test/hotspot/jtreg/compiler/debug/VerifyAdapterSharing.java index 00ec02911310a..89da61a576326 100644 --- a/test/hotspot/jtreg/compiler/debug/VerifyAdapterSharing.java +++ b/test/hotspot/jtreg/compiler/debug/VerifyAdapterSharing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder("-Xcomp", "-XX:+IgnoreUnrecognizedVMOptions", + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xcomp", "-XX:+IgnoreUnrecognizedVMOptions", "-XX:+VerifyAdapterSharing", "-version"); out = new OutputAnalyzer(pb.start()); out.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/compiler/escapeAnalysis/TestIterativeEA.java b/test/hotspot/jtreg/compiler/escapeAnalysis/TestIterativeEA.java index ef4db4635164f..f0524368d70d9 100644 --- a/test/hotspot/jtreg/compiler/escapeAnalysis/TestIterativeEA.java +++ b/test/hotspot/jtreg/compiler/escapeAnalysis/TestIterativeEA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ public class TestIterativeEA { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-server", "-XX:-TieredCompilation", "-Xbatch", "-XX:+PrintEliminateAllocations", Launcher.class.getName()); diff --git a/test/hotspot/jtreg/compiler/inlining/InlineAccessors.java b/test/hotspot/jtreg/compiler/inlining/InlineAccessors.java index 0d4da50cfc56b..934a13c97aac1 100644 --- a/test/hotspot/jtreg/compiler/inlining/InlineAccessors.java +++ b/test/hotspot/jtreg/compiler/inlining/InlineAccessors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ public class InlineAccessors { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", "-server", "-XX:-TieredCompilation", "-Xbatch", "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining", diff --git a/test/hotspot/jtreg/compiler/inlining/PrintInlining.java b/test/hotspot/jtreg/compiler/inlining/PrintInlining.java index a0975dee673f3..768fa90965db7 100644 --- a/test/hotspot/jtreg/compiler/inlining/PrintInlining.java +++ b/test/hotspot/jtreg/compiler/inlining/PrintInlining.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ public class PrintInlining { static void test(String option) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", "-server", "-XX:-TieredCompilation", "-Xbatch", "-XX:-UseOnStackReplacement", "-XX:CompileCommand=dontinline,*::bar", diff --git a/test/hotspot/jtreg/compiler/inlining/ResolvedClassTest.java b/test/hotspot/jtreg/compiler/inlining/ResolvedClassTest.java index 65394d5a38b33..c0f39f12e4add 100644 --- a/test/hotspot/jtreg/compiler/inlining/ResolvedClassTest.java +++ b/test/hotspot/jtreg/compiler/inlining/ResolvedClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class ResolvedClassTest { /* ======================================================================== */ static void testStatic() throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining", "-Xbatch", "-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly," + TestStatic.class.getName() + "::test", @@ -78,7 +78,7 @@ public static void main(String[] args) { /* ======================================================================== */ static void testStaticInit() throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining", "-Xbatch", "-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly," + TestStaticInit.class.getName() + "::test", @@ -115,7 +115,7 @@ public static void main(String[] args) { /* ======================================================================== */ static void testIndy() throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining", "-Xbatch", "-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly," + TestIndy.class.getName() + "::test", diff --git a/test/hotspot/jtreg/compiler/intrinsics/chacha/TestChaCha20.java b/test/hotspot/jtreg/compiler/intrinsics/chacha/TestChaCha20.java index a3b708fab81c9..c2275f6563e09 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/chacha/TestChaCha20.java +++ b/test/hotspot/jtreg/compiler/intrinsics/chacha/TestChaCha20.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2021, Red Hat, Inc. All rights reserved. - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,7 +127,7 @@ public static void main(String... args) throws Exception { for (String className : classNames) { // Start a new job { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( mix(c, "-Xmx256m", className)); Process p = pb.start(); OutputAnalyzer oa = new OutputAnalyzer(p); diff --git a/test/hotspot/jtreg/compiler/jsr292/ContinuousCallSiteTargetChange.java b/test/hotspot/jtreg/compiler/jsr292/ContinuousCallSiteTargetChange.java index e8e6551e453a1..2b501064b76e8 100644 --- a/test/hotspot/jtreg/compiler/jsr292/ContinuousCallSiteTargetChange.java +++ b/test/hotspot/jtreg/compiler/jsr292/ContinuousCallSiteTargetChange.java @@ -61,7 +61,7 @@ static void runTest(Class test, String... extraArgs) throws Exception { argsList.add(test.getName()); argsList.add(Integer.toString(ITERATIONS)); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(argsList); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(argsList); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/jsr292/MHInlineTest.java b/test/hotspot/jtreg/compiler/jsr292/MHInlineTest.java index a2358cb6edc50..a8e76f5797d43 100644 --- a/test/hotspot/jtreg/compiler/jsr292/MHInlineTest.java +++ b/test/hotspot/jtreg/compiler/jsr292/MHInlineTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ public class MHInlineTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", "-XX:-TieredCompilation", "-Xbatch", "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining", diff --git a/test/hotspot/jtreg/compiler/jsr292/PollutedTrapCounts.java b/test/hotspot/jtreg/compiler/jsr292/PollutedTrapCounts.java index 6e060c5a37505..b43a6f33a1eab 100644 --- a/test/hotspot/jtreg/compiler/jsr292/PollutedTrapCounts.java +++ b/test/hotspot/jtreg/compiler/jsr292/PollutedTrapCounts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ public class PollutedTrapCounts { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-XX:-TieredCompilation", "-Xbatch", "-XX:PerBytecodeRecompilationCutoff=10", "-XX:PerMethodRecompilationCutoff=10", diff --git a/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java b/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java index d299f4f6ac778..1c36ab78ac6bf 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java @@ -84,7 +84,7 @@ static void test(String explicitFlag, Expectation... expectations) throws Except String[] flags = {"-XX:+EnableJVMCIProduct", "-XX:+UseGraalJIT"}; String cwd = System.getProperty("user.dir"); for (String flag : flags) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", flag, "-XX:-UnlockExperimentalVMOptions", explicitFlag, "-XX:+PrintFlagsFinal", diff --git a/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java b/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java index 0cffca55dc434..1fec1eeb278c5 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ public class TestInvalidJVMCIOption { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+EagerJVMCI", "-XX:+UseJVMCICompiler", diff --git a/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java b/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java index 16eb6dfb8f9b1..4e4a013db409b 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public static void main(String[] args) throws Exception { } static void test(String enableFlag) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", enableFlag, "-Djvmci.Compiler=null", "-XX:+JVMCIPrintProperties"); diff --git a/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java b/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java index 423a575b6ea24..31e592ef906fa 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java @@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception { System.out.println("DONE IN MAIN"); return; } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+EagerJVMCI", "-XX:+UseJVMCICompiler", diff --git a/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java b/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java index d0c90bcd6da9b..511e0c4b98c48 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java @@ -83,7 +83,7 @@ private static long getTime() { } static void testSubprocess(boolean fatalError) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+UseJVMCICompiler", "-Djvmci.Compiler=ErrorCompiler", "-XX:-TieredCompilation", diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java index dba434d6d84ce..aa9252d4665d5 100644 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,7 +63,7 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI", "-XX:+PrintFlagsFinal", diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java index 21a9575b28b06..e5d1da81309af 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java @@ -167,7 +167,7 @@ public void jniEnomemTest() throws Exception { } String[] names = {"translate", "attachCurrentThread", "registerNativeMethods"}; for (String name : names) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI", "-XX:-UseJVMCICompiler", diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/TestVMProcess.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/TestVMProcess.java index d8e10e7631577..2c63bbe95895c 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/TestVMProcess.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/TestVMProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -146,7 +146,7 @@ private static String[] getVerifyFlags() { } private void start() { - ProcessBuilder process = ProcessTools.createJavaProcessBuilder(cmds); + ProcessBuilder process = ProcessTools.createLimitedTestJavaProcessBuilder(cmds); try { // Calls 'main' of TestVM to run all specified tests with commands 'cmds'. // Use executeProcess instead of executeTestJvm as we have already added the JTreg VM and diff --git a/test/hotspot/jtreg/compiler/linkage/TestLinkageErrorInGenerateOopMap.java b/test/hotspot/jtreg/compiler/linkage/TestLinkageErrorInGenerateOopMap.java index d61fc44dad4e5..ad02dd617a733 100644 --- a/test/hotspot/jtreg/compiler/linkage/TestLinkageErrorInGenerateOopMap.java +++ b/test/hotspot/jtreg/compiler/linkage/TestLinkageErrorInGenerateOopMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public class TestLinkageErrorInGenerateOopMap { public static void main(String args[]) throws Exception { if (args.length == 0) { // Spawn new VM instance to execute test - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:-BytecodeVerificationRemote", "-XX:-BytecodeVerificationLocal", diff --git a/test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMiningIterShortLoop.java b/test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMiningIterShortLoop.java index ecceaa4c4b797..80c046e7a3653 100644 --- a/test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMiningIterShortLoop.java +++ b/test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMiningIterShortLoop.java @@ -37,7 +37,7 @@ public class CheckLoopStripMiningIterShortLoop { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", "-XX:+PrintFlagsFinal", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", "-XX:+PrintFlagsFinal", "-version"); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java b/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java index 6bb7ca445c5f2..c356e4495c245 100644 --- a/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java +++ b/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java @@ -94,7 +94,7 @@ public static void testWith(Consumer check, String msg, boolean System.arraycopy(args, 0, cmds, 1, args.length); cmds[args.length + 1] = "-XX:+PrintFlagsFinal"; cmds[args.length + 2] = "-version"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmds); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWait.java b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWait.java index 66cf04fd62f7b..d5318a7bba461 100644 --- a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWait.java +++ b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWait.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright 2016 Azul Systems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -43,7 +43,7 @@ public class TestOnSpinWait { public static void main(String[] args) throws Exception { // Test C2 compiler - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", "-XX:-TieredCompilation", "-Xbatch", "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64.java b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64.java index 86f2d55e19fd6..76953bfb12422 100644 --- a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64.java +++ b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64.java @@ -71,7 +71,7 @@ public static void main(String[] args) throws Exception { command.add("-XX:CompileCommand=compileonly," + Launcher.class.getName() + "::" + "test"); command.add(Launcher.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(command); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(command); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64DefaultFlags.java b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64DefaultFlags.java index 1a6d5cb3dc723..f7ed60960808c 100644 --- a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64DefaultFlags.java +++ b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitAArch64DefaultFlags.java @@ -87,9 +87,9 @@ public static void main(String[] args) throws Exception { final String cpuModel = cpuFeatures.get(0); if (isCPUModelNeoverseN1(cpuModel)) { - checkFinalFlagsEqualTo(ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintFlagsFinal", "-version"), + checkFinalFlagsEqualTo(ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintFlagsFinal", "-version"), "isb", "1"); - checkFinalFlagsEqualTo(ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:OnSpinWaitInstCount=2", "-XX:+PrintFlagsFinal", "-version"), + checkFinalFlagsEqualTo(ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:OnSpinWaitInstCount=2", "-XX:+PrintFlagsFinal", "-version"), "isb", "2"); } else { System.out.println("Skip because no defaults for CPU model: " + cpuModel); diff --git a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitC1.java b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitC1.java index fde38cf858efd..380a818508442 100644 --- a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitC1.java +++ b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitC1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright 2016 Azul Systems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -45,7 +45,7 @@ public class TestOnSpinWaitC1 { public static void main(String[] args) throws Exception { // Test C1 compiler - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "-Xbatch", "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitNoneAArch64.java b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitNoneAArch64.java index 7569d9d07a630..51746b4c24503 100644 --- a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitNoneAArch64.java +++ b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitNoneAArch64.java @@ -54,7 +54,7 @@ public static void main(String[] args) throws Exception { command.add(Launcher.class.getName()); // Test C2 compiler - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(command); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(command); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitRISCV64.java b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitRISCV64.java index 78189e3c0a381..ad524065f46e1 100644 --- a/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitRISCV64.java +++ b/test/hotspot/jtreg/compiler/onSpinWait/TestOnSpinWaitRISCV64.java @@ -64,7 +64,7 @@ public static void main(String[] args) throws Exception { command.add("-Xbatch"); command.add(Launcher.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(command); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(command); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/oracle/CheckCompileCommandOption.java b/test/hotspot/jtreg/compiler/oracle/CheckCompileCommandOption.java index 96279f9412fb4..d6d989d500d87 100644 --- a/test/hotspot/jtreg/compiler/oracle/CheckCompileCommandOption.java +++ b/test/hotspot/jtreg/compiler/oracle/CheckCompileCommandOption.java @@ -251,7 +251,7 @@ private static void verifyValidOption(String[] arguments, String[] expected_outp ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder(arguments); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); out = new OutputAnalyzer(pb.start()); for (String expected_output : expected_outputs) { @@ -266,7 +266,7 @@ private static void verifyInvalidOption(String[] arguments) throws Exception { ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder(arguments); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); out = new OutputAnalyzer(pb.start()); out.shouldContain("CompileCommand: An error occurred during parsing"); @@ -277,7 +277,7 @@ private static void verifyInvalidOption(String[] arguments, String[] expected_ou ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder(arguments); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); out = new OutputAnalyzer(pb.start()); for (String expected_output : expected_outputs) { diff --git a/test/hotspot/jtreg/compiler/oracle/TestCompileCommand.java b/test/hotspot/jtreg/compiler/oracle/TestCompileCommand.java index 0279843b590f2..6cb80d0a0e3b8 100644 --- a/test/hotspot/jtreg/compiler/oracle/TestCompileCommand.java +++ b/test/hotspot/jtreg/compiler/oracle/TestCompileCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ private static void verifyValidOption(String[] arguments, String[] expected_outp ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder(arguments); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); out = new OutputAnalyzer(pb.start()); for (String expected_output : expected_outputs) { diff --git a/test/hotspot/jtreg/compiler/oracle/TestInvalidCompileCommand.java b/test/hotspot/jtreg/compiler/oracle/TestInvalidCompileCommand.java index bd3495d6db81d..6e23aa5d6e043 100644 --- a/test/hotspot/jtreg/compiler/oracle/TestInvalidCompileCommand.java +++ b/test/hotspot/jtreg/compiler/oracle/TestInvalidCompileCommand.java @@ -83,7 +83,7 @@ private static void verifyInvalidOption(String[] arguments, String[] expected_ou ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder(arguments); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); out = new OutputAnalyzer(pb.start()); for (String expected_output : expected_outputs) { diff --git a/test/hotspot/jtreg/compiler/rangechecks/TestRangeCheckHoistingScaledIV.java b/test/hotspot/jtreg/compiler/rangechecks/TestRangeCheckHoistingScaledIV.java index 88e6fcdcf9a9d..e342adf595c61 100644 --- a/test/hotspot/jtreg/compiler/rangechecks/TestRangeCheckHoistingScaledIV.java +++ b/test/hotspot/jtreg/compiler/rangechecks/TestRangeCheckHoistingScaledIV.java @@ -81,7 +81,7 @@ public static void main(String[] args) { } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "--add-modules", "jdk.incubator.vector", "-Xbatch", "-XX:+TraceLoopPredicate", Launcher.class.getName()); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/runtime/cr8015436/Driver8015436.java b/test/hotspot/jtreg/compiler/runtime/cr8015436/Driver8015436.java index 36f4266c7d532..bdf221b84c60d 100644 --- a/test/hotspot/jtreg/compiler/runtime/cr8015436/Driver8015436.java +++ b/test/hotspot/jtreg/compiler/runtime/cr8015436/Driver8015436.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ public class Driver8015436 { public static void main(String args[]) { OutputAnalyzer oa; try { - oa = ProcessTools.executeProcess(ProcessTools.createTestJvm( + oa = ProcessTools.executeProcess(ProcessTools.createTestJavaProcessBuilder( Test8015436.class.getName())); } catch (Exception ex) { throw new Error("TESTBUG: exception while running child process: " + ex, ex); diff --git a/test/hotspot/jtreg/compiler/sharedstubs/SharedStubToInterpTest.java b/test/hotspot/jtreg/compiler/sharedstubs/SharedStubToInterpTest.java index 3e578225e5307..5dd938442cc82 100644 --- a/test/hotspot/jtreg/compiler/sharedstubs/SharedStubToInterpTest.java +++ b/test/hotspot/jtreg/compiler/sharedstubs/SharedStubToInterpTest.java @@ -67,7 +67,7 @@ private static void runTest(String compiler, String test) throws Exception { command.add("-XX:CompileCommand=dontinline," + testClassName + "::" + "log02"); command.add(testClassName); - ProcessBuilder pb = ProcessTools.createTestJvm(command); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(command); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/sharedstubs/SharedTrampolineTest.java b/test/hotspot/jtreg/compiler/sharedstubs/SharedTrampolineTest.java index 1cfa210e3d8a2..f1e4d18b93a8c 100644 --- a/test/hotspot/jtreg/compiler/sharedstubs/SharedTrampolineTest.java +++ b/test/hotspot/jtreg/compiler/sharedstubs/SharedTrampolineTest.java @@ -60,7 +60,7 @@ private static void runTest(String compiler, String test) throws Exception { command.add(testClassName); command.add("a"); - ProcessBuilder pb = ProcessTools.createTestJvm(command); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(command); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/compiler/startup/NumCompilerThreadsCheck.java b/test/hotspot/jtreg/compiler/startup/NumCompilerThreadsCheck.java index 9761002c051b4..679f7ff8d0b10 100644 --- a/test/hotspot/jtreg/compiler/startup/NumCompilerThreadsCheck.java +++ b/test/hotspot/jtreg/compiler/startup/NumCompilerThreadsCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class NumCompilerThreadsCheck { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:CICompilerCount=-1"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CICompilerCount=-1"); OutputAnalyzer out = new OutputAnalyzer(pb.start()); String expectedOutput = "outside the allowed range"; diff --git a/test/hotspot/jtreg/compiler/startup/SmallCodeCacheStartup.java b/test/hotspot/jtreg/compiler/startup/SmallCodeCacheStartup.java index b32c4d48f8ae5..b3b92afa0d155 100644 --- a/test/hotspot/jtreg/compiler/startup/SmallCodeCacheStartup.java +++ b/test/hotspot/jtreg/compiler/startup/SmallCodeCacheStartup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,10 +44,10 @@ public class SmallCodeCacheStartup { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=3m", - "-XX:CICompilerCount=64", - "-Xcomp", - "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ReservedCodeCacheSize=3m", + "-XX:CICompilerCount=64", + "-Xcomp", + "-version"); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); try { analyzer.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/compiler/startup/StartupOutput.java b/test/hotspot/jtreg/compiler/startup/StartupOutput.java index 0f9ab3b1f9686..d97bcd0019a53 100644 --- a/test/hotspot/jtreg/compiler/startup/StartupOutput.java +++ b/test/hotspot/jtreg/compiler/startup/StartupOutput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,12 +43,12 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb; OutputAnalyzer out; - pb = ProcessTools.createJavaProcessBuilder("-Xint", "-XX:+DisplayVMOutputToStdout", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xint", "-XX:+DisplayVMOutputToStdout", "-version"); out = new OutputAnalyzer(pb.start()); out.shouldNotContain("no space to run compilers"); out.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-Xint", "-XX:ReservedCodeCacheSize=1770K", "-XX:InitialCodeCacheSize=4K", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xint", "-XX:ReservedCodeCacheSize=1770K", "-XX:InitialCodeCacheSize=4K", "-version"); out = new OutputAnalyzer(pb.start()); // The VM should not crash but may return an error message because we don't have enough space for adapters int exitCode = out.getExitValue(); diff --git a/test/hotspot/jtreg/compiler/testlibrary/rtm/RTMTestBase.java b/test/hotspot/jtreg/compiler/testlibrary/rtm/RTMTestBase.java index 40369000036da..b6535e65428c3 100644 --- a/test/hotspot/jtreg/compiler/testlibrary/rtm/RTMTestBase.java +++ b/test/hotspot/jtreg/compiler/testlibrary/rtm/RTMTestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,7 +63,7 @@ public class RTMTestBase { public static OutputAnalyzer executeRTMTest(CompilableTest test, String... options) throws Exception { ProcessBuilder processBuilder - = ProcessTools.createJavaProcessBuilder( + = ProcessTools.createLimitedTestJavaProcessBuilder( RTMTestBase.prepareTestOptions(test, options)); OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start()); @@ -83,7 +83,7 @@ public static OutputAnalyzer executeRTMTest(CompilableTest test, public static OutputAnalyzer executeRTMTest(String logFileName, CompilableTest test, String... options) throws Exception { ProcessBuilder processBuilder - = ProcessTools.createJavaProcessBuilder( + = ProcessTools.createLimitedTestJavaProcessBuilder( RTMTestBase.prepareTestOptions(logFileName, test, options)); OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start()); diff --git a/test/hotspot/jtreg/compiler/types/correctness/OffTest.java b/test/hotspot/jtreg/compiler/types/correctness/OffTest.java index 73574447eaf92..6f2354cf89592 100644 --- a/test/hotspot/jtreg/compiler/types/correctness/OffTest.java +++ b/test/hotspot/jtreg/compiler/types/correctness/OffTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,7 +86,7 @@ private static void runTest() throws Exception { OPTIONS[TYPE_PROFILE_INDEX] = typeProfileLevel; OPTIONS[USE_TYPE_SPECULATION_INDEX] = useTypeSpeculation; OPTIONS[PROFILING_TYPE_INDEX] = type.name(); - ProcessBuilder processBuilder = ProcessTools.createTestJvm(OPTIONS); + ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder(OPTIONS); OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start()); outputAnalyzer.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/compiler/vectorization/TestBufferVectorization.java b/test/hotspot/jtreg/compiler/vectorization/TestBufferVectorization.java index bb2bb994bc961..95970256c48d3 100644 --- a/test/hotspot/jtreg/compiler/vectorization/TestBufferVectorization.java +++ b/test/hotspot/jtreg/compiler/vectorization/TestBufferVectorization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -224,11 +224,11 @@ static void verify_vectors(String testName) { ProcessBuilder pb; OutputAnalyzer out; try { - pb = ProcessTools.createJavaProcessBuilder("-XX:-BackgroundCompilation", - "-XX:+TraceNewVectors", - "compiler.vectorization.TestBufferVectorization", - testName, - "run"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:-BackgroundCompilation", + "-XX:+TraceNewVectors", + "compiler.vectorization.TestBufferVectorization", + testName, + "run"); out = new OutputAnalyzer(pb.start()); } catch (Exception e) { throw new RuntimeException(" Exception launching Java process: " + e); diff --git a/test/hotspot/jtreg/containers/cgroup/PlainRead.java b/test/hotspot/jtreg/containers/cgroup/PlainRead.java index 5e092e663c042..21eccd79835d4 100644 --- a/test/hotspot/jtreg/containers/cgroup/PlainRead.java +++ b/test/hotspot/jtreg/containers/cgroup/PlainRead.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,7 +67,7 @@ static public void isNotContainer(OutputAnalyzer oa) { public static void main(String[] args) throws Exception { WhiteBox wb = WhiteBox.getWhiteBox(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+container=trace", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os+container=trace", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (wb.isContainerized()) { diff --git a/test/hotspot/jtreg/gc/TestAgeOutput.java b/test/hotspot/jtreg/gc/TestAgeOutput.java index a926243161145..fa4445e34bbde 100644 --- a/test/hotspot/jtreg/gc/TestAgeOutput.java +++ b/test/hotspot/jtreg/gc/TestAgeOutput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -66,7 +66,7 @@ public static void checkPattern(String pattern, String what) throws Exception { } public static void runTest(String gcArg) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockExperimentalVMOptions", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/TestAllocateHeapAt.java index 0c80e14635d3e..8daf0bbcdc731 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ public class TestAllocateHeapAt { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:AllocateHeapAt=" + System.getProperty("test.dir", "."), "-Xlog:gc+heap=info", "-Xmx32m", diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java b/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java index 748ddd2f1f93a..372437b8898a9 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ public static void main(String args[]) throws Exception { f = new File(test_dir, UUID.randomUUID().toString()); } while(f.exists()); - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:AllocateHeapAt=" + f.getName(), "-Xlog:gc+heap=info", "-Xmx32m", diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java b/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java index ddb2d9568e206..b2d2f1e429d53 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ public static void main(String args[]) throws Exception { "-Xlog:gc+heap=info", "-version"}); - ProcessBuilder pb = ProcessTools.createTestJvm(flags); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println("Output:\n" + output.getOutput()); diff --git a/test/hotspot/jtreg/gc/TestCardTablePageCommits.java b/test/hotspot/jtreg/gc/TestCardTablePageCommits.java index ca14cfd71bec8..c468a771076b2 100644 --- a/test/hotspot/jtreg/gc/TestCardTablePageCommits.java +++ b/test/hotspot/jtreg/gc/TestCardTablePageCommits.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public static void main(String args[]) throws Exception { // because of 8kB pages, assume 4 KB pages for all other CPUs. String Xmx = "-Xmx4m"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( Xmx, "-XX:NativeMemoryTracking=detail", "-XX:+UseParallelGC", diff --git a/test/hotspot/jtreg/gc/TestNumWorkerOutput.java b/test/hotspot/jtreg/gc/TestNumWorkerOutput.java index 9de36ef99684d..fd48c5a85d0af 100644 --- a/test/hotspot/jtreg/gc/TestNumWorkerOutput.java +++ b/test/hotspot/jtreg/gc/TestNumWorkerOutput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -58,7 +58,7 @@ public static void checkPatternOnce(String pattern, String what) throws Exceptio } public static void runTest(String gcArg) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockExperimentalVMOptions", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/gc/TestPLABAdaptToMinTLABSize.java b/test/hotspot/jtreg/gc/TestPLABAdaptToMinTLABSize.java index 81d8529f6e955..c5c4854946d4b 100644 --- a/test/hotspot/jtreg/gc/TestPLABAdaptToMinTLABSize.java +++ b/test/hotspot/jtreg/gc/TestPLABAdaptToMinTLABSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ private static void runTest(boolean shouldSucceed, String... extraArgs) throws E Collections.addAll(testArguments, extraArgs); testArguments.add("-version"); - ProcessBuilder pb = ProcessTools.createTestJvm(testArguments); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(testArguments); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/gc/TestSmallHeap.java b/test/hotspot/jtreg/gc/TestSmallHeap.java index f4d44862ed6d8..a9b32eb81c8f9 100644 --- a/test/hotspot/jtreg/gc/TestSmallHeap.java +++ b/test/hotspot/jtreg/gc/TestSmallHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,7 +96,7 @@ public static void main(String[] args) throws Exception { private static void verifySmallHeapSize(String gc, long expectedMaxHeap) throws Exception { long minMaxHeap = 4 * 1024 * 1024; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( gc, "-Xmx" + minMaxHeap, "-XX:+PrintFlagsFinal", diff --git a/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java b/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java index e213479872297..4ad9f9675d91a 100644 --- a/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java +++ b/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public class TestVerifyDuringStartup { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:-UseTLAB", "-XX:+UnlockDiagnosticVMOptions", "-XX:+VerifyDuringStartup", diff --git a/test/hotspot/jtreg/gc/TestVerifySilently.java b/test/hotspot/jtreg/gc/TestVerifySilently.java index c4dd4dd779b5f..b7b07a1eb8ec2 100644 --- a/test/hotspot/jtreg/gc/TestVerifySilently.java +++ b/test/hotspot/jtreg/gc/TestVerifySilently.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,7 @@ private static OutputAnalyzer runTest(boolean verifySilently) throws Exception { "-XX:+VerifyAfterGC", (verifySilently ? "-Xlog:gc":"-Xlog:gc+verify=debug"), TestVerifySilentlyRunSystemGC.class.getName()}); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(vmOpts); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println("Output:\n" + output.getOutput()); diff --git a/test/hotspot/jtreg/gc/TestVerifySubSet.java b/test/hotspot/jtreg/gc/TestVerifySubSet.java index b326dd7fe7f65..5aa8cc3eb1334 100644 --- a/test/hotspot/jtreg/gc/TestVerifySubSet.java +++ b/test/hotspot/jtreg/gc/TestVerifySubSet.java @@ -59,7 +59,7 @@ private static OutputAnalyzer runTest(String subset) throws Exception { "-Xlog:gc+verify=debug", "-XX:VerifySubSet="+subset, TestVerifySubSetRunSystemGC.class.getName()}); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(vmOpts); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println("Output:\n" + output.getOutput()); diff --git a/test/hotspot/jtreg/gc/arguments/GCArguments.java b/test/hotspot/jtreg/gc/arguments/GCArguments.java index b2610da0c4ed2..c59a14954bfa3 100644 --- a/test/hotspot/jtreg/gc/arguments/GCArguments.java +++ b/test/hotspot/jtreg/gc/arguments/GCArguments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * 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,19 +66,19 @@ static private String[] withDefaults(String[] arguments) { return augmented.toArray(new String[augmented.size()]); } - static public ProcessBuilder createJavaProcessBuilder(List arguments) { - return createJavaProcessBuilder(arguments.toArray(String[]::new)); + static public ProcessBuilder createLimitedTestJavaProcessBuilder(List arguments) { + return createLimitedTestJavaProcessBuilder(arguments.toArray(String[]::new)); } - static public ProcessBuilder createJavaProcessBuilder(String... arguments) { - return ProcessTools.createJavaProcessBuilder(withDefaults(arguments)); + static public ProcessBuilder createLimitedTestJavaProcessBuilder(String... arguments) { + return ProcessTools.createLimitedTestJavaProcessBuilder(withDefaults(arguments)); } - static public ProcessBuilder createTestJvm(List arguments) { - return createTestJvm(arguments.toArray(String[]::new)); + static public ProcessBuilder createTestJavaProcessBuilder(List arguments) { + return createTestJavaProcessBuilder(arguments.toArray(String[]::new)); } - static public ProcessBuilder createTestJvm(String... arguments) { - return ProcessTools.createTestJvm(withDefaults(arguments)); + static public ProcessBuilder createTestJavaProcessBuilder(String... arguments) { + return ProcessTools.createTestJavaProcessBuilder(withDefaults(arguments)); } } diff --git a/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java b/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java index 4070c36f8d7d4..d01773fd71105 100644 --- a/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java +++ b/test/hotspot/jtreg/gc/arguments/TestAggressiveHeap.java @@ -65,7 +65,7 @@ public static void main(String args[]) throws Exception { " *bool +UseParallelGC *= *true +\\{product\\} *\\{command line\\}"; private static void testFlag() throws Exception { - ProcessBuilder pb = GCArguments.createTestJvm( + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder( option, heapSizeOption, "-XX:+PrintFlagsFinal", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/gc/arguments/TestCompressedClassFlags.java b/test/hotspot/jtreg/gc/arguments/TestCompressedClassFlags.java index f33554c46e688..0b6dce0fc0efd 100644 --- a/test/hotspot/jtreg/gc/arguments/TestCompressedClassFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestCompressedClassFlags.java @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { } private static OutputAnalyzer runJava(String ... args) throws Exception { - ProcessBuilder pb = GCArguments.createTestJvm(args); + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(args); return new OutputAnalyzer(pb.start()); } } diff --git a/test/hotspot/jtreg/gc/arguments/TestDisableDefaultGC.java b/test/hotspot/jtreg/gc/arguments/TestDisableDefaultGC.java index c282a7842037f..e8e4552da0127 100644 --- a/test/hotspot/jtreg/gc/arguments/TestDisableDefaultGC.java +++ b/test/hotspot/jtreg/gc/arguments/TestDisableDefaultGC.java @@ -40,13 +40,13 @@ public class TestDisableDefaultGC { public static void main(String[] args) throws Exception { // Start VM, disabling all possible default GCs - ProcessBuilder pb = GCArguments.createTestJvm("-XX:-UseSerialGC", - "-XX:-UseParallelGC", - "-XX:-UseG1GC", - "-XX:-UseZGC", - "-XX:+UnlockExperimentalVMOptions", - "-XX:-UseShenandoahGC", - "-version"); + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder("-XX:-UseSerialGC", + "-XX:-UseParallelGC", + "-XX:-UseG1GC", + "-XX:-UseZGC", + "-XX:+UnlockExperimentalVMOptions", + "-XX:-UseShenandoahGC", + "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldMatch("Garbage collector not selected"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/gc/arguments/TestG1ConcMarkStepDurationMillis.java b/test/hotspot/jtreg/gc/arguments/TestG1ConcMarkStepDurationMillis.java index 53afba28a1a7f..21a4eddb410ec 100644 --- a/test/hotspot/jtreg/gc/arguments/TestG1ConcMarkStepDurationMillis.java +++ b/test/hotspot/jtreg/gc/arguments/TestG1ConcMarkStepDurationMillis.java @@ -78,7 +78,7 @@ private static void runG1ConcMarkStepDurationMillisTest(String expectedValue, in Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:G1ConcMarkStepDurationMillis="+expectedValue, "-XX:+PrintFlagsFinal", "-version"); - ProcessBuilder pb = GCArguments.createTestJvm(vmOpts); + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(vmOpts); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(expectedResult == PASS ? 0 : 1); diff --git a/test/hotspot/jtreg/gc/arguments/TestG1ConcRefinementThreads.java b/test/hotspot/jtreg/gc/arguments/TestG1ConcRefinementThreads.java index 8a2ec1ab5f64c..91be97782f53f 100644 --- a/test/hotspot/jtreg/gc/arguments/TestG1ConcRefinementThreads.java +++ b/test/hotspot/jtreg/gc/arguments/TestG1ConcRefinementThreads.java @@ -69,7 +69,7 @@ private static void runG1ConcRefinementThreadsTest(String[] passedOpts, } Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:+PrintFlagsFinal", "-version"); - ProcessBuilder pb = GCArguments.createTestJvm(vmOpts); + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(vmOpts); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/arguments/TestG1HeapRegionSize.java b/test/hotspot/jtreg/gc/arguments/TestG1HeapRegionSize.java index ededd10f0c327..0d63dec0c26ee 100644 --- a/test/hotspot/jtreg/gc/arguments/TestG1HeapRegionSize.java +++ b/test/hotspot/jtreg/gc/arguments/TestG1HeapRegionSize.java @@ -53,7 +53,7 @@ private static void checkG1HeapRegionSize(String[] flags, int expectedValue, int flagList.add("-XX:+PrintFlagsFinal"); flagList.add("-version"); - ProcessBuilder pb = GCArguments.createTestJvm(flagList); + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(flagList); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(exitValue); diff --git a/test/hotspot/jtreg/gc/arguments/TestG1PercentageOptions.java b/test/hotspot/jtreg/gc/arguments/TestG1PercentageOptions.java index abf7926f96643..875e995374aee 100644 --- a/test/hotspot/jtreg/gc/arguments/TestG1PercentageOptions.java +++ b/test/hotspot/jtreg/gc/arguments/TestG1PercentageOptions.java @@ -63,7 +63,7 @@ private static final class OptionDescription { }; private static void check(String flag, boolean is_valid) throws Exception { - ProcessBuilder pb = GCArguments.createTestJvm("-XX:+UseG1GC", flag, "-version"); + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder("-XX:+UseG1GC", flag, "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (is_valid) { output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/arguments/TestG1RemSetFlags.java b/test/hotspot/jtreg/gc/arguments/TestG1RemSetFlags.java index be18156df41b2..84483f3927251 100644 --- a/test/hotspot/jtreg/gc/arguments/TestG1RemSetFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestG1RemSetFlags.java @@ -48,7 +48,7 @@ private static void checkG1RemSetFlags(String[] flags, int exitValue) throws Exc flagList.add("-XX:+PrintFlagsFinal"); flagList.add("-version"); - ProcessBuilder pb = GCArguments.createTestJvm(flagList); + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(flagList); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(exitValue); } diff --git a/test/hotspot/jtreg/gc/arguments/TestHeapFreeRatio.java b/test/hotspot/jtreg/gc/arguments/TestHeapFreeRatio.java index 24528c923ed58..19ecb1814184c 100644 --- a/test/hotspot/jtreg/gc/arguments/TestHeapFreeRatio.java +++ b/test/hotspot/jtreg/gc/arguments/TestHeapFreeRatio.java @@ -48,7 +48,7 @@ enum Validation { } private static void testMinMaxFreeRatio(String min, String max, Validation type) throws Exception { - ProcessBuilder pb = GCArguments.createTestJvm( + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder( "-Xminf" + min, "-Xmaxf" + max, "-version"); diff --git a/test/hotspot/jtreg/gc/arguments/TestInitialTenuringThreshold.java b/test/hotspot/jtreg/gc/arguments/TestInitialTenuringThreshold.java index 5006dec7128f5..7bf78a001bf95 100644 --- a/test/hotspot/jtreg/gc/arguments/TestInitialTenuringThreshold.java +++ b/test/hotspot/jtreg/gc/arguments/TestInitialTenuringThreshold.java @@ -41,7 +41,7 @@ public class TestInitialTenuringThreshold { public static void runWithThresholds(int initial, int max, boolean shouldfail) throws Exception { - ProcessBuilder pb = GCArguments.createTestJvm( + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder( "-XX:+UseParallelGC", "-XX:InitialTenuringThreshold=" + String.valueOf(initial), "-XX:MaxTenuringThreshold=" + String.valueOf(max), @@ -58,7 +58,7 @@ public static void runWithThresholds(int initial, int max, boolean shouldfail) t public static void main(String args[]) throws Exception { - ProcessBuilder pb = GCArguments.createTestJvm( + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder( // some value below the default value of InitialTenuringThreshold of 7 "-XX:+UseParallelGC", "-XX:MaxTenuringThreshold=1", diff --git a/test/hotspot/jtreg/gc/arguments/TestMaxHeapSizeTools.java b/test/hotspot/jtreg/gc/arguments/TestMaxHeapSizeTools.java index 2480f882f00d8..3a5d472f9f8ce 100644 --- a/test/hotspot/jtreg/gc/arguments/TestMaxHeapSizeTools.java +++ b/test/hotspot/jtreg/gc/arguments/TestMaxHeapSizeTools.java @@ -115,7 +115,7 @@ private static long align_up(long value, long alignment) { } private static void getNewOldSize(String gcflag, long[] values) throws Exception { - ProcessBuilder pb = GCArguments.createTestJvm(gcflag, + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(gcflag, "-XX:+PrintFlagsFinal", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); @@ -208,7 +208,7 @@ public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, finalargs.add(classname); finalargs.addAll(Arrays.asList(arguments)); - ProcessBuilder pb = GCArguments.createTestJvm(finalargs.toArray(String[]::new)); + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(finalargs.toArray(String[]::new)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); @@ -308,7 +308,7 @@ private static void shouldContainOrNot(OutputAnalyzer output, boolean contains, } private static void expect(String[] flags, boolean hasWarning, boolean hasError, int errorcode) throws Exception { - ProcessBuilder pb = GCArguments.createTestJvm(flags); + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); shouldContainOrNot(output, hasWarning, "Warning"); shouldContainOrNot(output, hasError, "Error"); diff --git a/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java b/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java index 3cf0034f1a767..7e91fe60cfb79 100644 --- a/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestMaxMinHeapFreeRatioFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -98,7 +98,7 @@ public static void positiveTest(int minRatio, boolean useXminf, Boolean.toString(shrinkHeapInSteps) ); - ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions); + ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions); OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); analyzer.shouldHaveExitValue(0); } @@ -123,7 +123,7 @@ public static void negativeTest(int minRatio, boolean useXminf, "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-version" ); - ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions); + ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions); OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); analyzer.shouldHaveExitValue(1); analyzer.shouldContain("Error: Could not create the Java Virtual Machine."); diff --git a/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java b/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java index 6abcc9f84fe86..f2214b8b0cfb9 100644 --- a/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java +++ b/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java @@ -95,7 +95,7 @@ private static String getMaxNewSize(String[] flags) throws Exception { finalargs.add("-XX:+PrintFlagsFinal"); finalargs.add("-version"); - ProcessBuilder pb = GCArguments.createTestJvm(finalargs); + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder(finalargs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); String stdout = output.getStdout(); diff --git a/test/hotspot/jtreg/gc/arguments/TestMaxRAMFlags.java b/test/hotspot/jtreg/gc/arguments/TestMaxRAMFlags.java index c2802d18a8a7f..4c66afd5cf54d 100644 --- a/test/hotspot/jtreg/gc/arguments/TestMaxRAMFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestMaxRAMFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,7 @@ private static void checkMaxRAMSize(long maxram, int maxrampercent, boolean forc args.add("-XX:+PrintFlagsFinal"); args.add("-version"); - ProcessBuilder pb = GCArguments.createJavaProcessBuilder(args); + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); String stdout = output.getStdout(); @@ -84,7 +84,7 @@ private static long getHeapBaseMinAddress() throws Exception { args.add("-XX:+PrintFlagsFinal"); args.add("-version"); - ProcessBuilder pb = GCArguments.createJavaProcessBuilder(args); + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); String stdout = output.getStdout(); diff --git a/test/hotspot/jtreg/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java b/test/hotspot/jtreg/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java index 4e18a4c60b6e9..83f564b98a5ef 100644 --- a/test/hotspot/jtreg/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestMinAndInitialSurvivorRatioFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,7 @@ public static void testSurvivorRatio(int survivorRatio, Boolean.toString(useAdaptiveSizePolicy) ); vmOptions.removeIf((String p) -> p.isEmpty()); - ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions); + ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions); OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); analyzer.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/gc/arguments/TestNewRatioFlag.java b/test/hotspot/jtreg/gc/arguments/TestNewRatioFlag.java index 49ce08e5b0e8d..9076005fa8662 100644 --- a/test/hotspot/jtreg/gc/arguments/TestNewRatioFlag.java +++ b/test/hotspot/jtreg/gc/arguments/TestNewRatioFlag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ public static void testNewRatio(int ratio, LinkedList options) throws Ex Integer.toString(ratio) ); - ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions); + ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions); OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); analyzer.shouldHaveExitValue(0); System.out.println(analyzer.getOutput()); diff --git a/test/hotspot/jtreg/gc/arguments/TestNewSizeFlags.java b/test/hotspot/jtreg/gc/arguments/TestNewSizeFlags.java index 70a124e6f14eb..3c3aff980dde4 100644 --- a/test/hotspot/jtreg/gc/arguments/TestNewSizeFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestNewSizeFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -166,7 +166,7 @@ private static OutputAnalyzer startVM(LinkedList options, Long.toString(maxHeapSize) ); vmOptions.removeIf(String::isEmpty); - ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions); + ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions); OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); return analyzer; } diff --git a/test/hotspot/jtreg/gc/arguments/TestNewSizeThreadIncrease.java b/test/hotspot/jtreg/gc/arguments/TestNewSizeThreadIncrease.java index be69ff2c79b47..82e98429100c0 100644 --- a/test/hotspot/jtreg/gc/arguments/TestNewSizeThreadIncrease.java +++ b/test/hotspot/jtreg/gc/arguments/TestNewSizeThreadIncrease.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,13 +65,13 @@ public static void main(String[] args) throws Exception { } static void runNewSizeThreadIncreaseTest(String expectedValue, boolean isNewsizeChanged) throws Exception { - ProcessBuilder pb = GCArguments.createJavaProcessBuilder("-XX:+UseSerialGC", - "-Xms96M", - "-Xmx128M", - "-XX:NewRatio=2", - "-Xlog:gc+heap+ergo=debug", - "-XX:NewSizeThreadIncrease="+expectedValue, - GCTest.class.getName()); + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder("-XX:+UseSerialGC", + "-Xms96M", + "-Xmx128M", + "-XX:NewRatio=2", + "-Xlog:gc+heap+ergo=debug", + "-XX:NewSizeThreadIncrease="+expectedValue, + GCTest.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/arguments/TestObjectTenuringFlags.java b/test/hotspot/jtreg/gc/arguments/TestObjectTenuringFlags.java index 0a2c8c146da85..ca45def0b2b72 100644 --- a/test/hotspot/jtreg/gc/arguments/TestObjectTenuringFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestObjectTenuringFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -161,7 +161,7 @@ private static void runTenuringFlagsConsistencyTest(String[] tenuringFlags, } Collections.addAll(vmOpts, "-XX:+UseParallelGC", "-XX:+PrintFlagsFinal", "-version"); - ProcessBuilder pb = GCArguments.createJavaProcessBuilder(vmOpts); + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(vmOpts); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (shouldFail) { diff --git a/test/hotspot/jtreg/gc/arguments/TestParallelGCThreads.java b/test/hotspot/jtreg/gc/arguments/TestParallelGCThreads.java index 6e447f455cf74..1055f4fee1304 100644 --- a/test/hotspot/jtreg/gc/arguments/TestParallelGCThreads.java +++ b/test/hotspot/jtreg/gc/arguments/TestParallelGCThreads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ public static void main(String args[]) throws Exception { private static final String printFlagsFinalPattern = " *uint *" + flagName + " *:?= *(\\d+) *\\{product\\} *"; public static void testDefaultValue() throws Exception { - ProcessBuilder pb = GCArguments.createJavaProcessBuilder( + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+PrintFlagsFinal", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); @@ -94,7 +94,7 @@ public static void testFlags() throws Exception { for (String gc : supportedGC) { // Make sure the VM does not allow ParallelGCThreads set to 0 - ProcessBuilder pb = GCArguments.createJavaProcessBuilder( + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder( "-XX:+Use" + gc + "GC", "-XX:ParallelGCThreads=0", "-XX:+PrintFlagsFinal", @@ -124,7 +124,7 @@ public static void testFlags() throws Exception { } public static long getParallelGCThreadCount(String... flags) throws Exception { - ProcessBuilder pb = GCArguments.createJavaProcessBuilder(flags); + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); String stdout = output.getStdout(); diff --git a/test/hotspot/jtreg/gc/arguments/TestParallelRefProc.java b/test/hotspot/jtreg/gc/arguments/TestParallelRefProc.java index b936e87c3708c..d47d277e30b82 100644 --- a/test/hotspot/jtreg/gc/arguments/TestParallelRefProc.java +++ b/test/hotspot/jtreg/gc/arguments/TestParallelRefProc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,7 @@ private static void testFlag(String[] args, boolean expectedTrue) throws Excepti result.addAll(Arrays.asList(args)); result.add("-XX:+PrintFlagsFinal"); result.add("-version"); - ProcessBuilder pb = GCArguments.createJavaProcessBuilder(result); + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(result); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java b/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java index dfa3bbfb36443..a48f21c957bed 100644 --- a/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java +++ b/test/hotspot/jtreg/gc/arguments/TestSelectDefaultGC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ public static void assertVMOption(OutputAnalyzer output, String option, boolean public static void testDefaultGC(boolean actAsServer) throws Exception { // Start VM without specifying GC - ProcessBuilder pb = GCArguments.createJavaProcessBuilder( + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder( "-XX:" + (actAsServer ? "+" : "-") + "AlwaysActAsServerClassMachine", "-XX:" + (actAsServer ? "-" : "+") + "NeverActAsServerClassMachine", "-XX:+PrintFlagsFinal", diff --git a/test/hotspot/jtreg/gc/arguments/TestSmallInitialHeapWithLargePageAndNUMA.java b/test/hotspot/jtreg/gc/arguments/TestSmallInitialHeapWithLargePageAndNUMA.java index 2cf0763fe2005..779a5d8b53714 100644 --- a/test/hotspot/jtreg/gc/arguments/TestSmallInitialHeapWithLargePageAndNUMA.java +++ b/test/hotspot/jtreg/gc/arguments/TestSmallInitialHeapWithLargePageAndNUMA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ public static void main(String[] args) throws Exception { long initHeap = heapAlignment; long maxHeap = heapAlignment * 2; - ProcessBuilder pb_enabled = GCArguments.createJavaProcessBuilder( + ProcessBuilder pb_enabled = GCArguments.createLimitedTestJavaProcessBuilder( "-XX:+UseParallelGC", "-Xms" + String.valueOf(initHeap), "-Xmx" + String.valueOf(maxHeap), diff --git a/test/hotspot/jtreg/gc/arguments/TestSurvivorRatioFlag.java b/test/hotspot/jtreg/gc/arguments/TestSurvivorRatioFlag.java index 1a2246b15819b..8567615220ad9 100644 --- a/test/hotspot/jtreg/gc/arguments/TestSurvivorRatioFlag.java +++ b/test/hotspot/jtreg/gc/arguments/TestSurvivorRatioFlag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,7 +87,7 @@ public static void testSurvivorRatio(int ratio, LinkedList options) thro Integer.toString(ratio) ); - ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions); + ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions); OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); analyzer.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java index f530bf3599632..8f8b4aa10877a 100644 --- a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java +++ b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -116,7 +116,7 @@ public static void negativeTest(int ratio, LinkedList options) throws Ex vmOptions.add("-XX:TargetSurvivorRatio=" + ratio); vmOptions.add("-version"); - ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions); + ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions); OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); analyzer.shouldHaveExitValue(1); @@ -151,7 +151,7 @@ public static void positiveTest(int ratio, LinkedList options) throws Ex Integer.toString(ratio) ); - ProcessBuilder procBuilder = GCArguments.createJavaProcessBuilder(vmOptions); + ProcessBuilder procBuilder = GCArguments.createLimitedTestJavaProcessBuilder(vmOptions); OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); analyzer.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/arguments/TestUnrecognizedVMOptionsHandling.java b/test/hotspot/jtreg/gc/arguments/TestUnrecognizedVMOptionsHandling.java index 8d1ee6ebb6e07..24da380298b78 100644 --- a/test/hotspot/jtreg/gc/arguments/TestUnrecognizedVMOptionsHandling.java +++ b/test/hotspot/jtreg/gc/arguments/TestUnrecognizedVMOptionsHandling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -40,7 +40,7 @@ public class TestUnrecognizedVMOptionsHandling { public static void main(String args[]) throws Exception { // The first two JAVA processes are expected to fail, but with a correct VM option suggestion - ProcessBuilder pb = GCArguments.createJavaProcessBuilder( + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder( "-XX:+UseDynamicNumberOfGcThreads", "-version" ); @@ -50,7 +50,7 @@ public static void main(String args[]) throws Exception { throw new RuntimeException("Not expected to get exit value 0"); } - pb = GCArguments.createJavaProcessBuilder( + pb = GCArguments.createLimitedTestJavaProcessBuilder( "-XX:MaxiumHeapSize=500m", "-version" ); @@ -61,7 +61,7 @@ public static void main(String args[]) throws Exception { } // The last JAVA process should run successfully for the purpose of sanity check - pb = GCArguments.createJavaProcessBuilder( + pb = GCArguments.createLimitedTestJavaProcessBuilder( "-XX:+UseDynamicNumberOfGCThreads", "-version" ); diff --git a/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsErgoTools.java b/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsErgoTools.java index 8979b92eaf66d..19ebdea3c0eba 100644 --- a/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsErgoTools.java +++ b/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsErgoTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -93,7 +93,7 @@ public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, finalargs.add(classname); finalargs.addAll(Arrays.asList(arguments)); - ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs); + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(finalargs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); return output; @@ -157,7 +157,7 @@ private static boolean getFlagBoolValue(String flag, String where) { } private static String expect(String[] flags, boolean hasWarning, boolean hasError, int errorcode) throws Exception { - ProcessBuilder pb = GCArguments.createJavaProcessBuilder(flags); + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(errorcode); return output.getStdout(); diff --git a/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java b/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java index ada10a210f1bb..07cf4126970a8 100644 --- a/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java +++ b/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ private static void checkFlag(long ulimit, long maxram, int maxrampercent, boole // Convert bytes to kbytes for ulimit -v var ulimit_prefix = "ulimit -v " + (ulimit / 1024); - String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJvm(args.toArray(String[]::new))); + String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJavaProcessBuilder(args.toArray(String[]::new))); ProcessBuilder pb = new ProcessBuilder("sh", "-c", ulimit_prefix + ";" + cmd); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/arguments/TestUseNUMAInterleaving.java b/test/hotspot/jtreg/gc/arguments/TestUseNUMAInterleaving.java index 7f3857594b6dc..4a7fb7108c3c7 100644 --- a/test/hotspot/jtreg/gc/arguments/TestUseNUMAInterleaving.java +++ b/test/hotspot/jtreg/gc/arguments/TestUseNUMAInterleaving.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ public class TestUseNUMAInterleaving { public static void main(String[] args) throws Exception { - ProcessBuilder pb = GCArguments.createTestJvm( + ProcessBuilder pb = GCArguments.createTestJavaProcessBuilder( "-XX:+UseNUMA", "-XX:+PrintFlagsFinal", "-version"); diff --git a/test/hotspot/jtreg/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java b/test/hotspot/jtreg/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java index 4b46d00c16dd6..a3d6d5a7440c5 100644 --- a/test/hotspot/jtreg/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java +++ b/test/hotspot/jtreg/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -99,7 +99,7 @@ public static void testVerifyFlags(boolean verifyBeforeGC, : "-XX:-VerifyAfterGC"), GarbageProducer.class.getName(), doFullGC ? "t" : "f" }); - ProcessBuilder pb = GCArguments.createJavaProcessBuilder(vmOpts); + ProcessBuilder pb = GCArguments.createLimitedTestJavaProcessBuilder(vmOpts); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); analyzer.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java b/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java index b94ceebaad544..238e747fb1ef7 100644 --- a/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java +++ b/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ public class TestG1ClassUnloadingHWM { private static long YoungGenSize = 32 * 1024 * 1024; private static OutputAnalyzer run(boolean enableUnloading) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", diff --git a/test/hotspot/jtreg/gc/epsilon/TestDieDefault.java b/test/hotspot/jtreg/gc/epsilon/TestDieDefault.java index a883eb9f27c44..c978f149fcac5 100644 --- a/test/hotspot/jtreg/gc/epsilon/TestDieDefault.java +++ b/test/hotspot/jtreg/gc/epsilon/TestDieDefault.java @@ -37,14 +37,14 @@ public class TestDieDefault { public static void passWith(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldNotContain("OutOfMemoryError"); out.shouldHaveExitValue(0); } public static void failWith(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldContain("OutOfMemoryError"); if (out.getExitValue() == 0) { diff --git a/test/hotspot/jtreg/gc/epsilon/TestDieWithHeapDump.java b/test/hotspot/jtreg/gc/epsilon/TestDieWithHeapDump.java index c717b49333025..2e19141d286cb 100644 --- a/test/hotspot/jtreg/gc/epsilon/TestDieWithHeapDump.java +++ b/test/hotspot/jtreg/gc/epsilon/TestDieWithHeapDump.java @@ -38,14 +38,14 @@ public class TestDieWithHeapDump { public static void passWith(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldNotContain("OutOfMemoryError"); out.shouldHaveExitValue(0); } public static void failWith(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); Process p = pb.start(); OutputAnalyzer out = new OutputAnalyzer(p); out.shouldContain("OutOfMemoryError"); diff --git a/test/hotspot/jtreg/gc/epsilon/TestDieWithOnError.java b/test/hotspot/jtreg/gc/epsilon/TestDieWithOnError.java index 2cac3843b0e55..a6593fecdff8b 100644 --- a/test/hotspot/jtreg/gc/epsilon/TestDieWithOnError.java +++ b/test/hotspot/jtreg/gc/epsilon/TestDieWithOnError.java @@ -39,7 +39,7 @@ public class TestDieWithOnError { static String ON_ERR_MSG = "Epsilon error handler message"; public static void passWith(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldNotContain("OutOfMemoryError"); out.stdoutShouldNotMatch("^" + ON_ERR_MSG); @@ -47,7 +47,7 @@ public static void passWith(String... args) throws Exception { } public static void failWith(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldContain("OutOfMemoryError"); if (out.getExitValue() == 0) { diff --git a/test/hotspot/jtreg/gc/ergonomics/TestDynamicNumberOfGCThreads.java b/test/hotspot/jtreg/gc/ergonomics/TestDynamicNumberOfGCThreads.java index 80f1828c0dd28..3e7293a5a92c5 100644 --- a/test/hotspot/jtreg/gc/ergonomics/TestDynamicNumberOfGCThreads.java +++ b/test/hotspot/jtreg/gc/ergonomics/TestDynamicNumberOfGCThreads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,7 @@ private static void testDynamicNumberOfGCThreads(String gcFlag) throws Exception String[] baseArgs = {"-XX:+UnlockExperimentalVMOptions", "-XX:+" + gcFlag, "-Xmx10M", "-XX:+UseDynamicNumberOfGCThreads", "-Xlog:gc+task=trace", GCTest.class.getName()}; // Base test with gc and +UseDynamicNumberOfGCThreads: - ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(baseArgs); + ProcessBuilder pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder(baseArgs); verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start())); // Turn on parallel reference processing @@ -81,7 +81,7 @@ private static void testDynamicNumberOfGCThreads(String gcFlag) throws Exception String[] parRefArgs = new String[baseArgs.length + parRefProcArg.length]; System.arraycopy(parRefProcArg, 0, parRefArgs, 0, parRefProcArg.length); System.arraycopy(baseArgs, 0, parRefArgs, parRefProcArg.length, baseArgs.length); - pb_enabled = ProcessTools.createJavaProcessBuilder(parRefArgs); + pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder(parRefArgs); verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start())); } diff --git a/test/hotspot/jtreg/gc/ergonomics/TestInitialGCThreadLogging.java b/test/hotspot/jtreg/gc/ergonomics/TestInitialGCThreadLogging.java index a20721a9e5629..dc1b83cd2c1ee 100644 --- a/test/hotspot/jtreg/gc/ergonomics/TestInitialGCThreadLogging.java +++ b/test/hotspot/jtreg/gc/ergonomics/TestInitialGCThreadLogging.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ private static void verifyDynamicNumberOfGCThreads(OutputAnalyzer output, String private static void testInitialGCThreadLogging(String gcFlag, String threadName) throws Exception { // Base test with gc and +UseDynamicNumberOfGCThreads: - ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+" + gcFlag, "-Xmx10M", diff --git a/test/hotspot/jtreg/gc/g1/Test2GbHeap.java b/test/hotspot/jtreg/gc/g1/Test2GbHeap.java index 125ea34a9018e..8e06ac3ee2c69 100644 --- a/test/hotspot/jtreg/gc/g1/Test2GbHeap.java +++ b/test/hotspot/jtreg/gc/g1/Test2GbHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,7 @@ public static void main(String[] args) throws Exception { testArguments.add("-Xmx2g"); testArguments.add("-version"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testArguments); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(testArguments); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegions.java b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegions.java index a459c1131ad7b..a334783eca6c1 100644 --- a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegions.java +++ b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,7 +80,7 @@ public static void main(String[] args) { public class TestEagerReclaimHumongousRegions { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseG1GC", "-Xms128M", "-Xmx128M", diff --git a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java index 774929c4799e5..56de136fe5970 100644 --- a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java +++ b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java @@ -119,7 +119,7 @@ public static void main(String[] args) { public class TestEagerReclaimHumongousRegionsClearMarkBits { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseG1GC", "-Xms128M", "-Xmx128M", diff --git a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java index b372d99b0ee27..03af9c2b4bba7 100644 --- a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java +++ b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsLog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ private static String getSumValue(String s) { } public static void runTest() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockExperimentalVMOptions", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java index 9c6b011fff2a8..335567a9c3659 100644 --- a/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java +++ b/test/hotspot/jtreg/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,7 +92,7 @@ public static void main(String[] args) { public class TestEagerReclaimHumongousRegionsWithRefs { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseG1GC", "-Xms128M", "-Xmx128M", diff --git a/test/hotspot/jtreg/gc/g1/TestEvacuationFailure.java b/test/hotspot/jtreg/gc/g1/TestEvacuationFailure.java index 31bf77672ccea..bbd7fee046704 100644 --- a/test/hotspot/jtreg/gc/g1/TestEvacuationFailure.java +++ b/test/hotspot/jtreg/gc/g1/TestEvacuationFailure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,15 +43,15 @@ public class TestEvacuationFailure { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-Xmx32M", - "-Xmn16M", - "-XX:+G1EvacuationFailureALot", - "-XX:G1EvacuationFailureALotCount=100", - "-XX:G1EvacuationFailureALotInterval=1", - "-XX:+UnlockDiagnosticVMOptions", - "-Xlog:gc", - GCTestWithEvacuationFailure.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-Xmx32M", + "-Xmn16M", + "-XX:+G1EvacuationFailureALot", + "-XX:G1EvacuationFailureALotCount=100", + "-XX:G1EvacuationFailureALotInterval=1", + "-XX:+UnlockDiagnosticVMOptions", + "-Xlog:gc", + GCTestWithEvacuationFailure.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println(output.getStdout()); diff --git a/test/hotspot/jtreg/gc/g1/TestG1SkipCompaction.java b/test/hotspot/jtreg/gc/g1/TestG1SkipCompaction.java index 9b9e748e8a662..8455e03b18fa6 100644 --- a/test/hotspot/jtreg/gc/g1/TestG1SkipCompaction.java +++ b/test/hotspot/jtreg/gc/g1/TestG1SkipCompaction.java @@ -54,7 +54,7 @@ public static void runTest() throws Exception { "-XX:G1HeapRegionSize=1m", GCTest.class.getName() }; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println(output.getStdout()); diff --git a/test/hotspot/jtreg/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java b/test/hotspot/jtreg/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java index 3eafc348a4b3d..4dedac0a61bbb 100644 --- a/test/hotspot/jtreg/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java +++ b/test/hotspot/jtreg/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,14 +41,14 @@ public class TestG1TraceEagerReclaimHumongousObjects { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-Xms128M", - "-Xmx128M", - "-Xmn16M", - "-XX:G1HeapRegionSize=1M", - "-Xlog:gc+phases=trace,gc+humongous=trace", - "-XX:+UnlockExperimentalVMOptions", - GCWithHumongousObjectTest.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-Xms128M", + "-Xmx128M", + "-Xmn16M", + "-XX:G1HeapRegionSize=1M", + "-Xlog:gc+phases=trace,gc+humongous=trace", + "-XX:+UnlockExperimentalVMOptions", + GCWithHumongousObjectTest.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java index 1d5c164b90774..6b249d69ab90d 100644 --- a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java +++ b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -218,26 +218,26 @@ public static void main(String[] args) throws Exception { private void testNormalLogs() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-Xmx10M", - GCTest.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-Xmx10M", + GCTest.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); checkMessagesAtLevel(output, allLogMessages, Level.OFF); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-Xmx10M", - "-Xlog:gc+phases=debug", - GCTest.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-Xmx10M", + "-Xlog:gc+phases=debug", + GCTest.class.getName()); output = new OutputAnalyzer(pb.start()); checkMessagesAtLevel(output, allLogMessages, Level.DEBUG); - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-Xmx10M", - "-Xlog:gc+phases=trace", - GCTest.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-Xmx10M", + "-Xlog:gc+phases=trace", + GCTest.class.getName()); output = new OutputAnalyzer(pb.start()); checkMessagesAtLevel(output, allLogMessages, Level.TRACE); @@ -253,10 +253,10 @@ private void testNormalLogs() throws Exception { }; private void testConcurrentRefinementLogs() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-Xmx10M", - "-Xlog:gc+refine+stats=debug", - GCTest.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-Xmx10M", + "-Xlog:gc+refine+stats=debug", + GCTest.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); checkMessagesAtLevel(output, concRefineMessages, Level.DEBUG); } @@ -271,27 +271,27 @@ private void testConcurrentRefinementLogs() throws Exception { }; private void testWithEvacuationFailureLogs() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-Xmx32M", - "-Xmn16M", - "-XX:+G1EvacuationFailureALot", - "-XX:G1EvacuationFailureALotCount=100", - "-XX:G1EvacuationFailureALotInterval=1", - "-XX:+UnlockDiagnosticVMOptions", - "-Xlog:gc+phases=debug", - GCTestWithEvacuationFailure.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-Xmx32M", + "-Xmn16M", + "-XX:+G1EvacuationFailureALot", + "-XX:G1EvacuationFailureALotCount=100", + "-XX:G1EvacuationFailureALotInterval=1", + "-XX:+UnlockDiagnosticVMOptions", + "-Xlog:gc+phases=debug", + GCTestWithEvacuationFailure.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); checkMessagesAtLevel(output, exhFailureMessages, Level.DEBUG); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-Xmx32M", - "-Xmn16M", - "-Xms32M", - "-XX:+UnlockDiagnosticVMOptions", - "-Xlog:gc+phases=trace", - GCTestWithEvacuationFailure.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-Xmx32M", + "-Xmn16M", + "-Xms32M", + "-XX:+UnlockDiagnosticVMOptions", + "-Xlog:gc+phases=trace", + GCTestWithEvacuationFailure.class.getName()); output = new OutputAnalyzer(pb.start()); checkMessagesAtLevel(output, exhFailureMessages, Level.TRACE); @@ -304,13 +304,13 @@ private void testWithEvacuationFailureLogs() throws Exception { }; private void testWithConcurrentStart() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-Xmx10M", - "-Xbootclasspath/a:.", - "-Xlog:gc*=debug", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - GCTestWithConcurrentStart.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-Xmx10M", + "-Xbootclasspath/a:.", + "-Xlog:gc*=debug", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + GCTestWithConcurrentStart.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); checkMessagesAtLevel(output, concurrentStartMessages, Level.TRACE); @@ -318,13 +318,13 @@ private void testWithConcurrentStart() throws Exception { } private void testExpandHeap() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-Xmx10M", - "-Xbootclasspath/a:.", - "-Xlog:gc+ergo+heap=debug", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - GCTest.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-Xmx10M", + "-Xbootclasspath/a:.", + "-Xlog:gc+ergo+heap=debug", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + GCTest.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Expand the heap. requested expansion amount: "); diff --git a/test/hotspot/jtreg/gc/g1/TestHumongousAllocConcurrentStart.java b/test/hotspot/jtreg/gc/g1/TestHumongousAllocConcurrentStart.java index f2276c3904efb..b3a754f74c5a9 100644 --- a/test/hotspot/jtreg/gc/g1/TestHumongousAllocConcurrentStart.java +++ b/test/hotspot/jtreg/gc/g1/TestHumongousAllocConcurrentStart.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ public class TestHumongousAllocConcurrentStart { private static final int initiatingHeapOccupancyPercent = 50; // % public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseG1GC", "-Xms" + heapSize + "m", "-Xmx" + heapSize + "m", diff --git a/test/hotspot/jtreg/gc/g1/TestHumongousAllocNearlyFullRegion.java b/test/hotspot/jtreg/gc/g1/TestHumongousAllocNearlyFullRegion.java index d1803674120cf..fb33e9cc7c547 100644 --- a/test/hotspot/jtreg/gc/g1/TestHumongousAllocNearlyFullRegion.java +++ b/test/hotspot/jtreg/gc/g1/TestHumongousAllocNearlyFullRegion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ public class TestHumongousAllocNearlyFullRegion { private static final int heapRegionSize = 1; // MB public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseG1GC", "-Xms" + heapSize + "m", "-Xmx" + heapSize + "m", diff --git a/test/hotspot/jtreg/gc/g1/TestHumongousCodeCacheRoots.java b/test/hotspot/jtreg/gc/g1/TestHumongousCodeCacheRoots.java index 77f76b30b672e..2e669f6dfe19d 100644 --- a/test/hotspot/jtreg/gc/g1/TestHumongousCodeCacheRoots.java +++ b/test/hotspot/jtreg/gc/g1/TestHumongousCodeCacheRoots.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -106,7 +106,7 @@ public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, finalargs.add(classname); finalargs.addAll(Arrays.asList(arguments)); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(finalargs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); return output; diff --git a/test/hotspot/jtreg/gc/g1/TestHumongousConcurrentStartUndo.java b/test/hotspot/jtreg/gc/g1/TestHumongousConcurrentStartUndo.java index 92bad43d798aa..d30d9240103fc 100644 --- a/test/hotspot/jtreg/gc/g1/TestHumongousConcurrentStartUndo.java +++ b/test/hotspot/jtreg/gc/g1/TestHumongousConcurrentStartUndo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ public class TestHumongousConcurrentStartUndo { private static final int YoungSize = HeapSize / 8; public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UseG1GC", "-Xms" + HeapSize + "m", diff --git a/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java b/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java index 0afd362c65a88..777391845a422 100644 --- a/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java +++ b/test/hotspot/jtreg/gc/g1/TestLargePageUseForAuxMemory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -123,7 +123,7 @@ static void testVM(String what, long heapsize, boolean cardsShouldUseLargePages, ProcessBuilder pb; // Test with large page enabled. - pb = ProcessTools.createJavaProcessBuilder(getOpts(heapsize, true)); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(getOpts(heapsize, true)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); @@ -138,7 +138,7 @@ static void testVM(String what, long heapsize, boolean cardsShouldUseLargePages, output.shouldHaveExitValue(0); // Test with large page disabled. - pb = ProcessTools.createJavaProcessBuilder(getOpts(heapsize, false)); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(getOpts(heapsize, false)); output = new OutputAnalyzer(pb.start()); checkSmallTables(output, smallPageSize); diff --git a/test/hotspot/jtreg/gc/g1/TestLargePageUseForHeap.java b/test/hotspot/jtreg/gc/g1/TestLargePageUseForHeap.java index cfd59eadd3a32..72afde512bc57 100644 --- a/test/hotspot/jtreg/gc/g1/TestLargePageUseForHeap.java +++ b/test/hotspot/jtreg/gc/g1/TestLargePageUseForHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,12 +87,12 @@ static void checkHeap(OutputAnalyzer output, long expectedPageSize) throws Excep static void testVM(long regionSize) throws Exception { ProcessBuilder pb; // Test with large page enabled. - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-XX:G1HeapRegionSize=" + regionSize, - "-Xmx128m", - "-Xlog:gc+init,pagesize,gc+heap+coops=debug", - "-XX:+UseLargePages", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-XX:G1HeapRegionSize=" + regionSize, + "-Xmx128m", + "-Xlog:gc+init,pagesize,gc+heap+coops=debug", + "-XX:+UseLargePages", + "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); boolean largePageEnabled = checkLargePageEnabled(output); @@ -100,12 +100,12 @@ static void testVM(long regionSize) throws Exception { output.shouldHaveExitValue(0); // Test with large page disabled. - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-XX:G1HeapRegionSize=" + regionSize, - "-Xmx128m", - "-Xlog:gc+init,pagesize,gc+heap+coops=debug", - "-XX:-UseLargePages", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-XX:G1HeapRegionSize=" + regionSize, + "-Xmx128m", + "-Xlog:gc+init,pagesize,gc+heap+coops=debug", + "-XX:-UseLargePages", + "-version"); output = new OutputAnalyzer(pb.start()); checkHeap(output, smallPageSize); diff --git a/test/hotspot/jtreg/gc/g1/TestMarkStackSizes.java b/test/hotspot/jtreg/gc/g1/TestMarkStackSizes.java index 23f014d05cba1..d056a5ef74720 100644 --- a/test/hotspot/jtreg/gc/g1/TestMarkStackSizes.java +++ b/test/hotspot/jtreg/gc/g1/TestMarkStackSizes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ private static void runTest(boolean shouldSucceed, String... extraArgs) throws E Collections.addAll(testArguments, extraArgs); testArguments.add("-version"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testArguments); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(testArguments); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/gc/g1/TestMixedGCLiveThreshold.java b/test/hotspot/jtreg/gc/g1/TestMixedGCLiveThreshold.java index 26ba0da396a0f..035a6b896796f 100644 --- a/test/hotspot/jtreg/gc/g1/TestMixedGCLiveThreshold.java +++ b/test/hotspot/jtreg/gc/g1/TestMixedGCLiveThreshold.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,7 +109,7 @@ private static OutputAnalyzer testWithMixedGCLiveThresholdPercent(int percent) t basicOpts.add(GCTest.class.getName()); - ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(basicOpts); + ProcessBuilder procBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(basicOpts); OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); return analyzer; } diff --git a/test/hotspot/jtreg/gc/g1/TestOneEdenRegionAfterGC.java b/test/hotspot/jtreg/gc/g1/TestOneEdenRegionAfterGC.java index f6bf6fd452dac..36c3c04c629d3 100644 --- a/test/hotspot/jtreg/gc/g1/TestOneEdenRegionAfterGC.java +++ b/test/hotspot/jtreg/gc/g1/TestOneEdenRegionAfterGC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ public class TestOneEdenRegionAfterGC { private static long YoungGenSize = 32 * 1024 * 1024; private static OutputAnalyzer run() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-Xmn" + YoungGenSize, "-Xmx512M", diff --git a/test/hotspot/jtreg/gc/g1/TestPLABOutput.java b/test/hotspot/jtreg/gc/g1/TestPLABOutput.java index 6cb3110b20d5d..e6342a1911c6b 100644 --- a/test/hotspot/jtreg/gc/g1/TestPLABOutput.java +++ b/test/hotspot/jtreg/gc/g1/TestPLABOutput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ public static void runTest() throws Exception { GCTest.class.getName() }; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/g1/TestPLABSizeBounds.java b/test/hotspot/jtreg/gc/g1/TestPLABSizeBounds.java index fcd0057d4c9e9..ade281a4a929f 100644 --- a/test/hotspot/jtreg/gc/g1/TestPLABSizeBounds.java +++ b/test/hotspot/jtreg/gc/g1/TestPLABSizeBounds.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,7 +62,7 @@ public static void runTest(int regionSize, int plabSize, boolean shouldSucceed) testArguments.add("-XX:OldPLABSize=" + plabSize); testArguments.add(GCTest.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testArguments); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(testArguments); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (shouldSucceed) { diff --git a/test/hotspot/jtreg/gc/g1/TestPeriodicLogMessages.java b/test/hotspot/jtreg/gc/g1/TestPeriodicLogMessages.java index 1babf4f483cf1..de79be020b491 100644 --- a/test/hotspot/jtreg/gc/g1/TestPeriodicLogMessages.java +++ b/test/hotspot/jtreg/gc/g1/TestPeriodicLogMessages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,22 +40,22 @@ public class TestPeriodicLogMessages { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-XX:G1PeriodicGCInterval=0", - "-Xlog:gc+init,gc+periodic=debug", - "-Xmx10M", - GCTest.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-XX:G1PeriodicGCInterval=0", + "-Xlog:gc+init,gc+periodic=debug", + "-Xmx10M", + GCTest.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Periodic GC: Disabled"); output.shouldNotContain("Checking for periodic GC"); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-XX:G1PeriodicGCInterval=100", - "-Xlog:gc+init,gc+periodic=debug", - "-Xmx10M", - GCTest.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-XX:G1PeriodicGCInterval=100", + "-Xlog:gc+init,gc+periodic=debug", + "-Xmx10M", + GCTest.class.getName()); output = new OutputAnalyzer(pb.start()); output.shouldContain("Periodic GC: Enabled"); diff --git a/test/hotspot/jtreg/gc/g1/TestPrintRegionRememberedSetInfo.java b/test/hotspot/jtreg/gc/g1/TestPrintRegionRememberedSetInfo.java index 3c848d5ce015c..ea718c7f6ed08 100644 --- a/test/hotspot/jtreg/gc/g1/TestPrintRegionRememberedSetInfo.java +++ b/test/hotspot/jtreg/gc/g1/TestPrintRegionRememberedSetInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,7 @@ public static String runTest(String arg) throws Exception { finalargs.add(RunAndWaitForMarking.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(finalargs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/g1/TestRemsetLoggingThreads.java b/test/hotspot/jtreg/gc/g1/TestRemsetLoggingThreads.java index 8d8f77db81aa7..5d4b4d958f8ed 100644 --- a/test/hotspot/jtreg/gc/g1/TestRemsetLoggingThreads.java +++ b/test/hotspot/jtreg/gc/g1/TestRemsetLoggingThreads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,12 +44,12 @@ public class TestRemsetLoggingThreads { private static void runTest(int refinementThreads, int workerThreads) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", - "-XX:+UnlockDiagnosticVMOptions", - "-Xlog:gc+remset+exit=trace", - "-XX:G1ConcRefinementThreads=" + refinementThreads, - "-XX:ParallelGCThreads=" + workerThreads, - "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseG1GC", + "-XX:+UnlockDiagnosticVMOptions", + "-Xlog:gc+remset+exit=trace", + "-XX:G1ConcRefinementThreads=" + refinementThreads, + "-XX:ParallelGCThreads=" + workerThreads, + "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/gc/g1/TestRemsetLoggingTools.java b/test/hotspot/jtreg/gc/g1/TestRemsetLoggingTools.java index 8a0b4ead47509..69f34e071462f 100644 --- a/test/hotspot/jtreg/gc/g1/TestRemsetLoggingTools.java +++ b/test/hotspot/jtreg/gc/g1/TestRemsetLoggingTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,7 @@ public static String runTest(String[] additionalArgs, int numGCs) throws Excepti finalargs.add(VerifySummaryOutput.class.getName()); finalargs.add(String.valueOf(numGCs)); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(finalargs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/g1/TestSharedArchiveWithPreTouch.java b/test/hotspot/jtreg/gc/g1/TestSharedArchiveWithPreTouch.java index 841ed393392c2..d894c58d73757 100644 --- a/test/hotspot/jtreg/gc/g1/TestSharedArchiveWithPreTouch.java +++ b/test/hotspot/jtreg/gc/g1/TestSharedArchiveWithPreTouch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -59,7 +59,7 @@ public static void main(String[] args) throws Exception { } dump_args.addAll(Arrays.asList(new String[] { "-Xshare:dump", "-Xlog:cds" })); - pb = ProcessTools.createJavaProcessBuilder(dump_args); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(dump_args); OutputAnalyzer output = new OutputAnalyzer(pb.start()); try { output.shouldContain("Loading classes to share"); @@ -72,7 +72,7 @@ public static void main(String[] args) throws Exception { } load_args.addAll(Arrays.asList(new String[] { "-Xshare:on", "-version" })); - pb = ProcessTools.createJavaProcessBuilder(load_args.toArray(new String[0])); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(load_args.toArray(new String[0])); output = new OutputAnalyzer(pb.start()); output.shouldContain("sharing"); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java index 851115d8fee0f..645e545443d1d 100644 --- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java +++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,7 +88,7 @@ protected void test() throws Exception { } private void performTest(List opts) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm(opts); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(opts); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println(output.getStdout()); diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java b/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java index 3f41a8f45f8fc..acdce6b641752 100644 --- a/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java +++ b/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,7 @@ public class TestShrinkDefragmentedHeap { private static final int REGION_SIZE = 1 * 1024 * 1024; public static void main(String[] args) throws Exception, Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:InitialHeapSize=" + INITIAL_HEAP_SIZE, "-Xmn" + MINIMAL_YOUNG_SIZE, "-Xmx" + MAXIMUM_HEAP_SIZE, diff --git a/test/hotspot/jtreg/gc/g1/TestSkipRebuildRemsetPhase.java b/test/hotspot/jtreg/gc/g1/TestSkipRebuildRemsetPhase.java index 8666c3c3c4aa7..4c7190ada02d6 100644 --- a/test/hotspot/jtreg/gc/g1/TestSkipRebuildRemsetPhase.java +++ b/test/hotspot/jtreg/gc/g1/TestSkipRebuildRemsetPhase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,16 +40,16 @@ public class TestSkipRebuildRemsetPhase { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:.", - "-XX:+UseG1GC", - "-XX:+UnlockExperimentalVMOptions", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "-XX:G1MixedGCLiveThresholdPercent=20", - "-Xlog:gc+marking=debug,gc+phases=debug,gc+remset+tracking=trace", - "-Xms10M", - "-Xmx10M", - GCTest.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xbootclasspath/a:.", + "-XX:+UseG1GC", + "-XX:+UnlockExperimentalVMOptions", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:G1MixedGCLiveThresholdPercent=20", + "-Xlog:gc+marking=debug,gc+phases=debug,gc+remset+tracking=trace", + "-Xms10M", + "-Xmx10M", + GCTest.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Skipping Remembered Set Rebuild."); output.shouldContain("No Remembered Sets to update after rebuild"); diff --git a/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java b/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java index 36c6fd6ce6054..02ee74bed8b2a 100644 --- a/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java +++ b/test/hotspot/jtreg/gc/g1/TestVerifyGCType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -178,7 +178,7 @@ private static OutputAnalyzer testWithVerificationType(String[] types, String... basicOpts.add(TriggerGCs.class.getName()); - ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(basicOpts); + ProcessBuilder procBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(basicOpts); OutputAnalyzer analyzer = new OutputAnalyzer(procBuilder.start()); return analyzer; diff --git a/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java b/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java index 73fd4e821065f..0c8d4896c4e01 100644 --- a/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java +++ b/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,7 +90,7 @@ private static OutputAnalyzer spawnMixedGCProvoker(String... extraFlags) Collections.addAll(testOpts, extraFlags); testOpts.add(RunMixedGC.class.getName()); System.out.println(testOpts); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testOpts); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(testOpts); return new OutputAnalyzer(pb.start()); } } diff --git a/test/hotspot/jtreg/gc/g1/numa/TestG1NUMATouchRegions.java b/test/hotspot/jtreg/gc/g1/numa/TestG1NUMATouchRegions.java index dbc0fd370ac2b..4f972e10f3110 100644 --- a/test/hotspot/jtreg/gc/g1/numa/TestG1NUMATouchRegions.java +++ b/test/hotspot/jtreg/gc/g1/numa/TestG1NUMATouchRegions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -181,7 +181,7 @@ static void testMemoryTouch(String largePagesSetting, int regionSizeInMB) throws return; } - ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-Xlog:pagesize,gc+heap+region=trace", "-XX:+UseG1GC", diff --git a/test/hotspot/jtreg/gc/logging/TestDeprecatedPrintFlags.java b/test/hotspot/jtreg/gc/logging/TestDeprecatedPrintFlags.java index cedb42c2e2f71..04607502a2226 100644 --- a/test/hotspot/jtreg/gc/logging/TestDeprecatedPrintFlags.java +++ b/test/hotspot/jtreg/gc/logging/TestDeprecatedPrintFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class TestDeprecatedPrintFlags { public static void testPrintGC() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintGC", DoGC.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintGC", DoGC.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("-XX:+PrintGC is deprecated. Will use -Xlog:gc instead."); output.shouldNotContain("PrintGCDetails"); @@ -52,7 +52,7 @@ public static void testPrintGC() throws Exception { } public static void testPrintGCDetails() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintGCDetails", DoGC.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintGCDetails", DoGC.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("-XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead."); output.shouldNotContain("PrintGC is deprecated"); @@ -63,7 +63,7 @@ public static void testPrintGCDetails() throws Exception { public static void testXloggc() throws Exception { String fileName = "gc-test.log"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xloggc:" + fileName, DoGC.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xloggc:" + fileName, DoGC.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("-Xloggc is deprecated. Will use -Xlog:gc:gc-test.log instead."); output.shouldNotContain("PrintGCDetails"); @@ -80,7 +80,7 @@ public static void testXloggc() throws Exception { public static void testXloggcWithPrintGCDetails() throws Exception { String fileName = "gc-test.log"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintGCDetails", "-Xloggc:" + fileName, DoGC.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintGCDetails", "-Xloggc:" + fileName, DoGC.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("-XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead."); output.shouldContain("-Xloggc is deprecated. Will use -Xlog:gc:gc-test.log instead."); diff --git a/test/hotspot/jtreg/gc/logging/TestGCId.java b/test/hotspot/jtreg/gc/logging/TestGCId.java index f720bfac7ab6c..dca1681e0e8a5 100644 --- a/test/hotspot/jtreg/gc/logging/TestGCId.java +++ b/test/hotspot/jtreg/gc/logging/TestGCId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,7 +74,7 @@ private static void verifyContainsGCIDs(OutputAnalyzer output) { private static void testGCId(String gcFlag) throws Exception { ProcessBuilder pb_default = - ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+" + gcFlag, "-Xlog:gc", "-Xmx10M", GCTest.class.getName()); + ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+" + gcFlag, "-Xlog:gc", "-Xmx10M", GCTest.class.getName()); verifyContainsGCIDs(new OutputAnalyzer(pb_default.start())); } diff --git a/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java b/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java index 4a2ad34b3dbe5..b67063091fb32 100644 --- a/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java +++ b/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -94,7 +94,7 @@ private static boolean check(String line) { private static void testMetaSpaceUpdate() throws Exception { ProcessBuilder pb = - ProcessTools.createTestJvm( + ProcessTools.createTestJavaProcessBuilder( "-Xlog:gc*", "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/gc/logging/TestPrintReferences.java b/test/hotspot/jtreg/gc/logging/TestPrintReferences.java index 6272f08e9943b..99932bc68a640 100644 --- a/test/hotspot/jtreg/gc/logging/TestPrintReferences.java +++ b/test/hotspot/jtreg/gc/logging/TestPrintReferences.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,10 +67,10 @@ static String indent(int count) { } public static void testRefs() throws Exception { - ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder("-Xlog:gc+ref+phases=debug", - "-XX:+UseG1GC", - "-Xmx32M", - GCTest.class.getName()); + ProcessBuilder pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:gc+ref+phases=debug", + "-XX:+UseG1GC", + "-Xmx32M", + GCTest.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb_enabled.start()); checkRefsLogFormat(output); @@ -95,13 +95,13 @@ private static void checkRefsLogFormat(OutputAnalyzer output) { } public static void testPhases(boolean parallelRefProcEnabled) throws Exception { - ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder("-Xlog:gc+phases+ref=debug", - "-XX:+UseG1GC", - "-Xmx32M", - "-XX:" + (parallelRefProcEnabled ? "+" : "-") + "ParallelRefProcEnabled", - "-XX:-UseDynamicNumberOfGCThreads", - "-XX:ParallelGCThreads=2", - GCTest.class.getName()); + ProcessBuilder pb_enabled = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:gc+phases+ref=debug", + "-XX:+UseG1GC", + "-Xmx32M", + "-XX:" + (parallelRefProcEnabled ? "+" : "-") + "ParallelRefProcEnabled", + "-XX:-UseDynamicNumberOfGCThreads", + "-XX:ParallelGCThreads=2", + GCTest.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb_enabled.start()); checkLogFormat(output, parallelRefProcEnabled); diff --git a/test/hotspot/jtreg/gc/metaspace/TestMetaspaceSizeFlags.java b/test/hotspot/jtreg/gc/metaspace/TestMetaspaceSizeFlags.java index d717315b93fb4..eda71fa9c4bb4 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestMetaspaceSizeFlags.java +++ b/test/hotspot/jtreg/gc/metaspace/TestMetaspaceSizeFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -84,7 +84,7 @@ private static MetaspaceFlags runAndGetValue(long maxMetaspaceSize, long metaspa } private static OutputAnalyzer run(long maxMetaspaceSize, long metaspaceSize) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:MaxMetaspaceSize=" + maxMetaspaceSize, "-XX:MetaspaceSize=" + metaspaceSize, "-XX:-UseLargePages", // Prevent us from using 2GB large pages on solaris + sparc. diff --git a/test/hotspot/jtreg/gc/metaspace/TestSizeTransitions.java b/test/hotspot/jtreg/gc/metaspace/TestSizeTransitions.java index 5ecacc7be70d8..a87ed22e15b06 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestSizeTransitions.java +++ b/test/hotspot/jtreg/gc/metaspace/TestSizeTransitions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Twitter, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -119,7 +119,7 @@ public static void main(String... args) throws Exception { System.out.println(" " + a); } - final ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(jvmArgs); + final ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(jvmArgs); final OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println(output.getStdout()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/serial/HeapChangeLogging.java b/test/hotspot/jtreg/gc/serial/HeapChangeLogging.java index 9d7d8961527ea..8480d046dfbde 100644 --- a/test/hotspot/jtreg/gc/serial/HeapChangeLogging.java +++ b/test/hotspot/jtreg/gc/serial/HeapChangeLogging.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public class HeapChangeLogging { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-Xlog:gc", HeapFiller.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-Xlog:gc", HeapFiller.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); String stdout = output.getStdout(); System.out.println(stdout); diff --git a/test/hotspot/jtreg/gc/shenandoah/TestEvilSyncBug.java b/test/hotspot/jtreg/gc/shenandoah/TestEvilSyncBug.java index e58e8d6db5ce0..67690d8cad53d 100644 --- a/test/hotspot/jtreg/gc/shenandoah/TestEvilSyncBug.java +++ b/test/hotspot/jtreg/gc/shenandoah/TestEvilSyncBug.java @@ -56,7 +56,7 @@ public static void main(String[] args) throws Exception { for (int c = 0; c < NUM_RUNS; c++) { Callable task = () -> { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xms128m", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xms128m", "-Xmx128m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/gc/shenandoah/TestObjItrWithHeapDump.java b/test/hotspot/jtreg/gc/shenandoah/TestObjItrWithHeapDump.java index 41943d4befd71..c0161b7a2382d 100644 --- a/test/hotspot/jtreg/gc/shenandoah/TestObjItrWithHeapDump.java +++ b/test/hotspot/jtreg/gc/shenandoah/TestObjItrWithHeapDump.java @@ -41,7 +41,7 @@ public static void testWith(String... args) throws Exception { String[] cmds = Arrays.copyOf(args, args.length + 2); cmds[args.length] = TestObjItrWithHeapDump.class.getName(); cmds[args.length + 1] = "test"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmds); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/shenandoah/TestPeriodicGC.java b/test/hotspot/jtreg/gc/shenandoah/TestPeriodicGC.java index 84795fa404238..b65aa0cd0b46a 100644 --- a/test/hotspot/jtreg/gc/shenandoah/TestPeriodicGC.java +++ b/test/hotspot/jtreg/gc/shenandoah/TestPeriodicGC.java @@ -42,7 +42,7 @@ public static void testWith(String msg, boolean periodic, String... args) throws String[] cmds = Arrays.copyOf(args, args.length + 2); cmds[args.length] = TestPeriodicGC.class.getName(); cmds[args.length + 1] = "test"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmds); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocLargeObj.java b/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocLargeObj.java index 3996c19a98d61..1057eb4a97762 100644 --- a/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocLargeObj.java +++ b/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocLargeObj.java @@ -55,7 +55,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx16m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", @@ -68,7 +68,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx1g", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", diff --git a/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocLargerThanHeap.java b/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocLargerThanHeap.java index c996bfd714eca..1567e3d05da2c 100644 --- a/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocLargerThanHeap.java +++ b/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocLargerThanHeap.java @@ -50,7 +50,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx16m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", @@ -63,7 +63,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx1g", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", diff --git a/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocSmallObj.java b/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocSmallObj.java index 0820237ab9421..bc32c1f0aa0ea 100644 --- a/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocSmallObj.java +++ b/test/hotspot/jtreg/gc/shenandoah/oom/TestAllocSmallObj.java @@ -54,7 +54,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx16m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", @@ -67,7 +67,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx1g", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", diff --git a/test/hotspot/jtreg/gc/shenandoah/oom/TestClassLoaderLeak.java b/test/hotspot/jtreg/gc/shenandoah/oom/TestClassLoaderLeak.java index 21962b2182d3e..080842c37f90f 100644 --- a/test/hotspot/jtreg/gc/shenandoah/oom/TestClassLoaderLeak.java +++ b/test/hotspot/jtreg/gc/shenandoah/oom/TestClassLoaderLeak.java @@ -99,7 +99,7 @@ public static void testWith(boolean shouldPass, String... args) throws Exception pbArgs.add(TestClassLoaderLeak.class.getName()); pbArgs.add("test"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(pbArgs.toArray(new String[0])); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(pbArgs.toArray(new String[0])); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/gc/shenandoah/oom/TestThreadFailure.java b/test/hotspot/jtreg/gc/shenandoah/oom/TestThreadFailure.java index a342b4160104b..75cb2d5c31a24 100644 --- a/test/hotspot/jtreg/gc/shenandoah/oom/TestThreadFailure.java +++ b/test/hotspot/jtreg/gc/shenandoah/oom/TestThreadFailure.java @@ -62,7 +62,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx32m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestArgumentRanges.java b/test/hotspot/jtreg/gc/shenandoah/options/TestArgumentRanges.java index bcda88b553f62..2cc2c2c2197ab 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestArgumentRanges.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestArgumentRanges.java @@ -46,7 +46,7 @@ public static void main(String[] args) throws Exception { private static void testHeuristics() throws Exception { { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", @@ -57,7 +57,7 @@ private static void testHeuristics() throws Exception { output.shouldHaveExitValue(0); } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", @@ -68,7 +68,7 @@ private static void testHeuristics() throws Exception { output.shouldHaveExitValue(0); } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", @@ -83,7 +83,7 @@ private static void testHeuristics() throws Exception { private static void testRange(String option, int min, int max) throws Exception { { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", @@ -94,7 +94,7 @@ private static void testRange(String option, int min, int max) throws Exception output.shouldHaveExitValue(1); } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", @@ -105,7 +105,7 @@ private static void testRange(String option, int min, int max) throws Exception output.shouldHaveExitValue(0); } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", @@ -116,7 +116,7 @@ private static void testRange(String option, int min, int max) throws Exception output.shouldHaveExitValue(1); } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestClassUnloadingArguments.java b/test/hotspot/jtreg/gc/shenandoah/options/TestClassUnloadingArguments.java index 4ebdcc33d14a0..c575b51084c79 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestClassUnloadingArguments.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestClassUnloadingArguments.java @@ -43,7 +43,7 @@ public static void testWith(String msg, boolean cu, boolean cuConc, String... ar cmds[args.length] = "-Xmx128m"; cmds[args.length + 1] = "-XX:+PrintFlagsFinal"; cmds[args.length + 2] = "-version"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmds); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldContain("ClassUnloading"); diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestExplicitGC.java b/test/hotspot/jtreg/gc/shenandoah/options/TestExplicitGC.java index 4e8d699ddeecf..49e7c41713057 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestExplicitGC.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestExplicitGC.java @@ -60,7 +60,7 @@ public static void main(String[] args) throws Exception { }; { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", @@ -77,7 +77,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", @@ -95,7 +95,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", @@ -113,7 +113,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", @@ -131,7 +131,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestExplicitGCNoConcurrent.java b/test/hotspot/jtreg/gc/shenandoah/options/TestExplicitGCNoConcurrent.java index 70724658eb85a..6499457b667aa 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestExplicitGCNoConcurrent.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestExplicitGCNoConcurrent.java @@ -60,7 +60,7 @@ public static void main(String[] args) throws Exception { }; for (String opt : opts) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestHeuristicsUnlock.java b/test/hotspot/jtreg/gc/shenandoah/options/TestHeuristicsUnlock.java index f122cc55fcd79..c9f1c75b4e112 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestHeuristicsUnlock.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestHeuristicsUnlock.java @@ -52,7 +52,7 @@ public static void main(String[] args) throws Exception { private static void testWith(String h, Mode mode) throws Exception { { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:-UnlockDiagnosticVMOptions", "-XX:-UnlockExperimentalVMOptions", @@ -73,7 +73,7 @@ private static void testWith(String h, Mode mode) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:-UnlockExperimentalVMOptions", @@ -94,7 +94,7 @@ private static void testWith(String h, Mode mode) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:-UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestHumongousThresholdArgs.java b/test/hotspot/jtreg/gc/shenandoah/options/TestHumongousThresholdArgs.java index 9c7ca182210b0..523f434dbbd39 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestHumongousThresholdArgs.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestHumongousThresholdArgs.java @@ -38,7 +38,7 @@ public class TestHumongousThresholdArgs { public static void main(String[] args) throws Exception { { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { int[] invalid = new int[] {-100, -1, 0, 101, 1000}; for (int v : valid) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", @@ -62,7 +62,7 @@ public static void main(String[] args) throws Exception { } for (int v : invalid) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestLoopMiningArguments.java b/test/hotspot/jtreg/gc/shenandoah/options/TestLoopMiningArguments.java index f84e576f2f0b1..79452b6cbc5f9 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestLoopMiningArguments.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestLoopMiningArguments.java @@ -44,7 +44,7 @@ public static void testWith(String msg, boolean cls, int iters, String... args) cmds[args.length] = "-Xmx128m"; cmds[args.length + 1] = "-XX:+PrintFlagsFinal"; cmds[args.length + 2] = "-version"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmds); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldContain("UseCountedLoopSafepoints"); diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestModeUnlock.java b/test/hotspot/jtreg/gc/shenandoah/options/TestModeUnlock.java index 6c03281c3ca2e..0c8fea7f9933f 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestModeUnlock.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestModeUnlock.java @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { private static void testWith(String h, Mode mode) throws Exception { { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:-UnlockDiagnosticVMOptions", "-XX:-UnlockExperimentalVMOptions", @@ -72,7 +72,7 @@ private static void testWith(String h, Mode mode) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:-UnlockExperimentalVMOptions", @@ -93,7 +93,7 @@ private static void testWith(String h, Mode mode) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:-UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestRegionSizeArgs.java b/test/hotspot/jtreg/gc/shenandoah/options/TestRegionSizeArgs.java index 17c8b1ed6e3ad..79d0b517e8990 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestRegionSizeArgs.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestRegionSizeArgs.java @@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception { private static void testInvalidRegionSizes() throws Exception { { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms4m", "-Xmx1g", @@ -55,7 +55,7 @@ private static void testInvalidRegionSizes() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms8m", "-Xmx1g", @@ -65,7 +65,7 @@ private static void testInvalidRegionSizes() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms100m", "-Xmx1g", @@ -77,7 +77,7 @@ private static void testInvalidRegionSizes() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms100m", "-Xmx1g", @@ -88,7 +88,7 @@ private static void testInvalidRegionSizes() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms100m", "-Xmx1g", @@ -100,7 +100,7 @@ private static void testInvalidRegionSizes() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms100m", "-Xmx1g", @@ -111,7 +111,7 @@ private static void testInvalidRegionSizes() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms1g", "-Xmx1g", @@ -122,7 +122,7 @@ private static void testInvalidRegionSizes() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms1g", "-Xmx1g", @@ -134,7 +134,7 @@ private static void testInvalidRegionSizes() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms1g", "-Xmx1g", @@ -145,7 +145,7 @@ private static void testInvalidRegionSizes() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms1g", "-Xmx1g", @@ -160,7 +160,7 @@ private static void testInvalidRegionSizes() throws Exception { private static void testMinRegionSize() throws Exception { { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms100m", "-Xmx1g", @@ -172,7 +172,7 @@ private static void testMinRegionSize() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms100m", "-Xmx1g", @@ -184,7 +184,7 @@ private static void testMinRegionSize() throws Exception { output.shouldHaveExitValue(1); } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms100m", "-Xmx1g", @@ -196,7 +196,7 @@ private static void testMinRegionSize() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms100m", "-Xmx1g", @@ -211,7 +211,7 @@ private static void testMinRegionSize() throws Exception { private static void testMaxRegionSize() throws Exception { { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms100m", "-Xmx1g", @@ -223,7 +223,7 @@ private static void testMaxRegionSize() throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms100m", "-Xmx1g", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestSelectiveBarrierFlags.java b/test/hotspot/jtreg/gc/shenandoah/options/TestSelectiveBarrierFlags.java index a6f76f867ef5c..1e1627d0fe58b 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestSelectiveBarrierFlags.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestSelectiveBarrierFlags.java @@ -90,7 +90,7 @@ public static void main(String[] args) throws Exception { pool.submit(() -> { try { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(conf.toArray(new String[0])); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(conf.toArray(new String[0])); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); } catch (Exception e) { diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestSoftMaxHeapSize.java b/test/hotspot/jtreg/gc/shenandoah/options/TestSoftMaxHeapSize.java index cd1e3591fe026..78bbf75189c0c 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestSoftMaxHeapSize.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestSoftMaxHeapSize.java @@ -38,7 +38,7 @@ public class TestSoftMaxHeapSize { public static void main(String[] args) throws Exception { { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms4m", "-Xmx128m", @@ -49,7 +49,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms4m", "-Xmx128m", @@ -60,7 +60,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-Xms4m", "-Xmx128m", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestThreadCounts.java b/test/hotspot/jtreg/gc/shenandoah/options/TestThreadCounts.java index 8100ff57c0599..f7f9ee56b59ab 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestThreadCounts.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestThreadCounts.java @@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception { } private static void testWith(int conc, int par) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestThreadCountsOverride.java b/test/hotspot/jtreg/gc/shenandoah/options/TestThreadCountsOverride.java index c8c876c23e562..5e63595e726fe 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestThreadCountsOverride.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestThreadCountsOverride.java @@ -38,7 +38,7 @@ public class TestThreadCountsOverride { public static void main(String[] args) throws Exception { { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", @@ -53,7 +53,7 @@ public static void main(String[] args) throws Exception { } { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierDisable.java b/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierDisable.java index 4c2ece2bafdde..0e913375534da 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierDisable.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierDisable.java @@ -63,7 +63,7 @@ public static void main(String[] args) throws Exception { private static void shouldFailAll(String h, String[] barriers) throws Exception { for (String b : barriers) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", @@ -81,7 +81,7 @@ private static void shouldFailAll(String h, String[] barriers) throws Exception private static void shouldPassAll(String h, String[] barriers) throws Exception { for (String b : barriers) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierEnable.java b/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierEnable.java index bf37e8db1b3c6..84645621eb401 100644 --- a/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierEnable.java +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierEnable.java @@ -55,7 +55,7 @@ public static void main(String[] args) throws Exception { private static void shouldFailAll(String h, String[] barriers) throws Exception { for (String b : barriers) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", @@ -73,7 +73,7 @@ private static void shouldFailAll(String h, String[] barriers) throws Exception private static void shouldPassAll(String h, String[] barriers) throws Exception { for (String b : barriers) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", diff --git a/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java b/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java index 87ae12d6bbd2d..83f211ad5fa10 100644 --- a/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java +++ b/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -61,7 +61,7 @@ public static void main(String[] args) throws Exception { "-XX:+PrintNMTStatistics" )); baseargs.addAll(Arrays.asList(args)); baseargs.add(GCTest.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(baseargs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(baseargs); verifySymbolMemoryUsageNotTooHigh(new OutputAnalyzer(pb.start())); } diff --git a/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java b/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java index 983b9f6c33fec..2a02039c60e42 100644 --- a/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java +++ b/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -101,7 +101,7 @@ public static void main(String[] args) throws Exception { "-Dregionsize=" + regionSize, TestStressG1HumongousImpl.class.getName() ); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(options); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(options); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/gc/stress/TestStressG1Uncommit.java b/test/hotspot/jtreg/gc/stress/TestStressG1Uncommit.java index e256ea405c2c2..2f61c166cb8f0 100644 --- a/test/hotspot/jtreg/gc/stress/TestStressG1Uncommit.java +++ b/test/hotspot/jtreg/gc/stress/TestStressG1Uncommit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ public static void main(String[] args) throws Exception { "-XX:+UseG1GC", StressUncommit.class.getName() ); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(options); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(options); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldMatch("Uncommit regions"); diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java index 4230399f4bd7b..31c11b66dfc7e 100644 --- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java +++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java @@ -299,7 +299,7 @@ private static OutputAnalyzer runTest(String... extraArgs) throws Exception { args.addAll(Arrays.asList(defaultArgs)); args.addAll(Arrays.asList(extraArgs)); - ProcessBuilder pb = ProcessTools.createTestJvm(args); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(args); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.err.println(output.getStderr()); System.out.println(output.getStdout()); diff --git a/test/hotspot/jtreg/gc/whitebox/TestWBGC.java b/test/hotspot/jtreg/gc/whitebox/TestWBGC.java index c2cb35d4f9df1..c2fe2633e4e90 100644 --- a/test/hotspot/jtreg/gc/whitebox/TestWBGC.java +++ b/test/hotspot/jtreg/gc/whitebox/TestWBGC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ public class TestWBGC { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", diff --git a/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java index 30cd1984c5cae..de3d1f585a7cb 100644 --- a/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public static void main(String[] args) throws Exception { final String heapBackingFile = "Heap Backing File: " + directory; final String failedToCreateFile = "Failed to create file " + directory; - ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder( + ProcessTools.executeProcess(ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseZGC", "-XX:-ZGenerational", "-Xlog:gc*", diff --git a/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java b/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java index 17b463b0cd959..5a20ee8322aef 100644 --- a/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java +++ b/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ public static void main(String[] args) throws Exception { } public static void main(String[] args) throws Exception { - ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder( + ProcessTools.executeProcess(ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseZGC", "-XX:-ZGenerational", "-Xms128M", diff --git a/test/hotspot/jtreg/gc/x/TestSmallHeap.java b/test/hotspot/jtreg/gc/x/TestSmallHeap.java index 6710838c815f6..0fc6477b59b74 100644 --- a/test/hotspot/jtreg/gc/x/TestSmallHeap.java +++ b/test/hotspot/jtreg/gc/x/TestSmallHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception { for (var maxCapacity: args) { - ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder( + ProcessTools.executeProcess(ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseZGC", "-XX:-ZGenerational", "-Xlog:gc,gc+init,gc+reloc,gc+heap", diff --git a/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java index 5a39792aadec4..f5a6113f6ff88 100644 --- a/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java @@ -41,7 +41,7 @@ public static void main(String[] args) throws Exception { final String heapBackingFile = "Heap Backing File: " + directory; final String failedToCreateFile = "Failed to create file " + directory; - ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder( + ProcessTools.executeProcess(ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseZGC", "-XX:+ZGenerational", "-Xlog:gc*", diff --git a/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java b/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java index ca39c35518e16..629edccd49629 100644 --- a/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java +++ b/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java @@ -68,7 +68,7 @@ public static void main(String[] args) throws Exception { } public static void main(String[] args) throws Exception { - ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder( + ProcessTools.executeProcess(ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseZGC", "-XX:+ZGenerational", "-Xms128M", diff --git a/test/hotspot/jtreg/gc/z/TestSmallHeap.java b/test/hotspot/jtreg/gc/z/TestSmallHeap.java index 1b73d5735a745..bfe1c0310ca49 100644 --- a/test/hotspot/jtreg/gc/z/TestSmallHeap.java +++ b/test/hotspot/jtreg/gc/z/TestSmallHeap.java @@ -53,7 +53,7 @@ public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception { for (var maxCapacity: args) { - ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder( + ProcessTools.executeProcess(ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseZGC", "-XX:+ZGenerational", "-Xlog:gc,gc+init,gc+reloc,gc+heap", diff --git a/test/hotspot/jtreg/gc/z/TestZForceDiscontiguousHeapReservations.java b/test/hotspot/jtreg/gc/z/TestZForceDiscontiguousHeapReservations.java index 18b37c21442b8..2993038faa583 100644 --- a/test/hotspot/jtreg/gc/z/TestZForceDiscontiguousHeapReservations.java +++ b/test/hotspot/jtreg/gc/z/TestZForceDiscontiguousHeapReservations.java @@ -45,7 +45,7 @@ private static void testValue(int n) throws Exception { */ final int XmxInM = 2000; final int XmsInM = Math.min(16 * XmxInM / (n + 1), XmxInM); - OutputAnalyzer oa = ProcessTools.executeProcess(ProcessTools.createTestJvm( + OutputAnalyzer oa = ProcessTools.executeProcess(ProcessTools.createTestJavaProcessBuilder( "-XX:+UseZGC", "-XX:+ZGenerational", "-Xms" + XmsInM + "M", diff --git a/test/hotspot/jtreg/gc/z/TestZNMT.java b/test/hotspot/jtreg/gc/z/TestZNMT.java index 87a8643fcd572..066ebd063f60a 100644 --- a/test/hotspot/jtreg/gc/z/TestZNMT.java +++ b/test/hotspot/jtreg/gc/z/TestZNMT.java @@ -68,7 +68,7 @@ private static void testValue(int zForceDiscontiguousHeapReservations) throws Ex * reservations. */ final int XmsInM = Math.min(16 * XmxInM / (zForceDiscontiguousHeapReservations + 1), XmxInM); - OutputAnalyzer oa = ProcessTools.executeProcess(ProcessTools.createTestJvm( + OutputAnalyzer oa = ProcessTools.executeProcess(ProcessTools.createTestJavaProcessBuilder( "-XX:+UseZGC", "-XX:+ZGenerational", "-Xms" + XmsInM + "M", diff --git a/test/hotspot/jtreg/resourcehogs/serviceability/jvmti/GetObjectSizeOverflow.java b/test/hotspot/jtreg/resourcehogs/serviceability/jvmti/GetObjectSizeOverflow.java index b423453ce77a3..236d2eb948609 100644 --- a/test/hotspot/jtreg/resourcehogs/serviceability/jvmti/GetObjectSizeOverflow.java +++ b/test/hotspot/jtreg/resourcehogs/serviceability/jvmti/GetObjectSizeOverflow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ public static void main(String[] args) throws Exception { var jar = new ProcessBuilder(JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "GetObjectSizeOverflowAgent.class"); new OutputAnalyzer(jar.start()).shouldHaveExitValue(0); - ProcessBuilder pt = ProcessTools.createTestJvm("-Xmx4000m", "-javaagent:agent.jar", "GetObjectSizeOverflowAgent"); + ProcessBuilder pt = ProcessTools.createTestJavaProcessBuilder("-Xmx4000m", "-javaagent:agent.jar", "GetObjectSizeOverflowAgent"); OutputAnalyzer output = new OutputAnalyzer(pt.start()); output.stdoutShouldContain("GetObjectSizeOverflow passed"); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java b/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java index 7de7245d8628e..db7cfebfd90c4 100644 --- a/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java +++ b/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ public class TestUnrecognizedVmOption { static final String OPTION="this_is_not_an_option"; public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-showversion", "-XX:" + OPTION); new OutputAnalyzer(pb.start()) .shouldNotHaveExitValue(0) diff --git a/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java b/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java index c84bc7e015991..ebbae35e4e087 100644 --- a/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java +++ b/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ import static java.util.Arrays.stream; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; -import static jdk.test.lib.process.ProcessTools.createJavaProcessBuilder; +import static jdk.test.lib.process.ProcessTools.createLimitedTestJavaProcessBuilder; import static jdk.test.lib.Platform.isWindows; import jdk.test.lib.Utils; import jdk.test.lib.Platform; @@ -229,7 +229,7 @@ public static void main(String[] args) throws Exception { throw new SkippedException("Could not find lsof like command"); } - ProcessBuilder pb = createJavaProcessBuilder( + ProcessBuilder pb = createLimitedTestJavaProcessBuilder( "-Xlog:gc:\"" + logPath + "\"", "-Dtest.jdk=" + getProperty("test.jdk"), VMStartedWithLogging.class.getName(), @@ -250,7 +250,7 @@ static class VMStartedWithLogging { // second VM public static void main(String[] args) throws IOException, InterruptedException { System.out.println(SECOND_VM_PID_PREFIX + ProcessHandle.current().pid()); - ProcessBuilder pb = createJavaProcessBuilder( + ProcessBuilder pb = createLimitedTestJavaProcessBuilder( "-Dtest.jdk=" + getProperty("test.jdk"), VMShouldNotInheritFileDescriptors.class.getName(), args[0], diff --git a/test/hotspot/jtreg/runtime/BadObjectClass/BootstrapRedefine.java b/test/hotspot/jtreg/runtime/BadObjectClass/BootstrapRedefine.java index c4dd815cc4a0e..d94dd1fb927bf 100644 --- a/test/hotspot/jtreg/runtime/BadObjectClass/BootstrapRedefine.java +++ b/test/hotspot/jtreg/runtime/BadObjectClass/BootstrapRedefine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { "--patch-module=java.base"), "mods/java.base"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.base=mods/java.base", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("--patch-module=java.base=mods/java.base", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("Incompatible definition of java.lang.Object") .shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/BootClassAppendProp/BootClassPathAppend.java b/test/hotspot/jtreg/runtime/BootClassAppendProp/BootClassPathAppend.java index 8d6f0fddacd4e..67c6ca493df9a 100644 --- a/test/hotspot/jtreg/runtime/BootClassAppendProp/BootClassPathAppend.java +++ b/test/hotspot/jtreg/runtime/BootClassAppendProp/BootClassPathAppend.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ public class BootClassPathAppend { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintCompilation", "-Xcomp", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/BootstrapMethod/BSMCalledTwice.java b/test/hotspot/jtreg/runtime/BootstrapMethod/BSMCalledTwice.java index a8a8aa060bf03..fb00abb3d188f 100644 --- a/test/hotspot/jtreg/runtime/BootstrapMethod/BSMCalledTwice.java +++ b/test/hotspot/jtreg/runtime/BootstrapMethod/BSMCalledTwice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -107,7 +107,7 @@ public Class loadClass(String name) throws ClassNotFoundException { }; cl.loadClass(classTestCName); - ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", classTestCName); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-cp", ".", classTestCName); OutputAnalyzer output = new OutputAnalyzer(pb.start()); String test_output = output.getOutput(); if (test_output == null) { diff --git a/test/hotspot/jtreg/runtime/BootstrapMethod/TestLambdaExceptionInInitializer.java b/test/hotspot/jtreg/runtime/BootstrapMethod/TestLambdaExceptionInInitializer.java index 77c367a0c23db..008165314f459 100644 --- a/test/hotspot/jtreg/runtime/BootstrapMethod/TestLambdaExceptionInInitializer.java +++ b/test/hotspot/jtreg/runtime/BootstrapMethod/TestLambdaExceptionInInitializer.java @@ -37,7 +37,7 @@ public class TestLambdaExceptionInInitializer { public static void main(String args[]) throws Throwable { // Run Lamba class - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("TestPkg.Lambda"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("TestPkg.Lambda"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldMatch("Exception in thread \".+\" java.lang.ExceptionInInitializerError"); diff --git a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java index be97d1cf056eb..51b0469ce46b8 100644 --- a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java +++ b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class CDSCompressedKPtrs { public static void main(String[] args) throws Exception { ProcessBuilder pb; - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops", "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CDSCompressedKPtrs.jsa", "-Xshare:dump", "-Xlog:cds"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); @@ -50,7 +50,7 @@ public static void main(String[] args) throws Exception { output.shouldContain("Loading classes to share"); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops", "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CDSCompressedKPtrs.jsa", "-Xshare:on", "-version"); output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java index 19c4128f46009..e53758a671a46 100644 --- a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java +++ b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ public class XShareAuto { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-server", "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./XShareAuto.jsa", "-Xshare:dump", "-Xlog:cds"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); @@ -55,7 +55,7 @@ public static void main(String[] args) throws Exception { }; for (String x : cases) { - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./XShareAuto.jsa", "-Xlog:cds", diff --git a/test/hotspot/jtreg/runtime/ClassFile/FormatCheckingTest.java b/test/hotspot/jtreg/runtime/ClassFile/FormatCheckingTest.java index 0ff1f0a65be01..8ab2d2252a8dd 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/FormatCheckingTest.java +++ b/test/hotspot/jtreg/runtime/ClassFile/FormatCheckingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ public class FormatCheckingTest { public static void main(String args[]) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("BadHelloWorld"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("BadHelloWorld"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("java.lang.ClassFormatError: Illegal class name"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/ClassFile/JsrRewriting.java b/test/hotspot/jtreg/runtime/ClassFile/JsrRewriting.java index 4d2c74360c774..8563c79b19c12 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/JsrRewriting.java +++ b/test/hotspot/jtreg/runtime/ClassFile/JsrRewriting.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ public static void main(String[] args) throws Exception { // ======= execute the test // We run the test with MallocLimit set to 768m in oom mode, // in order to trigger and observe a fake os::malloc oom. This needs NMT. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-cp", ".", "-XX:+UnlockDiagnosticVMOptions", "-XX:NativeMemoryTracking=summary", diff --git a/test/hotspot/jtreg/runtime/ClassFile/OomWhileParsingRepeatedJsr.java b/test/hotspot/jtreg/runtime/ClassFile/OomWhileParsingRepeatedJsr.java index b82f03786ec0a..9ea18f5e2fc49 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/OomWhileParsingRepeatedJsr.java +++ b/test/hotspot/jtreg/runtime/ClassFile/OomWhileParsingRepeatedJsr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,7 @@ public static void main(String[] args) throws Exception { // ======= execute the test // We run the test with MallocLimit set to 768m in oom mode, // in order to trigger and observe a fake os::malloc oom. This needs NMT. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-cp", ".", "-XX:+UnlockDiagnosticVMOptions", "-XX:NativeMemoryTracking=summary", diff --git a/test/hotspot/jtreg/runtime/ClassFile/PreviewVersion.java b/test/hotspot/jtreg/runtime/ClassFile/PreviewVersion.java index 160d0559fbe92..9e3ae8de83285 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/PreviewVersion.java +++ b/test/hotspot/jtreg/runtime/ClassFile/PreviewVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -54,21 +54,21 @@ public static void main(String args[]) throws Throwable { // Run the test. This should fail because --enable-preview is not specified. ClassFileInstaller.writeClassToDisk("PVTest", klassbuf, System.getProperty("test.classes")); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-cp", "." + File.pathSeparator + System.getProperty("test.classes"), "PVTest"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldContain("Preview features are not enabled"); oa.shouldHaveExitValue(1); // This should be successful because --enable-preview is specified. - pb = ProcessTools.createJavaProcessBuilder("--enable-preview", + pb = ProcessTools.createLimitedTestJavaProcessBuilder("--enable-preview", "-cp", "." + File.pathSeparator + System.getProperty("test.classes"), "PVTest"); oa = new OutputAnalyzer(pb.start()); oa.shouldContain("Hi!"); oa.shouldHaveExitValue(0); // Test -Xlog:class+preview - pb = ProcessTools.createJavaProcessBuilder("--enable-preview", "-Xlog:class+preview", + pb = ProcessTools.createLimitedTestJavaProcessBuilder("--enable-preview", "-Xlog:class+preview", "-cp", "." + File.pathSeparator + System.getProperty("test.classes"), "PVTest"); oa = new OutputAnalyzer(pb.start()); oa.shouldContain("[info][class,preview] Loading class PVTest that depends on preview features"); diff --git a/test/hotspot/jtreg/runtime/ClassFile/TestCheckedExceptions.java b/test/hotspot/jtreg/runtime/ClassFile/TestCheckedExceptions.java index a6f64e96bb66c..3c041ed253632 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/TestCheckedExceptions.java +++ b/test/hotspot/jtreg/runtime/ClassFile/TestCheckedExceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class TestCheckedExceptions { public static void main(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xlog:exceptions=warning", "CheckedExceptions"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/ClassFile/UnsupportedClassFileVersion.java b/test/hotspot/jtreg/runtime/ClassFile/UnsupportedClassFileVersion.java index 3ac53335ea47b..c61f46c3ecda9 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/UnsupportedClassFileVersion.java +++ b/test/hotspot/jtreg/runtime/ClassFile/UnsupportedClassFileVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public class UnsupportedClassFileVersion implements Opcodes { public static void main(String... args) throws Exception { writeClassFile(); - ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", "ClassFile"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-cp", ".", "ClassFile"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("ClassFile has been compiled by a more recent version of the " + "Java Runtime (class file version 99.0), this version of " + diff --git a/test/hotspot/jtreg/runtime/CommandLine/BooleanFlagWithInvalidValue.java b/test/hotspot/jtreg/runtime/CommandLine/BooleanFlagWithInvalidValue.java index 55278a67bc220..1ca819497fa6e 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/BooleanFlagWithInvalidValue.java +++ b/test/hotspot/jtreg/runtime/CommandLine/BooleanFlagWithInvalidValue.java @@ -37,14 +37,14 @@ public class BooleanFlagWithInvalidValue { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintWarnings=8", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Improperly specified VM option 'PrintWarnings=8'"); output.shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-PrintWarnings=8", "-version"); output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/CommandLine/CompilerConfigFileWarning.java b/test/hotspot/jtreg/runtime/CommandLine/CompilerConfigFileWarning.java index c1807e4b3ec0a..ca0038a2226fc 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/CompilerConfigFileWarning.java +++ b/test/hotspot/jtreg/runtime/CommandLine/CompilerConfigFileWarning.java @@ -47,7 +47,7 @@ public static void main(String[] args) throws Exception { pw.println("aaa, aaa"); pw.close(); - pb = ProcessTools.createJavaProcessBuilder("-XX:CompileCommandFile=hs_comp.txt", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompileCommandFile=hs_comp.txt", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(1); output.shouldContain("An error occurred during parsing"); @@ -60,7 +60,7 @@ public static void main(String[] args) throws Exception { pw.println("aa"); pw.close(); - pb = ProcessTools.createJavaProcessBuilder("-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-version"); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldContain("warning: .hotspot_compiler file is present but has been ignored. Run with -XX:CompileCommandFile=.hotspot_compiler to load the file."); diff --git a/test/hotspot/jtreg/runtime/CommandLine/ConfigFileParsing.java b/test/hotspot/jtreg/runtime/CommandLine/ConfigFileParsing.java index 471c71a00466d..4f31b210da1ec 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/ConfigFileParsing.java +++ b/test/hotspot/jtreg/runtime/CommandLine/ConfigFileParsing.java @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { pw.close(); // start VM - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-XX:Flags=.hotspotrc", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/CommandLine/ConfigFileWarning.java b/test/hotspot/jtreg/runtime/CommandLine/ConfigFileWarning.java index 62aef23b58082..d9e72fa300adf 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/ConfigFileWarning.java +++ b/test/hotspot/jtreg/runtime/CommandLine/ConfigFileWarning.java @@ -47,7 +47,7 @@ public static void main(String[] args) throws Exception { pw.println("aaa"); pw.close(); - pb = ProcessTools.createJavaProcessBuilder("-XX:Flags=hs_flags.txt","-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:Flags=hs_flags.txt","-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Unrecognized VM option 'aaa'"); output.shouldHaveExitValue(1); @@ -58,7 +58,7 @@ public static void main(String[] args) throws Exception { pw.println("aa"); pw.close(); - pb = ProcessTools.createJavaProcessBuilder("-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-version"); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.shouldContain("warning: .hotspotrc file is present but has been ignored. Run with -XX:Flags=.hotspotrc to load the file."); diff --git a/test/hotspot/jtreg/runtime/CommandLine/DoubleFlagWithIntegerValue.java b/test/hotspot/jtreg/runtime/CommandLine/DoubleFlagWithIntegerValue.java index e24fd8f9ae061..65b1533542d62 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/DoubleFlagWithIntegerValue.java +++ b/test/hotspot/jtreg/runtime/CommandLine/DoubleFlagWithIntegerValue.java @@ -37,7 +37,7 @@ public class DoubleFlagWithIntegerValue { public static void testDoubleFlagWithValue(String flag, String value) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flag + "=" + value, "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(flag + "=" + value, "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Improperly specified VM option"); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/CommandLine/FlagWithInvalidValue.java b/test/hotspot/jtreg/runtime/CommandLine/FlagWithInvalidValue.java index 5cfc3497a94a6..c16a05a79a845 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/FlagWithInvalidValue.java +++ b/test/hotspot/jtreg/runtime/CommandLine/FlagWithInvalidValue.java @@ -37,7 +37,7 @@ public class FlagWithInvalidValue { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:MaxRAMPercentage=v", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/CommandLine/IgnoreUnrecognizedVMOptions.java b/test/hotspot/jtreg/runtime/CommandLine/IgnoreUnrecognizedVMOptions.java index 36f58fb3a977a..4a5a4f7127b2c 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/IgnoreUnrecognizedVMOptions.java +++ b/test/hotspot/jtreg/runtime/CommandLine/IgnoreUnrecognizedVMOptions.java @@ -38,7 +38,7 @@ public class IgnoreUnrecognizedVMOptions { private static void runJavaAndCheckExitValue(boolean shouldSucceed, String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (shouldSucceed) { output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java b/test/hotspot/jtreg/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java index 0aead7092456e..5ea305431b0b9 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java +++ b/test/hotspot/jtreg/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java @@ -37,14 +37,14 @@ public class NonBooleanFlagWithInvalidBooleanPrefix { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-MaxRAMPercentage=1", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMPercentage=1'"); output.shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+MaxRAMPercentage=1", "-version"); output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/CommandLine/ObsoleteFlagErrorMessage.java b/test/hotspot/jtreg/runtime/CommandLine/ObsoleteFlagErrorMessage.java index 8de8292611b4c..1dc1cd9976b1d 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/ObsoleteFlagErrorMessage.java +++ b/test/hotspot/jtreg/runtime/CommandLine/ObsoleteFlagErrorMessage.java @@ -41,7 +41,7 @@ public static void main(String[] args) throws Exception { String flag = "DummyObsoleteTestFlag"; // Case 1: Newly obsolete flags with extra junk appended should not be treated as newly obsolete (8060449) - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:" + flag + "PlusJunk", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); @@ -49,7 +49,7 @@ public static void main(String[] args) throws Exception { output.shouldHaveExitValue(1); // Case 2: Newly obsolete flags should be recognized as newly obsolete (8073989) - ProcessBuilder pb2 = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb2 = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+" + flag, "-version"); OutputAnalyzer output2 = new OutputAnalyzer(pb2.start()); diff --git a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java index b56cc3767884f..b5b15f6d75f04 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java +++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { OutputAnalyzer output; System.out.println("Verify jcmd error message and that jcmd does not write errors to the target process output"); - output = new OutputAnalyzer((ProcessTools.createJavaProcessBuilder( + output = new OutputAnalyzer((ProcessTools.createLimitedTestJavaProcessBuilder( "-Dtest.jdk=" + System.getProperty("test.jdk"), "-XX:MinHeapFreeRatio=20", "-XX:MaxHeapFreeRatio=80", runJcmd.class.getName())).start()); diff --git a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java index ed37cc6560170..78a508343d679 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java +++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -417,7 +417,7 @@ private boolean runJavaWithParam(String optionValue, boolean valid) throws Excep runJava.add(optionValue); runJava.add(JVMStartup.class.getName()); - out = new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(runJava).start()); + out = new OutputAnalyzer(ProcessTools.createLimitedTestJavaProcessBuilder(runJava).start()); exitCode = out.getExitValue(); String exitCodeString = null; diff --git a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java index ba0b2f7d61faa..031d30bf2bdc1 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java +++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -469,7 +469,7 @@ private static Map getOptionsAsMap(boolean withRanges, Predic runJava.add(PRINT_FLAGS_RANGES); runJava.add("-version"); - p = ProcessTools.createJavaProcessBuilder(runJava).start(); + p = ProcessTools.createLimitedTestJavaProcessBuilder(runJava).start(); result = getJVMOptions(new InputStreamReader(p.getInputStream()), withRanges, acceptOrigin); diff --git a/test/hotspot/jtreg/runtime/CommandLine/TestHexArguments.java b/test/hotspot/jtreg/runtime/CommandLine/TestHexArguments.java index 3d0dab15ce128..7f646edfdccbf 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/TestHexArguments.java +++ b/test/hotspot/jtreg/runtime/CommandLine/TestHexArguments.java @@ -39,13 +39,13 @@ public class TestHexArguments { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:SharedBaseAddress=0x1D000000", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Could not create the Java Virtual Machine"); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:SharedBaseAddress=1D000000", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldNotHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/CommandLine/TestLongUnrecognizedVMOption.java b/test/hotspot/jtreg/runtime/CommandLine/TestLongUnrecognizedVMOption.java index bae2aaf5ceb2f..04bdd25714f18 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/TestLongUnrecognizedVMOption.java +++ b/test/hotspot/jtreg/runtime/CommandLine/TestLongUnrecognizedVMOption.java @@ -43,7 +43,7 @@ public class TestLongUnrecognizedVMOption { public static void main(String[] args) throws Exception { OutputAnalyzer output; - output = new OutputAnalyzer(ProcessTools.createJavaProcessBuilder("-XX:" + VERY_LONG_OPTION, "-version").start()); + output = new OutputAnalyzer(ProcessTools.createLimitedTestJavaProcessBuilder("-XX:" + VERY_LONG_OPTION, "-version").start()); output.shouldHaveExitValue(1); output.shouldContain(String.format("Unrecognized VM option '%s'", VERY_LONG_OPTION)); } diff --git a/test/hotspot/jtreg/runtime/CommandLine/TestNullTerminatedFlags.java b/test/hotspot/jtreg/runtime/CommandLine/TestNullTerminatedFlags.java index 20a6f73ad1efb..e31a7e2cd171e 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/TestNullTerminatedFlags.java +++ b/test/hotspot/jtreg/runtime/CommandLine/TestNullTerminatedFlags.java @@ -58,7 +58,7 @@ public static void main(String args[]) throws Exception{ for (String option : options) { String testOption = option + "junk"; ProcessBuilder pb = - ProcessTools.createJavaProcessBuilder(testOption, "-version"); + ProcessTools.createLimitedTestJavaProcessBuilder(testOption, "-version"); new OutputAnalyzer(pb.start()) .shouldContain("Unrecognized option: " + testOption) .shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/CommandLine/TestVMOptions.java b/test/hotspot/jtreg/runtime/CommandLine/TestVMOptions.java index 58a7307cafa54..4ebeb9b7025b4 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/TestVMOptions.java +++ b/test/hotspot/jtreg/runtime/CommandLine/TestVMOptions.java @@ -38,7 +38,7 @@ public class TestVMOptions { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:bogus", "-XX:+IgnoreUnrecognizedVMOptions", "-XX:+PrintFlagsInitial"); @@ -46,7 +46,7 @@ public static void main(String[] args) throws Exception { output.shouldHaveExitValue(0); output.shouldContain("bool UseSerialGC"); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-PrintVMOptions", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); @@ -55,7 +55,7 @@ public static void main(String[] args) throws Exception { File dir = new File(System.getProperty("test.src", ".")); File file = new File(dir, "flagfile.txt"); String s = file.getAbsolutePath(); - pb = ProcessTools.createJavaProcessBuilder("-XX:Flags="+s); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:Flags="+s); output = new OutputAnalyzer(pb.start()); output.shouldNotHaveExitValue(0); output.shouldContain("VM option '-IgnoreUnrecognizedVMOptions'"); diff --git a/test/hotspot/jtreg/runtime/CommandLine/TraceExceptionsTest.java b/test/hotspot/jtreg/runtime/CommandLine/TraceExceptionsTest.java index 3f719849f080c..09b51712c05c5 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/TraceExceptionsTest.java +++ b/test/hotspot/jtreg/runtime/CommandLine/TraceExceptionsTest.java @@ -38,7 +38,7 @@ public class TraceExceptionsTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xlog:exceptions=info", "NoClassFound"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain(""); diff --git a/test/hotspot/jtreg/runtime/CommandLine/UnrecognizedVMOption.java b/test/hotspot/jtreg/runtime/CommandLine/UnrecognizedVMOption.java index 388b4e9fa5fbc..dfbb08d2f6897 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/UnrecognizedVMOption.java +++ b/test/hotspot/jtreg/runtime/CommandLine/UnrecognizedVMOption.java @@ -44,7 +44,7 @@ public static void main(String[] args) throws Exception { "bogus_option", }; for (String option : badOptions) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:" + option, "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java index 6d847088f0d34..95dd88c72237a 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java +++ b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java @@ -101,7 +101,7 @@ static void testDeprecated(String[][] optionInfo) throws Throwable { // command line by -XX:+UnlockDiagnosticVMOptions. static void testDeprecatedDiagnostic(String option, String value) throws Throwable { String XXoption = CommandLineOptionTest.prepareFlag(option, value); - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, XXoption, "-version"); OutputAnalyzer output = new OutputAnalyzer(processBuilder.start()); // check for option deprecation message: @@ -114,7 +114,7 @@ static void testDeprecatedDiagnostic(String option, String value) throws Throwa // command line by -XX:+UnlockExperimentalVMOption. static void testDeprecatedExperimental(String option, String value) throws Throwable { String XXoption = CommandLineOptionTest.prepareFlag(option, value); - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, XXoption, "-version"); OutputAnalyzer output = new OutputAnalyzer(processBuilder.start()); // check for option deprecation message: diff --git a/test/hotspot/jtreg/runtime/CommandLine/VMOptionWarning.java b/test/hotspot/jtreg/runtime/CommandLine/VMOptionWarning.java index 32f9bab43c630..e4740a3bcb71a 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/VMOptionWarning.java +++ b/test/hotspot/jtreg/runtime/CommandLine/VMOptionWarning.java @@ -38,7 +38,7 @@ public class VMOptionWarning { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+AlwaysSafeConstructors", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+AlwaysSafeConstructors", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotHaveExitValue(0); output.shouldContain("Error: VM option 'AlwaysSafeConstructors' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions."); @@ -48,17 +48,17 @@ public static void main(String[] args) throws Exception { return; } - pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintInlining", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintInlining", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldNotHaveExitValue(0); output.shouldContain("Error: VM option 'PrintInlining' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions."); - pb = ProcessTools.createJavaProcessBuilder("-XX:+VerifyStack", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+VerifyStack", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldNotHaveExitValue(0); output.shouldContain("Error: VM option 'VerifyStack' is develop and is available only in debug version of VM."); - pb = ProcessTools.createJavaProcessBuilder("-XX:+CheckCompressedOops", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+CheckCompressedOops", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldNotHaveExitValue(0); output.shouldContain("Error: VM option 'CheckCompressedOops' is notproduct and is available only in debug version of VM."); diff --git a/test/hotspot/jtreg/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java b/test/hotspot/jtreg/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java index e9daf2575f7a8..675e688fa3566 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java +++ b/test/hotspot/jtreg/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java @@ -248,7 +248,7 @@ private static ProcessBuilder createProcessBuilder() throws Exception { runJava.add(PrintPropertyAndOptions.class.getName()); runJava.addAll(appParams); - pb = ProcessTools.createJavaProcessBuilder(runJava); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(runJava); VMParams.clear(); appParams.clear(); diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java index 6b41a7461d159..4feadfb5565b6 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java @@ -69,7 +69,7 @@ static boolean isCCSReservedAnywhere(OutputAnalyzer output) { // CDS off, small heap, ccs size default (1G) // A small heap should allow us to place the ccs within the lower 32G and thus allow zero based encoding. public static void smallHeapTest() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedBaseAddress=8g", "-Xmx128m", @@ -86,7 +86,7 @@ public static void smallHeapTest() throws Exception { // CDS off, small heap, ccs size explicitely set to 1G // A small heap should allow us to place the ccs within the lower 32G and thus allow zero based encoding. public static void smallHeapTestWith1G() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:CompressedClassSpaceSize=1g", "-Xmx128m", @@ -104,7 +104,7 @@ public static void smallHeapTestWith1G() throws Exception { // We expect the ccs to be mapped somewhere far beyond the heap, such that it is not possible // to use zero based encoding. public static void largeHeapTest() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", "-Xmx30g", @@ -129,7 +129,7 @@ public static void largeHeapTest() throws Exception { // for compressed oops. // We expect a zerobased ccs. public static void largeHeapAbove32GTest() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", "-Xmx31g", @@ -150,7 +150,7 @@ public static void largeHeapAbove32GTest() throws Exception { // Using large paged heap, metaspace uses small pages. public static void largePagesForHeapTest() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx128m", "-XX:+UseLargePages", @@ -164,7 +164,7 @@ public static void largePagesForHeapTest() throws Exception { } public static void heapBaseMinAddressTest() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:HeapBaseMinAddress=1m", "-Xlog:gc+heap+coops=debug", "-version"); @@ -175,7 +175,7 @@ public static void heapBaseMinAddressTest() throws Exception { public static void sharingTest() throws Exception { // Test small heaps - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CompressedClassPointers.jsa", "-Xmx128m", @@ -191,7 +191,7 @@ public static void sharingTest() throws Exception { output.shouldContain("Loading classes to share"); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CompressedClassPointers.jsa", "-Xmx128m", @@ -210,7 +210,7 @@ public static void sharingTest() throws Exception { } public static void smallHeapTestNoCoop() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", @@ -228,7 +228,7 @@ public static void smallHeapTestNoCoop() throws Exception { } public static void smallHeapTestWith1GNoCoop() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", @@ -250,7 +250,7 @@ public static void smallHeapTestWith1GNoCoop() throws Exception { } public static void largeHeapTestNoCoop() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", @@ -272,7 +272,7 @@ public static void largeHeapTestNoCoop() throws Exception { } public static void largePagesTestNoCoop() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", @@ -286,7 +286,7 @@ public static void largePagesTestNoCoop() throws Exception { } public static void heapBaseMinAddressTestNoCoop() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", "-XX:+UseCompressedClassPointers", "-XX:HeapBaseMinAddress=1m", @@ -299,7 +299,7 @@ public static void heapBaseMinAddressTestNoCoop() throws Exception { public static void sharingTestNoCoop() throws Exception { // Test small heaps - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", @@ -317,7 +317,7 @@ public static void sharingTestNoCoop() throws Exception { output.shouldContain("Loading classes to share"); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-UseCompressedOops", "-XX:+UseCompressedClassPointers", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java index 5eaced668f0a2..e0ec12713469f 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,23 +42,23 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb; OutputAnalyzer output; // Minimum size is 1MB - pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=0", + "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("outside the allowed range") .shouldHaveExitValue(1); // Invalid size of -1 should be handled correctly - pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1", + "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'") .shouldHaveExitValue(1); // Maximum size is 3GB - pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g", + "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("outside the allowed range") .shouldHaveExitValue(1); @@ -67,28 +67,28 @@ public static void main(String[] args) throws Exception { // Make sure the minimum size is set correctly and printed // (Note: ccs size are rounded up to the next larger root chunk boundary (16m). // Note that this is **reserved** size and does not affect rss. - pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", - "-XX:CompressedClassSpaceSize=1m", - "-Xlog:gc+metaspace=trace", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", + "-XX:CompressedClassSpaceSize=1m", + "-Xlog:gc+metaspace=trace", + "-version"); output = new OutputAnalyzer(pb.start()); output.shouldMatch("Compressed class space.*16777216") .shouldHaveExitValue(0); // Make sure the maximum size is set correctly and printed - pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", - "-XX:CompressedClassSpaceSize=3g", - "-Xlog:gc+metaspace=trace", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", + "-XX:CompressedClassSpaceSize=3g", + "-Xlog:gc+metaspace=trace", + "-version"); output = new OutputAnalyzer(pb.start()); output.shouldMatch("Compressed class space.*3221225472") .shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClassPointers", - "-XX:CompressedClassSpaceSize=1m", - "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:-UseCompressedClassPointers", + "-XX:CompressedClassSpaceSize=1m", + "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used") .shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java index 28c517bbca9c8..403654d1cc8f1 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -50,7 +50,7 @@ private static void runWithAlignment(int alignment) throws Exception { ProcessBuilder pb; OutputAnalyzer output; - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops", "-XX:ObjectAlignmentInBytes=" + alignment, diff --git a/test/hotspot/jtreg/runtime/CompressedOops/ObjectAlignment.java b/test/hotspot/jtreg/runtime/CompressedOops/ObjectAlignment.java index f9c6d6921aad6..0cf4a72f51982 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/ObjectAlignment.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/ObjectAlignment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,8 +74,8 @@ public static void main(String[] args) throws Exception { } private static OutputAnalyzer testObjectAlignment(int alignment) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:ObjectAlignmentInBytes=" + alignment, - "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ObjectAlignmentInBytes=" + alignment, + "-version"); return new OutputAnalyzer(pb.start()); } } diff --git a/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java b/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java index bf4d58232a840..3d118bf73b141 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -189,7 +189,7 @@ private static OutputAnalyzer testCompressedOops(ArrayList flags1, Strin args.add("-version"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); return new OutputAnalyzer(pb.start()); } } diff --git a/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java b/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java index 493f02f30362f..4e4a9329f5da8 100644 --- a/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java +++ b/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ public class CleanProtectionDomain { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xlog:protectiondomain+table=debug", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java b/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java index 756bff98ffb2d..423fba7d22140 100644 --- a/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java +++ b/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -98,7 +98,7 @@ public static void main(final String[] args) throws Exception { } public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Djava.security.policy==" + System.getProperty("test.src") + File.separator + "test.policy", "-Dtest.classes=" + System.getProperty("test.classes", "."), "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/runtime/EnclosingMethodAttr/EnclMethodAttr.java b/test/hotspot/jtreg/runtime/EnclosingMethodAttr/EnclMethodAttr.java index db6b924078bc4..9b9acdce023da 100644 --- a/test/hotspot/jtreg/runtime/EnclosingMethodAttr/EnclMethodAttr.java +++ b/test/hotspot/jtreg/runtime/EnclosingMethodAttr/EnclMethodAttr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class EnclMethodAttr { public static void main(String args[]) throws Throwable { System.out.println("Regression test for bug 8044738"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("EnclMethTest"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("EnclMethTest"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotHaveExitValue(0); output.shouldContain("java.lang.ClassFormatError: Wrong EnclosingMethod"); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java index af4553f0022e7..435deeb696dc0 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java @@ -45,7 +45,7 @@ // This test was adapted from SafeFetchInErrorHandlingTest.java. public class BadNativeStackInErrorHandlingTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:ErrorHandlerTest=14", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ClassPathEnvVar.java b/test/hotspot/jtreg/runtime/ErrorHandling/ClassPathEnvVar.java index 68fbf40e44100..4b4e41944de39 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ClassPathEnvVar.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ClassPathEnvVar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,9 +51,9 @@ public static void main(String[] args) throws Exception { } private static OutputAnalyzer runCrasher() throws Exception { ProcessBuilder pb = - ProcessTools.createJavaProcessBuilder("-XX:-CreateCoredumpOnCrash", - "-XX:ErrorHandlerTest=14", - "-XX:+ErrorFileToStdout"); + ProcessTools.createLimitedTestJavaProcessBuilder("-XX:-CreateCoredumpOnCrash", + "-XX:ErrorHandlerTest=14", + "-XX:+ErrorFileToStdout"); // Obtain the CLASSPATH setting and expand it to more than 2000 chars. Map envMap = pb.environment(); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java b/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java index 36502046570ff..73efc0e5e4605 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ public static void main(String[] args) throws Exception { } public static OutputAnalyzer runTest(String option) throws Exception { return new OutputAnalyzer( - ProcessTools.createJavaProcessBuilder( + ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName()) .start()); } diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileOverwriteTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileOverwriteTest.java index ea8e944aebbce..5fcb4ec5f9ed6 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileOverwriteTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileOverwriteTest.java @@ -97,7 +97,7 @@ public static void do_test(boolean with_percent_p) throws Exception { System.out.println("First crash..."); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx64M", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=1", @@ -123,7 +123,7 @@ public static void do_test(boolean with_percent_p) throws Exception { System.out.println("Second crash..."); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx64M", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=2", // << now 2 diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileRedirectTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileRedirectTest.java index 3c32c6f8141c2..0e03317d640b8 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileRedirectTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileRedirectTest.java @@ -48,7 +48,7 @@ public class ErrorFileRedirectTest { public static void do_test(boolean redirectStdout, boolean redirectStderr) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx64M", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=14", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/MachCodeFramesInErrorFile.java b/test/hotspot/jtreg/runtime/ErrorHandling/MachCodeFramesInErrorFile.java index 8dced9a3a9c40..5717a576e6542 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/MachCodeFramesInErrorFile.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/MachCodeFramesInErrorFile.java @@ -115,7 +115,7 @@ public static void main(String[] args) throws Exception { * expected to have a min number of MachCode sections. */ private static void run(boolean crashInJava) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx64m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", "-Xcomp", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java index d57a2bf29c252..b53dadfc41e20 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java @@ -53,7 +53,7 @@ public static void main(String[] args) throws Exception { // Need to disable ShowRegistersOnAssert: that flag causes registers to be shown, which calls os::print_location, // which - as part of its checks - will iterate the threads list under a ThreadListHandle, changing the max nesting // counters and confusing this test. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+EnableThreadSMRStatistics", "-Xmx100M", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java index dc54b09156c0b..e3d9c90408d53 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java @@ -47,7 +47,7 @@ public static void main(String[] args) { } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx64m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Exception in thread"); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ReattemptErrorTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ReattemptErrorTest.java index 279b07ffff779..92327d96dfb53 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ReattemptErrorTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ReattemptErrorTest.java @@ -57,7 +57,7 @@ public static void main(String[] args) throws Exception { // * Third a step will use almost all stack space and then fault with SIGSEGV. After this the // proceeding reattempt steps will be skipped because of low stack headroom. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:-CreateCoredumpOnCrash", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ResourceMarkTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ResourceMarkTest.java index 77f8be0188788..5bbc4cfac00b4 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ResourceMarkTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ResourceMarkTest.java @@ -48,7 +48,7 @@ public class ResourceMarkTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:-CreateCoredumpOnCrash", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java index 01c5c5e795341..a08d673115c49 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java @@ -47,7 +47,7 @@ public class SafeFetchInErrorHandlingTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:ErrorHandlerTest=14", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java index 9f689380c7035..012d5a5c16d84 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java @@ -80,7 +80,7 @@ public static void main(String[] args) throws Exception { // We also check, optionally, that +ErrorLogSecondaryErrorDetails produces callstacks for // the secondary error. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:-CreateCoredumpOnCrash", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java index f2214204f4e43..b861e44532db7 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java @@ -55,7 +55,7 @@ private static void do_test(boolean do_assert, // true - assert, false - guarant { System.out.println("Testing " + (do_assert ? "assert" : "guarantee") + " with " + (show_registers_on_assert ? "-XX:+ShowRegistersOnAssert" : "-XX:-ShowRegistersOnAssert") + "..."); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=" + (do_assert ? "1" : "2"), (show_registers_on_assert ? "-XX:+ShowRegistersOnAssert" : "-XX:-ShowRegistersOnAssert"), diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/StackWalkNativeToJava.java b/test/hotspot/jtreg/runtime/ErrorHandling/StackWalkNativeToJava.java index 0c9c846c8b6d3..7d7deffdb6e35 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/StackWalkNativeToJava.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/StackWalkNativeToJava.java @@ -65,7 +65,7 @@ public static void testStackWalkNativeToJavaNative(String... extraFlags) throws commands.addAll(Arrays.asList(extraFlags)); commands.add("StackWalkNativeToJava$TestNativeToJavaNative"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(commands); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(commands); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("java.lang.RuntimeException: Reached statement after obj.wait()"); output.shouldNotContain("[error occurred during error reporting (printing native stack"); @@ -99,7 +99,7 @@ public static void testStackWalkNativeToJava(String... extraFlags) throws Except commands.addAll(Arrays.asList(extraFlags)); commands.add("StackWalkNativeToJava$TestNativeToJava"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(commands); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(commands); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("java.lang.RuntimeException: Reached statement after synchronized"); output.shouldNotContain("[error occurred during error reporting (printing native stack"); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestAbortVmOnException.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestAbortVmOnException.java index f71bc0ef8af34..cafa23fd672ef 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestAbortVmOnException.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestAbortVmOnException.java @@ -60,12 +60,12 @@ public static void main(String[] args) throws Exception { private static Process runProcess(String exceptionName, boolean withMessage, String exceptionMessage) throws IOException { if (exceptionMessage == null) { - return ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", + return ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:AbortVMOnException=" + exceptionName, "-Xcomp", "-XX:TieredStopAtLevel=3", "-XX:-CreateCoredumpOnCrash", "-XX:CompileCommand=compileonly,TestAbortVmOnException::*", TestAbortVmOnException.class.getName(), withMessage ? "throwExceptionWithMessage" : "throwException").start(); } else { - return ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", + return ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:AbortVMOnException=" + exceptionName, "-XX:AbortVMOnExceptionMessage=" + exceptionMessage, "-Xcomp", "-XX:TieredStopAtLevel=3", "-XX:-CreateCoredumpOnCrash", "-XX:CompileCommand=compileonly,TestAbortVmOnException::*", TestAbortVmOnException.class.getName(),withMessage ? "throwExceptionWithMessage" : "throwException").start(); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java index da46cd9e8116b..0be39d22ebecb 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java @@ -54,7 +54,7 @@ public static void main(String[] args) throws Exception { } } // else this is the main test - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError", "-XX:-CreateCoredumpOnCrash", "-Xmx128m", TestCrashOnOutOfMemoryError.class.getName(),"throwOOME"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); int exitValue = output.getExitValue(); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java index effcd8b321695..2ae46a36229f0 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java @@ -137,7 +137,7 @@ private static void test() throws Exception { private static void runAndCheck(Flags flags, DwarfConstraint... constraints) throws Exception { OutputAnalyzer crashOut; - crashOut = ProcessTools.executeProcess(ProcessTools.createTestJvm(flags.getFlags())); + crashOut = ProcessTools.executeProcess(ProcessTools.createTestJavaProcessBuilder(flags.getFlags())); String crashOutputString = crashOut.getOutput(); Asserts.assertNotEquals(crashOut.getExitValue(), 0, "Crash JVM should not exit gracefully"); System.out.println(crashOutputString); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java index e56ed4a1b0317..145dd4aadc99d 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java @@ -49,7 +49,7 @@ public static void main(String[] args) throws Exception { } // else this is the main test - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+ExitOnOutOfMemoryError", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+ExitOnOutOfMemoryError", "-Xmx128m", TestExitOnOutOfMemoryError.class.getName(), "throwOOME"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestGZippedHeapDumpOnOutOfMemoryError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestGZippedHeapDumpOnOutOfMemoryError.java index a2a0154f0b375..5f4c1dd9b1ae7 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestGZippedHeapDumpOnOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestGZippedHeapDumpOnOutOfMemoryError.java @@ -63,7 +63,7 @@ public static void main(String[] args) throws Exception { } static void test(int level) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpGzipLevel=" + level, "-Xmx128M", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpOnOutOfMemoryError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpOnOutOfMemoryError.java index 9324adbb2e0b5..fb098bd27fec7 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpOnOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpOnOutOfMemoryError.java @@ -75,7 +75,7 @@ public static void main(String[] args) throws Exception { static void test(String type) throws Exception { String heapdumpFilename = type + ".hprof"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+HeapDumpOnOutOfMemoryError", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=" + heapdumpFilename, // Note: When trying to provoke a metaspace OOM we may generate a lot of classes. In debug VMs this // can cause considerable wait times since: diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpPath.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpPath.java index 0cc6dbc765f4c..167b94e1fe1a5 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpPath.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpPath.java @@ -54,7 +54,7 @@ static void testHeapDumpPath() throws Exception { String heapdumpPath = "dumps"; File dumpDirectory = new File(heapdumpPath); dumpDirectory.mkdir(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+HeapDumpOnOutOfMemoryError", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+HeapDumpOnOutOfMemoryError", "-Xmx64m", "-XX:HeapDumpPath=" + heapdumpPath, TestHeapDumpPath.class.getName(), "OOME"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java index 00475f8bdd793..53410c5379c43 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java @@ -41,7 +41,7 @@ public class TestOnError { public static void main(String[] args) throws Exception { String msg = "Test Succeeded"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=14", // trigger potential SEGV "-XX:OnError=echo " + msg, diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestOnOutOfMemoryError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestOnOutOfMemoryError.java index fe3c5c34f8041..f498caa2bff52 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestOnOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestOnOutOfMemoryError.java @@ -47,12 +47,12 @@ public static void main(String[] args) throws Exception { // else this is the main test String msg1 = "Test1 Succeeded"; String msg2 = "Test2 Succeeded"; - ProcessBuilder pb_single = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb_single = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:OnOutOfMemoryError=echo " + msg1, TestOnOutOfMemoryError.class.getName(), "throwOOME"); - ProcessBuilder pb_multiple = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb_multiple = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:OnOutOfMemoryError=echo " + msg1, "-XX:OnOutOfMemoryError=echo " + msg2, TestOnOutOfMemoryError.class.getName(), diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestSigInfoInHsErrFile.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestSigInfoInHsErrFile.java index a33a2b38ca1ce..e53757a29f382 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestSigInfoInHsErrFile.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestSigInfoInHsErrFile.java @@ -46,7 +46,7 @@ public class TestSigInfoInHsErrFile { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:-CreateCoredumpOnCrash", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java index f2930e5c5bd98..0b5cc88819fce 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java @@ -53,7 +53,7 @@ public static void main(String[] args) throws Exception { // Need to disable ShowRegistersOnAssert: that flag causes registers to be shown, which calls os::print_location, // which - as part of its checks - will iterate the threads list under a ThreadListHandle, changing the max nesting // counters and confusing this test. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+EnableThreadSMRStatistics", "-Xmx100M", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TimeoutInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/TimeoutInErrorHandlingTest.java index 0ff835a8c0d19..68613f8fd7145 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TimeoutInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TimeoutInErrorHandlingTest.java @@ -108,7 +108,7 @@ public static void main(String[] args) throws Exception { arguments.add("-XX:OnError=echo hi"); } arguments.add("-version"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); OutputAnalyzer output_detail = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/VeryEarlyAssertTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/VeryEarlyAssertTest.java index 348ce77c4dc38..2d26079fa0eaa 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/VeryEarlyAssertTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/VeryEarlyAssertTest.java @@ -50,7 +50,7 @@ public class VeryEarlyAssertTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-version"); Map env = pb.environment(); env.put("HOTSPOT_FATAL_ERROR_DURING_DYNAMIC_INITIALIZATION", "1"); diff --git a/test/hotspot/jtreg/runtime/GenerateOopMap/TestGenerateOopMapCrash.java b/test/hotspot/jtreg/runtime/GenerateOopMap/TestGenerateOopMapCrash.java index b556e0d0211c8..559c6145cb621 100644 --- a/test/hotspot/jtreg/runtime/GenerateOopMap/TestGenerateOopMapCrash.java +++ b/test/hotspot/jtreg/runtime/GenerateOopMap/TestGenerateOopMapCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ public class TestGenerateOopMapCrash { public static void main(String args[]) throws Exception { if (args.length == 0) { // Spawn new VM instance to execute test - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:-TieredCompilation", "-XX:CompileCommand=dontinline,if_icmpleIsLastOpcode.m*", "-Xmx64m", diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java b/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java index a5fe4b2a1481c..57df630627608 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ public class invocationC1Tests { public static void runTest(String whichTests, String classFileVersion) throws Throwable { System.out.println("\nC1 invocation tests, Tests: " + whichTests + ", class file version: " + classFileVersion); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xmx128M", "-Xcomp", "-XX:TieredStopAtLevel=1", "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", whichTests, "--classfile_version=" + classFileVersion); diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invocationOldCHATests.java b/test/hotspot/jtreg/runtime/InvocationTests/invocationOldCHATests.java index 2d4c2a38b2113..415cd105ee9ad 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invocationOldCHATests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invocationOldCHATests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,7 +67,7 @@ public class invocationOldCHATests { public static void runTest(String whichTests, String classFileVersion) throws Throwable { System.out.println("\nOld CHA invocation tests, Tests: " + whichTests + ", class file version: " + classFileVersion); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xmx128M", "-Xcomp", "-XX:+UnlockDiagnosticVMOptions", "-XX:-UseVtableBasedCHA", "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", whichTests, "--classfile_version=" + classFileVersion); diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java b/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java index 9d8a164637e9a..9b72899d13866 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,7 @@ public class invokeinterfaceTests { public static void runTest(String classFileVersion, String option) throws Throwable { System.out.println("\ninvokeinterface invocation tests, option: " + option + ", class file version: " + classFileVersion); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", option, + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xmx128M", option, "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", "invokeinterface.Generator", "--classfile_version=" + classFileVersion); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java b/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java index 564f83d822ec3..817e5da961664 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ public class invokespecialTests { public static void runTest(String classFileVersion, String option) throws Throwable { System.out.println("\ninvokespecial invocation tests, option: " + option + ", class file version: " + classFileVersion); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", option, + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xmx128M", option, "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", "invokespecial.Generator", "--classfile_version=" + classFileVersion); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java b/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java index 9cc19b6081cf1..5f998a6029eca 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ public class invokevirtualTests { public static void runTest(String classFileVersion, String option) throws Throwable { System.out.println("\ninvokevirtual invocation tests, option: " + option + ", class file version: " + classFileVersion); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", option, + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xmx128M", option, "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", "invokevirtual.Generator", "--classfile_version=" + classFileVersion); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/LoadClass/LoadClassNegative.java b/test/hotspot/jtreg/runtime/LoadClass/LoadClassNegative.java index 45360a251d6b1..94c2bde6e7677 100644 --- a/test/hotspot/jtreg/runtime/LoadClass/LoadClassNegative.java +++ b/test/hotspot/jtreg/runtime/LoadClass/LoadClassNegative.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class LoadClassNegative { public static void main(String args[]) throws Exception { String bootCP = "-Xbootclasspath/a:" + System.getProperty("test.src") + File.separator + "dummy.jar"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( bootCP, "TestForName"); diff --git a/test/hotspot/jtreg/runtime/LoadClass/LongBCP.java b/test/hotspot/jtreg/runtime/LoadClass/LongBCP.java index e14cb45df8730..aa4c559ff6465 100644 --- a/test/hotspot/jtreg/runtime/LoadClass/LongBCP.java +++ b/test/hotspot/jtreg/runtime/LoadClass/LongBCP.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ public static void main(String args[]) throws Exception { CompilerUtils.compile(sourceDir, destDir); String bootCP = "-Xbootclasspath/a:" + destDir.toString(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( bootCP, "Hello"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); @@ -82,7 +82,7 @@ public static void main(String args[]) throws Exception { CompilerUtils.compile(sourceDir, destDir); bootCP = "-Xbootclasspath/a:" + destDir.toString(); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( bootCP, "Hello"); output = new OutputAnalyzer(pb.start()); @@ -97,7 +97,7 @@ public static void main(String args[]) throws Exception { // run with long bootclasspath to hello.jar bootCP = "-Xbootclasspath/a:" + helloJar; - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( bootCP, "Hello"); output = new OutputAnalyzer(pb.start()); @@ -122,7 +122,7 @@ public static void main(String args[]) throws Exception { CompilerUtils.compile(sourceDir, destDir); bootCP = "-Xbootclasspath/a:" + destDir.toString(); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( bootCP, "Hello"); output = new OutputAnalyzer(pb.start()); @@ -139,7 +139,7 @@ public static void main(String args[]) throws Exception { Path jarPath = jarDir.resolve("hello.jar"); Files.copy(Paths.get(helloJar), jarPath); bootCP = "-Xbootclasspath/a:" + jarPath.toString(); - pb = ProcessTools.createJavaProcessBuilder(bootCP, "Hello"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(bootCP, "Hello"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Hello World") @@ -151,7 +151,7 @@ public static void main(String args[]) throws Exception { CompilerUtils.compile(sourceDir, destDir); bootCP = "-Xbootclasspath/a:" + destDir.toString(); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( bootCP, "Hello"); output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/LoadClass/TestResize.java b/test/hotspot/jtreg/runtime/LoadClass/TestResize.java index 56ae7e9b78d87..9177ede52dafd 100644 --- a/test/hotspot/jtreg/runtime/LoadClass/TestResize.java +++ b/test/hotspot/jtreg/runtime/LoadClass/TestResize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -131,10 +131,10 @@ public static void main(String[] args) throws Exception { // that will allow us to calculate the table's load factor. // -Xlog:safepoint+cleanup will print out cleanup details at safepoint // that will allow us to detect if the system dictionary resized. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintClassLoaderDataGraphAtExit", - "-Xlog:safepoint+cleanup,class+loader+data", - "TriggerResize", - String.valueOf(CLASSES_TO_LOAD)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintClassLoaderDataGraphAtExit", + "-Xlog:safepoint+cleanup,class+loader+data", + "TriggerResize", + String.valueOf(CLASSES_TO_LOAD)); analyzeOutputOn(pb); } } diff --git a/test/hotspot/jtreg/runtime/LocalLong/LocalLongTest.java b/test/hotspot/jtreg/runtime/LocalLong/LocalLongTest.java index 6a9adec6c0c6f..f48eddc51802a 100644 --- a/test/hotspot/jtreg/runtime/LocalLong/LocalLongTest.java +++ b/test/hotspot/jtreg/runtime/LocalLong/LocalLongTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,11 +37,11 @@ public class LocalLongTest { public static void main(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xint", - "--add-opens", "java.base/java.lang=ALL-UNNAMED", - "--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED", - "--add-exports", "java.base/jdk.internal.vm=ALL-UNNAMED", - "LocalLongHelper"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xint", + "--add-opens", "java.base/java.lang=ALL-UNNAMED", + "--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED", + "--add-exports", "java.base/jdk.internal.vm=ALL-UNNAMED", + "LocalLongHelper"); OutputAnalyzer o = new OutputAnalyzer(pb.start()); o.shouldHaveExitValue(0); }; diff --git a/test/hotspot/jtreg/runtime/LocalVariableTable/TestLVT.java b/test/hotspot/jtreg/runtime/LocalVariableTable/TestLVT.java index b1ed991b931b7..c84fef5c126d2 100644 --- a/test/hotspot/jtreg/runtime/LocalVariableTable/TestLVT.java +++ b/test/hotspot/jtreg/runtime/LocalVariableTable/TestLVT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,17 +41,17 @@ public class TestLVT { public static void main(String[] args) throws Exception { test(); // Test good LVT in this test - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("DuplicateLVT"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("DuplicateLVT"); new OutputAnalyzer(pb.start()) .shouldContain("Duplicated LocalVariableTable attribute entry for 'by' in class file DuplicateLVT") .shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("DuplicateLVTT"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("DuplicateLVTT"); new OutputAnalyzer(pb.start()) .shouldContain("Duplicated LocalVariableTypeTable attribute entry for 'list' in class file DuplicateLVTT") .shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("NotFoundLVTT"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("NotFoundLVTT"); new OutputAnalyzer(pb.start()) .shouldContain("LVTT entry for 'list' in class file NotFoundLVTT does not match any LVT entry") .shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java b/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java index ee1b10903a92f..d2d000f7c7d23 100644 --- a/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java +++ b/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -126,7 +126,7 @@ public static void test(GC gc, boolean doConcurrent) throws Throwable { Path gcLogPath = createGcLogPath("gc." + gc + "." + doConcurrent); System.err.println("test(" + gc + ", " + doConcurrent + ")" + " " + dateFormat.format(new Date())); // Run this Leak class with logging - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xlog:membername+table=trace,gc+verify=debug,gc:" + gcLogPath + ":time,utctime,uptime,pid,level,tags", "-XX:+UnlockExperimentalVMOptions", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java index eb8698295f92a..867257cba1271 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java +++ b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,7 +81,7 @@ public static void main(String... args) throws Exception { test++; report("Test " + test + ": normal command-line flag"); - pb = ProcessTools.createJavaProcessBuilder(flag, main, max); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(flag, main, max); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.reportDiagnosticSummary(); @@ -96,7 +96,7 @@ public static void main(String... args) throws Exception { for (String envVar : envVars) { report("Test " + test + ": " + envVar + " env-var"); - pb = ProcessTools.createJavaProcessBuilder(main, max); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(main, max); pb.environment().put(envVar, flag); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); @@ -112,7 +112,7 @@ public static void main(String... args) throws Exception { PrintWriter pw = new PrintWriter(rcFile); pw.println(flagRaw); pw.close(); - pb = ProcessTools.createJavaProcessBuilder(rcFileFlag, main, max); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(rcFileFlag, main, max); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); output.reportDiagnosticSummary(); diff --git a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java index 32aaa34db50b6..76c24eb1d25ad 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java +++ b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ public class MaxMetaspaceSizeTest { public static void main(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx1g", "-XX:MaxMetaspaceSize=4K", "-XX:+UseCompressedClassPointers", diff --git a/test/hotspot/jtreg/runtime/MinimalVM/CDS.java b/test/hotspot/jtreg/runtime/MinimalVM/CDS.java index a86504c451a0b..84e0f47e9b8bf 100644 --- a/test/hotspot/jtreg/runtime/MinimalVM/CDS.java +++ b/test/hotspot/jtreg/runtime/MinimalVM/CDS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,17 +38,17 @@ public class CDS { public static void main(String args[]) throws Exception { ProcessBuilder pb; - pb = ProcessTools.createJavaProcessBuilder("-minimal", "-Xshare:dump"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-minimal", "-Xshare:dump"); new OutputAnalyzer(pb.start()) .shouldContain("Shared spaces are not supported in this VM") .shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-minimal", "-Xshare:on"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-minimal", "-Xshare:on"); new OutputAnalyzer(pb.start()) .shouldContain("Shared spaces are not supported in this VM") .shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-minimal", "-Xshare:auto", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-minimal", "-Xshare:auto", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("Shared spaces are not supported in this VM") .shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/MinimalVM/CheckJNI.java b/test/hotspot/jtreg/runtime/MinimalVM/CheckJNI.java index 01c436c70868e..5a1ee499c60e9 100644 --- a/test/hotspot/jtreg/runtime/MinimalVM/CheckJNI.java +++ b/test/hotspot/jtreg/runtime/MinimalVM/CheckJNI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ public class CheckJNI { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-minimal", "-Xcheck:jni", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-minimal", "-Xcheck:jni", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("Minimal VM warning: JNI CHECKING is not supported in this VM") .shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/MinimalVM/Instrumentation.java b/test/hotspot/jtreg/runtime/MinimalVM/Instrumentation.java index 29fa15e607b26..c2b30fdd6a21d 100644 --- a/test/hotspot/jtreg/runtime/MinimalVM/Instrumentation.java +++ b/test/hotspot/jtreg/runtime/MinimalVM/Instrumentation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public class Instrumentation { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-minimal", "-javaagent:redefineagent.jar", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("Instrumentation agents are not supported in this VM") diff --git a/test/hotspot/jtreg/runtime/MinimalVM/JMX.java b/test/hotspot/jtreg/runtime/MinimalVM/JMX.java index b7afcb6a81d0f..53ef41902ed57 100644 --- a/test/hotspot/jtreg/runtime/MinimalVM/JMX.java +++ b/test/hotspot/jtreg/runtime/MinimalVM/JMX.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,12 +38,12 @@ public class JMX { public static void main(String args[]) throws Exception { ProcessBuilder pb; - pb = ProcessTools.createJavaProcessBuilder("-minimal", "-XX:+ManagementServer", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-minimal", "-XX:+ManagementServer", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("ManagementServer is not supported in this VM.") .shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-minimal", "-Dcom.sun.management ", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-minimal", "-Dcom.sun.management ", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("-Dcom.sun.management is not supported in this VM.") .shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/MinimalVM/JVMTI.java b/test/hotspot/jtreg/runtime/MinimalVM/JVMTI.java index 9a96e1bc481bc..1914aafcfd639 100644 --- a/test/hotspot/jtreg/runtime/MinimalVM/JVMTI.java +++ b/test/hotspot/jtreg/runtime/MinimalVM/JVMTI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ public class JVMTI { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-minimal", "-agentlib:jdwp=server=y,transport=dt_socket,address=5000,suspend=n", "-version"); diff --git a/test/hotspot/jtreg/runtime/MinimalVM/NMT.java b/test/hotspot/jtreg/runtime/MinimalVM/NMT.java index 740912be2317b..958ccc1758dce 100644 --- a/test/hotspot/jtreg/runtime/MinimalVM/NMT.java +++ b/test/hotspot/jtreg/runtime/MinimalVM/NMT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,17 +38,17 @@ public class NMT { public static void main(String args[]) throws Exception { ProcessBuilder pb; - pb = ProcessTools.createJavaProcessBuilder("-minimal", "-XX:NativeMemoryTracking=detail", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-minimal", "-XX:NativeMemoryTracking=detail", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("Native Memory Tracking is not supported in this VM") .shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-minimal", "-XX:NativeMemoryTracking=summary", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-minimal", "-XX:NativeMemoryTracking=summary", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("Native Memory Tracking is not supported in this VM") .shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-minimal", "-XX:NativeMemoryTracking=off", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-minimal", "-XX:NativeMemoryTracking=off", "-version"); new OutputAnalyzer(pb.start()) .shouldContain("Native Memory Tracking is not supported in this VM") .shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/Monitor/DeflationIntervalsTest.java b/test/hotspot/jtreg/runtime/Monitor/DeflationIntervalsTest.java index 8663989fd9e16..eb3942351964b 100644 --- a/test/hotspot/jtreg/runtime/Monitor/DeflationIntervalsTest.java +++ b/test/hotspot/jtreg/runtime/Monitor/DeflationIntervalsTest.java @@ -272,7 +272,7 @@ public static void test(Disabled disabled, Guaranteed guaranteed, Threshold thre opts.addAll(Arrays.asList(args)); opts.add("DeflationIntervalsTest$Test"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(opts); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(opts); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/Monitor/MonitorUsedDeflationThresholdTest.java b/test/hotspot/jtreg/runtime/Monitor/MonitorUsedDeflationThresholdTest.java index 5dd01e4262bcd..41b86e0e19eaf 100644 --- a/test/hotspot/jtreg/runtime/Monitor/MonitorUsedDeflationThresholdTest.java +++ b/test/hotspot/jtreg/runtime/Monitor/MonitorUsedDeflationThresholdTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,7 @@ public static void usage() { public static void main(String[] args) throws Exception { if (args.length == 0) { // Without args we invoke the test in a java sub-process: - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( // Test doesn't need much Java heap: "-Xmx100M", // AvgMonitorsPerThreadEstimate == 1 means we'll start with diff --git a/test/hotspot/jtreg/runtime/Monitor/SyncOnValueBasedClassTest.java b/test/hotspot/jtreg/runtime/Monitor/SyncOnValueBasedClassTest.java index 28bfd0f2bd4ee..3de4e89e3a0ef 100644 --- a/test/hotspot/jtreg/runtime/Monitor/SyncOnValueBasedClassTest.java +++ b/test/hotspot/jtreg/runtime/Monitor/SyncOnValueBasedClassTest.java @@ -84,14 +84,14 @@ private static void generateTests() { public static void main(String[] args) throws Exception { generateTests(); for (int i = 0; i < fatalTests.length; i++) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(fatalTests[i]); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(fatalTests[i]); OutputAnalyzer output = ProcessTools.executeProcess(pb); output.shouldContain("fatal error: Synchronizing on object"); output.shouldNotContain("synchronization on value based class did not fail"); output.shouldNotHaveExitValue(0); } for (int i = 0; i < logTests.length; i++) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(logTests[i]); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(logTests[i]); OutputAnalyzer output = ProcessTools.executeProcess(pb); output.shouldHaveExitValue(0); checkOutput(output); @@ -171,7 +171,7 @@ private static void virtualThreadTests() throws Exception { "", "SyncOnValueBasedClassTest$VTTest" }; // Fatal test vtTest[2] = "-XX:DiagnoseSyncOnValueBasedClasses=1"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vtTest); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(vtTest); OutputAnalyzer output = ProcessTools.executeProcess(pb); output.shouldContain("fatal error: Synchronizing on object"); output.shouldNotContain("synchronization on value based class did not fail"); @@ -179,7 +179,7 @@ private static void virtualThreadTests() throws Exception { // Log test vtTest[2] = "-XX:DiagnoseSyncOnValueBasedClasses=2"; - pb = ProcessTools.createJavaProcessBuilder(vtTest); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(vtTest); output = ProcessTools.executeProcess(pb); output.shouldHaveExitValue(0); output.shouldContain("Synchronizing on object"); diff --git a/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java b/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java index 71fdfd8aea59c..411676b1b6393 100644 --- a/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java +++ b/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java @@ -91,7 +91,7 @@ public static void main(String args[]) throws Exception { // If modules in the system image have been archived in CDS, they will not be // created again at run time. Explicitly use an external module to make sure // we have a runtime-defined ModuleEntry - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:NativeMemoryTracking=detail", "-XX:+PrintNMTStatistics", diff --git a/test/hotspot/jtreg/runtime/NMT/CommandLineDetail.java b/test/hotspot/jtreg/runtime/NMT/CommandLineDetail.java index 074a9b194eb68..57f2302db3078 100644 --- a/test/hotspot/jtreg/runtime/NMT/CommandLineDetail.java +++ b/test/hotspot/jtreg/runtime/NMT/CommandLineDetail.java @@ -37,7 +37,7 @@ public class CommandLineDetail { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:NativeMemoryTracking=detail", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/NMT/CommandLineEmptyArgument.java b/test/hotspot/jtreg/runtime/NMT/CommandLineEmptyArgument.java index 3d2ac8baf29b6..2a0620b7badaf 100644 --- a/test/hotspot/jtreg/runtime/NMT/CommandLineEmptyArgument.java +++ b/test/hotspot/jtreg/runtime/NMT/CommandLineEmptyArgument.java @@ -37,7 +37,7 @@ public class CommandLineEmptyArgument { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:NativeMemoryTracking="); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:NativeMemoryTracking="); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/NMT/CommandLineInvalidArgument.java b/test/hotspot/jtreg/runtime/NMT/CommandLineInvalidArgument.java index d82df08b8cc85..655fa140d35a6 100644 --- a/test/hotspot/jtreg/runtime/NMT/CommandLineInvalidArgument.java +++ b/test/hotspot/jtreg/runtime/NMT/CommandLineInvalidArgument.java @@ -37,7 +37,7 @@ public class CommandLineInvalidArgument { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:NativeMemoryTracking=apa"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:NativeMemoryTracking=apa"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/NMT/CommandLineSummary.java b/test/hotspot/jtreg/runtime/NMT/CommandLineSummary.java index c44be999d5fb8..02b37a40ef418 100644 --- a/test/hotspot/jtreg/runtime/NMT/CommandLineSummary.java +++ b/test/hotspot/jtreg/runtime/NMT/CommandLineSummary.java @@ -37,7 +37,7 @@ public class CommandLineSummary { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:NativeMemoryTracking=summary", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/NMT/CommandLineTurnOffNMT.java b/test/hotspot/jtreg/runtime/NMT/CommandLineTurnOffNMT.java index 710902a53cb76..199a2957f613b 100644 --- a/test/hotspot/jtreg/runtime/NMT/CommandLineTurnOffNMT.java +++ b/test/hotspot/jtreg/runtime/NMT/CommandLineTurnOffNMT.java @@ -37,7 +37,7 @@ public class CommandLineTurnOffNMT { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:NativeMemoryTracking=off", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/NMT/JcmdWithNMTDisabled.java b/test/hotspot/jtreg/runtime/NMT/JcmdWithNMTDisabled.java index 079d8d990523f..3b61a0be3830d 100644 --- a/test/hotspot/jtreg/runtime/NMT/JcmdWithNMTDisabled.java +++ b/test/hotspot/jtreg/runtime/NMT/JcmdWithNMTDisabled.java @@ -51,13 +51,13 @@ public static void main(String args[]) throws Exception { // First run without enabling NMT (not in debug, where NMT is by default on) if (!Platform.isDebugBuild()) { - pb = ProcessTools.createJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "JcmdWithNMTDisabled"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "JcmdWithNMTDisabled"); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); } // Then run with explicitly disabling NMT, should not be any difference - pb = ProcessTools.createJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "-XX:NativeMemoryTracking=off", "JcmdWithNMTDisabled"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Dtest.jdk=" + testjdkPath, "-XX:NativeMemoryTracking=off", "JcmdWithNMTDisabled"); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/NMT/MallocLimitTest.java b/test/hotspot/jtreg/runtime/NMT/MallocLimitTest.java index ba53d4d06a18e..a58ff861a2965 100644 --- a/test/hotspot/jtreg/runtime/NMT/MallocLimitTest.java +++ b/test/hotspot/jtreg/runtime/NMT/MallocLimitTest.java @@ -98,7 +98,7 @@ private static ProcessBuilder processBuilderWithSetting(String... extraSettings) args.add("-XX:NativeMemoryTracking=summary"); args.addAll(Arrays.asList(extraSettings)); args.add("-version"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); return pb; } diff --git a/test/hotspot/jtreg/runtime/NMT/NMTInitializationTest.java b/test/hotspot/jtreg/runtime/NMT/NMTInitializationTest.java index ef1e5cd834650..8cbacfb57014a 100644 --- a/test/hotspot/jtreg/runtime/NMT/NMTInitializationTest.java +++ b/test/hotspot/jtreg/runtime/NMT/NMTInitializationTest.java @@ -156,7 +156,7 @@ public static void main(String args[]) throws Exception { } vmArgs.add("-version"); - ProcessBuilder pb = ProcessTools.createTestJvm(vmArgs); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(vmArgs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (debug) { output.reportDiagnosticSummary(); diff --git a/test/hotspot/jtreg/runtime/NMT/NMTJavaHeapTest.java b/test/hotspot/jtreg/runtime/NMT/NMTJavaHeapTest.java index 603760379de48..f2abd3ac0ad8d 100644 --- a/test/hotspot/jtreg/runtime/NMT/NMTJavaHeapTest.java +++ b/test/hotspot/jtreg/runtime/NMT/NMTJavaHeapTest.java @@ -37,7 +37,7 @@ public class NMTJavaHeapTest { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintNMTStatistics", "-XX:NativeMemoryTracking=summary", diff --git a/test/hotspot/jtreg/runtime/NMT/NMTWithCDS.java b/test/hotspot/jtreg/runtime/NMT/NMTWithCDS.java index 994705e1e77e3..226626acb3461 100644 --- a/test/hotspot/jtreg/runtime/NMT/NMTWithCDS.java +++ b/test/hotspot/jtreg/runtime/NMT/NMTWithCDS.java @@ -38,14 +38,14 @@ public class NMTWithCDS { public static void main(String[] args) throws Exception { ProcessBuilder pb; - pb = ProcessTools.createTestJvm( + pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./NMTWithCDS.jsa", "-Xshare:dump", "-Xlog:cds"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); try { output.shouldContain("Loading classes to share"); output.shouldHaveExitValue(0); - pb = ProcessTools.createTestJvm( + pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:NativeMemoryTracking=detail", "-XX:SharedArchiveFile=./NMTWithCDS.jsa", "-Xshare:on", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("sharing"); diff --git a/test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java b/test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java index 3263cc402331e..389e6a25de560 100644 --- a/test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java +++ b/test/hotspot/jtreg/runtime/NMT/PrintNMTStatistics.java @@ -37,7 +37,7 @@ public class PrintNMTStatistics { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintNMTStatistics", "-XX:NativeMemoryTracking=detail", @@ -55,7 +55,7 @@ public static void main(String args[]) throws Exception { // Make sure memory reserved for Module processing is recorded. output_detail.shouldContain(" Module (reserved="); - ProcessBuilder pb1 = ProcessTools.createTestJvm( + ProcessBuilder pb1 = ProcessTools.createTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintNMTStatistics", "-XX:NativeMemoryTracking=summary", diff --git a/test/hotspot/jtreg/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java b/test/hotspot/jtreg/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java index 70222701b06ce..897893c47eaab 100644 --- a/test/hotspot/jtreg/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java +++ b/test/hotspot/jtreg/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java @@ -37,7 +37,7 @@ public class PrintNMTStatisticsWithNMTDisabled { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintNMTStatistics", "-XX:NativeMemoryTracking=off", "-version"); diff --git a/test/hotspot/jtreg/runtime/PerfMemDestroy/PerfMemDestroy.java b/test/hotspot/jtreg/runtime/PerfMemDestroy/PerfMemDestroy.java index 2040c755576e8..1ee2f604df6da 100644 --- a/test/hotspot/jtreg/runtime/PerfMemDestroy/PerfMemDestroy.java +++ b/test/hotspot/jtreg/runtime/PerfMemDestroy/PerfMemDestroy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ public class PerfMemDestroy { public static void main(String args[]) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PerfAllowAtExitRegistration", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PerfAllowAtExitRegistration", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/PrintStringTableStats/PrintStringTableStatsTest.java b/test/hotspot/jtreg/runtime/PrintStringTableStats/PrintStringTableStatsTest.java index 1425e3e6eb103..4dfde2f1d0b03 100644 --- a/test/hotspot/jtreg/runtime/PrintStringTableStats/PrintStringTableStatsTest.java +++ b/test/hotspot/jtreg/runtime/PrintStringTableStats/PrintStringTableStatsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -34,7 +34,7 @@ public class PrintStringTableStatsTest { public static void main(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintStringTableStatistics", "--version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/ReservedStack/ReservedStackTest.java b/test/hotspot/jtreg/runtime/ReservedStack/ReservedStackTest.java index 36f74d01b54f8..e75e66438093b 100644 --- a/test/hotspot/jtreg/runtime/ReservedStack/ReservedStackTest.java +++ b/test/hotspot/jtreg/runtime/ReservedStack/ReservedStackTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -254,7 +254,7 @@ private static void initIsSupportedPlatform() throws Exception { // In order to dynamicaly determine if the platform supports the reserved // stack area, run with -XX:StackReservedPages=1 and see if we get the // expected warning message for platforms that don't support it. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:StackReservedPages=1", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:StackReservedPages=1", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println("StackReservedPages=1 log: [" + output.getOutput() + "]"); if (output.getExitValue() != 0) { diff --git a/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java b/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java index 33de13f6c451c..a2c3f944db86b 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java +++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java @@ -63,7 +63,7 @@ public static void main(String[] args) throws Exception { } public static void testWith(int delay, boolean shouldPass) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+AbortVMOnVMOperationTimeout", "-XX:AbortVMOnVMOperationTimeoutDelay=" + delay, diff --git a/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java b/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java index 55f1e30d5efdf..c85dd6573381a 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java +++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -41,7 +41,7 @@ public class TestAbortVMOnSafepointTimeout { public static void testThreadKilledOnSafepointTimeout() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", @@ -61,7 +61,7 @@ public static void testThreadKilledOnSafepointTimeout() throws Exception { } public static void testGracePeriodAppliedBeforeVmAbort() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", diff --git a/test/hotspot/jtreg/runtime/StackTrace/LargeClassTest.java b/test/hotspot/jtreg/runtime/StackTrace/LargeClassTest.java index 5ef84f9ca953f..d82b4b1f19541 100644 --- a/test/hotspot/jtreg/runtime/StackTrace/LargeClassTest.java +++ b/test/hotspot/jtreg/runtime/StackTrace/LargeClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -45,7 +45,7 @@ public class LargeClassTest implements Opcodes { public static void main(String... args) throws Exception { writeClassFile(); - ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", "Large"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-cp", ".", "Large"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java b/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java index b4e5e6b514b77..a10f41932348f 100644 --- a/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java +++ b/test/hotspot/jtreg/runtime/Thread/TestAlwaysPreTouchStacks.java @@ -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, 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 @@ -90,7 +90,7 @@ public static void main(String[] args) throws Exception { } else { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:+AlwaysPreTouchStacks", diff --git a/test/hotspot/jtreg/runtime/Thread/TestBreakSignalThreadDump.java b/test/hotspot/jtreg/runtime/Thread/TestBreakSignalThreadDump.java index 1ad74dbec0f7c..aecf3fdb5a66b 100644 --- a/test/hotspot/jtreg/runtime/Thread/TestBreakSignalThreadDump.java +++ b/test/hotspot/jtreg/runtime/Thread/TestBreakSignalThreadDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -67,7 +67,7 @@ public static void main(String[] argv) throws Exception { public static void main(String[] argv) throws Exception { String main = "TestBreakSignalThreadDump$TestProcess"; - ProcessBuilder pb = ProcessTools.createTestJvm("-Djava.library.path=" + Utils.TEST_NATIVE_PATH, main); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-Djava.library.path=" + Utils.TEST_NATIVE_PATH, main); if (argv.length > 0 && argv[0].equals("load_libjsig")) { prepend_jsig_lib(pb.environment()); diff --git a/test/hotspot/jtreg/runtime/Thread/TooSmallStackSize.java b/test/hotspot/jtreg/runtime/Thread/TooSmallStackSize.java index 88099b44ab2d5..09db906b1516b 100644 --- a/test/hotspot/jtreg/runtime/Thread/TooSmallStackSize.java +++ b/test/hotspot/jtreg/runtime/Thread/TooSmallStackSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -94,14 +94,14 @@ static String getMinStackAllowed(String testOutput) { static ProcessBuilder createProcessWithOptions(String stackOption, String stackSize) throws Exception { if (testShadowSize == null) { - return ProcessTools.createJavaProcessBuilder( + return ProcessTools.createLimitedTestJavaProcessBuilder( stackOption + stackSize, // Uncomment the following to get log output // that shows actual thread creation sizes. // "-Xlog:os+thread", "-version"); } else { - return ProcessTools.createJavaProcessBuilder( + return ProcessTools.createLimitedTestJavaProcessBuilder( stackOption + stackSize, // Uncomment the following to get log output // that shows actual thread creation sizes. diff --git a/test/hotspot/jtreg/runtime/Throwable/StackTraceLogging.java b/test/hotspot/jtreg/runtime/Throwable/StackTraceLogging.java index 1482037b28f29..ef63dc942f194 100644 --- a/test/hotspot/jtreg/runtime/Throwable/StackTraceLogging.java +++ b/test/hotspot/jtreg/runtime/Throwable/StackTraceLogging.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,11 +51,11 @@ static void analyzeOutputOn(ProcessBuilder pb) throws Exception { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:stacktrace=info", - "-XX:MaxJavaStackTraceDepth=1024", - "--add-opens", - "java.base/java.lang=ALL-UNNAMED", - "TestThrowable"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:stacktrace=info", + "-XX:MaxJavaStackTraceDepth=1024", + "--add-opens", + "java.base/java.lang=ALL-UNNAMED", + "TestThrowable"); analyzeOutputOn(pb); } } diff --git a/test/hotspot/jtreg/runtime/Throwable/TestCatchThrowableOOM.java b/test/hotspot/jtreg/runtime/Throwable/TestCatchThrowableOOM.java index 36fedc0bd2dda..b7c261afbd012 100644 --- a/test/hotspot/jtreg/runtime/Throwable/TestCatchThrowableOOM.java +++ b/test/hotspot/jtreg/runtime/Throwable/TestCatchThrowableOOM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,10 +43,10 @@ public class TestCatchThrowableOOM { }; public static void main(String[] args) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx64m", - "-Xlog:exceptions=trace", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xmx64m", + "-Xlog:exceptions=trace", - "TestCatchThrowableOOM$OOM"); + "TestCatchThrowableOOM$OOM"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); for (String msg : expected) { diff --git a/test/hotspot/jtreg/runtime/Throwable/TestMaxJavaStackTraceDepth.java b/test/hotspot/jtreg/runtime/Throwable/TestMaxJavaStackTraceDepth.java index 92e5771860889..95f29ee2eb6bd 100644 --- a/test/hotspot/jtreg/runtime/Throwable/TestMaxJavaStackTraceDepth.java +++ b/test/hotspot/jtreg/runtime/Throwable/TestMaxJavaStackTraceDepth.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -79,11 +79,11 @@ public static void main(String args[]) throws Exception { int[] depths = {0, 20, 1024}; for (int d : depths) { System.out.println("running test with -XX:MaxJavaStackTraceDepth=" + d); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:stacktrace=info", - "-XX:MaxJavaStackTraceDepth=" + d, - "--add-opens", - "java.base/java.lang=ALL-UNNAMED", - "TestMaxJavaStackTraceDepth"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:stacktrace=info", + "-XX:MaxJavaStackTraceDepth=" + d, + "--add-opens", + "java.base/java.lang=ALL-UNNAMED", + "TestMaxJavaStackTraceDepth"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (d == 0) { // Should get all the elements in stack trace diff --git a/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java b/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java index 2f9ae3fddffa3..788b96fb22ef7 100644 --- a/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java +++ b/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ public class RangeCheck { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-Xmx128m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", diff --git a/test/hotspot/jtreg/runtime/XCheckJniJsig/XCheckJSig.java b/test/hotspot/jtreg/runtime/XCheckJniJsig/XCheckJSig.java index 03d5d885e45aa..aae401df96387 100644 --- a/test/hotspot/jtreg/runtime/XCheckJniJsig/XCheckJSig.java +++ b/test/hotspot/jtreg/runtime/XCheckJniJsig/XCheckJSig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -61,14 +61,14 @@ public static void main(String args[]) throws Throwable { throw new RuntimeException("File libjsig not found, path: " + libjsig); } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xcheck:jni", "-version"); Map env = pb.environment(); env.put(env_var, libjsig); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("libjsig is activated"); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-verbose:jni", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xcheck:jni", "-verbose:jni", "-version"); env = pb.environment(); env.put(env_var, libjsig); output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/cds/MaxMetaspaceSize.java b/test/hotspot/jtreg/runtime/cds/MaxMetaspaceSize.java index b1aab5d3371d7..08665415764e6 100644 --- a/test/hotspot/jtreg/runtime/cds/MaxMetaspaceSize.java +++ b/test/hotspot/jtreg/runtime/cds/MaxMetaspaceSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ public static void main(String[] args) throws Exception { } String msg = "OutOfMemoryError: ((Metaspace)|(Compressed class space))"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(processArgs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(processArgs); CDSTestUtils.executeAndLog(pb, "dump").shouldMatch(msg).shouldHaveExitValue(1); } } diff --git a/test/hotspot/jtreg/runtime/cds/SharedStrings.java b/test/hotspot/jtreg/runtime/cds/SharedStrings.java index bda830401f05a..33a041bb2985b 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedStrings.java +++ b/test/hotspot/jtreg/runtime/cds/SharedStrings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ public static void main(String[] args) throws Exception { // This also serves as a reference on how to use this feature, // hence the command lines are spelled out instead of using the // test utils methods. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./SharedStrings.jsa", "-Xlog:cds,cds+hashtables", @@ -56,7 +56,7 @@ public static void main(String[] args) throws Exception { CDSTestUtils.checkDump(out, "Shared string table stats"); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./SharedStrings.jsa", // needed for access to white box test API diff --git a/test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java b/test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java index 1a13e30f33a80..183b1c3afcf20 100644 --- a/test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java +++ b/test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java @@ -49,7 +49,7 @@ public static void main(String[] args) throws Exception { } } // else this is the main test - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError", "-XX:-CreateCoredumpOnCrash", "-Xmx128m", "-Xshare:on", TestCDSVMCrash.class.getName(),"throwOOME"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); // executeAndLog should throw an exception in the VM crashed diff --git a/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java b/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java index 7b4a03850b8f5..8e33bf0bb0c17 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java @@ -163,7 +163,7 @@ private static void testExtraCase(String jarFile, String[] classList) throws Exc } String[] args = new String[] { "-cp", jarFile, "-XX:ArchiveClassesAtExit=" + dynName, "-XX:DumpLoadedClassList=" + dumpedListName, "Hello"}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer output = TestCommon.executeAndLog(pb, "combo"); output.shouldHaveExitValue(0) .shouldContain(HELLO_WORLD); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/FillerObjectLoadTest.java b/test/hotspot/jtreg/runtime/cds/appcds/FillerObjectLoadTest.java index 97511db815f50..d53120fc1b18a 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/FillerObjectLoadTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/FillerObjectLoadTest.java @@ -35,14 +35,14 @@ public class FillerObjectLoadTest { public static void main(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-XX:-UseCompressedClassPointers", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseEpsilonGC", "-Xshare:dump", "-XX:SharedArchiveFile=" + TestCommon.getNewArchiveName()); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); analyzer.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+IgnoreUnrecognizedVMOptions", "-XX:-UseCompressedClassPointers", "-XX:TLABSize=2048", "-Xshare:dump", "-XX:SharedArchiveFile=" + TestCommon.getNewArchiveName()); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java b/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java index 317d676704635..007d9fb4c2c7a 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -300,7 +300,7 @@ public static OutputAnalyzer createArchive(CDSOptions opts) } } - ProcessBuilder pb = ProcessTools.createTestJvm(cmd); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(cmd); if (opts.appJarDir != null) { pb.directory(new File(opts.appJarDir)); } @@ -447,7 +447,7 @@ public static OutputAnalyzer runWithArchive(CDSOptions opts) } } - ProcessBuilder pb = ProcessTools.createTestJvm(cmd); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(cmd); if (opts.appJarDir != null) { pb.directory(new File(opts.appJarDir)); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestDumpClassListSource.java b/test/hotspot/jtreg/runtime/cds/appcds/TestDumpClassListSource.java index 647e44bc45576..17634e9a31ea5 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestDumpClassListSource.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestDumpClassListSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -112,7 +112,7 @@ public static void main(String[] args) throws Exception { "-cp", jarFile, mainInvokeClass}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(launchArgs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); OutputAnalyzer output = TestCommon.executeAndLog(pb, "invoke-class"); checkFileExistence("Archive", fileArchive); @@ -137,7 +137,7 @@ public static void main(String[] args) throws Exception { jarFile, mainCutomClass, "1"}; - pb = ProcessTools.createJavaProcessBuilder(launchArgs); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); output = TestCommon.executeAndLog(pb, "custom-nosource"); checkFileExistence("Archive", fileArchive); @@ -163,7 +163,7 @@ public static void main(String[] args) throws Exception { jarFile, mainCutomClass, "2"}; - pb = ProcessTools.createJavaProcessBuilder(launchArgs); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); output = TestCommon.executeAndLog(pb, "custom-nosource"); checkFileExistence("Archive", fileArchive); @@ -184,7 +184,7 @@ public static void main(String[] args) throws Exception { jarFile, mainCutomClass, "3"}; - pb = ProcessTools.createJavaProcessBuilder(launchArgs); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); output = TestCommon.executeAndLog(pb, "custom-dump-classlist"); checkFileExistence("ClassList", fileList); @@ -205,7 +205,7 @@ public static void main(String[] args) throws Exception { jarFile, mainCutomClass, "3"}; - pb = ProcessTools.createJavaProcessBuilder(launchArgs); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); output = TestCommon.executeAndLog(pb, "custom-dump"); checkFileExistence("Archive", archiveFile); @@ -225,7 +225,7 @@ public static void main(String[] args) throws Exception { jarFile, mainCutomClass, "3"}; - pb = ProcessTools.createJavaProcessBuilder(launchArgs); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); output = TestCommon.executeAndLog(pb, "custom-share"); checkFileExistence("ClassList", newFile); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/VerifyWithDefaultArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/VerifyWithDefaultArchive.java index aa65bb38b1cfe..6835adf33f3d5 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/VerifyWithDefaultArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/VerifyWithDefaultArchive.java @@ -37,7 +37,7 @@ public class VerifyWithDefaultArchive { public static void main(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:cds", "-XX:+VerifySharedSpaces", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:cds", "-XX:+VerifySharedSpaces", "-version"); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldNotContain("relocation bitmap CRC error"); out.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java index f35ffbf5d0042..108002246db64 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -261,7 +261,7 @@ private static Result execProcess(String mode, String jarDir, String[] cmdLine) if (!executedIn_run) { throw new Exception("Test error: dynamic archive tests must be executed via DynamicArchiveTestBase.run()"); } - ProcessBuilder pb = ProcessTools.createTestJvm(cmdLine); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(cmdLine); if (jarDir != null) { pb.directory(new File(jarDir)); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdasInTwoArchives.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdasInTwoArchives.java index 8c66225b95faa..0c9c2514e403b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdasInTwoArchives.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdasInTwoArchives.java @@ -93,7 +93,7 @@ static void test() throws Exception { "-Xlog:cds", "-Xlog:cds+lambda", "-cp", appJar, mainClass}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(launchArgs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(launchArgs); OutputAnalyzer oa = TestCommon.executeAndLog(pb, "lambda-classes"); oa.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jcmd/JCmdTestDynamicDump.java b/test/hotspot/jtreg/runtime/cds/appcds/jcmd/JCmdTestDynamicDump.java index 65e8b090dda0e..228948f3ebd4d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jcmd/JCmdTestDynamicDump.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jcmd/JCmdTestDynamicDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -133,7 +133,7 @@ static void test() throws Exception { private static void dumpStaticArchive(String archiveFile) throws Exception { String javapath = JDKToolFinder.getJDKTool("java"); String cmd[] = {javapath, "-Xshare:dump", "-XX:SharedArchiveFile=" + archiveFile}; - // Do not use ProcessTools.createTestJvm(cmd) here, it copies jtreg env. + // Do not use ProcessTools.createTestJavaProcessBuilder(cmd) here, it copies jtreg env. ProcessBuilder pb = new ProcessBuilder(cmd); CDSTestUtils.executeAndLog(pb, "dump") .shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ResolvedReferencesNotNullTest.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ResolvedReferencesNotNullTest.java index 005a1f78e0ba4..bdd5ad9ec7ec0 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ResolvedReferencesNotNullTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ResolvedReferencesNotNullTest.java @@ -42,14 +42,14 @@ public static void main(String[] args) throws Exception { String appJar = TestCommon.getTestJar(SharedStringsUtils.TEST_JAR_NAME_FULL); String whiteboxParam = SharedStringsUtils.getWbParam(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-cp", - appJar, - whiteboxParam, - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "ResolvedReferencesWb", - "false" // ResolvedReferencesTestApp is not archived - ); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-cp", + appJar, + whiteboxParam, + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "ResolvedReferencesWb", + "false" // ResolvedReferencesTestApp is not archived + ); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/classFileParserBug/Bad_NCDFE_Msg.java b/test/hotspot/jtreg/runtime/classFileParserBug/Bad_NCDFE_Msg.java index 215887f7bb350..1baf5bdc8a8b2 100644 --- a/test/hotspot/jtreg/runtime/classFileParserBug/Bad_NCDFE_Msg.java +++ b/test/hotspot/jtreg/runtime/classFileParserBug/Bad_NCDFE_Msg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ public class Bad_NCDFE_Msg { public static void main(String args[]) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-cp", System.getProperty("test.classes") + File.separator + "pkg", "C"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("java.lang.NoClassDefFoundError: C (wrong name: pkg/C"); diff --git a/test/hotspot/jtreg/runtime/classFileParserBug/ClassFileParserBug.java b/test/hotspot/jtreg/runtime/classFileParserBug/ClassFileParserBug.java index 31dde4d3adf6c..bac36378d2e6e 100644 --- a/test/hotspot/jtreg/runtime/classFileParserBug/ClassFileParserBug.java +++ b/test/hotspot/jtreg/runtime/classFileParserBug/ClassFileParserBug.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public class ClassFileParserBug { public static void main(String args[]) throws Throwable { System.out.println("Regression test for bug 8040018"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("LambdaMath"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("LambdaMath"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("java.lang.ClassFormatError: Bad length on BootstrapMethods"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/classFileParserBug/TestBadPackageWithInterface.java b/test/hotspot/jtreg/runtime/classFileParserBug/TestBadPackageWithInterface.java index f7028990b0547..35abee5ce3ee4 100644 --- a/test/hotspot/jtreg/runtime/classFileParserBug/TestBadPackageWithInterface.java +++ b/test/hotspot/jtreg/runtime/classFileParserBug/TestBadPackageWithInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ public class TestBadPackageWithInterface { public static void main(String args[]) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-cp", System.getProperty("test.classes"), "-XX:+UnlockDiagnosticVMOptions", "-XX:+VerifyBeforeExit", MyLoader.class.getName()); diff --git a/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java b/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java index ea91f54da83c2..53c85d53c44a5 100644 --- a/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java +++ b/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ public static void main(String args[]) throws Throwable { // ======= execute test case #1 // Expect a lack of main method, this implies that the class loaded correctly // with an empty bootstrap_methods and did not generate a ClassFormatError. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Duser.language=en", "-Duser.country=US", className); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("java.lang.ClassFormatError"); @@ -65,7 +65,7 @@ public static void main(String args[]) throws Throwable { // ======= execute test case #2 // Expect a lack of main method, this implies that the class loaded correctly // with an empty bootstrap_methods and did not generate ClassFormatError. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Duser.language=en", "-Duser.country=US", className); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("java.lang.ClassFormatError"); diff --git a/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java b/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java index 4ae0eaa0df3b4..a07c98caa6638 100644 --- a/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java +++ b/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -42,7 +42,7 @@ public class BadBSMUseTest { public static void main(String args[]) throws Throwable { // 1. Test a CONSTANT_Dynamic_info's bootstrap_method_attr_index points // at a BSM meant for a CONSTANT_InvokeDynamic_info - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("CondyUsesIndyBSM"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("CondyUsesIndyBSM"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldContain("In Indybsm target CallSite method foo"); oa.shouldContain("BootstrapMethodError: bootstrap method initialization exception"); @@ -50,7 +50,7 @@ public static void main(String args[]) throws Throwable { // 2. Test a CONSTANT_InvokeDynamic_info's bootstrap_method_attr_index points // at a BSM meant for a CONSTANT_Dynamic_info - pb = ProcessTools.createJavaProcessBuilder("IndyUsesCondyBSM"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("IndyUsesCondyBSM"); oa = new OutputAnalyzer(pb.start()); oa.shouldContain("In Condybsm"); oa.shouldContain("BootstrapMethodError: bootstrap method initialization exception"); diff --git a/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java b/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java index ef26a6bf67466..22cfb727eb8b8 100644 --- a/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java +++ b/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -42,16 +42,16 @@ public class CondyLDCTest { public static void main(String args[]) throws Throwable { // 1. Test a ldc_w instruction can be used with condy's which generate // loadable constants of the following types: byte, char, short, float, integer, boolean. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xverify:all", - "CondyUseLDC_W"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xverify:all", + "CondyUseLDC_W"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldNotContain("VerifyError"); oa.shouldHaveExitValue(0); // 2. Test ldc2_w of a condy which returns a dynamically generated // float constant, generates a VerifyError. - pb = ProcessTools.createJavaProcessBuilder("-Xverify:all", - "CondyBadLDC2_W"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xverify:all", + "CondyBadLDC2_W"); oa = new OutputAnalyzer(pb.start()); oa.shouldContain("java.lang.VerifyError: Illegal type at constant pool entry"); oa.shouldContain("CondyBadLDC2_W.F()F @0: ldc2_w"); @@ -59,8 +59,8 @@ public static void main(String args[]) throws Throwable { // 3. Test a ldc of a condy which returns a dynamically generated // double constant, generates a VerifyError. - pb = ProcessTools.createJavaProcessBuilder("-Xverify:all", - "CondyBadLDC"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xverify:all", + "CondyBadLDC"); oa = new OutputAnalyzer(pb.start()); oa.shouldContain("java.lang.VerifyError: Illegal type at constant pool entry"); oa.shouldContain("CondyBadLDC.D()D @0: ldc"); diff --git a/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java b/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java index 2de9e7286668d..6e810d0d3b88c 100644 --- a/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java +++ b/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -38,8 +38,8 @@ public class CondyNewInvokeSpecialTest { public static void main(String args[]) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xverify:all", - "CondyNewInvokeSpecial"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xverify:all", + "CondyNewInvokeSpecial"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldContain("In CondyNewInvokeSpecial method"); oa.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java b/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java index cb4b6960cf967..877a805c445fd 100644 --- a/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java +++ b/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ public class TestEscapeCondy { public static void main(String args[]) throws Throwable { // 1. Test escape analysis of a method that contains // a ldc instruction of a condy whose return type is an array of boolean - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:CompileCommand=dontinline,runtime.condy.TestEscapeThroughInvokeWithCondy::create", "runtime.condy.TestEscapeThroughInvokeWithCondy"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java b/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java index c8b8aeba22e4d..2b572edb66fec 100644 --- a/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java +++ b/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ public class TestInitException { public static void main(java.lang.String[] unused) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("Example"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("Example"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); // First call stack trace // shouldMatch is used to workaround CODETOOLS-7902686 diff --git a/test/hotspot/jtreg/runtime/contended/Options.java b/test/hotspot/jtreg/runtime/contended/Options.java index ea7261c229a44..f646b152921de 100644 --- a/test/hotspot/jtreg/runtime/contended/Options.java +++ b/test/hotspot/jtreg/runtime/contended/Options.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -40,59 +40,59 @@ public static void main(String[] args) throws Exception { ProcessBuilder pb; OutputAnalyzer output; - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=-128", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=-128", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("ContendedPaddingWidth"); output.shouldContain("outside the allowed range"); output.shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=-8", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=-8", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("ContendedPaddingWidth"); output.shouldContain("outside the allowed range"); output.shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=-1", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=-1", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("ContendedPaddingWidth"); output.shouldContain("outside the allowed range"); output.shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=0", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=0", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=1", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=1", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("ContendedPaddingWidth"); output.shouldContain("must be a multiple of 8"); output.shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=8", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8184", "-version"); // 8192-8 = 8184 + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=8184", "-version"); // 8192-8 = 8184 output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8191", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=8191", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("ContendedPaddingWidth"); output.shouldContain("must be a multiple of 8"); output.shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8192", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=8192", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8193", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=8193", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("ContendedPaddingWidth"); output.shouldContain("outside the allowed range"); output.shouldHaveExitValue(1); - pb = ProcessTools.createJavaProcessBuilder("-XX:ContendedPaddingWidth=8200", "-version"); // 8192+8 = 8200 + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:ContendedPaddingWidth=8200", "-version"); // 8192+8 = 8200 output = new OutputAnalyzer(pb.start()); output.shouldContain("ContendedPaddingWidth"); output.shouldContain("outside the allowed range"); diff --git a/test/hotspot/jtreg/runtime/duplAttributes/DuplAttributesTest.java b/test/hotspot/jtreg/runtime/duplAttributes/DuplAttributesTest.java index aebc9d0a89931..4116c91705f33 100644 --- a/test/hotspot/jtreg/runtime/duplAttributes/DuplAttributesTest.java +++ b/test/hotspot/jtreg/runtime/duplAttributes/DuplAttributesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public class DuplAttributesTest { static final String testsrc = System.getProperty("test.src"); public static void runTest(String test, String result) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(test); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(test); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("java.lang.ClassFormatError: Multiple " + result); output.shouldNotHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/execstack/Testexecstack.java b/test/hotspot/jtreg/runtime/execstack/Testexecstack.java index 7af23d7a41ee9..3c690d54a2338 100644 --- a/test/hotspot/jtreg/runtime/execstack/Testexecstack.java +++ b/test/hotspot/jtreg/runtime/execstack/Testexecstack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ public static void main(String[] args) throws Throwable { // Create a new java process for the Test Java/JNI test without // an executeable stack - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Djava.library.path=" + libpath + ":.", "Test", "test-rw"); // Start the process and check the output @@ -56,7 +56,7 @@ public static void main(String[] args) throws Throwable { // Create a new java process for the Test Java/JNI test with an // executable stack - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Djava.library.path=" + libpath + ":.", "Test", "test-rwx"); // Start the process and check the output @@ -65,7 +65,7 @@ public static void main(String[] args) throws Throwable { // Create a new java process for the TestMT Java/JNI test with an // executable stack - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Djava.library.path=" + libpath + ":.", "TestMT", "test-rwx"); // Start the process and check the output diff --git a/test/hotspot/jtreg/runtime/getSysPackage/GetPackageXbootclasspath.java b/test/hotspot/jtreg/runtime/getSysPackage/GetPackageXbootclasspath.java index db4d26f801be8..ae1f86cc7c155 100644 --- a/test/hotspot/jtreg/runtime/getSysPackage/GetPackageXbootclasspath.java +++ b/test/hotspot/jtreg/runtime/getSysPackage/GetPackageXbootclasspath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ public static void main(String args[]) throws Exception { ClassFileInstaller.writeClassToDisk("P/Test", InMemoryJavaCompiler.compile("P.Test", Test_src), test_classes); - new OutputAnalyzer(ProcessTools.createJavaProcessBuilder( + new OutputAnalyzer(ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:" + test_classes, "P.Test") .start()).shouldContain("Test Passed") .shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/getSysPackage/GetSysPkgTest.java b/test/hotspot/jtreg/runtime/getSysPackage/GetSysPkgTest.java index a6e5d40db3d4f..0cd3e371d8b31 100644 --- a/test/hotspot/jtreg/runtime/getSysPackage/GetSysPkgTest.java +++ b/test/hotspot/jtreg/runtime/getSysPackage/GetSysPkgTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,7 +101,7 @@ public static void main(String args[]) throws Throwable { InMemoryJavaCompiler.compile("GetSysPkg_package.GetSysClass", source); ClassFileInstaller.writeClassToDisk("GetSysPkg_package/GetSysClass", klassbuf); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:bl_dir", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xbootclasspath/a:bl_dir", "--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED", "-cp", "." + File.pathSeparator + System.getProperty("test.classes"), "GetSysPkgTest", "do_tests"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/handshake/HandshakeTimeoutTest.java b/test/hotspot/jtreg/runtime/handshake/HandshakeTimeoutTest.java index b92ff56da9a27..a1a5ff68c3133 100644 --- a/test/hotspot/jtreg/runtime/handshake/HandshakeTimeoutTest.java +++ b/test/hotspot/jtreg/runtime/handshake/HandshakeTimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class HandshakeTimeoutTest { public static void main(String[] args) throws Exception { ProcessBuilder pb = - ProcessTools.createTestJvm( + ProcessTools.createTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", diff --git a/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java b/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java index b8e03763e2b70..5480b495a2d42 100644 --- a/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java +++ b/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ public static void main(String[] args) throws Exception { commands.add("-XX:CICompilerCount=2"); commands.addAll(Arrays.asList(args)); commands.add("HandshakeTransitionTest$Test"); - ProcessBuilder pb = ProcessTools.createTestJvm(commands); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(commands); OutputAnalyzer output = ProcessTools.executeProcess(pb); output.reportDiagnosticSummary(); diff --git a/test/hotspot/jtreg/runtime/handshake/SystemMembarHandshakeTransitionTest.java b/test/hotspot/jtreg/runtime/handshake/SystemMembarHandshakeTransitionTest.java index 0c02c40eae50f..0f0e5b90e8549 100644 --- a/test/hotspot/jtreg/runtime/handshake/SystemMembarHandshakeTransitionTest.java +++ b/test/hotspot/jtreg/runtime/handshake/SystemMembarHandshakeTransitionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ public static void main(String[] args) throws Exception { commands.add("-XX:+UseSystemMemoryBarrier"); commands.addAll(Arrays.asList(args)); commands.add("HandshakeTransitionTest$Test"); - ProcessBuilder pb = ProcessTools.createTestJvm(commands); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(commands); OutputAnalyzer output = ProcessTools.executeProcess(pb); output.reportDiagnosticSummary(); diff --git a/test/hotspot/jtreg/runtime/jni/checked/TestCheckedReleaseArrayElements.java b/test/hotspot/jtreg/runtime/jni/checked/TestCheckedReleaseArrayElements.java index 038136b74beed..6395e3b9f0b30 100644 --- a/test/hotspot/jtreg/runtime/jni/checked/TestCheckedReleaseArrayElements.java +++ b/test/hotspot/jtreg/runtime/jni/checked/TestCheckedReleaseArrayElements.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,9 +48,9 @@ public static void main(String[] args) throws Throwable { // Uses executeProcess() instead of executeTestJvm() to avoid passing options // that might generate output on stderr (which should be empty for this test). ProcessBuilder pb = - ProcessTools.createJavaProcessBuilder("-Xcheck:jni", - "-Djava.library.path=" + Utils.TEST_NATIVE_PATH, - "TestCheckedReleaseArrayElements"); + ProcessTools.createLimitedTestJavaProcessBuilder("-Xcheck:jni", + "-Djava.library.path=" + Utils.TEST_NATIVE_PATH, + "TestCheckedReleaseArrayElements"); OutputAnalyzer output = ProcessTools.executeProcess(pb); output.shouldHaveExitValue(0); output.stderrShouldBeEmpty(); diff --git a/test/hotspot/jtreg/runtime/jni/checked/TestPrimitiveArrayCriticalWithBadParam.java b/test/hotspot/jtreg/runtime/jni/checked/TestPrimitiveArrayCriticalWithBadParam.java index ed5d6b052b23d..53cba9d9e479f 100644 --- a/test/hotspot/jtreg/runtime/jni/checked/TestPrimitiveArrayCriticalWithBadParam.java +++ b/test/hotspot/jtreg/runtime/jni/checked/TestPrimitiveArrayCriticalWithBadParam.java @@ -65,7 +65,7 @@ private static void runTest(boolean useVThread) { pbArgs.add(TestPrimitiveArrayCriticalWithBadParam.class.getName()); pbArgs.add(useVThread ? "vtest" : "test"); try { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(pbArgs.toArray(new String[0])); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(pbArgs.toArray(new String[0])); OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); // -Xcheck:jni should warn the bad parameter diff --git a/test/hotspot/jtreg/runtime/jsig/Testjsig.java b/test/hotspot/jtreg/runtime/jsig/Testjsig.java index 315ec3d150037..6e287a6cdc190 100644 --- a/test/hotspot/jtreg/runtime/jsig/Testjsig.java +++ b/test/hotspot/jtreg/runtime/jsig/Testjsig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ public static void main(String[] args) throws Throwable { String libpath = System.getProperty("java.library.path"); // Create a new java process for the TestJNI Java/JNI test - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Djava.library.path=" + libpath + ":.", "TestJNI", "100"); diff --git a/test/hotspot/jtreg/runtime/logging/ClassInitializationTest.java b/test/hotspot/jtreg/runtime/logging/ClassInitializationTest.java index a2e1f0c94f528..34249e5fec8af 100644 --- a/test/hotspot/jtreg/runtime/logging/ClassInitializationTest.java +++ b/test/hotspot/jtreg/runtime/logging/ClassInitializationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,10 +41,10 @@ public class ClassInitializationTest { public static void main(String... args) throws Exception { // (1) - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=info", - "-Xverify:all", - "-Xmx128m", - "BadMap50"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:class+init=info", + "-Xverify:all", + "-Xmx128m", + "BadMap50"); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldNotHaveExitValue(0); out.shouldContain("Start class verification for:"); @@ -54,10 +54,10 @@ public static void main(String... args) throws Exception { out.shouldContain("Fail over class verification to old verifier for: BadMap50"); // (2) class+init should turn off. - pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=off", - "-Xverify:all", - "-Xmx128m", - "BadMap50"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:class+init=off", + "-Xverify:all", + "-Xmx128m", + "BadMap50"); out = new OutputAnalyzer(pb.start()); out.shouldNotHaveExitValue(0); out.shouldNotContain("[class,init]"); diff --git a/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java b/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java index 3a9e03c05e14e..4d59cfa89ab5d 100644 --- a/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java +++ b/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -74,7 +74,7 @@ static OutputAnalyzer exec(String... args) throws Exception { Collections.addAll(argsList, args); Collections.addAll(argsList, "-Xmn8m", "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+ClassUnloading", ClassUnloadTestMain.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(argsList); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(argsList); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); return output; diff --git a/test/hotspot/jtreg/runtime/logging/ClassResolutionTest.java b/test/hotspot/jtreg/runtime/logging/ClassResolutionTest.java index 05155e5108fc1..129d34bd2dba0 100644 --- a/test/hotspot/jtreg/runtime/logging/ClassResolutionTest.java +++ b/test/hotspot/jtreg/runtime/logging/ClassResolutionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,17 +60,17 @@ public static void main(String... args) throws Exception { public static void main(String... args) throws Exception { // (1) class+resolve should turn on. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+resolve=debug", - ClassResolutionTestMain.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:class+resolve=debug", + ClassResolutionTestMain.class.getName()); OutputAnalyzer o = new OutputAnalyzer(pb.start()); o.shouldHaveExitValue(0); o.shouldContain("[class,resolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1"); o.shouldContain("[class,resolve] resolve JVM_CONSTANT_MethodHandle"); // (2) class+resolve should turn off. - pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+resolve=debug", - "-Xlog:class+resolve=off", - ClassResolutionTestMain.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:class+resolve=debug", + "-Xlog:class+resolve=off", + ClassResolutionTestMain.class.getName()); o = new OutputAnalyzer(pb.start()); o.shouldHaveExitValue(0); o.shouldNotContain("[class,resolve]"); diff --git a/test/hotspot/jtreg/runtime/logging/CompressedOopsTest.java b/test/hotspot/jtreg/runtime/logging/CompressedOopsTest.java index ee1a4997900af..79167f581e72a 100644 --- a/test/hotspot/jtreg/runtime/logging/CompressedOopsTest.java +++ b/test/hotspot/jtreg/runtime/logging/CompressedOopsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,20 +51,20 @@ static void analyzeOutputOff(ProcessBuilder pb) throws Exception { } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseCompressedOops", - "-Xlog:gc+heap+coops=debug", - InnerClass.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseCompressedOops", + "-Xlog:gc+heap+coops=debug", + InnerClass.class.getName()); analyzeOutputOn(pb); - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseCompressedOops", - "-Xlog:gc+heap+coops", - InnerClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseCompressedOops", + "-Xlog:gc+heap+coops", + InnerClass.class.getName()); // No coops logging on info level. analyzeOutputOff(pb); - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseCompressedOops", - "-Xlog:gc+heap+coops=off", - InnerClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UseCompressedOops", + "-Xlog:gc+heap+coops=off", + InnerClass.class.getName()); analyzeOutputOff(pb); } diff --git a/test/hotspot/jtreg/runtime/logging/CondyIndyTest.java b/test/hotspot/jtreg/runtime/logging/CondyIndyTest.java index f94f5e5cb2077..c62402c918bdb 100644 --- a/test/hotspot/jtreg/runtime/logging/CondyIndyTest.java +++ b/test/hotspot/jtreg/runtime/logging/CondyIndyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,8 +40,8 @@ public class CondyIndyTest { public static void main(String... args) throws Exception { // (1) methodhandles should turn on, no indy, no condy - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:methodhandles", - "CondyIndy"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:methodhandles", + "CondyIndy"); OutputAnalyzer o = new OutputAnalyzer(pb.start()); o.shouldHaveExitValue(0); o.shouldContain("[info][methodhandles"); @@ -49,8 +49,8 @@ public static void main(String... args) throws Exception { o.shouldNotContain("[debug][methodhandles,condy"); // (2) methodhandles+condy=debug only - pb = ProcessTools.createJavaProcessBuilder("-Xlog:methodhandles+condy=debug", - "CondyIndy"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:methodhandles+condy=debug", + "CondyIndy"); o = new OutputAnalyzer(pb.start()); o.shouldHaveExitValue(0); o.shouldNotContain("[info ][methodhandles"); @@ -58,8 +58,8 @@ public static void main(String... args) throws Exception { o.shouldContain("[debug][methodhandles,condy"); // (3) methodhandles+indy=debug only - pb = ProcessTools.createJavaProcessBuilder("-Xlog:methodhandles+indy=debug", - "CondyIndy"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:methodhandles+indy=debug", + "CondyIndy"); o = new OutputAnalyzer(pb.start()); o.shouldHaveExitValue(0); o.shouldNotContain("[info ][methodhandles"); @@ -67,10 +67,10 @@ public static void main(String... args) throws Exception { o.shouldNotContain("[debug][methodhandles,condy"); // (4) methodhandles, condy, indy all on - pb = ProcessTools.createJavaProcessBuilder("-Xlog:methodhandles=info", - "-Xlog:methodhandles+condy=debug", - "-Xlog:methodhandles+indy=debug", - "CondyIndy"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:methodhandles=info", + "-Xlog:methodhandles+condy=debug", + "-Xlog:methodhandles+indy=debug", + "CondyIndy"); o = new OutputAnalyzer(pb.start()); o.shouldHaveExitValue(0); o.shouldContain("[info ][methodhandles"); diff --git a/test/hotspot/jtreg/runtime/logging/DefaultMethodsTest.java b/test/hotspot/jtreg/runtime/logging/DefaultMethodsTest.java index 2ea7e6bb07a35..d41d6685c2393 100644 --- a/test/hotspot/jtreg/runtime/logging/DefaultMethodsTest.java +++ b/test/hotspot/jtreg/runtime/logging/DefaultMethodsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,8 +37,8 @@ public class DefaultMethodsTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:defaultmethods=debug", - InnerClass.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:defaultmethods=debug", + InnerClass.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Slots that need filling:"); output.shouldContain("requires default method processing"); diff --git a/test/hotspot/jtreg/runtime/logging/ExceptionsTest.java b/test/hotspot/jtreg/runtime/logging/ExceptionsTest.java index 976478253ee6d..327b1cc0f24fd 100644 --- a/test/hotspot/jtreg/runtime/logging/ExceptionsTest.java +++ b/test/hotspot/jtreg/runtime/logging/ExceptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,25 +57,25 @@ static void analyzeOutputOff(ProcessBuilder pb) throws Exception { } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:exceptions=info", - InternalClass.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:exceptions=info", + InternalClass.class.getName()); analyzeOutputOn(pb); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:exceptions=off", - InternalClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:exceptions=off", + InternalClass.class.getName()); analyzeOutputOff(pb); - pb = ProcessTools.createJavaProcessBuilder(InternalClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(InternalClass.class.getName()); updateEnvironment(pb, "_JAVA_OPTIONS", "-Xlog:exceptions=info"); analyzeOutputOn(pb); - pb = ProcessTools.createJavaProcessBuilder(InternalClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(InternalClass.class.getName()); updateEnvironment(pb, "JAVA_TOOL_OPTIONS", "-Xlog:exceptions=info -Xlog:exceptions=off"); analyzeOutputOff(pb); - pb = ProcessTools.createJavaProcessBuilder("-XX:VMOptionsFile=" + System.getProperty("test.src", ".") - + File.separator + "ExceptionsTest_options_file", - InternalClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:VMOptionsFile=" + System.getProperty("test.src", ".") + + File.separator + "ExceptionsTest_options_file", + InternalClass.class.getName()); analyzeOutputOn(pb); } diff --git a/test/hotspot/jtreg/runtime/logging/FoldMultilinesTest.java b/test/hotspot/jtreg/runtime/logging/FoldMultilinesTest.java index 1ae9f2c21d004..8df835245c82a 100644 --- a/test/hotspot/jtreg/runtime/logging/FoldMultilinesTest.java +++ b/test/hotspot/jtreg/runtime/logging/FoldMultilinesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021 NTT DATA. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -79,15 +79,15 @@ private static void test(String out) throws Exception { ProcessBuilder pb; Xlog = XLOG_BASE + out + "::foldmultilines=true"; - pb = ProcessTools.createJavaProcessBuilder(Xlog, InternalClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(Xlog, InternalClass.class.getName()); analyzeFoldMultilinesOn(pb, out); Xlog = XLOG_BASE + out + "::foldmultilines=false"; - pb = ProcessTools.createJavaProcessBuilder(Xlog, InternalClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(Xlog, InternalClass.class.getName()); analyzeFoldMultilinesOff(pb, out); Xlog = XLOG_BASE + out + "::foldmultilines=invalid"; - pb = ProcessTools.createJavaProcessBuilder(Xlog, InternalClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(Xlog, InternalClass.class.getName()); analyzeFoldMultilinesInvalid(pb); } diff --git a/test/hotspot/jtreg/runtime/logging/ItablesTest.java b/test/hotspot/jtreg/runtime/logging/ItablesTest.java index 009986285a47b..6869e5b2917ca 100644 --- a/test/hotspot/jtreg/runtime/logging/ItablesTest.java +++ b/test/hotspot/jtreg/runtime/logging/ItablesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ public class ItablesTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:itables=trace", "ClassB"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:itables=trace", "ClassB"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain(": Initializing itables for ClassB"); output.shouldContain(": Initializing itable indices for interface "); @@ -53,7 +53,7 @@ public static void main(String[] args) throws Exception { output.shouldContain("invokeinterface selected method: receiver-class"); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:itables=trace", "ItablesVtableTest"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:itables=trace", "ItablesVtableTest"); output = new OutputAnalyzer(pb.start()); output.shouldContain("vtable index "); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java b/test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java index 0661ae8144620..39ad3b872a2b8 100644 --- a/test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java +++ b/test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -66,7 +66,7 @@ static ProcessBuilder exec(String... args) throws Exception { Collections.addAll(argsList, "-XX:+UnlockDiagnosticVMOptions"); Collections.addAll(argsList, "-XX:+WhiteBoxAPI"); Collections.addAll(argsList, ClassUnloadTestMain.class.getName()); - return ProcessTools.createJavaProcessBuilder(argsList); + return ProcessTools.createLimitedTestJavaProcessBuilder(argsList); } public static void main(String... args) throws Exception { diff --git a/test/hotspot/jtreg/runtime/logging/ModulesTest.java b/test/hotspot/jtreg/runtime/logging/ModulesTest.java index 5d30fa3a6a4a9..96292b1d5d220 100644 --- a/test/hotspot/jtreg/runtime/logging/ModulesTest.java +++ b/test/hotspot/jtreg/runtime/logging/ModulesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,7 @@ static void testModuleUnload(String... args) throws Exception { } static OutputAnalyzer run(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); return new OutputAnalyzer(pb.start()); } } diff --git a/test/hotspot/jtreg/runtime/logging/MonitorInflationTest.java b/test/hotspot/jtreg/runtime/logging/MonitorInflationTest.java index 85f025469b4e8..737c64621e8ca 100644 --- a/test/hotspot/jtreg/runtime/logging/MonitorInflationTest.java +++ b/test/hotspot/jtreg/runtime/logging/MonitorInflationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,12 +51,12 @@ static void analyzeOutputOff(ProcessBuilder pb) throws Exception { } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:monitorinflation=trace", - InnerClass.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:monitorinflation=trace", + InnerClass.class.getName()); analyzeOutputOn(pb); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:monitorinflation=off", - InnerClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:monitorinflation=off", + InnerClass.class.getName()); analyzeOutputOff(pb); } diff --git a/test/hotspot/jtreg/runtime/logging/MonitorMismatchTest.java b/test/hotspot/jtreg/runtime/logging/MonitorMismatchTest.java index ac54ab8c2ca64..c3b9198b39813 100644 --- a/test/hotspot/jtreg/runtime/logging/MonitorMismatchTest.java +++ b/test/hotspot/jtreg/runtime/logging/MonitorMismatchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -40,19 +40,19 @@ public class MonitorMismatchTest { public static void main(String... args) throws Exception { // monitormismatch should turn on. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xcomp", - "-XX:+TieredCompilation", - "-Xlog:monitormismatch=info", - "MonitorMismatchHelper"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xcomp", + "-XX:+TieredCompilation", + "-Xlog:monitormismatch=info", + "MonitorMismatchHelper"); OutputAnalyzer o = new OutputAnalyzer(pb.start()); o.shouldHaveExitValue(0); o.shouldContain("[monitormismatch] Monitor mismatch in method"); // monitormismatch should turn off. - pb = ProcessTools.createJavaProcessBuilder("-Xcomp", - "-XX:+TieredCompilation", - "-Xlog:monitormismatch=off", - "MonitorMismatchHelper"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xcomp", + "-XX:+TieredCompilation", + "-Xlog:monitormismatch=off", + "MonitorMismatchHelper"); o = new OutputAnalyzer(pb.start()); o.shouldHaveExitValue(0); o.shouldNotContain("[monitormismatch]"); diff --git a/test/hotspot/jtreg/runtime/logging/MutexRankTest.java b/test/hotspot/jtreg/runtime/logging/MutexRankTest.java index d1d459ac00292..9bf2459a651d7 100644 --- a/test/hotspot/jtreg/runtime/logging/MutexRankTest.java +++ b/test/hotspot/jtreg/runtime/logging/MutexRankTest.java @@ -36,8 +36,8 @@ public class MutexRankTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:vmmutex", - "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:vmmutex", + "-version"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldContain("VM Mutex/Monitor ranks:"); if (Platform.isDebugBuild()) { diff --git a/test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java b/test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java index bf6e3faed5987..a1141964f38e3 100644 --- a/test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java +++ b/test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,14 +52,14 @@ static void analyzeOutputForOsCpuLog(OutputAnalyzer output) throws Exception { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+cpu", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os+cpu", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); analyzeOutputForOsCpuLog(output); // PPC64 only uses polling pages when UseSIGTRAP is off. pb = (Platform.isPPC() && Platform.is64bit()) - ? ProcessTools.createJavaProcessBuilder("-Xlog:os", "-XX:-UseSIGTRAP", "-version") - : ProcessTools.createJavaProcessBuilder("-Xlog:os", "-version"); + ? ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os", "-XX:-UseSIGTRAP", "-version") + : ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os", "-version"); output = new OutputAnalyzer(pb.start()); analyzeOutputForOsLog(output); } diff --git a/test/hotspot/jtreg/runtime/logging/ProtectionDomainVerificationTest.java b/test/hotspot/jtreg/runtime/logging/ProtectionDomainVerificationTest.java index 9d89de8b67b23..c99429519e0b0 100644 --- a/test/hotspot/jtreg/runtime/logging/ProtectionDomainVerificationTest.java +++ b/test/hotspot/jtreg/runtime/logging/ProtectionDomainVerificationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,30 +39,30 @@ public class ProtectionDomainVerificationTest { public static void main(String... args) throws Exception { // -Xlog:protectiondomain=trace - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:protectiondomain=trace", - "-Xmx128m", - "-Djava.security.manager=allow", - Hello.class.getName(), "security_manager"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:protectiondomain=trace", + "-Xmx128m", + "-Djava.security.manager=allow", + Hello.class.getName(), "security_manager"); new OutputAnalyzer(pb.start()) .shouldHaveExitValue(0) .shouldContain("[protectiondomain] Checking package access") .shouldContain("[protectiondomain] adding protection domain for class"); // -Xlog:protectiondomain=debug - pb = ProcessTools.createJavaProcessBuilder("-Xlog:protectiondomain=debug", - "-Xmx128m", - "-Djava.security.manager=allow", - Hello.class.getName(), "security_manager"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:protectiondomain=debug", + "-Xmx128m", + "-Djava.security.manager=allow", + Hello.class.getName(), "security_manager"); new OutputAnalyzer(pb.start()) .shouldHaveExitValue(0) .shouldContain("[protectiondomain] Checking package access") .shouldNotContain("[protectiondomain] adding protection domain for class"); // -Xlog:protectiondomain=debug - pb = ProcessTools.createJavaProcessBuilder("-Xlog:protectiondomain=trace", - "-Xmx128m", - "-Djava.security.manager=disallow", - Hello.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:protectiondomain=trace", + "-Xmx128m", + "-Djava.security.manager=disallow", + Hello.class.getName()); new OutputAnalyzer(pb.start()) .shouldHaveExitValue(0) .shouldNotContain("[protectiondomain] Checking package access") diff --git a/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java b/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java index 82859b38f15a9..d4ec877f19bb6 100644 --- a/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java +++ b/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,12 +51,12 @@ static void analyzeOutputOff(ProcessBuilder pb) throws Exception { } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint+cleanup=info", - InnerClass.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:safepoint+cleanup=info", + InnerClass.class.getName()); analyzeOutputOn(pb); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint+cleanup=off", - InnerClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:safepoint+cleanup=off", + InnerClass.class.getName()); analyzeOutputOff(pb); } diff --git a/test/hotspot/jtreg/runtime/logging/SafepointTest.java b/test/hotspot/jtreg/runtime/logging/SafepointTest.java index b79a46ca68644..58d02b6466044 100644 --- a/test/hotspot/jtreg/runtime/logging/SafepointTest.java +++ b/test/hotspot/jtreg/runtime/logging/SafepointTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,8 @@ public class SafepointTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint=trace", - InnerClass.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:safepoint=trace", + InnerClass.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Safepoint synchronization initiated"); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/logging/StackWalkTest.java b/test/hotspot/jtreg/runtime/logging/StackWalkTest.java index b72358842d916..226dac6f466d5 100644 --- a/test/hotspot/jtreg/runtime/logging/StackWalkTest.java +++ b/test/hotspot/jtreg/runtime/logging/StackWalkTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,12 +49,12 @@ static void analyzeOutputOff(ProcessBuilder pb) throws Exception { } public static void main(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:stackwalk=debug", - InnerClass.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:stackwalk=debug", + InnerClass.class.getName()); analyzeOutputOn(pb); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:stackwalk=off", - InnerClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:stackwalk=off", + InnerClass.class.getName()); analyzeOutputOff(pb); } diff --git a/test/hotspot/jtreg/runtime/logging/StartupTimeTest.java b/test/hotspot/jtreg/runtime/logging/StartupTimeTest.java index 2066331cb772d..88ec76efd12a2 100644 --- a/test/hotspot/jtreg/runtime/logging/StartupTimeTest.java +++ b/test/hotspot/jtreg/runtime/logging/StartupTimeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,12 +52,12 @@ static void analyzeOutputOff(ProcessBuilder pb) throws Exception { } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime", - InnerClass.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:startuptime", + InnerClass.class.getName()); analyzeOutputOn(pb); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime=off", - InnerClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:startuptime=off", + InnerClass.class.getName()); analyzeOutputOff(pb); } diff --git a/test/hotspot/jtreg/runtime/logging/ThreadLoggingTest.java b/test/hotspot/jtreg/runtime/logging/ThreadLoggingTest.java index d98fc45531938..2e62240aeb1a0 100644 --- a/test/hotspot/jtreg/runtime/logging/ThreadLoggingTest.java +++ b/test/hotspot/jtreg/runtime/logging/ThreadLoggingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016 SAP SE and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -61,11 +61,11 @@ static void analyzeOutputForDebugLevel(OutputAnalyzer output) throws Exception { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os+thread", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); analyzeOutputForInfoLevel(output); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread=debug", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os+thread=debug", "-version"); output = new OutputAnalyzer(pb.start()); analyzeOutputForDebugLevel(output); output.reportDiagnosticSummary(); diff --git a/test/hotspot/jtreg/runtime/logging/VMOperationTest.java b/test/hotspot/jtreg/runtime/logging/VMOperationTest.java index 873ed6e67924a..014db90423574 100644 --- a/test/hotspot/jtreg/runtime/logging/VMOperationTest.java +++ b/test/hotspot/jtreg/runtime/logging/VMOperationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,10 +38,10 @@ public class VMOperationTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:vmoperation=debug", - "-Xmx128m", - "-Xms128m", - InternalClass.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:vmoperation=debug", + "-Xmx128m", + "-Xms128m", + InternalClass.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("VM_Operation ("); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/logging/VerificationTest.java b/test/hotspot/jtreg/runtime/logging/VerificationTest.java index 0a7f01f86b7e4..a6a0ee66accc4 100644 --- a/test/hotspot/jtreg/runtime/logging/VerificationTest.java +++ b/test/hotspot/jtreg/runtime/logging/VerificationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -63,17 +63,17 @@ static void analyzeOutputOff(ProcessBuilder pb) throws Exception { } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:verification=info", - InternalClass.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:verification=info", + InternalClass.class.getName()); analyzeOutputOn(pb, true); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:verification=off", - InternalClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:verification=off", + InternalClass.class.getName()); analyzeOutputOff(pb); // logging level 'debug' should output stackmaps and bytecode data. - pb = ProcessTools.createJavaProcessBuilder("-Xlog:verification=debug", - InternalClass.class.getName()); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:verification=debug", + InternalClass.class.getName()); analyzeOutputOn(pb, false); } diff --git a/test/hotspot/jtreg/runtime/logging/VtablesTest.java b/test/hotspot/jtreg/runtime/logging/VtablesTest.java index bc525cf253475..a07fe89517376 100644 --- a/test/hotspot/jtreg/runtime/logging/VtablesTest.java +++ b/test/hotspot/jtreg/runtime/logging/VtablesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ public class VtablesTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:vtables=trace", "ClassB"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:vtables=trace", "ClassB"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("copy vtable from ClassA to ClassB"); output.shouldContain("Initializing: ClassB"); @@ -55,7 +55,7 @@ public static void main(String[] args) throws Exception { output.shouldContain("NOT overriding with p2.D.nooverride()V"); output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:vtables=trace", "p1/C"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:vtables=trace", "p1/C"); output = new OutputAnalyzer(pb.start()); output.shouldContain("transitive overriding superclass "); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/logging/loadLibraryTest/LoadLibraryTest.java b/test/hotspot/jtreg/runtime/logging/loadLibraryTest/LoadLibraryTest.java index 29dd7b2fbc0da..f43f3cf760ec1 100644 --- a/test/hotspot/jtreg/runtime/logging/loadLibraryTest/LoadLibraryTest.java +++ b/test/hotspot/jtreg/runtime/logging/loadLibraryTest/LoadLibraryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -118,7 +118,7 @@ static class LoadLibraryClass { public static void main(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-Xmn8m", "-Xlog:library=info", "-Djava.library.path=" + System.getProperty("java.library.path"), diff --git a/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java b/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java index d0292d37dd8c0..7719c8a2db4fc 100644 --- a/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java +++ b/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -136,7 +136,7 @@ private static OutputAnalyzer executeNewJVM(Flag... flags) throws Exception { args.add("-Xlog:pagesize"); args.add("-version"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/memory/ReadFromNoaccessArea.java b/test/hotspot/jtreg/runtime/memory/ReadFromNoaccessArea.java index 889e35577f02b..ede6241663387 100644 --- a/test/hotspot/jtreg/runtime/memory/ReadFromNoaccessArea.java +++ b/test/hotspot/jtreg/runtime/memory/ReadFromNoaccessArea.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ public class ReadFromNoaccessArea { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", diff --git a/test/hotspot/jtreg/runtime/memory/ReserveMemory.java b/test/hotspot/jtreg/runtime/memory/ReserveMemory.java index 7cd0e1a0e78db..6341a031c13ab 100644 --- a/test/hotspot/jtreg/runtime/memory/ReserveMemory.java +++ b/test/hotspot/jtreg/runtime/memory/ReserveMemory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -48,7 +48,7 @@ public static void main(String args[]) throws Exception { // expected to crash WhiteBox.getWhiteBox().readReservedMemory(); } else { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", diff --git a/test/hotspot/jtreg/runtime/modules/ClassLoaderNoUnnamedModuleTest.java b/test/hotspot/jtreg/runtime/modules/ClassLoaderNoUnnamedModuleTest.java index 91017b3070218..765f9dcee7dc4 100644 --- a/test/hotspot/jtreg/runtime/modules/ClassLoaderNoUnnamedModuleTest.java +++ b/test/hotspot/jtreg/runtime/modules/ClassLoaderNoUnnamedModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -37,7 +37,7 @@ public class ClassLoaderNoUnnamedModuleTest { public static void main(String args[]) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=java.base", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", diff --git a/test/hotspot/jtreg/runtime/modules/IgnoreModulePropertiesTest.java b/test/hotspot/jtreg/runtime/modules/IgnoreModulePropertiesTest.java index a3c9c8ac6eeb7..6bd2b299a55a8 100644 --- a/test/hotspot/jtreg/runtime/modules/IgnoreModulePropertiesTest.java +++ b/test/hotspot/jtreg/runtime/modules/IgnoreModulePropertiesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ public class IgnoreModulePropertiesTest { // bogus for that property. But, since the property is ignored no exception is // thrown. public static void testProperty(String prop, String value) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-D" + prop + "=" + value, "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain(" version "); @@ -62,7 +62,7 @@ public static void testProperty(String prop, String value) throws Exception { public static void testOption(boolean shouldVMFail, String option, String value, String prop, String result) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( option + "=" + value, "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (shouldVMFail) { diff --git a/test/hotspot/jtreg/runtime/modules/ModuleOptionsTest.java b/test/hotspot/jtreg/runtime/modules/ModuleOptionsTest.java index 140b910391051..137e482ffb212 100644 --- a/test/hotspot/jtreg/runtime/modules/ModuleOptionsTest.java +++ b/test/hotspot/jtreg/runtime/modules/ModuleOptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public static void main(String[] args) throws Exception { // Test that multiple --add-modules options are cumulative, not last one wins. // An exception should be thrown because module i_dont_exist doesn't exist. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=i_dont_exist", "--add-modules=java.base", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("FindException"); @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { // Test that the last --limit-modules is the only one recognized. No exception // should be thrown. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "--limit-modules=i_dont_exist", "--limit-modules=java.base", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/modules/ModuleOptionsWarn.java b/test/hotspot/jtreg/runtime/modules/ModuleOptionsWarn.java index 5e6b526b5a319..73870e029adda 100644 --- a/test/hotspot/jtreg/runtime/modules/ModuleOptionsWarn.java +++ b/test/hotspot/jtreg/runtime/modules/ModuleOptionsWarn.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,77 +41,77 @@ public class ModuleOptionsWarn { public static void main(String[] args) throws Exception { // Test that a warning is not issued for extraneous jdk.module properties. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.ignored", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning is issued for a reserved jdk.module property. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.addmods", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning is issued for a reserved jdk.module property ending in '.'. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.limitmods.", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning is issued for a reserved jdk.module property ending in '='. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.addexports=", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning is issued for a reserved jdk.module property ending in ".stuff" - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.addreads.stuff", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning is issued for a reserved jdk.module property ending in "=stuff" - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.path=stuff", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning is issued for a reserved jdk.module property ending in ".=" - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.upgrade.path.=xx", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning is issued for a reserved jdk.module property ending in "." - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.patch.3=xx", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning can be suppressed for module related properties that get ignored. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Djdk.module.addmods", "-XX:-PrintWarnings", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning is not issued for properties of the form "jdk.module.main" - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+PrintWarnings", "-Djdk.module.main.ignored", "-version"); output = new OutputAnalyzer(pb.start()); output.shouldNotContain("Ignoring system property option"); output.shouldHaveExitValue(0); // Test that a warning is issued for module related properties specified using _JAVA_OPTIONS. - pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintWarnings", "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintWarnings", "-version"); Map env = pb.environment(); env.put("_JAVA_OPTIONS", "-Djdk.module.addreads"); output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/modules/ModuleStress/ExportModuleStressTest.java b/test/hotspot/jtreg/runtime/modules/ModuleStress/ExportModuleStressTest.java index ce9246e83c6d1..1de5f4ae0f8f2 100644 --- a/test/hotspot/jtreg/runtime/modules/ModuleStress/ExportModuleStressTest.java +++ b/test/hotspot/jtreg/runtime/modules/ModuleStress/ExportModuleStressTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,7 @@ public static void main(String[] args) throws Exception { // Sanity check that the test, jdk.test/test/Main.java // runs without error. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-p", MODS_DIR.toString(), "-m", "jdk.test/test.Main"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStress.java b/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStress.java index bc23a0383abe0..7232e21341080 100644 --- a/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStress.java +++ b/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -50,7 +50,7 @@ public static void main(String[] args) throws Exception { // loaders (boot, application, platform). Thus there is // not a need to walk those lists at a GC safepoint since // those loaders never die. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-Xlog:module=trace", "-version"); @@ -85,7 +85,7 @@ public static void main(String[] args) throws Exception { // m1x's module readability list and package p2's exportability should // not be walked at a GC safepoint since both modules are defined to // the same loader and thus have the exact same life cycle. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-Xlog:module=trace", "ModuleSameCLMain"); @@ -99,7 +99,7 @@ public static void main(String[] args) throws Exception { // m1x's module readability list and package p2's exportability list must // be walked at a GC safepoint since both modules are defined to non-builtin // class loaders which could die and thus be unloaded. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-Xlog:module=trace", "ModuleNonBuiltinCLMain"); @@ -116,7 +116,7 @@ public static void main(String[] args) throws Exception { // m3x is defined to the system class loader, m2x's module readability // list does not have to be walked at a GC safepoint, but package p2's // exportability list does. - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Djava.system.class.loader=CustomSystemClassLoader", "-Xbootclasspath/a:.", "-Xlog:module=trace", diff --git a/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStressGC.java b/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStressGC.java index 05b9cf7c2ef99..44bbe4ed5c220 100644 --- a/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStressGC.java +++ b/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStressGC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ public static void main(String[] args) throws Exception { // Check that jdk.test/test.MainGC walks module jdk.test's // reads list and walks the exports list for package test, // defined in module jdk.test, during a GC. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmx128m", "-Xlog:module=trace", "-p", MODS_DIR.toString(), diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModule2Dirs.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModule2Dirs.java index b582314411da4..cd0670cfb72c5 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModule2Dirs.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModule2Dirs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ public static void main(String[] args) throws Exception { InMemoryJavaCompiler.compile("java.beans.Encoder", source2, "--patch-module=java.desktop"), "mods2/java.desktop"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "--patch-module=java.naming=mods/java.naming", "--patch-module=java.desktop=mods2/java.desktop", "PatchModule2DirsMain", "javax.naming.spi.NamingManager", "java.beans.Encoder"); diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleCDS.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleCDS.java index 109f6cf2616f8..e7bf5dabf2122 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleCDS.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleCDS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ public static void main(String args[]) throws Throwable { // Case 1: Test that --patch-module and -Xshare:dump are compatible String filename = "patch_module.jsa"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + filename, "-Xshare:dump", @@ -69,7 +69,7 @@ public static void main(String args[]) throws Throwable { InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "--patch-module=java.naming"), System.getProperty("test.classes")); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + filename, "-Xshare:dump", @@ -84,7 +84,7 @@ public static void main(String args[]) throws Throwable { // Case 3a: Test CDS dumping with jar file in --patch-module BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager"); String moduleJar = BasicJarBuilder.getTestJar("javanaming.jar"); - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + filename, "-Xshare:dump", @@ -98,7 +98,7 @@ public static void main(String args[]) throws Throwable { .shouldContain("Cannot use the following option when dumping the shared archive: --patch-module"); // Case 3b: Test CDS run with jar file in --patch-module - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + filename, "-Xshare:auto", diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleClassList.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleClassList.java index a4a03935f03f2..35ec86f841d64 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleClassList.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleClassList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,7 @@ public static void main(String args[]) throws Throwable { String moduleJar = BasicJarBuilder.getTestJar("javanaming.jar"); String classList = "javanaming.list"; - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:DumpLoadedClassList=" + classList, "--patch-module=java.naming=" + moduleJar, "PatchModuleMain", BOOT_CLASS.replace('/', '.')); @@ -98,7 +98,7 @@ public static void main(String args[]) throws Throwable { moduleJar = BasicJarBuilder.getTestJar("javasql.jar"); classList = "javasql.list"; - pb = ProcessTools.createTestJvm( + pb = ProcessTools.createTestJavaProcessBuilder( "-XX:DumpLoadedClassList=" + classList, "--patch-module=java.sql=" + moduleJar, "PatchModuleMain", PLATFORM_CLASS.replace('/', '.')); @@ -130,7 +130,7 @@ public static void main(String args[]) throws Throwable { moduleJar = BasicJarBuilder.getTestJar("hello.jar"); classList = "hello.list"; - pb = ProcessTools.createTestJvm( + pb = ProcessTools.createTestJavaProcessBuilder( "-XX:DumpLoadedClassList=" + classList, "-Xbootclasspath/a:" + moduleJar, "Hello"); diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupJavaBase.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupJavaBase.java index a256a1f6c8583..d9d00a1573e5a 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupJavaBase.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupJavaBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public class PatchModuleDupJavaBase { // The VM should exit initialization if java.base is specified // more than once to --patch-module. public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "--patch-module=java.base=javabase_dir", "--patch-module=java.base=javabase_dir", "-version"); diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupModule.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupModule.java index a454dcb152781..464a15f78bd5a 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupModule.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ public class PatchModuleDupModule { // if --patch-module is specified with the same module more than once. public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "--patch-module=module_one=module_one_dir", "--patch-module=module_one=module_one_dir", "-version"); diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleJavaBase.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleJavaBase.java index 58aef0fb87766..75fcf26f63331 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleJavaBase.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleJavaBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { InMemoryJavaCompiler.compile("java.lang.NewClass", source, "--patch-module=java.base"), "mods/java.base"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.base=mods/java.base", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("--patch-module=java.base=mods/java.base", "PatchModuleMain", "java.lang.NewClass"); new OutputAnalyzer(pb.start()) diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTest.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTest.java index 045f156c9d8a3..ed9f9019033d8 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTest.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "--patch-module=java.naming"), "mods/java.naming"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", "PatchModuleMain", "javax.naming.spi.NamingManager"); new OutputAnalyzer(pb.start()) diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJar.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJar.java index ed9e2b0ea8be5..617d144d186f9 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJar.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -76,7 +76,7 @@ public static void main(String[] args) throws Exception { System.getProperty("test.classes")); // Supply --patch-module with the name of the jar file for the module java.naming. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=" + moduleJar, + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("--patch-module=java.naming=" + moduleJar, "PatchModuleMain", "javax.naming.spi.NamingManager"); new OutputAnalyzer(pb.start()) diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJarDir.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJarDir.java index 2b2952b1e2347..1be1f2f0e2248 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJarDir.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJarDir.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,13 +92,13 @@ public static void main(String[] args) throws Exception { // Supply --patch-module with the name of the jar file for the module java.naming. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=" + - moduleJar + - File.pathSeparator + - System.getProperty("test.classes") + "/mods/java.naming", - "PatchModule2DirsMain", - "javax.naming.spi.NamingManager1", - "javax.naming.spi.NamingManager2"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("--patch-module=java.naming=" + + moduleJar + + File.pathSeparator + + System.getProperty("test.classes") + "/mods/java.naming", + "PatchModule2DirsMain", + "javax.naming.spi.NamingManager1", + "javax.naming.spi.NamingManager2"); new OutputAnalyzer(pb.start()) .shouldContain("I pass one!") diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTraceCL.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTraceCL.java index f98f85cce9a5a..dd8b33402ac62 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTraceCL.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTraceCL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ public static void main(String[] args) throws Exception { InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "--patch-module=java.naming"), "mods/java.naming"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", "-Xlog:class+load=info", "PatchModuleMain", "javax.naming.spi.NamingManager"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); @@ -77,7 +77,7 @@ public static void main(String[] args) throws Exception { InMemoryJavaCompiler.compile("PatchModuleTraceCL_pkg.ItIsI", source), "xbcp"); - pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:xbcp", + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xbootclasspath/a:xbcp", "-Xlog:class+load=info", "PatchModuleMain", "PatchModuleTraceCL_pkg.ItIsI"); output = new OutputAnalyzer(pb.start()); // -Xbootclasspath/a case. diff --git a/test/hotspot/jtreg/runtime/modules/Visibility/PatchModuleVisibility.java b/test/hotspot/jtreg/runtime/modules/Visibility/PatchModuleVisibility.java index f11d52b46f0ab..96982593dbb06 100644 --- a/test/hotspot/jtreg/runtime/modules/Visibility/PatchModuleVisibility.java +++ b/test/hotspot/jtreg/runtime/modules/Visibility/PatchModuleVisibility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,7 +86,7 @@ public static void main(String[] args) throws Throwable { Files.delete(Paths.get(System.getProperty("test.classes") + File.separator + "p2" + File.separator + "Vis2_B.class")); - new OutputAnalyzer(ProcessTools.createJavaProcessBuilder( + new OutputAnalyzer(ProcessTools.createLimitedTestJavaProcessBuilder( "--patch-module=java.base=mods2/java.base", "--add-exports=java.base/p2=ALL-UNNAMED", "Vis2_A") diff --git a/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpNoVisibility.java b/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpNoVisibility.java index 9d10fe6488c43..90df4c10f2767 100644 --- a/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpNoVisibility.java +++ b/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpNoVisibility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,7 @@ public static void main(String args[]) throws Exception { ClassFileInstaller.writeClassToDisk("Vis3_A", InMemoryJavaCompiler.compile("Vis3_A", Vis3_A_src), System.getProperty("test.classes")); - new OutputAnalyzer(ProcessTools.createJavaProcessBuilder( + new OutputAnalyzer(ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:.", "Vis3_A") .start()) diff --git a/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpVisibility.java b/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpVisibility.java index df20c356c92e1..5d1605b74feae 100644 --- a/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpVisibility.java +++ b/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpVisibility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -104,7 +104,7 @@ public static void main(String[] args) throws Throwable { Files.delete(Paths.get(System.getProperty("test.classes") + File.separator + "p2" + File.separator + "Vis1_C.class")); - new OutputAnalyzer(ProcessTools.createJavaProcessBuilder( + new OutputAnalyzer(ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:nonexistent.jar", "-Xbootclasspath/a:mods1", "Vis1_A") diff --git a/test/hotspot/jtreg/runtime/os/AvailableProcessors.java b/test/hotspot/jtreg/runtime/os/AvailableProcessors.java index 97491d241b9c4..18201d991270a 100644 --- a/test/hotspot/jtreg/runtime/os/AvailableProcessors.java +++ b/test/hotspot/jtreg/runtime/os/AvailableProcessors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,8 +69,8 @@ public static void main(String[] args) throws Exception { // Get the java command we want to execute // Enable logging for easier failure diagnosis ProcessBuilder master = - ProcessTools.createJavaProcessBuilder("-Xlog:os=trace", - "AvailableProcessors"); + ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os=trace", + "AvailableProcessors"); int[] expected = new int[] { 1, available/2, available-1, available }; diff --git a/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java b/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java index 261ec205d3952..519bcc94b0120 100644 --- a/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java +++ b/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java @@ -179,7 +179,7 @@ public static void main(String[] args) throws Exception { switch (args[0]) { case "PATCH-ENABLED": { finalargs.add(TestMain.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(finalargs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); @@ -216,7 +216,7 @@ public static void main(String[] args) throws Exception { finalargs.add("-XX:-THPStackMitigation"); finalargs.add(TestMain.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(finalargs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java b/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java index 80d7df080d097..2e2d9092c742f 100644 --- a/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java +++ b/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java @@ -48,7 +48,7 @@ public static void main(String[] args) throws Exception { finalargs.addAll(Arrays.asList(defaultArgs)); finalargs.add("-version"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( new String[] {"-Xlog:pagesize", "-Xmx64M", "-version"}); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/os/TestTimerSlack.java b/test/hotspot/jtreg/runtime/os/TestTimerSlack.java index 86aece992b5d2..b703625dfd0a4 100644 --- a/test/hotspot/jtreg/runtime/os/TestTimerSlack.java +++ b/test/hotspot/jtreg/runtime/os/TestTimerSlack.java @@ -42,7 +42,7 @@ public static void main(String[] args) throws Exception { // Check the timer slack value is not printed by default { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os+thread", "TestTimerSlack$TestMain"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); @@ -52,7 +52,7 @@ public static void main(String[] args) throws Exception { // Check the timer slack value is not printed when explicitly disabled { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os+thread", "-XX:+UnlockExperimentalVMOptions", "-XX:TimerSlack=-1", "TestTimerSlack$TestMain"); @@ -64,7 +64,7 @@ public static void main(String[] args) throws Exception { // Check the timer slack value is good when system-wide default is requested { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os+thread", "-XX:+UnlockExperimentalVMOptions", "-XX:TimerSlack=0", "TestTimerSlack$TestMain"); @@ -82,7 +82,7 @@ public static void main(String[] args) throws Exception { // Check the timer slack value is accepted by all threads for (int slack : new int[] {1, 10, 100, 1000, 10000, 100000, 1000000}) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os+thread", "-XX:+UnlockExperimentalVMOptions", "-XX:TimerSlack=" + slack, "TestTimerSlack$TestMain"); diff --git a/test/hotspot/jtreg/runtime/os/TestTrimNative.java b/test/hotspot/jtreg/runtime/os/TestTrimNative.java index cdc49bd42163f..84d8d41de1bf3 100644 --- a/test/hotspot/jtreg/runtime/os/TestTrimNative.java +++ b/test/hotspot/jtreg/runtime/os/TestTrimNative.java @@ -167,7 +167,7 @@ private static String[] prepareOptions(String[] extraVMOptions, String[] program } private static OutputAnalyzer runTestWithOptions(String[] extraOptions, String[] programOptions) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(prepareOptions(extraOptions, programOptions)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(prepareOptions(extraOptions, programOptions)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); return output; diff --git a/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java b/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java index 0146256f7dd73..6b98f8fd2d928 100644 --- a/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java +++ b/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,10 +42,10 @@ public class TestUseCpuAllocPath { public static void main(String[] args) throws Exception { ProcessBuilder pb = - ProcessTools.createJavaProcessBuilder("-Xlog:os=trace", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+UseCpuAllocPath", - "-version"); + ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:os=trace", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+UseCpuAllocPath", + "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/posixSig/TestPosixSig.java b/test/hotspot/jtreg/runtime/posixSig/TestPosixSig.java index 52402ebe83f33..1a9a283f740d8 100644 --- a/test/hotspot/jtreg/runtime/posixSig/TestPosixSig.java +++ b/test/hotspot/jtreg/runtime/posixSig/TestPosixSig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ public static void main(String[] args) throws Throwable { if (args.length == 0) { // Create a new java process for the TestPsig Java/JNI test. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+CheckJNICalls", "-Djava.library.path=" + libpath + ":.", "TestPosixSig", "dummy"); diff --git a/test/hotspot/jtreg/runtime/records/RedefineRecord.java b/test/hotspot/jtreg/runtime/records/RedefineRecord.java index bad4542885eb7..1019a4c3e7b23 100644 --- a/test/hotspot/jtreg/runtime/records/RedefineRecord.java +++ b/test/hotspot/jtreg/runtime/records/RedefineRecord.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,7 @@ public static void main(String argv[]) throws Exception { return; } if (argv.length == 1 && argv[0].equals("runtest")) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:MetaspaceSize=12m", "-XX:MaxMetaspaceSize=12m", "-javaagent:redefineagent.jar", diff --git a/test/hotspot/jtreg/runtime/sealedClasses/RedefinePermittedSubclass.java b/test/hotspot/jtreg/runtime/sealedClasses/RedefinePermittedSubclass.java index 1832d295cc556..29ce452cc2c30 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/RedefinePermittedSubclass.java +++ b/test/hotspot/jtreg/runtime/sealedClasses/RedefinePermittedSubclass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -126,7 +126,7 @@ public static void main(String argv[]) throws Exception { if (argv.length == 1 && argv[0].equals("runtest")) { String[] javaArgs1 = { "-XX:MetaspaceSize=12m", "-XX:MaxMetaspaceSize=12m", "-javaagent:redefineagent.jar", "RedefinePermittedSubclass"}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(javaArgs1); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(javaArgs1); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("processing of -javaagent failed"); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/sealedClasses/RedefineSealedClass.java b/test/hotspot/jtreg/runtime/sealedClasses/RedefineSealedClass.java index 515dfa9f5e060..84a1b6bfac73a 100644 --- a/test/hotspot/jtreg/runtime/sealedClasses/RedefineSealedClass.java +++ b/test/hotspot/jtreg/runtime/sealedClasses/RedefineSealedClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,7 +108,7 @@ public static void main(String argv[]) throws Exception { if (argv.length == 1 && argv[0].equals("runtest")) { String[] javaArgs1 = { "-XX:MetaspaceSize=12m", "-XX:MaxMetaspaceSize=12m", "-javaagent:redefineagent.jar", "RedefineSealedClass"}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(javaArgs1); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(javaArgs1); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("processing of -javaagent failed"); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/runtime/stringtable/StringTableVerifyTest.java b/test/hotspot/jtreg/runtime/stringtable/StringTableVerifyTest.java index 6f6b0a6ef730e..f0513de13a4ff 100644 --- a/test/hotspot/jtreg/runtime/stringtable/StringTableVerifyTest.java +++ b/test/hotspot/jtreg/runtime/stringtable/StringTableVerifyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -36,7 +36,7 @@ public class StringTableVerifyTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:+VerifyStringTableAtExit", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", "-XX:+VerifyStringTableAtExit", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/symboltable/ShortLivedSymbolCleanup.java b/test/hotspot/jtreg/runtime/symboltable/ShortLivedSymbolCleanup.java index 6e5db46bd5c4a..ee7fa8f40d706 100644 --- a/test/hotspot/jtreg/runtime/symboltable/ShortLivedSymbolCleanup.java +++ b/test/hotspot/jtreg/runtime/symboltable/ShortLivedSymbolCleanup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -89,13 +89,13 @@ static void analyzeOutputOn(int size, ProcessBuilder pb) throws Exception { } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:symboltable=trace", - "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:symboltable=trace", + "-version"); int size = getSymbolTableSize(pb); - pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintSymbolTableSizeHistogram", - LotsOfTempSymbols.class.getName(), - Integer.toString(size)); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintSymbolTableSizeHistogram", + LotsOfTempSymbols.class.getName(), + Integer.toString(size)); analyzeOutputOn(size, pb); } diff --git a/test/hotspot/jtreg/runtime/verifier/OverriderMsg.java b/test/hotspot/jtreg/runtime/verifier/OverriderMsg.java index 38a8595d25d58..5b24caacd3e1e 100644 --- a/test/hotspot/jtreg/runtime/verifier/OverriderMsg.java +++ b/test/hotspot/jtreg/runtime/verifier/OverriderMsg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -125,7 +125,7 @@ public static void dump_Overrider () throws Exception { public static void main(String... args) throws Exception { dump_HasFinal(); dump_Overrider(); - ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", "Overrider"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-cp", ".", "Overrider"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain( "java.lang.IncompatibleClassChangeError: class Overrider overrides final method HasFinal.m(Ljava/lang/String;)V"); diff --git a/test/hotspot/jtreg/runtime/verifier/TestANewArray.java b/test/hotspot/jtreg/runtime/verifier/TestANewArray.java index 99333da56dd51..011749133dac1 100644 --- a/test/hotspot/jtreg/runtime/verifier/TestANewArray.java +++ b/test/hotspot/jtreg/runtime/verifier/TestANewArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,7 @@ public static void main(String... args) throws Exception { byte[] classFile_254 = dumpClassFile(cfv, test_Dimension_254, array_Dimension_254); writeClassFileFromByteArray(classFile_254); System.err.println("Running with cfv: " + cfv + ", test_Dimension_254"); - ProcessBuilder pb = ProcessTools.createTestJvm("-verify", "-cp", ".", classCName); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-verify", "-cp", ".", classCName); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("java.lang.VerifyError"); output.shouldHaveExitValue(0); @@ -78,7 +78,7 @@ public static void main(String... args) throws Exception { byte[] classFile_255 = dumpClassFile(cfv, test_Dimension_255, array_Dimension_255); writeClassFileFromByteArray(classFile_255); System.err.println("Running with cfv: " + cfv + ", test_Dimension_255"); - pb = ProcessTools.createTestJvm("-verify", "-cp", ".", classCName); + pb = ProcessTools.createTestJavaProcessBuilder("-verify", "-cp", ".", classCName); output = new OutputAnalyzer(pb.start()); // If anewarray has an operand with 255 array dimensions then VerifyError should // be thrown because the resulting array would have 256 dimensions. @@ -95,7 +95,7 @@ public static void main(String... args) throws Exception { byte[] classFile_264 = dumpClassFile(cfv, test_Dimension_264, array_Dimension_264); writeClassFileFromByteArray(classFile_264); System.err.println("Running with cfv: " + cfv + ", test_Dimension_264"); - pb = ProcessTools.createTestJvm("-verify", "-cp", ".", classCName); + pb = ProcessTools.createTestJavaProcessBuilder("-verify", "-cp", ".", classCName); output = new OutputAnalyzer(pb.start()); output.shouldContain("java.lang.ClassFormatError"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/verifier/TestMultiANewArray.java b/test/hotspot/jtreg/runtime/verifier/TestMultiANewArray.java index 07f2f33110d6b..6f04278c4cd7d 100644 --- a/test/hotspot/jtreg/runtime/verifier/TestMultiANewArray.java +++ b/test/hotspot/jtreg/runtime/verifier/TestMultiANewArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ public static void main(String... args) throws Exception { int cfv = Integer.parseInt(args[0]); writeClassFile(cfv); System.err.println("Running with cfv: " + cfv); - ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", "ClassFile"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-cp", ".", "ClassFile"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("VerifyError"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/verifier/TestTableSwitch.java b/test/hotspot/jtreg/runtime/verifier/TestTableSwitch.java index 2daffb162f89b..0225b0ea753ae 100644 --- a/test/hotspot/jtreg/runtime/verifier/TestTableSwitch.java +++ b/test/hotspot/jtreg/runtime/verifier/TestTableSwitch.java @@ -42,12 +42,12 @@ public static void main(String[] args) throws Exception { LookupSwitchp1.runLookup(); } } else { - ProcessBuilder pb = ProcessTools.createTestJvm("TestTableSwitch", "runTable"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("TestTableSwitch", "runTable"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("java.lang.VerifyError: Bad instruction"); output.shouldHaveExitValue(1); - pb = ProcessTools.createTestJvm("TestTableSwitch", "runLookup"); + pb = ProcessTools.createTestJavaProcessBuilder("TestTableSwitch", "runLookup"); output = new OutputAnalyzer(pb.start()); output.shouldContain("java.lang.VerifyError: Bad instruction"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/verifier/TraceClassRes.java b/test/hotspot/jtreg/runtime/verifier/TraceClassRes.java index c4e420a1613ab..ddb5e68e1d3c1 100644 --- a/test/hotspot/jtreg/runtime/verifier/TraceClassRes.java +++ b/test/hotspot/jtreg/runtime/verifier/TraceClassRes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ public class TraceClassRes { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xlog:class+resolve=debug", "-verify", "-Xshare:off", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/whitebox/TestWBDeflateIdleMonitors.java b/test/hotspot/jtreg/runtime/whitebox/TestWBDeflateIdleMonitors.java index e5e22e582392e..e88bc025e8c77 100644 --- a/test/hotspot/jtreg/runtime/whitebox/TestWBDeflateIdleMonitors.java +++ b/test/hotspot/jtreg/runtime/whitebox/TestWBDeflateIdleMonitors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ public class TestWBDeflateIdleMonitors { static final int N_TRIES = 5; // number of times to try deflation public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", diff --git a/test/hotspot/jtreg/serviceability/attach/AttachSetGetFlag.java b/test/hotspot/jtreg/serviceability/attach/AttachSetGetFlag.java index d6b21a5a32706..dcc5bdce8308a 100644 --- a/test/hotspot/jtreg/serviceability/attach/AttachSetGetFlag.java +++ b/test/hotspot/jtreg/serviceability/attach/AttachSetGetFlag.java @@ -66,7 +66,7 @@ public static void main(String... args) throws Exception { } public static ProcessBuilder runTarget(String flagName, String flagValue) throws Exception { - return ProcessTools.createJavaProcessBuilder( + return ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:" + flagName + "=" + flagValue, "AttachSetGetFlag$Target"); diff --git a/test/hotspot/jtreg/serviceability/attach/AttachWithStalePidFile.java b/test/hotspot/jtreg/serviceability/attach/AttachWithStalePidFile.java index f5905396782b8..aceaa82d66859 100644 --- a/test/hotspot/jtreg/serviceability/attach/AttachWithStalePidFile.java +++ b/test/hotspot/jtreg/serviceability/attach/AttachWithStalePidFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -59,7 +59,7 @@ public static void main(String... args) throws Exception { } public static boolean runTest() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+PauseAtStartup", "AttachWithStalePidFileTarget"); Process target = pb.start(); Path pidFile = null; diff --git a/test/hotspot/jtreg/serviceability/attach/ShMemLongName.java b/test/hotspot/jtreg/serviceability/attach/ShMemLongName.java index bf90dd9a08cad..3618a4cfa09c5 100644 --- a/test/hotspot/jtreg/serviceability/attach/ShMemLongName.java +++ b/test/hotspot/jtreg/serviceability/attach/ShMemLongName.java @@ -94,7 +94,7 @@ private static void log(String s) { // creates target process builder for the specified shmem transport name private static ProcessBuilder getTarget(String shmemName) throws IOException { log("starting target with shmem name: '" + shmemName + "'..."); - return ProcessTools.createJavaProcessBuilder( + return ProcessTools.createLimitedTestJavaProcessBuilder( "-Xrunjdwp:transport=" + transport + ",server=y,suspend=n,address=" + shmemName, "ShMemLongName$Target"); } diff --git a/test/hotspot/jtreg/serviceability/dcmd/gc/RunFinalizationTest.java b/test/hotspot/jtreg/serviceability/dcmd/gc/RunFinalizationTest.java index bf8605ee32028..da47616d6e4a5 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/gc/RunFinalizationTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/gc/RunFinalizationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ public static void main(String ... args) throws Exception { javaArgs.add("-cp"); javaArgs.add(System.getProperty("test.class.path")); javaArgs.add(TEST_APP_NAME); - ProcessBuilder testAppPb = ProcessTools.createJavaProcessBuilder(javaArgs); + ProcessBuilder testAppPb = ProcessTools.createLimitedTestJavaProcessBuilder(javaArgs); final AtomicBoolean failed = new AtomicBoolean(); final AtomicBoolean passed = new AtomicBoolean(); diff --git a/test/hotspot/jtreg/serviceability/dtrace/DTraceOptionsTest.java b/test/hotspot/jtreg/serviceability/dtrace/DTraceOptionsTest.java index f0bd1e1fdfbb9..66476712514b4 100644 --- a/test/hotspot/jtreg/serviceability/dtrace/DTraceOptionsTest.java +++ b/test/hotspot/jtreg/serviceability/dtrace/DTraceOptionsTest.java @@ -62,7 +62,7 @@ public static void main(String[] args) throws Throwable { }; for (String opt : options) { - var pb = ProcessTools.createJavaProcessBuilder("-XX:+" + opt, "-version"); + var pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+" + opt, "-version"); var oa = new OutputAnalyzer(pb.start()); if (dtraceEnabled) { oa.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java b/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java index 2d03d2f418f51..f7467affdf8db 100644 --- a/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java +++ b/test/hotspot/jtreg/serviceability/jdwp/DebuggeeLauncher.java @@ -69,7 +69,7 @@ public DebuggeeLauncher(Listener listener) { */ public void launchDebuggee() throws Throwable { - ProcessBuilder pb = ProcessTools.createTestJvm(JDWP_OPT, DEBUGGEE); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(JDWP_OPT, DEBUGGEE); p = pb.start(); StreamHandler inputHandler = new StreamHandler(p.getInputStream(), this); StreamHandler errorHandler = new StreamHandler(p.getErrorStream(), l -> System.out.println("[stderr]: " + l)); diff --git a/test/hotspot/jtreg/serviceability/jvmti/CanGenerateAllClassHook/CanGenerateAllClassHook.java b/test/hotspot/jtreg/serviceability/jvmti/CanGenerateAllClassHook/CanGenerateAllClassHook.java index 759967c5c9642..b3c8ed66a0b8b 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/CanGenerateAllClassHook/CanGenerateAllClassHook.java +++ b/test/hotspot/jtreg/serviceability/jvmti/CanGenerateAllClassHook/CanGenerateAllClassHook.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -125,7 +125,7 @@ private static void log(String msg) { } private static OutputAnalyzer execJava(String... args) throws IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java b/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java index 126f3333cae03..b5ab4eeb99792 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java +++ b/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "GetObjectSizeClassAgent.class"}); pb.start().waitFor(); - ProcessBuilder pt = ProcessTools.createTestJvm("-javaagent:agent.jar", "GetObjectSizeClassAgent"); + ProcessBuilder pt = ProcessTools.createTestJavaProcessBuilder("-javaagent:agent.jar", "GetObjectSizeClassAgent"); OutputAnalyzer output = new OutputAnalyzer(pt.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineLeak.java b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineLeak.java index bd14f8ec3c7ed..b369f4abb85f5 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineLeak.java +++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -105,7 +105,7 @@ public static void main(String argv[]) throws Exception { } if (argv.length == 1 && argv[0].equals("runtest")) { // run outside of jtreg to not OOM on jtreg classes that are loaded after metaspace is full - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:MetaspaceSize=12m", "-XX:MaxMetaspaceSize=12m", "-javaagent:redefineagent.jar", diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefinePreviousVersions.java b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefinePreviousVersions.java index 80933a7beb00b..9fe9f43b8a99b 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefinePreviousVersions.java +++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefinePreviousVersions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -84,7 +84,7 @@ public static void main(String[] args) throws Exception { if (args.length > 0) { // java -javaagent:redefineagent.jar -Xlog:stuff RedefinePreviousVersions - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-javaagent:redefineagent.jar", + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-javaagent:redefineagent.jar", "-Xlog:redefine+class+iklass+add=trace,redefine+class+iklass+purge=trace", "RedefinePreviousVersions"); new OutputAnalyzer(pb.start()) diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineSharedClassJFR.java b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineSharedClassJFR.java index 6ee54be7831af..bf6216ae85a07 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineSharedClassJFR.java +++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineSharedClassJFR.java @@ -75,7 +75,7 @@ public static void main(String[] args) throws Exception { List offCommand = new ArrayList<>(); offCommand.add("-Xshare:off"); offCommand.addAll(baseCommand); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(offCommand); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(offCommand); new OutputAnalyzer(pb.start()) // We can't expect any of the transformed classes to be in use // so the only thing we can verify is that no scratch classes @@ -89,7 +89,7 @@ public static void main(String[] args) throws Exception { List onCommand = new ArrayList<>(); onCommand.add("-Xshare:on"); onCommand.addAll(baseCommand); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(onCommand); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(onCommand); new OutputAnalyzer(pb.start()) .shouldContain(SHOULD_CLEAN_FALSE) .shouldNotContain(SHOULD_CLEAN_TRUE) diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RetransformClassesZeroLength.java b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RetransformClassesZeroLength.java index 13ac65a2eb756..7f7ec792941e5 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RetransformClassesZeroLength.java +++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RetransformClassesZeroLength.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -56,7 +56,7 @@ public class RetransformClassesZeroLength { public static void main(String args[]) throws Throwable { String agentJar = buildAgent(); ProcessTools.executeProcess( - ProcessTools.createJavaProcessBuilder( + ProcessTools.createLimitedTestJavaProcessBuilder( "-javaagent:" + agentJar, "-version") ).shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TransformerDeadlockTest.java b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TransformerDeadlockTest.java index f51ff4c58a55e..99c7a49263c20 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TransformerDeadlockTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TransformerDeadlockTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,7 @@ public class TransformerDeadlockTest { public static void main(String args[]) throws Throwable { String agentJar = buildAgent(); ProcessTools.executeProcess( - ProcessTools.createJavaProcessBuilder( + ProcessTools.createLimitedTestJavaProcessBuilder( "-javaagent:" + agentJar, TransformerDeadlockTest.Agent.class.getName()) ).shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/premain/AgentWithVThreadTest.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/premain/AgentWithVThreadTest.java index 4e0db40d1b9af..ab04520f4ae9c 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/vthread/premain/AgentWithVThreadTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/premain/AgentWithVThreadTest.java @@ -37,7 +37,7 @@ public class AgentWithVThreadTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm("-javaagent:agent.jar", "-version"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-javaagent:agent.jar", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.stdoutShouldContain("passed"); } diff --git a/test/hotspot/jtreg/serviceability/logging/TestBasicLogOutput.java b/test/hotspot/jtreg/serviceability/logging/TestBasicLogOutput.java index 07aafabf9958c..895e5504feb6a 100644 --- a/test/hotspot/jtreg/serviceability/logging/TestBasicLogOutput.java +++ b/test/hotspot/jtreg/serviceability/logging/TestBasicLogOutput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ public class TestBasicLogOutput { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:all=trace", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:all=trace", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldMatch("\\[logging *\\]"); // expected tag(s) output.shouldContain("Log configuration fully initialized."); // expected message diff --git a/test/hotspot/jtreg/serviceability/logging/TestDefaultLogOutput.java b/test/hotspot/jtreg/serviceability/logging/TestDefaultLogOutput.java index 3a7fde88894e8..a1f70fdeb1344 100644 --- a/test/hotspot/jtreg/serviceability/logging/TestDefaultLogOutput.java +++ b/test/hotspot/jtreg/serviceability/logging/TestDefaultLogOutput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ public class TestDefaultLogOutput { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:badTag"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:badTag"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.stdoutShouldMatch("\\[error *\\]\\[logging *\\]"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/serviceability/logging/TestFullNames.java b/test/hotspot/jtreg/serviceability/logging/TestFullNames.java index dceb2e32f6332..0a3bc855d8f92 100644 --- a/test/hotspot/jtreg/serviceability/logging/TestFullNames.java +++ b/test/hotspot/jtreg/serviceability/logging/TestFullNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,9 +63,9 @@ public static void main(String[] args) throws Exception { for (String logOutput : validOutputs) { Asserts.assertFalse(file.exists()); // Run with logging=trace on stdout so that we can verify the log configuration afterwards. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:logging=trace", - "-Xlog:all=trace:" + logOutput, - "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:logging=trace", + "-Xlog:all=trace:" + logOutput, + "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); Asserts.assertTrue(file.exists()); diff --git a/test/hotspot/jtreg/serviceability/logging/TestLogRotation.java b/test/hotspot/jtreg/serviceability/logging/TestLogRotation.java index 608c656c58010..585e8bda47d6d 100644 --- a/test/hotspot/jtreg/serviceability/logging/TestLogRotation.java +++ b/test/hotspot/jtreg/serviceability/logging/TestLogRotation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,7 @@ public static void cleanLogs() { } public static void runTest(int numberOfFiles) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-cp", System.getProperty("java.class.path"), "-Xlog:gc=debug:" + logFileName + "::filesize=" + logFileSizeK + "k" diff --git a/test/hotspot/jtreg/serviceability/logging/TestMultipleXlogArgs.java b/test/hotspot/jtreg/serviceability/logging/TestMultipleXlogArgs.java index 8570eec736062..13560eeb68afa 100644 --- a/test/hotspot/jtreg/serviceability/logging/TestMultipleXlogArgs.java +++ b/test/hotspot/jtreg/serviceability/logging/TestMultipleXlogArgs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,13 +36,13 @@ public class TestMultipleXlogArgs { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:logging=debug", - "-Xlog:logging=trace", - "-Xlog:defaultmethods=trace", - "-Xlog:defaultmethods=warning", - "-Xlog:safepoint=info", - "-Xlog:safepoint=info", - "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:logging=debug", + "-Xlog:logging=trace", + "-Xlog:defaultmethods=trace", + "-Xlog:defaultmethods=warning", + "-Xlog:safepoint=info", + "-Xlog:safepoint=info", + "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); // -Xlog:logging=trace means that the log configuration will be printed. String stdoutConfigLine = "\\[logging *\\] #0: stdout .*"; diff --git a/test/hotspot/jtreg/serviceability/logging/TestQuotedLogOutputs.java b/test/hotspot/jtreg/serviceability/logging/TestQuotedLogOutputs.java index dff973f61da41..dea656130ab5b 100644 --- a/test/hotspot/jtreg/serviceability/logging/TestQuotedLogOutputs.java +++ b/test/hotspot/jtreg/serviceability/logging/TestQuotedLogOutputs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,9 +73,9 @@ public static void main(String[] args) throws Exception { }; for (String logOutput : validOutputs) { // Run with logging=trace on stdout so that we can verify the log configuration afterwards. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:logging=trace", - "-Xlog:all=trace:" + logOutput, - "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:logging=trace", + "-Xlog:all=trace:" + logOutput, + "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); Asserts.assertTrue(file.exists()); @@ -98,9 +98,9 @@ public static void main(String[] args) throws Exception { "A" + quote + quote + "B" }; for (String logOutput : invalidOutputs) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:logging=trace", - "-Xlog:all=trace:" + logOutput, - "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:logging=trace", + "-Xlog:all=trace:" + logOutput, + "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(1); // Ensure error message was logged diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java index 3655a8c8847f2..53370fc09d618 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,7 +90,7 @@ public static void main(String[] args) throws Exception { try { List options = new ArrayList<>(); options.addAll(Arrays.asList(jArgs)); - ProcessBuilder pb = ProcessTools.createTestJvm(options); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(options); // Add "ulimit -c unlimited" if we can since we are generating a core file. pb = CoreUtils.addCoreUlimitCommand(pb); crashOutput = ProcessTools.executeProcess(pb); diff --git a/test/hotspot/jtreg/serviceability/sa/TestClassDump.java b/test/hotspot/jtreg/serviceability/sa/TestClassDump.java index 18f3c47e5d142..04d225287b86d 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestClassDump.java +++ b/test/hotspot/jtreg/serviceability/sa/TestClassDump.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,7 @@ private static void dumpClass(long lingeredAppPid) ProcessBuilder pb; OutputAnalyzer output; - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Dsun.jvm.hotspot.tools.jcore.outputDir=jtreg_classes", "-m", "jdk.hotspot.agent/sun.jvm.hotspot.tools.jcore.ClassDump", String.valueOf(lingeredAppPid)); SATestUtils.addPrivilegesIfNeeded(pb); @@ -68,7 +68,7 @@ private static void dumpClass(long lingeredAppPid) throw new RuntimeException("jtreg_classes/sun/net/util/URLUtil.class not found"); } - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Dsun.jvm.hotspot.tools.jcore.outputDir=jtreg_classes2", "-Dsun.jvm.hotspot.tools.jcore.PackageNameFilter.pkgList=jdk,sun", "-m", "jdk.hotspot.agent/sun.jvm.hotspot.tools.jcore.ClassDump", String.valueOf(lingeredAppPid)); diff --git a/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java index 4753c924f1e34..ca5c99d00b8b0 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,7 +91,7 @@ private static void createAnotherToAttach( String[] instanceKlassNames, long lingeredAppPid) throws Exception { // Start a new process to attach to the lingered app - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", diff --git a/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java b/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java index f674008e2f85c..094c7525048ea 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java +++ b/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -98,7 +98,7 @@ private static void createAnotherToAttach( String[] instanceKlassNames, long lingeredAppPid) throws Exception { // Start a new process to attach to the lingered app - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", diff --git a/test/hotspot/jtreg/serviceability/sa/TestG1HeapRegion.java b/test/hotspot/jtreg/serviceability/sa/TestG1HeapRegion.java index 70b9f066257c9..5c344b408dc87 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestG1HeapRegion.java +++ b/test/hotspot/jtreg/serviceability/sa/TestG1HeapRegion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, 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 @@ -72,7 +72,7 @@ private static void checkHeapRegion(String pid) throws Exception { private static void createAnotherToAttach(long lingeredAppPid) throws Exception { // Start a new process to attach to the lingered app - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.gc.g1=ALL-UNNAMED", diff --git a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java index a2190d4848779..ebe55b7506170 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java +++ b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ private static void startMeWithArgs() throws Exception { } try { // Run this app with the LingeredApp PID to get SA output from the LingeredApp - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", diff --git a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java index f2310dfe5613f..e0f7cbecd2f5b 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java +++ b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,7 +103,7 @@ private static void createAnotherToAttach( String[] instanceKlassNames, int lingeredAppPid) throws Exception { // Start a new process to attach to the LingeredApp process to get SA info - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java index 367720436688b..9119ac45cc338 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,7 @@ public static void main(String[] args) throws Throwable { } static void test(String type) throws Throwable { - ProcessBuilder pb = ProcessTools.createTestJvm("-XX:+CreateCoredumpOnCrash", + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-XX:+CreateCoredumpOnCrash", "-Xmx512m", "-XX:MaxMetaspaceSize=64m", "-XX:+CrashOnOutOfMemoryError", // The test loads lots of small classes to exhaust Metaspace, skip method // dependency verification to improve performance in debug builds. diff --git a/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java b/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java index 236dee6c39dae..84744c70cdf67 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java +++ b/test/hotspot/jtreg/serviceability/sa/TestObjectAlignment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,7 @@ private static void checkAlignment(String pid, int expectedAlign) throws Excepti private static void createAnotherToAttach(long lingeredAppPid, int expectedAlign) throws Exception { // Start a new process to attach to the lingered app - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", diff --git a/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java b/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java index 666fa16936371..5ab952775261d 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java +++ b/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java @@ -73,7 +73,7 @@ private static void test(String pid) { private static void createAnotherToAttach(long lingeredAppPid) throws Exception { // Start a new process to attach to the lingered app - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", diff --git a/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java index da7334503db25..315c931d49e3a 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,7 +66,7 @@ private static void computeReversePointers(String pid) throws Exception { private static void createAnotherToAttach(long lingeredAppPid) throws Exception { // Start a new process to attach to the lingered app - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED", diff --git a/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java b/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java index 533ef82b4f3c7..932974d2dce3d 100644 --- a/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java +++ b/test/hotspot/jtreg/serviceability/sa/UniqueVtableTest.java @@ -146,7 +146,7 @@ private static void runTest(HotSpotAgent agent) throws Throwable { private static void createAnotherToAttach(long lingeredAppPid) throws Throwable { // Start a new process to attach to the lingered app - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( "--add-modules=jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED", diff --git a/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java b/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java index ef31f325481f3..9d923f7b7104f 100644 --- a/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java +++ b/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java @@ -77,7 +77,7 @@ public static void main(String[] args) throws Exception { private static void testHProfFileFormat(String vmArgs, long heapSize, String expectedFormat) throws Exception, IOException, InterruptedException, FileNotFoundException { - ProcessBuilder procBuilder = ProcessTools.createTestJvm( + ProcessBuilder procBuilder = ProcessTools.createTestJavaProcessBuilder( "--add-exports=java.management/sun.management=ALL-UNNAMED", vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize)); procBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); Process largeHeapProc = procBuilder.start(); diff --git a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java index c23561b6d524d..478b74c27412c 100644 --- a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java +++ b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java @@ -183,7 +183,7 @@ private void startCtwforAllClasses() { while (!done) { String[] cmd = cmd(classStart, classStop); try { - ProcessBuilder pb = ProcessTools.createTestJvm(cmd); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(cmd); String commandLine = pb.command() .stream() .collect(Collectors.joining(" ")); diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java index e350d5cf121ce..1f824c5109f53 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ public static void main(String[] args) { } OutputAnalyzer oa; try { - ProcessBuilder pb = ProcessTools.createTestJvm(args); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(args); oa = new OutputAnalyzer(pb.start()); } catch (Exception e) { throw new Error("Unexpected exception on test jvm start :" + e, e); diff --git a/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java b/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java index ec22510bf8dc5..2aa2e2a207bd2 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java +++ b/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -103,7 +103,7 @@ protected void compile(String[] args) throws Exception { } } } - ProcessBuilder pb = ProcessTools.createTestJvm(cmd); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(cmd); OutputAnalyzer output = new OutputAnalyzer(pb.start()); dump(output, "compile"); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestDScenarios.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestDScenarios.java index 10a49f9a3c7fe..e5476afc1f669 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestDScenarios.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestDScenarios.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,7 @@ public static void main(String[] args) throws Exception { } else { // Test invalid -DScenario flag. OutputAnalyzer oa; - ProcessBuilder process = ProcessTools.createJavaProcessBuilder( + ProcessBuilder process = ProcessTools.createLimitedTestJavaProcessBuilder( "-Dtest.jdk=" + Utils.TEST_JDK, "-DScenarios=a,1,b,10", "ir_framework.tests.TestDScenarios", " test3"); oa = ProcessTools.executeProcess(process); diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestDTestAndExclude.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestDTestAndExclude.java index b74012fd54adc..22d52f692a335 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestDTestAndExclude.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestDTestAndExclude.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -97,7 +97,7 @@ public static void main(String[] args) throws Exception { protected static void run(String dTest, String dExclude, String arg) throws Exception { System.out.println("Run -DTest=" + dTest + " -DExclude=" + dExclude + " arg=" + arg); OutputAnalyzer oa; - ProcessBuilder process = ProcessTools.createJavaProcessBuilder( + ProcessBuilder process = ProcessTools.createLimitedTestJavaProcessBuilder( "-Dtest.class.path=" + Utils.TEST_CLASS_PATH, "-Dtest.jdk=" + Utils.TEST_JDK, "-Dtest.vm.opts=-DTest=" + dTest + " -DExclude=" + dExclude, "ir_framework.tests.TestDTestAndExclude", arg); diff --git a/test/hotspot/jtreg/vmTestbase/gc/huge/quicklook/largeheap/MemOptions/MemOptionsTest.java b/test/hotspot/jtreg/vmTestbase/gc/huge/quicklook/largeheap/MemOptions/MemOptionsTest.java index 8eea44148ed94..67e629fddcdcf 100644 --- a/test/hotspot/jtreg/vmTestbase/gc/huge/quicklook/largeheap/MemOptions/MemOptionsTest.java +++ b/test/hotspot/jtreg/vmTestbase/gc/huge/quicklook/largeheap/MemOptions/MemOptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,7 +93,7 @@ private void positive(String name, String... opts) throws IOException { var cmd = new ArrayList(); Collections.addAll(cmd, opts); cmd.add(MemStat.class.getName()); - var pb = ProcessTools.createTestJvm(cmd); + var pb = ProcessTools.createTestJavaProcessBuilder(cmd); var output = new OutputAnalyzer(pb.start()); if (output.getExitValue() != 0) { output.reportDiagnosticSummary(); @@ -106,7 +106,7 @@ private void negative(String name, String... opts) throws IOException { var cmd = new ArrayList(); Collections.addAll(cmd, opts); cmd.add(MemStat.class.getName()); - var pb = ProcessTools.createTestJvm(cmd); + var pb = ProcessTools.createTestJavaProcessBuilder(cmd); var output = new OutputAnalyzer(pb.start()); if (output.getExitValue() == 0) { output.reportDiagnosticSummary(); diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java b/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java index 5df4b8aea8fc7..728c6baed6ef4 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,8 +40,8 @@ public class TestMaxMetaspaceSize { public static void main(String[] args) throws Exception { ProcessBuilder pb = - ProcessTools.createTestJvm("-XX:MaxMetaspaceSize=100m", - maxMetaspaceSize.class.getName()); + ProcessTools.createTestJavaProcessBuilder("-XX:MaxMetaspaceSize=100m", + maxMetaspaceSize.class.getName()); OutputAnalyzer out = new OutputAnalyzer(pb.start()); if (out.getExitValue() == 0) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.java index 25ceeeecfbca8..f81acedbaeca2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,7 +80,7 @@ public class alloc001 { private static final int STATUS_NO_OOM = 3 + STATUS_BASE; public static void main(String[] args) throws Throwable { - String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJvm( + String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJavaProcessBuilder( "-XX:MaxHeapSize=" + (Platform.is32bit() ? "256m" : "512m"), "-Djava.library.path=" + Utils.TEST_NATIVE_PATH, "-agentpath:" + Utils.TEST_NATIVE_PATH + File.separator + System.mapLibraryName("alloc001"), diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java index 57afb3a0e4673..be48854648faf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, 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 @@ -68,7 +68,7 @@ public class TestDriver { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-agentlib:retransform003-01=id=1 can_retransform_classes=1", "-agentlib:retransform003-02=id=2 can_retransform_classes=0", "-agentlib:retransform003-03=id=3 can_retransform_classes=1", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java index b1057f9893e95..898e76713324a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, 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 @@ -57,7 +57,7 @@ public class TestDriver { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-agentlib:SetNativeMethodPrefix001=trace=all", "-agentlib:SetNativeMethodPrefix002-01=trace=all prefix=wa_", "-agentlib:SetNativeMethodPrefix002-02=trace=all prefix=wb_", diff --git a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfo/Test.java b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfo/Test.java index 118d6c8f821f5..f63eb21a8938a 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfo/Test.java +++ b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfo/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,7 @@ public class Test { public static void main(String[] args) throws Exception { { System.out.println("SegmentedCodeCache is enabled"); - var pb = ProcessTools.createTestJvm( + var pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+SegmentedCodeCache", "-XX:+PrintCodeCache", "-version"); @@ -79,7 +79,7 @@ public static void main(String[] args) throws Exception { } { System.out.println("SegmentedCodeCache is disabled"); - var pb = ProcessTools.createTestJvm( + var pb = ProcessTools.createTestJavaProcessBuilder( "-XX:-SegmentedCodeCache", "-XX:+PrintCodeCache", "-version"); diff --git a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/Test.java b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/Test.java index 4580e7f0ec8cc..145072487ecc9 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/Test.java +++ b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ public class Test { private static String REGEXP = "^(CodeCache|(CodeHeap.*)): size=\\d+Kb used=\\d+Kb max_used=\\d+Kb free=\\d+Kb"; public static void main(String[] args) throws Exception { - var pb = ProcessTools.createTestJvm( + var pb = ProcessTools.createTestJavaProcessBuilder( "-XX:-PrintCodeCache", "-XX:+PrintCodeCacheOnCompilation", "-XX:-Inline", diff --git a/test/jdk/com/sun/jdi/JITDebug.java b/test/jdk/com/sun/jdi/JITDebug.java index e7a5647fdd493..45ec0f2ea7953 100644 --- a/test/jdk/com/sun/jdi/JITDebug.java +++ b/test/jdk/com/sun/jdi/JITDebug.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -104,7 +104,7 @@ boolean parseArgs(String[] args) { } void testLaunch() { - ProcessBuilder pb = ProcessTools.createTestJvm(); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(); List largs = pb.command(); largs.add("-classpath"); largs.add(Utils.TEST_CLASSES); diff --git a/test/jdk/com/sun/jdi/NoLaunchOptionTest.java b/test/jdk/com/sun/jdi/NoLaunchOptionTest.java index 275b130bf967e..fca9d59196f2e 100644 --- a/test/jdk/com/sun/jdi/NoLaunchOptionTest.java +++ b/test/jdk/com/sun/jdi/NoLaunchOptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception { "onthrow=java.lang.ClassNotFoundException,suspend=n", "NotAClass" }); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmd); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmd); OutputAnalyzer output = ProcessTools.executeProcess(pb); System.out.println(output.getOutput()); diff --git a/test/jdk/com/sun/jdi/PrivateTransportTest.java b/test/jdk/com/sun/jdi/PrivateTransportTest.java index c12db8b90bed7..a023b8a752c6c 100644 --- a/test/jdk/com/sun/jdi/PrivateTransportTest.java +++ b/test/jdk/com/sun/jdi/PrivateTransportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ private void test() throws Throwable { String libName = transportLib.getFileName().toString().replace("dt_socket", "private_dt_socket"); Files.copy(transportLib, Paths.get(Utils.TEST_CLASSES).resolve(libName)); - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-agentlib:jdwp=transport=private_dt_socket,server=y,suspend=n", "-classpath", Utils.TEST_CLASSES, "HelloWorld"); diff --git a/test/jdk/com/sun/jdi/ProcessAttachTest.java b/test/jdk/com/sun/jdi/ProcessAttachTest.java index 04cc83205703e..746b5d047fe7c 100644 --- a/test/jdk/com/sun/jdi/ProcessAttachTest.java +++ b/test/jdk/com/sun/jdi/ProcessAttachTest.java @@ -69,7 +69,7 @@ public static void main(String[] args) throws Exception { } private static void runTest(String jdwpArg) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( jdwpArg, "ProcessAttachTestTarg"); Process p = null; diff --git a/test/jdk/com/sun/jdi/RunToExit.java b/test/jdk/com/sun/jdi/RunToExit.java index d5fd5d2b6f758..a7c7058b7aa92 100644 --- a/test/jdk/com/sun/jdi/RunToExit.java +++ b/test/jdk/com/sun/jdi/RunToExit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2021, 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 @@ -79,7 +79,7 @@ private static Process launch(String class_name) throws Exception { }; args = VMConnection.insertDebuggeeVMOptions(args); - ProcessBuilder launcher = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder launcher = ProcessTools.createLimitedTestJavaProcessBuilder(args); System.out.println(launcher.command().stream().collect(Collectors.joining(" ", "Starting: ", ""))); diff --git a/test/jdk/com/sun/jdi/cds/CDSJDITest.java b/test/jdk/com/sun/jdi/cds/CDSJDITest.java index 22abd30163fcb..0ec201d7035c1 100644 --- a/test/jdk/com/sun/jdi/cds/CDSJDITest.java +++ b/test/jdk/com/sun/jdi/cds/CDSJDITest.java @@ -39,7 +39,7 @@ public static void runTest(String testname, String[] jarClasses) throws Exceptio File jarClasslistFile = makeClassList(jarClasses); String appJar = buildJar(testname, jarClasses); - // These are the arguments passed to createJavaProcessBuilder() to launch + // These are the arguments passed to createLimitedTestJavaProcessBuilder() to launch // the JDI test. String[] testArgs = { // JVM Args: @@ -67,7 +67,7 @@ public static void runTest(String testname, String[] jarClasses) throws Exceptio }; // Dump the archive - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xbootclasspath/a:" + appJar, "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", "-XX:ExtraSharedClassListFile=" + jarClasslistFile.getPath(), @@ -80,7 +80,7 @@ public static void runTest(String testname, String[] jarClasses) throws Exceptio outputDump.shouldHaveExitValue(0); // Run the test specified JDI test - pb = ProcessTools.createTestJvm(testArgs); + pb = ProcessTools.createTestJavaProcessBuilder(testArgs); OutputAnalyzer outputRun = executeAndLog(pb, "exec"); try { outputRun.shouldContain("sharing"); diff --git a/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java b/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java index 8d6f840254d9a..709e5f0912a85 100644 --- a/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java +++ b/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java @@ -123,7 +123,7 @@ public ProcessBuilder prepare() { + onthrowArgs); debuggeeArgs.addAll(options); debuggeeArgs.add(mainClass); - return ProcessTools.createTestJvm(debuggeeArgs); + return ProcessTools.createTestJavaProcessBuilder(debuggeeArgs); } public Debuggee launch(String name) { diff --git a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java index 133ca19be74a7..d0557e630f082 100644 --- a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java +++ b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java @@ -60,7 +60,7 @@ public static void main(String... args) throws Exception { } ProcessBuilder pb = ProcessTools. - createJavaProcessBuilder( + createLimitedTestJavaProcessBuilder( "--add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED", "-XX:+UseG1GC", // this will cause MaxNewSize to be FLAG_SET_ERGO "-XX:+UseCodeCacheFlushing", diff --git a/test/jdk/com/sun/tools/attach/RunnerUtil.java b/test/jdk/com/sun/tools/attach/RunnerUtil.java index 92f1a951d07b2..120736de21b8e 100644 --- a/test/jdk/com/sun/tools/attach/RunnerUtil.java +++ b/test/jdk/com/sun/tools/attach/RunnerUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ public static ProcessThread startApplication(String... additionalOpts) throws Th "-Dattach.test=true", "-classpath", classpath, "Application" }); String[] args = Utils.addTestJavaOpts(myArgs); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); ProcessThread pt = new ProcessThread("runApplication", (line) -> line.equals(Application.READY_MSG), pb); pt.start(); return pt; diff --git a/test/jdk/java/awt/MenuBar/TestNoScreenMenuBar.java b/test/jdk/java/awt/MenuBar/TestNoScreenMenuBar.java index fb545ca8480b8..a903b31c5c4a0 100644 --- a/test/jdk/java/awt/MenuBar/TestNoScreenMenuBar.java +++ b/test/jdk/java/awt/MenuBar/TestNoScreenMenuBar.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 @@ -148,7 +148,7 @@ private void closeOtherApplication() { private Process execute() { try { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( TestNoScreenMenuBar.class.getSimpleName(), "mark"); return ProcessTools.startProcess("Other frame", pb); } catch (IOException ex) { diff --git a/test/jdk/java/awt/Robot/NonEmptyErrorStream.java b/test/jdk/java/awt/Robot/NonEmptyErrorStream.java index 87137ac74ed92..5bdada8aa5f19 100644 --- a/test/jdk/java/awt/Robot/NonEmptyErrorStream.java +++ b/test/jdk/java/awt/Robot/NonEmptyErrorStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public final class NonEmptyErrorStream { public static void main(String[] args) throws Exception { if (args.length == 0) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( NonEmptyErrorStream.class.getSimpleName(),"run"); Process p = pb.start(); OutputAnalyzer output = new OutputAnalyzer(p); diff --git a/test/jdk/java/awt/Toolkit/ScreenInsetsDPIVariation/ScreenInsetsDPIVariation.java b/test/jdk/java/awt/Toolkit/ScreenInsetsDPIVariation/ScreenInsetsDPIVariation.java index e089ef26ca909..244f8bb6bd733 100644 --- a/test/jdk/java/awt/Toolkit/ScreenInsetsDPIVariation/ScreenInsetsDPIVariation.java +++ b/test/jdk/java/awt/Toolkit/ScreenInsetsDPIVariation/ScreenInsetsDPIVariation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,7 @@ public static int clipRound(double coordinate) { private static void runProcess(String dpi, int screen, Insets insets) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Dsun.java2d.uiScale=" + dpi, ScreenInsetsDPIVariation.class.getSimpleName(), String.valueOf(screen), String.valueOf(insets.left), diff --git a/test/jdk/java/awt/Window/MainKeyWindowTest/TestMainKeyWindow.java b/test/jdk/java/awt/Window/MainKeyWindowTest/TestMainKeyWindow.java index 1b052f953a948..51ce7721ef77c 100644 --- a/test/jdk/java/awt/Window/MainKeyWindowTest/TestMainKeyWindow.java +++ b/test/jdk/java/awt/Window/MainKeyWindowTest/TestMainKeyWindow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, 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 @@ -149,7 +149,7 @@ private void performTest(Object windowIdentification, boolean selectColorPanel) private Process execute() { try { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( TestMainKeyWindow.class.getSimpleName(), "mark"); return ProcessTools.startProcess("Other frame", pb); } catch (IOException ex) { diff --git a/test/jdk/java/awt/Window/MinimumSizeDPIVariation/MinimumSizeDPIVariation.java b/test/jdk/java/awt/Window/MinimumSizeDPIVariation/MinimumSizeDPIVariation.java index f00564ff934d4..534f25c4cbb22 100644 --- a/test/jdk/java/awt/Window/MinimumSizeDPIVariation/MinimumSizeDPIVariation.java +++ b/test/jdk/java/awt/Window/MinimumSizeDPIVariation/MinimumSizeDPIVariation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,7 +110,7 @@ private static void checkAllDPI(String comp, int w, int h) private static void runProcess(String dpi, String comp, int w, int h) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Dsun.java2d.uiScale=" + dpi, MinimumSizeDPIVariation.class.getSimpleName(), comp, String.valueOf(w), String.valueOf(h), dpi); diff --git a/test/jdk/java/awt/color/ICC_ColorSpace/MTTransformReplacedProfile.java b/test/jdk/java/awt/color/ICC_ColorSpace/MTTransformReplacedProfile.java index 9694554ed4fdf..9a82c3c85c9b8 100644 --- a/test/jdk/java/awt/color/ICC_ColorSpace/MTTransformReplacedProfile.java +++ b/test/jdk/java/awt/color/ICC_ColorSpace/MTTransformReplacedProfile.java @@ -1,6 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,7 @@ public final class MTTransformReplacedProfile { public static void main(String[] args) throws Exception { if (args.length > 0 && args[0].equals("checkJNI")) { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-Xcheck:jni", MTTransformReplacedProfile.class.getName()); OutputAnalyzer oa = ProcessTools.executeProcess(pb); oa.stderrShouldBeEmpty(); diff --git a/test/jdk/java/awt/font/JNICheck/FreeTypeScalerJNICheck.java b/test/jdk/java/awt/font/JNICheck/FreeTypeScalerJNICheck.java index a71918c22972c..73c2770fba53e 100644 --- a/test/jdk/java/awt/font/JNICheck/FreeTypeScalerJNICheck.java +++ b/test/jdk/java/awt/font/JNICheck/FreeTypeScalerJNICheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, JetBrains s.r.o.. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -43,7 +43,7 @@ public static void main(String[] args) throws Exception { if (args.length > 0 && args[0].equals("runtest")) { runTest(); } else { - ProcessBuilder pb = ProcessTools.createTestJvm("-Xcheck:jni", FreeTypeScalerJNICheck.class.getName(), "runtest"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-Xcheck:jni", FreeTypeScalerJNICheck.class.getName(), "runtest"); OutputAnalyzer oa = ProcessTools.executeProcess(pb); oa.shouldContain("Done").shouldNotContain("WARNING").shouldHaveExitValue(0); } diff --git a/test/jdk/java/foreign/UpcallTestHelper.java b/test/jdk/java/foreign/UpcallTestHelper.java index 1c2ca8aee800e..2939c4bfd3747 100644 --- a/test/jdk/java/foreign/UpcallTestHelper.java +++ b/test/jdk/java/foreign/UpcallTestHelper.java @@ -63,7 +63,7 @@ public Output runInNewProcess(Class target, boolean useSpec, String... progra )); command.addAll(Arrays.asList(programArgs)); - Process process = ProcessTools.createTestJvm(command).start(); + Process process = ProcessTools.createTestJavaProcessBuilder(command).start(); int result = process.waitFor(); assertNotEquals(result, 0); diff --git a/test/jdk/java/io/Console/RedirectTest.java b/test/jdk/java/io/Console/RedirectTest.java index d7aa6c644688f..644ece9c3a232 100644 --- a/test/jdk/java/io/Console/RedirectTest.java +++ b/test/jdk/java/io/Console/RedirectTest.java @@ -40,7 +40,7 @@ public class RedirectTest { public static void main(String... args) throws Throwable { if (args.length == 0) { // no arg will launch the child process that actually perform tests - var pb = ProcessTools.createTestJvm( + var pb = ProcessTools.createTestJavaProcessBuilder( "-D" + SYSPROP + "=" + System.getProperty(SYSPROP, ""), "RedirectTest", "dummy"); var input = new File(System.getProperty("test.src", "."), "input.txt"); diff --git a/test/jdk/java/io/File/MacPath.java b/test/jdk/java/io/File/MacPath.java index a9d910187830f..751113b7fd8a6 100644 --- a/test/jdk/java/io/File/MacPath.java +++ b/test/jdk/java/io/File/MacPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ public class MacPath { public static void main(String args[]) throws Exception { final ProcessBuilder pb = - ProcessTools.createTestJvm(MacPathTest.class.getName()); + ProcessTools.createTestJavaProcessBuilder(MacPathTest.class.getName()); final Map env = pb.environment(); env.put("LC_ALL", "en_US.UTF-8"); Process p = ProcessTools.startProcess("Mac Path Test", pb); diff --git a/test/jdk/java/io/Serializable/class/NonSerializableTest.java b/test/jdk/java/io/Serializable/class/NonSerializableTest.java index b2ac4e933cbef..fa81b3e3ce737 100644 --- a/test/jdk/java/io/Serializable/class/NonSerializableTest.java +++ b/test/jdk/java/io/Serializable/class/NonSerializableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,7 @@ public void test(String[] args) throws Exception { Paths.get(System.getProperty("user.dir"))); assertTrue(b, "Compilation failed"); String params[] = Arrays.copyOfRange(args, 1, args.length); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(params); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(params); Process p = ProcessTools.startProcess("Serializable Test", pb); int exitValue = p.waitFor(); assertEquals(exitValue, 0, "Test failed"); diff --git a/test/jdk/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java b/test/jdk/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java index faccc09bb4bb3..bf51dc66c54d8 100644 --- a/test/jdk/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java +++ b/test/jdk/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,7 +81,7 @@ private static void setup() throws Exception { } private static void runTestSerialDriver() throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-classpath", SHARE.toString() + File.pathSeparator @@ -93,7 +93,7 @@ private static void runTestSerialDriver() throws Exception { } private static void runInstallSerialDriver() throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-classpath", SHARE.toString() + File.pathSeparator diff --git a/test/jdk/java/lang/ClassLoader/GetSystemPackage.java b/test/jdk/java/lang/ClassLoader/GetSystemPackage.java index 25967bca620d8..2af81f3c416f7 100644 --- a/test/jdk/java/lang/ClassLoader/GetSystemPackage.java +++ b/test/jdk/java/lang/ClassLoader/GetSystemPackage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -118,7 +118,7 @@ private static void buildJar(String name, Manifest man) throws Exception { private static void runSubProcess(String messageOnError, String ... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); int res = pb.directory(tmpFolder).inheritIO().start().waitFor(); if (res != 0) { throw new RuntimeException(messageOnError); diff --git a/test/jdk/java/lang/Object/InvalidFinalizationOption.java b/test/jdk/java/lang/Object/InvalidFinalizationOption.java index c5cca549ead09..f87ecfe9045b4 100644 --- a/test/jdk/java/lang/Object/InvalidFinalizationOption.java +++ b/test/jdk/java/lang/Object/InvalidFinalizationOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ record TestData(String arg, String expected) { } }; for (var data : testData) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(data.arg); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(data.arg); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain(data.expected); output.shouldHaveExitValue(1); diff --git a/test/jdk/java/lang/ProcessBuilder/InheritIOTest.java b/test/jdk/java/lang/ProcessBuilder/InheritIOTest.java index 340507cb37b56..f1c1940f5388c 100644 --- a/test/jdk/java/lang/ProcessBuilder/InheritIOTest.java +++ b/test/jdk/java/lang/ProcessBuilder/InheritIOTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ public Object[][] testCases() { @Test(dataProvider = "testCases") public void testInheritWithoutRedirect(List arguments) throws Throwable { - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(arguments); + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(arguments); OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(processBuilder); outputAnalyzer.shouldHaveExitValue(0); assertEquals(outputAnalyzer.getStdout(), EXPECTED_RESULT_STDOUT); diff --git a/test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java b/test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java index d82a317148e72..00543b0994768 100644 --- a/test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java +++ b/test/jdk/java/lang/ProcessBuilder/JspawnhelperProtocol.java @@ -78,9 +78,9 @@ private static void parentCode(String arg) throws IOException, InterruptedExcept private static void normalExec() throws Exception { ProcessBuilder pb; - pb = ProcessTools.createJavaProcessBuilder("-Djdk.lang.Process.launchMechanism=posix_spawn", - "JspawnhelperProtocol", - "normalExec"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Djdk.lang.Process.launchMechanism=posix_spawn", + "JspawnhelperProtocol", + "normalExec"); pb.inheritIO(); Process p = pb.start(); if (!p.waitFor(TIMEOUT, TimeUnit.SECONDS)) { @@ -93,9 +93,9 @@ private static void normalExec() throws Exception { private static void simulateCrashInChild(int stage) throws Exception { ProcessBuilder pb; - pb = ProcessTools.createJavaProcessBuilder("-Djdk.lang.Process.launchMechanism=posix_spawn", - "JspawnhelperProtocol", - "simulateCrashInChild" + stage); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Djdk.lang.Process.launchMechanism=posix_spawn", + "JspawnhelperProtocol", + "simulateCrashInChild" + stage); pb.environment().put(ENV_KEY, Integer.toString(stage)); Process p = pb.start(); @@ -126,9 +126,9 @@ private static void simulateCrashInChild(int stage) throws Exception { private static void simulateCrashInParent(int stage) throws Exception { ProcessBuilder pb; - pb = ProcessTools.createJavaProcessBuilder("-Djdk.lang.Process.launchMechanism=posix_spawn", - "JspawnhelperProtocol", - "simulateCrashInParent" + stage); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Djdk.lang.Process.launchMechanism=posix_spawn", + "JspawnhelperProtocol", + "simulateCrashInParent" + stage); pb.environment().put(ENV_KEY, Integer.toString(stage)); Process p = pb.start(); @@ -172,9 +172,9 @@ private static void simulateCrashInParent(int stage) throws Exception { private static void simulateTruncatedWriteInParent(int stage) throws Exception { ProcessBuilder pb; - pb = ProcessTools.createJavaProcessBuilder("-Djdk.lang.Process.launchMechanism=posix_spawn", - "JspawnhelperProtocol", - "simulateTruncatedWriteInParent" + stage); + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Djdk.lang.Process.launchMechanism=posix_spawn", + "JspawnhelperProtocol", + "simulateTruncatedWriteInParent" + stage); pb.environment().put(ENV_KEY, Integer.toString(stage)); Process p = pb.start(); diff --git a/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java b/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java index efe4f842c7f4b..3768b34ea536b 100644 --- a/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java +++ b/test/jdk/java/lang/ProcessBuilder/ReaderWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ void testCaseNativeEncoding() throws IOException { Charset cs = Charset.forName(nativeEncoding); System.out.println("Native.encoding Charset: " + cs); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("ReaderWriterTest$ChildWithCharset"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("ReaderWriterTest$ChildWithCharset"); Process p = pb.start(); writeTestChars(p.outputWriter()); checkReader(p.inputReader(), cs, "Out"); @@ -121,7 +121,7 @@ void testRedirects() throws IOException { // 2: redirectErrorStream(true); no redirect of errorOutput // 3: redirectErrorStream(true); redirect of errorOutput to a file - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("ReaderWriterTest$ChildWithCharset"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("ReaderWriterTest$ChildWithCharset"); pb.redirectInput(inPath.toFile()); pb.redirectOutput(outPath.toFile()); if (errType == 1 || errType == 3) { @@ -191,7 +191,7 @@ void testCase(String encoding) throws IOException { } String cleanCSName = cleanCharsetName(cs); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Dsun.stdout.encoding=" + cleanCSName, // Encode in the child using the charset "-Dsun.stderr.encoding=" + cleanCSName, "ReaderWriterTest$ChildWithCharset"); @@ -217,7 +217,7 @@ void testCase(String encoding) throws IOException { @Test void testNullCharsets() throws IOException { // Launch a child; its behavior is not interesting and is ignored - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "ReaderWriterTest$ChildWithCharset"); Process p = pb.start(); @@ -263,7 +263,7 @@ void testIllegalArgCharsets() throws IOException { : StandardCharsets.UTF_8; // Launch a child; its behavior is not interesting and is ignored - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "ReaderWriterTest$ChildWithCharset"); Process p = pb.start(); diff --git a/test/jdk/java/lang/RuntimeTests/shutdown/ShutdownInterruptedMain.java b/test/jdk/java/lang/RuntimeTests/shutdown/ShutdownInterruptedMain.java index e141fc3521237..85040e9548e28 100644 --- a/test/jdk/java/lang/RuntimeTests/shutdown/ShutdownInterruptedMain.java +++ b/test/jdk/java/lang/RuntimeTests/shutdown/ShutdownInterruptedMain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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,14 +31,14 @@ */ import jdk.test.lib.process.OutputAnalyzer; -import static jdk.test.lib.process.ProcessTools.createTestJvm; +import static jdk.test.lib.process.ProcessTools.createTestJavaProcessBuilder; import static jdk.test.lib.process.ProcessTools.executeProcess; public class ShutdownInterruptedMain { public static void main(String[] args) throws Exception { if (args.length > 0) { - ProcessBuilder pb = createTestJvm("ShutdownInterruptedMain"); + ProcessBuilder pb = createTestJavaProcessBuilder("ShutdownInterruptedMain"); OutputAnalyzer output = executeProcess(pb); output.shouldContain("Shutdown Hook"); output.shouldHaveExitValue(0); diff --git a/test/jdk/java/lang/SecurityManager/modules/CustomSecurityManagerTest.java b/test/jdk/java/lang/SecurityManager/modules/CustomSecurityManagerTest.java index bb346f04b2a73..92b9e44f8920b 100644 --- a/test/jdk/java/lang/SecurityManager/modules/CustomSecurityManagerTest.java +++ b/test/jdk/java/lang/SecurityManager/modules/CustomSecurityManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,7 @@ public Object[][] testCases() { @Test(dataProvider = "testCases") public void testProvider(List args) throws Throwable { - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(args); OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(processBuilder); outputAnalyzer.shouldHaveExitValue(0); } diff --git a/test/jdk/java/lang/StackWalker/CallerFromMain.java b/test/jdk/java/lang/StackWalker/CallerFromMain.java index 3cb599c685976..86e7cfb7043da 100644 --- a/test/jdk/java/lang/StackWalker/CallerFromMain.java +++ b/test/jdk/java/lang/StackWalker/CallerFromMain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public class CallerFromMain { private static final StackWalker sw = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); public static void main(String[] args) throws Exception { if (args.length > 0) { - ProcessBuilder pb = ProcessTools.createTestJvm("CallerFromMain"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("CallerFromMain"); OutputAnalyzer output = ProcessTools.executeProcess(pb); System.out.println(output.getOutput()); output.shouldHaveExitValue(0); diff --git a/test/jdk/java/lang/System/FileEncodingTest.java b/test/jdk/java/lang/System/FileEncodingTest.java index 6bff90ccb8b2b..1e41194a29b74 100644 --- a/test/jdk/java/lang/System/FileEncodingTest.java +++ b/test/jdk/java/lang/System/FileEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,7 @@ public void testFileEncodingToDefault(String fileEncoding, String expected) thro var cmds = fileEncoding.isEmpty() ? List.of(FileEncodingTest.class.getName(), expected) : List.of("-Dfile.encoding=" + fileEncoding, FileEncodingTest.class.getName(), expected); - var pb = ProcessTools.createTestJvm(cmds); + var pb = ProcessTools.createTestJavaProcessBuilder(cmds); var env = pb.environment(); env.put("LANG", "C"); env.put("LC_ALL", "C"); diff --git a/test/jdk/java/lang/System/MacEncoding/MacJNUEncoding.java b/test/jdk/java/lang/System/MacEncoding/MacJNUEncoding.java index a962bbb7002fa..a58686871d5ce 100644 --- a/test/jdk/java/lang/System/MacEncoding/MacJNUEncoding.java +++ b/test/jdk/java/lang/System/MacEncoding/MacJNUEncoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,7 @@ public static void main(String[] args) throws Exception { var cmds = (args.length == 4) ? List.of("-Dfile.encoding=" + args[3], ExpectedEncoding.class.getName(), args[0], args[1]) : List.of(ExpectedEncoding.class.getName(), args[0], args[1]); - ProcessBuilder pb = ProcessTools.createTestJvm(cmds); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(cmds); Map env = pb.environment(); env.put("LANG", locale); env.put("LC_ALL", locale); diff --git a/test/jdk/java/lang/System/i18nEnvArg.java b/test/jdk/java/lang/System/i18nEnvArg.java index 776ea19f6539b..ba9d31cb37323 100644 --- a/test/jdk/java/lang/System/i18nEnvArg.java +++ b/test/jdk/java/lang/System/i18nEnvArg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,7 +80,7 @@ public static void main(String[] args) throws Exception { "i18nEnvArg$Verify", EUC_JP_TEXT)); } - pb = ProcessTools.createTestJvm(cmds); + pb = ProcessTools.createTestJavaProcessBuilder(cmds); Map environ = pb.environment(); environ.clear(); environ.put("LANG", "ja_JP.eucjp"); diff --git a/test/jdk/java/lang/Thread/UncaughtExceptionsTest.java b/test/jdk/java/lang/Thread/UncaughtExceptionsTest.java index e53c370e7f798..42d85593088ed 100644 --- a/test/jdk/java/lang/Thread/UncaughtExceptionsTest.java +++ b/test/jdk/java/lang/Thread/UncaughtExceptionsTest.java @@ -85,7 +85,7 @@ private static Stream testCases() { @MethodSource("testCases") void test(String className, int exitValue, String stdOutMatch, String stdErrMatch) throws Throwable { String cmd = "UncaughtExitSimulator$" + className; - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(cmd); + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(cmd); OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(processBuilder); outputAnalyzer.shouldHaveExitValue(exitValue); outputAnalyzer.stderrShouldMatch(stdErrMatch); diff --git a/test/jdk/java/lang/Thread/virtual/ShutdownHook.java b/test/jdk/java/lang/Thread/virtual/ShutdownHook.java index 84c59dcc82f5b..a30d3d295dda6 100644 --- a/test/jdk/java/lang/Thread/virtual/ShutdownHook.java +++ b/test/jdk/java/lang/Thread/virtual/ShutdownHook.java @@ -29,14 +29,14 @@ */ import jdk.test.lib.process.OutputAnalyzer; -import static jdk.test.lib.process.ProcessTools.createTestJvm; +import static jdk.test.lib.process.ProcessTools.createTestJavaProcessBuilder; import static jdk.test.lib.process.ProcessTools.executeProcess; public class ShutdownHook { public static void main(String[] args) throws Exception { if (args.length > 0) { - ProcessBuilder pb = createTestJvm("ShutdownHook"); + ProcessBuilder pb = createTestJavaProcessBuilder("ShutdownHook"); OutputAnalyzer output = executeProcess(pb); output.shouldContain("Shutdown Hook"); output.shouldHaveExitValue(0); diff --git a/test/jdk/java/lang/annotation/LoaderLeakTest.java b/test/jdk/java/lang/annotation/LoaderLeakTest.java index e5e0a8d61c445..ed230d8df0ea5 100644 --- a/test/jdk/java/lang/annotation/LoaderLeakTest.java +++ b/test/jdk/java/lang/annotation/LoaderLeakTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2021, 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 @@ -55,7 +55,7 @@ public void testWithReadingAnnotations() throws Throwable { } private void runJavaProcessExpectSuccessExitCode(String ... command) throws Throwable { - var processBuilder = ProcessTools.createJavaProcessBuilder(command) + var processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder(command) .directory(Paths.get(Utils.TEST_CLASSES).toFile()); ProcessTools.executeCommand(processBuilder).shouldHaveExitValue(0); } diff --git a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java index 728fc5d17abbd..697ca7366a0cd 100644 --- a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java +++ b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java @@ -1,6 +1,6 @@ /* * Copyright 2014 Goldman Sachs. - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ public class TestDaemonThreadLauncher { public static void main(String args[]) throws Exception { for(int i=0; i<50; i++) { - ProcessBuilder pb = ProcessTools.createTestJvm("-javaagent:DummyAgent.jar", "TestDaemonThread", "."); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", "."); OutputAnalyzer analyzer = ProcessTools.executeProcess(pb); analyzer.shouldNotContain("ASSERTION FAILED"); analyzer.shouldHaveExitValue(0); diff --git a/test/jdk/java/lang/instrument/NegativeAgentRunner.java b/test/jdk/java/lang/instrument/NegativeAgentRunner.java index 1b7ff2f73359d..9689c323114d1 100644 --- a/test/jdk/java/lang/instrument/NegativeAgentRunner.java +++ b/test/jdk/java/lang/instrument/NegativeAgentRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ public static void main(String argv[]) throws Exception { } String agentClassName = argv[0]; String excepClassName = argv[1]; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-javaagent:" + agentClassName + ".jar", "-Xmx128m", "-XX:-CreateCoredumpOnCrash", agentClassName); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java b/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java index b59b69d3c75df..ecd284fe6e0c1 100644 --- a/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java +++ b/test/jdk/java/lang/instrument/PremainClass/PremainClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ public static void main(String[] a) throws Exception { System.getProperty("test.src"), System.getProperty("test.classes", ".")); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( Utils.addTestJavaOpts(testArgs.split("\\s+"))); System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb)); diff --git a/test/jdk/java/lang/invoke/condy/CondyNestedResolutionTest.java b/test/jdk/java/lang/invoke/condy/CondyNestedResolutionTest.java index b5dd8befa48b9..914e90650daf5 100644 --- a/test/jdk/java/lang/invoke/condy/CondyNestedResolutionTest.java +++ b/test/jdk/java/lang/invoke/condy/CondyNestedResolutionTest.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 @@ -44,7 +44,7 @@ */ public class CondyNestedResolutionTest { public static void main(String args[]) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("CondyNestedResolution"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("CondyNestedResolution"); OutputAnalyzer oa = new OutputAnalyzer(pb.start()); oa.shouldContain("StackOverflowError"); oa.shouldContain("bsm1arg"); diff --git a/test/jdk/java/nio/channels/Selector/LotsOfUpdatesTest.java b/test/jdk/java/nio/channels/Selector/LotsOfUpdatesTest.java index ef2c389ef3948..86c3c828f70e0 100644 --- a/test/jdk/java/nio/channels/Selector/LotsOfUpdatesTest.java +++ b/test/jdk/java/nio/channels/Selector/LotsOfUpdatesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ public class LotsOfUpdatesTest { private static final String ULIMIT_SET_CMD = "ulimit -n 2048"; private static final String JAVA_CMD = ProcessTools.getCommandLine( - ProcessTools.createJavaProcessBuilder(LotsOfUpdates.class.getName())); + ProcessTools.createLimitedTestJavaProcessBuilder(LotsOfUpdates.class.getName())); public static void main(String[] args) throws Throwable { ProcessTools.executeCommand("sh", "-c", ULIMIT_SET_CMD + " && " + JAVA_CMD) diff --git a/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java b/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java index 9ea2902fb0de8..be33ecb70f2ae 100644 --- a/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java +++ b/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ public class DefaultCharsetTest { private static final ProcessBuilder pb - = ProcessTools.createTestJvm(Default.class.getName()); + = ProcessTools.createTestJavaProcessBuilder(Default.class.getName()); private static final Map env = pb.environment(); private static String UNSUPPORTED = null; diff --git a/test/jdk/java/nio/file/Path/MacPathTest.java b/test/jdk/java/nio/file/Path/MacPathTest.java index d3b37aa978ddf..7563e30338ca5 100644 --- a/test/jdk/java/nio/file/Path/MacPathTest.java +++ b/test/jdk/java/nio/file/Path/MacPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,9 +49,9 @@ public static void main(String args[]) throws Exception { ProcessBuilder pb; if (NORMALIZE_FILE_PATHS) { String option = "-D" + PROPERTY_NORMALIZE_FILE_PATHS + "=true"; - pb = ProcessTools.createTestJvm(option, MacPath.class.getName()); + pb = ProcessTools.createTestJavaProcessBuilder(option, MacPath.class.getName()); } else { - pb = ProcessTools.createTestJvm(MacPath.class.getName()); + pb = ProcessTools.createTestJavaProcessBuilder(MacPath.class.getName()); } pb.environment().put("LC_ALL", "en_US.UTF-8"); ProcessTools.executeProcess(pb) diff --git a/test/jdk/java/security/SignedJar/SignedJarWithCustomClassLoader.java b/test/jdk/java/security/SignedJar/SignedJarWithCustomClassLoader.java index 1f335c87f1495..540990bc82a7a 100644 --- a/test/jdk/java/security/SignedJar/SignedJarWithCustomClassLoader.java +++ b/test/jdk/java/security/SignedJar/SignedJarWithCustomClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ public static void main(String[] args) {} .shouldHaveExitValue(0); // run app with system class loader set to custom classloader - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-cp", "signed.jar", "-Djava.system.class.loader=CustomClassLoader", "Main"); ProcessTools.executeProcess(pb) @@ -85,7 +85,7 @@ public static void main(String[] args) {} .shouldHaveExitValue(0); // run app again, should still succeed even though SHA-1 is disabled - pb = ProcessTools.createJavaProcessBuilder( + pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-cp", "signed.jar", "-Djava.system.class.loader=CustomClassLoader", "Main"); ProcessTools.executeProcess(pb) diff --git a/test/jdk/java/util/Formatter/BasicTestLauncher.java b/test/jdk/java/util/Formatter/BasicTestLauncher.java index 0b37acfd944ae..4dfc0e3674305 100644 --- a/test/jdk/java/util/Formatter/BasicTestLauncher.java +++ b/test/jdk/java/util/Formatter/BasicTestLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ void testTimeZone(String timeZone) throws IOException{ */ private static OutputAnalyzer RunTest(String timeZone) throws IOException{ // Build and run Basic class with correct configuration - ProcessBuilder pb = ProcessTools.createTestJvm(JAVA_OPTS, TEST_CLASS); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(JAVA_OPTS, TEST_CLASS); pb.environment().put("TZ", timeZone); Process process = pb.start(); return new OutputAnalyzer(process); diff --git a/test/jdk/java/util/Properties/StoreReproducibilityTest.java b/test/jdk/java/util/Properties/StoreReproducibilityTest.java index c19657923be98..b77f3262a4ae3 100644 --- a/test/jdk/java/util/Properties/StoreReproducibilityTest.java +++ b/test/jdk/java/util/Properties/StoreReproducibilityTest.java @@ -92,7 +92,7 @@ private static void testWithoutSecurityManager() throws Exception { for (int i = 0; i < 5; i++) { final Path tmpFile = Files.createTempFile("8231640", ".props"); storedFiles.add(tmpFile); - final ProcessBuilder processBuilder = ProcessTools.createTestJvm( + final ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder( "-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal, StoreTest.class.getName(), tmpFile.toString(), @@ -134,7 +134,7 @@ private static void testWithSecMgrExplicitPermission() throws Exception { for (int i = 0; i < 5; i++) { final Path tmpFile = Files.createTempFile("8231640", ".props"); storedFiles.add(tmpFile); - final ProcessBuilder processBuilder = ProcessTools.createTestJvm( + final ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder( "-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal, "-Djava.security.manager", "-Djava.security.policy=" + policyFile, @@ -178,7 +178,7 @@ private static void testWithSecMgrNoSpecificPermission() throws Exception { for (int i = 0; i < 5; i++) { final Path tmpFile = Files.createTempFile("8231640", ".props"); storedFiles.add(tmpFile); - final ProcessBuilder processBuilder = ProcessTools.createTestJvm( + final ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder( "-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal, "-Djava.security.manager", "-Djava.security.policy=" + policyFile, @@ -208,7 +208,7 @@ private static void testBlankSysPropValue() throws Exception { for (int i = 0; i < 2; i++) { final Path tmpFile = Files.createTempFile("8231640", ".props"); storedFiles.add(tmpFile); - final ProcessBuilder processBuilder = ProcessTools.createTestJvm( + final ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder( "-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal, StoreTest.class.getName(), tmpFile.toString(), @@ -240,7 +240,7 @@ private static void testBlankSysPropValue() throws Exception { private static void testEmptySysPropValue() throws Exception { for (int i = 0; i < 2; i++) { final Path tmpFile = Files.createTempFile("8231640", ".props"); - final ProcessBuilder processBuilder = ProcessTools.createTestJvm( + final ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder( "-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=", "-Duser.timezone=UTC", StoreTest.class.getName(), @@ -272,7 +272,7 @@ private static void testNonDateSysPropValue() throws Exception { for (int i = 0; i < 2; i++) { final Path tmpFile = Files.createTempFile("8231640", ".props"); storedFiles.add(tmpFile); - final ProcessBuilder processBuilder = ProcessTools.createTestJvm( + final ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder( "-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal, StoreTest.class.getName(), tmpFile.toString(), @@ -301,7 +301,7 @@ private static void testMultiLineSysPropValue() throws Exception { for (int i = 0; i < 2; i++) { final Path tmpFile = Files.createTempFile("8231640", ".props"); storedFiles.add(tmpFile); - final ProcessBuilder processBuilder = ProcessTools.createTestJvm( + final ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder( "-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal, StoreTest.class.getName(), tmpFile.toString(), @@ -343,7 +343,7 @@ private static void testBackSlashInSysPropValue() throws Exception { for (int i = 0; i < 2; i++) { final Path tmpFile = Files.createTempFile("8231640", ".props"); storedFiles.add(tmpFile); - final ProcessBuilder processBuilder = ProcessTools.createTestJvm( + final ProcessBuilder processBuilder = ProcessTools.createTestJavaProcessBuilder( "-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal, StoreTest.class.getName(), tmpFile.toString(), diff --git a/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java b/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java index 28afa8f49e1bb..ece90a9d7cd5e 100644 --- a/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java +++ b/test/jdk/java/util/TimeZone/CustomTzIDCheckDST.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ public class CustomTzIDCheckDST { private static String CUSTOM_TZ2 = "MEZ-1MESZ,M10.5.0,M3.5.0/3"; public static void main(String args[]) throws Throwable { if (args.length == 0) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(List.of("CustomTzIDCheckDST", "runTZTest")); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(List.of("CustomTzIDCheckDST", "runTZTest")); pb.environment().put("TZ", CUSTOM_TZ); OutputAnalyzer output = ProcessTools.executeProcess(pb); output.shouldHaveExitValue(0); diff --git a/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java b/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java index 603e2890a0e4f..8645e6ff86aca 100644 --- a/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java +++ b/test/jdk/javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java @@ -280,7 +280,7 @@ private static void testDefaultAgent(String propertyFile, String additionalArgum } pbArgs.add(TEST_APP_NAME); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( pbArgs.toArray(new String[pbArgs.size()]) ); diff --git a/test/jdk/javax/management/security/HashedPasswordFileTest.java b/test/jdk/javax/management/security/HashedPasswordFileTest.java index e2d5bd7deb6f1..7a3f02bc7c845 100644 --- a/test/jdk/javax/management/security/HashedPasswordFileTest.java +++ b/test/jdk/javax/management/security/HashedPasswordFileTest.java @@ -439,7 +439,7 @@ public void testDefaultAgent() throws Exception { pbArgs.add("jdk.management.agent/jdk.internal.agent=ALL-UNNAMED"); pbArgs.add(TestApp.class.getSimpleName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( pbArgs.toArray(new String[0])); Process process = ProcessTools.startProcess( TestApp.class.getSimpleName(), @@ -481,7 +481,7 @@ public void testDefaultAgentNoHash() throws Exception { pbArgs.add("jdk.management.agent/jdk.internal.agent=ALL-UNNAMED"); pbArgs.add(TestApp.class.getSimpleName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( pbArgs.toArray(new String[0])); Process process = ProcessTools.startProcess( TestApp.class.getSimpleName(), diff --git a/test/jdk/javax/net/ssl/TLSCommon/interop/ProcUtils.java b/test/jdk/javax/net/ssl/TLSCommon/interop/ProcUtils.java index 10cb3d68856f6..de27f538f7066 100644 --- a/test/jdk/javax/net/ssl/TLSCommon/interop/ProcUtils.java +++ b/test/jdk/javax/net/ssl/TLSCommon/interop/ProcUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class ProcUtils { */ public static OutputAnalyzer java(Path javaPath, Class clazz, Map props) { - ProcessBuilder pb = createJavaProcessBuilder(javaPath, clazz, props); + ProcessBuilder pb = createLimitedTestJavaProcessBuilder(javaPath, clazz, props); try { return ProcessTools.executeCommand(pb); } catch (Throwable e) { @@ -50,7 +50,7 @@ public static OutputAnalyzer java(Path javaPath, Class clazz, } } - private static ProcessBuilder createJavaProcessBuilder(Path javaPath, + private static ProcessBuilder createLimitedTestJavaProcessBuilder(Path javaPath, Class clazz, Map props) { List cmds = new ArrayList<>(); cmds.add(javaPath.toString()); diff --git a/test/jdk/javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java b/test/jdk/javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java index c2d413cff251e..c3bb610bb871e 100644 --- a/test/jdk/javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java +++ b/test/jdk/javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMemoryLeaks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -224,7 +224,7 @@ private static void test(Object[] listeners) { } private static Process runProcess(LookAndFeelInfo laf) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Dswing.defaultlaf=" + laf.getClassName(), "-mx9m", "-XX:+HeapDumpOnOutOfMemoryError", UnninstallUIMemoryLeaks.class.getSimpleName(), "mark"); diff --git a/test/jdk/javax/swing/text/html/CSS/bug8234913.java b/test/jdk/javax/swing/text/html/CSS/bug8234913.java index cf4c43d75316a..bd74fbaeb93bb 100644 --- a/test/jdk/javax/swing/text/html/CSS/bug8234913.java +++ b/test/jdk/javax/swing/text/html/CSS/bug8234913.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -52,7 +52,7 @@ static ProcessBuilder exec(String... args) throws Exception { Collections.addAll(argsList, "-Xmn8m"); Collections.addAll(argsList, "-Dtest.class.path=" + System.getProperty("test.class.path", ".")); Collections.addAll(argsList, FontSizePercentTest.class.getName()); - return ProcessTools.createJavaProcessBuilder(argsList.toArray(new String[argsList.size()])); + return ProcessTools.createLimitedTestJavaProcessBuilder(argsList.toArray(new String[argsList.size()])); } static void checkFor(String... outputStrings) throws Exception { diff --git a/test/jdk/jdk/incubator/vector/LoadJsvmlTest.java b/test/jdk/jdk/incubator/vector/LoadJsvmlTest.java index 355201bfbf331..e6e613bbc90b7 100644 --- a/test/jdk/jdk/incubator/vector/LoadJsvmlTest.java +++ b/test/jdk/jdk/incubator/vector/LoadJsvmlTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ public static void main(String[] args) throws Exception { } public static void main(String... args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xmn8m", "-Xlog:library=info", "--add-modules=jdk.incubator.vector", VectorTest.class.getName()); diff --git a/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java b/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java index 90d3be1f7df83..c48de900ec3ec 100644 --- a/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java +++ b/test/jdk/jdk/internal/misc/VM/RuntimeArguments.java @@ -117,7 +117,7 @@ public void test(List args, List expected) throws Exception { Stream options = Stream.concat(args.stream(), Stream.of("-classpath", TEST_CLASSES, "RuntimeArguments")); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( // The runtime image may be created with jlink --add-options // The initial VM options will be included in the result // returned by VM.getRuntimeArguments() diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/Application.java b/test/jdk/jdk/jfr/api/consumer/streaming/Application.java index 6cc7876a7cb9b..fea8347ceafe2 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/Application.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/Application.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,7 @@ public void start() throws IOException { args[2] = Application.class.getName(); args[3] = lockFile.toString(); args[4] = message; - ProcessBuilder pb = ProcessTools.createTestJvm(args); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(args); touch(lockFile); process = pb.start(); // For debugging diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java index 75885d508766f..313b5f026e1e2 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,7 +127,7 @@ static class EventProducer { static Process start() throws Exception { String[] args = {"-XX:StartFlightRecording", EventProducer.class.getName()}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); return ProcessTools.startProcess("Event-Producer", pb, line -> line.contains(MAIN_STARTED), 0, TimeUnit.SECONDS); diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java index 8643ec35bc243..dbbdbe9c67db2 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,7 +66,7 @@ public TestProcess(String name, boolean createCore) throws IOException { "-XX:" + (createCore ? "+" : "-") + "CreateCoredumpOnCrash", TestProcess.class.getName(), path.toString() }; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(args); process = ProcessTools.startProcess(name, pb); } diff --git a/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java b/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java index 67962399569b7..d347378b6063d 100644 --- a/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java +++ b/test/jdk/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ public static void main(String[] args) throws Exception { "-Xms32m", "-Xmx64m", Tester.class.getName()}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(jvm_args); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(jvm_args); OutputAnalyzer analyzer = ProcessTools.executeProcess(pb); analyzer.shouldHaveExitValue(0); } diff --git a/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java b/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java index aa8cdbbf662d4..d8fd9a6e67344 100644 --- a/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java +++ b/test/jdk/jdk/jfr/event/os/TestInitialEnvironmentVariable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -48,7 +48,7 @@ public class TestInitialEnvironmentVariable { private final static String EVENT_NAME = EventNames.InitialEnvironmentVariable; public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(Test.class.getName()); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(Test.class.getName()); setEnv(pb.environment()); (new OutputAnalyzer(pb.start())).shouldHaveExitValue(0); } diff --git a/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java b/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java index 4282c1afffb50..83af0de239d3d 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java +++ b/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,7 +89,7 @@ private static void test(Class crasher, String reason) throws Exception { private static long runProcess(Class crasher) throws Exception { System.out.println("Test case for " + crasher.getName()); - Process p = ProcessTools.createTestJvm( + Process p = ProcessTools.createTestJavaProcessBuilder( "-Xmx64m", "-XX:-CreateCoredumpOnCrash", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", diff --git a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java index 26d725781704f..d680dde023d7a 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java @@ -89,7 +89,7 @@ public static void main(String[] args) throws Throwable { } private static void runSubtest(int subTestIndex) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-Xlog:jfr=debug", "-XX:-CreateCoredumpOnCrash", "-XX:-TieredCompilation", diff --git a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java index 374e23ecb488a..29e21ddd89d7d 100644 --- a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java +++ b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java @@ -131,7 +131,7 @@ private static long runProcess(Class crasher, String signal, boolean disk, St } options.add(crasher.getName()); options.add(signal); - Process p = ProcessTools.createTestJvm(options).start(); + Process p = ProcessTools.createTestJavaProcessBuilder(options).start(); OutputAnalyzer output = new OutputAnalyzer(p); System.out.println("========== Crasher process output:"); diff --git a/test/jdk/jdk/jfr/jvm/TestEventWriterLog.java b/test/jdk/jdk/jfr/jvm/TestEventWriterLog.java index e152b00acae93..9e68d0501dfd9 100644 --- a/test/jdk/jdk/jfr/jvm/TestEventWriterLog.java +++ b/test/jdk/jdk/jfr/jvm/TestEventWriterLog.java @@ -35,7 +35,7 @@ public class TestEventWriterLog { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:jfr+system+bytecode=trace", "-XX:StartFlightRecording", "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-Xlog:jfr+system+bytecode=trace", "-XX:StartFlightRecording", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("superclass: jdk/jfr/events/AbstractJDKEvent"); } diff --git a/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java b/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java index 9156ffb6b66ac..50514e0202441 100644 --- a/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java +++ b/test/jdk/jdk/jfr/startupargs/TestBadOptionValues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -54,7 +54,7 @@ private static void test(String prepend, String expectedOutput, String... option Asserts.assertGreaterThan(options.length, 0); for (String option : options) { - pb = ProcessTools.createJavaProcessBuilder(prepend + option, "-version"); + pb = ProcessTools.createLimitedTestJavaProcessBuilder(prepend + option, "-version"); output = new OutputAnalyzer(pb.start()); output.shouldContain(expectedOutput); } diff --git a/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java b/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java index 454bbb631ad99..eaf325a779d64 100644 --- a/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java +++ b/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,7 +92,7 @@ private static Path findJFRFileInCurrentDirectory() { } private static void testDumponExit(Supplier p,String... args) throws Exception, IOException { - ProcessBuilder pb = ProcessTools.createTestJvm(args); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(args); OutputAnalyzer output = ProcessTools.executeProcess(pb); System.out.println(output.getOutput()); output.shouldHaveExitValue(0); diff --git a/test/jdk/jdk/jfr/startupargs/TestJFCWarnings.java b/test/jdk/jdk/jfr/startupargs/TestJFCWarnings.java index 139ab8385d749..cf0cb0212169b 100644 --- a/test/jdk/jdk/jfr/startupargs/TestJFCWarnings.java +++ b/test/jdk/jdk/jfr/startupargs/TestJFCWarnings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ private static void testUnknownOption() throws Exception { } private static void launch(String commandLine, String expectedOutput) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(commandLine, "-version"); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(commandLine, "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain(expectedOutput); } diff --git a/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java b/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java index baa56bbddc9e4..9c90d04691ab1 100644 --- a/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java +++ b/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -483,19 +483,19 @@ private static void launchTestVM(TestCase tc) throws Exception { final String flightRecorderOptions = tc.getTestString(); ProcessBuilder pb; if (flightRecorderOptions != null) { - pb = ProcessTools.createTestJvm("--add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED", - "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", - flightRecorderOptions, - "-XX:StartFlightRecording", - SUT.class.getName(), - tc.getTestName()); + pb = ProcessTools.createTestJavaProcessBuilder("--add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", + flightRecorderOptions, + "-XX:StartFlightRecording", + SUT.class.getName(), + tc.getTestName()); } else { // default, no FlightRecorderOptions passed - pb = ProcessTools.createTestJvm("--add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED", - "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", - "-XX:StartFlightRecording", - SUT.class.getName(), - tc.getTestName()); + pb = ProcessTools.createTestJavaProcessBuilder("--add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", + "-XX:StartFlightRecording", + SUT.class.getName(), + tc.getTestName()); } System.out.println("Driver launching SUT with string: " + flightRecorderOptions != null ? flightRecorderOptions : "default"); diff --git a/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java b/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java index e8cbff2dfd393..24be874a87f60 100644 --- a/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java +++ b/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.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 @@ -55,14 +55,14 @@ private static void test(ProcessBuilder pb, String... expectedOutputs) throws Ex private static void launchUnary(String options) throws Exception { String recording1 = START_FLIGHT_RECORDING + (options != null ? options : ""); - ProcessBuilder pb = ProcessTools.createTestJvm(recording1, MainClass.class.getName()); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(recording1, MainClass.class.getName()); test(pb, "Started recording 1"); } private static void launchBinary(String options1, String options2) throws Exception { String recording1 = START_FLIGHT_RECORDING + (options1 != null ? options1 : ""); String recording2 = START_FLIGHT_RECORDING + (options2 != null ? options2 : ""); - ProcessBuilder pb = ProcessTools.createTestJvm(recording1, recording2, MainClass.class.getName()); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(recording1, recording2, MainClass.class.getName()); test(pb, "Started recording 1", "Started recording 2"); } @@ -70,7 +70,7 @@ private static void launchTernary(String options1, String options2, String optio String recording1 = START_FLIGHT_RECORDING + (options1 != null ? options1 : ""); String recording2 = START_FLIGHT_RECORDING + (options2 != null ? options2 : ""); String recording3 = START_FLIGHT_RECORDING + (options3 != null ? options3 : ""); - ProcessBuilder pb = ProcessTools.createTestJvm(recording1, recording2, recording3, MainClass.class.getName()); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(recording1, recording2, recording3, MainClass.class.getName()); test(pb, "Started recording 1", "Started recording 2", "Started recording 3"); } @@ -94,7 +94,7 @@ private static void testWithFlightRecorderOptions() throws Exception { String flightRecorderOptions = FLIGHT_RECORDER_OPTIONS + "=maxchunksize=8m"; String recording1 = START_FLIGHT_RECORDING + "=filename=recording1.jfr"; String recording2 = START_FLIGHT_RECORDING + "=name=myrecording,filename=recording2.jfr"; - ProcessBuilder pb = ProcessTools.createTestJvm(flightRecorderOptions, recording1, recording2, MainClass.class.getName()); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(flightRecorderOptions, recording1, recording2, MainClass.class.getName()); test(pb, "Started recording 1", "Started recording 2"); } diff --git a/test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java b/test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java index 1942b3d3f6397..3a4d3f207326a 100644 --- a/test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java +++ b/test/jdk/jdk/jfr/startupargs/TestOptionsWithLocale.java @@ -36,7 +36,7 @@ public static void main(String... args) throws IOException { return; } - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-Duser.country=DE", "-Duser.language=de", "-XX:FlightRecorderOptions:stackdepth=128", diff --git a/test/jdk/jdk/jfr/startupargs/TestPreserveRepository.java b/test/jdk/jdk/jfr/startupargs/TestPreserveRepository.java index 335681bfc0cc1..4f4ee195e1fae 100644 --- a/test/jdk/jdk/jfr/startupargs/TestPreserveRepository.java +++ b/test/jdk/jdk/jfr/startupargs/TestPreserveRepository.java @@ -46,7 +46,7 @@ public static void main(String... args) throws Exception { "-XX:FlightRecorderOptions:repository=" + path + ",preserve-repository=true", "-version" }; - ProcessBuilder pb = ProcessTools.createTestJvm(arguments); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(arguments); OutputAnalyzer output = ProcessTools.executeProcess(pb); output.shouldHaveExitValue(0); Optional p = Files.find(path, 99, (a,b) -> a.getFileName().toString().endsWith(".jfr")).findAny(); diff --git a/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java b/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java index a427cfc1af47e..8c8703dc9e697 100644 --- a/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java +++ b/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -104,7 +104,7 @@ private static void startApp(boolean recording, boolean retransform, Consumer cmd = ProcessTools.createJavaProcessBuilder().command(); + List cmd = ProcessTools.createLimitedTestJavaProcessBuilder().command(); Stream.of(jdk.internal.misc.VM.getRuntimeArguments()) .filter(arg -> arg.startsWith("--add-exports=") || arg.startsWith("--add-opens=")) diff --git a/test/jdk/sun/security/provider/KeyStore/DKSTest.java b/test/jdk/sun/security/provider/KeyStore/DKSTest.java index 76c66f492d11d..1d1943ec7295c 100644 --- a/test/jdk/sun/security/provider/KeyStore/DKSTest.java +++ b/test/jdk/sun/security/provider/KeyStore/DKSTest.java @@ -80,7 +80,7 @@ public class DKSTest { public static void main(String[] args) throws Exception { if (args.length == 0) { // Environment variable and system properties referred in domains.cfg used by this Test. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(List.of( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(List.of( "-Dtest.src=" + TEST_SRC , "-Duser.dir=" + USER_DIR, "DKSTest", "run")); pb.environment().putAll(System.getenv()); pb.environment().put("KEYSTORE_PWD", "test12"); diff --git a/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java index c0d3bbfda3134..d6ec20c93d2ed 100644 --- a/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java +++ b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java @@ -118,7 +118,7 @@ public static void main(String args[]) throws Exception { System.out.println("test.java.opts: " + System.getProperty("test.java.opts")); - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( Utils.addTestJavaOpts("SSLEngineKeyLimit", "p", args[1], args[2])); diff --git a/test/jdk/sun/security/ssl/SSLSessionImpl/ResumptionUpdateBoundValues.java b/test/jdk/sun/security/ssl/SSLSessionImpl/ResumptionUpdateBoundValues.java index f7796e1a49d72..4778cc217ba3e 100644 --- a/test/jdk/sun/security/ssl/SSLSessionImpl/ResumptionUpdateBoundValues.java +++ b/test/jdk/sun/security/ssl/SSLSessionImpl/ResumptionUpdateBoundValues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * 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 @@ public static void main(String[] args) throws Exception { System.out.println("test.java.opts: " + System.getProperty("test.java.opts")); - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( Utils.addTestJavaOpts("ResumptionUpdateBoundValues", "p")); OutputAnalyzer output = ProcessTools.executeProcess(pb); diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java index 8b19d39af7ead..f0519a94249d6 100644 --- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java @@ -134,7 +134,7 @@ public static void main(String args[]) throws Exception { System.out.println("test.java.opts: " + System.getProperty("test.java.opts")); - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( Utils.addTestJavaOpts("SSLSocketKeyLimit", "p", args[1], args[2])); diff --git a/test/jdk/sun/tools/jstat/JStatInterval.java b/test/jdk/sun/tools/jstat/JStatInterval.java index 1dfa1f9187bcc..0719e1d11b60b 100644 --- a/test/jdk/sun/tools/jstat/JStatInterval.java +++ b/test/jdk/sun/tools/jstat/JStatInterval.java @@ -61,7 +61,7 @@ public static void main(String[] args) { } } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createTestJvm( + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder( "-XX:+UsePerfData", Application.class.getName() ); diff --git a/test/jdk/tools/jimage/JImageToolTest.java b/test/jdk/tools/jimage/JImageToolTest.java index fce9a0ac34767..feb6a56a968c3 100644 --- a/test/jdk/tools/jimage/JImageToolTest.java +++ b/test/jdk/tools/jimage/JImageToolTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ private static void jimage(String... jimageArgs) throws Exception { args.add("jdk.tools.jimage.Main"); args.addAll(Arrays.asList(jimageArgs)); - ProcessBuilder builder = ProcessTools.createJavaProcessBuilder(args.toArray(new String[args.size()])); + ProcessBuilder builder = ProcessTools.createLimitedTestJavaProcessBuilder(args.toArray(new String[args.size()])); int res = builder.inheritIO().start().waitFor(); if (res != 0) { diff --git a/test/jdk/tools/launcher/modules/basic/BasicTest.java b/test/jdk/tools/launcher/modules/basic/BasicTest.java index 6a91cdc6d7c1d..ac831119988c2 100644 --- a/test/jdk/tools/launcher/modules/basic/BasicTest.java +++ b/test/jdk/tools/launcher/modules/basic/BasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -270,7 +270,7 @@ public void testTryRunWithMainClassInWrongModule() throws Exception { * while setting the _JAVA_LAUNCHER_DEBUG environment variable. */ private ProcessBuilder createProcessWithLauncherDebugging(String... cmds) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(Utils.addTestJavaOpts(cmds)); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(Utils.addTestJavaOpts(cmds)); pb.environment().put("_JAVA_LAUNCHER_DEBUG", "true"); return pb; diff --git a/test/lib-test/jdk/test/lib/process/ProcessToolsLastLineTest.java b/test/lib-test/jdk/test/lib/process/ProcessToolsLastLineTest.java index 696f76f0f1e78..54b5a3bc2205b 100644 --- a/test/lib-test/jdk/test/lib/process/ProcessToolsLastLineTest.java +++ b/test/lib-test/jdk/test/lib/process/ProcessToolsLastLineTest.java @@ -37,7 +37,7 @@ public class ProcessToolsLastLineTest { static void test(String output) throws Exception { final StringBuffer sb = new StringBuffer(); Process p = ProcessTools.startProcess("process", - ProcessTools.createJavaProcessBuilder(ProcessToolsLastLineTest.class.getName(), output), + ProcessTools.createLimitedTestJavaProcessBuilder(ProcessToolsLastLineTest.class.getName(), output), line -> { sb.append(line);}); p.waitFor(); String expectedOutput = output.replace("\n", ""); diff --git a/test/lib/jdk/test/lib/cds/CDSTestUtils.java b/test/lib/jdk/test/lib/cds/CDSTestUtils.java index 629cf682384c1..7115912380ac9 100644 --- a/test/lib/jdk/test/lib/cds/CDSTestUtils.java +++ b/test/lib/jdk/test/lib/cds/CDSTestUtils.java @@ -266,7 +266,7 @@ public static OutputAnalyzer createArchive(CDSOptions opts) for (String s : opts.suffix) cmd.add(s); String[] cmdLine = cmd.toArray(new String[cmd.size()]); - ProcessBuilder pb = ProcessTools.createTestJvm(cmdLine); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(cmdLine); return executeAndLog(pb, "dump"); } @@ -444,7 +444,7 @@ public static OutputAnalyzer runWithArchive(CDSOptions opts) for (String s : opts.suffix) cmd.add(s); String[] cmdLine = cmd.toArray(new String[cmd.size()]); - ProcessBuilder pb = ProcessTools.createTestJvm(cmdLine); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(cmdLine); return executeAndLog(pb, "exec"); } diff --git a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java index b3b1b8a7e2caf..31cff4b8c25f2 100644 --- a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java +++ b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -113,7 +113,7 @@ public static void verifyJVMStartup(String expectedMessages[], finalOptions.add("-version"); ProcessBuilder processBuilder - = ProcessTools.createJavaProcessBuilder(finalOptions.toArray( + = ProcessTools.createLimitedTestJavaProcessBuilder(finalOptions.toArray( new String[finalOptions.size()])); OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start()); @@ -263,7 +263,7 @@ public static void verifyOptionValue(String optionName, Collections.addAll(vmOpts, additionalVMOpts); Collections.addAll(vmOpts, "-XX:+PrintFlagsFinal", "-version"); - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( vmOpts.toArray(new String[vmOpts.size()])); OutputAnalyzer outputAnalyzer @@ -333,7 +333,7 @@ public static OutputAnalyzer startVMWithOptions(String[] optionNames, Collections.addAll(vmOpts, additionalVMOpts); Collections.addAll(vmOpts, "-version"); - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + ProcessBuilder processBuilder = ProcessTools.createLimitedTestJavaProcessBuilder( vmOpts.toArray(new String[vmOpts.size()])); return new OutputAnalyzer(processBuilder.start()); diff --git a/test/lib/jdk/test/lib/jfr/AppExecutorHelper.java b/test/lib/jdk/test/lib/jfr/AppExecutorHelper.java index df8d39e32b837..90621c2ed9945 100644 --- a/test/lib/jdk/test/lib/jfr/AppExecutorHelper.java +++ b/test/lib/jdk/test/lib/jfr/AppExecutorHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,7 @@ public static OutputAnalyzer executeAndRecord(String settings, String jfrFilenam Collections.addAll(arguments, classArguments); } - ProcessBuilder pb = ProcessTools.createTestJvm(arguments); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(arguments); return ProcessTools.executeProcess(pb); } } diff --git a/test/lib/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java index b97d93bb47625..89ef525672903 100644 --- a/test/lib/jdk/test/lib/process/ProcessTools.java +++ b/test/lib/jdk/test/lib/process/ProcessTools.java @@ -376,16 +376,6 @@ public static long getProcessId() throws Exception { return ProcessHandle.current().pid(); } - /** - * Create ProcessBuilder using the java launcher from the jdk to be tested. - * - * @param command Arguments to pass to the java command. - * @return The ProcessBuilder instance representing the java command. - */ - public static ProcessBuilder createJavaProcessBuilder(List command) { - return createJavaProcessBuilder(command.toArray(String[]::new)); - } - /* Convert arguments for tests running with virtual threads test thread factory. When test is executed with test thread factory the line is changed from @@ -457,7 +447,7 @@ private static List addTestThreadFactoryArgs(String testThreadFactoryNam * @param command Arguments to pass to the java command. * @return The ProcessBuilder instance representing the java command. */ - public static ProcessBuilder createJavaProcessBuilder(String... command) { + private static ProcessBuilder createJavaProcessBuilder(String... command) { String javapath = JDKToolFinder.getJDKTool("java"); ArrayList args = new ArrayList<>(); @@ -512,8 +502,8 @@ private static void printStack(Thread t, StackTraceElement[] stack) { * @param command Arguments to pass to the java command. * @return The ProcessBuilder instance representing the java command. */ - public static ProcessBuilder createTestJvm(List command) { - return createTestJvm(command.toArray(String[]::new)); + public static ProcessBuilder createTestJavaProcessBuilder(List command) { + return createTestJavaProcessBuilder(command.toArray(String[]::new)); } /** @@ -527,10 +517,54 @@ public static ProcessBuilder createTestJvm(List command) { * @param command Arguments to pass to the java command. * @return The ProcessBuilder instance representing the java command. */ - public static ProcessBuilder createTestJvm(String... command) { + public static ProcessBuilder createTestJavaProcessBuilder(String... command) { return createJavaProcessBuilder(Utils.prependTestJavaOpts(command)); } + /** + * Create ProcessBuilder using the java launcher from the jdk to + * be tested. + * + *

Please observe that you likely should use + * createTestJavaProcessBuilder() instead of this method because + * createTestJavaProcessBuilder() will add JVM options from + * "test.vm.opts" and "test.java.opts" and this method will + * not do that. + * + *

If you still chose to use + * createLimitedTestJavaProcessBuilder() you should probably use + * it in combination with @requires vm.flagless JTREG + * anotation as to not waste energy and test resources. + * + * @param command Arguments to pass to the java command. + * @return The ProcessBuilder instance representing the java command. + */ + public static ProcessBuilder createLimitedTestJavaProcessBuilder(List command) { + return createLimitedTestJavaProcessBuilder(command.toArray(String[]::new)); + } + + /** + * Create ProcessBuilder using the java launcher from the jdk to + * be tested. + * + *

Please observe that you likely should use + * createTestJavaProcessBuilder() instead of this method because + * createTestJavaProcessBuilder() will add JVM options from + * "test.vm.opts" and "test.java.opts" and this method will + * not do that. + * + *

If you still chose to use + * createLimitedTestJavaProcessBuilder() you should probably use + * it in combination with @requires vm.flagless JTREG + * anotation as to not waste energy and test resources. + * + * @param command Arguments to pass to the java command. + * @return The ProcessBuilder instance representing the java command. + */ + public static ProcessBuilder createLimitedTestJavaProcessBuilder(String... command) { + return createJavaProcessBuilder(command); + } + /** * Executes a test jvm process, waits for it to finish and returns the process output. * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added. @@ -562,7 +596,7 @@ public static OutputAnalyzer executeTestJvm(List cmds) throws Exception * @return The output from the process. */ public static OutputAnalyzer executeTestJvm(String... cmds) throws Exception { - ProcessBuilder pb = createTestJvm(cmds); + ProcessBuilder pb = createTestJavaProcessBuilder(cmds); return executeProcess(pb); } From b9dcd4b74138dd77faa46525f101b985248fffc5 Mon Sep 17 00:00:00 2001 From: Leo Korinth Date: Fri, 27 Oct 2023 09:51:22 +0000 Subject: [PATCH 12/16] 8318964: Fix build failures caused by 8315097 Reviewed-by: aboldtch, rcastanedalo --- .../CompressedOops/CompressedClassPointersEncodingScheme.java | 2 +- .../jtreg/runtime/ErrorHandling/TestSymbolsInHsErrFile.java | 2 +- .../jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java | 2 +- .../lang/instrument/modules/AppendToClassPathModuleTest.java | 2 +- .../jdk/tools/launcher/modules/classpath/JavaClassPathTest.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java index c1ef73d836c6b..070c856a32233 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java @@ -45,7 +45,7 @@ public class CompressedClassPointersEncodingScheme { private static void test(long forceAddress, long classSpaceSize, long expectedEncodingBase, int expectedEncodingShift) throws IOException { String forceAddressString = String.format("0x%016X", forceAddress).toLowerCase(); String expectedEncodingBaseString = String.format("0x%016X", expectedEncodingBase).toLowerCase(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-Xshare:off", // to make CompressedClassSpaceBaseAddress work "-XX:+UnlockDiagnosticVMOptions", "-XX:-UseCompressedOops", // keep VM from optimizing heap location diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestSymbolsInHsErrFile.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestSymbolsInHsErrFile.java index b6a7b58261182..c8ab832058c50 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestSymbolsInHsErrFile.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestSymbolsInHsErrFile.java @@ -43,7 +43,7 @@ public class TestSymbolsInHsErrFile { public static void main(String[] args) throws Exception { // Start a jvm and cause a SIGSEGV / ACCESS_VIOLATION - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", "-XX:-CreateCoredumpOnCrash", diff --git a/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java b/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java index e93309c0b0032..340c13707388d 100644 --- a/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java +++ b/test/hotspot/jtreg/runtime/os/TestHugePageDecisionsAtVMStartup.java @@ -146,7 +146,7 @@ public static void main(String[] extraOptions) throws Exception { boolean useTHP = allOptions.contains("-XX:+UseTransparentHugePages"); System.out.println("useLP: " + useLP + " useTHP: " + useTHP); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(allOptions.toArray(new String[0])); + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(allOptions.toArray(new String[0])); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.reportDiagnosticSummary(); HugePageConfiguration configuration = HugePageConfiguration.readFromOS(); diff --git a/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java b/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java index 943abe7385150..76655758b8b8a 100644 --- a/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java +++ b/test/jdk/java/lang/instrument/modules/AppendToClassPathModuleTest.java @@ -47,7 +47,7 @@ public class AppendToClassPathModuleTest { public static void main(String... args) throws Throwable { String modulepath = System.getProperty("test.module.path"); - // can't use ProcessTools.createJavaProcessBuilder as it always adds -cp + // can't use ProcessTools.createLimitedTestJavaProcessBuilder as it always adds -cp ProcessBuilder pb = new ProcessBuilder( JDKToolFinder.getTestJDKTool("java"), "-javaagent:Agent.jar", diff --git a/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java b/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java index 0526c881d8a96..5854021c4a312 100644 --- a/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java +++ b/test/jdk/tools/launcher/modules/classpath/JavaClassPathTest.java @@ -200,7 +200,7 @@ public void testClassPathAttribute() throws Throwable { } private OutputAnalyzer execute(List options) throws Throwable { - // can't use ProcessTools.createJavaProcessBuilder as it always adds -cp + // can't use ProcessTools.createLimitedTestJavaProcessBuilder as it always adds -cp ProcessBuilder pb = new ProcessBuilder( Stream.concat(Stream.of(JDKToolFinder.getTestJDKTool("java")), options.stream() From 667cca9d7aef1ff4abe630cefaac34c0b1646925 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 27 Oct 2023 10:08:59 +0000 Subject: [PATCH 13/16] 8288899: java/util/concurrent/ExecutorService/CloseTest.java failed with "InterruptedException: sleep interrupted" Reviewed-by: alanb --- .../util/concurrent/CountedCompleter.java | 21 +- .../java/util/concurrent/ForkJoinPool.java | 3014 +++++++++-------- .../java/util/concurrent/ForkJoinTask.java | 1130 +++--- .../util/concurrent/ForkJoinWorkerThread.java | 5 +- test/jdk/ProblemList.txt | 4 +- .../concurrent/ExecutorService/CloseTest.java | 177 +- .../ExecutorService/InvokeTest.java | 787 +++++ .../ExecutorService/SubmitTest.java | 370 ++ .../concurrent/Future/DefaultMethods.java | 119 +- test/jdk/java/util/concurrent/TEST.properties | 1 + .../concurrent/forkjoin/AsyncShutdownNow.java | 95 +- .../concurrent/tck/ForkJoinPool19Test.java | 106 +- .../concurrent/tck/ForkJoinPool8Test.java | 21 +- .../util/concurrent/tck/ForkJoinTaskTest.java | 8 +- .../util/concurrent/tck/JSR166TestCase.java | 26 +- .../concurrent/tck/RecursiveActionTest.java | 25 +- .../concurrent/tck/RecursiveTaskTest.java | 18 +- test/jdk/java/util/concurrent/tck/tck.policy | 1 + 18 files changed, 3862 insertions(+), 2066 deletions(-) create mode 100644 test/jdk/java/util/concurrent/ExecutorService/InvokeTest.java create mode 100644 test/jdk/java/util/concurrent/ExecutorService/SubmitTest.java create mode 100644 test/jdk/java/util/concurrent/TEST.properties diff --git a/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java b/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java index 3278d191074ea..7884a131ffb70 100644 --- a/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java +++ b/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java @@ -524,6 +524,10 @@ public final int getPendingCount() { return pending; } + final void initPending(int count) { + U.putInt(this, PENDING, count); + } + /** * Sets the pending count to the given value. * @@ -724,26 +728,27 @@ public final void quietlyCompleteRoot() { * processed. */ public final void helpComplete(int maxTasks) { - ForkJoinPool.WorkQueue q; Thread t; boolean owned; - if (owned = (t = Thread.currentThread()) instanceof ForkJoinWorkerThread) + ForkJoinPool.WorkQueue q; Thread t; boolean internal; + if (internal = + (t = Thread.currentThread()) instanceof ForkJoinWorkerThread) q = ((ForkJoinWorkerThread)t).workQueue; else q = ForkJoinPool.commonQueue(); if (q != null && maxTasks > 0) - q.helpComplete(this, owned, maxTasks); + q.helpComplete(this, internal, maxTasks); } + // ForkJoinTask overrides /** * Supports ForkJoinTask exception propagation. */ @Override - final int trySetException(Throwable ex) { + final void onAuxExceptionSet(Throwable ex) { CountedCompleter a = this, p = a; - do {} while (isExceptionalStatus(a.trySetThrown(ex)) && - a.onExceptionalCompletion(ex, p) && - (a = (p = a).completer) != null && a.status >= 0); - return status; + do {} while (a.onExceptionalCompletion(ex, p) && + (a = (p = a).completer) != null && + a.trySetThrown(ex)); } /** diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 5e698b1540f06..a14f6d884e0b5 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -47,11 +47,10 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.function.Predicate; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.locks.LockSupport; -import java.util.concurrent.locks.ReentrantLock; -import java.util.concurrent.locks.Condition; import jdk.internal.access.JavaUtilConcurrentFJPAccess; import jdk.internal.access.SharedSecrets; import jdk.internal.misc.Unsafe; @@ -187,27 +186,39 @@ public class ForkJoinPool extends AbstractExecutorService { * Implementation Overview * * This class and its nested classes provide the main - * functionality and control for a set of worker threads: - * Submissions from non-FJ threads enter into submission queues. - * Workers take these tasks and typically split them into subtasks - * that may be stolen by other workers. Work-stealing based on - * randomized scans generally leads to better throughput than - * "work dealing" in which producers assign tasks to idle threads, - * in part because threads that have finished other tasks before - * the signalled thread wakes up (which can be a long time) can - * take the task instead. Preference rules give first priority to - * processing tasks from their own queues (LIFO or FIFO, depending - * on mode), then to randomized FIFO steals of tasks in other - * queues. This framework began as vehicle for supporting - * tree-structured parallelism using work-stealing. Over time, - * its scalability advantages led to extensions and changes to - * better support more diverse usage contexts. Because most - * internal methods and nested classes are interrelated, their - * main rationale and descriptions are presented here; individual - * methods and nested classes contain only brief comments about - * details. There are a fair number of odd code constructions and - * design decisions for components that reside at the edge of Java - * vs JVM functionality. + * functionality and control for a set of worker threads. Because + * most internal methods and nested classes are interrelated, + * their main rationale and descriptions are presented here; + * individual methods and nested classes contain only brief + * comments about details. Broadly: submissions from non-FJ + * threads enter into submission queues. Workers take these tasks + * and typically split them into subtasks that may be stolen by + * other workers. Work-stealing based on randomized scans + * generally leads to better throughput than "work dealing" in + * which producers assign tasks to idle threads, in part because + * threads that have finished other tasks before the signalled + * thread wakes up (which can be a long time) can take the task + * instead. Preference rules give first priority to processing + * tasks from their own queues (LIFO or FIFO, depending on mode), + * then to randomized FIFO steals of tasks in other queues. This + * framework began as vehicle for supporting tree-structured + * parallelism using work-stealing. Over time, its scalability + * advantages led to extensions and changes to better support more + * diverse usage contexts. Here's a brief history of major + * revisions, each also with other minor features and changes. + * + * 1. Only handle recursively structured computational tasks + * 2. Async (FIFO) mode and striped submission queues + * 3. Completion-based tasks (mainly CountedCompleters) + * 4. CommonPool and parallelStream support + * 5. InterruptibleTasks for externally submitted tasks + * + * Most changes involve adaptions of base algorithms using + * combinations of static and dynamic bitwise mode settings (both + * here and in ForkJoinTask), and subclassing of ForkJoinTask. + * There are a fair number of odd code constructions and design + * decisions for components that reside at the edge of Java vs JVM + * functionality. * * WorkQueues * ========== @@ -238,16 +249,11 @@ public class ForkJoinPool extends AbstractExecutorService { * Nardelli, PPoPP 2013 * (http://www.di.ens.fr/~zappa/readings/ppopp13.pdf) for an * analysis of memory ordering requirements in work-stealing - * algorithms similar to the one used here. We also use ordered, - * moded accesses and/or fences for other control, with modes - * reflecting the presence or absence of other contextual sync - * provided by atomic and/or volatile accesses. Some methods (or - * their primary loops) begin with an acquire fence or - * otherwise-unnecessary volatile read that amounts to an - * acquiring read of "this" to cover all fields (which is - * sometimes stronger than necessary, but less brittle). Some - * constructions are intentionally racy because they use read - * values as hints, not for correctness. + * algorithms similar to the one used here. We use per-operation + * ordered writes of various kinds for updates, but usually use + * explicit load fences for reads, to cover access of several + * fields of possibly several objects without further constraining + * read-by-read ordering. * * We also support a user mode in which local task processing is * in FIFO, not LIFO order, simply by using a local version of @@ -256,7 +262,7 @@ public class ForkJoinPool extends AbstractExecutorService { * increased contention among task producers and consumers. Also, * the same data structure (and class) is used for "submission * queues" (described below) holding externally submitted tasks, - * that differ only in that a lock (field "access"; see below) is + * that differ only in that a lock (using field "phase"; see below) is * required by external callers to push and pop tasks. * * Adding tasks then takes the form of a classic array push(task) @@ -267,8 +273,7 @@ public class ForkJoinPool extends AbstractExecutorService { * uses masking, not mod, for indexing a power-of-two-sized array, * enforces memory ordering, supports resizing, and possibly * signals waiting workers to start scanning (described below), - * which requires even internal usages to strictly order accesses - * (using a form of lock release). + * which requires stronger forms of order accesses. * * The pop operation (always performed by owner) is of the form: * if ((task = getAndSet(q.array, (q.top-1) % length, null)) != null) @@ -289,7 +294,10 @@ public class ForkJoinPool extends AbstractExecutorService { * * Slot k must be read with an acquiring read, which it must * anyway to dereference and run the task if the (acquiring) * CAS succeeds, but uses an explicit acquire fence to support - * the following rechecks even if the CAS is not attempted. + * the following rechecks even if the CAS is not attempted. To + * more easily distinguish among kinds of CAS failures, we use + * the compareAndExchange version, and usually handle null + * returns (indicating contention) separately from others. * * * q.base may change between reading and using its value to * index the slot. To avoid trying to use the wrong t, the @@ -310,8 +318,8 @@ public class ForkJoinPool extends AbstractExecutorService { * q.base doesn't change on repeated reads of null t and when * no other alternatives apply, spin-wait for it to settle. To * reduce producing these kinds of stalls by other stealers, we - * encourage timely writes to indices using store fences when - * memory ordering is not already constrained by context. + * encourage timely writes to indices using otherwise + * unnecessarily strong writes. * * * The CAS may fail, in which case we may want to retry unless * there is too much contention. One goal is to balance and @@ -329,12 +337,12 @@ public class ForkJoinPool extends AbstractExecutorService { * when deciding whether to try to poll or repoll after a * failure. Both top and base may move independently, and both * lag updates to the underlying array. To reduce memory - * contention, when possible, non-owners avoid reading the - * "top" index at all, and instead use array reads, including - * one-ahead reads to check whether to repoll, relying on the - * fact that a non-empty queue does not have two null slots in - * a row, except in cases (resizes and shifts) that can be - * detected with a secondary recheck. + * contention, non-owners avoid reading the "top" when + * possible, by using one-ahead reads to check whether to + * repoll, relying on the fact that a non-empty queue does not + * have two null slots in a row, except in cases (resizes and + * shifts) that can be detected with a secondary recheck that + * is less likely to conflict with owner writes. * * The poll operations in q.poll(), scan(), helpJoin(), and * elsewhere differ with respect to whether other queues are @@ -362,14 +370,11 @@ public class ForkJoinPool extends AbstractExecutorService { * like workers except that they are restricted to executing local * tasks that they submitted (or when known, subtasks thereof). * Insertion of tasks in shared mode requires a lock. We use only - * a simple spinlock because submitters encountering a busy queue - * move to a different position to use or create other queues. - * They (spin) block when registering new queues, and less - * often in tryRemove and helpComplete. The lock needed for - * external queues is generalized (as field "access") for - * operations on owned queues that require a fully-fenced write - * (including push, parking status, and termination) in order to - * deal with Dekker-like signalling constructs described below. + * a simple spinlock (as one role of field "phase") because + * submitters encountering a busy queue move to a different + * position to use or create other queues. They (spin) block when + * registering new queues, or indirectly elsewhere, by revisiting + * later. * * Management * ========== @@ -395,29 +400,58 @@ public class ForkJoinPool extends AbstractExecutorService { * restrict maximum parallelism to (1<<15)-1 (which is far in * excess of normal operating range) to allow ids, counts, and * their negations (used for thresholding) to fit into 16bit - * subfields. Field "parallelism" holds the target parallelism - * (normally corresponding to pool size). It is needed (nearly) - * only in methods updating ctl, so is packed nearby. As of the - * current release, users can dynamically reset target - * parallelism, which is read once per update, so only slowly has - * an effect in creating threads or letting them time out and - * terminate when idle. - * - * Field "runState" holds lifetime status, atomically and - * monotonically setting SHUTDOWN, STOP, and finally TERMINATED - * bits. It is updated only via bitwise atomics (getAndBitwiseOr). + * subfields. + * + * Field "runState" and per-WorkQueue field "phase" play similar + * roles, as lockable, versioned counters. Field runState also + * includes monotonic event bits (SHUTDOWN, STOP, and TERMINATED). + * The version tags enable detection of state changes (by + * comparing two reads) modulo bit wraparound. The bit range in + * each case suffices for purposes of determining quiescence, + * termination, avoiding ABA-like errors, and signal control, most + * of which are ultimately based on at most 15bit ranges (due to + * 32767 max total workers). RunState updates do not need to be + * atomic with respect to ctl updates, but because they are not, + * some care is required to avoid stalls. The seqLock properties + * detect changes and conditionally upgrade to coordinate with + * updates. It is typically held for less than a dozen + * instructions unless the queue array is being resized, during + * which contention is rare. To be conservative, lockRunState is + * implemented as a spin/sleep loop. Here and elsewhere spin + * constants are short enough to apply even on systems with few + * available processors. In addition to checking pool status, + * reads of runState sometimes serve as acquire fences before + * reading other fields. + * + * Field "parallelism" holds the target parallelism (normally + * corresponding to pool size). Users can dynamically reset target + * parallelism, but is only accessed when signalling or awaiting + * work, so only slowly has an effect in creating threads or + * letting them time out and terminate when idle. * * Array "queues" holds references to WorkQueues. It is updated * (only during worker creation and termination) under the - * registrationLock, but is otherwise concurrently readable (often - * prefaced by a volatile read of mode to check termination, that - * is required anyway, and serves as an acquire fence). To - * simplify index-based operations, the array size is always a - * power of two, and all readers must tolerate null slots. Worker - * queues are at odd indices. Worker ids masked with SMASK match - * their index. Shared (submission) queues are at even - * indices. Grouping them together in this way simplifies and - * speeds up task scanning. + * runState lock. It is otherwise concurrently readable but reads + * for use in scans (see below) are always prefaced by a volatile + * read of runState (or equivalent constructions), ensuring that + * its state is current at the point it is used (which is all we + * require). To simplify index-based operations, the array size is + * always a power of two, and all readers must tolerate null + * slots. Worker queues are at odd indices. Worker phase ids + * masked with SMASK match their index. Shared (submission) queues + * are at even indices. Grouping them together in this way aids in + * task scanning: At top-level, both kinds of queues should be + * sampled with approximately the same probability, which is + * simpler if they are all in the same array. But we also need to + * identify what kind they are without looking at them, leading to + * this odd/even scheme. One disadvantage is that there are + * usually many fewer submission queues, so there can be many + * wasted probes (null slots). But this is still cheaper than + * alternatives. Other loops over the queues array vary in origin + * and stride depending on whether they cover only submission + * (even) or worker (odd) queues or both, and whether they require + * randomness (in which case cyclically exhaustive strides may be + * used). * * All worker thread creation is on-demand, triggered by task * submissions, replacement of terminated workers, and/or @@ -429,7 +463,11 @@ public class ForkJoinPool extends AbstractExecutorService { * one source of some of the messy code constructions here). In * essence, the queues array serves as a weak reference * mechanism. In particular, the stack top subfield of ctl stores - * indices, not references. + * indices, not references. Operations on queues obtained from + * these indices remain valid (with at most some unnecessary extra + * work) even if an underlying worker failed and was replaced by + * another at the same index. During termination, worker queue + * array updates are disabled. * * Queuing Idle Workers. Unlike HPC work-stealing frameworks, we * cannot let workers spin indefinitely scanning for tasks when @@ -438,28 +476,30 @@ public class ForkJoinPool extends AbstractExecutorService { * other hand, we must quickly prod them into action when new * tasks are submitted or generated. These latencies are mainly a * function of JVM park/unpark (and underlying OS) performance, - * which can be slow and variable. In many usages, ramp-up time + * which can be slow and variable (even though usages are + * streamlined as much as possible). In many usages, ramp-up time * is the main limiting factor in overall performance, which is * compounded at program start-up by JIT compilation and * allocation. On the other hand, throughput degrades when too - * many threads poll for too few tasks. + * many threads poll for too few tasks. (See below.) * * The "ctl" field atomically maintains total and "released" * worker counts, plus the head of the available worker queue * (actually stack, represented by the lower 32bit subfield of * ctl). Released workers are those known to be scanning for - * and/or running tasks. Unreleased ("available") workers are - * recorded in the ctl stack. These workers are made eligible for - * signalling by enqueuing in ctl (see method awaitWork). The - * "queue" is a form of Treiber stack. This is ideal for - * activating threads in most-recently used order, and improves - * performance and locality, outweighing the disadvantages of - * being prone to contention and inability to release a worker - * unless it is topmost on stack. The top stack state holds the - * value of the "phase" field of the worker: its index and status, - * plus a version counter that, in addition to the count subfields - * (also serving as version stamps) provide protection against - * Treiber stack ABA effects. + * and/or running tasks (we cannot accurately determine + * which). Unreleased ("available") workers are recorded in the + * ctl stack. These workers are made eligible for signalling by + * enqueuing in ctl (see method runWorker). This "queue" is a + * form of Treiber stack. This is ideal for activating threads in + * most-recently used order, and improves performance and + * locality, outweighing the disadvantages of being prone to + * contention and inability to release a worker unless it is + * topmost on stack. The top stack state holds the value of the + * "phase" field of the worker: its index and status, plus a + * version counter that, in addition to the count subfields (also + * serving as version stamps) provide protection against Treiber + * stack ABA effects. * * Creating workers. To create a worker, we pre-increment counts * (serving as a reservation), and attempt to construct a @@ -473,16 +513,14 @@ public class ForkJoinPool extends AbstractExecutorService { * workers. If exceptional, the exception is propagated, generally * to some external caller. * - * WorkQueue field "phase" is used by both workers and the pool to - * manage and track whether a worker is unsignalled (possibly - * blocked waiting for a signal), conveniently using the sign bit - * to check. When a worker is enqueued its phase field is set - * negative. Note that phase field updates lag queue CAS releases; - * seeing a negative phase does not guarantee that the worker is - * available (and so is never checked in this way). When queued, - * the lower 16 bits of its phase must hold its pool index. So we - * place the index there upon initialization and never modify - * these bits. + * WorkQueue field "phase" encodes the queue array id in lower + * bits, and otherwise acts similarly to the pool runState field: + * The "IDLE" bit is clear while active (either a released worker + * or a locked external queue), with other bits serving as a + * version counter to distinguish changes across multiple reads. + * Note that phase field updates lag queue CAS releases; seeing a + * non-idle phase does not guarantee that the worker is available + * (and so is never checked in this way). * * The ctl field also serves as the basis for memory * synchronization surrounding activation. This uses a more @@ -498,109 +536,142 @@ public class ForkJoinPool extends AbstractExecutorService { * workers to scan for tasks. Method signalWork and its callers * try to approximate the unattainable goal of having the right * number of workers activated for the tasks at hand, but must err - * on the side of too many workers vs too few to avoid stalls. If - * computations are purely tree structured, it suffices for every - * worker to activate another when it pushes a task into an empty - * queue, resulting in O(log(#threads)) steps to full activation. - * (To reduce resource usages in some cases, at the expense of - * slower startup in others, activation of an idle thread is - * preferred over creating a new one, here and elsewhere.) If - * instead, tasks come in serially from only a single producer, - * each worker taking its first (since the last activation) task - * from a queue should signal another if there are more tasks in - * that queue. This is equivalent to, but generally faster than, - * arranging the stealer take two tasks, re-pushing one on its own - * queue, and signalling (because its queue is empty), also - * resulting in logarithmic full activation time. Because we don't - * know about usage patterns (or most commonly, mixtures), we use - * both approaches. Together these are minimally necessary for - * maintaining liveness. However, they do not account for the fact - * that when tasks are short-lived, signals are unnecessary - * because workers will already be scanning for new tasks without - * the need of new signals. We track these cases (variable - * "prevSrc" in scan() and related methods) to avoid some - * unnecessary signals and scans. However, signal contention and - * overhead effects may still occur during ramp-up, ramp-down, and - * small computations involving only a few workers. + * on the side of too many workers vs too few to avoid stalls: + * + * * If computations are purely tree structured, it suffices for + * every worker to activate another when it pushes a task into + * an empty queue, resulting in O(log(#threads)) steps to full + * activation. Emptiness must be conservatively approximated, + * sometimes resulting in unnecessary signals. Also, to reduce + * resource usages in some cases, at the expense of slower + * startup in others, activation of an idle thread is preferred + * over creating a new one, here and elsewhere. + * + * * If instead, tasks come in serially from only a single + * producer, each worker taking its first (since the last + * activation) task from a queue should propagate a signal if + * there are more tasks in that queue. This is equivalent to, + * but generally faster than, arranging the stealer take + * multiple tasks, re-pushing one or more on its own queue, and + * signalling (because its queue is empty), also resulting in + * logarithmic full activation time + * + * * Because we don't know about usage patterns (or most commonly, + * mixtures), we use both approaches, which present even more + * opportunities to over-signal. Note that in either of these + * contexts, signals may be (and often are) unnecessary because + * active workers continue scanning after running tasks without + * the need to be signalled (which is one reason work stealing + * is often faster than alternatives), so additional workers + * aren't needed. But there is no efficient way to detect this. + * + * * For rapidly branching tasks that require full pool resources, + * oversignalling is OK, because signalWork will soon have no + * more workers to create or reactivate. But for others (mainly + * externally submitted tasks), overprovisioning may cause very + * noticeable slowdowns due to contention and resource + * wastage. All remedies are intrinsically heuristic. We use a + * strategy that works well in most cases: We track "sources" + * (queue ids) of non-empty (usually polled) queues while + * scanning. These are maintained in the "source" field of + * WorkQueues for use in method helpJoin and elsewhere (see + * below). We also maintain them as arguments/results of + * top-level polls (argument "window" in method scan, with setup + * in method runWorker) as an encoded sliding window of current + * and previous two sources (or INVALID_ID if none), and stop + * signalling when all were from the same source. Also, retries + * are suppressed on CAS failures by newly activated workers, + * which serves as a form of admission control. These + * mechanisms may result in transiently too few workers, but + * once workers poll from a new source, they rapidly reactivate + * others. + * + * * Despite these, signal contention and overhead effects still + * occur during ramp-up and ramp-down of small computations. * * Scanning. Method scan performs top-level scanning for (and * execution of) tasks by polling a pseudo-random permutation of - * the array (by starting at a random index, and using a constant - * cyclically exhaustive stride.) It uses the same basic polling + * the array (by starting at a given index, and using a constant + * cyclically exhaustive stride.) It uses the same basic polling * method as WorkQueue.poll(), but restarts with a different - * permutation on each invocation. (Non-top-level scans; for - * example in helpJoin, use simpler and faster linear probes - * because they do not systematically contend with top-level - * scans.) The pseudorandom generator need not have high-quality - * statistical properties in the long term. We use Marsaglia - * XorShifts, seeded with the Weyl sequence from ThreadLocalRandom - * probes, which are cheap and suffice. Scans do not otherwise - * explicitly take into account core affinities, loads, cache - * localities, etc, However, they do exploit temporal locality - * (which usually approximates these) by preferring to re-poll - * from the same queue (using method tryPoll()) after a successful - * poll before trying others (see method topLevelExec), which also - * reduces bookkeeping and scanning overhead. This also reduces + * permutation on each invocation. The pseudorandom generator + * need not have high-quality statistical properties in the long + * term. We use Marsaglia XorShifts, seeded with the Weyl sequence + * from ThreadLocalRandom probes, which are cheap and + * suffice. Scans do not otherwise explicitly take into account + * core affinities, loads, cache localities, etc, However, they do + * exploit temporal locality (which usually approximates these) by + * preferring to re-poll from the same queue (either in method + * tryPoll() or scan) after a successful poll before trying others + * (see method topLevelExec), which also reduces bookkeeping, + * cache traffic, and scanning overhead. But it also reduces * fairness, which is partially counteracted by giving up on * contention. * * Deactivation. When method scan indicates that no tasks are - * found by a worker, it deactivates (see awaitWork). Note that - * not finding tasks doesn't mean that there won't soon be + * found by a worker, it tries to deactivate (in runWorker). Note + * that not finding tasks doesn't mean that there won't soon be * some. Further, a scan may give up under contention, returning * even without knowing whether any tasks are still present, which - * is OK, given the above signalling rules that will eventually - * maintain progress. Blocking and unblocking via park/unpark can - * cause serious slowdowns when tasks are rapidly but irregularly - * generated (which is often due to garbage collectors and other - * activities). One way to ameliorate is for workers to rescan - * multiple times, even when there are unlikely to be tasks. But - * this causes enough memory and CAS contention to prefer using - * quieter spinwaits in awaitWork; currently set to small values - * that only cover near-miss scenarios for deactivate vs activate - * races. Because idle workers are often not yet blocked (via - * LockSupport.park), we use the WorkQueue access field to - * advertise that a waiter actually needs unparking upon signal. - * - * When idle workers are not continually woken up, the count - * fields in ctl allow efficient and accurate discovery of - * quiescent states (i.e., when all workers are idle) after - * deactivation. However, this voting mechanism alone does not - * guarantee that a pool can become dormant (quiesced or - * terminated), because external racing producers do not vote, and - * can asynchronously submit new tasks. To deal with this, the - * final unparked thread (in awaitWork) scans external queues to - * check for tasks that could have been added during a race window - * that would not be accompanied by a signal, in which case - * re-activating itself (or any other worker) to recheck. The same - * sets of checks are used in tryTerminate, to correctly trigger - * delayed termination (shutDown, followed by quiescence) in the - * presence of racing submissions. In all cases, the notion of the - * "final" unparked thread is an approximation, because new - * workers could be in the process of being constructed, which - * occasionally adds some extra unnecessary processing. - * - * Shutdown and Termination. A call to shutdownNow invokes - * tryTerminate to atomically set a mode bit. The calling thread, - * as well as every other worker thereafter terminating, helps - * terminate others by cancelling their unprocessed tasks, and - * interrupting other workers. Calls to non-abrupt shutdown() - * preface this by checking isQuiescent before triggering the - * "STOP" phase of termination. During termination, workers are - * stopped using all three of (often in parallel): releasing via - * ctl (method reactivate), interrupts, and cancelling tasks that - * will cause workers to not find work and exit. To support this, - * worker references not removed from the queues array during - * termination. It is possible for late thread creations to still - * be in progress after a quiescent termination reports terminated - * status, but they will also immediately terminate. To conform to - * ExecutorService invoke, invokeAll, and invokeAny specs, we must - * track pool status while waiting in ForkJoinTask.awaitDone, and - * interrupt interruptible callers on termination, while also - * avoiding cancelling other tasks that are normally completing - * during quiescent termination. This is tracked by recording - * ForkJoinTask.POOLSUBMIT in task status and/or as a bit flag - * argument to joining methods. + * is OK given, a secondary check (in awaitWork) needed to cover + * deactivation/signal races. Blocking and unblocking via + * park/unpark can cause serious slowdowns when tasks are rapidly + * but irregularly generated (which is often due to garbage + * collectors and other activities). One way to ameliorate is for + * workers to rescan multiple times, even when there are unlikely + * to be tasks. But this causes enough memory traffic and CAS + * contention to prefer using quieter short spinwaits in awaitWork + * and elsewhere. Those in awaitWork are set to small values that + * only cover near-miss scenarios for inactivate/activate races. + * Because idle workers are often not yet blocked (parked), we use + * the WorkQueue parker field to advertise that a waiter actually + * needs unparking upon signal. + * + * Quiescence. Workers scan looking for work, giving up when they + * don't find any, without being sure that none are available. + * However, some required functionality relies on consensus about + * quiescence (also termination, discussed below). The count + * fields in ctl allow accurate discovery of states in which all + * workers are idle. However, because external (asynchronous) + * submitters are not part of this vote, these mechanisms + * themselves do not guarantee that the pool is in a quiescent + * state with respect to methods isQuiescent, shutdown (which + * begins termination when quiescent), helpQuiesce, and indirectly + * others including tryCompensate. Method quiescent() is + * used in all of these contexts. It provides checks that all + * workers are idle and there are no submissions that they could + * poll if they were not idle, retrying on inconsistent reads of + * queues and using the runState seqLock to retry on queue array + * updates. (It also reports quiescence if the pool is + * terminating.) A true report means only that there was a moment + * at which quiescence held. False negatives are inevitable (for + * example when queues indices lag updates, as described above), + * which is accommodated when (tentatively) idle by scanning for + * work etc, and then re-invoking. This includes cases in which + * the final unparked thread (in awaitWork) uses quiescent() + * to check for tasks that could have been added during a race + * window that would not be accompanied by a signal, in which case + * re-activating itself (or any other worker) to rescan. Method + * helpQuiesce acts similarly but cannot rely on ctl counts to + * determine that all workers are inactive because the caller and + * any others executing helpQuiesce are not included in counts. + * + * Termination. A call to shutdownNow invokes tryTerminate to + * atomically set a runState mode bit. However, the process of + * termination is intrinsically non-atomic. The calling thread, as + * well as other workers thereafter terminating help cancel queued + * tasks and interrupt other workers. These actions race with + * unterminated workers. By default, workers check for + * termination only when accessing pool state. This may take a + * while but suffices for structured computational tasks. But not + * necessarily for others. Class InterruptibleTask (see below) + * further arranges runState checks before executing task bodies, + * and ensures interrupts while terminating. Even so, there are no + * guarantees after an abrupt shutdown that remaining tasks + * complete normally or exceptionally or are cancelled. + * Termination may fail to complete if running tasks ignore both + * task status and interrupts and/or produce more tasks after + * others that could cancel them have exited. * * Trimming workers. To release resources after periods of lack of * use, a worker starting to wait when the pool is quiescent will @@ -610,66 +681,82 @@ public class ForkJoinPool extends AbstractExecutorService { * Joining Tasks * ============= * - * Normally, the first option when joining a task that is not done - * is to try to take it from local queue and run it. Otherwise, - * any of several actions may be taken when one worker is waiting - * to join a task stolen (or always held) by another. Because we - * are multiplexing many tasks on to a pool of workers, we can't - * always just let them block (as in Thread.join). We also cannot - * just reassign the joiner's run-time stack with another and - * replace it later, which would be a form of "continuation", that - * even if possible is not necessarily a good idea since we may - * need both an unblocked task and its continuation to progress. - * Instead we combine two tactics: - * - * Helping: Arranging for the joiner to execute some task that it - * could be running if the steal had not occurred. - * - * Compensating: Unless there are already enough live threads, - * method tryCompensate() may create or re-activate a spare - * thread to compensate for blocked joiners until they unblock. - * - * A third form (implemented via tryRemove) amounts to helping a - * hypothetical compensator: If we can readily tell that a - * possible action of a compensator is to steal and execute the - * task being joined, the joining thread can do so directly, - * without the need for a compensation thread; although with a - * possibility of reduced parallelism because of a transient gap - * in the queue array that stalls stealers. - * - * Other intermediate forms available for specific task types (for - * example helpAsyncBlocker) often avoid or postpone the need for - * blocking or compensation. - * - * The ManagedBlocker extension API can't use helping so relies - * only on compensation in method awaitBlocker. + * The "Join" part of ForkJoinPools consists of a set of + * mechanisms that sometimes or always (depending on the kind of + * task) avoid context switching or adding worker threads when one + * task would otherwise be blocked waiting for completion of + * another, basically, just by running that task or one of its + * subtasks if not already taken. These mechanics are disabled for + * InterruptibleTasks, that guarantee that callers do not executed + * submitted tasks. + * + * The basic structure of joining is an extended spin/block scheme + * in which workers check for task completions status between + * steps to find other work, until relevant pool state stabilizes + * enough to believe that no such tasks are available, at which + * point blocking. This is usually a good choice of when to block + * that would otherwise be harder to approximate. + * + * These forms of helping may increase stack space usage, but that + * space is bounded in tree/dag structured procedurally parallel + * designs to be no more than that if a task were executed only by + * the joining thread. This is arranged by associated task + * subclasses that also help detect and control the ways in which + * this may occur. * - * The algorithm in helpJoin entails a form of "linear helping". - * Each worker records (in field "source") a reference to the - * queue from which it last stole a task. The scan in method + * Normally, the first option when joining a task that is not done + * is to try to take it from the local queue and run it. Method + * tryRemoveAndExec tries to do so. For tasks with any form of + * subtasks that must be completed first, we try to locate these + * subtasks and run them as well. This is easy when local, but + * when stolen, steal-backs are restricted to the same rules as + * stealing (polling), which requires additional bookkeeping and + * scanning. This cost is still very much worthwhile because of + * its impact on task scheduling and resource control. + * + * The two methods for finding and executing subtasks vary in + * details. The algorithm in helpJoin entails a form of "linear + * helping". Each worker records (in field "source") the index of + * the internal queue from which it last stole a task. (Note: + * because chains cannot include even-numbered external queues, + * they are ignored, and 0 is an OK default.) The scan in method * helpJoin uses these markers to try to find a worker to help - * (i.e., steal back a task from and execute it) that could hasten - * completion of the actively joined task. Thus, the joiner - * executes a task that would be on its own local deque if the - * to-be-joined task had not been stolen. This is a conservative - * variant of the approach described in Wagner & Calder - * "Leapfrogging: a portable technique for implementing efficient - * futures" SIGPLAN Notices, 1993 + * (i.e., steal back a task from and execute it) that could make + * progress toward completion of the actively joined task. Thus, + * the joiner executes a task that would be on its own local deque + * if the to-be-joined task had not been stolen. This is a + * conservative variant of the approach described in Wagner & + * Calder "Leapfrogging: a portable technique for implementing + * efficient futures" SIGPLAN Notices, 1993 * (http://portal.acm.org/citation.cfm?id=155354). It differs * mainly in that we only record queues, not full dependency - * links. This requires a linear scan of the queues array to - * locate stealers, but isolates cost to when it is needed, rather - * than adding to per-task overhead. For CountedCompleters, the + * links. This requires a linear scan of the queues to locate + * stealers, but isolates cost to when it is needed, rather than + * adding to per-task overhead. For CountedCompleters, the * analogous method helpComplete doesn't need stealer-tracking, - * but requires a similar check of completion chains. + * but requires a similar (but simpler) check of completion + * chains. * * In either case, searches can fail to locate stealers when - * stalls delay recording sources. We avoid some of these cases by - * using snapshotted values of ctl as a check that the numbers of - * workers are not changing. But even when accurately identified, - * stealers might not ever produce a task that the joiner can in - * turn help with. So, compensation is tried upon failure to find - * tasks to run. + * stalls delay recording sources or issuing subtasks. We avoid + * some of these cases by using snapshotted values of ctl as a + * check that the numbers of workers are not changing, along with + * rescans to deal with contention and stalls. But even when + * accurately identified, stealers might not ever produce a task + * that the joiner can in turn help with. + * + * Related method helpAsyncBlocker does not directly rely on + * subtask structure, but instead avoids or postpones blocking of + * tagged tasks (CompletableFuture.AsynchronousCompletionTask) by + * executing other asyncs that can be processed in any order. + * This is currently invoked only in non-join-based blocking + * contexts from classes CompletableFuture and + * SubmissionPublisher, that could be further generalized. + * + * When any of the above fail to avoid blocking, we rely on + * "compensation" -- an indirect form of context switching that + * either activates an existing worker to take the place of the + * blocked one, or expands the number of workers. * * Compensation does not by default aim to keep exactly the target * parallelism number of unblocked threads running at any given @@ -677,12 +764,28 @@ public class ForkJoinPool extends AbstractExecutorService { * compensations for any blocked join. However, in practice, the * vast majority of blockages are transient byproducts of GC and * other JVM or OS activities that are made worse by replacement - * when they cause longer-term oversubscription. Rather than - * impose arbitrary policies, we allow users to override the - * default of only adding threads upon apparent starvation. The - * compensation mechanism may also be bounded. Bounds for the - * commonPool better enable JVMs to cope with programming errors - * and abuse before running out of resources to do so. + * by causing longer-term oversubscription. These are inevitable + * without (unobtainably) perfect information about whether worker + * creation is actually necessary. False alarms are common enough + * to negatively impact performance, so compensation is by default + * attempted only when it appears possible that the pool could + * stall due to lack of any unblocked workers. However, we allow + * users to override defaults using the long form of the + * ForkJoinPool constructor. The compensation mechanism may also + * be bounded. Bounds for the commonPool better enable JVMs to + * cope with programming errors and abuse before running out of + * resources to do so. + * + * The ManagedBlocker extension API can't use helping so relies + * only on compensation in method awaitBlocker. This API was + * designed to highlight the uncertainty of compensation decisions + * by requiring implementation of method isReleasable to abort + * compensation during attempts to obtain a stable snapshot. But + * users now rely upon the fact that if isReleasable always + * returns false, the API can be used to obtain precautionary + * compensation, which is sometimes the only reasonable option + * when running unknown code in tasks; which is now supported more + * simply (see method beginCompensatedBlock). * * Common Pool * =========== @@ -691,32 +794,31 @@ public class ForkJoinPool extends AbstractExecutorService { * initialization. Since it (or any other created pool) need * never be used, we minimize initial construction overhead and * footprint to the setup of about a dozen fields, although with - * some System property parsing and with security processing that - * takes far longer than the actual construction when - * SecurityManagers are used or properties are set. The common - * pool is distinguished internally by having both a null - * workerNamePrefix and ISCOMMON config bit set, along with - * PRESET_SIZE set if parallelism was configured by system - * property. - * - * When external threads use ForkJoinTask.fork for the common - * pool, they can perform subtask processing (see helpComplete and - * related methods) upon joins. This caller-helps policy makes it - * sensible to set common pool parallelism level to one (or more) - * less than the total number of available cores, or even zero for - * pure caller-runs. For the sake of ExecutorService specs, we can - * only do this for tasks entered via fork, not submit. We track - * this using a task status bit (markPoolSubmission). In all - * other cases, external threads waiting for joins first check the - * common pool for their task, which fails quickly if the caller - * did not fork to common pool. + * some System property parsing and security processing that takes + * far longer than the actual construction when SecurityManagers + * are used or properties are set. The common pool is + * distinguished by having a null workerNamePrefix (which is an + * odd convention, but avoids the need to decode status in factory + * classes). It also has PRESET_SIZE config set if parallelism + * was configured by system property. + * + * When external threads use the common pool, they can perform + * subtask processing (see helpComplete and related methods) upon + * joins, unless they are submitted using ExecutorService + * submission methods, which implicitly disallow this. This + * caller-helps policy makes it sensible to set common pool + * parallelism level to one (or more) less than the total number + * of available cores, or even zero for pure caller-runs. External + * threads waiting for joins first check the common pool for their + * task, which fails quickly if the caller did not fork to common + * pool. * * Guarantees for common pool parallelism zero are limited to * tasks that are joined by their callers in a tree-structured * fashion or use CountedCompleters (as is true for jdk * parallelStreams). Support infiltrates several methods, - * including those that retry helping steps or spin until we are - * sure that none apply if there are no workers. + * including those that retry helping steps until we are sure that + * none apply if there are no workers. * * As a more appropriate default in managed environments, unless * overridden by system properties, we use workers of subclass @@ -727,55 +829,82 @@ public class ForkJoinPool extends AbstractExecutorService { * may be JVM-dependent and must access particular Thread class * fields to achieve this effect. * - * Interrupt handling - * ================== - * - * The framework is designed to manage task cancellation - * (ForkJoinTask.cancel) independently from the interrupt status - * of threads running tasks. (See the public ForkJoinTask - * documentation for rationale.) Interrupts are issued only in - * tryTerminate, when workers should be terminating and tasks - * should be cancelled anyway. Interrupts are cleared only when - * necessary to ensure that calls to LockSupport.park do not loop - * indefinitely (park returns immediately if the current thread is - * interrupted). For cases in which task bodies are specified or - * desired to interrupt upon cancellation, ForkJoinTask.cancel can - * be overridden to do so (as is done for invoke{Any,All}). + * InterruptibleTasks + * ==================== + * + * Regular ForkJoinTasks manage task cancellation (method cancel) + * independently from the interrupt status of threads running + * tasks. Interrupts are issued internally only while + * terminating, to wake up workers and cancel queued tasks. By + * default, interrupts are cleared only when necessary to ensure + * that calls to LockSupport.park do not loop indefinitely (park + * returns immediately if the current thread is interrupted). + * + * To comply with ExecutorService specs, we use subclasses of + * abstract class InterruptibleTask for tasks that require + * stronger interruption and cancellation guarantees. External + * submitters never run these tasks, even if in the common pool. + * InterruptibleTasks include a "runner" field (implemented + * similarly to FutureTask) to support cancel(true). Upon pool + * shutdown, runners are interrupted so they can cancel. Since + * external joining callers never run these tasks, they must await + * cancellation by others, which can occur along several different + * paths. + * + * Across these APIs, rules for reporting exceptions for tasks + * with results accessed via join() differ from those via get(), + * which differ from those invoked using pool submit methods by + * non-workers (which comply with Future.get() specs). Internal + * usages of ForkJoinTasks ignore interrupt status when executing + * or awaiting completion. Otherwise, reporting task results or + * exceptions is preferred to throwing InterruptedExecptions, + * which are in turn preferred to timeouts. Similarly, completion + * status is preferred to reporting cancellation. Cancellation is + * reported as an unchecked exception by join(), and by worker + * calls to get(), but is otherwise wrapped in a (checked) + * ExecutionException. + * + * Worker Threads cannot be VirtualThreads, as enforced by + * requiring ForkJoinWorkerThreads in factories. There are + * several constructions relying on this. However as of this + * writing, virtual thread bodies are by default run as some form + * of InterruptibleTask. * * Memory placement * ================ * * Performance is very sensitive to placement of instances of - * ForkJoinPool and WorkQueues and their queue arrays, as well the - * placement of their fields. Caches misses and contention due to - * false-sharing have been observed to slow down some programs by - * more than a factor of four. There is no perfect solution, in - * part because isolating more fields also generates more cache - * misses in more common cases (because some fields snd slots are - * usually read at the same time), and the main means of placing - * memory, the @Contended annotation provides only rough control - * (for good reason). We isolate the ForkJoinPool.ctl field as - * well the set of WorkQueue fields that otherwise cause the most - * false-sharing misses with respect to other fields. Also, - * ForkJoinPool fields are ordered such that fields less prone to - * contention effects are first, offsetting those that otherwise - * would be, while also reducing total footprint vs using - * multiple @Contended regions, which tends to slow down - * less-contended applications. These arrangements mainly reduce - * cache traffic by scanners, which speeds up finding tasks to - * run. Initial sizing and resizing of WorkQueue arrays is an - * even more delicate tradeoff because the best strategy may vary - * across garbage collectors. Small arrays are better for locality - * and reduce GC scan time, but large arrays reduce both direct - * false-sharing and indirect cases due to GC bookkeeping + * ForkJoinPool and WorkQueues and their queue arrays, as well as + * the placement of their fields. Caches misses and contention due + * to false-sharing have been observed to slow down some programs + * by more than a factor of four. Effects may vary across initial + * memory configuarations, applications, and different garbage + * collectors and GC settings, so there is no perfect solution. + * Too much isolation may generate more cache misses in common + * cases (because some fields snd slots are usually read at the + * same time). The @Contended annotation provides only rough + * control (for good reason). Similarly for relying on fields + * being placed in size-sorted declaration order. + * + * For class ForkJoinPool, it is usually more effective to order + * fields such that the most commonly accessed fields are unlikely + * to share cache lines with adjacent objects under JVM layout + * rules. For class WorkQueue, an embedded @Contended region + * segregates fields most heavily updated by owners from those + * most commonly read by stealers or other management. Initial + * sizing and resizing of WorkQueue arrays is an even more + * delicate tradeoff because the best strategy systematically + * varies across garbage collectors. Small arrays are better for + * locality and reduce GC scan time, but large arrays reduce both + * direct false-sharing and indirect cases due to GC bookkeeping * (cardmarks etc), and reduce the number of resizes, which are - * not especially fast because they require atomic transfers, and - * may cause other scanning workers to stall or give up. + * not especially fast because they require atomic transfers. * Currently, arrays are initialized to be fairly small but early * resizes rapidly increase size by more than a factor of two * until very large. (Maintenance note: any changes in fields, - * queues, or their uses must be accompanied by re-evaluation of - * these placement and sizing decisions.) + * queues, or their uses, or JVM layout policies, must be + * accompanied by re-evaluation of these placement and sizing + * decisions.) * * Style notes * =========== @@ -787,7 +916,9 @@ public class ForkJoinPool extends AbstractExecutorService { * other jdk components that require early parallelism. This can * be awkward and ugly, but also reflects the need to control * outcomes across the unusual cases that arise in very racy code - * with very few invariants. All fields are read into locals + * with very few invariants. All atomic task slot updates use + * Unsafe operations requiring offset positions, not indices, as + * computed by method slotOffset. All fields are read into locals * before use, and null-checked if they are references, even if * they can never be null under current usages. Usually, * computations (held in local variables) are defined as soon as @@ -818,7 +949,7 @@ public class ForkJoinPool extends AbstractExecutorService { * perform reasonably even when interpreted (not compiled). * * The order of declarations in this file is (with a few exceptions): - * (1) Static constants + * (1) Static configuration constants * (2) Static utility functions * (3) Nested (static) classes * (4) Fields, along with constants used when unpacking some of them @@ -832,15 +963,19 @@ public class ForkJoinPool extends AbstractExecutorService { * * The main sources of differences from previous version are: * - * * Use of Unsafe vs VarHandle, including re-instatement of some - * constructions from pre-VarHandle versions. - * * Reduced memory and signal contention, mainly by distinguishing - * failure cases. - * * Improved initialization, in part by preparing for possible - * removal of SecurityManager - * * Enable resizing (includes refactoring quiescence/termination) - * * Unification of most internal vs external operations; some made - * possible via use of WorkQueue.access, and POOLSUBMIT status in tasks. + * * New abstract class ForkJoinTask.InterruptibleTask ensures + * handling of tasks submitted under the ExecutorService + * API are consistent with specs. + * * Method quiescent() replaces previous quiescence-related + * checks, relying on versioning and sequence locking instead + * of ReentrantLock. + * * Termination processing now ensures that internal data + * structures are maintained consistently enough while stopping + * to interrupt all workers and cancel all tasks. It also uses a + * CountDownLatch instead of a Condition for termination because + * of lock change. + * * Many other changes to avoid performance regressions due + * to the above. */ // static configuration constants @@ -860,7 +995,7 @@ public class ForkJoinPool extends AbstractExecutorService { * The default value for common pool maxSpares. Overridable using * the "java.util.concurrent.ForkJoinPool.common.maximumSpares" * system property. The default value is far in excess of normal - * requirements, but also far short of MAX_CAP and typical OS + * requirements, but also far short of maximum capacity and typical OS * thread limits, so allows JVMs to catch misuse/abuse before * running out of resources needed to do so. */ @@ -872,26 +1007,42 @@ public class ForkJoinPool extends AbstractExecutorService { */ static final int INITIAL_QUEUE_CAPACITY = 1 << 6; - // Bounds - static final int SWIDTH = 16; // width of short - static final int SMASK = 0xffff; // short bits == max index - static final int MAX_CAP = 0x7fff; // max #workers - 1 - - // pool.runState and workQueue.access bits and sentinels - static final int STOP = 1 << 31; // must be negative - static final int SHUTDOWN = 1; - static final int TERMINATED = 2; - static final int PARKED = -1; // access value when parked - - // {pool, workQueue}.config bits - static final int FIFO = 1 << 16; // fifo queue or access mode - static final int SRC = 1 << 17; // set when stealable - static final int CLEAR_TLS = 1 << 18; // set for Innocuous workers - static final int TRIMMED = 1 << 19; // timed out while idle - static final int ISCOMMON = 1 << 20; // set for common pool - static final int PRESET_SIZE = 1 << 21; // size was set by property - - static final int UNCOMPENSATE = 1 << 16; // tryCompensate return + // conversions among short, int, long + static final int SMASK = 0xffff; // (unsigned) short bits + static final long LMASK = 0xffffffffL; // lower 32 bits of long + static final long UMASK = ~LMASK; // upper 32 bits + + // masks and sentinels for queue indices + static final int MAX_CAP = 0x7fff; // max # workers + static final int EXTERNAL_ID_MASK = 0x3ffe; // max external queue id + static final int INVALID_ID = 0x4000; // unused external queue id + + // pool.runState bits + static final int STOP = 1 << 0; // terminating + static final int SHUTDOWN = 1 << 1; // terminate when quiescent + static final int TERMINATED = 1 << 2; // only set if STOP also set + static final int RS_LOCK = 1 << 3; // lowest seqlock bit + + // spin/sleep limits for runState locking and elsewhere + static final int SPIN_WAITS = 1 << 7; // max calls to onSpinWait + static final int MIN_SLEEP = 1 << 10; // approx 1 usec as nanos + static final int MAX_SLEEP = 1 << 20; // approx 1 sec as nanos + + // {pool, workQueue} config bits + static final int FIFO = 1 << 0; // fifo queue or access mode + static final int CLEAR_TLS = 1 << 1; // set for Innocuous workers + static final int PRESET_SIZE = 1 << 2; // size was set by property + + // source history window packing used in scan() and runWorker() + static final long RESCAN = 1L << 63; // must be negative + static final long WMASK = ~(((long)SMASK) << 48); // id bits only + static final long NO_HISTORY = ((((long)INVALID_ID) << 32) | // no 3rd + (((long)INVALID_ID) << 16)); // no 2nd + + // others + static final int DEREGISTERED = 1 << 31; // worker terminating + static final int UNCOMPENSATE = 1 << 16; // tryCompensate return + static final int IDLE = 1 << 16; // phase seqlock/version count /* * Bits and masks for ctl and bounds are packed with 4 16 bit subfields: @@ -911,9 +1062,6 @@ public class ForkJoinPool extends AbstractExecutorService { * Other updates of multiple subfields require CAS. */ - // Lower and upper word masks - static final long SP_MASK = 0xffffffffL; - static final long UC_MASK = ~SP_MASK; // Release counts static final int RC_SHIFT = 48; static final long RC_UNIT = 0x0001L << RC_SHIFT; @@ -922,12 +1070,26 @@ public class ForkJoinPool extends AbstractExecutorService { static final int TC_SHIFT = 32; static final long TC_UNIT = 0x0001L << TC_SHIFT; static final long TC_MASK = 0xffffL << TC_SHIFT; - // sp bits - static final int SS_SEQ = 1 << 16; // version count - static final int INACTIVE = 1 << 31; // phase bit when idle + + /* + * All atomic operations on task arrays (queues) use Unsafe + * operations that take array offsets versus indices, based on + * array base and shift constants established during static + * initialization. + */ + static final long ABASE; + static final int ASHIFT; // Static utilities + /** + * Returns the array offset corresponding to the given index for + * Unsafe task queue operations + */ + static long slotOffset(int index) { + return ((long)index << ASHIFT) + ABASE; + } + /** * If there is a security manager, makes sure caller has * permission to modify threads. @@ -1046,72 +1208,80 @@ public ForkJoinWorkerThread run() { * submission. See above for descriptions and algorithms. */ static final class WorkQueue { - int stackPred; // pool stack (ctl) predecessor link - int config; // index, mode, ORed with SRC after init - int base; // index of next slot for poll + // fields declared in order of their likely layout on most VMs + final ForkJoinWorkerThread owner; // null if shared + volatile Thread parker; // set when parking in awaitWork ForkJoinTask[] array; // the queued tasks; power of 2 size - final ForkJoinWorkerThread owner; // owning thread or null if shared + int base; // index of next slot for poll + final int config; // mode bits // fields otherwise causing more unnecessary false-sharing cache misses @jdk.internal.vm.annotation.Contended("w") int top; // index of next slot for push @jdk.internal.vm.annotation.Contended("w") - volatile int access; // values 0, 1 (locked), PARKED, STOP + volatile int phase; // versioned active status @jdk.internal.vm.annotation.Contended("w") - volatile int phase; // versioned, negative if inactive + int stackPred; // pool stack (ctl) predecessor link @jdk.internal.vm.annotation.Contended("w") - volatile int source; // source queue id in topLevelExec + volatile int source; // source queue id (or DEREGISTERED) @jdk.internal.vm.annotation.Contended("w") int nsteals; // number of steals from other queues // Support for atomic operations private static final Unsafe U; - private static final long ACCESS; private static final long PHASE; - private static final long ABASE; - private static final int ASHIFT; + private static final long BASE; + private static final long TOP; + private static final long SOURCE; + private static final long ARRAY; - static ForkJoinTask getAndClearSlot(ForkJoinTask[] a, int i) { - return (ForkJoinTask) - U.getAndSetReference(a, ((long)i << ASHIFT) + ABASE, null); + final void updateBase(int v) { + U.putIntVolatile(this, BASE, v); + } + final void updateTop(int v) { + U.putIntOpaque(this, TOP, v); } - static boolean casSlotToNull(ForkJoinTask[] a, int i, - ForkJoinTask c) { - return U.compareAndSetReference(a, ((long)i << ASHIFT) + ABASE, - c, null); + final void forgetSource() { + U.putIntOpaque(this, SOURCE, 0); } - final void forcePhaseActive() { // clear sign bit - U.getAndBitwiseAndInt(this, PHASE, 0x7fffffff); + final void updateArray(ForkJoinTask[] a) { + U.getAndSetReference(this, ARRAY, a); } - final int getAndSetAccess(int v) { - return U.getAndSetInt(this, ACCESS, v); + final void unlockPhase() { + U.getAndAddInt(this, PHASE, IDLE); } - final void releaseAccess() { - U.putIntRelease(this, ACCESS, 0); + final boolean tryLockPhase() { // seqlock acquire + int p; + return (((p = phase) & IDLE) != 0 && + U.compareAndSetInt(this, PHASE, p, p + IDLE)); } /** - * Constructor. For owned queues, most fields are initialized + * Constructor. For internal queues, most fields are initialized * upon thread start in pool.registerWorker. */ - WorkQueue(ForkJoinWorkerThread owner, int config) { + WorkQueue(ForkJoinWorkerThread owner, int id, int cfg, + boolean clearThreadLocals) { + if (clearThreadLocals) + cfg |= CLEAR_TLS; + this.config = cfg; + top = base = 1; + this.phase = id; this.owner = owner; - this.config = config; - base = top = 1; } /** * Returns an exportable index (used by ForkJoinWorkerThread). */ final int getPoolIndex() { - return (config & 0xffff) >>> 1; // ignore odd/even tag bit + return (phase & 0xffff) >>> 1; // ignore odd/even tag bit } /** * Returns the approximate number of tasks in the queue. */ final int queueSize() { - int unused = access; // for ordering effect + int unused = phase; // for ordering effect return Math.max(top - base, 0); // ignore transient negative } @@ -1119,42 +1289,50 @@ final int queueSize() { * Pushes a task. Called only by owner or if already locked * * @param task the task. Caller must ensure non-null. - * @param pool the pool. Must be non-null unless terminating. - * @param signalIfEmpty true if signal when pushing to empty queue - * @throws RejectedExecutionException if array cannot be resized + * @param pool the pool to signal if was previously empty, else null + * @param internal if caller owns this queue + * @throws RejectedExecutionException if array could not be resized */ final void push(ForkJoinTask task, ForkJoinPool pool, - boolean signalIfEmpty) { - boolean resize = false; - int s = top++, b = base, cap, m; ForkJoinTask[] a; - if ((a = array) != null && (cap = a.length) > 0) { - if ((m = (cap - 1)) == s - b) { - resize = true; // rapidly grow until large - int newCap = (cap < 1 << 24) ? cap << 2 : cap << 1; - ForkJoinTask[] newArray; + boolean internal) { + int s = top, b = base, cap, m, room; ForkJoinTask[] a; + if ((a = array) == null || (cap = a.length) <= 0 || + (room = (m = cap - 1) - (s - b)) < 0) { // could not resize + if (!internal) + unlockPhase(); + throw new RejectedExecutionException("Queue capacity exceeded"); + } + top = s + 1; + long pos = slotOffset(m & s); + if (!internal) + U.putReference(a, pos, task); // inside lock + else + U.getAndSetReference(a, pos, task); // fully fenced + if (room == 0) { // resize for next time + int newCap; // rapidly grow until large + if ((newCap = (cap < 1 << 24) ? cap << 2 : cap << 1) > 0) { + ForkJoinTask[] newArray = null; try { newArray = new ForkJoinTask[newCap]; - } catch (Throwable ex) { - top = s; - access = 0; - throw new RejectedExecutionException( - "Queue capacity exceeded"); + } catch (OutOfMemoryError ex) { } - if (newCap > 0) { // always true - int newMask = newCap - 1, k = s; - do { // poll old, push to new - newArray[k-- & newMask] = task; - } while ((task = getAndClearSlot(a, k & m)) != null); + if (newArray != null) { // else throw on next push + int newMask = newCap - 1; // poll old, push to new + for (int k = s, j = cap; j > 0; --j, --k) { + if ((newArray[k & newMask] = + (ForkJoinTask)U.getAndSetReference( + a, slotOffset(k & m), null)) == null) + break; // lost to pollers + } + updateArray(newArray); // fully fenced } - array = newArray; } - else - a[m & s] = task; - getAndSetAccess(0); // for memory effects if owned - if ((resize || (a[m & (s - 1)] == null && signalIfEmpty)) && - pool != null) - pool.signalWork(); } + if (!internal) + unlockPhase(); + if ((room == 0 || room >= m || a[m & (s - 1)] == null) && + pool != null) + pool.signalWork(); } /** @@ -1162,36 +1340,35 @@ final void push(ForkJoinTask task, ForkJoinPool pool, * so acts as either local-pop or local-poll. Called only by owner. * @param fifo nonzero if FIFO mode */ - final ForkJoinTask nextLocalTask(int fifo) { + private ForkJoinTask nextLocalTask(int fifo) { ForkJoinTask t = null; ForkJoinTask[] a = array; - int p = top, s = p - 1, b = base, nb, cap; - if (p - b > 0 && a != null && (cap = a.length) > 0) { - do { + int b = base, p = top, cap; + if (a != null && (cap = a.length) > 0) { + for (int m = cap - 1, s, nb; p - b > 0; ) { if (fifo == 0 || (nb = b + 1) == p) { - if ((t = getAndClearSlot(a, (cap - 1) & s)) != null) - top = s; - break; // lost race for only task + if ((t = (ForkJoinTask)U.getAndSetReference( + a, slotOffset(m & (s = p - 1)), null)) != null) + updateTop(s); // else lost race for only task + break; } - else if ((t = getAndClearSlot(a, (cap - 1) & b)) != null) { - base = nb; + if ((t = (ForkJoinTask)U.getAndSetReference( + a, slotOffset(m & b), null)) != null) { + updateBase(nb); break; } - else { - while (b == (b = base)) { - U.loadFence(); - Thread.onSpinWait(); // spin to reduce memory traffic - } + while (b == (b = base)) { + U.loadFence(); + Thread.onSpinWait(); // spin to reduce memory traffic } - } while (p - b > 0); - U.storeStoreFence(); // for timely index updates + } } return t; } /** * Takes next task, if one exists, using configured mode. - * (Always owned, never called for Common pool.) + * (Always internal, never called for Common pool.) */ final ForkJoinTask nextLocalTask() { return nextLocalTask(config & FIFO); @@ -1199,24 +1376,25 @@ final ForkJoinTask nextLocalTask() { /** * Pops the given task only if it is at the current top. + * @param task the task. Caller must ensure non-null. + * @param internal if caller owns this queue */ - final boolean tryUnpush(ForkJoinTask task, boolean owned) { + final boolean tryUnpush(ForkJoinTask task, boolean internal) { + boolean taken = false; ForkJoinTask[] a = array; - int p = top, s, cap, k; - if (task != null && base != p && a != null && (cap = a.length) > 0 && - a[k = (cap - 1) & (s = p - 1)] == task) { - if (owned || getAndSetAccess(1) == 0) { - if (top != p || a[k] != task || - getAndClearSlot(a, k) == null) - access = 0; - else { - top = s; - access = 0; - return true; - } + int p = top, s = p - 1, cap, k; + if (a != null && (cap = a.length) > 0 && + a[k = (cap - 1) & s] == task && + (internal || tryLockPhase())) { + if (top == p && + U.compareAndSetReference(a, slotOffset(k), task, null)) { + taken = true; + updateTop(s); } + if (!internal) + unlockPhase(); } - return false; + return taken; } /** @@ -1224,7 +1402,7 @@ final boolean tryUnpush(ForkJoinTask task, boolean owned) { */ final ForkJoinTask peek() { ForkJoinTask[] a = array; - int cfg = config, p = top, b = base, cap; + int b = base, cfg = config, p = top, cap; if (p != b && a != null && (cap = a.length) > 0) { if ((cfg & FIFO) == 0) return a[(cap - 1) & (p - 1)]; @@ -1240,60 +1418,52 @@ final ForkJoinTask peek() { } /** - * Polls for a task. Used only by non-owners in usually - * uncontended contexts. + * Polls for a task. Used only by non-owners. * * @param pool if nonnull, pool to signal if more tasks exist */ final ForkJoinTask poll(ForkJoinPool pool) { - for (int b = base;;) { - int cap; ForkJoinTask[] a; - if ((a = array) == null || (cap = a.length) <= 0) - break; // currently impossible - int k = (cap - 1) & b, nb = b + 1, nk = (cap - 1) & nb; - ForkJoinTask t = a[k]; - U.loadFence(); // for re-reads - if (b != (b = base)) // inconsistent - ; - else if (t != null && casSlotToNull(a, k, t)) { - base = nb; - U.storeFence(); - if (pool != null && a[nk] != null) - pool.signalWork(); // propagate - return t; + for (;;) { + ForkJoinTask[] a = array; + int b = base, cap, k; + if (a == null || (cap = a.length) <= 0) + break; + ForkJoinTask t = a[k = b & (cap - 1)]; + U.loadFence(); + if (base == b) { + Object o; + int nb = b + 1, nk = nb & (cap - 1); + if (t == null) + o = a[k]; + else if (t == (o = U.compareAndExchangeReference( + a, slotOffset(k), t, null))) { + updateBase(nb); + if (a[nk] != null && pool != null) + pool.signalWork(); // propagate + return t; + } + if (o == null && a[nk] == null && array == a && + (phase & (IDLE | 1)) != 0 && top - base <= 0) + break; // empty } - else if (array != a || a[k] != null) - ; // stale - else if (a[nk] == null && top - b <= 0) - break; // empty } return null; } /** - * Tries to poll next task in FIFO order, failing on - * contention or stalls. Used only by topLevelExec to repoll - * from the queue obtained from pool.scan. + * Tries to poll next task in FIFO order, failing without + * retries on contention or stalls. Used only by topLevelExec + * to repoll from the queue obtained from pool.scan. */ - final ForkJoinTask tryPoll() { - int b = base, cap; ForkJoinTask[] a; - if ((a = array) != null && (cap = a.length) > 0) { - for (;;) { - int k = (cap - 1) & b, nb = b + 1; - ForkJoinTask t = a[k]; - U.loadFence(); // for re-reads - if (b != (b = base)) - ; // inconsistent - else if (t != null) { - if (casSlotToNull(a, k, t)) { - base = nb; - U.storeStoreFence(); - return t; - } - break; // contended - } - else if (a[k] == null) - break; // empty or stalled + private ForkJoinTask tryPoll() { + ForkJoinTask t; ForkJoinTask[] a; int b, cap, k; + if ((a = array) != null && (cap = a.length) > 0 && + (t = a[k = (b = base) & (cap - 1)]) != null) { + U.loadFence(); + if (base == b && + U.compareAndSetReference(a, slotOffset(k), t, null)) { + updateBase(b + 1); + return t; } } return null; @@ -1303,59 +1473,64 @@ else if (a[k] == null) /** * Runs the given (stolen) task if nonnull, as well as - * remaining local tasks and/or others available from its - * source queue, if any. + * remaining local tasks and/or others available from the + * given queue, if any. */ - final void topLevelExec(ForkJoinTask task, WorkQueue src) { - int cfg = config, fifo = cfg & FIFO, nstolen = 1; + final void topLevelExec(ForkJoinTask task, WorkQueue src, int srcId) { + int cfg = config, fifo = cfg & FIFO, nstolen = nsteals + 1; + if ((srcId & 1) != 0) // don't record external sources + source = srcId; + if ((cfg & CLEAR_TLS) != 0) + ThreadLocalRandom.eraseThreadLocals(Thread.currentThread()); while (task != null) { task.doExec(); - if ((task = nextLocalTask(fifo)) == null && - src != null && (task = src.tryPoll()) != null) + if ((task = nextLocalTask(fifo)) == null && src != null && + (task = src.tryPoll()) != null) ++nstolen; } - nsteals += nstolen; - source = 0; - if ((cfg & CLEAR_TLS) != 0) - ThreadLocalRandom.eraseThreadLocals(Thread.currentThread()); + nsteals = nstolen; + forgetSource(); } /** * Deep form of tryUnpush: Traverses from top and removes and - * runs task if present, shifting others to fill gap. - * @return task status if removed, else 0 + * runs task if present. */ - final int tryRemoveAndExec(ForkJoinTask task, boolean owned) { + final void tryRemoveAndExec(ForkJoinTask task, boolean internal) { ForkJoinTask[] a = array; - int p = top, s = p - 1, d = p - base, cap; - if (task != null && d > 0 && a != null && (cap = a.length) > 0) { - for (int m = cap - 1, i = s; ; --i) { - ForkJoinTask t; int k; - if ((t = a[k = i & m]) == task) { - if (!owned && getAndSetAccess(1) != 0) - break; // fail if locked - else if (top != p || a[k] != task || - getAndClearSlot(a, k) == null) { - access = 0; - break; // missed - } - else { - if (i != s && i == base) - base = i + 1; // avoid shift - else { - for (int j = i; j != s;) // shift down - a[j & m] = getAndClearSlot(a, ++j & m); - top = s; + int b = base, p = top, s = p - 1, d = p - b, cap; + if (a != null && (cap = a.length) > 0) { + for (int m = cap - 1, i = s; d > 0; --i, --d) { + ForkJoinTask t; int k; boolean taken; + if ((t = a[k = i & m]) == null) + break; + if (t == task) { + long pos = slotOffset(k); + if (!internal && !tryLockPhase()) + break; // fail if locked + if (taken = + (top == p && + U.compareAndSetReference(a, pos, task, null))) { + if (i == s) // act as pop + updateTop(s); + else if (i == base) // act as poll + updateBase(i + 1); + else { // swap with top + U.putReferenceVolatile( + a, pos, (ForkJoinTask) + U.getAndSetReference( + a, slotOffset(s & m), null)); + updateTop(s); } - releaseAccess(); - return task.doExec(); } - } - else if (t == null || --d == 0) + if (!internal) + unlockPhase(); + if (taken) + task.doExec(); break; + } } } - return 0; } /** @@ -1364,39 +1539,45 @@ else if (t == null || --d == 0) * * @param task root of computation * @param limit max runs, or zero for no limit - * @return task status on exit + * @return task status if known to be done */ - final int helpComplete(ForkJoinTask task, boolean owned, int limit) { + final int helpComplete(ForkJoinTask task, boolean internal, int limit) { int status = 0; if (task != null) { outer: for (;;) { - ForkJoinTask[] a; ForkJoinTask t; - int p, s, cap, k; - if ((status = task.status) < 0) - return status; - if ((a = array) == null || (cap = a.length) <= 0 || - (t = a[k = (cap - 1) & (s = (p = top) - 1)]) == null || - !(t instanceof CountedCompleter)) + ForkJoinTask[] a; ForkJoinTask t; boolean taken; + int stat, p, s, cap, k; + if ((stat = task.status) < 0) { + status = stat; + break; + } + if ((a = array) == null || (cap = a.length) <= 0) + break; + if ((t = a[k = (cap - 1) & (s = (p = top) - 1)]) == null) + break; + if (!(t instanceof CountedCompleter)) break; - for (CountedCompleter f = (CountedCompleter)t;;) { + CountedCompleter f = (CountedCompleter)t; + for (int steps = cap;;) { // bound path if (f == task) break; - else if ((f = f.completer) == null) - break outer; // ineligible + if ((f = f.completer) == null || --steps == 0) + break outer; } - if (!owned && getAndSetAccess(1) != 0) - break; // fail if locked - if (top != p || a[k] != t || getAndClearSlot(a, k) == null) { - access = 0; - break; // missed - } - top = s; - releaseAccess(); + if (!internal && !tryLockPhase()) + break; + if (taken = + (top == p && + U.compareAndSetReference(a, slotOffset(k), t, null))) + updateTop(s); + if (!internal) + unlockPhase(); + if (!taken) + break; t.doExec(); if (limit != 0 && --limit == 0) break; } - status = task.status; } return status; } @@ -1408,67 +1589,50 @@ else if ((f = f.completer) == null) * @param blocker the blocker */ final void helpAsyncBlocker(ManagedBlocker blocker) { - if (blocker != null) { - for (;;) { - int b = base, cap; ForkJoinTask[] a; - if ((a = array) == null || (cap = a.length) <= 0 || b == top) - break; - int k = (cap - 1) & b, nb = b + 1, nk = (cap - 1) & nb; - ForkJoinTask t = a[k]; - U.loadFence(); // for re-reads - if (base != b) - ; - else if (blocker.isReleasable()) - break; - else if (a[k] != t) - ; - else if (t != null) { - if (!(t instanceof CompletableFuture - .AsynchronousCompletionTask)) - break; - else if (casSlotToNull(a, k, t)) { - base = nb; - U.storeStoreFence(); - t.doExec(); - } - } - else if (a[nk] == null) + for (;;) { + ForkJoinTask[] a; int b, cap, k; + if ((a = array) == null || (cap = a.length) <= 0) + break; + ForkJoinTask t = a[k = (b = base) & (cap - 1)]; + U.loadFence(); + if (t == null) { + if (top - b <= 0) break; } + else if (!(t instanceof CompletableFuture + .AsynchronousCompletionTask)) + break; + if (blocker != null && blocker.isReleasable()) + break; + if (base == b && t != null && + U.compareAndSetReference(a, slotOffset(k), t, null)) { + updateBase(b + 1); + t.doExec(); + } } } // misc /** - * Returns true if owned by a worker thread and not known to be blocked. + * Returns true if internal and not known to be blocked. */ final boolean isApparentlyUnblocked() { Thread wt; Thread.State s; - return (access != STOP && (wt = owner) != null && + return ((wt = owner) != null && (phase & IDLE) != 0 && (s = wt.getState()) != Thread.State.BLOCKED && s != Thread.State.WAITING && s != Thread.State.TIMED_WAITING); } - /** - * Called in constructors if ThreadLocals not preserved - */ - final void setClearThreadLocals() { - config |= CLEAR_TLS; - } - static { U = Unsafe.getUnsafe(); Class klass = WorkQueue.class; - ACCESS = U.objectFieldOffset(klass, "access"); PHASE = U.objectFieldOffset(klass, "phase"); - Class aklass = ForkJoinTask[].class; - ABASE = U.arrayBaseOffset(aklass); - int scale = U.arrayIndexScale(aklass); - ASHIFT = 31 - Integer.numberOfLeadingZeros(scale); - if ((scale & (scale - 1)) != 0) - throw new Error("array index scale not a power of two"); + BASE = U.objectFieldOffset(klass, "base"); + TOP = U.objectFieldOffset(klass, "top"); + SOURCE = U.objectFieldOffset(klass, "source"); + ARRAY = U.objectFieldOffset(klass, "array"); } } @@ -1500,27 +1664,21 @@ final void setClearThreadLocals() { */ static volatile RuntimePermission modifyThreadPermission; - - // Instance fields - volatile long stealCount; // collects worker nsteals - volatile long threadIds; // for worker thread names - final long keepAlive; // milliseconds before dropping if idle - final long bounds; // min, max threads packed as shorts - final int config; // static configuration bits - volatile int runState; // SHUTDOWN, STOP, TERMINATED bits - WorkQueue[] queues; // main registry - final ReentrantLock registrationLock; - Condition termination; // lazily constructed - final String workerNamePrefix; // null for common pool + // fields declared in order of their likely layout on most VMs + volatile CountDownLatch termination; // lazily constructed + final Predicate saturate; final ForkJoinWorkerThreadFactory factory; final UncaughtExceptionHandler ueh; // per-worker UEH - final Predicate saturate; final SharedThreadContainer container; - - @jdk.internal.vm.annotation.Contended("fjpctl") // segregate + final String workerNamePrefix; // null for common pool + WorkQueue[] queues; // main registry + final long keepAlive; // milliseconds before dropping if idle + final long config; // static configuration bits + volatile long stealCount; // collects worker nsteals + volatile long threadIds; // for worker thread names volatile long ctl; // main pool control - @jdk.internal.vm.annotation.Contended("fjpctl") // colocate int parallelism; // target number of workers + volatile int runState; // versioned, lockable // Support for atomic operations private static final Unsafe U; @@ -1528,6 +1686,7 @@ final void setClearThreadLocals() { private static final long RUNSTATE; private static final long PARALLELISM; private static final long THREADIDS; + private static final long TERMINATION; private static final Object POOLIDS_BASE; private static final long POOLIDS; @@ -1540,9 +1699,6 @@ private long compareAndExchangeCtl(long c, long v) { private long getAndAddCtl(long v) { return U.getAndAddLong(this, CTL, v); } - private int getAndBitwiseOrRunState(int v) { - return U.getAndBitwiseOrInt(this, RUNSTATE, v); - } private long incrementThreadIds() { return U.getAndAddLong(this, THREADIDS, 1L); } @@ -1555,6 +1711,51 @@ private int getAndSetParallelism(int v) { private int getParallelismOpaque() { return U.getIntOpaque(this, PARALLELISM); } + private CountDownLatch cmpExTerminationSignal(CountDownLatch x) { + return (CountDownLatch) + U.compareAndExchangeReference(this, TERMINATION, null, x); + } + + // runState operations + + private int getAndBitwiseOrRunState(int v) { // for status bits + return U.getAndBitwiseOrInt(this, RUNSTATE, v); + } + private boolean casRunState(int c, int v) { + return U.compareAndSetInt(this, RUNSTATE, c, v); + } + private void unlockRunState() { // increment lock bit + U.getAndAddInt(this, RUNSTATE, RS_LOCK); + } + private int lockRunState() { // lock and return current state + int s, u; // locked when RS_LOCK set + if (((s = runState) & RS_LOCK) == 0 && casRunState(s, u = s + RS_LOCK)) + return u; + else + return spinLockRunState(); + } + private int spinLockRunState() { // spin/sleep + for (int waits = 0, s, u;;) { + if (((s = runState) & RS_LOCK) == 0) { + if (casRunState(s, u = s + RS_LOCK)) + return u; + waits = 0; + } else if (waits < SPIN_WAITS) { + ++waits; + Thread.onSpinWait(); + } else { + if (waits < MIN_SLEEP) + waits = MIN_SLEEP; + LockSupport.parkNanos(this, (long)waits); + if (waits < MAX_SLEEP) + waits <<= 1; + } + } + } + + static boolean poolIsStopping(ForkJoinPool p) { // Used by ForkJoinTask + return p != null && (p.runState & STOP) != 0; + } // Creating, registering, and deregistering workers @@ -1567,12 +1768,16 @@ private int getParallelismOpaque() { */ private boolean createWorker() { ForkJoinWorkerThreadFactory fac = factory; + SharedThreadContainer ctr = container; Throwable ex = null; ForkJoinWorkerThread wt = null; try { - if (runState >= 0 && // avoid construction if terminating + if ((runState & STOP) == 0 && // avoid construction if terminating fac != null && (wt = fac.newThread(this)) != null) { - container.start(wt); + if (ctr != null) + ctr.start(wt); + else + wt.start(); return true; } } catch (Throwable rex) { @@ -1594,49 +1799,49 @@ final String nextWorkerThreadName() { } /** - * Finishes initializing and records owned queue. + * Finishes initializing and records internal queue. * * @param w caller's WorkQueue */ final void registerWorker(WorkQueue w) { - ThreadLocalRandom.localInit(); - int seed = ThreadLocalRandom.getProbe(); - ReentrantLock lock = registrationLock; - int cfg = config & FIFO; - if (w != null && lock != null) { + if (w != null) { w.array = new ForkJoinTask[INITIAL_QUEUE_CAPACITY]; - cfg |= w.config | SRC; - w.stackPred = seed; - int id = (seed << 1) | 1; // initial index guess - lock.lock(); + ThreadLocalRandom.localInit(); + int seed = w.stackPred = ThreadLocalRandom.getProbe(); + int phaseSeq = seed & ~((IDLE << 1) - 1); // initial phase tag + int id = ((seed << 1) | 1) & SMASK; // base of linear-probe-like scan + int stop = lockRunState() & STOP; try { - WorkQueue[] qs; int n; // find queue index - if ((qs = queues) != null && (n = qs.length) > 0) { - int k = n, m = n - 1; - for (; qs[id &= m] != null && k > 0; id -= 2, k -= 2); - if (k == 0) - id = n | 1; // resize below - w.phase = w.config = id | cfg; // now publishable - + WorkQueue[] qs; int n; + if (stop == 0 && (qs = queues) != null && (n = qs.length) > 0) { + for (int k = n, m = n - 1; ; id += 2) { + if (qs[id &= m] == null) + break; + if ((k -= 2) <= 0) { + id |= n; + break; + } + } + w.phase = id | phaseSeq; // now publishable if (id < n) qs[id] = w; - else { // expand array + else { // expand int an = n << 1, am = an - 1; WorkQueue[] as = new WorkQueue[an]; as[id & am] = w; for (int j = 1; j < n; j += 2) as[j] = qs[j]; for (int j = 0; j < n; j += 2) { - WorkQueue q; - if ((q = qs[j]) != null) // shared queues may move - as[q.config & am] = q; + WorkQueue q; // shared queues may move + if ((q = qs[j]) != null) + as[q.phase & EXTERNAL_ID_MASK & am] = q; } - U.storeFence(); // fill before publish + U.storeFence(); // fill before publish queues = as; } } } finally { - lock.unlock(); + unlockRunState(); } } } @@ -1651,146 +1856,159 @@ final void registerWorker(WorkQueue w) { * @param ex the exception causing failure, or null if none */ final void deregisterWorker(ForkJoinWorkerThread wt, Throwable ex) { - WorkQueue w = (wt == null) ? null : wt.workQueue; - int cfg = (w == null) ? 0 : w.config; + WorkQueue w = null; + int src = 0, phase = 0; + boolean replaceable = false; + if (wt != null && (w = wt.workQueue) != null) { + phase = w.phase; + if ((src = w.source) != DEREGISTERED) { // else trimmed on timeout + w.source = DEREGISTERED; + if (phase != 0) { // else failed to start + replaceable = true; + if ((phase & IDLE) != 0) + reactivate(w); // pool stopped before released + } + } + } long c = ctl; - if ((cfg & TRIMMED) == 0) // decrement counts + if (src != DEREGISTERED) // decrement counts do {} while (c != (c = compareAndExchangeCtl( c, ((RC_MASK & (c - RC_UNIT)) | (TC_MASK & (c - TC_UNIT)) | - (SP_MASK & c))))); - else if ((int)c == 0) // was dropped on timeout - cfg &= ~SRC; // suppress signal if last - if (!tryTerminate(false, false) && w != null) { - ReentrantLock lock; WorkQueue[] qs; int n, i; - long ns = w.nsteals & 0xffffffffL; - if ((lock = registrationLock) != null) { - lock.lock(); // remove index unless terminating - if ((qs = queues) != null && (n = qs.length) > 0 && - qs[i = cfg & (n - 1)] == w) - qs[i] = null; - stealCount += ns; // accumulate steals - lock.unlock(); + (LMASK & c))))); + else if ((int)c == 0) // was dropped on timeout + replaceable = false; + if (w != null) { // cancel remaining tasks + for (ForkJoinTask t; (t = w.nextLocalTask()) != null; ) { + try { + t.cancel(false); + } catch (Throwable ignore) { + } } - if ((cfg & SRC) != 0) - signalWork(); // possibly replace worker - } - if (ex != null) { - if (w != null) { - w.access = STOP; // cancel tasks - for (ForkJoinTask t; (t = w.nextLocalTask(0)) != null; ) - ForkJoinTask.cancelIgnoringExceptions(t); + } + if ((tryTerminate(false, false) & STOP) == 0 && w != null) { + WorkQueue[] qs; int n, i; // remove index unless terminating + long ns = w.nsteals & 0xffffffffL; + int stop = lockRunState() & STOP; + if (stop == 0 && (qs = queues) != null && (n = qs.length) > 0 && + qs[i = phase & SMASK & (n - 1)] == w) { + qs[i] = null; + stealCount += ns; // accumulate steals } - ForkJoinTask.rethrow(ex); + unlockRunState(); } + if ((runState & STOP) == 0 && replaceable) + signalWork(); // may replace unless trimmed or uninitialized + if (ex != null) + ForkJoinTask.rethrow(ex); } - /* + /** * Releases an idle worker, or creates one if not enough exist. */ final void signalWork() { - int pc = parallelism, n; - long c = ctl; - WorkQueue[] qs = queues; - if ((short)(c >>> RC_SHIFT) < pc && qs != null && (n = qs.length) > 0) { - for (;;) { - boolean create = false; - int sp = (int)c & ~INACTIVE; - WorkQueue v = qs[sp & (n - 1)]; - int deficit = pc - (short)(c >>> TC_SHIFT); - long ac = (c + RC_UNIT) & RC_MASK, nc; - if (sp != 0 && v != null) - nc = (v.stackPred & SP_MASK) | (c & TC_MASK); - else if (deficit <= 0) - break; - else { - create = true; - nc = ((c + TC_UNIT) & TC_MASK); - } - if (c == (c = compareAndExchangeCtl(c, nc | ac))) { - if (create) - createWorker(); - else { - Thread owner = v.owner; - v.phase = sp; - if (v.access == PARKED) - LockSupport.unpark(owner); - } + int pc = parallelism; + for (long c = ctl;;) { + WorkQueue[] qs = queues; + long ac = (c + RC_UNIT) & RC_MASK, nc; + int sp = (int)c, i = sp & SMASK; + if (qs == null || qs.length <= i) + break; + WorkQueue w = qs[i], v = null; + if (sp == 0) { + if ((short)(c >>> TC_SHIFT) >= pc) break; - } + nc = ((c + TC_UNIT) & TC_MASK); } - } - } - - /** - * Reactivates any idle worker, if one exists. - * - * @return the signalled worker, or null if none - */ - private WorkQueue reactivate() { - WorkQueue[] qs; int n; - long c = ctl; - if ((qs = queues) != null && (n = qs.length) > 0) { - for (;;) { - int sp = (int)c & ~INACTIVE; - WorkQueue v = qs[sp & (n - 1)]; - long ac = UC_MASK & (c + RC_UNIT); - if (sp == 0 || v == null) - break; - if (c == (c = compareAndExchangeCtl( - c, (v.stackPred & SP_MASK) | ac))) { - Thread owner = v.owner; + else if ((short)(c >>> RC_SHIFT) >= pc || (v = w) == null) + break; + else + nc = (v.stackPred & LMASK) | (c & TC_MASK); + if (c == (c = compareAndExchangeCtl(c, nc | ac))) { + if (v == null) + createWorker(); + else { + Thread t; v.phase = sp; - if (v.access == PARKED) - LockSupport.unpark(owner); - return v; + if ((t = v.parker) != null) + U.unpark(t); } + break; } } - return null; } /** - * Tries to deactivate worker w; called only on idle timeout. + * Reactivates the given worker, and possibly interrupts others if + * not top of ctl stack. Called only during shutdown to ensure release + * on termination. */ - private boolean tryTrim(WorkQueue w) { - if (w != null) { - int pred = w.stackPred, cfg = w.config | TRIMMED; - long c = ctl; - int sp = (int)c & ~INACTIVE; - if ((sp & SMASK) == (cfg & SMASK) && - compareAndSetCtl(c, ((pred & SP_MASK) | - (UC_MASK & (c - TC_UNIT))))) { - w.config = cfg; // add sentinel for deregisterWorker - w.phase = sp; - return true; + private void reactivate(WorkQueue w) { + for (long c = ctl;;) { + WorkQueue[] qs; WorkQueue v; int sp, i; + if ((qs = queues) == null || (sp = (int)c) == 0 || + qs.length <= (i = sp & SMASK) || (v = qs[i]) == null || + (v != w && w != null && (w.phase & IDLE) == 0)) + break; + if (c == (c = compareAndExchangeCtl( + c, ((UMASK & (c + RC_UNIT)) | (c & TC_MASK) | + (v.stackPred & LMASK))))) { + Thread t; + v.phase = sp; + if ((t = v.parker) != null) { + try { + t.interrupt(); + } catch (Throwable ignore) { + } + } + if (v == w) + break; } } - return false; } /** - * Returns true if any queue is detectably nonempty. Accurate - * only when workers are quiescent; else conservatively - * approximate. - * @param submissionsOnly if true, only check submission queues - */ - private boolean hasTasks(boolean submissionsOnly) { - int step = submissionsOnly ? 2 : 1; - for (int checkSum = 0;;) { // repeat until stable (normally twice) - U.loadFence(); - WorkQueue[] qs = queues; - int n = (qs == null) ? 0 : qs.length, sum = 0; - for (int i = 0; i < n; i += step) { - WorkQueue q; int s; - if ((q = qs[i]) != null) { - if (q.access > 0 || (s = q.top) != q.base) - return true; - sum += (s << 16) + i + 1; + * Internal version of isQuiescent and related functionality. + * @return true if terminating or all workers are inactive and + * submission queues are empty and unlocked; if so, setting STOP + * if shutdown is enabled + */ + private boolean quiescent() { + outer: for (;;) { + long phaseSum = 0L; + boolean swept = false; + for (int e, prevRunState = 0; ; prevRunState = e) { + long c = ctl; + if (((e = runState) & STOP) != 0) + return true; // terminating + else if ((c & RC_MASK) > 0L) + return false; // at least one active + else if (!swept || e != prevRunState || (e & RS_LOCK) != 0) { + long sum = c; + WorkQueue[] qs = queues; WorkQueue q; + int n = (qs == null) ? 0 : qs.length; + for (int i = 0; i < n; ++i) { // scan queues + if ((q = qs[i]) != null) { + int p = q.phase, s = q.top, b = q.base; + sum += (p & 0xffffffffL) | ((long)b << 32); + if ((p & IDLE) == 0 || s - b > 0) { + if ((i & 1) == 0 && compareAndSetCtl(c, c)) + signalWork(); // ensure live + return false; + } + } + } + swept = (phaseSum == (phaseSum = sum)); } + else if (compareAndSetCtl(c, c) && // confirm + casRunState(e, (e & SHUTDOWN) != 0 ? e | STOP : e)) { + if ((e & SHUTDOWN) != 0) // enable termination + interruptAll(); + return true; + } + else + break; // restart } - if (checkSum == (checkSum = sum)) - return false; } } @@ -1801,129 +2019,139 @@ private boolean hasTasks(boolean submissionsOnly) { * @param w caller's WorkQueue (may be null on failed initialization) */ final void runWorker(WorkQueue w) { - if (w != null) { // skip on failed init - int r = w.stackPred, src = 0; // use seed from registerWorker - do { - r ^= r << 13; r ^= r >>> 17; r ^= r << 5; // xorshift - } while ((src = scan(w, src, r)) >= 0 || - (src = awaitWork(w)) == 0); - w.access = STOP; // record normal termination + if (w != null) { + int phase = w.phase, r = w.stackPred; // seed from registerWorker + for (long window = NO_HISTORY | (r >>> 16);;) { + r ^= r << 13; r ^= r >>> 17; r ^= r << 5; // xorshift + if ((runState & STOP) != 0) // terminating + break; + if (window == (window = scan(w, window & WMASK, r)) && + window >= 0L && phase != (phase = awaitWork(w, phase))) { + if ((phase & IDLE) != 0) + break; // worker exit + window = NO_HISTORY | (window & SMASK); // clear history + } + } } } /** * Scans for and if found executes top-level tasks: Tries to poll - * each queue starting at a random index with random stride, - * returning source id or retry indicator. + * each queue starting at initial index with random stride, + * returning next scan window and retry indicator. * * @param w caller's WorkQueue - * @param prevSrc the two previous queues (if nonzero) stolen from in current phase, packed as int + * @param window up to three queue indices * @param r random seed - * @return the next prevSrc value to use, or negative if none found + * @return the next window to use, with RESCAN set for rescan */ - private int scan(WorkQueue w, int prevSrc, int r) { + private long scan(WorkQueue w, long window, int r) { WorkQueue[] qs = queues; - int n = (w == null || qs == null) ? 0 : qs.length; - for (int step = (r >>> 16) | 1, i = n; i > 0; --i, r += step) { + int n = (qs == null) ? 0 : qs.length, step = (r << 1) | 1; + outer: for (int i = (short)window, l = n; l > 0; --l, i += step) { int j, cap; WorkQueue q; ForkJoinTask[] a; - if ((q = qs[j = r & (n - 1)]) != null && + if ((q = qs[j = i & SMASK & (n - 1)]) != null && (a = q.array) != null && (cap = a.length) > 0) { - int src = j | SRC, b = q.base; - int k = (cap - 1) & b, nb = b + 1, nk = (cap - 1) & nb; - ForkJoinTask t = a[k]; - U.loadFence(); // for re-reads - if (q.base != b) // inconsistent - return prevSrc; - else if (t != null && WorkQueue.casSlotToNull(a, k, t)) { - q.base = nb; - w.source = src; - if (src + (src << SWIDTH) != prevSrc && - q.base == nb && a[nk] != null) - signalWork(); // propagate at most twice/run - w.topLevelExec(t, q); - return src + (prevSrc << SWIDTH); - } - else if (q.array != a || a[k] != null || a[nk] != null) - return prevSrc; // revisit - } - } - return -1; - } - - /** - * Advances phase, enqueues, and awaits signal or termination. - * - * @return negative if terminated, else 0 - */ - private int awaitWork(WorkQueue w) { - if (w == null) - return -1; // currently impossible - int p = (w.phase + SS_SEQ) & ~INACTIVE; // advance phase - boolean idle = false; // true if possibly quiescent - if (runState < 0) - return -1; // terminating - long sp = p & SP_MASK, pc = ctl, qc; - w.phase = p | INACTIVE; - do { // enqueue - w.stackPred = (int)pc; // set ctl stack link - } while (pc != (pc = compareAndExchangeCtl( - pc, qc = ((pc - RC_UNIT) & UC_MASK) | sp))); - if ((qc & RC_MASK) <= 0L) { - if (hasTasks(true) && (w.phase >= 0 || reactivate() == w)) - return 0; // check for stragglers - if (runState != 0 && tryTerminate(false, false)) - return -1; // quiescent termination - idle = true; - } - WorkQueue[] qs = queues; // spin for expected #accesses in scan+signal - int spins = ((qs == null) ? 0 : ((qs.length & SMASK) << 1)) | 0xf; - while ((p = w.phase) < 0 && --spins > 0) - Thread.onSpinWait(); - if (p < 0) { - long deadline = idle ? keepAlive + System.currentTimeMillis() : 0L; - LockSupport.setCurrentBlocker(this); - for (;;) { // await signal or termination - if (runState < 0) - return -1; - w.access = PARKED; // enable unpark - if (w.phase < 0) { - if (idle) - LockSupport.parkUntil(deadline); - else - LockSupport.park(); - } - w.access = 0; // disable unpark - if (w.phase >= 0) { - LockSupport.setCurrentBlocker(null); - break; - } - Thread.interrupted(); // clear status for next park - if (idle) { // check for idle timeout - if (deadline - System.currentTimeMillis() < TIMEOUT_SLOP) { - if (tryTrim(w)) - return -1; - else // not at head; restart timer - deadline += keepAlive; + for (;;) { + int b, k; Object o; + ForkJoinTask t = a[k = (b = q.base) & (cap - 1)]; + U.loadFence(); // re-read b and t + if (q.base == b) { // else inconsistent; retry + int nb = b + 1, nk = nb & (cap - 1); + if (t == null) { + if (a[k] == null) { // revisit if another task + if (window >= 0L && a[nk] != null) + window |= RESCAN; + break; + } + } + else if (t == (o = U.compareAndExchangeReference( + a, slotOffset(k), t, null))) { + q.updateBase(nb); + long pw = window, nw = ((pw << 16) | j) & WMASK; + window = nw | RESCAN; + if ((nw != pw || (short)(nw >>> 32) != j) && + a[nk] != null) + signalWork(); // limit propagation + if (w != null) // always true + w.topLevelExec(t, q, j); + break outer; + } + else if (o == null) // contended + break; // retried unless newly active } } } } - return 0; + return window; } /** - * Non-overridable version of isQuiescent. Returns true if - * quiescent or already terminating. + * Tries to inactivate, and if successful, awaits signal or termination. + * + * @param w the worker (may be null if already terminated) + * @param p current phase + * @return current phase, with IDLE set if worker should exit */ - private boolean canStop() { - long c = ctl; - do { - if (runState < 0) - break; - if ((c & RC_MASK) > 0L || hasTasks(false)) - return false; - } while (c != (c = ctl)); // validate - return true; + private int awaitWork(WorkQueue w, int p) { + if (w != null) { + int idlePhase = p + IDLE, nextPhase = p + (IDLE << 1); + long pc = ctl, qc = (nextPhase & LMASK) | ((pc - RC_UNIT) & UMASK); + w.stackPred = (int)pc; // set ctl stack link + w.phase = idlePhase; // try to inactivate + if (!compareAndSetCtl(pc, qc)) // contended enque + return w.phase = p; // back out + int ac = (short)(qc >>> RC_SHIFT); + boolean quiescent = (ac <= 0 && quiescent()); + if ((runState & STOP) != 0) + return idlePhase; + int spins = ac + ((((int)(qc >>> TC_SHIFT)) & SMASK) << 1); + while ((p = w.phase) == idlePhase && --spins > 0) + Thread.onSpinWait(); // spin for approx #accesses to signal + if (p == idlePhase) { + long deadline = (!quiescent ? 0L : // timeout for trim + System.currentTimeMillis() + keepAlive); + WorkQueue[] qs = queues; + int n = (qs == null) ? 0 : qs.length; + for (int i = 0; i < n; ++i) { // recheck queues + WorkQueue q; ForkJoinTask[] a; int cap; + if ((q = qs[i]) != null && + (a = q.array) != null && (cap = a.length) > 0 && + a[q.base & (cap - 1)] != null && + ctl == qc && compareAndSetCtl(qc, pc)) { + w.phase = (int)qc; // release + break; + } + } + if ((p = w.phase) == idlePhase) { // emulate LockSupport.park + LockSupport.setCurrentBlocker(this); + w.parker = Thread.currentThread(); + for (;;) { + if ((runState & STOP) != 0 || (p = w.phase) != idlePhase) + break; + U.park(quiescent, deadline); + if ((p = w.phase) != idlePhase || (runState & STOP) != 0) + break; + Thread.interrupted(); // clear for next park + if (quiescent && TIMEOUT_SLOP > + deadline - System.currentTimeMillis()) { + long sp = w.stackPred & LMASK; + long c = ctl, nc = sp | (UMASK & (c - TC_UNIT)); + if (((int)c & SMASK) == (idlePhase & SMASK) && + compareAndSetCtl(c, nc)) { + w.source = DEREGISTERED; + w.phase = (int)c; + break; + } + deadline += keepAlive; // not head; reset timer + } + } + w.parker = null; + LockSupport.setCurrentBlocker(null); + } + } + } + return p; } /** @@ -1934,16 +2162,18 @@ private boolean canStop() { * @param submissionsOnly if true, only scan submission queues */ private ForkJoinTask pollScan(boolean submissionsOnly) { - int r = ThreadLocalRandom.nextSecondarySeed(); - if (submissionsOnly) // even indices only - r &= ~1; - int step = (submissionsOnly) ? 2 : 1; - WorkQueue[] qs; int n; WorkQueue q; ForkJoinTask t; - if (runState >= 0 && (qs = queues) != null && (n = qs.length) > 0) { - for (int i = n; i > 0; i -= step, r += step) { - if ((q = qs[r & (n - 1)]) != null && - (t = q.poll(this)) != null) - return t; + if ((runState & STOP) == 0) { + WorkQueue[] qs; int n; WorkQueue q; ForkJoinTask t; + int r = ThreadLocalRandom.nextSecondarySeed(); + if (submissionsOnly) // even indices only + r &= ~1; + int step = (submissionsOnly) ? 2 : 1; + if ((qs = queues) != null && (n = qs.length) > 0) { + for (int i = n; i > 0; i -= step, r += step) { + if ((q = qs[r & (n - 1)]) != null && + (t = q.poll(this)) != null) + return t; + } } } return null; @@ -1958,47 +2188,48 @@ private ForkJoinTask pollScan(boolean submissionsOnly) { * unblocked. * * @param c incoming ctl value - * @param canSaturate to override saturate predicate * @return UNCOMPENSATE: block then adjust, 0: block, -1 : retry */ - private int tryCompensate(long c, boolean canSaturate) { + private int tryCompensate(long c) { Predicate sat; - long b = bounds; // unpack fields - int pc = parallelism; - int minActive = (short)(b & SMASK), - maxTotal = (short)(b >>> SWIDTH) + pc, + long b = config; + int pc = parallelism, // unpack fields + minActive = (short)(b >>> RC_SHIFT), + maxTotal = (short)(b >>> TC_SHIFT) + pc, active = (short)(c >>> RC_SHIFT), total = (short)(c >>> TC_SHIFT), - sp = (int)c & ~INACTIVE; - if (sp != 0 && active <= pc) { // activate idle worker - WorkQueue[] qs; WorkQueue v; int i; - if (ctl == c && (qs = queues) != null && - qs.length > (i = sp & SMASK) && (v = qs[i]) != null) { - long nc = (v.stackPred & SP_MASK) | (UC_MASK & c); - if (compareAndSetCtl(c, nc)) { - v.phase = sp; - LockSupport.unpark(v.owner); - return UNCOMPENSATE; - } + sp = (int)c, + stat = -1; // default retry return + if (sp != 0 && active <= pc) { // activate idle worker + WorkQueue[] qs; WorkQueue v; int i; Thread t; + if ((qs = queues) != null && qs.length > (i = sp & SMASK) && + (v = qs[i]) != null && + compareAndSetCtl(c, (c & UMASK) | (v.stackPred & LMASK))) { + v.phase = sp; + if ((t = v.parker) != null) + U.unpark(t); + stat = UNCOMPENSATE; } - return -1; // retry } else if (active > minActive && total >= pc) { // reduce active workers - long nc = ((RC_MASK & (c - RC_UNIT)) | (~RC_MASK & c)); - return compareAndSetCtl(c, nc) ? UNCOMPENSATE : -1; + if (compareAndSetCtl(c, ((c - RC_UNIT) & RC_MASK) | (c & ~RC_MASK))) + stat = UNCOMPENSATE; } - else if (total < maxTotal && total < MAX_CAP) { // expand pool + else if (total < maxTotal && total < MAX_CAP) { // try to expand pool long nc = ((c + TC_UNIT) & TC_MASK) | (c & ~TC_MASK); - return (!compareAndSetCtl(c, nc) ? -1 : - !createWorker() ? 0 : UNCOMPENSATE); + if ((runState & STOP) != 0) // terminating + stat = 0; + else if (compareAndSetCtl(c, nc)) + stat = createWorker() ? UNCOMPENSATE : 0; } else if (!compareAndSetCtl(c, c)) // validate - return -1; - else if (canSaturate || ((sat = saturate) != null && sat.test(this))) - return 0; + ; + else if ((sat = saturate) != null && sat.test(this)) + stat = 0; else throw new RejectedExecutionException( "Thread limit exceeded replacing blocked worker"); + return stat; } /** @@ -2016,234 +2247,256 @@ final void uncompensate() { * * @param task the task * @param w caller's WorkQueue - * @param timed true if this is a timed join + * @param internal true if w is owned by a ForkJoinWorkerThread * @return task status on exit, or UNCOMPENSATE for compensated blocking */ - final int helpJoin(ForkJoinTask task, WorkQueue w, boolean timed) { - if (w == null || task == null) - return 0; - int wsrc = w.source, wid = (w.config & SMASK) | SRC, r = wid + 2; - long sctl = 0L; // track stability - for (boolean rescan = true;;) { - int s; WorkQueue[] qs; - if ((s = task.status) < 0) - return s; - if (!rescan && sctl == (sctl = ctl)) { - if (runState < 0) - return 0; - if ((s = tryCompensate(sctl, timed)) >= 0) - return s; // block - } - rescan = false; - int n = ((qs = queues) == null) ? 0 : qs.length, m = n - 1; - scan: for (int i = n >>> 1; i > 0; --i, r += 2) { - int j, cap; WorkQueue q; ForkJoinTask[] a; - if ((q = qs[j = r & m]) != null && (a = q.array) != null && - (cap = a.length) > 0) { - for (int src = j | SRC;;) { - int sq = q.source, b = q.base; - int k = (cap - 1) & b, nb = b + 1; - ForkJoinTask t = a[k]; - U.loadFence(); // for re-reads - boolean eligible = true; // check steal chain - for (int d = n, v = sq;;) { // may be cyclic; bound - WorkQueue p; - if (v == wid) - break; - if (v == 0 || --d == 0 || (p = qs[v & m]) == null) { - eligible = false; + + final int helpJoin(ForkJoinTask task, WorkQueue w, boolean internal) { + if (w != null) + w.tryRemoveAndExec(task, internal); + int s = 0; + if (task != null && (s = task.status) >= 0 && internal && w != null) { + int wid = w.phase & SMASK, r = wid + 2, wsrc = w.source; + long sctl = 0L; // track stability + outer: for (boolean rescan = true;;) { + if ((s = task.status) < 0) + break; + if (!rescan) { + if ((runState & STOP) != 0) + break; + if (sctl == (sctl = ctl) && (s = tryCompensate(sctl)) >= 0) + break; + } + rescan = false; + WorkQueue[] qs = queues; + int n = (qs == null) ? 0 : qs.length; + scan: for (int l = n >>> 1; l > 0; --l, r += 2) { + int j; WorkQueue q; + if ((q = qs[j = r & SMASK & (n - 1)]) != null) { + for (;;) { + int sq = q.source, b, cap, k; ForkJoinTask[] a; + if ((a = q.array) == null || (cap = a.length) <= 0) break; + ForkJoinTask t = a[k = (b = q.base) & (cap - 1)]; + U.loadFence(); + boolean eligible = false; + if (t == task) + eligible = true; + else if (t != null) { // check steal chain + for (int v = sq, d = cap;;) { + WorkQueue p; + if (v == wid) { + eligible = true; + break; + } + if ((v & 1) == 0 || // external or none + --d < 0 || // bound depth + (p = qs[v & (n - 1)]) == null) + break; + v = p.source; + } } - v = p.source; - } - if (q.source != sq || q.base != b) - ; // stale - else if ((s = task.status) < 0) - return s; // recheck before taking - else if (t == null) { - if (a[k] == null) { - if (!rescan && eligible && - (q.array != a || q.top != b)) - rescan = true; // resized or stalled - break; + if ((s = task.status) < 0) + break outer; // validate + if (q.source == sq && q.base == b && a[k] == t) { + int nb = b + 1, nk = nb & (cap - 1); + if (!eligible) { // revisit if nonempty + if (!rescan && t == null && + (a[nk] != null || q.top - b > 0)) + rescan = true; + break; + } + if (U.compareAndSetReference( + a, slotOffset(k), t, null)) { + q.updateBase(nb); + w.source = j; + t.doExec(); + w.source = wsrc; + rescan = true; // restart at index r + break scan; + } } } - else if (t != task && !eligible) - break; - else if (WorkQueue.casSlotToNull(a, k, t)) { - q.base = nb; - w.source = src; - t.doExec(); - w.source = wsrc; - rescan = true; - break scan; - } } } } } + return s; } /** * Version of helpJoin for CountedCompleters. * - * @param task the task + * @param task root of computation (only called when a CountedCompleter) * @param w caller's WorkQueue - * @param owned true if w is owned by a ForkJoinWorkerThread - * @param timed true if this is a timed join + * @param internal true if w is owned by a ForkJoinWorkerThread * @return task status on exit, or UNCOMPENSATE for compensated blocking */ - final int helpComplete(ForkJoinTask task, WorkQueue w, boolean owned, - boolean timed) { - if (w == null || task == null) - return 0; - int wsrc = w.source, r = w.config; - long sctl = 0L; // track stability - for (boolean rescan = true;;) { - int s; WorkQueue[] qs; - if ((s = w.helpComplete(task, owned, 0)) < 0) - return s; - if (!rescan && sctl == (sctl = ctl)) { - if (!owned || runState < 0) - return 0; - if ((s = tryCompensate(sctl, timed)) >= 0) - return s; - } - rescan = false; - int n = ((qs = queues) == null) ? 0 : qs.length, m = n - 1; - scan: for (int i = n; i > 0; --i, ++r) { - int j, cap; WorkQueue q; ForkJoinTask[] a; - if ((q = qs[j = r & m]) != null && (a = q.array) != null && - (cap = a.length) > 0) { - poll: for (int src = j | SRC, b = q.base;;) { - int k = (cap - 1) & b, nb = b + 1; - ForkJoinTask t = a[k]; - U.loadFence(); // for re-reads - if (b != (b = q.base)) - ; // stale - else if ((s = task.status) < 0) - return s; // recheck before taking - else if (t == null) { - if (a[k] == null) { - if (!rescan && // resized or stalled - (q.array != a || q.top != b)) - rescan = true; + final int helpComplete(ForkJoinTask task, WorkQueue w, boolean internal) { + int s = 0; + if (task != null && (s = task.status) >= 0 && w != null) { + int r = w.phase + 1; // for indexing + long sctl = 0L; // track stability + outer: for (boolean rescan = true, locals = true;;) { + if (locals && (s = w.helpComplete(task, internal, 0)) < 0) + break; + if ((s = task.status) < 0) + break; + if (!rescan) { + if ((runState & STOP) != 0) + break; + if (sctl == (sctl = ctl) && + (!internal || (s = tryCompensate(sctl)) >= 0)) + break; + } + rescan = locals = false; + WorkQueue[] qs = queues; + int n = (qs == null) ? 0 : qs.length; + scan: for (int l = n; l > 0; --l, ++r) { + int j; WorkQueue q; + if ((q = qs[j = r & SMASK & (n - 1)]) != null) { + for (;;) { + ForkJoinTask[] a; int b, cap, k; + if ((a = q.array) == null || (cap = a.length) <= 0) break; + ForkJoinTask t = a[k = (b = q.base) & (cap - 1)]; + U.loadFence(); + boolean eligible = false; + if (t instanceof CountedCompleter) { + CountedCompleter f = (CountedCompleter)t; + for (int steps = cap; steps > 0; --steps) { + if (f == task) { + eligible = true; + break; + } + if ((f = f.completer) == null) + break; + } } - } - else if (t instanceof CountedCompleter) { - CountedCompleter f; - for (f = (CountedCompleter)t;;) { - if (f == task) + if ((s = task.status) < 0) // validate + break outer; + if (q.base == b) { + int nb = b + 1, nk = nb & (cap - 1); + if (eligible) { + if (U.compareAndSetReference( + a, slotOffset(k), t, null)) { + q.updateBase(nb); + t.doExec(); + locals = rescan = true; + break scan; + } + } + else if (a[k] == t) { + if (!rescan && t == null && + (a[nk] != null || q.top - b > 0)) + rescan = true; // revisit break; - else if ((f = f.completer) == null) - break poll; // ineligible - } - if (WorkQueue.casSlotToNull(a, k, t)) { - q.base = nb; - w.source = src; - t.doExec(); - w.source = wsrc; - rescan = true; - break scan; + } } } - else - break; } } } } + return s; } /** - * Runs tasks until {@code isQuiescent()}. Rather than blocking - * when tasks cannot be found, rescans until all others cannot - * find tasks either. + * Runs tasks until all workers are inactive and no tasks are + * found. Rather than blocking when tasks cannot be found, rescans + * until all others cannot find tasks either. * * @param nanos max wait time (Long.MAX_VALUE if effectively untimed) * @param interruptible true if return on interrupt * @return positive if quiescent, negative if interrupted, else 0 */ private int helpQuiesce(WorkQueue w, long nanos, boolean interruptible) { - long startTime = System.nanoTime(), parkTime = 0L; - int phase; // w.phase set negative when temporarily quiescent - if (w == null || (phase = w.phase) < 0) + int phase; // w.phase inactive bit set when temporarily quiescent + if (w == null || ((phase = w.phase) & IDLE) != 0) return 0; - int activePhase = phase, inactivePhase = phase | INACTIVE; - int wsrc = w.source, r = 0; - for (boolean locals = true;;) { - WorkQueue[] qs; WorkQueue q; - if (runState < 0) { // terminating - w.phase = activePhase; - return 1; + int wsrc = w.source; + long startTime = System.nanoTime(); + long maxSleep = Math.min(nanos >>> 8, MAX_SLEEP); // approx 1% nanos + long prevSum = 0L; + int activePhase = phase, inactivePhase = phase + IDLE; + int r = phase + 1, waits = 0, returnStatus = 1; + boolean locals = true; + for (int e = runState;;) { + if ((e & STOP) != 0) + break; // terminating + if (interruptible && Thread.interrupted()) { + returnStatus = -1; + break; } if (locals) { // run local tasks before (re)polling + locals = false; for (ForkJoinTask u; (u = w.nextLocalTask()) != null;) u.doExec(); } - boolean rescan = false, busy = locals = false, interrupted; - int n = ((qs = queues) == null) ? 0 : qs.length, m = n - 1; - scan: for (int i = n, j; i > 0; --i, ++r) { - if ((q = qs[j = m & r]) != null && q != w) { - for (int src = j | SRC;;) { - ForkJoinTask[] a = q.array; - int b = q.base, cap; - if (a == null || (cap = a.length) <= 0) - break; - int k = (cap - 1) & b, nb = b + 1, nk = (cap - 1) & nb; - ForkJoinTask t = a[k]; - U.loadFence(); // for re-reads - if (q.base != b || q.array != a || a[k] != t) - ; - else if (t == null) { - if (!rescan) { - if (a[nk] != null || q.top - b > 0) - rescan = true; - else if (!busy && - q.owner != null && q.phase >= 0) - busy = true; - } + WorkQueue[] qs = queues; + int n = (qs == null) ? 0 : qs.length; + long phaseSum = 0L; + boolean rescan = false, busy = false; + scan: for (int l = n; l > 0; --l, ++r) { + int j; WorkQueue q; + if ((q = qs[j = r & SMASK & (n - 1)]) != null && q != w) { + for (;;) { + ForkJoinTask[] a; int b, cap, k; + if ((a = q.array) == null || (cap = a.length) <= 0) break; - } - else if (phase < 0) // reactivate before taking + ForkJoinTask t = a[k = (b = q.base) & (cap - 1)]; + if (t != null && phase == inactivePhase) // reactivate w.phase = phase = activePhase; - else if (WorkQueue.casSlotToNull(a, k, t)) { - q.base = nb; - w.source = src; - t.doExec(); - w.source = wsrc; - rescan = locals = true; - break scan; + U.loadFence(); + if (q.base == b && a[k] == t) { + int nb = b + 1; + if (t == null) { + if (!rescan) { + int qp = q.phase, mq = qp & (IDLE | 1); + phaseSum += qp; + if (mq == 0 || q.top - b > 0) + rescan = true; + else if (mq == 1) + busy = true; + } + break; + } + if (U.compareAndSetReference( + a, slotOffset(k), t, null)) { + q.updateBase(nb); + w.source = j; + t.doExec(); + w.source = wsrc; + rescan = locals = true; + break scan; + } } } } } - if (rescan) - ; // retry - else if (phase >= 0) { - parkTime = 0L; + if (e != (e = runState) || prevSum != (prevSum = phaseSum) || + rescan || (e & RS_LOCK) != 0) + ; // inconsistent + else if (!busy) + break; + else if (phase == activePhase) { + waits = 0; // recheck, then sleep w.phase = phase = inactivePhase; } - else if (!busy) { - w.phase = activePhase; - return 1; - } - else if (parkTime == 0L) { - parkTime = 1L << 10; // initially about 1 usec - Thread.yield(); - } - else if ((interrupted = interruptible && Thread.interrupted()) || - System.nanoTime() - startTime > nanos) { - w.phase = activePhase; - return interrupted ? -1 : 0; + else if (System.nanoTime() - startTime > nanos) { + returnStatus = 0; // timed out + break; } + else if (waits == 0) // same as spinLockRunState except + waits = MIN_SLEEP; // with rescan instead of onSpinWait else { - LockSupport.parkNanos(this, parkTime); - if (parkTime < nanos >>> 8 && parkTime < 1L << 20) - parkTime <<= 1; // max sleep approx 1 sec or 1% nanos + LockSupport.parkNanos(this, (long)waits); + if (waits < maxSleep) + waits <<= 1; } } + w.phase = activePhase; + return returnStatus; } /** @@ -2254,28 +2507,31 @@ else if ((interrupted = interruptible && Thread.interrupted()) || * @return positive if quiescent, negative if interrupted, else 0 */ private int externalHelpQuiesce(long nanos, boolean interruptible) { - for (long startTime = System.nanoTime(), parkTime = 0L;;) { - ForkJoinTask t; - if ((t = pollScan(false)) != null) { - t.doExec(); - parkTime = 0L; - } - else if (canStop()) - return 1; - else if (parkTime == 0L) { - parkTime = 1L << 10; - Thread.yield(); - } - else if ((System.nanoTime() - startTime) > nanos) - return 0; - else if (interruptible && Thread.interrupted()) - return -1; - else { - LockSupport.parkNanos(this, parkTime); - if (parkTime < nanos >>> 8 && parkTime < 1L << 20) - parkTime <<= 1; + if (!quiescent()) { + long startTime = System.nanoTime(); + long maxSleep = Math.min(nanos >>> 8, MAX_SLEEP); + for (int waits = 0;;) { + ForkJoinTask t; + if (interruptible && Thread.interrupted()) + return -1; + else if ((t = pollScan(false)) != null) { + waits = 0; + t.doExec(); + } + else if (quiescent()) + break; + else if (System.nanoTime() - startTime > nanos) + return 0; + else if (waits == 0) + waits = MIN_SLEEP; + else { + LockSupport.parkNanos(this, (long)waits); + if (waits < maxSleep) + waits <<= 1; + } } } + return 1; } /** @@ -2316,59 +2572,69 @@ final ForkJoinTask nextTaskFor(WorkQueue w) { /** * Finds and locks a WorkQueue for an external submitter, or * throws RejectedExecutionException if shutdown or terminating. + * @param r current ThreadLocalRandom.getProbe() value * @param isSubmit false if this is for a common pool fork */ - final WorkQueue submissionQueue(boolean isSubmit) { - int r; - ReentrantLock lock = registrationLock; - if ((r = ThreadLocalRandom.getProbe()) == 0) { + private WorkQueue submissionQueue(int r) { + if (r == 0) { ThreadLocalRandom.localInit(); // initialize caller's probe r = ThreadLocalRandom.getProbe(); } - if (lock != null) { // else init error - for (int id = r << 1;;) { // even indices only - int n, i; WorkQueue[] qs; WorkQueue q; - if ((qs = queues) == null || (n = qs.length) <= 0) - break; - else if ((q = qs[i = (n - 1) & id]) == null) { - WorkQueue w = new WorkQueue(null, id | SRC); - w.array = new ForkJoinTask[INITIAL_QUEUE_CAPACITY]; - lock.lock(); // install under lock - if (queues == qs && qs[i] == null) - qs[i] = w; // else lost race; discard - lock.unlock(); - } - else if (q.getAndSetAccess(1) != 0) // move and restart - id = (r = ThreadLocalRandom.advanceProbe(r)) << 1; - else if (isSubmit && runState != 0) { - q.access = 0; // check while lock held - break; - } - else + for (;;) { + int n, i, id; WorkQueue[] qs; WorkQueue q; + if ((qs = queues) == null) + break; + if ((n = qs.length) <= 0) + break; + if ((q = qs[i = (id = r & EXTERNAL_ID_MASK) & (n - 1)]) == null) { + WorkQueue w = new WorkQueue(null, id, 0, false); + w.array = new ForkJoinTask[INITIAL_QUEUE_CAPACITY]; + int stop = lockRunState() & STOP; + if (stop == 0 && queues == qs && qs[i] == null) + q = qs[i] = w; // else discard; retry + unlockRunState(); + if (q != null) return q; + if (stop != 0) + break; + } + else if (!q.tryLockPhase()) // move index + r = ThreadLocalRandom.advanceProbe(r); + else if ((runState & SHUTDOWN) != 0) { + q.unlockPhase(); // check while q lock held + break; } + else + return q; } + tryTerminate(false, false); throw new RejectedExecutionException(); } - /** - * Pushes a submission to the pool, using internal queue if called - * from ForkJoinWorkerThread, else external queue. - */ - private ForkJoinTask poolSubmit(boolean signalIfEmpty, - ForkJoinTask task) { - WorkQueue q; Thread t; ForkJoinWorkerThread wt; - U.storeStoreFence(); // ensure safely publishable - if (task == null) throw new NullPointerException(); + private void poolSubmit(boolean signalIfEmpty, ForkJoinTask task) { + Thread t; ForkJoinWorkerThread wt; WorkQueue q; boolean internal; if (((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) && - (wt = (ForkJoinWorkerThread)t).pool == this) + (wt = (ForkJoinWorkerThread)t).pool == this) { + internal = true; q = wt.workQueue; - else { - task.markPoolSubmission(); - q = submissionQueue(true); } - q.push(task, this, signalIfEmpty); - return task; + else { // find and lock queue + internal = false; + q = submissionQueue(ThreadLocalRandom.getProbe()); + } + q.push(task, signalIfEmpty ? this : null, internal); + } + + /** + * Returns queue for an external submission, bypassing call to + * submissionQueue if already established and unlocked. + */ + final WorkQueue externalSubmissionQueue() { + WorkQueue[] qs; WorkQueue q; int n; + int r = ThreadLocalRandom.getProbe(); + return (((qs = queues) != null && (n = qs.length) > 0 && + (q = qs[r & EXTERNAL_ID_MASK & (n - 1)]) != null && r != 0 && + q.tryLockPhase()) ? q : submissionQueue(r)); } /** @@ -2376,12 +2642,12 @@ private ForkJoinTask poolSubmit(boolean signalIfEmpty, * possibly ever submitted to the given pool (nonzero probe), or * null if none. */ - private static WorkQueue externalQueue(ForkJoinPool p) { - WorkQueue[] qs; - int r = ThreadLocalRandom.getProbe(), n; + static WorkQueue externalQueue(ForkJoinPool p) { + WorkQueue[] qs; int n; + int r = ThreadLocalRandom.getProbe(); return (p != null && (qs = p.queues) != null && (n = qs.length) > 0 && r != 0) ? - qs[(n - 1) & (r << 1)] : null; + qs[r & EXTERNAL_ID_MASK & (n - 1)] : null; } /** @@ -2391,13 +2657,6 @@ static WorkQueue commonQueue() { return externalQueue(common); } - /** - * Returns queue for an external thread, if one exists - */ - final WorkQueue externalQueue() { - return externalQueue(this); - } - /** * If the given executor is a ForkJoinPool, poll and execute * AsynchronousCompletionTasks from worker's queue until none are @@ -2405,12 +2664,11 @@ final WorkQueue externalQueue() { */ static void helpAsyncBlocker(Executor e, ManagedBlocker blocker) { WorkQueue w = null; Thread t; ForkJoinWorkerThread wt; - if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) { - if ((wt = (ForkJoinWorkerThread)t).pool == e) - w = wt.workQueue; - } + if (((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) && + (wt = (ForkJoinWorkerThread)t).pool == e) + w = wt.workQueue; else if (e instanceof ForkJoinPool) - w = ((ForkJoinPool)e).externalQueue(); + w = externalQueue((ForkJoinPool)e); if (w != null) w.helpAsyncBlocker(blocker); } @@ -2482,59 +2740,83 @@ static int getSurplusQueuedTaskCount() { * @param now if true, unconditionally terminate, else only * if no work and no active workers * @param enable if true, terminate when next possible - * @return true if terminating or terminated - */ - private boolean tryTerminate(boolean now, boolean enable) { - int rs; ReentrantLock lock; Condition cond; - if ((rs = runState) >= 0) { // set SHUTDOWN and/or STOP - if ((config & ISCOMMON) != 0) - return false; // cannot shutdown - if (!now) { - if ((rs & SHUTDOWN) == 0) { - if (!enable) - return false; - getAndBitwiseOrRunState(SHUTDOWN); - } - if (!canStop()) - return false; + * @return runState on exit + */ + private int tryTerminate(boolean now, boolean enable) { + int e = runState; + if ((e & STOP) == 0) { + if (now) { + int s = lockRunState(); + runState = e = (s + RS_LOCK) | STOP | SHUTDOWN; + if ((s & STOP) == 0) + interruptAll(); + } + else { + int isShutdown = (e & SHUTDOWN); + if (isShutdown == 0 && enable) + getAndBitwiseOrRunState(isShutdown = SHUTDOWN); + if (isShutdown != 0) + quiescent(); // may trigger STOP + e = runState; } - getAndBitwiseOrRunState(SHUTDOWN | STOP); - } - WorkQueue released = reactivate(); // try signalling waiter - int tc = (short)(ctl >>> TC_SHIFT); - if (released == null && tc > 0) { // help unblock and cancel - Thread current = Thread.currentThread(); - WorkQueue w = ((current instanceof ForkJoinWorkerThread) ? - ((ForkJoinWorkerThread)current).workQueue : null); - int r = (w == null) ? 0 : w.config + 1; // stagger traversals + } + if ((e & (STOP | TERMINATED)) == STOP) { // help cancel tasks + int r = (int)Thread.currentThread().threadId(); // stagger traversals WorkQueue[] qs = queues; int n = (qs == null) ? 0 : qs.length; - for (int i = 0; i < n; ++i) { - WorkQueue q; Thread thread; - if ((q = qs[(r + i) & (n - 1)]) != null && - (thread = q.owner) != current && q.access != STOP) { - for (ForkJoinTask t; (t = q.poll(null)) != null; ) - ForkJoinTask.cancelIgnoringExceptions(t); - if (thread != null && !thread.isInterrupted()) { - q.forcePhaseActive(); // for awaitWork - try { - thread.interrupt(); - } catch (Throwable ignore) { - } + for (int l = n; l > 0; --l, ++r) { + int j = r & SMASK & (n - 1); WorkQueue q; ForkJoinTask t; + while ((q = qs[j]) != null && q.source != DEREGISTERED && + (t = q.poll(null)) != null) { + try { + t.cancel(false); + } catch (Throwable ignore) { } } } + if (((e = runState) & TERMINATED) == 0 && ctl == 0L) { + if ((getAndBitwiseOrRunState(TERMINATED) & TERMINATED) == 0) { + CountDownLatch done; SharedThreadContainer ctr; + if ((done = termination) != null) + done.countDown(); + if ((ctr = container) != null) + ctr.close(); + } + e = runState; + } } - if ((tc <= 0 || (short)(ctl >>> TC_SHIFT) <= 0) && - (getAndBitwiseOrRunState(TERMINATED) & TERMINATED) == 0 && - (lock = registrationLock) != null) { - lock.lock(); // signal when no workers - if ((cond = termination) != null) - cond.signalAll(); - lock.unlock(); - container.close(); + return e; + } + + /** + * Interrupts all workers + */ + private void interruptAll() { + Thread current = Thread.currentThread(); + WorkQueue[] qs = queues; + int n = (qs == null) ? 0 : qs.length; + for (int i = 1; i < n; i += 2) { + WorkQueue q; Thread o; + if ((q = qs[i]) != null && (o = q.owner) != null && o != current && + q.source != DEREGISTERED) { + try { + o.interrupt(); + } catch (Throwable ignore) { + } + } } - return true; + } + + + /** + * Returns termination signal, constructing if necessary + */ + private CountDownLatch terminationSignal() { + CountDownLatch signal, s, u; + if ((signal = termination) == null) + signal = ((u = cmpExTerminationSignal( + s = new CountDownLatch(1))) == null) ? s : u; + return signal; } // Exported methods @@ -2708,19 +2990,17 @@ public ForkJoinPool(int parallelism, throw new IllegalArgumentException(); if (factory == null || unit == null) throw new NullPointerException(); + int size = 1 << (33 - Integer.numberOfLeadingZeros(p - 1)); this.parallelism = p; this.factory = factory; this.ueh = handler; this.saturate = saturate; - this.config = asyncMode ? FIFO : 0; this.keepAlive = Math.max(unit.toMillis(keepAliveTime), TIMEOUT_SLOP); - int corep = Math.clamp(corePoolSize, p, MAX_CAP); int maxSpares = Math.clamp(maximumPoolSize - p, 0, MAX_CAP); int minAvail = Math.clamp(minimumRunnable, 0, MAX_CAP); - this.bounds = (long)(minAvail & SMASK) | (long)(maxSpares << SWIDTH) | - ((long)corep << 32); - int size = 1 << (33 - Integer.numberOfLeadingZeros(p - 1)); - this.registrationLock = new ReentrantLock(); + this.config = (((asyncMode ? FIFO : 0) & LMASK) | + (((long)maxSpares) << TC_SHIFT) | + (((long)minAvail) << RC_SHIFT)); this.queues = new WorkQueue[size]; String pid = Integer.toString(getAndAddPoolIds(1) + 1); String name = "ForkJoinPool-" + pid; @@ -2768,14 +3048,13 @@ private ForkJoinPool(byte forCommonPoolOnly) { int p = Math.min(pc, MAX_CAP); int size = (p == 0) ? 1 : 1 << (33 - Integer.numberOfLeadingZeros(p-1)); this.parallelism = p; - this.config = ISCOMMON | preset; - this.bounds = (long)(1 | (maxSpares << SWIDTH)); + this.config = ((preset & LMASK) | (((long)maxSpares) << TC_SHIFT) | + (1L << RC_SHIFT)); this.factory = fac; this.ueh = handler; this.keepAlive = DEFAULT_KEEPALIVE; this.saturate = null; this.workerNamePrefix = null; - this.registrationLock = new ReentrantLock(); this.queues = new WorkQueue[size]; this.container = SharedThreadContainer.create("ForkJoinPool.commonPool"); } @@ -2818,6 +3097,7 @@ public static ForkJoinPool commonPool() { * scheduled for execution */ public T invoke(ForkJoinTask task) { + Objects.requireNonNull(task); poolSubmit(true, task); return task.join(); } @@ -2831,6 +3111,7 @@ public T invoke(ForkJoinTask task) { * scheduled for execution */ public void execute(ForkJoinTask task) { + Objects.requireNonNull(task); poolSubmit(true, task); } @@ -2864,7 +3145,9 @@ public void execute(Runnable task) { * scheduled for execution */ public ForkJoinTask submit(ForkJoinTask task) { - return poolSubmit(true, task); + Objects.requireNonNull(task); + poolSubmit(true, task); + return task; } /** @@ -2874,7 +3157,12 @@ public ForkJoinTask submit(ForkJoinTask task) { */ @Override public ForkJoinTask submit(Callable task) { - return poolSubmit(true, new ForkJoinTask.AdaptedCallable(task)); + ForkJoinTask t = + (Thread.currentThread() instanceof ForkJoinWorkerThread) ? + new ForkJoinTask.AdaptedCallable(task) : + new ForkJoinTask.AdaptedInterruptibleCallable(task); + poolSubmit(true, t); + return t; } /** @@ -2884,7 +3172,12 @@ public ForkJoinTask submit(Callable task) { */ @Override public ForkJoinTask submit(Runnable task, T result) { - return poolSubmit(true, new ForkJoinTask.AdaptedRunnable(task, result)); + ForkJoinTask t = + (Thread.currentThread() instanceof ForkJoinWorkerThread) ? + new ForkJoinTask.AdaptedRunnable(task, result) : + new ForkJoinTask.AdaptedInterruptibleRunnable(task, result); + poolSubmit(true, t); + return t; } /** @@ -2895,13 +3188,15 @@ public ForkJoinTask submit(Runnable task, T result) { @Override @SuppressWarnings("unchecked") public ForkJoinTask submit(Runnable task) { - return poolSubmit(true, (task instanceof ForkJoinTask) - ? (ForkJoinTask) task // avoid re-wrap - : new ForkJoinTask.AdaptedRunnableAction(task)); + ForkJoinTask f = (task instanceof ForkJoinTask) ? + (ForkJoinTask) task : // avoid re-wrap + ((Thread.currentThread() instanceof ForkJoinWorkerThread) ? + new ForkJoinTask.AdaptedRunnable(task, null) : + new ForkJoinTask.AdaptedInterruptibleRunnable(task, null)); + poolSubmit(true, f); + return f; } - // Added mainly for possible use in Loom - /** * Submits the given task as if submitted from a non-{@code ForkJoinTask} * client. The task is added to a scheduling queue for submissions to the @@ -2920,10 +3215,8 @@ public ForkJoinTask submit(Runnable task) { * @since 20 */ public ForkJoinTask externalSubmit(ForkJoinTask task) { - U.storeStoreFence(); // ensure safely publishable - task.markPoolSubmission(); - WorkQueue q = submissionQueue(true); - q.push(task, this, true); + Objects.requireNonNull(task); + externalSubmissionQueue().push(task, this, false); return task; } @@ -2944,7 +3237,9 @@ public ForkJoinTask externalSubmit(ForkJoinTask task) { * @since 19 */ public ForkJoinTask lazySubmit(ForkJoinTask task) { - return poolSubmit(false, task); + Objects.requireNonNull(task); + poolSubmit(false, task); + return task; } /** @@ -2980,16 +3275,34 @@ public int setParallelism(int size) { } /** - * @throws NullPointerException {@inheritDoc} - * @throws RejectedExecutionException {@inheritDoc} + * Uninterrupible version of {@code invokeAll}. Executes the given + * tasks, returning a list of Futures holding their status and + * results when all complete, ignoring interrupts. {@link + * Future#isDone} is {@code true} for each element of the returned + * list. Note that a completed task could have + * terminated either normally or by throwing an exception. The + * results of this method are undefined if the given collection is + * modified while this operation is in progress. + * + * @apiNote This method supports usages that previously relied on an + * incompatible override of + * {@link ExecutorService#invokeAll(java.util.Collection)}. + * + * @param tasks the collection of tasks + * @param the type of the values returned from the tasks + * @return a list of Futures representing the tasks, in the same + * sequential order as produced by the iterator for the + * given task list, each of which has completed + * @throws NullPointerException if tasks or any of its elements are {@code null} + * @throws RejectedExecutionException if any task cannot be + * scheduled for execution + * @since 22 */ - @Override - public List> invokeAll(Collection> tasks) { + public List> invokeAllUninterruptibly(Collection> tasks) { ArrayList> futures = new ArrayList<>(tasks.size()); try { for (Callable t : tasks) { - ForkJoinTask f = - new ForkJoinTask.AdaptedInterruptibleCallable(t); + ForkJoinTask f = ForkJoinTask.adapt(t); futures.add(f); poolSubmit(true, f); } @@ -2998,139 +3311,66 @@ public List> invokeAll(Collection> tasks) { return futures; } catch (Throwable t) { for (Future e : futures) - ForkJoinTask.cancelIgnoringExceptions(e); + e.cancel(true); throw t; } } - @Override - public List> invokeAll(Collection> tasks, - long timeout, TimeUnit unit) + /** + * Common support for timed and untimed invokeAll + */ + private List> invokeAll(Collection> tasks, + long deadline) throws InterruptedException { - long nanos = unit.toNanos(timeout); ArrayList> futures = new ArrayList<>(tasks.size()); try { for (Callable t : tasks) { - ForkJoinTask f = - new ForkJoinTask.AdaptedInterruptibleCallable(t); + ForkJoinTask f = ForkJoinTask.adaptInterruptible(t); futures.add(f); poolSubmit(true, f); } - long startTime = System.nanoTime(), ns = nanos; - boolean timedOut = (ns < 0L); - for (int i = futures.size() - 1; i >= 0; --i) { - ForkJoinTask f = (ForkJoinTask)futures.get(i); - if (!f.isDone()) { - if (!timedOut) - timedOut = !f.quietlyJoin(ns, TimeUnit.NANOSECONDS); - if (timedOut) - ForkJoinTask.cancelIgnoringExceptions(f); - else - ns = nanos - (System.nanoTime() - startTime); - } - } + for (int i = futures.size() - 1; i >= 0; --i) + ((ForkJoinTask)futures.get(i)) + .quietlyJoinPoolInvokeAllTask(deadline); return futures; } catch (Throwable t) { for (Future e : futures) - ForkJoinTask.cancelIgnoringExceptions(e); + e.cancel(true); throw t; } } - // Task to hold results from InvokeAnyTasks - static final class InvokeAnyRoot extends ForkJoinTask { - private static final long serialVersionUID = 2838392045355241008L; - @SuppressWarnings("serial") // Conditionally serializable - volatile E result; - final AtomicInteger count; // in case all throw - @SuppressWarnings("serial") - final ForkJoinPool pool; // to check shutdown while collecting - InvokeAnyRoot(int n, ForkJoinPool p) { - pool = p; - count = new AtomicInteger(n); - } - final void tryComplete(Callable c) { // called by InvokeAnyTasks - Throwable ex = null; - boolean failed; - if (c == null || Thread.interrupted() || - (pool != null && pool.runState < 0)) - failed = true; - else if (isDone()) - failed = false; - else { - try { - complete(c.call()); - failed = false; - } catch (Throwable tx) { - ex = tx; - failed = true; - } - } - if ((pool != null && pool.runState < 0) || - (failed && count.getAndDecrement() <= 1)) - trySetThrown(ex != null ? ex : new CancellationException()); - } - public final boolean exec() { return false; } // never forked - public final E getRawResult() { return result; } - public final void setRawResult(E v) { result = v; } - } - - // Variant of AdaptedInterruptibleCallable with results in InvokeAnyRoot - static final class InvokeAnyTask extends ForkJoinTask { - private static final long serialVersionUID = 2838392045355241008L; - final InvokeAnyRoot root; - @SuppressWarnings("serial") // Conditionally serializable - final Callable callable; - transient volatile Thread runner; - InvokeAnyTask(InvokeAnyRoot root, Callable callable) { - this.root = root; - this.callable = callable; - } - public final boolean exec() { - Thread.interrupted(); - runner = Thread.currentThread(); - root.tryComplete(callable); - runner = null; - Thread.interrupted(); - return true; - } - public final boolean cancel(boolean mayInterruptIfRunning) { - Thread t; - boolean stat = super.cancel(false); - if (mayInterruptIfRunning && (t = runner) != null) { - try { - t.interrupt(); - } catch (Throwable ignore) { - } - } - return stat; - } - public final void setRawResult(E v) {} // unused - public final E getRawResult() { return null; } + @Override + public List> invokeAll(Collection> tasks) + throws InterruptedException { + return invokeAll(tasks, 0L); + } + // for jdk version < 22, replace with + // /** + // * @throws NullPointerException {@inheritDoc} + // * @throws RejectedExecutionException {@inheritDoc} + // */ + // @Override + // public List> invokeAll(Collection> tasks) { + // return invokeAllUninterruptibly(tasks); + // } + + @Override + public List> invokeAll(Collection> tasks, + long timeout, TimeUnit unit) + throws InterruptedException { + return invokeAll(tasks, (System.nanoTime() + unit.toNanos(timeout)) | 1L); } @Override public T invokeAny(Collection> tasks) throws InterruptedException, ExecutionException { - int n = tasks.size(); - if (n <= 0) - throw new IllegalArgumentException(); - InvokeAnyRoot root = new InvokeAnyRoot(n, this); - ArrayList> fs = new ArrayList<>(n); try { - for (Callable c : tasks) { - if (c == null) - throw new NullPointerException(); - InvokeAnyTask f = new InvokeAnyTask(root, c); - fs.add(f); - poolSubmit(true, f); - if (root.isDone()) - break; - } - return root.get(); - } finally { - for (InvokeAnyTask f : fs) - ForkJoinTask.cancelIgnoringExceptions(f); + return new ForkJoinTask.InvokeAnyRoot() + .invokeAny(tasks, this, false, 0L); + } catch (TimeoutException cannotHappen) { + assert false; + return null; } } @@ -3138,27 +3378,8 @@ public T invokeAny(Collection> tasks) public T invokeAny(Collection> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - long nanos = unit.toNanos(timeout); - int n = tasks.size(); - if (n <= 0) - throw new IllegalArgumentException(); - InvokeAnyRoot root = new InvokeAnyRoot(n, this); - ArrayList> fs = new ArrayList<>(n); - try { - for (Callable c : tasks) { - if (c == null) - throw new NullPointerException(); - InvokeAnyTask f = new InvokeAnyTask(root, c); - fs.add(f); - poolSubmit(true, f); - if (root.isDone()) - break; - } - return root.get(nanos, TimeUnit.NANOSECONDS); - } finally { - for (InvokeAnyTask f : fs) - ForkJoinTask.cancelIgnoringExceptions(f); - } + return new ForkJoinTask.InvokeAnyRoot() + .invokeAny(tasks, this, true, unit.toNanos(timeout)); } /** @@ -3264,7 +3485,7 @@ public int getActiveThreadCount() { * @return {@code true} if all threads are currently idle */ public boolean isQuiescent() { - return canStop(); + return quiescent(); } /** @@ -3339,7 +3560,14 @@ public int getQueuedSubmissionCount() { * @return {@code true} if there are any queued submissions */ public boolean hasQueuedSubmissions() { - return hasTasks(true); + WorkQueue[] qs; WorkQueue q; + if ((runState & STOP) == 0 && (qs = queues) != null) { + for (int i = 0; i < qs.length; i += 2) { + if ((q = qs[i]) != null && q.queueSize() > 0) + return true; + } + } + return false; } /** @@ -3388,6 +3616,7 @@ protected int drainTasksTo(Collection> c) { */ public String toString() { // Use a single pass through queues to collect counts + int e = runState; long st = stealCount; long qt = 0L, ss = 0L; int rc = 0; WorkQueue[] qs; WorkQueue q; @@ -3413,10 +3642,9 @@ public String toString() { int ac = (short)(c >>> RC_SHIFT); if (ac < 0) // ignore transient negative ac = 0; - int rs = runState; - String level = ((rs & TERMINATED) != 0 ? "Terminated" : - (rs & STOP) != 0 ? "Terminating" : - (rs & SHUTDOWN) != 0 ? "Shutting down" : + String level = ((e & TERMINATED) != 0 ? "Terminated" : + (e & STOP) != 0 ? "Terminating" : + (e & SHUTDOWN) != 0 ? "Shutting down" : "Running"); return super.toString() + "[" + level + @@ -3446,7 +3674,8 @@ public String toString() { */ public void shutdown() { checkPermission(); - tryTerminate(false, true); + if (workerNamePrefix != null) // not common pool + tryTerminate(false, true); } /** @@ -3469,7 +3698,8 @@ public void shutdown() { */ public List shutdownNow() { checkPermission(); - tryTerminate(true, true); + if (workerNamePrefix != null) // not common pool + tryTerminate(true, true); return Collections.emptyList(); } @@ -3479,7 +3709,7 @@ public List shutdownNow() { * @return {@code true} if all tasks have completed following shut down */ public boolean isTerminated() { - return (runState & TERMINATED) != 0; + return (tryTerminate(false, false) & TERMINATED) != 0; } /** @@ -3496,7 +3726,7 @@ public boolean isTerminated() { * @return {@code true} if terminating but not yet terminated */ public boolean isTerminating() { - return (runState & (STOP | TERMINATED)) == STOP; + return (tryTerminate(false, false) & (STOP | TERMINATED)) == STOP; } /** @@ -3505,7 +3735,7 @@ public boolean isTerminating() { * @return {@code true} if this pool has been shut down */ public boolean isShutdown() { - return runState != 0; + return (runState & SHUTDOWN) != 0; } /** @@ -3524,30 +3754,19 @@ public boolean isShutdown() { */ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { - ReentrantLock lock; Condition cond; boolean terminated; long nanos = unit.toNanos(timeout); - if ((config & ISCOMMON) != 0) { + CountDownLatch done; + if (workerNamePrefix == null) { // is common pool if (helpQuiescePool(this, nanos, true) < 0) throw new InterruptedException(); - terminated = false; - } - else if (!(terminated = ((runState & TERMINATED) != 0))) { - tryTerminate(false, false); // reduce transient blocking - if ((lock = registrationLock) != null && - !(terminated = (((runState & TERMINATED) != 0)))) { - lock.lock(); - try { - if ((cond = termination) == null) - termination = cond = lock.newCondition(); - while (!(terminated = ((runState & TERMINATED) != 0)) && - nanos > 0L) - nanos = cond.awaitNanos(nanos); - } finally { - lock.unlock(); - } - } + return false; } - return terminated; + else if ((tryTerminate(false, false) & TERMINATED) != 0 || + (done = terminationSignal()) == null || + (runState & TERMINATED) != 0) + return true; + else + return done.await(nanos, TimeUnit.NANOSECONDS); } /** @@ -3591,25 +3810,24 @@ public boolean awaitQuiescence(long timeout, TimeUnit unit) { */ @Override public void close() { - if ((config & ISCOMMON) == 0) { - boolean terminated = tryTerminate(false, false); - if (!terminated) { - shutdown(); - boolean interrupted = false; - while (!terminated) { + if (workerNamePrefix != null) { + checkPermission(); + CountDownLatch done = null; + boolean interrupted = false; + while ((tryTerminate(interrupted, true) & TERMINATED) == 0) { + if (done == null) + done = terminationSignal(); + else { try { - terminated = awaitTermination(1L, TimeUnit.DAYS); - } catch (InterruptedException e) { - if (!interrupted) { - shutdownNow(); - interrupted = true; - } + done.await(); + break; + } catch (InterruptedException ex) { + interrupted = true; } } - if (interrupted) { - Thread.currentThread().interrupt(); - } } + if (interrupted) + Thread.currentThread().interrupt(); } } @@ -3728,18 +3946,20 @@ public static void managedBlock(ManagedBlocker blocker) /** ManagedBlock for ForkJoinWorkerThreads */ private void compensatedBlock(ManagedBlocker blocker) throws InterruptedException { - if (blocker == null) throw new NullPointerException(); + Objects.requireNonNull(blocker); for (;;) { int comp; boolean done; long c = ctl; if (blocker.isReleasable()) break; - if ((comp = tryCompensate(c, false)) >= 0) { - long post = (comp == 0) ? 0L : RC_UNIT; + if ((runState & STOP) != 0) + throw new InterruptedException(); + if ((comp = tryCompensate(c)) >= 0) { try { done = blocker.block(); } finally { - getAndAddCtl(post); + if (comp > 0) + getAndAddCtl(RC_UNIT); } if (done) break; @@ -3753,22 +3973,17 @@ private void compensatedBlock(ManagedBlocker blocker) * blocking operation is done then endCompensatedBlock must be invoked * with the value returned by this method to re-adjust the parallelism. */ - private long beginCompensatedBlock() { - for (;;) { - int comp; - if ((comp = tryCompensate(ctl, false)) >= 0) { - return (comp == 0) ? 0L : RC_UNIT; - } else { - Thread.onSpinWait(); - } - } + final long beginCompensatedBlock() { + int c; + do {} while ((c = tryCompensate(ctl)) < 0); + return (c == 0) ? 0L : RC_UNIT; } /** * Re-adjusts parallelism after a blocking operation completes. */ void endCompensatedBlock(long post) { - if (post > 0) { + if (post > 0L) { getAndAddCtl(post); } } @@ -3776,22 +3991,22 @@ void endCompensatedBlock(long post) { /** ManagedBlock for external threads */ private static void unmanagedBlock(ManagedBlocker blocker) throws InterruptedException { - if (blocker == null) throw new NullPointerException(); + Objects.requireNonNull(blocker); do {} while (!blocker.isReleasable() && !blocker.block()); } - // AbstractExecutorService.newTaskFor overrides rely on - // undocumented fact that ForkJoinTask.adapt returns ForkJoinTasks - // that also implement RunnableFuture. - @Override protected RunnableFuture newTaskFor(Runnable runnable, T value) { - return new ForkJoinTask.AdaptedRunnable(runnable, value); + return (Thread.currentThread() instanceof ForkJoinWorkerThread) ? + new ForkJoinTask.AdaptedRunnable(runnable, value) : + new ForkJoinTask.AdaptedInterruptibleRunnable(runnable, value); } @Override protected RunnableFuture newTaskFor(Callable callable) { - return new ForkJoinTask.AdaptedCallable(callable); + return (Thread.currentThread() instanceof ForkJoinWorkerThread) ? + new ForkJoinTask.AdaptedCallable(callable) : + new ForkJoinTask.AdaptedInterruptibleCallable(callable); } static { @@ -3806,8 +4021,15 @@ protected RunnableFuture newTaskFor(Callable callable) { } CTL = U.objectFieldOffset(klass, "ctl"); RUNSTATE = U.objectFieldOffset(klass, "runState"); - PARALLELISM = U.objectFieldOffset(klass, "parallelism"); + PARALLELISM = U.objectFieldOffset(klass, "parallelism"); THREADIDS = U.objectFieldOffset(klass, "threadIds"); + TERMINATION = U.objectFieldOffset(klass, "termination"); + Class aklass = ForkJoinTask[].class; + ABASE = U.arrayBaseOffset(aklass); + int scale = U.arrayIndexScale(aklass); + ASHIFT = 31 - Integer.numberOfLeadingZeros(scale); + if ((scale & (scale - 1)) != 0) + throw new Error("array index scale not a power of two"); defaultForkJoinWorkerThreadFactory = new DefaultForkJoinWorkerThreadFactory(); diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java index e0737cde89d19..8706359cda28f 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java @@ -39,6 +39,7 @@ import java.lang.reflect.Constructor; import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.RandomAccess; import java.util.concurrent.locks.LockSupport; import jdk.internal.misc.Unsafe; @@ -208,20 +209,29 @@ public abstract class ForkJoinTask implements Future, Serializable { * See the internal documentation of class ForkJoinPool for a * general implementation overview. ForkJoinTasks are mainly * responsible for maintaining their "status" field amidst relays - * to methods in ForkJoinWorkerThread and ForkJoinPool. + * to methods in ForkJoinWorkerThread and ForkJoinPool, along with + * recording and reporting exceptions. The status field mainly + * holds bits recording completion status. Note that there is no + * status bit representing "running", recording whether incomplete + * tasks are queued vs executing. However these cases can be + * distinguished in subclasses of InterruptibleTask that adds this + * capability by recording the running thread. Cancellation is + * recorded in status bits (ABNORMAL but not THROWN), but reported + * in joining methods by throwing an exception. Other exceptions + * of completed (THROWN) tasks are recorded in the "aux" field, + * but are reconstructed (in getException) to produce more useful + * stack traces when reported. Sentinels for interruptions or + * timeouts while waiting for completion are not recorded as + * status bits but are included in return values of methods in + * which they occur. * * The methods of this class are more-or-less layered into * (1) basic status maintenance * (2) execution and awaiting completion * (3) user-level methods that additionally report results. + * (4) Subclasses for adaptors and internal usages * This is sometimes hard to see because this file orders exported * methods in a way that flows well in javadocs. - * - * Revision notes: This class uses jdk-internal Unsafe for atomics - * and special memory modes, rather than VarHandles, to avoid - * initialization dependencies in other jdk components that - * require early parallelism. It also simplifies handling of - * pool-submitted tasks, among other minor improvements. */ /** @@ -231,9 +241,9 @@ public abstract class ForkJoinTask implements Future, Serializable { * waiters. Cancelled waiters try to unsplice. */ static final class Aux { - final Thread thread; - final Throwable ex; // null if a waiter - Aux next; // accessed only via memory-acquire chains + Thread thread; // thrower or waiter + final Throwable ex; + Aux next; // accessed only via memory-acquire chains Aux(Thread thread, Throwable ex) { this.thread = thread; this.ex = ex; @@ -259,17 +269,13 @@ final boolean casNext(Aux c, Aux v) { // used only in cancellation * control bits occupy only (some of) the upper half (16 bits) of * status field. The lower bits are used for user-defined tags. */ - static final int DONE = 1 << 31; // must be negative - static final int ABNORMAL = 1 << 16; - static final int THROWN = 1 << 17; - static final int SMASK = 0xffff; // short bits for tags - static final int UNCOMPENSATE = 1 << 16; // helpJoin return sentinel - static final int POOLSUBMIT = 1 << 18; // for pool.submit vs fork - - // flags for awaitDone (in addition to above) - static final int RAN = 1; - static final int INTERRUPTIBLE = 2; - static final int TIMED = 4; + static final int DONE = 1 << 31; // must be negative + static final int ABNORMAL = 1 << 16; + static final int THROWN = 1 << 17; + static final int HAVE_EXCEPTION = DONE | ABNORMAL | THROWN; + static final int MARKER = 1 << 30; // utility marker + static final int SMASK = 0xffff; // short bits for tags + static final int UNCOMPENSATE = 1 << 16; // helpJoin sentinel // Fields volatile int status; // accessed directly by pool and workers @@ -285,25 +291,24 @@ private int getAndBitwiseOrStatus(int v) { private boolean casStatus(int c, int v) { return U.compareAndSetInt(this, STATUS, c, v); } + + // Support for waiting and signalling + private boolean casAux(Aux c, Aux v) { return U.compareAndSetReference(this, AUX, c, v); } - - /** - * Marks this task as an external pool submission. - */ - final void markPoolSubmission() { - getAndBitwiseOrStatus(POOLSUBMIT); + private Aux compareAndExchangeAux(Aux c, Aux v) { + return (Aux)U.compareAndExchangeReference(this, AUX, c, v); } - /** Removes and unparks waiters */ private void signalWaiters() { - for (Aux a; (a = aux) != null && a.ex == null; ) { - if (casAux(a, null)) { // detach entire list - for (Thread t; a != null; a = a.next) { - if ((t = a.thread) != Thread.currentThread() && t != null) - LockSupport.unpark(t); // don't self-signal - } + for (Aux a = aux;;) { + if (a == null || a.ex != null) + break; + if (a == (a = compareAndExchangeAux(a, null))) { + do { // detach entire list + LockSupport.unpark(a.thread); + } while ((a = a.next) != null); break; } } @@ -311,23 +316,27 @@ private void signalWaiters() { /** * Sets DONE status and wakes up threads waiting to join this task. - * @return status on exit */ - private int setDone() { - int s = getAndBitwiseOrStatus(DONE) | DONE; + private void setDone() { + getAndBitwiseOrStatus(DONE); signalWaiters(); - return s; } /** * Sets ABNORMAL DONE status unless already done, and wakes up threads * waiting to join this task. - * @return status on exit + * @return previous status */ - private int trySetCancelled() { + final int trySetCancelled() { int s; - do {} while ((s = status) >= 0 && !casStatus(s, s |= (DONE | ABNORMAL))); - signalWaiters(); + for (;;) { + if ((s = status) < 0) + break; + if (casStatus(s, s | (DONE | ABNORMAL))) { + signalWaiters(); + break; + } + } return s; } @@ -337,175 +346,175 @@ private int trySetCancelled() { * If losing a race with setDone or trySetCancelled, the exception * may be recorded but not reported. * - * @return status on exit + * @return true if set */ - final int trySetThrown(Throwable ex) { - Aux h = new Aux(Thread.currentThread(), ex), p = null; - boolean installed = false; + final boolean trySetThrown(Throwable ex) { int s; - while ((s = status) >= 0) { - Aux a; - if (!installed && ((a = aux) == null || a.ex == null) && - (installed = casAux(a, h))) - p = a; // list of waiters replaced by h - if (installed && casStatus(s, s |= (DONE | ABNORMAL | THROWN))) - break; + boolean set = false, installed = false; + if ((s = status) >= 0) { + Aux a, p = null, h = new Aux(Thread.currentThread(), ex); + do { + if (!installed && ((a = aux) == null || a.ex == null) && + (installed = casAux(a, h))) + p = a; // list of waiters replaced by h + if (installed && (set = casStatus(s, s | HAVE_EXCEPTION))) + break; + } while ((s = status) >= 0); + for (; p != null; p = p.next) + LockSupport.unpark(p.thread); } - for (; p != null; p = p.next) - LockSupport.unpark(p.thread); - return s; + return set; } /** - * Records exception unless already done. Overridable in subclasses. - * - * @return status on exit + * Overridable action on setting exception */ - int trySetException(Throwable ex) { - return trySetThrown(ex); + void onAuxExceptionSet(Throwable ex) { } /** - * Constructor for subclasses to call. + * Tries to set exception, if so invoking onAuxExceptionSet */ - public ForkJoinTask() {} - - static boolean isExceptionalStatus(int s) { // needed by subclasses - return (s & THROWN) != 0; + final void trySetException(Throwable ex) { + if (trySetThrown(ex)) + onAuxExceptionSet(ex); } - /** - * Unless done, calls exec and records status if completed, but - * doesn't wait for completion otherwise. + /* + * Waits for signal, interrupt, timeout, or pool termination. * - * @return status on exit from this method - */ - final int doExec() { - int s; boolean completed; + * @param pool if nonnull, the pool of ForkJoinWorkerThread caller + * @param compensation result from a helping method + * @param interruptible if wait is interruptible + * @param deadline if nonzero, timeout deadline + * @return ABNORMAL if interrupted, 0 on timeout, else status on exit + */ + private int awaitDone(ForkJoinPool pool, int compensation, + boolean interruptible, long deadline) { + int s; if ((s = status) >= 0) { - try { - completed = exec(); - } catch (Throwable rex) { - s = trySetException(rex); - completed = false; - } - if (completed) - s = setDone(); - } - return s; - } - - /** - * Helps and/or waits for completion from join, get, or invoke; - * called from either internal or external threads. - * - * @param how flags for POOLSUBMIT, RAN, INTERRUPTIBLE, TIMED - * @param deadline if timed, timeout deadline - * @return ABNORMAL if interrupted, else status on exit - */ - private int awaitDone(int how, long deadline) { - int s; Thread t; ForkJoinWorkerThread wt; ForkJoinPool p; - ForkJoinPool.WorkQueue q = null; - boolean timed = (how & TIMED) != 0; - boolean owned = false, uncompensate = false; - if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) { - owned = true; - q = (wt = (ForkJoinWorkerThread)t).workQueue; - p = wt.pool; - } - else if ((p = ForkJoinPool.common) != null && (how & POOLSUBMIT) == 0) - q = p.externalQueue(); - if (q != null && p != null) { // try helping - if (this instanceof CountedCompleter) - s = p.helpComplete(this, q, owned, timed); - else if ((how & RAN) != 0 || - (s = q.tryRemoveAndExec(this, owned)) >= 0) - s = (owned) ? p.helpJoin(this, q, timed) : 0; - if (s < 0) - return s; - if (s == UNCOMPENSATE) - uncompensate = true; - } - Aux node = null; - long ns = 0L; - boolean interrupted = false, queued = false; - for (;;) { // install node and await signal - Aux a; - if ((s = status) < 0) - break; - else if (node == null) + Aux node = null; + try { // spinwait if out of memory node = new Aux(Thread.currentThread(), null); - else if (!queued) { - if (((a = aux) == null || a.ex == null) && - (queued = casAux(node.next = a, node))) - LockSupport.setCurrentBlocker(this); + } catch (OutOfMemoryError ex) { } - else if (timed && (ns = deadline - System.nanoTime()) <= 0) { - s = 0; - break; - } - else if (Thread.interrupted()) { - interrupted = true; - if ((how & POOLSUBMIT) != 0 && p != null && p.runState < 0) - cancelIgnoringExceptions(this); // cancel on shutdown - else if ((how & INTERRUPTIBLE) != 0) { - s = ABNORMAL; + boolean queued = false; + for (Aux a;;) { // try to install node + if ((s = status) < 0) + break; + else if (node == null) + Thread.onSpinWait(); + else if (((a = aux) == null || a.ex == null) && + (queued = casAux(node.next = a, node))) break; - } } - else if ((s = status) < 0) // recheck - break; - else if (timed) - LockSupport.parkNanos(ns); - else - LockSupport.park(); - } - if (uncompensate) - p.uncompensate(); - - if (queued) { - LockSupport.setCurrentBlocker(null); - if (s >= 0) { // cancellation similar to AbstractQueuedSynchronizer - outer: for (Aux a; (a = aux) != null && a.ex == null; ) { - for (Aux trail = null;;) { + if (queued) { // await signal or interrupt + LockSupport.setCurrentBlocker(this); + int interrupts = 0; // < 0 : throw; > 0 : re-interrupt + for (;;) { + if ((s = status) < 0) + break; + else if (interrupts < 0) { + s = ABNORMAL; // interrupted and not done + break; + } + else if (Thread.interrupted()) { + if (!ForkJoinPool.poolIsStopping(pool)) + interrupts = interruptible ? -1 : 1; + else { + interrupts = 1; // re-assert if cleared + try { + cancel(true); + } catch (Throwable ignore) { + } + } + } + else if (deadline != 0L) { + long ns; + if ((ns = deadline - System.nanoTime()) <= 0) { + s = 0; + break; + } + LockSupport.parkNanos(ns); + } + else + LockSupport.park(); + } + node.thread = null; // help clean aux; raciness OK + clean: for (Aux a;;) { // remove node if still present + if ((a = aux) == null || a.ex != null) + break; + for (Aux prev = null;;) { Aux next = a.next; if (a == node) { - if (trail != null) - trail.casNext(trail, next); + if (prev != null) + prev.casNext(prev, next); else if (casAux(a, next)) - break outer; // cannot be re-encountered - break; // restart - } else { - trail = a; - if ((a = next) == null) - break outer; + break clean; + break; // check for failed or stale CAS } + prev = a; + if ((a = next) == null) + break clean; // not found } } - } - else { - signalWaiters(); // help clean or signal - if (interrupted) + LockSupport.setCurrentBlocker(null); + if (interrupts > 0) Thread.currentThread().interrupt(); } } + if (compensation == UNCOMPENSATE && pool != null) + pool.uncompensate(); return s; } /** - * Cancels, ignoring any exceptions thrown by cancel. Cancel is - * spec'ed not to throw any exceptions, but if it does anyway, we - * have no recourse, so guard against this case. + * Tries applicable helping steps while joining this task, + * otherwise invokes blocking version of awaitDone. Called only + * when pre-checked not to be done, and pre-screened for + * interrupts and timeouts, if applicable. + * + * @param interruptible if wait is interruptible + * @param deadline if nonzero, timeout deadline + * @return ABNORMAL if interrupted, else status on exit */ - static final void cancelIgnoringExceptions(Future t) { - if (t != null) { + private int awaitDone(boolean interruptible, long deadline) { + ForkJoinWorkerThread wt; ForkJoinPool p; ForkJoinPool.WorkQueue q; + Thread t; boolean internal; int s; + if (internal = + (t = Thread.currentThread()) instanceof ForkJoinWorkerThread) { + p = (wt = (ForkJoinWorkerThread)t).pool; + q = wt.workQueue; + } + else + q = ForkJoinPool.externalQueue(p = ForkJoinPool.common); + return (((s = (p == null) ? 0 : + ((this instanceof CountedCompleter) ? + p.helpComplete(this, q, internal) : + (this instanceof InterruptibleTask) && !internal ? status : + p.helpJoin(this, q, internal))) < 0)) ? s : + awaitDone(internal ? p : null, s, interruptible, deadline); + } + + /** + * Runs a task body: Unless done, calls exec and records status if + * completed, but doesn't wait for completion otherwise. + */ + final void doExec() { + if (status >= 0) { + boolean completed = false; try { - t.cancel(true); - } catch (Throwable ignore) { + completed = exec(); + } catch (Throwable rex) { + trySetException(rex); } + if (completed) + setDone(); } } + // Reporting Exceptions + /** * Returns a rethrowable exception for this task, if available. * To provide accurate stack traces, if the exception was not @@ -518,13 +527,19 @@ static final void cancelIgnoringExceptions(Future t) { * still correct, although it may contain a misleading stack * trace. * + * @param asExecutionException true if wrap as ExecutionException * @return the exception, or null if none */ - private Throwable getThrowableException() { - Throwable ex; Aux a; - if ((a = aux) == null) - ex = null; - else if ((ex = a.ex) != null && a.thread != Thread.currentThread()) { + private Throwable getException(boolean asExecutionException) { + int s; Throwable ex; Aux a; + if ((s = status) >= 0 || (s & ABNORMAL) == 0) + return null; + else if ((s & THROWN) == 0 || (a = aux) == null || (ex = a.ex) == null) { + ex = new CancellationException(); + if (!asExecutionException || !(this instanceof InterruptibleTask)) + return ex; // else wrap below + } + else if (a.thread != Thread.currentThread()) { try { Constructor noArgCtor = null, oneArgCtor = null; for (Constructor c : ex.getClass().getConstructors()) { @@ -546,40 +561,16 @@ else if (noArgCtor != null) { } catch (Exception ignore) { } } - return ex; - } - - /** - * Returns exception associated with the given status, or null if none. - */ - private Throwable getException(int s) { - Throwable ex = null; - if ((s & ABNORMAL) != 0 && (ex = getThrowableException()) == null) - ex = new CancellationException(); - return ex; - } - - /** - * Throws exception associated with the given status, or - * CancellationException if none recorded. - */ - private void reportException(int s) { - ForkJoinTask.uncheckedThrow(getThrowableException()); + return (asExecutionException) ? new ExecutionException(ex) : ex; } /** - * Throws exception for (timed or untimed) get, wrapping if - * necessary in an ExecutionException. + * Throws thrown exception, or CancellationException if none + * recorded. */ - private void reportExecutionException(int s) { - Throwable ex = null, rx; - if (s == ABNORMAL) - ex = new InterruptedException(); - else if (s >= 0) - ex = new TimeoutException(); - else if ((rx = getThrowableException()) != null) - ex = new ExecutionException(rx); - ForkJoinTask.uncheckedThrow(ex); + private void reportException(boolean asExecutionException) { + ForkJoinTask. + uncheckedThrow(getException(asExecutionException)); } /** @@ -603,8 +594,29 @@ void uncheckedThrow(Throwable t) throws T { throw (T)t; // rely on vacuous cast } + // Utilities shared among ForkJoinTask, ForkJoinPool + + /** + * Sets MARKER bit, returning nonzero if previously set + */ + final int setForkJoinTaskStatusMarkerBit() { + return getAndBitwiseOrStatus(MARKER) & MARKER; + } + + /** + * Returns nonzero if MARKER bit set. + */ + final int getForkJoinTaskStatusMarkerBit() { + return status & MARKER; + } + // public methods + /** + * Constructor for subclasses to call. + */ + public ForkJoinTask() {} + /** * Arranges to asynchronously execute this task in the pool the * current task is running in, if applicable, or using the {@link @@ -622,15 +634,15 @@ void uncheckedThrow(Throwable t) throws T { */ public final ForkJoinTask fork() { Thread t; ForkJoinWorkerThread wt; - ForkJoinPool p; ForkJoinPool.WorkQueue q; - U.storeStoreFence(); // ensure safely publishable - if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) { - p = (wt = (ForkJoinWorkerThread)t).pool; - q = wt.workQueue; + ForkJoinPool p; ForkJoinPool.WorkQueue q; boolean internal; + if (internal = + (t = Thread.currentThread()) instanceof ForkJoinWorkerThread) { + q = (wt = (ForkJoinWorkerThread)t).workQueue; + p = wt.pool; } else - q = (p = ForkJoinPool.common).submissionQueue(false); - q.push(this, p, true); + q = (p = ForkJoinPool.common).externalSubmissionQueue(); + q.push(this, p, internal); return this; } @@ -647,10 +659,8 @@ public final ForkJoinTask fork() { */ public final V join() { int s; - if ((s = status) >= 0) - s = awaitDone(s & POOLSUBMIT, 0L); - if ((s & ABNORMAL) != 0) - reportException(s); + if ((((s = status) < 0 ? s : awaitDone(false, 0L)) & ABNORMAL) != 0) + reportException(false); return getRawResult(); } @@ -663,12 +673,8 @@ public final V join() { * @return the computed result */ public final V invoke() { - int s; - if ((s = doExec()) >= 0) - s = awaitDone(RAN, 0L); - if ((s & ABNORMAL) != 0) - reportException(s); - return getRawResult(); + doExec(); + return join(); } /** @@ -693,18 +699,15 @@ public static void invokeAll(ForkJoinTask t1, ForkJoinTask t2) { if (t1 == null || t2 == null) throw new NullPointerException(); t2.fork(); - if ((s1 = t1.doExec()) >= 0) - s1 = t1.awaitDone(RAN, 0L); - if ((s1 & ABNORMAL) != 0) { - cancelIgnoringExceptions(t2); - t1.reportException(s1); - } - else { - if ((s2 = t2.status) >= 0) - s2 = t2.awaitDone(0, 0L); - if ((s2 & ABNORMAL) != 0) - t2.reportException(s2); + t1.doExec(); + if ((((s1 = t1.status) < 0 ? s1 : + t1.awaitDone(false, 0L)) & ABNORMAL) != 0) { + t2.cancel(false); + t1.reportException(false); } + else if ((((s2 = t2.status) < 0 ? s2 : + t2.awaitDone(false, 0L)) & ABNORMAL) != 0) + t2.reportException(false); } /** @@ -726,36 +729,36 @@ public static void invokeAll(ForkJoinTask... tasks) { Throwable ex = null; int last = tasks.length - 1; for (int i = last; i >= 0; --i) { - ForkJoinTask t; + ForkJoinTask t; int s; if ((t = tasks[i]) == null) { ex = new NullPointerException(); break; } if (i == 0) { - int s; - if ((s = t.doExec()) >= 0) - s = t.awaitDone(RAN, 0L); - if ((s & ABNORMAL) != 0) - ex = t.getException(s); + t.doExec(); + if ((((s = t.status) < 0 ? s : + t.awaitDone(false, 0L)) & ABNORMAL) != 0) + ex = t.getException(false); break; } t.fork(); } if (ex == null) { for (int i = 1; i <= last; ++i) { - ForkJoinTask t; - if ((t = tasks[i]) != null) { - int s; - if ((s = t.status) >= 0) - s = t.awaitDone(0, 0L); - if ((s & ABNORMAL) != 0 && (ex = t.getException(s)) != null) - break; - } + ForkJoinTask t; int s; + if ((t = tasks[i]) != null && + ((((s = t.status) < 0 ? s : + t.awaitDone(false, 0L)) & ABNORMAL) != 0) && + (ex = t.getException(false)) != null) + break; } } if (ex != null) { - for (int i = 1; i <= last; ++i) - cancelIgnoringExceptions(tasks[i]); + for (int i = 1; i <= last; ++i) { + ForkJoinTask t; + if ((t = tasks[i]) != null) + t.cancel(false); + } rethrow(ex); } } @@ -789,36 +792,36 @@ public static > Collection invokeAll(Collection Throwable ex = null; int last = ts.size() - 1; // nearly same as array version for (int i = last; i >= 0; --i) { - ForkJoinTask t; + ForkJoinTask t; int s; if ((t = ts.get(i)) == null) { ex = new NullPointerException(); break; } if (i == 0) { - int s; - if ((s = t.doExec()) >= 0) - s = t.awaitDone(RAN, 0L); - if ((s & ABNORMAL) != 0) - ex = t.getException(s); + t.doExec(); + if ((((s = t.status) < 0 ? s : + t.awaitDone(false, 0L)) & ABNORMAL) != 0) + ex = t.getException(false); break; } t.fork(); } if (ex == null) { for (int i = 1; i <= last; ++i) { - ForkJoinTask t; - if ((t = ts.get(i)) != null) { - int s; - if ((s = t.status) >= 0) - s = t.awaitDone(0, 0L); - if ((s & ABNORMAL) != 0 && (ex = t.getException(s)) != null) - break; - } + ForkJoinTask t; int s; + if ((t = ts.get(i)) != null && + ((((s = t.status) < 0 ? s : + t.awaitDone(false, 0L)) & ABNORMAL) != 0) && + (ex = t.getException(false)) != null) + break; } } if (ex != null) { - for (int i = 1; i <= last; ++i) - cancelIgnoringExceptions(ts.get(i)); + for (int i = 1; i <= last; ++i) { + ForkJoinTask t; + if ((t = ts.get(i)) != null) + t.cancel(false); + } rethrow(ex); } return tasks; @@ -852,7 +855,8 @@ public static > Collection invokeAll(Collection * @return {@code true} if this task is now cancelled */ public boolean cancel(boolean mayInterruptIfRunning) { - return (trySetCancelled() & (ABNORMAL | THROWN)) == ABNORMAL; + int s = trySetCancelled(); + return (s >= 0 || (s & (ABNORMAL | THROWN)) == ABNORMAL); } public final boolean isDone() { @@ -894,16 +898,25 @@ public State state() { @Override public V resultNow() { - if (!isCompletedNormally()) - throw new IllegalStateException(); + int s = status; + if ((s & DONE) == 0) + throw new IllegalStateException("Task has not completed"); + if ((s & ABNORMAL) != 0) { + if ((s & THROWN) != 0) + throw new IllegalStateException("Task completed with exception"); + else + throw new IllegalStateException("Task was cancelled"); + } return getRawResult(); } @Override public Throwable exceptionNow() { - if ((status & (ABNORMAL | THROWN)) != (ABNORMAL | THROWN)) + Throwable ex; + if ((status & HAVE_EXCEPTION) != HAVE_EXCEPTION || + (ex = getException(false)) == null) throw new IllegalStateException(); - return getThrowableException(); + return ex; } /** @@ -914,7 +927,7 @@ public Throwable exceptionNow() { * @return the exception, or {@code null} if none */ public final Throwable getException() { - return getException(status); + return getException(false); } /** @@ -984,13 +997,14 @@ public final void quietlyComplete() { * member of a ForkJoinPool and was interrupted while waiting */ public final V get() throws InterruptedException, ExecutionException { - int s; - if (Thread.interrupted()) - s = ABNORMAL; - else if ((s = status) >= 0) - s = awaitDone((s & POOLSUBMIT) | INTERRUPTIBLE, 0L); - if ((s & ABNORMAL) != 0) - reportExecutionException(s); + int stat = status; + int s = ((stat < 0) ? stat : + (Thread.interrupted()) ? ABNORMAL : + awaitDone(true, 0L)); + if (s == ABNORMAL) + throw new InterruptedException(); + else if ((s & ABNORMAL) != 0) + reportException(true); return getRawResult(); } @@ -1011,14 +1025,17 @@ else if ((s = status) >= 0) public final V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { long nanos = unit.toNanos(timeout); - int s; - if (Thread.interrupted()) - s = ABNORMAL; - else if ((s = status) >= 0 && nanos > 0L) - s = awaitDone((s & POOLSUBMIT) | INTERRUPTIBLE | TIMED, - nanos + System.nanoTime()); - if (s >= 0 || (s & ABNORMAL) != 0) - reportExecutionException(s); + int stat = status; + int s = ((stat < 0) ? stat : + (Thread.interrupted()) ? ABNORMAL : + (nanos <= 0L) ? 0 : + awaitDone(true, (System.nanoTime() + nanos) | 1L)); + if (s == ABNORMAL) + throw new InterruptedException(); + else if (s >= 0) + throw new TimeoutException(); + else if ((s & ABNORMAL) != 0) + reportException(true); return getRawResult(); } @@ -1029,9 +1046,8 @@ else if ((s = status) >= 0 && nanos > 0L) * known to have aborted. */ public final void quietlyJoin() { - int s; - if ((s = status) >= 0) - awaitDone(s & POOLSUBMIT, 0L); + if (status >= 0) + awaitDone(false, 0L); } /** @@ -1040,9 +1056,9 @@ public final void quietlyJoin() { * exception. */ public final void quietlyInvoke() { - int s; - if ((s = doExec()) >= 0) - awaitDone(RAN, 0L); + doExec(); + if (status >= 0) + awaitDone(false, 0L); } /** @@ -1059,17 +1075,15 @@ public final void quietlyInvoke() { */ public final boolean quietlyJoin(long timeout, TimeUnit unit) throws InterruptedException { - int s; long nanos = unit.toNanos(timeout); - if (Thread.interrupted()) - s = ABNORMAL; - else if ((s = status) >= 0 && nanos > 0L) - s = awaitDone((s & POOLSUBMIT) | INTERRUPTIBLE | TIMED, - nanos + System.nanoTime()); + int stat = status; + int s = ((stat < 0) ? stat : + (Thread.interrupted()) ? ABNORMAL : + (nanos <= 0L) ? 0 : + awaitDone(true, (System.nanoTime() + nanos) | 1L)); if (s == ABNORMAL) throw new InterruptedException(); - else - return (s < 0); + return (s < 0); } /** @@ -1086,10 +1100,28 @@ public final boolean quietlyJoinUninterruptibly(long timeout, int s; long nanos = unit.toNanos(timeout); if ((s = status) >= 0 && nanos > 0L) - s = awaitDone((s & POOLSUBMIT) | TIMED, nanos + System.nanoTime()); + s = awaitDone(false, (System.nanoTime() + nanos) | 1L); return (s < 0); } + /** + * Utility for possibly-timed ForkJoinPool.invokeAll + */ + final void quietlyJoinPoolInvokeAllTask(long deadline) + throws InterruptedException { + int s; + if ((s = status) >= 0) { + if (Thread.interrupted()) + s = ABNORMAL; + else if (deadline == 0L || deadline - System.nanoTime() > 0L) + s = awaitDone(true, deadline); + if (s == ABNORMAL) + throw new InterruptedException(); + else if (s >= 0) + cancel(true); + } + } + /** * Possibly executes tasks until the pool hosting the current task * {@linkplain ForkJoinPool#isQuiescent is quiescent}. This @@ -1160,12 +1192,13 @@ public static boolean inForkJoinPool() { * @return {@code true} if unforked */ public boolean tryUnfork() { - Thread t; ForkJoinPool.WorkQueue q; boolean owned; - if (owned = (t = Thread.currentThread()) instanceof ForkJoinWorkerThread) + Thread t; ForkJoinPool.WorkQueue q; boolean internal; + if (internal = + (t = Thread.currentThread()) instanceof ForkJoinWorkerThread) q = ((ForkJoinWorkerThread)t).workQueue; else q = ForkJoinPool.commonQueue(); - return (q != null && q.tryUnpush(this, owned)); + return (q != null && q.tryUnpush(this, internal)); } /** @@ -1361,6 +1394,147 @@ public final boolean compareAndSetForkJoinTaskTag(short expect, short update) { } } + // Factory methods for adaptors below + + /** + * Returns a new {@code ForkJoinTask} that performs the {@code run} + * method of the given {@code Runnable} as its action, and returns + * a null result upon {@link #join}. + * + * @param runnable the runnable action + * @return the task + */ + public static ForkJoinTask adapt(Runnable runnable) { + return new AdaptedRunnableAction(runnable); + } + + /** + * Returns a new {@code ForkJoinTask} that performs the {@code run} + * method of the given {@code Runnable} as its action, and returns + * the given result upon {@link #join}. + * + * @param runnable the runnable action + * @param result the result upon completion + * @param the type of the result + * @return the task + */ + public static ForkJoinTask adapt(Runnable runnable, T result) { + return new AdaptedRunnable(runnable, result); + } + + /** + * Returns a new {@code ForkJoinTask} that performs the {@code call} + * method of the given {@code Callable} as its action, and returns + * its result upon {@link #join}, translating any checked exceptions + * encountered into {@code RuntimeException}. + * + * @param callable the callable action + * @param the type of the callable's result + * @return the task + */ + public static ForkJoinTask adapt(Callable callable) { + return new AdaptedCallable(callable); + } + + /** + * Returns a new {@code ForkJoinTask} that performs the {@code call} + * method of the given {@code Callable} as its action, and returns + * its result upon {@link #join}, translating any checked exceptions + * encountered into {@code RuntimeException}. Additionally, + * invocations of {@code cancel} with {@code mayInterruptIfRunning + * true} will attempt to interrupt the thread performing the task. + * + * @param callable the callable action + * @param the type of the callable's result + * @return the task + * + * @since 19 + */ + public static ForkJoinTask adaptInterruptible(Callable callable) { + return new AdaptedInterruptibleCallable(callable); + } + + /** + * Returns a new {@code ForkJoinTask} that performs the {@code run} + * method of the given {@code Runnable} as its action, and returns + * the given result upon {@link #join}, translating any checked exceptions + * encountered into {@code RuntimeException}. Additionally, + * invocations of {@code cancel} with {@code mayInterruptIfRunning + * true} will attempt to interrupt the thread performing the task. + * + * @param runnable the runnable action + * @param result the result upon completion + * @param the type of the result + * @return the task + * + * @since 22 + */ + public static ForkJoinTask adaptInterruptible(Runnable runnable, T result) { + return new AdaptedInterruptibleRunnable(runnable, result); + } + + /** + * Returns a new {@code ForkJoinTask} that performs the {@code + * run} method of the given {@code Runnable} as its action, and + * returns null upon {@link #join}, translating any checked + * exceptions encountered into {@code RuntimeException}. + * Additionally, invocations of {@code cancel} with {@code + * mayInterruptIfRunning true} will attempt to interrupt the + * thread performing the task. + * + * @param runnable the runnable action + * @return the task + * + * @since 22 + */ + public static ForkJoinTask adaptInterruptible(Runnable runnable) { + return new AdaptedInterruptibleRunnable(runnable, null); + } + + // Serialization support + + private static final long serialVersionUID = -7721805057305804111L; + + /** + * Saves this task to a stream (that is, serializes it). + * + * @param s the stream + * @throws java.io.IOException if an I/O error occurs + * @serialData the current run status and the exception thrown + * during execution, or {@code null} if none + */ + private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { + Aux a; + s.defaultWriteObject(); + s.writeObject((a = aux) == null ? null : a.ex); + } + + /** + * Reconstitutes this task from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws java.io.IOException if an I/O error occurs + */ + private void readObject(java.io.ObjectInputStream s) + throws java.io.IOException, ClassNotFoundException { + s.defaultReadObject(); + Object ex = s.readObject(); + if (ex != null) + aux = new Aux(Thread.currentThread(), (Throwable)ex); + } + + static { + U = Unsafe.getUnsafe(); + STATUS = U.objectFieldOffset(ForkJoinTask.class, "status"); + AUX = U.objectFieldOffset(ForkJoinTask.class, "aux"); + Class dep1 = LockSupport.class; // ensure loaded + Class dep2 = Aux.class; + } + + // Special subclasses for adaptors and internal tasks + /** * Adapter for Runnables. This implements RunnableFuture * to be compliant with AbstractExecutorService constraints @@ -1373,7 +1547,7 @@ static final class AdaptedRunnable extends ForkJoinTask @SuppressWarnings("serial") // Conditionally serializable T result; AdaptedRunnable(Runnable runnable, T result) { - if (runnable == null) throw new NullPointerException(); + Objects.requireNonNull(runnable); this.runnable = runnable; this.result = result; // OK to set this even before completion } @@ -1395,7 +1569,7 @@ static final class AdaptedRunnableAction extends ForkJoinTask @SuppressWarnings("serial") // Conditionally serializable final Runnable runnable; AdaptedRunnableAction(Runnable runnable) { - if (runnable == null) throw new NullPointerException(); + Objects.requireNonNull(runnable); this.runnable = runnable; } public final Void getRawResult() { return null; } @@ -1408,34 +1582,6 @@ public String toString() { private static final long serialVersionUID = 5232453952276885070L; } - /** - * Adapter for Runnables in which failure forces worker exception. - */ - static final class RunnableExecuteAction extends ForkJoinTask { - @SuppressWarnings("serial") // Conditionally serializable - final Runnable runnable; - RunnableExecuteAction(Runnable runnable) { - if (runnable == null) throw new NullPointerException(); - this.runnable = runnable; - } - public final Void getRawResult() { return null; } - public final void setRawResult(Void v) { } - public final boolean exec() { runnable.run(); return true; } - int trySetException(Throwable ex) { // if a handler, invoke it - int s; Thread t; java.lang.Thread.UncaughtExceptionHandler h; - if (isExceptionalStatus(s = trySetThrown(ex)) && - (h = ((t = Thread.currentThread()). - getUncaughtExceptionHandler())) != null) { - try { - h.uncaughtException(t, ex); - } catch (Throwable ignore) { - } - } - return s; - } - private static final long serialVersionUID = 5232453952276885070L; - } - /** * Adapter for Callables. */ @@ -1446,7 +1592,7 @@ static final class AdaptedCallable extends ForkJoinTask @SuppressWarnings("serial") // Conditionally serializable T result; AdaptedCallable(Callable callable) { - if (callable == null) throw new NullPointerException(); + Objects.requireNonNull(callable); this.callable = callable; } public final T getRawResult() { return result; } @@ -1468,152 +1614,238 @@ public String toString() { private static final long serialVersionUID = 2838392045355241008L; } - static final class AdaptedInterruptibleCallable extends ForkJoinTask + /** + * Tasks with semantics conforming to ExecutorService conventions. + * Tasks are interruptible when cancelled, including cases of + * cancellation upon pool termination. In addition to recording + * the running thread to enable interrupt in cancel(true), the + * task checks for termination before executing the compute + * method, to cover shutdown races in which the task has not yet + * been cancelled on entry and might not otherwise be cancelled by + * others. + */ + static abstract class InterruptibleTask extends ForkJoinTask implements RunnableFuture { - @SuppressWarnings("serial") // Conditionally serializable - final Callable callable; transient volatile Thread runner; - @SuppressWarnings("serial") // Conditionally serializable - T result; - AdaptedInterruptibleCallable(Callable callable) { - if (callable == null) throw new NullPointerException(); - this.callable = callable; - } - public final T getRawResult() { return result; } - public final void setRawResult(T v) { result = v; } + abstract T compute() throws Exception; public final boolean exec() { Thread.interrupted(); - runner = Thread.currentThread(); + Thread t = runner = Thread.currentThread(); try { - if (!isDone()) // recheck - result = callable.call(); - return true; - } catch (RuntimeException rex) { - throw rex; - } catch (Exception ex) { - throw new RuntimeException(ex); + if ((t instanceof ForkJoinWorkerThread) && + ForkJoinPool.poolIsStopping(((ForkJoinWorkerThread)t).pool)) + cancel(true); + else { + try { + if (status >= 0) + setRawResult(compute()); + } catch (Exception ex) { + trySetException(ex); + } + } } finally { runner = null; - Thread.interrupted(); } + return true; } - public final void run() { invoke(); } - public final boolean cancel(boolean mayInterruptIfRunning) { + public boolean cancel(boolean mayInterruptIfRunning) { Thread t; - boolean stat = super.cancel(false); - if (mayInterruptIfRunning && (t = runner) != null) { - try { - t.interrupt(); - } catch (Throwable ignore) { + if (trySetCancelled() >= 0) { + if (mayInterruptIfRunning && (t = runner) != null) { + try { + t.interrupt(); + } catch (Throwable ignore) { + } } + return true; } - return stat; + return isCancelled(); } + public final void run() { quietlyInvoke(); } + Object adaptee() { return null; } // for printing and diagnostics public String toString() { - return super.toString() + "[Wrapped task = " + callable + "]"; + Object a = adaptee(); + String s = super.toString(); + return ((a == null) ? s : + (s + "[Wrapped task = " + a.toString() + "]")); } private static final long serialVersionUID = 2838392045355241008L; } /** - * Returns a new {@code ForkJoinTask} that performs the {@code run} - * method of the given {@code Runnable} as its action, and returns - * a null result upon {@link #join}. - * - * @param runnable the runnable action - * @return the task + * Adapter for Callable-based interruptible tasks. */ - public static ForkJoinTask adapt(Runnable runnable) { - return new AdaptedRunnableAction(runnable); + static final class AdaptedInterruptibleCallable extends InterruptibleTask { + @SuppressWarnings("serial") // Conditionally serializable + final Callable callable; + @SuppressWarnings("serial") // Conditionally serializable + T result; + AdaptedInterruptibleCallable(Callable callable) { + Objects.requireNonNull(callable); + this.callable = callable; + } + public final T getRawResult() { return result; } + public final void setRawResult(T v) { result = v; } + final T compute() throws Exception { return callable.call(); } + final Object adaptee() { return callable; } + private static final long serialVersionUID = 2838392045355241008L; } /** - * Returns a new {@code ForkJoinTask} that performs the {@code run} - * method of the given {@code Runnable} as its action, and returns - * the given result upon {@link #join}. - * - * @param runnable the runnable action - * @param result the result upon completion - * @param the type of the result - * @return the task + * Adapter for Runnable-based interruptible tasks. */ - public static ForkJoinTask adapt(Runnable runnable, T result) { - return new AdaptedRunnable(runnable, result); + static final class AdaptedInterruptibleRunnable extends InterruptibleTask { + @SuppressWarnings("serial") // Conditionally serializable + final Runnable runnable; + @SuppressWarnings("serial") // Conditionally serializable + final T result; + AdaptedInterruptibleRunnable(Runnable runnable, T result) { + Objects.requireNonNull(runnable); + this.runnable = runnable; + this.result = result; + } + public final T getRawResult() { return result; } + public final void setRawResult(T v) { } + final T compute() { runnable.run(); return result; } + final Object adaptee() { return runnable; } + private static final long serialVersionUID = 2838392045355241008L; } /** - * Returns a new {@code ForkJoinTask} that performs the {@code call} - * method of the given {@code Callable} as its action, and returns - * its result upon {@link #join}, translating any checked exceptions - * encountered into {@code RuntimeException}. - * - * @param callable the callable action - * @param the type of the callable's result - * @return the task + * Adapter for Runnables in which failure forces worker exception. */ - public static ForkJoinTask adapt(Callable callable) { - return new AdaptedCallable(callable); + static final class RunnableExecuteAction extends InterruptibleTask { + @SuppressWarnings("serial") // Conditionally serializable + final Runnable runnable; + RunnableExecuteAction(Runnable runnable) { + Objects.requireNonNull(runnable); + this.runnable = runnable; + } + public final Void getRawResult() { return null; } + public final void setRawResult(Void v) { } + final Void compute() { runnable.run(); return null; } + final Object adaptee() { return runnable; } + void onAuxExceptionSet(Throwable ex) { // if a handler, invoke it + Thread t; java.lang.Thread.UncaughtExceptionHandler h; + if ((h = ((t = Thread.currentThread()). + getUncaughtExceptionHandler())) != null) { + try { + h.uncaughtException(t, ex); + } catch (Throwable ignore) { + } + } + } + private static final long serialVersionUID = 5232453952276885070L; } /** - * Returns a new {@code ForkJoinTask} that performs the {@code call} - * method of the given {@code Callable} as its action, and returns - * its result upon {@link #join}, translating any checked exceptions - * encountered into {@code RuntimeException}. Additionally, - * invocations of {@code cancel} with {@code mayInterruptIfRunning - * true} will attempt to interrupt the thread performing the task. - * - * @param callable the callable action - * @param the type of the callable's result - * @return the task - * - * @since 19 - */ - public static ForkJoinTask adaptInterruptible(Callable callable) { - // https://bugs.openjdk.org/browse/JDK-8246587 - return new AdaptedInterruptibleCallable(callable); - } - - // Serialization support - - private static final long serialVersionUID = -7721805057305804111L; + * Task (that is never forked) to hold results for + * ForkJoinPool.invokeAny, or to report exception if all subtasks + * fail or are cancelled or the pool is terminating. Both + * InvokeAnyRoot and InvokeAnyTask objects exist only transiently + * during invokeAny invocations, so serialization support would be + * nonsensical and is omitted. + */ + @SuppressWarnings("serial") + static final class InvokeAnyRoot extends InterruptibleTask { + volatile T result; + volatile int count; // number of tasks; decremented in case all tasks fail + InvokeAnyRoot() { } + final void tryComplete(InvokeAnyTask f, T v, Throwable ex, + boolean completed) { + if (f != null && !isDone()) { + if (ForkJoinPool.poolIsStopping(getPool())) + trySetCancelled(); + else if (f.setForkJoinTaskStatusMarkerBit() == 0) { + if (completed) { + result = v; + quietlyComplete(); + } + else if (U.getAndAddInt(this, COUNT, -1) <= 1) { + if (ex == null) + trySetCancelled(); + else + trySetException(ex); + } + } + } + } + public final T compute() { return null; } // never forked + public final T getRawResult() { return result; } + public final void setRawResult(T v) { } + + // Common support for timed and untimed versions of invokeAny + final T invokeAny(Collection> tasks, + ForkJoinPool pool, boolean timed, long nanos) + throws InterruptedException, ExecutionException, TimeoutException { + if ((count = tasks.size()) <= 0) + throw new IllegalArgumentException(); + if (pool == null) + throw new NullPointerException(); + InvokeAnyTask t = null; // list of submitted tasks + try { + for (Callable c : tasks) + pool.execute((ForkJoinTask) + (t = new InvokeAnyTask(c, this, t))); + return timed ? get(nanos, TimeUnit.NANOSECONDS) : get(); + } finally { + for (; t != null; t = t.pred) + t.onRootCompletion(); + } + } - /** - * Saves this task to a stream (that is, serializes it). - * - * @param s the stream - * @throws java.io.IOException if an I/O error occurs - * @serialData the current run status and the exception thrown - * during execution, or {@code null} if none - */ - private void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException { - Aux a; - s.defaultWriteObject(); - s.writeObject((a = aux) == null ? null : a.ex); + private static final Unsafe U; + private static final long COUNT; + static { + U = Unsafe.getUnsafe(); + COUNT = U.objectFieldOffset(InvokeAnyRoot.class, "count"); + } } /** - * Reconstitutes this task from a stream (that is, deserializes it). - * @param s the stream - * @throws ClassNotFoundException if the class of a serialized object - * could not be found - * @throws java.io.IOException if an I/O error occurs + * Task with results in InvokeAnyRoot (and never independently + * joined). */ - private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException { - s.defaultReadObject(); - Object ex = s.readObject(); - if (ex != null) - trySetThrown((Throwable)ex); - } - - static { - U = Unsafe.getUnsafe(); - STATUS = U.objectFieldOffset(ForkJoinTask.class, "status"); - AUX = U.objectFieldOffset(ForkJoinTask.class, "aux"); - Class dep1 = LockSupport.class; // ensure loaded - Class dep2 = Aux.class; + @SuppressWarnings("serial") + static final class InvokeAnyTask extends InterruptibleTask { + final Callable callable; + final InvokeAnyRoot root; + final InvokeAnyTask pred; // to traverse on cancellation + InvokeAnyTask(Callable callable, InvokeAnyRoot root, + InvokeAnyTask pred) { + Objects.requireNonNull(callable); + this.callable = callable; + this.root = root; + this.pred = pred; + } + final Void compute() throws Exception { + InvokeAnyRoot r = root; + T v = null; Throwable ex = null; boolean completed = false; + if (r != null && !r.isDone()) { + try { + v = callable.call(); + completed = true; + } catch (Exception rex) { + ex = rex; + } finally { + r.tryComplete(this, v, ex, completed); + } + } + return null; + } + public final boolean cancel(boolean mayInterruptIfRunning) { + InvokeAnyRoot r; + boolean stat = super.cancel(mayInterruptIfRunning); + if ((r = root) != null) + r.tryComplete(this, null, null, false); + return stat; + } + final void onRootCompletion() { + if (!isDone()) + super.cancel(true); // no need for tryComplete + } + public final Void getRawResult() { return null; } + public final void setRawResult(Void v) { } + final Object adaptee() { return callable; } } - } diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java index f7281998251d4..c4fc3de975084 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java @@ -76,9 +76,8 @@ public class ForkJoinWorkerThread extends Thread { boolean clearThreadLocals) { super(group, null, pool.nextWorkerThreadName(), 0L, !clearThreadLocals); UncaughtExceptionHandler handler = (this.pool = pool).ueh; - this.workQueue = new ForkJoinPool.WorkQueue(this, 0); - if (clearThreadLocals) - workQueue.setClearThreadLocals(); + this.workQueue = new ForkJoinPool.WorkQueue(this, 0, (int)pool.config, + clearThreadLocals); super.setDaemon(true); if (handler != null) super.setUncaughtExceptionHandler(handler); diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index c14ab9b7c8e4b..490b3f5642ac7 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -724,8 +724,8 @@ com/sun/jdi/InvokeHangTest.java 8218463 linux-al # jdk_util -java/util/concurrent/forkjoin/AsyncShutdownNow.java 8286352 linux-all,windows-x64 -java/util/concurrent/ExecutorService/CloseTest.java 8288899 macosx-aarch64 +java/util/Locale/LocaleProvidersRun.java 8268379 macosx-x64 +sun/util/locale/provider/CalendarDataRegression.java 8268379 macosx-x64 ############################################################################ diff --git a/test/jdk/java/util/concurrent/ExecutorService/CloseTest.java b/test/jdk/java/util/concurrent/ExecutorService/CloseTest.java index 193a467735448..162d4f7d1b4b5 100644 --- a/test/jdk/java/util/concurrent/ExecutorService/CloseTest.java +++ b/test/jdk/java/util/concurrent/ExecutorService/CloseTest.java @@ -23,9 +23,9 @@ /* * @test - * @summary Test ExecutorService.close, including default implementation + * @summary Test implementations of ExecutorService.close * @library ../lib - * @run testng CloseTest + * @run junit CloseTest */ import java.time.Duration; @@ -37,37 +37,32 @@ import java.util.concurrent.Future; import java.util.concurrent.Phaser; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.*; - -public class CloseTest { - - @DataProvider(name = "executors") - public Object[][] executors() { - var defaultThreadFactory = Executors.defaultThreadFactory(); - var virtualThreadFactory = Thread.ofVirtual().factory(); - return new Object[][] { - // ensures that default close method is tested - { new DelegatingExecutorService(Executors.newCachedThreadPool()), }, - - // implementations that may override close - { new ForkJoinPool(), }, - { Executors.newFixedThreadPool(1), }, - { Executors.newCachedThreadPool(), }, - { Executors.newThreadPerTaskExecutor(defaultThreadFactory), }, - { Executors.newThreadPerTaskExecutor(virtualThreadFactory), }, - }; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; + +class CloseTest { + + static Stream executors() { + return Stream.of( + // ensures that default close method is tested + new DelegatingExecutorService(Executors.newCachedThreadPool()), + + // implementations that may override close + Executors.newCachedThreadPool(), + Executors.newVirtualThreadPerTaskExecutor(), + new ForkJoinPool() + ); } /** * Test close with no tasks running. */ - @Test(dataProvider = "executors") - public void testCloseWithNoTasks(ExecutorService executor) throws Exception { + @ParameterizedTest + @MethodSource("executors") + void testCloseWithNoTasks(ExecutorService executor) throws Exception { executor.close(); assertTrue(executor.isShutdown()); assertTrue(executor.isTerminated()); @@ -77,24 +72,109 @@ public void testCloseWithNoTasks(ExecutorService executor) throws Exception { /** * Test close with tasks running. */ - @Test(dataProvider = "executors") - public void testCloseWithRunningTasks(ExecutorService executor) throws Exception { + @ParameterizedTest + @MethodSource("executors") + void testCloseWithRunningTasks(ExecutorService executor) throws Exception { + Phaser phaser = new Phaser(2); Future future = executor.submit(() -> { + phaser.arriveAndAwaitAdvance(); Thread.sleep(Duration.ofMillis(100)); return "foo"; }); + phaser.arriveAndAwaitAdvance(); // wait for task to start + executor.close(); // waits for task to complete + assertFalse(Thread.interrupted()); assertTrue(executor.isShutdown()); assertTrue(executor.isTerminated()); assertTrue(executor.awaitTermination(10, TimeUnit.MILLISECONDS)); - assertEquals(future.resultNow(), "foo"); + assertEquals("foo", future.resultNow()); + } + + /** + * Test shutdown with tasks running. + */ + @ParameterizedTest + @MethodSource("executors") + void testShutdownWithRunningTasks(ExecutorService executor) throws Exception { + Phaser phaser = new Phaser(2); + Future future = executor.submit(() -> { + phaser.arriveAndAwaitAdvance(); + Thread.sleep(Duration.ofMillis(100)); + return "foo"; + }); + phaser.arriveAndAwaitAdvance(); // wait for task to start + + executor.shutdown(); + assertFalse(Thread.interrupted()); + assertTrue(executor.isShutdown()); + assertTrue(executor.awaitTermination(1, TimeUnit.MINUTES)); + assertTrue(executor.isTerminated()); + assertEquals("foo", future.resultNow()); + } + + /** + * Test close with multiple tasks running + */ + @ParameterizedTest + @MethodSource("executors") + void testCloseWith2RunningTasks(ExecutorService executor) throws Exception { + Phaser phaser = new Phaser(3); + Future f1 = executor.submit(() -> { + phaser.arriveAndAwaitAdvance(); + Thread.sleep(Duration.ofMillis(100)); + return "foo"; + }); + Future f2 = executor.submit(() -> { + phaser.arriveAndAwaitAdvance(); + Thread.sleep(Duration.ofMillis(100)); + return "bar"; + }); + phaser.arriveAndAwaitAdvance(); // wait for tasks to start + + executor.close(); // waits for task to complete + assertFalse(Thread.interrupted()); + assertTrue(executor.isShutdown()); + assertTrue(executor.isTerminated()); + assertTrue(executor.awaitTermination(10, TimeUnit.MILLISECONDS)); + assertEquals("foo", f1.resultNow()); + assertEquals("bar", f2.resultNow()); + } + + /** + * Test shutdown with multiple tasks running + */ + @ParameterizedTest + @MethodSource("executors") + void testShutdownWith2RunningTasks(ExecutorService executor) throws Exception { + Phaser phaser = new Phaser(3); + Future f1 = executor.submit(() -> { + phaser.arriveAndAwaitAdvance(); + Thread.sleep(Duration.ofMillis(100)); + return "foo"; + }); + Future f2 = executor.submit(() -> { + phaser.arriveAndAwaitAdvance(); + Thread.sleep(Duration.ofMillis(100)); + return "bar"; + }); + phaser.arriveAndAwaitAdvance(); // wait for tasks to start + + executor.shutdown(); + assertFalse(Thread.interrupted()); + assertTrue(executor.isShutdown()); + assertTrue(executor.awaitTermination(1, TimeUnit.MINUTES)); + assertTrue(executor.isTerminated()); + assertEquals("foo", f1.resultNow()); + assertEquals("bar", f2.resultNow()); } /** * Test close when executor is shutdown but not terminated. */ - @Test(dataProvider = "executors") - public void testShutdownBeforeClose(ExecutorService executor) throws Exception { + @ParameterizedTest + @MethodSource("executors") + void testShutdownBeforeClose(ExecutorService executor) throws Exception { Phaser phaser = new Phaser(2); Future future = executor.submit(() -> { phaser.arriveAndAwaitAdvance(); @@ -104,22 +184,22 @@ public void testShutdownBeforeClose(ExecutorService executor) throws Exception { phaser.arriveAndAwaitAdvance(); // wait for task to start executor.shutdown(); // shutdown, will not immediately terminate - executor.close(); assertTrue(executor.isShutdown()); assertTrue(executor.isTerminated()); assertTrue(executor.awaitTermination(10, TimeUnit.MILLISECONDS)); - assertEquals(future.resultNow(), "foo"); + Object s = future.resultNow(); + assertEquals("foo", s); } /** * Test close when terminated. */ - @Test(dataProvider = "executors") - public void testTerminateBeforeClose(ExecutorService executor) throws Exception { + @ParameterizedTest + @MethodSource("executors") + void testTerminateBeforeClose(ExecutorService executor) throws Exception { executor.shutdown(); assertTrue(executor.isTerminated()); - executor.close(); assertTrue(executor.isShutdown()); assertTrue(executor.isTerminated()); @@ -129,8 +209,9 @@ public void testTerminateBeforeClose(ExecutorService executor) throws Exception /** * Test invoking close with interrupt status set. */ - @Test(dataProvider = "executors") - public void testInterruptBeforeClose(ExecutorService executor) throws Exception { + @ParameterizedTest + @MethodSource("executors") + void testInterruptBeforeClose(ExecutorService executor) throws Exception { Phaser phaser = new Phaser(2); Future future = executor.submit(() -> { phaser.arriveAndAwaitAdvance(); @@ -149,21 +230,29 @@ public void testInterruptBeforeClose(ExecutorService executor) throws Exception assertTrue(executor.isShutdown()); assertTrue(executor.isTerminated()); assertTrue(executor.awaitTermination(10, TimeUnit.MILLISECONDS)); - expectThrows(ExecutionException.class, future::get); + assertThrows(ExecutionException.class, future::get); } /** * Test interrupting thread blocked in close. */ - @Test(dataProvider = "executors") - public void testInterruptDuringClose(ExecutorService executor) throws Exception { + @ParameterizedTest + @MethodSource("executors") + void testInterruptDuringClose(ExecutorService executor) throws Exception { + Phaser phaser = new Phaser(2); Future future = executor.submit(() -> { + phaser.arriveAndAwaitAdvance(); Thread.sleep(Duration.ofDays(1)); return null; }); + phaser.arriveAndAwaitAdvance(); // wait for task to start + + // schedule main thread to be interrupted Thread thread = Thread.currentThread(); new Thread(() -> { - try { Thread.sleep( Duration.ofMillis(500)); } catch (Exception ignore) { } + try { + Thread.sleep( Duration.ofMillis(100)); + } catch (Exception ignore) { } thread.interrupt(); }).start(); try { @@ -175,6 +264,6 @@ public void testInterruptDuringClose(ExecutorService executor) throws Exception assertTrue(executor.isShutdown()); assertTrue(executor.isTerminated()); assertTrue(executor.awaitTermination(10, TimeUnit.MILLISECONDS)); - expectThrows(ExecutionException.class, future::get); + assertThrows(ExecutionException.class, future::get); } } diff --git a/test/jdk/java/util/concurrent/ExecutorService/InvokeTest.java b/test/jdk/java/util/concurrent/ExecutorService/InvokeTest.java new file mode 100644 index 0000000000000..a9a4eb0d8d78e --- /dev/null +++ b/test/jdk/java/util/concurrent/ExecutorService/InvokeTest.java @@ -0,0 +1,787 @@ +/* + * 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 + * @summary Test implementations of ExecutorService.invokeAll/invokeAny + * @run junit InvokeTest + */ + +import java.time.Duration; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Stream; +import static java.lang.Thread.State.*; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; + +class InvokeTest { + + private static ScheduledExecutorService scheduler; + + @BeforeAll + static void setup() throws Exception { + scheduler = Executors.newSingleThreadScheduledExecutor(); + } + + @AfterAll + static void shutdown() { + scheduler.shutdown(); + } + + private static Stream executors() { + return Stream.of( + Executors.newCachedThreadPool(), + Executors.newVirtualThreadPerTaskExecutor(), + new ForkJoinPool() + ); + } + + /** + * Test invokeAny where all tasks complete normally. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAny1(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + Callable task2 = () -> "bar"; + String result = executor.invokeAny(List.of(task1, task2)); + assertTrue(Set.of("foo", "bar").contains(result)); + } + } + + /** + * Test invokeAny where all tasks complete normally. The completion of the + * first task should cancel remaining tasks. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAny2(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + + var task2Started = new AtomicBoolean(); + var task2Interrupted = new CountDownLatch(1); + Callable task2 = () -> { + task2Started.set(true); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + task2Interrupted.countDown(); + } + return null; + }; + + String result = executor.invokeAny(List.of(task1, task2)); + assertEquals("foo", result); + + // if task2 started then it should have been interrupted + if (task2Started.get()) { + task2Interrupted.await(); + } + } + } + + /** + * Test invokeAny where all tasks complete with exception. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAny3(ExecutorService executor) throws Exception { + try (executor) { + class FooException extends Exception { } + Callable task1 = () -> { throw new FooException(); }; + Callable task2 = () -> { throw new FooException(); }; + try { + executor.invokeAny(List.of(task1, task2)); + fail("invokeAny did not throw"); + } catch (ExecutionException e) { + Throwable cause = e.getCause(); + assertTrue(cause instanceof FooException); + } + } + } + + /** + * Test invokeAny where all tasks complete with exception. The completion + * of the last task is delayed. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAny4(ExecutorService executor) throws Exception { + try (executor) { + class FooException extends Exception { } + Callable task1 = () -> { throw new FooException(); }; + Callable task2 = () -> { + Thread.sleep(Duration.ofMillis(50)); + throw new FooException(); + }; + try { + executor.invokeAny(List.of(task1, task2)); + fail("invokeAny did not throw"); + } catch (ExecutionException e) { + Throwable cause = e.getCause(); + assertTrue(cause instanceof FooException); + } + } + } + + /** + * Test invokeAny where some, not all, tasks complete normally. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAny5(ExecutorService executor) throws Exception { + try (executor) { + class FooException extends Exception { } + Callable task1 = () -> "foo"; + Callable task2 = () -> { throw new FooException(); }; + String result = executor.invokeAny(List.of(task1, task2)); + assertEquals("foo", result); + } + } + + /** + * Test invokeAny where some, not all, tasks complete normally. The first + * task to complete normally is delayed. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAny6(ExecutorService executor) throws Exception { + try (executor) { + class FooException extends Exception { } + Callable task1 = () -> { + Thread.sleep(Duration.ofMillis(50)); + return "foo"; + }; + Callable task2 = () -> { throw new FooException(); }; + String result = executor.invokeAny(List.of(task1, task2)); + assertEquals("foo", result); + } + } + + /** + * Test timed-invokeAny where all tasks complete normally before the timeout. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAnyWithTimeout1(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + Callable task2 = () -> "bar"; + String result = executor.invokeAny(List.of(task1, task2), 1, TimeUnit.MINUTES); + assertTrue(Set.of("foo", "bar").contains(result)); + } + } + + /** + * Test timed-invokeAny where one task completes normally before the timeout. + * The remaining tests should be cancelled. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAnyWithTimeout2(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + + var task2Started = new AtomicBoolean(); + var task2Interrupted = new CountDownLatch(1); + Callable task2 = () -> { + task2Started.set(true); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + task2Interrupted.countDown(); + } + return null; + }; + + String result = executor.invokeAny(List.of(task1, task2), 1, TimeUnit.MINUTES); + assertEquals("foo", result); + + // if task2 started then it should have been interrupted + if (task2Started.get()) { + task2Interrupted.await(); + } + } + } + + /** + * Test timed-invokeAny where timeout expires before any task completes. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAnyWithTimeout3(ExecutorService executor) throws Exception { + try (executor) { + var task1Started = new AtomicBoolean(); + var task1Interrupted = new CountDownLatch(1); + Callable task1 = () -> { + task1Started.set(true); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + task1Interrupted.countDown(); + } + return null; + }; + + var task2Started = new AtomicBoolean(); + var task2Interrupted = new CountDownLatch(1); + Callable task2 = () -> { + task2Started.set(true); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + task2Interrupted.countDown(); + } + return null; + }; + + // invokeAny should throw TimeoutException + assertThrows(TimeoutException.class, + () -> executor.invokeAny(List.of(task1, task2), 100, TimeUnit.MILLISECONDS)); + + // tasks that started should be interrupted + if (task1Started.get()) { + task1Interrupted.await(); + } + if (task2Started.get()) { + task2Interrupted.await(); + } + } + } + + /** + * Test invokeAny with interrupt status set. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAnyWithInterruptSet(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> { + Thread.sleep(Duration.ofMinutes(1)); + return "foo"; + }; + Callable task2 = () -> { + Thread.sleep(Duration.ofMinutes(1)); + return "bar"; + }; + Thread.currentThread().interrupt(); + try { + executor.invokeAny(List.of(task1, task2)); + fail("invokeAny did not throw"); + } catch (InterruptedException expected) { + assertFalse(Thread.currentThread().isInterrupted()); + } finally { + Thread.interrupted(); // clear interrupt + } + } + } + + /** + * Test interrupting a thread blocked in invokeAny. + */ + @ParameterizedTest + @MethodSource("executors") + void testInterruptInvokeAny(ExecutorService executor) throws Exception { + try (executor) { + var task1Started = new AtomicBoolean(); + var task1Interrupted = new CountDownLatch(1); + Callable task1 = () -> { + task1Started.set(true); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + task1Interrupted.countDown(); + } + return null; + }; + + var task2Started = new AtomicBoolean(); + var task2Interrupted = new CountDownLatch(1); + Callable task2 = () -> { + task2Started.set(true); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + task2Interrupted.countDown(); + } + return null; + }; + + scheduleInterruptAt("invokeAny"); + try { + executor.invokeAny(List.of(task1, task2)); + fail("invokeAny did not throw"); + } catch (InterruptedException expected) { + assertFalse(Thread.currentThread().isInterrupted()); + } finally { + Thread.interrupted(); // clear interrupt + } + + // tasks that started should be interrupted + if (task1Started.get()) { + task1Interrupted.await(); + } + if (task2Started.get()) { + task2Interrupted.await(); + } + } + } + + /** + * Test invokeAny after ExecutorService has been shutdown. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAnyAfterShutdown(ExecutorService executor) throws Exception { + executor.shutdown(); + Callable task1 = () -> "foo"; + Callable task2 = () -> "bar"; + assertThrows(RejectedExecutionException.class, + () -> executor.invokeAny(List.of(task1, task2))); + } + + /** + * Test invokeAny with empty collection. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAnyEmpty1(ExecutorService executor) throws Exception { + try (executor) { + assertThrows(IllegalArgumentException.class, () -> executor.invokeAny(List.of())); + } + } + + /** + * Test timed-invokeAny with empty collection. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAnyEmpty2(ExecutorService executor) throws Exception { + try (executor) { + assertThrows(IllegalArgumentException.class, + () -> executor.invokeAny(List.of(), 1, TimeUnit.MINUTES)); + } + } + + /** + * Test invokeAny with null. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAnyNull1(ExecutorService executor)throws Exception { + try (executor) { + assertThrows(NullPointerException.class, () -> executor.invokeAny(null)); + } + } + + /** + * Test invokeAny with null element + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAnyNull2(ExecutorService executor)throws Exception { + try (executor) { + List> list = new ArrayList<>(); + list.add(() -> "foo"); + list.add(null); + assertThrows(NullPointerException.class, () -> executor.invokeAny(null)); + } + } + + /** + * Test invokeAll where all tasks complete normally. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAll1(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + Callable task2 = () -> { + Thread.sleep(Duration.ofMillis(50)); + return "bar"; + }; + + List> futures = executor.invokeAll(List.of(task1, task2)); + assertTrue(futures.size() == 2); + + // check results + List results = futures.stream().map(Future::resultNow).toList(); + assertEquals(results, List.of("foo", "bar")); + } + } + + /** + * Test invokeAll where all tasks complete with exception. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAll2(ExecutorService executor) throws Exception { + try (executor) { + class FooException extends Exception { } + class BarException extends Exception { } + Callable task1 = () -> { throw new FooException(); }; + Callable task2 = () -> { + Thread.sleep(Duration.ofMillis(50)); + throw new BarException(); + }; + + List> futures = executor.invokeAll(List.of(task1, task2)); + assertTrue(futures.size() == 2); + + // check results + Throwable e1 = assertThrows(ExecutionException.class, () -> futures.get(0).get()); + assertTrue(e1.getCause() instanceof FooException); + Throwable e2 = assertThrows(ExecutionException.class, () -> futures.get(1).get()); + assertTrue(e2.getCause() instanceof BarException); + } + } + + /** + * Test invokeAll where all tasks complete normally before the timeout expires. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAll3(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + Callable task2 = () -> { + Thread.sleep(Duration.ofMillis(50)); + return "bar"; + }; + + List> futures = executor.invokeAll(List.of(task1, task2), 1, TimeUnit.MINUTES); + assertTrue(futures.size() == 2); + + // check results + List results = futures.stream().map(Future::resultNow).toList(); + assertEquals(results, List.of("foo", "bar")); + } + } + + /** + * Test invokeAll where some tasks do not complete before the timeout expires. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAll4(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + + var task2Started = new AtomicBoolean(); + var task2Interrupted = new CountDownLatch(1); + Callable task2 = () -> { + task2Started.set(true); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + task2Interrupted.countDown(); + } + return null; + }; + + List> futures = executor.invokeAll(List.of(task1, task2), 1, TimeUnit.SECONDS); + assertTrue(futures.size() == 2); + + // task1 should be done + assertTrue(futures.get(0).isDone()); + + // task2 should be cancelled and interrupted + assertTrue(futures.get(1).isCancelled()); + + // if task2 started then it should have been interrupted + if (task2Started.get()) { + task2Interrupted.await(); + } + } + } + + /** + * Test invokeAll with interrupt status set. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllInterrupt1(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + Callable task2 = () -> { + Thread.sleep(Duration.ofMinutes(1)); + return "bar"; + }; + + Thread.currentThread().interrupt(); + try { + executor.invokeAll(List.of(task1, task2)); + fail("invokeAll did not throw"); + } catch (InterruptedException expected) { + assertFalse(Thread.currentThread().isInterrupted()); + } finally { + Thread.interrupted(); // clear interrupt + } + } + } + + /** + * Test timed-invokeAll with interrupt status set. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllInterrupt3(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + Callable task2 = () -> { + Thread.sleep(Duration.ofMinutes(1)); + return "bar"; + }; + + Thread.currentThread().interrupt(); + try { + executor.invokeAll(List.of(task1, task2), 1, TimeUnit.MINUTES); + fail("invokeAll did not throw"); + } catch (InterruptedException expected) { + assertFalse(Thread.currentThread().isInterrupted()); + } finally { + Thread.interrupted(); // clear interrupt + } + } + } + + /** + * Test interrupt with thread blocked in invokeAll. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllInterrupt4(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + + var task2Started = new AtomicBoolean(); + var task2Interrupted = new CountDownLatch(1); + Callable task2 = () -> { + task2Started.set(true); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + task2Interrupted.countDown(); + } + return null; + }; + + scheduleInterruptAt("invokeAll"); + try { + executor.invokeAll(List.of(task1, task2)); + fail("invokeAll did not throw"); + } catch (InterruptedException expected) { + assertFalse(Thread.currentThread().isInterrupted()); + } finally { + Thread.interrupted(); // clear interrupt + } + + // if task2 started then it should have been interrupted + if (task2Started.get()) { + task2Interrupted.await(); + } + } + } + + /** + * Test interrupt with thread blocked in timed-invokeAll. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllInterrupt6(ExecutorService executor) throws Exception { + try (executor) { + Callable task1 = () -> "foo"; + + var task2Started = new AtomicBoolean(); + var task2Interrupted = new CountDownLatch(1); + Callable task2 = () -> { + task2Started.set(true); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + task2Interrupted.countDown(); + } + return null; + }; + + scheduleInterruptAt("invokeAll"); + try { + executor.invokeAll(List.of(task1, task2), 1, TimeUnit.MINUTES); + fail("invokeAll did not throw"); + } catch (InterruptedException expected) { + assertFalse(Thread.currentThread().isInterrupted()); + } finally { + Thread.interrupted(); // clear interrupt + } + + // if task2 started then it should have been interrupted + if (task2Started.get()) { + task2Interrupted.await(); + } + } + } + + /** + * Test invokeAll after ExecutorService has been shutdown. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllAfterShutdown1(ExecutorService executor) throws Exception { + executor.shutdown(); + + Callable task1 = () -> "foo"; + Callable task2 = () -> "bar"; + assertThrows(RejectedExecutionException.class, + () -> executor.invokeAll(List.of(task1, task2))); + } + + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllAfterShutdown2(ExecutorService executor) throws Exception { + executor.shutdown(); + + Callable task1 = () -> "foo"; + Callable task2 = () -> "bar"; + assertThrows(RejectedExecutionException.class, + () -> executor.invokeAll(List.of(task1, task2), 1, TimeUnit.SECONDS)); + } + + /** + * Test invokeAll with empty collection. + */ + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllEmpty1(ExecutorService executor) throws Exception { + try (executor) { + List> list = executor.invokeAll(List.of()); + assertTrue(list.size() == 0); + } + } + + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllEmpty2(ExecutorService executor) throws Exception { + try (executor) { + List> list = executor.invokeAll(List.of(), 1, TimeUnit.SECONDS); + assertTrue(list.size() == 0); + } + } + + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllNull1(ExecutorService executor)throws Exception { + try (executor) { + assertThrows(NullPointerException.class, () -> executor.invokeAll(null)); + } + } + + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllNull2(ExecutorService executor)throws Exception { + try (executor) { + List> tasks = new ArrayList<>(); + tasks.add(() -> "foo"); + tasks.add(null); + assertThrows(NullPointerException.class, () -> executor.invokeAll(tasks)); + } + } + + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllNull3(ExecutorService executor)throws Exception { + try (executor) { + assertThrows(NullPointerException.class, + () -> executor.invokeAll(null, 1, TimeUnit.SECONDS)); + } + } + + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllNull4(ExecutorService executor)throws Exception { + try (executor) { + Callable task = () -> "foo"; + assertThrows(NullPointerException.class, + () -> executor.invokeAll(List.of(task), 1, null)); + } + } + + @ParameterizedTest + @MethodSource("executors") + void testInvokeAllNull5(ExecutorService executor)throws Exception { + try (executor) { + List> tasks = new ArrayList<>(); + tasks.add(() -> "foo"); + tasks.add(null); + assertThrows(NullPointerException.class, + () -> executor.invokeAll(tasks, 1, TimeUnit.SECONDS)); + } + } + + /** + * Schedules the current thread to be interrupted when it waits (timed or untimed) + * at the given method name. + */ + private void scheduleInterruptAt(String methodName) { + Thread target = Thread.currentThread(); + scheduler.submit(() -> { + try { + boolean found = false; + while (!found) { + Thread.State state = target.getState(); + assertTrue(state != TERMINATED); + if ((state == WAITING || state == TIMED_WAITING) + && contains(target.getStackTrace(), methodName)) { + found = true; + } else { + Thread.sleep(20); + } + } + target.interrupt(); + } catch (Exception e) { + e.printStackTrace(); + } + }); + } + + /** + * Returns true if the given stack trace contains an element for the given method name. + */ + private boolean contains(StackTraceElement[] stack, String methodName) { + return Arrays.stream(stack) + .anyMatch(e -> methodName.equals(e.getMethodName())); + } +} diff --git a/test/jdk/java/util/concurrent/ExecutorService/SubmitTest.java b/test/jdk/java/util/concurrent/ExecutorService/SubmitTest.java new file mode 100644 index 0000000000000..026d86a6c8501 --- /dev/null +++ b/test/jdk/java/util/concurrent/ExecutorService/SubmitTest.java @@ -0,0 +1,370 @@ +/* + * 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 + * @summary Test implementations of ExecutorService.submit/execute + * @run junit SubmitTest + */ + +import java.time.Duration; +import java.util.concurrent.*; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; + +class SubmitTest { + + private static Stream executors() { + return Stream.of( + Executors.newCachedThreadPool(), + Executors.newVirtualThreadPerTaskExecutor(), + new ForkJoinPool() + ); + } + + /** + * Test submit(Runnable) executes the task. + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitRunnable(ExecutorService executor) throws Exception { + try (executor) { + var latch = new CountDownLatch(1); + Future future = executor.submit(latch::countDown); + latch.await(); + assertNull(future.get()); + } + } + + /** + * Test submit(Runnable) throws if executor is shutdown. + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitRunnableAfterShutdown(ExecutorService executor) { + executor.shutdown(); + assertThrows(RejectedExecutionException.class, () -> executor.submit(() -> { })); + } + + /** + * Test task submitted with submit(Runnable) is not interrupted by cancel(false). + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitRunnableWithCancelFalse(ExecutorService executor) throws Exception { + try (executor) { + var started = new CountDownLatch(1); + var stop = new CountDownLatch(1); + var done = new CountDownLatch(1); + Future future = executor.submit(() -> { + started.countDown(); + try { + stop.await(); + } catch (InterruptedException e) { + // ignore + } finally { + done.countDown(); + } + }); + + // wait for task to start + started.await(); + + // cancel(false), task should not be interrupted + future.cancel(false); + assertFalse(done.await(500, TimeUnit.MILLISECONDS)); + + // let task finish + stop.countDown(); + } + } + + /** + * Test task submitted with submit(Runnable) is interrupted by cancel(true). + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitRunnableWithCancelTrue(ExecutorService executor) throws Exception { + try (executor) { + var started = new CountDownLatch(1); + var interrupted = new CountDownLatch(1); + Future future = executor.submit(() -> { + started.countDown(); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + interrupted.countDown(); + } + }); + + // wait for task to start + started.await(); + + // cancel(true), task should be interrupted + future.cancel(true); + interrupted.await(); + } + } + + /** + * Test task submitted with submit(Runnable) is interrupted if executor is + * stopped with shutdownNow. + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitRunnableWithShutdownNow(ExecutorService executor) throws Exception { + try (executor) { + var started = new CountDownLatch(1); + var interrupted = new CountDownLatch(1); + Future future = executor.submit(() -> { + started.countDown(); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + interrupted.countDown(); + } + }); + + // wait for task to start + started.await(); + + // shutdown forcefully, task should be interrupted + executor.shutdownNow(); + interrupted.await(); + } + } + + /** + * Test submit(Runnable) throws if task is null. + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitRunnableNull(ExecutorService executor) { + try (executor) { + Runnable nullTask = null; + assertThrows(NullPointerException.class, () -> executor.submit(nullTask)); + assertThrows(NullPointerException.class, () -> executor.submit(nullTask, Void.class)); + } + } + + // + + /** + * Test submit(Callable) executes the task. + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitCallable(ExecutorService executor) throws Exception { + try (executor) { + var latch = new CountDownLatch(1); + Future future = executor.submit(() -> { + latch.countDown(); + return "foo"; + }); + latch.await(); + assertEquals("foo", future.get()); + } + } + + /** + * Test submit(Callable) throws if executor is shutdown. + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitCallableAfterShutdown(ExecutorService executor) { + executor.shutdown(); + assertThrows(RejectedExecutionException.class, () -> executor.submit(() -> null)); + } + + /** + * Test task submitted with submit(Callable) is not interrupted by cancel(false). + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitCallableWithCancelFalse(ExecutorService executor) throws Exception { + try (executor) { + var started = new CountDownLatch(1); + var stop = new CountDownLatch(1); + var done = new CountDownLatch(1); + Future future = executor.submit(() -> { + started.countDown(); + try { + stop.await(); + } finally { + done.countDown(); + } + return null; + }); + + // wait for task to start + started.await(); + + // cancel(false), task should not be interrupted + future.cancel(false); + assertFalse(done.await(500, TimeUnit.MILLISECONDS)); + + // let task finish + stop.countDown(); + } + } + + /** + * Test task submitted with submit(Callable) is interrupted by cancel(true). + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitCallableWithCancelTrue(ExecutorService executor) throws Exception { + try (executor) { + var started = new CountDownLatch(1); + var interrupted = new CountDownLatch(1); + Future future = executor.submit(() -> { + started.countDown(); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + interrupted.countDown(); + } + return null; + }); + + // wait for task to start + started.await(); + + // cancel(true), task should be interrupted + future.cancel(true); + interrupted.await(); + } + } + + /** + * Test task submitted with submit(Callable) is interrupted if executor is + * stopped with shutdownNow. + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitCallableWithShutdownNow(ExecutorService executor) throws Exception { + try (executor) { + var started = new CountDownLatch(1); + var interrupted = new CountDownLatch(1); + Future future = executor.submit(() -> { + started.countDown(); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + interrupted.countDown(); + } + return null; + }); + + // wait for task to start + started.await(); + + // shutdown forcefully, task should be interrupted + executor.shutdownNow(); + interrupted.await(); + } + } + + /** + * Test submit(Callable) throws if task is null. + */ + @ParameterizedTest + @MethodSource("executors") + void testSubmitCallableNull(ExecutorService executor) { + try (executor) { + Callable nullTask = null; + assertThrows(NullPointerException.class, () -> executor.submit(nullTask)); + } + } + + // + + /** + * Test execute(Runnable) executes the task. + */ + @ParameterizedTest + @MethodSource("executors") + void testExecute(ExecutorService executor) throws Exception { + try (executor) { + var latch = new CountDownLatch(1); + executor.execute(latch::countDown); + latch.await(); + } + } + + /** + * Test execute(Runnable) throws if executor is shutdown. + */ + @ParameterizedTest + @MethodSource("executors") + void testExecuteAfterShutdown(ExecutorService executor) { + executor.shutdown(); + assertThrows(RejectedExecutionException.class, () -> executor.execute(() -> { })); + } + + /** + * Test task submitted with execute(Runnable) is interrupted if executor is + * stopped with shutdownNow. + */ + @ParameterizedTest + @MethodSource("executors") + void testExecuteWithShutdownNow(ExecutorService executor) throws Exception { + try (executor) { + var started = new CountDownLatch(1); + var interrupted = new CountDownLatch(1); + executor.execute(() -> { + started.countDown(); + try { + Thread.sleep(Duration.ofDays(1)); + } catch (InterruptedException e) { + interrupted.countDown(); + } + }); + + // wait for task to start + started.await(); + + // shutdown forcefully, task should be interrupted + executor.shutdownNow(); + interrupted.await(); + } + } + + /** + * Test execute(Runnable) throws if task is null. + */ + @ParameterizedTest + @MethodSource("executors") + void testExecuteNull(ExecutorService executor) { + try (executor) { + Runnable nullTask = null; + assertThrows(NullPointerException.class, () -> executor.execute(nullTask)); + } + } +} diff --git a/test/jdk/java/util/concurrent/Future/DefaultMethods.java b/test/jdk/java/util/concurrent/Future/DefaultMethods.java index 2571c56804322..dfeb5bde64e0d 100644 --- a/test/jdk/java/util/concurrent/Future/DefaultMethods.java +++ b/test/jdk/java/util/concurrent/Future/DefaultMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,42 +25,50 @@ * @test * @summary Test Future's default methods * @library ../lib - * @run testng DefaultMethods + * @run junit DefaultMethods */ -import java.util.concurrent.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.Future; +import java.util.stream.Stream; import static java.util.concurrent.Future.State.*; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; -public class DefaultMethods { +class DefaultMethods { - @DataProvider(name = "executors") - public Object[][] executors() { - return new Object[][] { - // ensures that default implementation is tested - { new DelegatingExecutorService(Executors.newCachedThreadPool()), }, + static Stream executors() { + return Stream.of( + // ensures that default close method is tested + new DelegatingExecutorService(Executors.newCachedThreadPool()), - // executors that may return a Future that overrides the methods - { new ForkJoinPool(), }, - { Executors.newCachedThreadPool(), } - }; + // executors that may return a Future that overrides the methods + Executors.newCachedThreadPool(), + Executors.newVirtualThreadPerTaskExecutor(), + new ForkJoinPool() + ); } /** * Test methods when the task has not completed. */ - @Test(dataProvider = "executors") - public void testRunningTask(ExecutorService executor) { + @ParameterizedTest + @MethodSource("executors") + void testRunningTask(ExecutorService executor) { try (executor) { var latch = new CountDownLatch(1); Future future = executor.submit(() -> { latch.await(); return null; }); try { assertTrue(future.state() == RUNNING); - expectThrows(IllegalStateException.class, future::resultNow); - expectThrows(IllegalStateException.class, future::exceptionNow); + assertThrows(IllegalStateException.class, future::resultNow); + assertThrows(IllegalStateException.class, future::exceptionNow); } finally { latch.countDown(); } @@ -70,41 +78,44 @@ public void testRunningTask(ExecutorService executor) { /** * Test methods when the task has already completed with a result. */ - @Test(dataProvider = "executors") - public void testCompletedTask1(ExecutorService executor) { + @ParameterizedTest + @MethodSource("executors") + void testCompletedTask1(ExecutorService executor) { try (executor) { Future future = executor.submit(() -> "foo"); awaitDone(future); assertTrue(future.state() == SUCCESS); - assertEquals(future.resultNow(), "foo"); - expectThrows(IllegalStateException.class, future::exceptionNow); + assertEquals("foo", future.resultNow()); + assertThrows(IllegalStateException.class, future::exceptionNow); } } /** * Test methods when the task has already completed with null. */ - @Test(dataProvider = "executors") - public void testCompletedTask2(ExecutorService executor) { + @ParameterizedTest + @MethodSource("executors") + void testCompletedTask2(ExecutorService executor) { try (executor) { Future future = executor.submit(() -> null); awaitDone(future); assertTrue(future.state() == SUCCESS); - assertEquals(future.resultNow(), null); - expectThrows(IllegalStateException.class, future::exceptionNow); + assertNull(future.resultNow()); + assertThrows(IllegalStateException.class, future::exceptionNow); } } /** * Test methods when the task has completed with an exception. */ - @Test(dataProvider = "executors") - public void testFailedTask(ExecutorService executor) { + @ParameterizedTest + @MethodSource("executors") + void testFailedTask(ExecutorService executor) { try (executor) { Future future = executor.submit(() -> { throw new ArithmeticException(); }); awaitDone(future); assertTrue(future.state() == FAILED); - expectThrows(IllegalStateException.class, future::resultNow); + assertThrows(IllegalStateException.class, future::resultNow); Throwable ex = future.exceptionNow(); assertTrue(ex instanceof ArithmeticException); } @@ -113,16 +124,17 @@ public void testFailedTask(ExecutorService executor) { /** * Test methods when the task has been cancelled (mayInterruptIfRunning=false) */ - @Test(dataProvider = "executors") - public void testCancelledTask1(ExecutorService executor) { + @ParameterizedTest + @MethodSource("executors") + void testCancelledTask1(ExecutorService executor) { try (executor) { var latch = new CountDownLatch(1); Future future = executor.submit(() -> { latch.await(); return null; }); future.cancel(false); try { assertTrue(future.state() == CANCELLED); - expectThrows(IllegalStateException.class, future::resultNow); - expectThrows(IllegalStateException.class, future::exceptionNow); + assertThrows(IllegalStateException.class, future::resultNow); + assertThrows(IllegalStateException.class, future::exceptionNow); } finally { latch.countDown(); } @@ -132,16 +144,17 @@ public void testCancelledTask1(ExecutorService executor) { /** * Test methods when the task has been cancelled (mayInterruptIfRunning=true) */ - @Test(dataProvider = "executors") - public void testCancelledTask2(ExecutorService executor) { + @ParameterizedTest + @MethodSource("executors") + void testCancelledTask2(ExecutorService executor) { try (executor) { var latch = new CountDownLatch(1); Future future = executor.submit(() -> { latch.await(); return null; }); future.cancel(true); try { assertTrue(future.state() == CANCELLED); - expectThrows(IllegalStateException.class, future::resultNow); - expectThrows(IllegalStateException.class, future::exceptionNow); + assertThrows(IllegalStateException.class, future::resultNow); + assertThrows(IllegalStateException.class, future::exceptionNow); } finally { latch.countDown(); } @@ -152,46 +165,46 @@ public void testCancelledTask2(ExecutorService executor) { * Test CompletableFuture with the task has not completed. */ @Test - public void testCompletableFuture1() { + void testCompletableFuture1() { var future = new CompletableFuture(); assertTrue(future.state() == RUNNING); - expectThrows(IllegalStateException.class, future::resultNow); - expectThrows(IllegalStateException.class, future::exceptionNow); + assertThrows(IllegalStateException.class, future::resultNow); + assertThrows(IllegalStateException.class, future::exceptionNow); } /** * Test CompletableFuture with the task that completed with result. */ @Test - public void testCompletableFuture2() { + void testCompletableFuture2() { var future = new CompletableFuture(); future.complete("foo"); assertTrue(future.state() == SUCCESS); - assertEquals(future.resultNow(), "foo"); - expectThrows(IllegalStateException.class, future::exceptionNow); + assertEquals("foo", future.resultNow()); + assertThrows(IllegalStateException.class, future::exceptionNow); } /** * Test CompletableFuture with the task that completed with null. */ @Test - public void testCompletableFuture3() { + void testCompletableFuture3() { var future = new CompletableFuture(); future.complete(null); assertTrue(future.state() == SUCCESS); - assertEquals(future.resultNow(), null); - expectThrows(IllegalStateException.class, future::exceptionNow); + assertNull(future.resultNow()); + assertThrows(IllegalStateException.class, future::exceptionNow); } /** * Test CompletableFuture with the task that completed with exception. */ @Test - public void testCompletableFuture4() { + void testCompletableFuture4() { var future = new CompletableFuture(); future.completeExceptionally(new ArithmeticException()); assertTrue(future.state() == FAILED); - expectThrows(IllegalStateException.class, future::resultNow); + assertThrows(IllegalStateException.class, future::resultNow); Throwable ex = future.exceptionNow(); assertTrue(ex instanceof ArithmeticException); } @@ -200,12 +213,12 @@ public void testCompletableFuture4() { * Test CompletableFuture with the task that was cancelled. */ @Test - public void testCompletableFuture5() { + void testCompletableFuture5() { var future = new CompletableFuture(); future.cancel(false); assertTrue(future.state() == CANCELLED); - expectThrows(IllegalStateException.class, future::resultNow); - expectThrows(IllegalStateException.class, future::exceptionNow); + assertThrows(IllegalStateException.class, future::resultNow); + assertThrows(IllegalStateException.class, future::exceptionNow); } /** diff --git a/test/jdk/java/util/concurrent/TEST.properties b/test/jdk/java/util/concurrent/TEST.properties new file mode 100644 index 0000000000000..74a024f2880ac --- /dev/null +++ b/test/jdk/java/util/concurrent/TEST.properties @@ -0,0 +1 @@ +maxOutputSize=2000000 diff --git a/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java index 7f7618a2189c9..5af31673167ba 100644 --- a/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java +++ b/test/jdk/java/util/concurrent/forkjoin/AsyncShutdownNow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,11 @@ /* * @test - * @run testng AsyncShutdownNow - * @summary Test invoking shutdownNow with threads blocked in Future.get, - * invokeAll, and invokeAny + * @summary Test ForkJoinPool.shutdownNow with threads blocked in invokeXXX and Future.get + * @run junit AsyncShutdownNow */ +import java.time.Duration; import java.util.Arrays; import java.util.List; import java.util.concurrent.Callable; @@ -38,42 +38,39 @@ import java.util.concurrent.ForkJoinPool; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import static java.lang.Thread.State.*; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.testng.Assert.*; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.*; -public class AsyncShutdownNow { +class AsyncShutdownNow { // long running interruptible task private static final Callable SLEEP_FOR_A_DAY = () -> { - Thread.sleep(86400_000); + Thread.sleep(Duration.ofDays(1)); return null; }; - /** - * The executors to test. - */ - @DataProvider(name = "executors") - public Object[][] executors() { - return new Object[][] { - { new ForkJoinPool() }, - { new ForkJoinPool(1) }, - }; + static Stream pools() { + return Stream.of( + new ForkJoinPool(), + new ForkJoinPool(1) + ); } /** - * Test shutdownNow with running task and thread blocked in Future::get. + * Test shutdownNow with a running task and main thread blocked in Future::get. */ - @Test(dataProvider = "executors") - public void testFutureGet(ExecutorService executor) throws Exception { - System.out.format("testFutureGet: %s%n", executor); - try (executor) { - Future future = executor.submit(SLEEP_FOR_A_DAY); + @ParameterizedTest + @MethodSource("pools") + void testFutureGet(ForkJoinPool pool) throws Exception { + try (pool) { + Future future = pool.submit(SLEEP_FOR_A_DAY); - // shutdownNow when main thread waits in ForkJoinTask.get - onWait("java.util.concurrent.ForkJoinTask.get", executor::shutdownNow); + // shutdownNow when main thread waits in ForkJoinTask.awaitDone + onWait("java.util.concurrent.ForkJoinTask.awaitDone", pool::shutdownNow); try { future.get(); fail(); @@ -84,16 +81,16 @@ public void testFutureGet(ExecutorService executor) throws Exception { } /** - * Test shutdownNow with running task and thread blocked in a timed Future::get. + * Test shutdownNow with a running task and main thread blocked in a timed Future::get. */ - @Test(dataProvider = "executors") - public void testTimedFutureGet(ExecutorService executor) throws Exception { - System.out.format("testTimedFutureGet: %s%n", executor); - try (executor) { - Future future = executor.submit(SLEEP_FOR_A_DAY); + @ParameterizedTest + @MethodSource("pools") + void testTimedFutureGet(ForkJoinPool pool) throws Exception { + try (pool) { + Future future = pool.submit(SLEEP_FOR_A_DAY); - // shutdownNow when main thread waits in ForkJoinTask.get - onWait("java.util.concurrent.ForkJoinTask.get", executor::shutdownNow); + // shutdownNow when main thread waits in ForkJoinTask.awaitDone + onWait("java.util.concurrent.ForkJoinTask.awaitDone", pool::shutdownNow); try { future.get(1, TimeUnit.HOURS); fail(); @@ -104,15 +101,15 @@ public void testTimedFutureGet(ExecutorService executor) throws Exception { } /** - * Test shutdownNow with thread blocked in invokeAll. + * Test shutdownNow with running tasks and main thread blocked in invokeAll. */ - @Test(dataProvider = "executors") - public void testInvokeAll(ExecutorService executor) throws Exception { - System.out.format("testInvokeAll: %s%n", executor); - try (executor) { - // shutdownNow when main thread waits in ForkJoinTask.quietlyJoin - onWait("java.util.concurrent.ForkJoinTask.quietlyJoin", executor::shutdownNow); - List> futures = executor.invokeAll(List.of(SLEEP_FOR_A_DAY, SLEEP_FOR_A_DAY)); + @ParameterizedTest + @MethodSource("pools") + void testInvokeAll(ForkJoinPool pool) throws Exception { + try (pool) { + // shutdownNow when main thread waits in ForkJoinTask.awaitDone + onWait("java.util.concurrent.ForkJoinTask.awaitDone", pool::shutdownNow); + List> futures = pool.invokeAll(List.of(SLEEP_FOR_A_DAY, SLEEP_FOR_A_DAY)); for (Future f : futures) { assertTrue(f.isDone()); try { @@ -126,16 +123,16 @@ public void testInvokeAll(ExecutorService executor) throws Exception { } /** - * Test shutdownNow with thread blocked in invokeAny. + * Test shutdownNow with running tasks and main thread blocked in invokeAny. */ - @Test(dataProvider = "executors", enabled = false) - public void testInvokeAny(ExecutorService executor) throws Exception { - System.out.format("testInvokeAny: %s%n", executor); - try (executor) { + @ParameterizedTest + @MethodSource("pools") + void testInvokeAny(ForkJoinPool pool) throws Exception { + try (pool) { // shutdownNow when main thread waits in ForkJoinTask.get - onWait("java.util.concurrent.ForkJoinTask.get", executor::shutdownNow); + onWait("java.util.concurrent.ForkJoinTask.get", pool::shutdownNow); try { - executor.invokeAny(List.of(SLEEP_FOR_A_DAY, SLEEP_FOR_A_DAY)); + pool.invokeAny(List.of(SLEEP_FOR_A_DAY, SLEEP_FOR_A_DAY)); fail(); } catch (ExecutionException e) { // expected diff --git a/test/jdk/java/util/concurrent/tck/ForkJoinPool19Test.java b/test/jdk/java/util/concurrent/tck/ForkJoinPool19Test.java index 320f908cd3dc0..5b1dcfc2b348d 100644 --- a/test/jdk/java/util/concurrent/tck/ForkJoinPool19Test.java +++ b/test/jdk/java/util/concurrent/tck/ForkJoinPool19Test.java @@ -249,14 +249,17 @@ static final class FailingFibAction extends RecursiveAction { FailingFibAction(int n) { number = n; } public void compute() { int n = number; - if (n <= 1) - throw new FJException(); - else { - FailingFibAction f1 = new FailingFibAction(n - 1); - FailingFibAction f2 = new FailingFibAction(n - 2); - invokeAll(f1, f2); - result = f1.result + f2.result; + if (n > 1) { + try { + FailingFibAction f1 = new FailingFibAction(n - 1); + FailingFibAction f2 = new FailingFibAction(n - 2); + invokeAll(f1, f2); + result = f1.result + f2.result; + return; + } catch (CancellationException fallthrough) { + } } + throw new FJException(); } } @@ -389,6 +392,7 @@ protected void realCompute() { } f.quietlyJoin(); checkCancelled(f); + Thread.interrupted(); }}; checkInvoke(a); a.reinitialize(); @@ -504,36 +508,78 @@ public void testAdaptInterruptible_Callable_toString() { * Implicitly closing a new pool using try-with-resources terminates it */ public void testClose() { - ForkJoinTask f = new FibAction(8); - ForkJoinPool pool = null; - try (ForkJoinPool p = new ForkJoinPool()) { - pool = p; - p.execute(f); - } - checkCompletedNormally(f); - assertTrue(pool != null && pool.isTerminated()); + Thread t = newStartedThread(new CheckedRunnable() { + public void realRun() throws InterruptedException { + FibAction f = new FibAction(1); + ForkJoinPool pool = null; + try (ForkJoinPool p = new ForkJoinPool()) { + pool = p; + p.execute(f); + } + assertTrue(pool != null && pool.isTerminated()); + f.join(); + assertEquals(1, f.result); + }}); + awaitTermination(t); } /** - * Implicitly closing common pool using try-with-resources has no effect. + * Explicitly closing a new pool terminates it */ - public void testCloseCommonPool() { - ForkJoinTask f = new FibAction(8); - ForkJoinPool pool; - try (ForkJoinPool p = pool = ForkJoinPool.commonPool()) { - p.execute(f); - } + public void testClose2() { + Thread t = newStartedThread(new CheckedRunnable() { + public void realRun() throws InterruptedException { + ForkJoinPool pool = new ForkJoinPool(); + FibAction f = new FibAction(1); + pool.execute(f); + pool.close(); + assertTrue(pool.isTerminated()); + f.join(); + assertEquals(1, f.result); + }}); + awaitTermination(t); + } - assertFalse(pool.isShutdown()); - assertFalse(pool.isTerminating()); - assertFalse(pool.isTerminated()); + /** + * Explicitly closing a shutdown pool awaits termination + */ + public void testClose3() { + Thread t = newStartedThread(new CheckedRunnable() { + public void realRun() throws InterruptedException { + ForkJoinPool pool = new ForkJoinPool(); + FibAction f = new FibAction(1); + pool.execute(f); + pool.shutdown(); + pool.close(); + assertTrue(pool.isTerminated()); + f.join(); + assertEquals(1, f.result); + }}); + awaitTermination(t); + } + /** + * Implicitly closing common pool using try-with-resources has no effect. + */ + public void testCloseCommonPool() { String prop = System.getProperty( "java.util.concurrent.ForkJoinPool.common.parallelism"); - if (! "0".equals(prop)) { - f.join(); - checkCompletedNormally(f); - } + boolean nothreads = "0".equals(prop); + Thread t = newStartedThread(new CheckedRunnable() { + public void realRun() throws InterruptedException { + ForkJoinTask f = new FibAction(8); + ForkJoinPool pool; + try (ForkJoinPool p = pool = ForkJoinPool.commonPool()) { + p.execute(f); + } + assertFalse(pool.isShutdown()); + assertFalse(pool.isTerminating()); + assertFalse(pool.isTerminated()); + if (!nothreads) { + f.join(); + checkCompletedNormally(f); + } + }}); + awaitTermination(t); } - } diff --git a/test/jdk/java/util/concurrent/tck/ForkJoinPool8Test.java b/test/jdk/java/util/concurrent/tck/ForkJoinPool8Test.java index 9be6ce3d4189c..2bc5021fcef08 100644 --- a/test/jdk/java/util/concurrent/tck/ForkJoinPool8Test.java +++ b/test/jdk/java/util/concurrent/tck/ForkJoinPool8Test.java @@ -232,14 +232,17 @@ static final class FailingFibAction extends RecursiveAction { FailingFibAction(int n) { number = n; } public void compute() { int n = number; - if (n <= 1) - throw new FJException(); - else { - FailingFibAction f1 = new FailingFibAction(n - 1); - FailingFibAction f2 = new FailingFibAction(n - 2); - invokeAll(f1, f2); - result = f1.result + f2.result; + if (n > 1) { + try { + FailingFibAction f1 = new FailingFibAction(n - 1); + FailingFibAction f2 = new FailingFibAction(n - 2); + invokeAll(f1, f2); + result = f1.result + f2.result; + return; + } catch (CancellationException fallthrough) { + } } + throw new FJException(); } } @@ -402,7 +405,9 @@ protected void realCompute() throws Exception { try { f.get(randomTimeout(), null); shouldThrow(); - } catch (NullPointerException success) {} + } catch (NullPointerException success) { + f.join(); + } }}; checkInvoke(a); } diff --git a/test/jdk/java/util/concurrent/tck/ForkJoinTaskTest.java b/test/jdk/java/util/concurrent/tck/ForkJoinTaskTest.java index 4eaa9d2a3db0b..24989cb152bf7 100644 --- a/test/jdk/java/util/concurrent/tck/ForkJoinTaskTest.java +++ b/test/jdk/java/util/concurrent/tck/ForkJoinTaskTest.java @@ -496,7 +496,9 @@ protected void realCompute() throws Exception { try { f.get(randomTimeout(), null); shouldThrow(); - } catch (NullPointerException success) {} + } catch (NullPointerException success) { + f.join(); + } }}; testInvokeOnPool(mainPool(), a); } @@ -1245,7 +1247,9 @@ protected void realCompute() throws Exception { try { f.get(randomTimeout(), null); shouldThrow(); - } catch (NullPointerException success) {} + } catch (NullPointerException success) { + f.join(); + } }}; testInvokeOnPool(singletonPool(), a); } diff --git a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java index 1f5a6e09683ce..76ab189e553fc 100644 --- a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java +++ b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java @@ -129,6 +129,7 @@ import java.util.Set; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; +import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.ExecutionException; @@ -1669,11 +1670,20 @@ void checkTimedGet(Future f, T expectedValue) { checkTimedGet(f, expectedValue, LONG_DELAY_MS); } + // Avoids unwanted interrupts when run inder jtreg + static ThreadGroup topThreadGroup() { + for (ThreadGroup g = Thread.currentThread().getThreadGroup(), p; ; g = p) + if ((p = g.getParent()) == null) + return g; + } + static final ThreadGroup jsr166TestThreadGroup = + new ThreadGroup(topThreadGroup(), "jsr1666TestThreadGroup"); + /** * Returns a new started daemon Thread running the given runnable. */ Thread newStartedThread(Runnable runnable) { - Thread t = new Thread(runnable); + Thread t = new Thread(jsr166TestThreadGroup, runnable); t.setDaemon(true); t.start(); return t; @@ -1693,10 +1703,12 @@ Thread newStartedThread(Action action) { * the thread (in the hope that it may terminate later) and fails. */ void awaitTermination(Thread thread, long timeoutMillis) { - try { - thread.join(timeoutMillis); - } catch (InterruptedException fail) { - threadUnexpectedException(fail); + for (;;) { // ignore stray interrupts by test harness + try { + thread.join(timeoutMillis); + break; + } catch (InterruptedException ignore) { + } } if (thread.getState() != Thread.State.TERMINATED) { String detail = String.format( @@ -1940,6 +1952,8 @@ public abstract class CheckedRecursiveAction extends RecursiveAction { @Override protected final void compute() { try { realCompute(); + } catch (CancellationException ex) { + throw ex; // expected by some tests } catch (Throwable fail) { threadUnexpectedException(fail); } @@ -1955,6 +1969,8 @@ public abstract class CheckedRecursiveTask extends RecursiveTask { @Override protected final T compute() { try { return realCompute(); + } catch (CancellationException ex) { + throw ex; } catch (Throwable fail) { threadUnexpectedException(fail); } diff --git a/test/jdk/java/util/concurrent/tck/RecursiveActionTest.java b/test/jdk/java/util/concurrent/tck/RecursiveActionTest.java index 64115eec1c9f0..69bae253dd196 100644 --- a/test/jdk/java/util/concurrent/tck/RecursiveActionTest.java +++ b/test/jdk/java/util/concurrent/tck/RecursiveActionTest.java @@ -162,10 +162,10 @@ void checkCancelled(RecursiveAction a) { void checkCompletedAbnormally(RecursiveAction a, Throwable t) { assertTrue(a.isDone()); - assertFalse(a.isCancelled()); assertFalse(a.isCompletedNormally()); assertTrue(a.isCompletedAbnormally()); - assertSame(t.getClass(), a.getException().getClass()); + if (!a.isCancelled()) + assertSame(t.getClass(), a.getException().getClass()); assertNull(a.getRawResult()); assertFalse(a.cancel(false)); assertFalse(a.cancel(true)); @@ -222,14 +222,17 @@ static final class FailingFibAction extends RecursiveAction { FailingFibAction(int n) { number = n; } public void compute() { int n = number; - if (n <= 1) - throw new FJException(); - else { - FailingFibAction f1 = new FailingFibAction(n - 1); - FailingFibAction f2 = new FailingFibAction(n - 2); - invokeAll(f1, f2); - result = f1.result + f2.result; + if (n > 1) { + try { + FailingFibAction f1 = new FailingFibAction(n - 1); + FailingFibAction f2 = new FailingFibAction(n - 2); + invokeAll(f1, f2); + result = f1.result + f2.result; + return; + } catch (CancellationException fallthrough) { + } } + throw new FJException(); } } @@ -488,7 +491,9 @@ protected void realCompute() throws Exception { try { f.get(randomTimeout(), null); shouldThrow(); - } catch (NullPointerException success) {} + } catch (NullPointerException success) { + f.join(); + } }}; testInvokeOnPool(mainPool(), a); } diff --git a/test/jdk/java/util/concurrent/tck/RecursiveTaskTest.java b/test/jdk/java/util/concurrent/tck/RecursiveTaskTest.java index 66745f4a19957..348fef78a6f79 100644 --- a/test/jdk/java/util/concurrent/tck/RecursiveTaskTest.java +++ b/test/jdk/java/util/concurrent/tck/RecursiveTaskTest.java @@ -178,10 +178,10 @@ void checkCancelled(RecursiveTask a) { void checkCompletedAbnormally(RecursiveTask a, Throwable t) { assertTrue(a.isDone()); - assertFalse(a.isCancelled()); assertFalse(a.isCompletedNormally()); assertTrue(a.isCompletedAbnormally()); - assertSame(t.getClass(), a.getException().getClass()); + if (!a.isCancelled()) + assertSame(t.getClass(), a.getException().getClass()); assertNull(a.getRawResult()); assertFalse(a.cancel(false)); assertFalse(a.cancel(true)); @@ -240,11 +240,15 @@ final class FailingFibTask extends RecursiveTask { FailingFibTask(int n) { number = n; } public Integer compute() { int n = number; - if (n <= 1) - throw new FJException(); - FailingFibTask f1 = new FailingFibTask(n - 1); - f1.fork(); - return new FibTask(n - 2).compute() + f1.join(); + if (n > 1) { + try { + FailingFibTask f1 = new FailingFibTask(n - 1); + f1.fork(); + return new FibTask(n - 2).compute() + f1.join(); + } catch (CancellationException fallthrough) { + } + } + throw new FJException(); } } diff --git a/test/jdk/java/util/concurrent/tck/tck.policy b/test/jdk/java/util/concurrent/tck/tck.policy index 66f79ab3e392d..62018f792a3f0 100644 --- a/test/jdk/java/util/concurrent/tck/tck.policy +++ b/test/jdk/java/util/concurrent/tck/tck.policy @@ -1,6 +1,7 @@ grant { // Permissions j.u.c. needs directly permission java.lang.RuntimePermission "modifyThread"; + permission java.lang.RuntimePermission "modifyThreadGroup"; permission java.lang.RuntimePermission "getClassLoader"; permission java.lang.RuntimePermission "setContextClassLoader"; permission java.util.PropertyPermission "*", "read"; From 141dae8b76d41accfa02a0250a1c24364cbf6f25 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Fri, 27 Oct 2023 12:10:55 +0000 Subject: [PATCH 14/16] 8318811: Compiler directives parser swallows a character after line comments Reviewed-by: shade, phh --- src/hotspot/share/utilities/json.cpp | 2 +- .../parser/DirectiveParserTest.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/utilities/json.cpp b/src/hotspot/share/utilities/json.cpp index fc0ac36bbb17f..baa15b435dbc2 100644 --- a/src/hotspot/share/utilities/json.cpp +++ b/src/hotspot/share/utilities/json.cpp @@ -580,7 +580,7 @@ u_char JSON::skip_line_comment() { return 0; } next(); - return next(); + return peek(); } /* diff --git a/test/hotspot/jtreg/compiler/compilercontrol/parser/DirectiveParserTest.java b/test/hotspot/jtreg/compiler/compilercontrol/parser/DirectiveParserTest.java index b230b1d72ab71..5401714b0f4d9 100644 --- a/test/hotspot/jtreg/compiler/compilercontrol/parser/DirectiveParserTest.java +++ b/test/hotspot/jtreg/compiler/compilercontrol/parser/DirectiveParserTest.java @@ -33,6 +33,9 @@ package compiler.compilercontrol.parser; +import java.io.FileNotFoundException; +import java.io.PrintStream; + import compiler.compilercontrol.share.JSONFile; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; @@ -52,6 +55,7 @@ public static void main(String[] args) { emptyFile(); noFile(); directory(); + lineCommentTest(); } private static void simpleTest() { @@ -145,4 +149,20 @@ private static void directory() { Asserts.assertNE(output.getExitValue(), 0, ERROR_MSG + "directory as " + "a name"); } + + private static void lineCommentTest() { + String fileName = "lineComment.json"; + try { + PrintStream out = new PrintStream(fileName); + out.println("[{"); + out.println(" match: \"*::*\","); + out.println(" c2: { Exclude: true } // c1 only for startup"); + out.println("}]"); + out.close(); + } catch (FileNotFoundException e) { + throw new Error("TESTBUG: can't open/create file " + fileName, e); + } + OutputAnalyzer output = HugeDirectiveUtil.execute(fileName); + output.shouldHaveExitValue(0); + } } From ddd071617e7bc25c496973b231d02ced438d1344 Mon Sep 17 00:00:00 2001 From: Damon Fenacci Date: Fri, 27 Oct 2023 12:56:03 +0000 Subject: [PATCH 15/16] 8317661: [REDO] store/load order not preserved when handling memory pool due to weakly ordered memory architecture of aarch64 Reviewed-by: dholmes, aph --- src/hotspot/share/code/codeCache.cpp | 2 ++ src/hotspot/share/services/memoryPool.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index 99539ed80cc4f..3af55c00567b7 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -573,6 +573,8 @@ CodeBlob* CodeCache::allocate(int size, CodeBlobType code_blob_type, bool handle CompileBroker::handle_full_code_cache(orig_code_blob_type); } return nullptr; + } else { + OrderAccess::release(); // ensure heap expansion is visible to an asynchronous observer (e.g. CodeHeapPool::get_memory_usage()) } if (PrintCodeCacheExtension) { ResourceMark rm; diff --git a/src/hotspot/share/services/memoryPool.cpp b/src/hotspot/share/services/memoryPool.cpp index 1521083547880..d5b8f93d929e8 100644 --- a/src/hotspot/share/services/memoryPool.cpp +++ b/src/hotspot/share/services/memoryPool.cpp @@ -179,6 +179,7 @@ CodeHeapPool::CodeHeapPool(CodeHeap* codeHeap, const char* name, bool support_us MemoryUsage CodeHeapPool::get_memory_usage() { size_t used = used_in_bytes(); + OrderAccess::acquire(); // ensure possible cache expansion in CodeCache::allocate is seen size_t committed = _codeHeap->capacity(); size_t maxSize = (available_for_allocation() ? max_size() : 0); From 2915d74a10c63cdca22d0055ebde67ef316a341b Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 27 Oct 2023 13:47:24 +0000 Subject: [PATCH 16/16] 8318837: javac generates wrong ldc instruction for dynamic constant loads Reviewed-by: vromero, jlahoda --- .../classes/com/sun/tools/javac/jvm/Code.java | 14 ++++++----- .../com/sun/tools/javac/jvm/Items.java | 19 ++++----------- .../javac/T8222949/TestConstantDynamic.java | 24 ++++++++++++------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java index 382c47935d353..b86bdc19be401 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java @@ -35,7 +35,9 @@ import java.util.function.ToIntFunction; import static com.sun.tools.javac.code.TypeTag.BOT; +import static com.sun.tools.javac.code.TypeTag.DOUBLE; import static com.sun.tools.javac.code.TypeTag.INT; +import static com.sun.tools.javac.code.TypeTag.LONG; import static com.sun.tools.javac.jvm.ByteCodes.*; import static com.sun.tools.javac.jvm.ClassFile.CONSTANT_Class; import static com.sun.tools.javac.jvm.ClassFile.CONSTANT_Double; @@ -401,10 +403,12 @@ void postop() { */ public void emitLdc(LoadableConstant constant) { int od = poolWriter.putConstant(constant); - if (od <= 255) { + Type constantType = types.constantType(constant); + if (constantType.hasTag(LONG) || constantType.hasTag(DOUBLE)) { + emitop2(ldc2w, od, constant); + } else if (od <= 255) { emitop1(ldc1, od, constant); - } - else { + } else { emitop2(ldc2, od, constant); } } @@ -1062,6 +1066,7 @@ public void emitop2(int op, int od, PoolConstant data) { Type t = types.erasure((Type)data); state.push(t); break; } + case ldc2: case ldc2w: state.push(types.constantType((LoadableConstant)data)); break; @@ -1069,9 +1074,6 @@ public void emitop2(int op, int od, PoolConstant data) { state.pop(1); state.push(syms.intType); break; - case ldc2: - state.push(types.constantType((LoadableConstant)data)); - break; case jsr: break; default: diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Items.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Items.java index c15287ad45e0e..c7e88efb71bc2 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Items.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Items.java @@ -590,15 +590,6 @@ class ImmediateItem extends Item { throw new UnsupportedOperationException("unsupported tag: " + typecode); } } - - private void ldc() { - if (typecode == LONGcode || typecode == DOUBLEcode) { - code.emitop2(ldc2w, value, PoolWriter::putConstant); - } else { - code.emitLdc(value); - } - } - private Number numericValue() { return (Number)((BasicConstant)value).data; } @@ -614,21 +605,21 @@ else if (Byte.MIN_VALUE <= ival && ival <= Byte.MAX_VALUE) else if (Short.MIN_VALUE <= ival && ival <= Short.MAX_VALUE) code.emitop2(sipush, ival); else - ldc(); + code.emitLdc(value); break; case LONGcode: long lval = numericValue().longValue(); if (lval == 0 || lval == 1) code.emitop0(lconst_0 + (int)lval); else - ldc(); + code.emitLdc(value); break; case FLOATcode: float fval = numericValue().floatValue(); if (isPosZero(fval) || fval == 1.0 || fval == 2.0) code.emitop0(fconst_0 + (int)fval); else { - ldc(); + code.emitLdc(value); } break; case DOUBLEcode: @@ -636,10 +627,10 @@ else if (Short.MIN_VALUE <= ival && ival <= Short.MAX_VALUE) if (isPosZero(dval) || dval == 1.0) code.emitop0(dconst_0 + (int)dval); else - ldc(); + code.emitLdc(value); break; case OBJECTcode: - ldc(); + code.emitLdc(value); break; default: Assert.error(); diff --git a/test/langtools/tools/javac/T8222949/TestConstantDynamic.java b/test/langtools/tools/javac/T8222949/TestConstantDynamic.java index dc34716e54443..c6a1531580dfa 100644 --- a/test/langtools/tools/javac/T8222949/TestConstantDynamic.java +++ b/test/langtools/tools/javac/T8222949/TestConstantDynamic.java @@ -81,21 +81,23 @@ public class TestConstantDynamic extends ComboInstance { enum ConstantType implements ComboParameter { - STRING("String", "Ljava/lang/String;"), - CLASS("Class", "Ljava/lang/Class;"), - INTEGER("int", "I"), - LONG("long", "J"), - FLOAT("float", "F"), - DOUBLE("double", "D"), - METHOD_HANDLE("MethodHandle", "Ljava/lang/invoke/MethodHandle;"), - METHOD_TYPE("MethodType", "Ljava/lang/invoke/MethodType;"); + STRING("String", "Ljava/lang/String;", Opcode.LDC), + CLASS("Class", "Ljava/lang/Class;", Opcode.LDC), + INTEGER("int", "I", Opcode.LDC), + LONG("long", "J", Opcode.LDC2_W), + FLOAT("float", "F", Opcode.LDC), + DOUBLE("double", "D", Opcode.LDC2_W), + METHOD_HANDLE("MethodHandle", "Ljava/lang/invoke/MethodHandle;", Opcode.LDC), + METHOD_TYPE("MethodType", "Ljava/lang/invoke/MethodType;", Opcode.LDC); String sourceTypeStr; String bytecodeTypeStr; + Opcode opcode; - ConstantType(String sourceTypeStr, String bytecodeTypeStr) { + ConstantType(String sourceTypeStr, String bytecodeTypeStr, Opcode opcode) { this.sourceTypeStr = sourceTypeStr; this.bytecodeTypeStr = bytecodeTypeStr; + this.opcode = opcode; } @Override @@ -205,6 +207,10 @@ void verifyBytecode(Result> res) { fail("type mismatch for ConstantDynamicEntry"); return; } + if (lci.opcode() != type.opcode) { + fail("unexpected opcode for constant value: " + lci.opcode()); + return; + } } }