From b4c8cc8d16a6926825e35c47ae19216b8fea3b37 Mon Sep 17 00:00:00 2001 From: Tyler Steele Date: Tue, 1 Aug 2023 17:06:43 +0000 Subject: [PATCH 001/341] 8307603: [AIX] Broken build after JDK-8307301 Backport-of: bb3e44d8b604b4e3facc4f49f625cc0b7ff2abd7 --- src/java.desktop/share/native/libharfbuzz/hb-subset.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/java.desktop/share/native/libharfbuzz/hb-subset.cc b/src/java.desktop/share/native/libharfbuzz/hb-subset.cc index ff591cb259f4c..538f4ec64bfe6 100644 --- a/src/java.desktop/share/native/libharfbuzz/hb-subset.cc +++ b/src/java.desktop/share/native/libharfbuzz/hb-subset.cc @@ -43,7 +43,11 @@ #include "OT/Color/sbix/sbix.hh" #include "hb-ot-os2-table.hh" #include "hb-ot-post-table.hh" + +#if !defined(AIX) #include "hb-ot-post-table-v2subset.hh" +#endif + #include "hb-ot-cff1-table.hh" #include "hb-ot-cff2-table.hh" #include "hb-ot-vorg-table.hh" From c486b9be7400f5ce55ca6db8f8beaca247951a77 Mon Sep 17 00:00:00 2001 From: Gui Cao Date: Wed, 2 Aug 2023 01:58:38 +0000 Subject: [PATCH 002/341] 8311923: TestIRMatching.java fails on RISC-V Reviewed-by: phh, fyang Backport-of: e7adbdb1f1506b82392907f7e4a5c8882d3198eb --- src/hotspot/cpu/riscv/riscv.ad | 10 +++++----- .../jtreg/compiler/lib/ir_framework/IRNode.java | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 3d59f61c83cba..6037a115b746b 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -2056,7 +2056,7 @@ bool Matcher::pd_clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, encode %{ // BEGIN Non-volatile memory access - enc_class riscv_enc_li_imm(iRegIorL dst, immIorL src) %{ + enc_class riscv_enc_mov_imm(iRegIorL dst, immIorL src) %{ C2_MacroAssembler _masm(&cbuf); int64_t con = (int64_t)$src$$constant; Register dst_reg = as_Register($dst$$reg); @@ -4672,9 +4672,9 @@ instruct loadConI(iRegINoSp dst, immI src) match(Set dst src); ins_cost(ALU_COST); - format %{ "li $dst, $src\t# int, #@loadConI" %} + format %{ "mv $dst, $src\t# int, #@loadConI" %} - ins_encode(riscv_enc_li_imm(dst, src)); + ins_encode(riscv_enc_mov_imm(dst, src)); ins_pipe(ialu_imm); %} @@ -4685,9 +4685,9 @@ instruct loadConL(iRegLNoSp dst, immL src) match(Set dst src); ins_cost(ALU_COST); - format %{ "li $dst, $src\t# long, #@loadConL" %} + format %{ "mv $dst, $src\t# long, #@loadConL" %} - ins_encode(riscv_enc_li_imm(dst, src)); + ins_encode(riscv_enc_mov_imm(dst, src)); ins_pipe(ialu_imm); %} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java index 0d3f22fad8fb4..2f2395b77c69c 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java @@ -53,13 +53,13 @@ public class IRNode { private static final String STORE_OF_CLASS_POSTFIX = "(:|\\+)\\S* \\*" + END; private static final String LOAD_OF_CLASS_POSTFIX = "(:|\\+)\\S* \\*" + END; - public static final String ALLOC = "(.*precise klass .*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END; - public static final String ALLOC_OF = COMPOSITE_PREFIX + "(.*precise klass .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END; - public static final String ALLOC_ARRAY = "(.*precise klass \\[L.*\\R((.*(?i:mov|xor|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END; - public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "(.*precise klass \\[L.*" + IS_REPLACED + ";:.*\\R((.*(?i:mov|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END; + public static final String ALLOC = "(.*precise klass .*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END; + public static final String ALLOC_OF = COMPOSITE_PREFIX + "(.*precise klass .*" + IS_REPLACED + ":.*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_instance_Java" + END; + public static final String ALLOC_ARRAY = "(.*precise klass \\[L.*\\R((.*(?i:mov|mv|xor|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END; + public static final String ALLOC_ARRAY_OF = COMPOSITE_PREFIX + "(.*precise klass \\[L.*" + IS_REPLACED + ";:.*\\R((.*(?i:mov|mv|xorl|nop|spill).*|\\s*|.*LGHI.*)\\R)*.*(?i:call,static).*wrapper for: _new_array_Java" + END; - public static final String CHECKCAST_ARRAY = "(((?i:cmp|CLFI|CLR).*precise klass \\[.*;:|.*(?i:mov|or).*precise klass \\[.*;:.*\\R.*(cmp|CMP|CLR))" + END; - public static final String CHECKCAST_ARRAY_OF = COMPOSITE_PREFIX + "(((?i:cmp|CLFI|CLR).*precise klass \\[.*" + IS_REPLACED + ";:|.*(?i:mov|or).*precise klass \\[.*" + IS_REPLACED + ";:.*\\R.*(cmp|CMP|CLR))" + END; + public static final String CHECKCAST_ARRAY = "(((?i:cmp|CLFI|CLR).*precise klass \\[.*;:|.*(?i:mov|mv|or).*precise klass \\[.*;:.*\\R.*(cmp|CMP|CLR))" + END; + public static final String CHECKCAST_ARRAY_OF = COMPOSITE_PREFIX + "(((?i:cmp|CLFI|CLR).*precise klass \\[.*" + IS_REPLACED + ";:|.*(?i:mov|mv|or).*precise klass \\[.*" + IS_REPLACED + ";:.*\\R.*(cmp|CMP|CLR))" + END; // Does not work on s390 (a rule containing this regex will be skipped on s390). public static final String CHECKCAST_ARRAYCOPY = "(.*((?i:call_leaf_nofp,runtime)|CALL,\\s?runtime leaf nofp|BCTRL.*.leaf call).*checkcast_arraycopy.*" + END; From 735e1da18e33d1ecd1de12ac754f949595c85fe0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 2 Aug 2023 08:20:21 +0000 Subject: [PATCH 003/341] 8307766: Linux: Provide the option to override the timer slack Backport-of: 7173c3009e0999f13eaa4bee5eedee7326f9d124 --- src/hotspot/os/linux/globals_linux.hpp | 14 +- src/hotspot/os/linux/os_linux.cpp | 20 +++ .../jtreg/runtime/os/TestTimerSlack.java | 143 ++++++++++++++++++ 3 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/runtime/os/TestTimerSlack.java diff --git a/src/hotspot/os/linux/globals_linux.hpp b/src/hotspot/os/linux/globals_linux.hpp index da20aa66cde1b..30a47e373d6cb 100644 --- a/src/hotspot/os/linux/globals_linux.hpp +++ b/src/hotspot/os/linux/globals_linux.hpp @@ -86,7 +86,19 @@ "Use CPU_ALLOC code path in os::active_processor_count ") \ \ product(bool, DumpPerfMapAtExit, false, DIAGNOSTIC, \ - "Write map file for Linux perf tool at exit") + "Write map file for Linux perf tool at exit") \ + \ + product(intx, TimerSlack, -1, EXPERIMENTAL, \ + "Overrides the timer slack value to the given number of " \ + "nanoseconds. Lower value provides more accurate " \ + "high-precision timers, at the expense of (possibly) worse " \ + "power efficiency. In current Linux, 0 means using the " \ + "system-wide default, which would disable the override, but " \ + "VM would still print the current timer slack values. Use -1 "\ + "to disable both the override and the printouts." \ + "See prctl(PR_SET_TIMERSLACK) for more info.") \ + \ + // end of RUNTIME_OS_FLAGS diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 1bfdacbb2afef..99dd4c824201a 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -108,6 +108,7 @@ # include # include # include +# include #ifdef __GLIBC__ # include #endif @@ -913,6 +914,16 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, if (ret == 0) { log_info(os, thread)("Thread \"%s\" started (pthread id: " UINTX_FORMAT ", attributes: %s). ", thread->name(), (uintx) tid, os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); + + // Print current timer slack if override is enabled and timer slack value is available. + // Avoid calling prctl otherwise for extra safety. + if (TimerSlack >= 0) { + int slack = prctl(PR_GET_TIMERSLACK); + if (slack >= 0) { + log_info(os, thread)("Thread \"%s\" (pthread id: " UINTX_FORMAT ") timer slack: %dns", + thread->name(), (uintx) tid, slack); + } + } } else { log_warning(os, thread)("Failed to start thread \"%s\" - pthread_create failed (%s) for attributes: %s.", thread->name(), os::errno_name(ret), os::Posix::describe_pthread_attr(buf, sizeof(buf), &attr)); @@ -4684,6 +4695,15 @@ jint os::init_2(void) { FLAG_SET_DEFAULT(UseCodeCacheFlushing, false); } + // Override the timer slack value if needed. The adjustment for the main + // thread will establish the setting for child threads, which would be + // most threads in JDK/JVM. + if (TimerSlack >= 0) { + if (prctl(PR_SET_TIMERSLACK, TimerSlack) < 0) { + vm_exit_during_initialization("Setting timer slack failed: %s", os::strerror(errno)); + } + } + return JNI_OK; } diff --git a/test/hotspot/jtreg/runtime/os/TestTimerSlack.java b/test/hotspot/jtreg/runtime/os/TestTimerSlack.java new file mode 100644 index 0000000000000..86aece992b5d2 --- /dev/null +++ b/test/hotspot/jtreg/runtime/os/TestTimerSlack.java @@ -0,0 +1,143 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.regex.Pattern; +import java.util.regex.Matcher; + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary Check that timer slack options work + * @requires os.family == "linux" + * @requires vm.flagless + * @library /test/lib + * @run driver TestTimerSlack + */ +public class TestTimerSlack { + + public static void main(String[] args) throws Exception { + int defaultSlack; + + // Check the timer slack value is not printed by default + { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread", + "TestTimerSlack$TestMain"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + output.shouldNotContain("timer slack:"); + } + + // Check the timer slack value is not printed when explicitly disabled + { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread", + "-XX:+UnlockExperimentalVMOptions", + "-XX:TimerSlack=-1", + "TestTimerSlack$TestMain"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + output.shouldNotContain("timer slack:"); + } + + // Check the timer slack value is good when system-wide default is requested + { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+thread", + "-XX:+UnlockExperimentalVMOptions", + "-XX:TimerSlack=0", + "TestTimerSlack$TestMain"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + output.shouldContain("timer slack:"); + + defaultSlack = parseSlackValue(output); + + if (defaultSlack == 0) { + fail(output, "Default slack value (" + defaultSlack + ") is unexpected"); + } + } + + // 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", + "-XX:+UnlockExperimentalVMOptions", + "-XX:TimerSlack=" + slack, + "TestTimerSlack$TestMain"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + output.shouldContain("timer slack:"); + + int actualSlack = parseSlackValue(output); + if (actualSlack != slack) { + fail(output, "Actual slack value (" + actualSlack + ") is not the requested one (" + slack + ")"); + } + } + } + + static final Pattern EXTRACT_PATTERN = Pattern.compile("(.*)timer slack: ([0-9]+)ns(.*)"); + + public static int parseSlackValue(OutputAnalyzer output) { + Integer value = null; + for (String s : output.asLines()) { + Matcher m = EXTRACT_PATTERN.matcher(s); + if (m.matches()) { + Integer parsedValue = Integer.parseInt(m.group(2)); + if (value == null) { + value = parsedValue; + } else if (!value.equals(parsedValue)) { + fail(output, "Multiple timer slack values detected"); + } + } + } + if (value == null) { + fail(output, "No timer slack values detected"); + } + return value; + } + + private static void fail(OutputAnalyzer output, String msg) { + output.reportDiagnosticSummary(); + throw new IllegalStateException(msg); + } + + public static class TestMain { + static final int THREADS = 8; + + public static void main(String... args) throws Exception { + Thread[] ts = new Thread[THREADS]; + for (int c = 0; c < THREADS; c++) { + ts[c] = new Thread(); + ts[c].start(); + } + + for (int c = 0; c < THREADS; c++) { + ts[c].join(); + } + } + } + +} From 482f2241da4d5d60c74e493c77fe7d9d11b1e753 Mon Sep 17 00:00:00 2001 From: Sonia Zaldana Calles Date: Wed, 2 Aug 2023 11:00:22 +0000 Subject: [PATCH 004/341] 8273803: Zero: Handle "zero" variant in CommandLineOptionTest.java Backport-of: 2d13fb21af783ebbe3dd5c2632aea11347317026 --- test/lib/jdk/test/lib/cli/CommandLineOptionTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java index 7247d879412cb..b3b1b8a7e2caf 100644 --- a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java +++ b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java @@ -500,6 +500,8 @@ private static String getVMTypeOption() { return "-client"; } else if (Platform.isMinimal()) { return "-minimal"; + } else if (Platform.isZero()) { + return "-zero"; } throw new RuntimeException("Unknown VM mode."); } From a5cdc22db03ac72d6a1aad50fef0cf4f47c72408 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 8 Aug 2023 17:41:00 +0000 Subject: [PATCH 005/341] 8313576: GCC 7 reports compiler warning in bundled freetype 2.13.0 Backport-of: 8248e351d0bed263fb68d8468004a4286e6391af --- make/modules/java.desktop/lib/Awt2dLibraries.gmk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/make/modules/java.desktop/lib/Awt2dLibraries.gmk b/make/modules/java.desktop/lib/Awt2dLibraries.gmk index 03d6c9c20e58a..b9e84d322277f 100644 --- a/make/modules/java.desktop/lib/Awt2dLibraries.gmk +++ b/make/modules/java.desktop/lib/Awt2dLibraries.gmk @@ -416,6 +416,7 @@ else LIBFREETYPE_LIBS := -lfreetype endif + # gcc_ftobjs.c := maybe-uninitialized required for GCC 7 builds. $(eval $(call SetupJdkLibrary, BUILD_LIBFREETYPE, \ NAME := freetype, \ OPTIMIZATION := HIGHEST, \ @@ -424,6 +425,7 @@ else EXTRA_HEADER_DIRS := $(BUILD_LIBFREETYPE_HEADER_DIRS), \ DISABLED_WARNINGS_microsoft := 4018 4267 4244 4312 4819, \ DISABLED_WARNINGS_gcc := implicit-fallthrough cast-function-type bad-function-cast dangling-pointer stringop-overflow, \ + DISABLED_WARNINGS_gcc_ftobjs.c := maybe-uninitialized, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ )) From 6349de605cc5da32a6bf094243ba9e9f7a07a7b0 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Wed, 9 Aug 2023 13:18:40 +0000 Subject: [PATCH 006/341] 8289797: tools/launcher/I18NArgTest.java fails on Japanese Windows environment Backport-of: a11477ce259d6d2a053117a2300ebb171145cfde --- test/jdk/tools/launcher/I18NArgTest.java | 73 ++++++++++++++++-------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/test/jdk/tools/launcher/I18NArgTest.java b/test/jdk/tools/launcher/I18NArgTest.java index fa09736da2f73..aec0296bc5451 100644 --- a/test/jdk/tools/launcher/I18NArgTest.java +++ b/test/jdk/tools/launcher/I18NArgTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,8 @@ import java.io.IOException; import java.util.Map; import java.util.HashMap; +import java.util.HexFormat; +import java.nio.charset.StandardCharsets; public class I18NArgTest extends TestHelper { public static void main(String... args) throws IOException { @@ -66,21 +68,21 @@ static void execTest(int unicodeValue) { execTest("*" + unicodeStr + unicodeStr + "*", hexValue + hexValue); execTest("?" + unicodeStr + unicodeStr + "?", hexValue + hexValue); - execTest("\"" + unicodeStr + "a" + unicodeStr + "\"", hexValue + "61" + hexValue); - execTest("\\" + unicodeStr + "a" + unicodeStr + "\\", hexValue + "61" + hexValue); - execTest(" " + unicodeStr + "a" + unicodeStr + " ", hexValue + "61"+ hexValue); - execTest("'" + unicodeStr + "a" + unicodeStr + "'", hexValue + "61"+ hexValue); - execTest("\t" + unicodeStr + "a" + unicodeStr + "\t", hexValue + "61"+ hexValue); - execTest("*" + unicodeStr + "a" + unicodeStr + "*", hexValue + "61"+ hexValue); - execTest("?" + unicodeStr + "a" + unicodeStr + "?", hexValue + "61"+ hexValue); + execTest("\"" + unicodeStr + "a" + unicodeStr + "\"", hexValue + "0061" + hexValue); + execTest("\\" + unicodeStr + "a" + unicodeStr + "\\", hexValue + "0061" + hexValue); + execTest(" " + unicodeStr + "a" + unicodeStr + " ", hexValue + "0061"+ hexValue); + execTest("'" + unicodeStr + "a" + unicodeStr + "'", hexValue + "0061"+ hexValue); + execTest("\t" + unicodeStr + "a" + unicodeStr + "\t", hexValue + "0061"+ hexValue); + execTest("*" + unicodeStr + "a" + unicodeStr + "*", hexValue + "0061"+ hexValue); + execTest("?" + unicodeStr + "a" + unicodeStr + "?", hexValue + "0061"+ hexValue); - execTest("\"" + unicodeStr + "\u00b1" + unicodeStr + "\"", hexValue + "b1" + hexValue); - execTest("\\" + unicodeStr + "\u00b1" + unicodeStr + "\\", hexValue + "b1" + hexValue); - execTest(" " + unicodeStr + "\u00b1" + unicodeStr + " ", hexValue + "b1"+ hexValue); - execTest("'" + unicodeStr + "\u00b1" + unicodeStr + "'", hexValue + "b1"+ hexValue); - execTest("\t" + unicodeStr + "\u00b1" + unicodeStr + "\t", hexValue + "b1"+ hexValue); - execTest("*" + unicodeStr + "\u00b1" + unicodeStr + "*", hexValue + "b1"+ hexValue); - execTest("?" + unicodeStr + "\u00b1" + unicodeStr + "?", hexValue + "b1"+ hexValue); + execTest("\"" + unicodeStr + "\u00b1" + unicodeStr + "\"", hexValue + "00b1" + hexValue); + execTest("\\" + unicodeStr + "\u00b1" + unicodeStr + "\\", hexValue + "00b1" + hexValue); + execTest(" " + unicodeStr + "\u00b1" + unicodeStr + " ", hexValue + "00b1"+ hexValue); + execTest("'" + unicodeStr + "\u00b1" + unicodeStr + "'", hexValue + "00b1"+ hexValue); + execTest("\t" + unicodeStr + "\u00b1" + unicodeStr + "\t", hexValue + "00b1"+ hexValue); + execTest("*" + unicodeStr + "\u00b1" + unicodeStr + "*", hexValue + "00b1"+ hexValue); + execTest("?" + unicodeStr + "\u00b1" + unicodeStr + "?", hexValue + "00b1"+ hexValue); } static void execTest(String unicodeStr, String hexValue) { @@ -97,12 +99,21 @@ static void execTest(String unicodeStr, String hexValue) { // Test via JDK_JAVA_OPTIONS Map env = new HashMap<>(); - String cmd = "-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath() + - " -Dtest.classes=" + TEST_CLASSES_DIR.getAbsolutePath() + - " -cp " + TEST_CLASSES_DIR.getAbsolutePath() + - " I18NArgTest " + unicodeStr + " " + hexValue; - env.put("JDK_JAVA_OPTIONS", cmd); - tr = doExec(env, javaCmd); + String sysPropName = "foo.bar"; + // When pass "-Dfoo.bar=" via the JDK_JAVA_OPTIONS environment variable, + // we expect that system property value to be passed along to the main method with the + // correct encoding + // If contains space or tab, it should be enclosed with double quotes. + if (unicodeStr.contains(" ") || unicodeStr.contains("\t")) { + unicodeStr = "\"" + unicodeStr + "\""; + } + String jdkJavaOpts = "-D" + sysPropName + "=" + unicodeStr; + env.put("JDK_JAVA_OPTIONS", jdkJavaOpts); + tr = doExec(env,javaCmd, + "-Dtest.src=" + TEST_SOURCES_DIR.getAbsolutePath(), + "-Dtest.classes=" + TEST_CLASSES_DIR.getAbsolutePath(), + "-cp", TEST_CLASSES_DIR.getAbsolutePath(), + "I18NArgTest", unicodeStr, hexValue, sysPropName); System.out.println(tr.testOutput); if (!tr.isOK()) { System.err.println(tr); @@ -113,10 +124,7 @@ static void execTest(String unicodeStr, String hexValue) { static void testCharacters(String... args) { String input = args[0]; String expected = args[1]; - String hexValue = ""; - for (int i = 0; i < input.length(); i++) { - hexValue = hexValue.concat(Integer.toHexString((int)input.charAt(i))); - } + var hexValue = HexFormat.of().formatHex(input.getBytes(StandardCharsets.UTF_16)); System.out.println("input:" + input); System.out.println("expected:" + expected); System.out.println("obtained:" + hexValue); @@ -125,5 +133,20 @@ static void testCharacters(String... args) { "expected:" + expected + " obtained:" + hexValue; throw new RuntimeException(message); } + if (args.length == 3) { + // verify the value of the system property matches the expected value + String sysPropName = args[2]; + String sysPropVal = System.getProperty(sysPropName); + if (sysPropVal == null) { + throw new RuntimeException("Missing system property " + sysPropName); + } + var sysPropHexVal = HexFormat.of().formatHex(sysPropVal.getBytes(StandardCharsets.UTF_16)); + System.out.println("System property " + sysPropName + " computed hex value: " + + sysPropHexVal); + if (!sysPropHexVal.contains(expected)) { + throw new RuntimeException("Unexpected value in system property, expected " + + expected + ", but got " + sysPropHexVal); + } + } } } From 2f5a9527fee0f380b515d41200dbf6db421183a5 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Wed, 9 Aug 2023 13:19:12 +0000 Subject: [PATCH 007/341] 8195589: T6587786.java failed after JDK-8189997 Backport-of: 21b62fef335aa981a239415532fa8b804fb5676d --- test/langtools/ProblemList.txt | 1 - test/langtools/tools/javap/T6587786.java | 17 ++++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/langtools/ProblemList.txt b/test/langtools/ProblemList.txt index d9d8cfeeb9de8..f10e02e0d48c7 100644 --- a/test/langtools/ProblemList.txt +++ b/test/langtools/ProblemList.txt @@ -54,7 +54,6 @@ tools/javac/modules/SourceInSymlinkTest.java # javap tools/javap/output/RepeatingTypeAnnotations.java 8057687 generic-all emit correct byte code an attributes for type annotations -tools/javap/T6587786.java 8195589 generic-all T6587786.java failed after JDK-8189997 ########################################################################### # diff --git a/test/langtools/tools/javap/T6587786.java b/test/langtools/tools/javap/T6587786.java index 950ff20a46388..4cb1acf5b1f41 100644 --- a/test/langtools/tools/javap/T6587786.java +++ b/test/langtools/tools/javap/T6587786.java @@ -36,18 +36,21 @@ public static void main(String[] args) throws Exception { } public void run() throws IOException { - javap("com.sun.javadoc.Doc", "com.sun.crypto.provider.ai"); - javap("com.sun.crypto.provider.ai", "com.sun.javadoc.ClassDoc"); + javap("jdk.javadoc.doclet.Doclet", "java.util.List"); + javap("java.util.List", "jdk.javadoc.doclet.StandardDoclet"); } void javap(String... args) { StringWriter sw = new StringWriter(); PrintWriter out = new PrintWriter(sw); //sun.tools.javap.Main.entry(args); - int rc = com.sun.tools.javap.Main.run(args, out); - if (rc != 0) - throw new Error("javap failed. rc=" + rc); - out.close(); - System.out.println(sw.toString()); + try { + int rc = com.sun.tools.javap.Main.run(args, out); + if (rc != 0) + throw new Error("javap failed. rc=" + rc); + } finally { + out.close(); + System.out.println(sw.toString()); + } } } From 4786a004e7d1c9136f4ccaba6dc985a28934eb41 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Wed, 9 Aug 2023 13:19:48 +0000 Subject: [PATCH 008/341] 8267860: Off-by-one bug when searching arrays in AlpnGreaseTest Backport-of: 2adef6a1f84d478bb38b179795f08ffa43680e36 --- test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java b/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java index d3c656043a266..66efefeee4a4a 100644 --- a/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java +++ b/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,7 +83,7 @@ public class AlpnGreaseTest implements SSLContextTemplate { new String(greaseBytes, StandardCharsets.ISO_8859_1); private static void findGreaseInClientHello(byte[] bytes) throws Exception { - for (int i = 0; i < bytes.length - greaseBytes.length; i++) { + for (int i = 0; i < bytes.length - greaseBytes.length + 1; i++) { if (Arrays.equals(bytes, i, i + greaseBytes.length, greaseBytes, 0, greaseBytes.length)) { System.out.println("Found greaseBytes in ClientHello at: " + i); From 9c8731bddeff5c134d81c1d3f9c0f3dea43dde5f Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Wed, 9 Aug 2023 13:21:05 +0000 Subject: [PATCH 009/341] 8309095: Remove UTF-8 character from TaskbarPositionTest.java Backport-of: 07f2070411b3bff5608166ceae0e0bdbf155e7c2 --- test/jdk/javax/swing/Popup/TaskbarPositionTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/javax/swing/Popup/TaskbarPositionTest.java b/test/jdk/javax/swing/Popup/TaskbarPositionTest.java index 6a6b93a10808e..5378f61c96f77 100644 --- a/test/jdk/javax/swing/Popup/TaskbarPositionTest.java +++ b/test/jdk/javax/swing/Popup/TaskbarPositionTest.java @@ -61,7 +61,7 @@ * @key headful * @summary Tests the location of the heavy weight popup portion of JComboBox, * JMenu and JPopupMenu. - * The test uses Ctrl+Down Arrow (↓) which is a system shortcut on macOS, + * The test uses Ctrl+Down Arrow which is a system shortcut on macOS, * disable it in system settings, otherwise the test will fail * @library ../regtesthelpers * @library /test/lib From ec2abc2d82bf737258ae8ee0bba8ba6a15e1dabb Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Wed, 9 Aug 2023 14:32:41 +0000 Subject: [PATCH 010/341] 8302182: Update Public Suffix List to 88467c9 Backport-of: 01b85129116dd2cc762e518ac631305bd8511764 --- make/data/publicsuffixlist/VERSION | 4 +- .../publicsuffixlist/public_suffix_list.dat | 1596 ++++++++--------- src/java.base/share/legal/public_suffix.md | 2 +- .../util/RegisteredDomain/ParseNames.java | 4 +- .../security/util/RegisteredDomain/tests.dat | 8 + 5 files changed, 782 insertions(+), 832 deletions(-) diff --git a/make/data/publicsuffixlist/VERSION b/make/data/publicsuffixlist/VERSION index be9290a33fcd4..4ffc88dbd8332 100644 --- a/make/data/publicsuffixlist/VERSION +++ b/make/data/publicsuffixlist/VERSION @@ -1,2 +1,2 @@ -Github: https://raw.githubusercontent.com/publicsuffix/list/3c213aab32b3c014f171b1673d4ce9b5cd72bf1c/public_suffix_list.dat -Date: 2021-11-27 +Github: https://raw.githubusercontent.com/publicsuffix/list/88467c960d6cdad2ca1623e892e5e17506bc269f/public_suffix_list.dat +Date: 2023-04-14 diff --git a/make/data/publicsuffixlist/public_suffix_list.dat b/make/data/publicsuffixlist/public_suffix_list.dat index 5529554d82df5..d9f0c71dbb447 100644 --- a/make/data/publicsuffixlist/public_suffix_list.dat +++ b/make/data/publicsuffixlist/public_suffix_list.dat @@ -9,7 +9,7 @@ // ===BEGIN ICANN DOMAINS=== -// ac : https://en.wikipedia.org/wiki/.ac +// ac : http://nic.ac/rules.htm ac com.ac edu.ac @@ -22,8 +22,7 @@ org.ac ad nom.ad -// ae : https://en.wikipedia.org/wiki/.ae -// see also: "Domain Name Eligibility Policy" at http://www.aeda.ae/eng/aepolicy.php +// ae : https://tdra.gov.ae/en/aeda/ae-policies ae co.ae net.ae @@ -381,11 +380,29 @@ org.bi // biz : https://en.wikipedia.org/wiki/.biz biz -// bj : https://en.wikipedia.org/wiki/.bj +// bj : https://nic.bj/bj-suffixes.txt +// submitted by registry bj -asso.bj -barreau.bj -gouv.bj +africa.bj +agro.bj +architectes.bj +assur.bj +avocats.bj +co.bj +com.bj +eco.bj +econo.bj +edu.bj +info.bj +loisirs.bj +money.bj +net.bj +org.bj +ote.bj +resto.bj +restaurant.bj +tourism.bj +univ.bj // bm : http://www.bermudanic.bm/dnr-text.txt bm @@ -865,6 +882,7 @@ gov.cx // cy : http://www.nic.cy/ // Submitted by registry Panayiotou Fotia +// namespace policies URL https://www.nic.cy/portal//sites/default/files/symfonia_gia_eggrafi.pdf cy ac.cy biz.cy @@ -872,10 +890,9 @@ com.cy ekloges.cy gov.cy ltd.cy -name.cy +mil.cy net.cy org.cy -parliament.cy press.cy pro.cy tm.cy @@ -1034,8 +1051,7 @@ fm // fo : https://en.wikipedia.org/wiki/.fo fo -// fr : http://www.afnic.fr/ -// domaines descriptifs : https://www.afnic.fr/medias/documents/Cadre_legal/Afnic_Naming_Policy_12122016_VEN.pdf +// fr : https://www.afnic.fr/ https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf fr asso.fr com.fr @@ -1043,7 +1059,7 @@ gouv.fr nom.fr prd.fr tm.fr -// domaines sectoriels : https://www.afnic.fr/en/products-and-services/the-fr-tld/sector-based-fr-domains-4.html +// Former "domaines sectoriels", still registration suffixes aeroport.fr avocat.fr avoues.fr @@ -1316,7 +1332,9 @@ web.id ie gov.ie -// il : http://www.isoc.org.il/domains/ +// il : http://www.isoc.org.il/domains/ +// see also: https://en.isoc.org.il/il-cctld/registration-rules +// ISOC-IL (operated by .il Registry) il ac.il co.il @@ -1326,6 +1344,16 @@ k12.il muni.il net.il org.il +// xn--4dbrk0ce ("Israel", Hebrew) : IL +ישראל +// xn--4dbgdty6c.xn--4dbrk0ce. +אקדמיה.ישראל +// xn--5dbhl8d.xn--4dbrk0ce. +ישוב.ישראל +// xn--8dbq2a.xn--4dbrk0ce. +צהל.ישראל +// xn--hebda8b.xn--4dbrk0ce. +ממשל.ישראל // im : https://www.nic.im/ // Submitted by registry @@ -1341,22 +1369,51 @@ tt.im tv.im // in : https://en.wikipedia.org/wiki/.in -// see also: https://registry.in/Policies +// see also: https://registry.in/policies // Please note, that nic.in is not an official eTLD, but used by most // government institutions. in +5g.in +6g.in +ac.in +ai.in +am.in +bihar.in +biz.in +business.in +ca.in +cn.in co.in +com.in +coop.in +cs.in +delhi.in +dr.in +edu.in +er.in firm.in -net.in -org.in gen.in +gov.in +gujarat.in ind.in +info.in +int.in +internet.in +io.in +me.in +mil.in +net.in nic.in -ac.in -edu.in +org.in +pg.in +post.in +pro.in res.in -gov.in -mil.in +travel.in +tv.in +uk.in +up.in +us.in // info : https://en.wikipedia.org/wiki/.info info @@ -1366,7 +1423,7 @@ info int eu.int -// io : http://www.nic.io/rules.html +// io : http://www.nic.io/rules.htm // list of other 2nd level tlds ? io com.io @@ -3765,11 +3822,10 @@ org.kw // ky : http://www.icta.ky/da_ky_reg_dom.php // Confirmed by registry 2008-06-17 ky -edu.ky -gov.ky com.ky -org.ky +edu.ky net.ky +org.ky // kz : https://en.wikipedia.org/wiki/.kz // see also: http://www.nic.kz/rules/index.jsp @@ -4013,555 +4069,8 @@ ac.mu co.mu or.mu -// museum : http://about.museum/naming/ -// http://index.museum/ +// museum : https://welcome.museum/wp-content/uploads/2018/05/20180525-Registration-Policy-MUSEUM-EN_VF-2.pdf https://welcome.museum/buy-your-dot-museum-2/ museum -academy.museum -agriculture.museum -air.museum -airguard.museum -alabama.museum -alaska.museum -amber.museum -ambulance.museum -american.museum -americana.museum -americanantiques.museum -americanart.museum -amsterdam.museum -and.museum -annefrank.museum -anthro.museum -anthropology.museum -antiques.museum -aquarium.museum -arboretum.museum -archaeological.museum -archaeology.museum -architecture.museum -art.museum -artanddesign.museum -artcenter.museum -artdeco.museum -arteducation.museum -artgallery.museum -arts.museum -artsandcrafts.museum -asmatart.museum -assassination.museum -assisi.museum -association.museum -astronomy.museum -atlanta.museum -austin.museum -australia.museum -automotive.museum -aviation.museum -axis.museum -badajoz.museum -baghdad.museum -bahn.museum -bale.museum -baltimore.museum -barcelona.museum -baseball.museum -basel.museum -baths.museum -bauern.museum -beauxarts.museum -beeldengeluid.museum -bellevue.museum -bergbau.museum -berkeley.museum -berlin.museum -bern.museum -bible.museum -bilbao.museum -bill.museum -birdart.museum -birthplace.museum -bonn.museum -boston.museum -botanical.museum -botanicalgarden.museum -botanicgarden.museum -botany.museum -brandywinevalley.museum -brasil.museum -bristol.museum -british.museum -britishcolumbia.museum -broadcast.museum -brunel.museum -brussel.museum -brussels.museum -bruxelles.museum -building.museum -burghof.museum -bus.museum -bushey.museum -cadaques.museum -california.museum -cambridge.museum -can.museum -canada.museum -capebreton.museum -carrier.museum -cartoonart.museum -casadelamoneda.museum -castle.museum -castres.museum -celtic.museum -center.museum -chattanooga.museum -cheltenham.museum -chesapeakebay.museum -chicago.museum -children.museum -childrens.museum -childrensgarden.museum -chiropractic.museum -chocolate.museum -christiansburg.museum -cincinnati.museum -cinema.museum -circus.museum -civilisation.museum -civilization.museum -civilwar.museum -clinton.museum -clock.museum -coal.museum -coastaldefence.museum -cody.museum -coldwar.museum -collection.museum -colonialwilliamsburg.museum -coloradoplateau.museum -columbia.museum -columbus.museum -communication.museum -communications.museum -community.museum -computer.museum -computerhistory.museum -comunicações.museum -contemporary.museum -contemporaryart.museum -convent.museum -copenhagen.museum -corporation.museum -correios-e-telecomunicações.museum -corvette.museum -costume.museum -countryestate.museum -county.museum -crafts.museum -cranbrook.museum -creation.museum -cultural.museum -culturalcenter.museum -culture.museum -cyber.museum -cymru.museum -dali.museum -dallas.museum -database.museum -ddr.museum -decorativearts.museum -delaware.museum -delmenhorst.museum -denmark.museum -depot.museum -design.museum -detroit.museum -dinosaur.museum -discovery.museum -dolls.museum -donostia.museum -durham.museum -eastafrica.museum -eastcoast.museum -education.museum -educational.museum -egyptian.museum -eisenbahn.museum -elburg.museum -elvendrell.museum -embroidery.museum -encyclopedic.museum -england.museum -entomology.museum -environment.museum -environmentalconservation.museum -epilepsy.museum -essex.museum -estate.museum -ethnology.museum -exeter.museum -exhibition.museum -family.museum -farm.museum -farmequipment.museum -farmers.museum -farmstead.museum -field.museum -figueres.museum -filatelia.museum -film.museum -fineart.museum -finearts.museum -finland.museum -flanders.museum -florida.museum -force.museum -fortmissoula.museum -fortworth.museum -foundation.museum -francaise.museum -frankfurt.museum -franziskaner.museum -freemasonry.museum -freiburg.museum -fribourg.museum -frog.museum -fundacio.museum -furniture.museum -gallery.museum -garden.museum -gateway.museum -geelvinck.museum -gemological.museum -geology.museum -georgia.museum -giessen.museum -glas.museum -glass.museum -gorge.museum -grandrapids.museum -graz.museum -guernsey.museum -halloffame.museum -hamburg.museum -handson.museum -harvestcelebration.museum -hawaii.museum -health.museum -heimatunduhren.museum -hellas.museum -helsinki.museum -hembygdsforbund.museum -heritage.museum -histoire.museum -historical.museum -historicalsociety.museum -historichouses.museum -historisch.museum -historisches.museum -history.museum -historyofscience.museum -horology.museum -house.museum -humanities.museum -illustration.museum -imageandsound.museum -indian.museum -indiana.museum -indianapolis.museum -indianmarket.museum -intelligence.museum -interactive.museum -iraq.museum -iron.museum -isleofman.museum -jamison.museum -jefferson.museum -jerusalem.museum -jewelry.museum -jewish.museum -jewishart.museum -jfk.museum -journalism.museum -judaica.museum -judygarland.museum -juedisches.museum -juif.museum -karate.museum -karikatur.museum -kids.museum -koebenhavn.museum -koeln.museum -kunst.museum -kunstsammlung.museum -kunstunddesign.museum -labor.museum -labour.museum -lajolla.museum -lancashire.museum -landes.museum -lans.museum -läns.museum -larsson.museum -lewismiller.museum -lincoln.museum -linz.museum -living.museum -livinghistory.museum -localhistory.museum -london.museum -losangeles.museum -louvre.museum -loyalist.museum -lucerne.museum -luxembourg.museum -luzern.museum -mad.museum -madrid.museum -mallorca.museum -manchester.museum -mansion.museum -mansions.museum -manx.museum -marburg.museum -maritime.museum -maritimo.museum -maryland.museum -marylhurst.museum -media.museum -medical.museum -medizinhistorisches.museum -meeres.museum -memorial.museum -mesaverde.museum -michigan.museum -midatlantic.museum -military.museum -mill.museum -miners.museum -mining.museum -minnesota.museum -missile.museum -missoula.museum -modern.museum -moma.museum -money.museum -monmouth.museum -monticello.museum -montreal.museum -moscow.museum -motorcycle.museum -muenchen.museum -muenster.museum -mulhouse.museum -muncie.museum -museet.museum -museumcenter.museum -museumvereniging.museum -music.museum -national.museum -nationalfirearms.museum -nationalheritage.museum -nativeamerican.museum -naturalhistory.museum -naturalhistorymuseum.museum -naturalsciences.museum -nature.museum -naturhistorisches.museum -natuurwetenschappen.museum -naumburg.museum -naval.museum -nebraska.museum -neues.museum -newhampshire.museum -newjersey.museum -newmexico.museum -newport.museum -newspaper.museum -newyork.museum -niepce.museum -norfolk.museum -north.museum -nrw.museum -nyc.museum -nyny.museum -oceanographic.museum -oceanographique.museum -omaha.museum -online.museum -ontario.museum -openair.museum -oregon.museum -oregontrail.museum -otago.museum -oxford.museum -pacific.museum -paderborn.museum -palace.museum -paleo.museum -palmsprings.museum -panama.museum -paris.museum -pasadena.museum -pharmacy.museum -philadelphia.museum -philadelphiaarea.museum -philately.museum -phoenix.museum -photography.museum -pilots.museum -pittsburgh.museum -planetarium.museum -plantation.museum -plants.museum -plaza.museum -portal.museum -portland.museum -portlligat.museum -posts-and-telecommunications.museum -preservation.museum -presidio.museum -press.museum -project.museum -public.museum -pubol.museum -quebec.museum -railroad.museum -railway.museum -research.museum -resistance.museum -riodejaneiro.museum -rochester.museum -rockart.museum -roma.museum -russia.museum -saintlouis.museum -salem.museum -salvadordali.museum -salzburg.museum -sandiego.museum -sanfrancisco.museum -santabarbara.museum -santacruz.museum -santafe.museum -saskatchewan.museum -satx.museum -savannahga.museum -schlesisches.museum -schoenbrunn.museum -schokoladen.museum -school.museum -schweiz.museum -science.museum -scienceandhistory.museum -scienceandindustry.museum -sciencecenter.museum -sciencecenters.museum -science-fiction.museum -sciencehistory.museum -sciences.museum -sciencesnaturelles.museum -scotland.museum -seaport.museum -settlement.museum -settlers.museum -shell.museum -sherbrooke.museum -sibenik.museum -silk.museum -ski.museum -skole.museum -society.museum -sologne.museum -soundandvision.museum -southcarolina.museum -southwest.museum -space.museum -spy.museum -square.museum -stadt.museum -stalbans.museum -starnberg.museum -state.museum -stateofdelaware.museum -station.museum -steam.museum -steiermark.museum -stjohn.museum -stockholm.museum -stpetersburg.museum -stuttgart.museum -suisse.museum -surgeonshall.museum -surrey.museum -svizzera.museum -sweden.museum -sydney.museum -tank.museum -tcm.museum -technology.museum -telekommunikation.museum -television.museum -texas.museum -textile.museum -theater.museum -time.museum -timekeeping.museum -topology.museum -torino.museum -touch.museum -town.museum -transport.museum -tree.museum -trolley.museum -trust.museum -trustee.museum -uhren.museum -ulm.museum -undersea.museum -university.museum -usa.museum -usantiques.museum -usarts.museum -uscountryestate.museum -usculture.museum -usdecorativearts.museum -usgarden.museum -ushistory.museum -ushuaia.museum -uslivinghistory.museum -utah.museum -uvic.museum -valley.museum -vantaa.museum -versailles.museum -viking.museum -village.museum -virginia.museum -virtual.museum -virtuel.museum -vlaanderen.museum -volkenkunde.museum -wales.museum -wallonie.museum -war.museum -washingtondc.museum -watchandclock.museum -watch-and-clock.museum -western.museum -westfalen.museum -whaling.museum -wildlife.museum -williamsburg.museum -windmill.museum -workshop.museum -york.museum -yorkshire.museum -yosemite.museum -youth.museum -zoological.museum -zoology.museum -ירושלים.museum -иком.museum // mv : https://en.wikipedia.org/wiki/.mv // "mv" included because, contra Wikipedia, google.mv exists. @@ -5804,7 +5313,7 @@ zarow.pl zgora.pl zgorzelec.pl -// pm : http://www.afnic.fr/medias/documents/AFNIC-naming-policy2012.pdf +// pm : https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf pm // pn : http://www.government.pn/PnRegistry/policies.htm @@ -5902,7 +5411,7 @@ net.qa org.qa sch.qa -// re : http://www.afnic.re/obtenir/chartes/nommage-re/annexe-descriptifs +// re : https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf re asso.re com.re @@ -6037,7 +5546,7 @@ gov.sg edu.sg per.sg -// sh : http://www.nic.sh/registrar.html +// sh : http://nic.sh/rules.htm sh com.sh net.sh @@ -6159,7 +5668,7 @@ td // http://www.telnic.org/ tel -// tf : https://en.wikipedia.org/wiki/.tf +// tf : https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf tf // tg : https://en.wikipedia.org/wiki/.tg @@ -6778,7 +6287,7 @@ edu.vu net.vu org.vu -// wf : http://www.afnic.fr/medias/documents/AFNIC-naming-policy2012.pdf +// wf : https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf wf // ws : https://en.wikipedia.org/wiki/.ws @@ -6790,7 +6299,7 @@ org.ws gov.ws edu.ws -// yt : http://www.afnic.fr/medias/documents/AFNIC-naming-policy2012.pdf +// yt : https://www.afnic.fr/wp-media/uploads/2022/12/afnic-naming-policy-2023-01-01.pdf yt // IDN ccTLDs @@ -7132,7 +6641,7 @@ org.zw // newGTLDs -// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2021-11-13T15:12:42Z +// List of new gTLDs imported from https://www.icann.org/resources/registries/gtlds/v2/gtlds.json on 2023-04-14T15:13:16Z // This list is auto-generated, don't edit it manually. // aaa : 2015-02-26 American Automobile Association, Inc. aaa @@ -7182,9 +6691,6 @@ aco // actor : 2013-12-12 Dog Beach, LLC actor -// adac : 2015-07-16 Allgemeiner Deutscher Automobil-Club e.V. (ADAC) -adac - // ads : 2014-12-04 Charleston Road Registry Inc. ads @@ -7197,9 +6703,6 @@ aeg // aetna : 2015-05-21 Aetna Life Insurance Company aetna -// afamilycompany : 2015-07-23 Johnson Shareholdings, Inc. -afamilycompany - // afl : 2014-10-02 Australian Football League afl @@ -7305,7 +6808,7 @@ arab // aramco : 2014-11-20 Aramco Services Company aramco -// archi : 2014-02-06 Afilias Limited +// archi : 2014-02-06 Identity Digital Limited archi // army : 2014-03-06 Dog Beach, LLC @@ -7338,7 +6841,7 @@ audi // audible : 2015-06-25 Amazon Registry Services, Inc. audible -// audio : 2014-03-20 UNR Corp. +// audio : 2014-03-20 XYZ.COM LLC audio // auspost : 2015-08-13 Australian Postal Corporation @@ -7353,7 +6856,7 @@ auto // autos : 2014-01-09 XYZ.COM LLC autos -// avianca : 2015-01-08 Avianca Holdings S.A. +// avianca : 2015-01-08 Avianca Inc. avianca // aws : 2015-06-25 AWS Registry LLC @@ -7449,7 +6952,7 @@ best // bestbuy : 2015-07-31 BBY Solutions, Inc. bestbuy -// bet : 2015-05-07 Afilias Limited +// bet : 2015-05-07 Identity Digital Limited bet // bharti : 2014-01-09 Bharti Enterprises (Holding) Private Limited @@ -7470,13 +6973,13 @@ bing // bingo : 2014-12-04 Binky Moon, LLC bingo -// bio : 2014-03-06 Afilias Limited +// bio : 2014-03-06 Identity Digital Limited bio -// black : 2014-01-16 Afilias Limited +// black : 2014-01-16 Identity Digital Limited black -// blackfriday : 2014-01-16 UNR Corp. +// blackfriday : 2014-01-16 Registry Services, LLC blackfriday // blockbuster : 2015-07-30 Dish DBS Corporation @@ -7488,7 +6991,7 @@ blog // bloomberg : 2014-07-17 Bloomberg IP Holdings LLC bloomberg -// blue : 2013-11-07 Afilias Limited +// blue : 2013-11-07 Identity Digital Limited blue // bms : 2014-10-30 Bristol-Myers Squibb Company @@ -7530,7 +7033,7 @@ bosch // bostik : 2015-05-28 Bostik SA bostik -// boston : 2015-12-10 Boston TLD Management, LLC +// boston : 2015-12-10 Registry Services, LLC boston // bot : 2014-12-18 Amazon Registry Services, Inc. @@ -7560,12 +7063,6 @@ brother // brussels : 2014-02-06 DNS.be vzw brussels -// budapest : 2013-11-21 Minds + Machines Group Limited -budapest - -// bugatti : 2015-07-23 Bugatti International SA -bugatti - // build : 2013-11-07 Plan Bee LLC build @@ -7599,7 +7096,7 @@ call // calvinklein : 2015-07-30 PVH gTLD Holdings LLC calvinklein -// cam : 2016-04-21 AC Webconnecting Holding B.V. +// cam : 2016-04-21 Cam Connecting SARL cam // camera : 2013-08-27 Binky Moon, LLC @@ -7608,9 +7105,6 @@ camera // camp : 2013-11-07 Binky Moon, LLC camp -// cancerresearch : 2014-05-15 Australian Cancer Research Foundation -cancerresearch - // canon : 2014-09-12 Canon Inc. canon @@ -7647,7 +7141,7 @@ cars // casa : 2013-11-21 Registry Services, LLC casa -// case : 2015-09-03 Helium TLDs Ltd +// case : 2015-09-03 Digity, LLC case // cash : 2014-03-06 Binky Moon, LLC @@ -7695,7 +7189,7 @@ chanel // channel : 2014-05-08 Charleston Road Registry Inc. channel -// charity : 2018-04-11 Binky Moon, LLC +// charity : 2018-04-11 Public Interest Registry charity // chase : 2015-04-30 JPMorgan Chase Bank, National Association @@ -7710,7 +7204,7 @@ cheap // chintai : 2015-06-11 CHINTAI Corporation chintai -// christmas : 2013-11-21 UNR Corp. +// christmas : 2013-11-21 XYZ.COM LLC christmas // chrome : 2014-07-24 Charleston Road Registry Inc. @@ -7749,7 +7243,7 @@ claims // cleaning : 2013-12-05 Binky Moon, LLC cleaning -// click : 2014-06-05 UNR Corp. +// click : 2014-06-05 Internet Naming Company LLC click // clinic : 2014-03-20 Binky Moon, LLC @@ -7833,7 +7327,7 @@ cool // corsica : 2014-09-25 Collectivité de Corse corsica -// country : 2013-12-19 DotCountry LLC +// country : 2013-12-19 Internet Naming Company LLC country // coupon : 2015-02-26 Amazon Registry Services, Inc. @@ -7842,7 +7336,7 @@ coupon // coupons : 2015-03-26 Binky Moon, LLC coupons -// courses : 2014-12-04 OPEN UNIVERSITIES AUSTRALIA PTY LTD +// courses : 2014-12-04 Registry Services, LLC courses // cpa : 2019-06-10 American Institute of Certified Public Accountants @@ -7872,9 +7366,6 @@ cruise // cruises : 2013-12-05 Binky Moon, LLC cruises -// csc : 2014-09-25 Alliance-One Services, Inc. -csc - // cuisinella : 2014-04-03 SCHMIDT GROUPE S.A.S. cuisinella @@ -7962,7 +7453,7 @@ dhl // diamonds : 2013-09-22 Binky Moon, LLC diamonds -// diet : 2014-06-26 UNR Corp. +// diet : 2014-06-26 XYZ.COM LLC diet // digital : 2014-03-06 Binky Moon, LLC @@ -8016,9 +7507,6 @@ dtv // dubai : 2015-01-01 Dubai Smart Government Department dubai -// duck : 2015-07-23 Johnson Shareholdings, Inc. -duck - // dunlop : 2015-07-02 The Goodyear Tire & Rubber Company dunlop @@ -8034,7 +7522,7 @@ dvag // dvr : 2016-05-26 DISH Technologies L.L.C. dvr -// earth : 2014-12-04 Interlink Co., Ltd. +// earth : 2014-12-04 Interlink Systems Innovation Institute K.K. earth // eat : 2014-01-23 Charleston Road Registry Inc. @@ -8211,7 +7699,7 @@ flir // florist : 2013-11-07 Binky Moon, LLC florist -// flowers : 2014-10-09 UNR Corp. +// flowers : 2014-10-09 XYZ.COM LLC flowers // fly : 2014-05-08 Charleston Road Registry Inc. @@ -8241,7 +7729,7 @@ forsale // forum : 2015-04-02 Fegistry, LLC forum -// foundation : 2013-12-05 Binky Moon, LLC +// foundation : 2013-12-05 Public Interest Registry foundation // fox : 2015-09-11 FOX Registry, LLC @@ -8298,7 +7786,7 @@ gallo // gallup : 2015-02-19 Gallup, Inc. gallup -// game : 2015-05-28 UNR Corp. +// game : 2015-05-28 XYZ.COM LLC game // games : 2015-05-28 Dog Beach, LLC @@ -8322,7 +7810,7 @@ gdn // gea : 2014-12-04 GEA Group Aktiengesellschaft gea -// gent : 2014-01-23 COMBELL NV +// gent : 2014-01-23 Easyhost BV gent // genting : 2015-03-12 Resorts World Inc Pte. Ltd. @@ -8340,22 +7828,19 @@ gift // gifts : 2014-07-03 Binky Moon, LLC gifts -// gives : 2014-03-06 Dog Beach, LLC +// gives : 2014-03-06 Public Interest Registry gives -// giving : 2014-11-13 Giving Limited +// giving : 2014-11-13 Public Interest Registry giving -// glade : 2015-07-23 Johnson Shareholdings, Inc. -glade - // glass : 2013-11-07 Binky Moon, LLC glass // gle : 2014-07-24 Charleston Road Registry Inc. gle -// global : 2014-04-17 Dot Global Domain Registry Limited +// global : 2014-04-17 Identity Digital Limited global // globo : 2013-12-19 Globo Comunicação e Participações S.A @@ -8412,7 +7897,7 @@ graphics // gratis : 2014-03-20 Binky Moon, LLC gratis -// green : 2014-05-08 Afilias Limited +// green : 2014-05-08 Identity Digital Limited green // gripe : 2014-03-06 Binky Moon, LLC @@ -8436,7 +7921,7 @@ guge // guide : 2013-09-13 Binky Moon, LLC guide -// guitars : 2013-11-14 UNR Corp. +// guitars : 2013-11-14 XYZ.COM LLC guitars // guru : 2013-08-27 Binky Moon, LLC @@ -8469,7 +7954,7 @@ health // healthcare : 2014-06-12 Binky Moon, LLC healthcare -// help : 2014-06-26 UNR Corp. +// help : 2014-06-26 Innovation service Limited help // helsinki : 2015-02-05 City of Helsinki @@ -8484,7 +7969,7 @@ hermes // hgtv : 2015-07-02 Lifestyle Domain Holdings, Inc. hgtv -// hiphop : 2014-03-06 UNR Corp. +// hiphop : 2014-03-06 Dot Hip Hop, LLC hiphop // hisamitsu : 2015-07-16 Hisamitsu Pharmaceutical Co.,Inc. @@ -8493,7 +7978,7 @@ hisamitsu // hitachi : 2014-10-31 Hitachi, Ltd. hitachi -// hiv : 2014-03-13 UNR Corp. +// hiv : 2014-03-13 Internet Naming Company LLC hiv // hkt : 2015-05-14 PCCW-HKT DataCom Services Limited @@ -8532,7 +8017,7 @@ hospital // host : 2014-04-17 Radix FZC host -// hosting : 2014-05-29 UNR Corp. +// hosting : 2014-05-29 XYZ.COM LLC hosting // hot : 2015-08-27 Amazon Registry Services, Inc. @@ -8697,7 +8182,7 @@ jpmorgan // jprs : 2014-09-18 Japan Registry Services Co., Ltd. jprs -// juegos : 2014-03-20 UNR Corp. +// juegos : 2014-03-20 Internet Naming Company LLC juegos // juniper : 2015-07-30 JUNIPER NETWORKS, INC. @@ -8727,7 +8212,7 @@ kia // kids : 2021-08-13 DotKids Foundation Limited kids -// kim : 2013-09-23 Afilias Limited +// kim : 2013-09-23 Identity Digital Limited kim // kinder : 2014-11-07 Ferrero Trading Lux S.A. @@ -8796,7 +8281,7 @@ lanxess // lasalle : 2015-04-02 Jones Lang LaSalle Incorporated lasalle -// lat : 2014-10-16 ECOM-LAC Federaciòn de Latinoamèrica y el Caribe para Internet y el Comercio Electrònico +// lat : 2014-10-16 XYZ.COM LLC lat // latino : 2015-07-30 Dish DBS Corporation @@ -8832,7 +8317,7 @@ lego // lexus : 2015-04-23 TOYOTA MOTOR CORPORATION lexus -// lgbt : 2014-05-08 Afilias Limited +// lgbt : 2014-05-08 Identity Digital Limited lgbt // lidl : 2014-09-18 Schwarz Domains und Services GmbH & Co. KG @@ -8865,10 +8350,7 @@ limo // lincoln : 2014-11-13 Ford Motor Company lincoln -// linde : 2014-12-04 Linde Aktiengesellschaft -linde - -// link : 2013-11-14 UNR Corp. +// link : 2013-11-14 Nova Registry Ltd link // lipsy : 2015-06-25 Lipsy Ltd @@ -8880,13 +8362,10 @@ live // living : 2015-07-30 Lifestyle Domain Holdings, Inc. living -// lixil : 2015-03-19 LIXIL Group Corporation -lixil - -// llc : 2017-12-14 Afilias Limited +// llc : 2017-12-14 Identity Digital Limited llc -// llp : 2019-08-26 UNR Corp. +// llp : 2019-08-26 Intercap Registry Inc. llp // loan : 2014-11-20 dot Loan Limited @@ -8901,10 +8380,7 @@ locker // locus : 2015-06-25 Locus Analytics LLC locus -// loft : 2015-07-30 Annco, Inc. -loft - -// lol : 2015-01-30 UNR Corp. +// lol : 2015-01-30 XYZ.COM LLC lol // london : 2013-11-14 Dot London Domains Limited @@ -8913,7 +8389,7 @@ london // lotte : 2014-11-07 Lotte Holdings Co., Ltd. lotte -// lotto : 2014-04-10 Afilias Limited +// lotto : 2014-04-10 Identity Digital Limited lotto // love : 2014-12-22 Merchant Law Group LLP @@ -8940,9 +8416,6 @@ luxe // luxury : 2013-10-17 Luxury Partners, LLC luxury -// macys : 2015-07-31 Macys, Inc. -macys - // madrid : 2014-05-01 Comunidad de Madrid madrid @@ -9021,7 +8494,7 @@ menu // merckmsd : 2016-07-14 MSD Registry Holdings, Inc. merckmsd -// miami : 2013-12-19 Minds + Machines Group Limited +// miami : 2013-12-19 Registry Services, LLC miami // microsoft : 2014-12-18 Microsoft Corporation @@ -9054,13 +8527,13 @@ mobile // moda : 2013-11-07 Dog Beach, LLC moda -// moe : 2013-11-13 Interlink Co., Ltd. +// moe : 2013-11-13 Interlink Systems Innovation Institute K.K. moe // moi : 2014-12-18 Amazon Registry Services, Inc. moi -// mom : 2015-04-16 UNR Corp. +// mom : 2015-04-16 XYZ.COM LLC mom // monash : 2013-09-30 Monash University @@ -9216,9 +8689,6 @@ obi // observer : 2015-04-30 Dog Beach, LLC observer -// off : 2015-07-23 Johnson Shareholdings, Inc. -off - // office : 2015-03-12 Microsoft Corporation office @@ -9264,7 +8734,7 @@ oracle // orange : 2015-03-12 Orange Brand Services Limited orange -// organic : 2014-03-27 Afilias Limited +// organic : 2014-03-27 Identity Digital Limited organic // origins : 2015-10-01 The Estée Lauder Companies Inc. @@ -9285,7 +8755,7 @@ ovh // page : 2014-12-04 Charleston Road Registry Inc. page -// panasonic : 2015-07-30 Panasonic Corporation +// panasonic : 2015-07-30 Panasonic Holdings Corporation panasonic // paris : 2014-01-30 City of Paris @@ -9312,7 +8782,7 @@ pay // pccw : 2015-05-14 PCCW Enterprises Limited pccw -// pet : 2015-05-07 Afilias Limited +// pet : 2015-05-07 Identity Digital Limited pet // pfizer : 2015-09-11 Pfizer Inc. @@ -9330,7 +8800,7 @@ philips // phone : 2016-06-02 Dish DBS Corporation phone -// photo : 2013-11-14 UNR Corp. +// photo : 2013-11-14 Registry Services, LLC photo // photography : 2013-09-20 Binky Moon, LLC @@ -9342,7 +8812,7 @@ photos // physio : 2014-05-01 PhysBiz Pty Ltd physio -// pics : 2013-11-14 UNR Corp. +// pics : 2013-11-14 XYZ.COM LLC pics // pictet : 2014-06-26 Pictet Europe S.A. @@ -9360,7 +8830,7 @@ pin // ping : 2015-06-11 Ping Registry Provider, Inc. ping -// pink : 2013-10-01 Afilias Limited +// pink : 2013-10-01 Identity Digital Limited pink // pioneer : 2015-07-16 Pioneer Corporation @@ -9390,7 +8860,7 @@ pnc // pohl : 2014-06-23 Deutsche Vermögensberatung Aktiengesellschaft DVAG pohl -// poker : 2014-07-03 Afilias Limited +// poker : 2014-07-03 Identity Digital Limited poker // politie : 2015-08-20 Politie Nederland @@ -9423,13 +8893,13 @@ prof // progressive : 2015-07-23 Progressive Casualty Insurance Company progressive -// promo : 2014-12-18 Afilias Limited +// promo : 2014-12-18 Identity Digital Limited promo // properties : 2013-12-05 Binky Moon, LLC properties -// property : 2014-05-22 UNR Corp. +// property : 2014-05-22 Internet Naming Company LLC property // protection : 2015-04-23 XYZ.COM LLC @@ -9447,7 +8917,7 @@ pub // pwc : 2015-10-29 PricewaterhouseCoopers LLP pwc -// qpon : 2013-11-14 dotCOOL, Inc. +// qpon : 2013-11-14 dotQPON LLC qpon // quebec : 2013-12-19 PointQuébec Inc @@ -9462,9 +8932,6 @@ racing // radio : 2016-07-21 European Broadcasting Union (EBU) radio -// raid : 2015-07-23 Johnson Shareholdings, Inc. -raid - // read : 2014-12-18 Amazon Registry Services, Inc. read @@ -9480,7 +8947,7 @@ realty // recipes : 2013-10-17 Binky Moon, LLC recipes -// red : 2013-11-07 Afilias Limited +// red : 2013-11-07 Identity Digital Limited red // redstone : 2014-10-31 Redstone Haute Couture Co., Ltd. @@ -9576,7 +9043,7 @@ rsvp // rugby : 2016-12-15 World Rugby Strategic Developments Limited rugby -// ruhr : 2013-10-02 regiodot GmbH & Co. KG +// ruhr : 2013-10-02 dotSaarland GmbH ruhr // run : 2015-03-19 Binky Moon, LLC @@ -9669,9 +9136,6 @@ schwarz // science : 2014-09-11 dot Science Limited science -// scjohnson : 2015-07-23 Johnson Shareholdings, Inc. -scjohnson - // scot : 2014-01-23 Dot Scot Registry Limited scot @@ -9699,9 +9163,6 @@ sener // services : 2014-02-27 Binky Moon, LLC services -// ses : 2015-07-23 SES -ses - // seven : 2015-08-06 Seven West Media Ltd seven @@ -9711,7 +9172,7 @@ sew // sex : 2014-11-13 ICM Registry SX LLC sex -// sexy : 2013-09-11 UNR Corp. +// sexy : 2013-09-11 Internet Naming Company LLC sexy // sfr : 2015-08-13 Societe Francaise du Radiotelephone - SFR @@ -9732,7 +9193,7 @@ shell // shia : 2014-09-04 Asia Green IT System Bilgisayar San. ve Tic. Ltd. Sti. shia -// shiksha : 2013-11-14 Afilias Limited +// shiksha : 2013-11-14 Identity Digital Limited shiksha // shoes : 2013-10-02 Binky Moon, LLC @@ -9765,7 +9226,7 @@ singles // site : 2015-01-15 Radix FZC site -// ski : 2015-04-09 Afilias Limited +// ski : 2015-04-09 Identity Digital Limited ski // skin : 2015-01-15 XYZ.COM LLC @@ -9786,7 +9247,7 @@ smart // smile : 2014-12-18 Amazon Registry Services, Inc. smile -// sncf : 2015-02-19 Société Nationale des Chemins de fer Francais S N C F +// sncf : 2015-02-19 Société Nationale SNCF sncf // soccer : 2015-03-26 Binky Moon, LLC @@ -9870,7 +9331,7 @@ stream // studio : 2015-02-11 Dog Beach, LLC studio -// study : 2014-12-11 OPEN UNIVERSITIES AUSTRALIA PTY LTD +// study : 2014-12-11 Registry Services, LLC study // style : 2014-12-04 Binky Moon, LLC @@ -9930,7 +9391,7 @@ tatamotors // tatar : 2014-04-24 Limited Liability Company "Coordination Center of Regional Domain of Tatarstan Republic" tatar -// tattoo : 2013-08-30 UNR Corp. +// tattoo : 2013-08-30 Top Level Design, LLC tattoo // tax : 2014-03-20 Binky Moon, LLC @@ -10023,7 +9484,7 @@ toray // toshiba : 2014-04-10 TOSHIBA Corporation toshiba -// total : 2015-08-06 Total SA +// total : 2015-08-06 TotalEnergies SE total // tours : 2015-01-22 Binky Moon, LLC @@ -10059,7 +9520,7 @@ travelers // travelersinsurance : 2015-03-26 Travelers TLD, LLC travelersinsurance -// trust : 2014-10-16 UNR Corp. +// trust : 2014-10-16 Internet Naming Company LLC trust // trv : 2015-03-26 Travelers TLD, LLC @@ -10206,7 +9667,7 @@ wanggou // watch : 2013-11-14 Binky Moon, LLC watch -// watches : 2014-12-22 Afilias Limited +// watches : 2014-12-22 Identity Digital Limited watches // weather : 2015-01-08 International Business Machines Corporation @@ -10341,7 +9802,7 @@ xin // xn--5tzm5g : 2014-12-22 Global Website TLD Asia Limited 网站 -// xn--6frz82g : 2013-09-23 Afilias Limited +// xn--6frz82g : 2013-09-23 Identity Digital Limited 移动 // xn--6qq986b3xl : 2013-09-13 Tycoon Treasure Limited @@ -10458,9 +9919,6 @@ xin // xn--jlq480n2rg : 2019-12-19 Amazon Registry Services, Inc. 亚马逊 -// xn--jlq61u9w7b : 2015-01-08 Nokia Corporation -诺基亚 - // xn--jvr189m : 2015-02-26 Amazon Registry Services, Inc. 食品 @@ -10648,6 +10106,14 @@ graphox.us // Submitted by accesso Team *.devcdnaccesso.com +// Acorn Labs : https://acorn.io +// Submitted by Craig Jellick +*.on-acorn.io + +// ActiveTrail: https://www.activetrail.biz/ +// Submitted by Ofer Kalaora +activetrail.biz + // Adobe : https://www.adobe.com/ // Submitted by Ian Boston and Lars Trieloff adobeaemcloud.com @@ -10657,10 +10123,43 @@ adobeaemcloud.net hlx.page hlx3.page +// Adobe Developer Platform : https://developer.adobe.com +// Submitted by Jesse MacFadyen +adobeio-static.net +adobeioruntime.net + // Agnat sp. z o.o. : https://domena.pl // Submitted by Przemyslaw Plewa beep.pl +// Airkit : https://www.airkit.com/ +// Submitted by Grant Cooksey +airkitapps.com +airkitapps-au.com +airkitapps.eu + +// Aiven: https://aiven.io/ +// Submitted by Etienne Stalmans +aivencloud.com + +// Akamai : https://www.akamai.com/ +// Submitted by Akamai Team +akadns.net +akamai.net +akamai-staging.net +akamaiedge.net +akamaiedge-staging.net +akamaihd.net +akamaihd-staging.net +akamaiorigin.net +akamaiorigin-staging.net +akamaized.net +akamaized-staging.net +edgekey.net +edgekey-staging.net +edgesuite.net +edgesuite-staging.net + // alboto.ca : http://alboto.ca // Submitted by Anton Avramov barsy.ca @@ -10682,19 +10181,134 @@ altervista.org // Submitted by Cyril alwaysdata.net -// Amazon CloudFront : https://aws.amazon.com/cloudfront/ +// Amaze Software : https://amaze.co +// Submitted by Domain Admin +myamaze.net + +// Amazon : https://www.amazon.com/ +// Submitted by AWS Security +// Subsections of Amazon/subsidiaries will appear until "concludes" tag + +// Amazon CloudFront // Submitted by Donavan Miller +// Reference: 54144616-fd49-4435-8535-19c6a601bdb3 cloudfront.net -// Amazon Elastic Compute Cloud : https://aws.amazon.com/ec2/ +// Amazon EC2 // Submitted by Luke Wells +// Reference: 4c38fa71-58ac-4768-99e5-689c1767e537 *.compute.amazonaws.com *.compute-1.amazonaws.com *.compute.amazonaws.com.cn us-east-1.amazonaws.com -// Amazon Elastic Beanstalk : https://aws.amazon.com/elasticbeanstalk/ +// Amazon S3 +// Submitted by Luke Wells +// Reference: d068bd97-f0a9-4838-a6d8-954b622ef4ae +s3.cn-north-1.amazonaws.com.cn +s3.dualstack.ap-northeast-1.amazonaws.com +s3.dualstack.ap-northeast-2.amazonaws.com +s3.ap-northeast-2.amazonaws.com +s3-website.ap-northeast-2.amazonaws.com +s3.dualstack.ap-south-1.amazonaws.com +s3.ap-south-1.amazonaws.com +s3-website.ap-south-1.amazonaws.com +s3.dualstack.ap-southeast-1.amazonaws.com +s3.dualstack.ap-southeast-2.amazonaws.com +s3.dualstack.ca-central-1.amazonaws.com +s3.ca-central-1.amazonaws.com +s3-website.ca-central-1.amazonaws.com +s3.dualstack.eu-central-1.amazonaws.com +s3.eu-central-1.amazonaws.com +s3-website.eu-central-1.amazonaws.com +s3.dualstack.eu-west-1.amazonaws.com +s3.dualstack.eu-west-2.amazonaws.com +s3.eu-west-2.amazonaws.com +s3-website.eu-west-2.amazonaws.com +s3.dualstack.eu-west-3.amazonaws.com +s3.eu-west-3.amazonaws.com +s3-website.eu-west-3.amazonaws.com +s3.amazonaws.com +s3-ap-northeast-1.amazonaws.com +s3-ap-northeast-2.amazonaws.com +s3-ap-south-1.amazonaws.com +s3-ap-southeast-1.amazonaws.com +s3-ap-southeast-2.amazonaws.com +s3-ca-central-1.amazonaws.com +s3-eu-central-1.amazonaws.com +s3-eu-west-1.amazonaws.com +s3-eu-west-2.amazonaws.com +s3-eu-west-3.amazonaws.com +s3-external-1.amazonaws.com +s3-fips-us-gov-west-1.amazonaws.com +s3-sa-east-1.amazonaws.com +s3-us-east-2.amazonaws.com +s3-us-gov-west-1.amazonaws.com +s3-us-west-1.amazonaws.com +s3-us-west-2.amazonaws.com +s3-website-ap-northeast-1.amazonaws.com +s3-website-ap-southeast-1.amazonaws.com +s3-website-ap-southeast-2.amazonaws.com +s3-website-eu-west-1.amazonaws.com +s3-website-sa-east-1.amazonaws.com +s3-website-us-east-1.amazonaws.com +s3-website-us-west-1.amazonaws.com +s3-website-us-west-2.amazonaws.com +s3.dualstack.sa-east-1.amazonaws.com +s3.dualstack.us-east-1.amazonaws.com +s3.dualstack.us-east-2.amazonaws.com +s3.us-east-2.amazonaws.com +s3-website.us-east-2.amazonaws.com + +// AWS Cloud9 +// Submitted by: AWS Security +// Reference: 2b6dfa9a-3a7f-4367-b2e7-0321e77c0d59 +vfs.cloud9.af-south-1.amazonaws.com +webview-assets.cloud9.af-south-1.amazonaws.com +vfs.cloud9.ap-east-1.amazonaws.com +webview-assets.cloud9.ap-east-1.amazonaws.com +vfs.cloud9.ap-northeast-1.amazonaws.com +webview-assets.cloud9.ap-northeast-1.amazonaws.com +vfs.cloud9.ap-northeast-2.amazonaws.com +webview-assets.cloud9.ap-northeast-2.amazonaws.com +vfs.cloud9.ap-northeast-3.amazonaws.com +webview-assets.cloud9.ap-northeast-3.amazonaws.com +vfs.cloud9.ap-south-1.amazonaws.com +webview-assets.cloud9.ap-south-1.amazonaws.com +vfs.cloud9.ap-southeast-1.amazonaws.com +webview-assets.cloud9.ap-southeast-1.amazonaws.com +vfs.cloud9.ap-southeast-2.amazonaws.com +webview-assets.cloud9.ap-southeast-2.amazonaws.com +vfs.cloud9.ca-central-1.amazonaws.com +webview-assets.cloud9.ca-central-1.amazonaws.com +vfs.cloud9.eu-central-1.amazonaws.com +webview-assets.cloud9.eu-central-1.amazonaws.com +vfs.cloud9.eu-north-1.amazonaws.com +webview-assets.cloud9.eu-north-1.amazonaws.com +vfs.cloud9.eu-south-1.amazonaws.com +webview-assets.cloud9.eu-south-1.amazonaws.com +vfs.cloud9.eu-west-1.amazonaws.com +webview-assets.cloud9.eu-west-1.amazonaws.com +vfs.cloud9.eu-west-2.amazonaws.com +webview-assets.cloud9.eu-west-2.amazonaws.com +vfs.cloud9.eu-west-3.amazonaws.com +webview-assets.cloud9.eu-west-3.amazonaws.com +vfs.cloud9.me-south-1.amazonaws.com +webview-assets.cloud9.me-south-1.amazonaws.com +vfs.cloud9.sa-east-1.amazonaws.com +webview-assets.cloud9.sa-east-1.amazonaws.com +vfs.cloud9.us-east-1.amazonaws.com +webview-assets.cloud9.us-east-1.amazonaws.com +vfs.cloud9.us-east-2.amazonaws.com +webview-assets.cloud9.us-east-2.amazonaws.com +vfs.cloud9.us-west-1.amazonaws.com +webview-assets.cloud9.us-west-1.amazonaws.com +vfs.cloud9.us-west-2.amazonaws.com +webview-assets.cloud9.us-west-2.amazonaws.com + +// AWS Elastic Beanstalk // Submitted by Luke Wells +// Reference: aa202394-43a0-4857-b245-8db04549137e cn-north-1.eb.amazonaws.com.cn cn-northwest-1.eb.amazonaws.com.cn elasticbeanstalk.com @@ -10716,71 +10330,24 @@ us-gov-west-1.elasticbeanstalk.com us-west-1.elasticbeanstalk.com us-west-2.elasticbeanstalk.com -// Amazon Elastic Load Balancing : https://aws.amazon.com/elasticloadbalancing/ +// (AWS) Elastic Load Balancing // Submitted by Luke Wells -*.elb.amazonaws.com +// Reference: 12a3d528-1bac-4433-a359-a395867ffed2 *.elb.amazonaws.com.cn +*.elb.amazonaws.com -// Amazon Global Accelerator : https://aws.amazon.com/global-accelerator/ +// AWS Global Accelerator // Submitted by Daniel Massaguer +// Reference: d916759d-a08b-4241-b536-4db887383a6a awsglobalaccelerator.com -// Amazon S3 : https://aws.amazon.com/s3/ -// Submitted by Luke Wells -s3.amazonaws.com -s3-ap-northeast-1.amazonaws.com -s3-ap-northeast-2.amazonaws.com -s3-ap-south-1.amazonaws.com -s3-ap-southeast-1.amazonaws.com -s3-ap-southeast-2.amazonaws.com -s3-ca-central-1.amazonaws.com -s3-eu-central-1.amazonaws.com -s3-eu-west-1.amazonaws.com -s3-eu-west-2.amazonaws.com -s3-eu-west-3.amazonaws.com -s3-external-1.amazonaws.com -s3-fips-us-gov-west-1.amazonaws.com -s3-sa-east-1.amazonaws.com -s3-us-gov-west-1.amazonaws.com -s3-us-east-2.amazonaws.com -s3-us-west-1.amazonaws.com -s3-us-west-2.amazonaws.com -s3.ap-northeast-2.amazonaws.com -s3.ap-south-1.amazonaws.com -s3.cn-north-1.amazonaws.com.cn -s3.ca-central-1.amazonaws.com -s3.eu-central-1.amazonaws.com -s3.eu-west-2.amazonaws.com -s3.eu-west-3.amazonaws.com -s3.us-east-2.amazonaws.com -s3.dualstack.ap-northeast-1.amazonaws.com -s3.dualstack.ap-northeast-2.amazonaws.com -s3.dualstack.ap-south-1.amazonaws.com -s3.dualstack.ap-southeast-1.amazonaws.com -s3.dualstack.ap-southeast-2.amazonaws.com -s3.dualstack.ca-central-1.amazonaws.com -s3.dualstack.eu-central-1.amazonaws.com -s3.dualstack.eu-west-1.amazonaws.com -s3.dualstack.eu-west-2.amazonaws.com -s3.dualstack.eu-west-3.amazonaws.com -s3.dualstack.sa-east-1.amazonaws.com -s3.dualstack.us-east-1.amazonaws.com -s3.dualstack.us-east-2.amazonaws.com -s3-website-us-east-1.amazonaws.com -s3-website-us-west-1.amazonaws.com -s3-website-us-west-2.amazonaws.com -s3-website-ap-northeast-1.amazonaws.com -s3-website-ap-southeast-1.amazonaws.com -s3-website-ap-southeast-2.amazonaws.com -s3-website-eu-west-1.amazonaws.com -s3-website-sa-east-1.amazonaws.com -s3-website.ap-northeast-2.amazonaws.com -s3-website.ap-south-1.amazonaws.com -s3-website.ca-central-1.amazonaws.com -s3-website.eu-central-1.amazonaws.com -s3-website.eu-west-2.amazonaws.com -s3-website.eu-west-3.amazonaws.com -s3-website.us-east-2.amazonaws.com +// eero +// Submitted by Yue Kang +// Reference: 264afe70-f62c-4c02-8ab9-b5281ed24461 +eero.online +eero-stage.online + +// concludes Amazon // Amune : https://amune.org/ // Submitted by Team Amune @@ -10833,6 +10400,14 @@ myasustor.com // Submitted by Sam Smyth cdn.prod.atlassian-dev.net +// Authentick UG (haftungsbeschränkt) : https://authentick.net +// Submitted by Lukas Reschke +translated.page + +// Autocode : https://autocode.com +// Submitted by Jacob Lee +autocode.dev + // AVM : https://avm.de // Submitted by Andreas Weise myfritz.net @@ -10847,7 +10422,7 @@ onavstack.net *.advisor.ws // AZ.pl sp. z.o.o: https://az.pl -// Submited by Krzysztof Wolski +// Submitted by Krzysztof Wolski ecommerce-shop.pl // b-data GmbH : https://www.b-data.io @@ -10873,6 +10448,26 @@ rs.ba app.banzaicloud.io *.backyards.banzaicloud.io +// BASE, Inc. : https://binc.jp +// Submitted by Yuya NAGASAWA +base.ec +official.ec +buyshop.jp +fashionstore.jp +handcrafted.jp +kawaiishop.jp +supersale.jp +theshop.jp +shopselect.net +base.shop + +// BeagleBoard.org Foundation : https://beagleboard.org +// Submitted by Jason Kridner +beagleboard.io + +// Beget Ltd +// Submitted by Lev Nekrasov +*.beget.app // BetaInABox // Submitted by Adrian @@ -10941,6 +10536,11 @@ cafjs.com // Submitted by Marcus Popp mycd.eu +// Canva Pty Ltd : https://canva.com/ +// Submitted by Joel Aquilina +canva-apps.cn +canva-apps.com + // Carrd : https://carrd.co // Submitted by AJ drr.ac @@ -11070,8 +10670,11 @@ cloudcontrolapp.com // Cloudflare, Inc. : https://www.cloudflare.com/ // Submitted by Cloudflare Team -pages.dev +cf-ipfs.com +cloudflare-ipfs.com trycloudflare.com +pages.dev +r2.dev workers.dev // Clovyr : https://clovyr.io @@ -11115,6 +10718,10 @@ cloudns.us // Submitted by Angelo Gladding cnpy.gdn +// Codeberg e. V. : https://codeberg.org +// Submitted by Moritz Marquardt +codeberg.page + // CoDNS B.V. co.nl co.no @@ -11241,11 +10848,21 @@ deno-staging.dev // Submitted by Peter Thomassen dedyn.io +// Deta: https://www.deta.sh/ +// Submitted by Aavash Shrestha +deta.app +deta.dev + // Diher Solutions : https://diher.solutions // Submitted by Didi Hermawan *.rss.my.id *.diher.solutions +// Discord Inc : https://discord.com +// Submitted by Sahn Lam +discordsays.com +discordsez.com + // DNS Africa Ltd https://dns.business // Submitted by Calvin Browne jozi.biz @@ -11634,10 +11251,10 @@ dynv6.net // Submitted by Vladimir Dudr e4.cz -// eero : https://eero.com/ -// Submitted by Yue Kang -eero.online -eero-stage.online +// Easypanel : https://easypanel.io +// Submitted by Andrei Canta +easypanel.app +easypanel.host // Elementor : Elementor Ltd. // Submitted by Anton Barkan @@ -11653,11 +11270,20 @@ en-root.fr mytuleap.com tuleap-partners.com +// Encoretivity AB: https://encore.dev +// Submitted by André Eriksson +encr.app +encoreapi.com + // ECG Robotics, Inc: https://ecgrobotics.org // Submitted by onred.one staging.onred.one +// encoway GmbH : https://www.encoway.de +// Submitted by Marcel Daus +eu.encoway.cloud + // EU.org https://eu.org/ // Submitted by Pierre Beyssac eu.org @@ -11832,6 +11458,7 @@ u.channelsdvr.net // Fastly Inc. : http://www.fastly.com/ // Submitted by Fastly Security edgecompute.app +fastly-edge.com fastly-terrarium.com fastlylb.net map.fastlylb.net @@ -11843,6 +11470,10 @@ a.ssl.fastly.net b.ssl.fastly.net global.ssl.fastly.net +// Fastmail : https://www.fastmail.com/ +// Submitted by Marc Bradshaw +*.user.fm + // FASTVPS EESTI OU : https://fastvps.ru/ // Submitted by Likhachev Vasiliy fastvps-server.com @@ -11861,8 +11492,6 @@ app.os.stg.fedoraproject.org // FearWorks Media Ltd. : https://fearworksmedia.co.uk // submitted by Keith Fairley -couk.me -ukco.me conn.uk copro.uk hosp.uk @@ -11921,6 +11550,10 @@ id.forgerock.io // Submitted by Koen Rouwhorst framer.app framercanvas.com +framer.media +framer.photos +framer.website +framer.wiki // Frusky MEDIA&PR : https://www.frusky.de // Submitted by Victor Pupynin @@ -11966,10 +11599,22 @@ futuremailing.at *.kunden.ortsinfo.at *.statics.cloud -// GDS : https://www.gov.uk/service-manual/operations/operating-servicegovuk-subdomains -// Submitted by David Illsley +// GDS : https://www.gov.uk/service-manual/technology/managing-domain-names +// Submitted by Stephen Ford +independent-commission.uk +independent-inquest.uk +independent-inquiry.uk +independent-panel.uk +independent-review.uk +public-inquiry.uk +royal-commission.uk +campaign.gov.uk service.gov.uk +// CDDO : https://www.gov.uk/guidance/get-an-api-domain-on-govuk +// Submitted by Jamie Tanna +api.gov.uk + // Gehirn Inc. : https://www.gehirn.co.jp/ // Submitted by Kohei YOSHIDA gehirn.ne.jp @@ -12019,8 +11664,114 @@ co.ro shop.ro // GMO Pepabo, Inc. : https://pepabo.com/ -// Submitted by dojineko +// Submitted by Hosting Div lolipop.io +angry.jp +babyblue.jp +babymilk.jp +backdrop.jp +bambina.jp +bitter.jp +blush.jp +boo.jp +boy.jp +boyfriend.jp +but.jp +candypop.jp +capoo.jp +catfood.jp +cheap.jp +chicappa.jp +chillout.jp +chips.jp +chowder.jp +chu.jp +ciao.jp +cocotte.jp +coolblog.jp +cranky.jp +cutegirl.jp +daa.jp +deca.jp +deci.jp +digick.jp +egoism.jp +fakefur.jp +fem.jp +flier.jp +floppy.jp +fool.jp +frenchkiss.jp +girlfriend.jp +girly.jp +gloomy.jp +gonna.jp +greater.jp +hacca.jp +heavy.jp +her.jp +hiho.jp +hippy.jp +holy.jp +hungry.jp +icurus.jp +itigo.jp +jellybean.jp +kikirara.jp +kill.jp +kilo.jp +kuron.jp +littlestar.jp +lolipopmc.jp +lolitapunk.jp +lomo.jp +lovepop.jp +lovesick.jp +main.jp +mods.jp +mond.jp +mongolian.jp +moo.jp +namaste.jp +nikita.jp +nobushi.jp +noor.jp +oops.jp +parallel.jp +parasite.jp +pecori.jp +peewee.jp +penne.jp +pepper.jp +perma.jp +pigboat.jp +pinoko.jp +punyu.jp +pupu.jp +pussycat.jp +pya.jp +raindrop.jp +readymade.jp +sadist.jp +schoolbus.jp +secret.jp +staba.jp +stripper.jp +sub.jp +sunnyday.jp +thick.jp +tonkotsu.jp +under.jp +upper.jp +velvet.jp +verse.jp +versus.jp +vivian.jp +watson.jp +weblike.jp +whitesnow.jp +zombie.jp +heteml.net // GOV.UK Platform as a Service : https://www.cloud.service.gov.uk/ // Submitted by Tom Whitwell @@ -12142,6 +11893,10 @@ blogspot.vn // Submitted by Niels Martignene goupile.fr +// Government of the Netherlands: https://www.government.nl +// Submitted by +gov.nl + // Group 53, LLC : https://www.group53.com // Submitted by Tyler Todd awsmppl.com @@ -12152,7 +11907,7 @@ günstigbestellen.de günstigliefern.de // Hakaran group: http://hakaran.cz -// Submited by Arseniy Sokolov +// Submitted by Arseniy Sokolov fin.ci free.hr caa.li @@ -12187,20 +11942,25 @@ herokussl.com // Hibernating Rhinos // Submitted by Oren Eini -myravendb.com +ravendb.cloud ravendb.community ravendb.me development.run ravendb.run // home.pl S.A.: https://home.pl -// Submited by Krzysztof Wolski +// Submitted by Krzysztof Wolski homesklep.pl // Hong Kong Productivity Council: https://www.hkpc.org/ // Submitted by SECaaS Team secaas.hk +// Hoplix : https://www.hoplix.com +// Submitted by Danilo De Franco +hoplix.shop + + // HOSTBIP REGISTRY : https://www.hostbip.com/ // Submitted by Atanunu Igbunuroghene orx.biz @@ -12212,7 +11972,10 @@ ltd.ng ngo.ng edu.scot sch.so -org.yt + +// HostFly : https://www.ie.ua +// Submitted by Bohdan Dub +ie.ua // HostyHosting (hostyhosting.com) hostyhosting.io @@ -12230,6 +11993,11 @@ moonscale.net // Submitted by Hannu Aronsson iki.fi +// iliad italia: https://www.iliad.it +// Submitted by Marios Makassikis +ibxos.it +iliadboxos.it + // Impertrix Solutions : // Submitted by Zhixiang Zhao impertrixcdn.com @@ -12299,7 +12067,7 @@ to.leg.br pixolino.com // Internet-Pro, LLP: https://netangels.ru/ -// Submited by Vasiliy Sheredeko +// Submitted by Vasiliy Sheredeko na4u.ru // iopsys software solutions AB : https://iopsys.eu/ @@ -12310,9 +12078,11 @@ iopsys.se // Submitted by Matthew Hardeman ipifony.net -// IServ GmbH : https://iserv.eu -// Submitted by Kim-Alexander Brodowski +// IServ GmbH : https://iserv.de +// Submitted by Mario Hoberg +iservschule.de mein-iserv.de +schulplattform.de schulserver.de test-iserv.de iserv.dev @@ -12322,7 +12092,7 @@ iserv.dev iobb.net // Jelastic, Inc. : https://jelastic.com/ -// Submited by Ihor Kolodyuk +// Submitted by Ihor Kolodyuk mel.cloudlets.com.au cloud.interhostsolutions.be users.scale.virtualcloud.com.br @@ -12433,6 +12203,14 @@ js.org kaas.gg khplay.nl +// Kakao : https://www.kakaocorp.com/ +// Submitted by JaeYoong Lee +ktistory.com + +// Kapsi : https://kapsi.fi +// Submitted by Tomi Juntunen +kapsi.fi + // Keyweb AG : https://www.keyweb.de // Submitted by Martin Dannehl keymachine.de @@ -12446,6 +12224,10 @@ uni5.net // Submitted by Roy Keene knightpoint.systems +// KoobinEvent, SL: https://www.koobin.com +// Submitted by Iván Oliva +koobin.events + // KUROKU LTD : https://kuroku.ltd/ // Submitted by DisposaBoy oya.to @@ -12510,6 +12292,10 @@ ip.linodeusercontent.com // Submitted by Victor Velchev we.bs +// Localcert : https://localcert.dev +// Submitted by Lann Martin +*.user.localcert.dev + // localzone.xyz // Submitted by Kenny Niehage localzone.xyz @@ -12618,6 +12404,10 @@ hra.health miniserver.com memset.net +// Messerli Informatik AG : https://www.messerli.ch/ +// Submitted by Ruben Schmidmeister +messerli.app + // MetaCentrum, CESNET z.s.p.o. : https://www.metacentrum.cz/en/ // Submitted by Zdeněk Šustr *.cloud.metacentrum.cz @@ -12637,12 +12427,15 @@ eu.meteorapp.com co.pl // Microsoft Corporation : http://microsoft.com -// Submitted by Mitch Webster +// Submitted by Public Suffix List Admin *.azurecontainer.io azurewebsites.net azure-mobile.net cloudapp.net azurestaticapps.net +1.azurestaticapps.net +2.azurestaticapps.net +3.azurestaticapps.net centralus.azurestaticapps.net eastasia.azurestaticapps.net eastus2.azurestaticapps.net @@ -12695,24 +12488,9 @@ cust.retrosnub.co.uk // Submitted by Paulus Schoutsen ui.nabu.casa -// Names.of.London : https://names.of.london/ -// Submitted by James Stevens or -pony.club -of.fashion -in.london -of.london -from.marketing -with.marketing -for.men -repair.men -and.mom -for.mom -for.one -under.one -for.sale -that.win -from.work -to.work +// Net at Work Gmbh : https://www.netatwork.de +// Submitted by Jan Jaeschke +cloud.nospamproxy.com // Netlify : https://www.netlify.com // Submitted by Jessica Parsons @@ -12724,7 +12502,19 @@ netlify.app // ngrok : https://ngrok.com/ // Submitted by Alan Shreve +ngrok.app +ngrok-free.app +ngrok.dev +ngrok-free.dev ngrok.io +ap.ngrok.io +au.ngrok.io +eu.ngrok.io +in.ngrok.io +jp.ngrok.io +sa.ngrok.io +us.ngrok.io +ngrok.pizza // Nimbus Hosting Ltd. : https://www.nimbushosting.co.uk/ // Submitted by Nicholas Ford @@ -12742,7 +12532,10 @@ noop.app // Northflank Ltd. : https://northflank.com/ // Submitted by Marco Suter *.northflank.app +*.build.run *.code.run +*.database.run +*.migration.run // Noticeable : https://noticeable.io // Submitted by Laurent Pellegrino @@ -12873,11 +12666,6 @@ zapto.org // Submitted by Konstantin Nosov stage.nodeart.io -// Nodum B.V. : https://nodum.io/ -// Submitted by Wietse Wind -nodum.co -nodum.io - // Nucleos Inc. : https://nucleos.com // Submitted by Piotr Zduniak pcloud.host @@ -12908,7 +12696,26 @@ omniwe.site // One.com: https://www.one.com/ // Submitted by Jacob Bunk Nielsen +123hjemmeside.dk +123hjemmeside.no +123homepage.it +123kotisivu.fi +123minsida.se +123miweb.es +123paginaweb.pt +123sait.ru +123siteweb.fr +123webseite.at +123webseite.de +123website.be +123website.ch +123website.lu +123website.nl service.one +simplesite.com +simplesite.com.br +simplesite.gr +simplesite.pl // One Fold Media : http://www.onefoldmedia.com/ // Submitted by Eddie Jones @@ -12930,8 +12737,12 @@ orsites.com // Submitted by Yngve Pettersen operaunite.com +// Orange : https://www.orange.com +// Submitted by Alexandre Linte +tech.orange + // Oursky Limited : https://authgear.com/, https://skygear.io/ -// Submited by Authgear Team , Skygear Developer +// Submitted by Authgear Team , Skygear Developer authgear-staging.com authgearapps.com skygearapp.com @@ -13039,6 +12850,10 @@ pleskns.com // Submitted by Maximilian Schieder dyn53.io +// Porter : https://porter.run/ +// Submitted by Rudraksh MK +onporter.run + // Positive Codes Technology Company : http://co.bn/faq.html // Submitted by Zulfais co.bn @@ -13096,6 +12911,10 @@ qoto.io // Submitted by Xavier De Cock qualifioapp.com +// Quality Unit: https://qualityunit.com +// Submitted by Vasyl Tsalko +ladesk.com + // QuickBackend: https://www.quickbackend.com // Submitted by Dani Biro qbuser.com @@ -13169,7 +12988,9 @@ app.render.com onrender.com // Repl.it : https://repl.it -// Submitted by Mason Clayton +// Submitted by Lincoln Bergeson +firewalledreplit.co +id.firewalledreplit.co repl.co id.repl.co repl.run @@ -13200,6 +13021,10 @@ itcouldbewor.se // Submitted by Jennifer Herting git-pages.rit.edu +// Rocky Enterprise Software Foundation : https://resf.org +// Submitted by Neil Hanlon +rocky.page + // Rusnames Limited: http://rusnames.ru/ // Submitted by Sergey Zotov биз.рус @@ -13213,6 +13038,62 @@ git-pages.rit.edu спб.рус я.рус +// SAKURA Internet Inc. : https://www.sakura.ad.jp/ +// Submitted by Internet Service Department +180r.com +dojin.com +sakuratan.com +sakuraweb.com +x0.com +2-d.jp +bona.jp +crap.jp +daynight.jp +eek.jp +flop.jp +halfmoon.jp +jeez.jp +matrix.jp +mimoza.jp +ivory.ne.jp +mail-box.ne.jp +mints.ne.jp +mokuren.ne.jp +opal.ne.jp +sakura.ne.jp +sumomo.ne.jp +topaz.ne.jp +netgamers.jp +nyanta.jp +o0o0.jp +rdy.jp +rgr.jp +rulez.jp +s3.isk01.sakurastorage.jp +s3.isk02.sakurastorage.jp +saloon.jp +sblo.jp +skr.jp +tank.jp +uh-oh.jp +undo.jp +rs.webaccel.jp +user.webaccel.jp +websozai.jp +xii.jp +squares.net +jpn.org +kirara.st +x0.to +from.tv +sakura.tv + +// Salesforce.com, Inc. https://salesforce.com/ +// Submitted by Michael Biven +*.builder.code.com +*.dev-builder.code.com +*.stg-builder.code.com + // Sandstorm Development Group, Inc. : https://sandcats.io/ // Submitted by Asheesh Laroia sandcats.io @@ -13222,6 +13103,34 @@ sandcats.io logoip.de logoip.com +// Scaleway : https://www.scaleway.com/ +// Submitted by Rémy Léone +fr-par-1.baremetal.scw.cloud +fr-par-2.baremetal.scw.cloud +nl-ams-1.baremetal.scw.cloud +fnc.fr-par.scw.cloud +functions.fnc.fr-par.scw.cloud +k8s.fr-par.scw.cloud +nodes.k8s.fr-par.scw.cloud +s3.fr-par.scw.cloud +s3-website.fr-par.scw.cloud +whm.fr-par.scw.cloud +priv.instances.scw.cloud +pub.instances.scw.cloud +k8s.scw.cloud +k8s.nl-ams.scw.cloud +nodes.k8s.nl-ams.scw.cloud +s3.nl-ams.scw.cloud +s3-website.nl-ams.scw.cloud +whm.nl-ams.scw.cloud +k8s.pl-waw.scw.cloud +nodes.k8s.pl-waw.scw.cloud +s3.pl-waw.scw.cloud +s3-website.pl-waw.scw.cloud +scalebook.scw.cloud +smartlabeling.scw.cloud +dedibox.fr + // schokokeks.org GbR : https://schokokeks.org/ // Submitted by Hanno Böck schokokeks.net @@ -13329,6 +13238,13 @@ small-web.org // Submitted by Dan Kozak vp4.me +// Snowflake Inc : https://www.snowflake.com/ +// Submitted by Faith Olapade +snowflake.app +privatelink.snowflake.app +streamlit.app +streamlitapp.com + // Snowplow Analytics : https://snowplowanalytics.com/ // Submitted by Ian Streeter try-snowplow.com @@ -13342,6 +13258,8 @@ srht.site stackhero-network.com // Staclar : https://staclar.com +// Submitted by Q Misell +musician.io // Submitted by Matthias Merkel novecore.site @@ -13440,25 +13358,28 @@ syncloud.it // Synology, Inc. : https://www.synology.com/ // Submitted by Rony Weng -diskstation.me dscloud.biz -dscloud.me -dscloud.mobi +direct.quickconnect.cn dsmynas.com -dsmynas.net -dsmynas.org familyds.com -familyds.net -familyds.org +diskstation.me +dscloud.me i234.me myds.me synology.me +dscloud.mobi +dsmynas.net +familyds.net +dsmynas.org +familyds.org vpnplus.to direct.quickconnect.to // Tabit Technologies Ltd. : https://tabit.cloud/ // Submitted by Oren Agiv tabitorder.co.il +mytabit.co.il +mytabit.com // TAIFUN Software AG : http://taifun-software.de // Submitted by Bjoern Henke @@ -13476,9 +13397,14 @@ gdynia.pl med.pl sopot.pl +// team.blue https://team.blue +// Submitted by Cedric Dubois +site.tb-hosting.com + // Teckids e.V. : https://www.teckids.org // Submitted by Dominik George -edugit.org +edugit.io +s3.teckids.org // Telebit : https://telebit.cloud // Submitted by AJ ONeal @@ -13486,10 +13412,6 @@ telebit.app telebit.io *.telebit.xyz -// The Gwiddle Foundation : https://gwiddlefoundation.org.uk -// Submitted by Joshua Bayfield -gwiddle.co.uk - // Thingdust AG : https://thingdust.com/ // Submitted by Adrian Imboden *.firenet.ch @@ -13524,10 +13446,6 @@ pages.torproject.net bloxcms.com townnews-staging.com -// TradableBits: https://tradablebits.com -// Submitted by Dmitry Khrisanov dmitry@tradablebits.com -tbits.me - // TrafficPlex GmbH : https://www.trafficplex.de/ // Submitted by Phillipp Röll 12hp.at @@ -13556,6 +13474,10 @@ lima.zone *.transurl.eu *.transurl.nl +// TransIP: https://www.transip.nl +// Submitted by Cedric Dubois +site.transip.me + // TuxFamily : http://tuxfamily.org // Submitted by TuxFamily administrators tuxfamily.org @@ -13576,6 +13498,14 @@ syno-ds.de synology-diskstation.de synology-ds.de +// Typedream : https://typedream.com +// Submitted by Putri Karunia +typedream.app + +// Typeform : https://www.typeform.com +// Submitted by Sergi Ferriz +pro.typeform.com + // Uberspace : https://uberspace.de // Submitted by Moritz Werner uber.space @@ -13588,6 +13518,19 @@ hk.org ltd.hk inc.hk +// UK Intis Telecom LTD : https://it.com +// Submitted by ITComdomains +it.com + +// UNIVERSAL DOMAIN REGISTRY : https://www.udr.org.yt/ +// see also: whois -h whois.udr.org.yt help +// Submitted by Atanunu Igbunuroghene +name.pm +sch.tf +biz.wf +sch.wf +org.yt + // United Gameserver GmbH : https://united-gameserver.de // Submitted by Stefan Schwarz virtualuser.de @@ -13674,19 +13617,14 @@ me.vu // Submitted by Serhii Rostilo v.ua +// Vultr Objects : https://www.vultr.com/products/object-storage/ +// Submitted by Niels Maumenee +*.vultrobjects.com + // Waffle Computer Inc., Ltd. : https://docs.waffleinfo.com // Submitted by Masayuki Note wafflecell.com -// WapBlog.ID : https://www.wapblog.id -// Submitted by Fajar Sodik -idnblogger.com -indowapblog.com -bloger.id -wblog.id -wbq.me -fastblog.net - // WebHare bv: https://www.webhare.com/ // Submitted by Arnold Hendriks *.webhare.dev @@ -13723,6 +13661,10 @@ wmcloud.org panel.gg daemon.panel.gg +// Wizard Zines : https://wizardzines.com +// Submitted by Julia Evans +messwithdns.com + // WoltLab GmbH : https://www.woltlab.com // Submitted by Tim Düsterhus woltlab-demo.com diff --git a/src/java.base/share/legal/public_suffix.md b/src/java.base/share/legal/public_suffix.md index 61d9607177ec3..d228ac298b90c 100644 --- a/src/java.base/share/legal/public_suffix.md +++ b/src/java.base/share/legal/public_suffix.md @@ -11,7 +11,7 @@ If you do not wish to use the Public Suffix List, you may remove the The Source Code of this file is available under the Mozilla Public License, v. 2.0 and is located at -https://raw.githubusercontent.com/publicsuffix/list/3c213aab32b3c014f171b1673d4ce9b5cd72bf1c/public_suffix_list.dat. +https://raw.githubusercontent.com/publicsuffix/list/88467c960d6cdad2ca1623e892e5e17506bc269f/public_suffix_list.dat. If a copy of the MPL was not distributed with this file, you can obtain one at https://mozilla.org/MPL/2.0/. diff --git a/test/jdk/sun/security/util/RegisteredDomain/ParseNames.java b/test/jdk/sun/security/util/RegisteredDomain/ParseNames.java index 69ca9577c687f..74045b533c295 100644 --- a/test/jdk/sun/security/util/RegisteredDomain/ParseNames.java +++ b/test/jdk/sun/security/util/RegisteredDomain/ParseNames.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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8228969 8244087 8255266 + * @bug 8228969 8244087 8255266 8302182 * @modules java.base/sun.security.util * @summary unit test for RegisteredDomain */ diff --git a/test/jdk/sun/security/util/RegisteredDomain/tests.dat b/test/jdk/sun/security/util/RegisteredDomain/tests.dat index e4cf659c6341a..8d8ba34c832b1 100644 --- a/test/jdk/sun/security/util/RegisteredDomain/tests.dat +++ b/test/jdk/sun/security/util/RegisteredDomain/tests.dat @@ -84,6 +84,10 @@ foo.fj fj foo.fj www.foo.ie ie foo.ie www.foo.gov.ie gov.ie foo.gov.ie +# in +5g.in 5g.in null +www.5g.in 5g.in www.5g.in + # it has a large number of entries www.gr.it gr.it www.gr.it www.blahblahblah.it it blahblahblah.it @@ -153,4 +157,8 @@ w.s.pvt.k12.ma.us pvt.k12.ma.us s.pvt.k12.ma.us foo.السعودية السعودية foo.السعودية w.foo.السعودية السعودية foo.السعودية +# Microsoft +1.azurestaticapps.net 1.azurestaticapps.net null +app.1.azurestaticapps.net 1.azurestaticapps.net app.1.azurestaticapps.net + ## END From fe3920e63bdeb81947091c1fa5fc66b785f98a7f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 9 Aug 2023 16:46:23 +0000 Subject: [PATCH 011/341] 8283276: java/io/ObjectStreamClass/ObjectStreamClassCaching.java fails with various GCs Backport-of: d4a795d75aef8d787934f5c05e146c61138a408a --- .../ObjectStreamClassCaching.java | 112 +++++++++++++----- 1 file changed, 85 insertions(+), 27 deletions(-) diff --git a/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java b/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java index 74c21c540d864..5dafdc181cd07 100644 --- a/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java +++ b/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. * 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,29 +30,93 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; -/* @test +/* + * @test id=G1 + * @requires vm.gc.G1 + * @bug 8277072 + * @library /test/lib/ + * @summary ObjectStreamClass caches keep ClassLoaders alive (G1 GC) + * @run testng/othervm -Xmx64m -XX:+UseG1GC ObjectStreamClassCaching + */ + +/* + * @test id=Parallel + * @requires vm.gc.Parallel + * @bug 8277072 + * @library /test/lib/ + * @summary ObjectStreamClass caches keep ClassLoaders alive (Parallel GC) + * @run testng/othervm -Xmx64m -XX:+UseParallelGC ObjectStreamClassCaching + */ + +/* + * @test id=Z + * @requires vm.gc.Z + * @bug 8277072 + * @library /test/lib/ + * @summary ObjectStreamClass caches keep ClassLoaders alive (Z GC) + * @run testng/othervm -Xmx64m -XX:+UseZGC ObjectStreamClassCaching + */ + +/* + * @test id=Shenandoah + * @requires vm.gc.Shenandoah + * @bug 8277072 + * @library /test/lib/ + * @summary ObjectStreamClass caches keep ClassLoaders alive (Shenandoah GC) + * @run testng/othervm -Xmx64m -XX:+UseShenandoahGC ObjectStreamClassCaching + */ + +/* + * @test id=Serial + * @requires vm.gc.Serial * @bug 8277072 * @library /test/lib/ - * @summary ObjectStreamClass caches keep ClassLoaders alive - * @run testng/othervm -Xmx10m -XX:SoftRefLRUPolicyMSPerMB=1 ObjectStreamClassCaching + * @summary ObjectStreamClass caches keep ClassLoaders alive (Serial GC) + * @run testng/othervm -Xmx64m -XX:+UseSerialGC ObjectStreamClassCaching */ public class ObjectStreamClassCaching { + /** + * Test methods execute in same VM and are ordered by name. + * We test effectiveness 1st which is sensitive to previous allocations when ZGC is used. + */ @Test - public void testCachingEffectiveness() throws Exception { - var ref = lookupObjectStreamClass(TestClass.class); + public void test1CacheEffectiveness() throws Exception { + var list = new ArrayList<>(); + var ref1 = lookupObjectStreamClass(TestClass1.class); + var ref2 = newWeakRef(); + boolean oome = false; + try { + while (!ref2.refersTo(null)) { + list.add(new byte[1024 * 1024 * 1]); // 1 MiB chunks + System.out.println("1MiB allocated..."); + Thread.sleep(5L); + } + } catch (OutOfMemoryError e) { + // release + list = null; + oome = true; + } + assertFalse(oome, "WeakReference was not cleared although memory was pressed hard"); + assertFalse(ref1.refersTo(null), + "Cache lost entry together with WeakReference being cleared although memory was not under pressure"); System.gc(); Thread.sleep(100L); - // to trigger any ReferenceQueue processing... - lookupObjectStreamClass(AnotherTestClass.class); - assertFalse(ref.refersTo(null), - "Cache lost entry although memory was not under pressure"); } @Test - public void testCacheReleaseUnderMemoryPressure() throws Exception { - var ref = lookupObjectStreamClass(TestClass.class); - pressMemoryHard(ref); + public void test2CacheReleaseUnderMemoryPressure() throws Exception { + var list = new ArrayList<>(); + var ref = lookupObjectStreamClass(TestClass2.class); + try { + while (!ref.refersTo(null)) { + list.add(new byte[1024 * 1024 * 4]); // 4 MiB chunks + System.out.println("4MiB allocated..."); + } + } catch (OutOfMemoryError e) { + // release + list = null; + } System.gc(); Thread.sleep(100L); assertTrue(ref.refersTo(null), @@ -60,24 +124,18 @@ public void testCacheReleaseUnderMemoryPressure() throws Exception { } // separate method so that the looked-up ObjectStreamClass is not kept on stack - private static WeakReference lookupObjectStreamClass(Class cl) { + private static Reference lookupObjectStreamClass(Class cl) { return new WeakReference<>(ObjectStreamClass.lookup(cl)); } - private static void pressMemoryHard(Reference ref) { - try { - var list = new ArrayList<>(); - while (!ref.refersTo(null)) { - list.add(new byte[1024 * 1024 * 64]); // 64 MiB chunks - } - } catch (OutOfMemoryError e) { - // release - } + // separate method so that the new Object() is not kept on stack + private static Reference newWeakRef() { + return new WeakReference<>(new Object()); } -} -class TestClass implements Serializable { -} + static class TestClass1 implements Serializable { + } -class AnotherTestClass implements Serializable { + static class TestClass2 implements Serializable { + } } From 8aad696538397934198671faa0fffce1684ed1b0 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Thu, 10 Aug 2023 08:34:16 +0000 Subject: [PATCH 012/341] 8301167: Update VerifySignedJar to actually exercise and test verification Backport-of: 05ea083b0563ddacf3e38dc329ba00dc4bac9b29 --- .../util/jar/JarFile/VerifySignedJar.java | 124 ++++++++++++++---- test/jdk/java/util/jar/JarFile/thawjar.jar | Bin 2441 -> 0 bytes 2 files changed, 98 insertions(+), 26 deletions(-) delete mode 100644 test/jdk/java/util/jar/JarFile/thawjar.jar diff --git a/test/jdk/java/util/jar/JarFile/VerifySignedJar.java b/test/jdk/java/util/jar/JarFile/VerifySignedJar.java index 1f4db736e8f40..bd5490502c9ec 100644 --- a/test/jdk/java/util/jar/JarFile/VerifySignedJar.java +++ b/test/jdk/java/util/jar/JarFile/VerifySignedJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,48 +23,120 @@ /** * @test + * @library /test/lib + * @modules java.base/sun.security.x509 + * @modules java.base/sun.security.tools.keytool * @bug 4419266 4842702 * @summary Make sure verifying signed Jar doesn't throw SecurityException */ -import java.io.File; -import java.util.jar.JarFile; +import jdk.security.jarsigner.JarSigner; +import sun.security.tools.keytool.CertAndKeyGen; +import sun.security.x509.X500Name; + +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.KeyStore; +import java.security.cert.Certificate; +import java.security.cert.X509Certificate; +import java.util.Collections; +import java.util.Objects; +import java.util.concurrent.TimeUnit; import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; import java.util.zip.ZipEntry; -import java.util.Enumeration; +import java.util.zip.ZipFile; + +import static jdk.test.lib.Utils.runAndCheckException; + public class VerifySignedJar { - private static void Unreached (Object o) - throws Exception - { - // Should never get here - throw new Exception ("Expected exception was not thrown"); - } public static void main(String[] args) throws Exception { - File f = new File(System.getProperty("test.src", "."), "thawjar.jar"); - JarFile jf = new JarFile(f); - try { - // Read entries via Enumeration - for (Enumeration e = jf.entries(); e.hasMoreElements();) - jf.getInputStream((ZipEntry) e.nextElement()); - // Read entry by name - ZipEntry ze = jf.getEntry("getprop.class"); - JarEntry je = jf.getJarEntry("getprop.class"); + Path j = createJar(); + Path s = signJar(j, keyEntry("cn=duke")); + + try (JarFile jf = new JarFile(s.toFile())) { - // Make sure we throw NPE on null objects - try { Unreached (jf.getEntry(null)); } - catch (NullPointerException e) {} + for (JarEntry e: Collections.list(jf.entries())) { + // Reading entry to trigger verification + jf.getInputStream(e).transferTo(OutputStream.nullOutputStream()); + // Check that all regular files are signed by duke + if (!e.getName().startsWith("META-INF/")) { + checkSignedBy(e, "cn=duke"); + } + } - try { Unreached (jf.getJarEntry(null)); } - catch (NullPointerException e) {} + // Read ZIP and JAR entries by name + Objects.requireNonNull(jf.getEntry("getprop.class")); + Objects.requireNonNull(jf.getJarEntry("getprop.class")); - try { Unreached (jf.getInputStream(null)); } - catch (NullPointerException e) {} + // Make sure we throw NPE on null parameters + runAndCheckException(() -> jf.getEntry(null), NullPointerException.class); + runAndCheckException(() -> jf.getJarEntry(null), NullPointerException.class); + runAndCheckException(() -> jf.getInputStream(null), NullPointerException.class); } catch (SecurityException se) { throw new Exception("Got SecurityException when verifying signed " + "jar:" + se); } } + + // Check that a JAR entry is signed by an expected DN + private static void checkSignedBy(JarEntry e, String expectedDn) throws Exception { + Certificate[] certs = e.getCertificates(); + if (certs == null || certs.length == 0) { + throw new Exception("JarEntry has no certificates: " + e.getName()); + } + + if (certs[0] instanceof X509Certificate x) { + String name = x.getSubjectX500Principal().getName(); + if (!name.equalsIgnoreCase(expectedDn)) { + throw new Exception("Expected entry signed by %s, was %s".formatted(name, expectedDn)); + } + } else { + throw new Exception("Expected JarEntry.getCertificate to return X509Certificate"); + } + } + + private static Path createJar() throws Exception { + Path j = Path.of("unsigned.jar"); + try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(j))){ + out.putNextEntry(new JarEntry("getprop.class")); + out.write(new byte[] {(byte) 0XCA, (byte) 0XFE, (byte) 0XBA, (byte) 0XBE}); + } + return j; + } + + private static Path signJar(Path j, KeyStore.PrivateKeyEntry entry) throws Exception { + Path s = Path.of("signed.jar"); + + JarSigner signer = new JarSigner.Builder(entry) + .signerName("zigbert") + .digestAlgorithm("SHA-256") + .signatureAlgorithm("SHA256withRSA") + .build(); + + try (ZipFile zip = new ZipFile(j.toFile()); + OutputStream out = Files.newOutputStream(s)) { + signer.sign(zip, out); + } + + return s; + } + + private static KeyStore.PrivateKeyEntry keyEntry(String dname) throws Exception { + + CertAndKeyGen gen = new CertAndKeyGen("RSA", "SHA256withRSA"); + + gen.generate(1048); // Small key size makes test run faster + + var oneDay = TimeUnit.DAYS.toSeconds(1); + Certificate cert = gen.getSelfCertificate(new X500Name(dname), oneDay); + + return new KeyStore.PrivateKeyEntry(gen.getPrivateKey(), + new Certificate[] {cert}); + } } diff --git a/test/jdk/java/util/jar/JarFile/thawjar.jar b/test/jdk/java/util/jar/JarFile/thawjar.jar deleted file mode 100644 index 49d247cb40d9a5dc2e4d9c65be47b5cccd709a02..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2441 zcmZuz2{;s58y+TRlC4I}DA`?VVwjToiIHn-46-E4RSd%nW1Hl(gbYH;l5j0! zkFxw2V}vM@$S!5f}{P&#aJI`~L?>*1?&iB0EYmNaP0B{-@fTqqU=0(b$ z7vKf}C_n%}fV1l6dfms*+eaDa=|m>SS=xH{qlI^?QJ*!uGV;Z8Qo9b{Q^(eZ+dVm8 zt(#&OmdqE`Q9}2PJ@T$%FsxxI;CD7A8a)A8dMr#g7C)H|f-kUM29a;h4lXY0BsK|V z%?}Ou+H^n!?8R@Ku{t|&W@K;)-Kqyvni80!*|;>L#bbE+;V{NE+mBwfG9SxCe~5l@ zS}jEYA}?Z+Tuz)&<>Nn;x3X-w8#OpQLMHmd>a*w_RK=7rBs?Voy2u>Ppn^^h#&3w2 z!+#4%hZd|{jVPVKTZXwj*XVq(a@wp{QbI{?XJp->uBXhe30ELrVl?DC$IOz~ekViy zb8*3rzZ3XE8j4T&&8#6#(@jQe+Ku!I>aQb6S{}A;A)c=$9oFxzeb2UyS1Hjr;`Dk_ zA}2IAP#9dQYZ^xlptw>$fCDd>j^u!CkBo-jlDhB~*K5RQ0Jo@eZxQGQ;zogJW%GZiOL5t<@%UIl?e35ZIAmh-@vD2=_*tA zrJiS-1?jO}wm@q_n}vsHDcbp4v@TfPx;Fl~GcK%LT3s_jAhZXRI9TXKN-i?O+-bfP zb59&hhj`S?C!3j%7exGJ(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}i`$55)HV;pQ#dH{=X3!*Z(@oMY-HqV+ z0rRv!IGKFoa?q?q#H3Jaxv83+Z=74(>S_-TSHm`%D8HAze6yzr Date: Thu, 10 Aug 2023 08:37:56 +0000 Subject: [PATCH 013/341] 8307079: Update test java/awt/Choice/DragOffNoSelect.java Backport-of: 89711f376751d4cfa05758705867afedfafeb602 --- test/jdk/java/awt/Choice/DragOffNoSelectTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/java/awt/Choice/DragOffNoSelectTest.java b/test/jdk/java/awt/Choice/DragOffNoSelectTest.java index 587fc701e9320..a3b808dbcf897 100644 --- a/test/jdk/java/awt/Choice/DragOffNoSelectTest.java +++ b/test/jdk/java/awt/Choice/DragOffNoSelectTest.java @@ -71,7 +71,7 @@ static void createUI() { } frame.add(theChoice); frame.addWindowListener(testInstance); - frame.setSize(400, 400); + frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); From 242513fbcd10e1fb9f09fe6a2dae5f15253de45c Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Thu, 10 Aug 2023 08:38:28 +0000 Subject: [PATCH 014/341] 6381945: (cal) Japanese calendar unit test system should avoid multiple static imports Backport-of: f79b3d42f07b703f0e3b9fc67c92dee260b0e602 --- test/jdk/java/util/Calendar/CalendarTestScripts/Symbol.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/jdk/java/util/Calendar/CalendarTestScripts/Symbol.java b/test/jdk/java/util/Calendar/CalendarTestScripts/Symbol.java index a310f968ded54..c872d09ab5a7d 100644 --- a/test/jdk/java/util/Calendar/CalendarTestScripts/Symbol.java +++ b/test/jdk/java/util/Calendar/CalendarTestScripts/Symbol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ import java.util.Locale; import java.util.Map; -import static java.util.Calendar.*; import static java.util.GregorianCalendar.*; public class Symbol { From fe9b7c69714b86c2784273f0d53b21d167400392 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Thu, 10 Aug 2023 08:38:58 +0000 Subject: [PATCH 015/341] 8255548: Missing coverage for javax.xml.crypto.dom.DOMCryptoContext Backport-of: 76cda9f44a80b1979e6e1b7a21431ef631f80782 --- .../xml/crypto/dsig/GenerationTests.java | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/test/jdk/javax/xml/crypto/dsig/GenerationTests.java b/test/jdk/javax/xml/crypto/dsig/GenerationTests.java index 5f1e217ab8bd1..e78ec0243062e 100644 --- a/test/jdk/javax/xml/crypto/dsig/GenerationTests.java +++ b/test/jdk/javax/xml/crypto/dsig/GenerationTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, 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 @@ -31,6 +31,7 @@ * java.xml.crypto/org.jcp.xml.dsig.internal.dom * jdk.httpserver/com.sun.net.httpserver * @library /test/lib + * @build jdk.test.lib.Asserts * @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java * X509KeySelector.java GenerationTests.java * @run main/othervm/timeout=300 -Dsun.net.httpserver.nodelay=true GenerationTests @@ -93,6 +94,7 @@ import org.w3c.dom.*; import jdk.test.lib.security.SecurityUtils; +import jdk.test.lib.Asserts; /** * Test that recreates merlin-xmldsig-twenty-three test vectors (and more) @@ -292,6 +294,7 @@ public static void main(String args[]) throws Exception { SecurityUtils.removeAlgsFromDSigPolicy("sha1"); setup(); + test_context_iterator(); test_create_signature_enveloped_dsa(1024); test_create_signature_enveloped_dsa(2048); test_create_signature_enveloping_b64_dsa(); @@ -1886,6 +1889,48 @@ static boolean test_create_detached_signature0(String canonicalizationMethod, return true; } + static boolean test_context_iterator() throws Exception { + System.out.println("Testing context iterator() method."); + + Reference ref = fac.newReference("#object", + fac.newDigestMethod(DigestMethod.SHA512, null)); + SignedInfo si = fac.newSignedInfo(withoutComments, rsaSha512, + Collections.singletonList(ref)); + + Document doc = db.newDocument(); + XMLObject obj = fac.newXMLObject(Collections.singletonList( + new DOMStructure(doc.createTextNode("test text"))), "object", + null, null); + + DOMSignContext dsc = new DOMSignContext(signingKey, doc); + Asserts.assertNotNull(dsc.iterator()); + Asserts.assertFalse(dsc.iterator().hasNext()); + + String namespaceURI = "https://example.com/ns"; + String idAttrValue = "id1"; + String elementQualifiedName = "test:data"; + + Element elm = doc.createElementNS(namespaceURI, elementQualifiedName); + elm.setAttributeNS(namespaceURI, "test:id", idAttrValue); + dsc.setIdAttributeNS(elm, namespaceURI, "id"); + + Iterator> iter = dsc.iterator(); + Asserts.assertTrue(dsc.iterator().hasNext()); + + Map.Entry element = iter.next(); + Asserts.assertEquals(element.getKey(), idAttrValue); + Asserts.assertEquals(element.getValue().getNodeName(), elementQualifiedName); + + try { + iter.remove(); + throw new RuntimeException( + "The expected UnsupportedOperationException was not thrown."); + } catch (UnsupportedOperationException exc) { + // this is expected + } + return true; + } + private static Key[] getCachedKeys(String signatureMethod) { return cachedKeys.computeIfAbsent(signatureMethod, sm -> { try { From 762c351b6620ae1675276dd8b0fa2689c2e678ef Mon Sep 17 00:00:00 2001 From: Andrew Leonard Date: Thu, 10 Aug 2023 10:06:17 +0000 Subject: [PATCH 016/341] 8273092: Sort classlist in JDK image Reviewed-by: aph Backport-of: 1996f649a3a30b7ac4b547a762417f807f5fa414 --- make/GenerateLinkOptData.gmk | 7 +- .../build/tools/classlist/SortClasslist.java | 79 +++++++++++++++++++ make/scripts/compare.sh | 4 +- 3 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 make/jdk/src/classes/build/tools/classlist/SortClasslist.java diff --git a/make/GenerateLinkOptData.gmk b/make/GenerateLinkOptData.gmk index 0de28d643fc5f..5dd766c8c07df 100644 --- a/make/GenerateLinkOptData.gmk +++ b/make/GenerateLinkOptData.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. # 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,10 @@ $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXECUTABLE_SUFFIX) $(CLASSLIST $(CAT) $(LINK_OPT_DIR)/stderr $(JLI_TRACE_FILE) ; \ exit $$exitcode \ ) - $(GREP) -v HelloClasslist $@.raw.2 > $@ + $(GREP) -v HelloClasslist $@.raw.2 > $@.raw.3 + $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java \ + -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \ + build.tools.classlist.SortClasslist $@.raw.3 > $@ # The jli trace is created by the same recipe as classlist. By declaring these # dependencies, make will correctly rebuild both jli trace and classlist diff --git a/make/jdk/src/classes/build/tools/classlist/SortClasslist.java b/make/jdk/src/classes/build/tools/classlist/SortClasslist.java new file mode 100644 index 0000000000000..872d00c6d06b5 --- /dev/null +++ b/make/jdk/src/classes/build/tools/classlist/SortClasslist.java @@ -0,0 +1,79 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * This application is meant to be run to create a classlist file representing + * common use. + * + * The classlist is produced by adding -XX:DumpLoadedClassList=classlist + */ +package build.tools.classlist; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.regex.Pattern; +import java.util.regex.Matcher; +import java.util.Scanner; + +/** + * The classlist generated by build.tools.classlist.HelloClasslist + * may have non-deterministic contents, affected by Java thread execution order. + * SortClasslist sorts the file to make the JDK image's contents more deterministic. + */ +public class SortClasslist { + public static void main(String args[]) throws FileNotFoundException { + ArrayList classes = new ArrayList<>(); + ArrayList lambdas = new ArrayList<>(); + + FileInputStream fis = new FileInputStream(args[0]); + Scanner scanner = new Scanner(fis); + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + if (line.startsWith("#")) { + // Comments -- print them first without sorting. These appear only at the top + // of the file. + System.out.println(line); + } else if (line.startsWith("@")) { + // @lambda-form-invoker, @lambda-proxy, etc. + lambdas.add(line); + } else { + // Class name line + classes.add(line); + } + } + + Collections.sort(classes); + Collections.sort(lambdas); + + for (String s : classes) { + System.out.println(s); + } + for (String s : lambdas) { + System.out.println(s); + } + } +} diff --git a/make/scripts/compare.sh b/make/scripts/compare.sh index b33c80c784456..76c3a06840c61 100644 --- a/make/scripts/compare.sh +++ b/make/scripts/compare.sh @@ -357,8 +357,8 @@ compare_general_files() { " $CAT $OTHER_DIR/$f | eval "$SVG_FILTER" > $OTHER_FILE $CAT $THIS_DIR/$f | eval "$SVG_FILTER" > $THIS_FILE - elif [[ "$f" = *"/lib/classlist" ]] || [ "$SUFFIX" = "jar_contents" ]; then - # The classlist files may have some lines in random order + elif [ "$SUFFIX" = "jar_contents" ]; then + # The jar_contents files may have some lines in random order OTHER_FILE=$WORK_DIR/$f.other THIS_FILE=$WORK_DIR/$f.this $MKDIR -p $(dirname $OTHER_FILE) $(dirname $THIS_FILE) From 38204b0925a36dbcf6060796f15d17764b8383ed Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Thu, 10 Aug 2023 18:20:17 +0000 Subject: [PATCH 017/341] 8289646: configure script failed on WSL Backport-of: 3f1174aa4709aabcfde8b40deec88b8ed466cc06 --- make/scripts/fixpath.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/make/scripts/fixpath.sh b/make/scripts/fixpath.sh index 73672a1118f74..acbcd76dcbe67 100644 --- a/make/scripts/fixpath.sh +++ b/make/scripts/fixpath.sh @@ -148,14 +148,13 @@ function import_path() { if [[ "$path" != "" ]]; then # Store current unix path unixpath="$path" - # Now turn it into a windows path - winpath="$($PATHTOOL -w "$path" 2>/dev/null)" - # If it fails, try again with an added .exe (needed on WSL) - if [[ $? -ne 0 ]]; then + # If $unixpath does not exist, add .exe (needed on WSL) + if [[ ! -e "$unixpath" ]]; then unixpath="$unixpath.exe" - winpath="$($PATHTOOL -w "$unixpath" 2>/dev/null)" fi - if [[ $? -eq 0 ]]; then + # Now turn it into a windows path + winpath="$($PATHTOOL -w "$unixpath" 2>/dev/null)" + if [[ $? -eq 0 && -e "$unixpath" ]]; then if [[ ! "$winpath" =~ ^"$ENVROOT"\\.*$ ]] ; then # If it is not in envroot, it's a generic windows path if [[ ! $winpath =~ ^[-_.:\\a-zA-Z0-9]*$ ]] ; then From 8683db8853d083618e4538a3ef478e7bc3848681 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Fri, 11 Aug 2023 21:24:34 +0000 Subject: [PATCH 018/341] 8308232: nsk/jdb tests don't pass -verbose flag to the debuggee Backport-of: c6f20db945c6217aea84cebd6c97dbf8b93c48a4 --- test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java index d7aa6c30219ae..a960c7dfc810a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Launcher.java @@ -217,6 +217,10 @@ private String[] makeJdbCmdLine (String classToExecute) { } } String cmdline = classToExecute + " " + ArgumentHandler.joinArguments(argumentHandler.getArguments(), " "); + cmdline += " -waittime " + argumentHandler.getWaitTime(); + if (argumentHandler.verbose()) { + cmdline += " -verbose"; + } connect.append(",main=" + cmdline.trim()); } From 10942c1f2fab05f4d85a884faedfac5b95d2a7e5 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Fri, 11 Aug 2023 21:25:05 +0000 Subject: [PATCH 019/341] 8156889: ListKeychainStore.sh fails in some virtualized environments Backport-of: 82c8b28f4005c3c335d4fd60c2e3b55adfd200c6 --- test/jdk/ProblemList.txt | 2 - .../tools/keytool/ExportPrivateKeyNoPwd.java | 57 ----- .../tools/keytool/ListKeyChainStore.java | 202 ++++++++++++++++++ .../tools/keytool/ListKeychainStore.sh | 188 ---------------- 4 files changed, 202 insertions(+), 247 deletions(-) delete mode 100644 test/jdk/sun/security/tools/keytool/ExportPrivateKeyNoPwd.java create mode 100644 test/jdk/sun/security/tools/keytool/ListKeyChainStore.java delete mode 100644 test/jdk/sun/security/tools/keytool/ListKeychainStore.sh diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 3c00310762901..33af3a2bcff7f 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -635,8 +635,6 @@ com/sun/nio/sctp/SctpChannel/SocketOptionTests.java 8141694 linux-al sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic-all -sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-all - javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x64 sun/security/smartcardio/TestChannel.java 8039280 generic-all diff --git a/test/jdk/sun/security/tools/keytool/ExportPrivateKeyNoPwd.java b/test/jdk/sun/security/tools/keytool/ExportPrivateKeyNoPwd.java deleted file mode 100644 index 799bf455b23d0..0000000000000 --- a/test/jdk/sun/security/tools/keytool/ExportPrivateKeyNoPwd.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.security.*; - -/* - * Export a private key from the named keychain entry without supplying a - * password. See JDK-8062264. - * - * NOTE: Keychain access controls must already have been lowered to permit - * the target entry to be accessed. - */ -public class ExportPrivateKeyNoPwd { - - public static final void main(String[] args) throws Exception { - - if (args.length != 1) { - throw new Exception( - "ExportPrivateKeyNoPwd: must supply name of a keystore entry"); - } - String alias = args[0]; - - KeyStore ks = KeyStore.getInstance("KeychainStore"); - System.out.println("ExportPrivateKeyNoPwd: loading keychains..."); - ks.load(null, null); - - System.out.println("ExportPrivateKeyNoPwd: exporting key..."); - Key key = ks.getKey(alias, null); - if (key instanceof PrivateKey) { - System.out.println("ExportPrivateKeyNoPwd: exported " + - key.getAlgorithm() + " private key from '" + alias + "'"); - } else { - throw new Exception("Error exporting private key from keychain"); - } - } -} - diff --git a/test/jdk/sun/security/tools/keytool/ListKeyChainStore.java b/test/jdk/sun/security/tools/keytool/ListKeyChainStore.java new file mode 100644 index 0000000000000..39626b8dfc5b9 --- /dev/null +++ b/test/jdk/sun/security/tools/keytool/ListKeyChainStore.java @@ -0,0 +1,202 @@ +/* + * 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 + * 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 7133495 8062264 8046777 8153005 + * @summary KeyChain KeyStore implementation retrieves only one private key entry + * @requires (os.family == "mac") + * @library /test/lib + * @run main/othervm/manual ListKeyChainStore + */ + +import jdk.test.lib.SecurityTools; +import jdk.test.lib.process.ProcessTools; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.Key; +import java.security.KeyStore; +import java.security.PrivateKey; + +public class ListKeyChainStore { + private static final String PWD = "xxxxxx"; + private static final String DEFAULT_KEYTOOL = "-list -storetype KeychainStore " + + "-keystore NONE -storepass " + PWD; + private static final String USER_DIR = System.getProperty("user.dir", "."); + private static final String FS = System.getProperty("file.separator"); + private static final String PKCS12_KEYSTORE = USER_DIR + FS + "7133495.p12"; + private static final String KEYCHAIN_FILE = USER_DIR + FS + "7133495.keychain"; + private static final String TEMPORARY_FILE = USER_DIR + FS + "7133495.tmp"; + private static final String USER_KEYCHAIN_LIST = USER_DIR + FS + "user.keychain.list"; + private static final String PRIVATE_KEY_ENTRY = "PrivateKeyEntry"; + + public static void main(String[] args) throws Throwable { + LOG_MSG("WARNING: This test doesn't work on macOS virtualized environment. " + + "`security list-keychains -s` doesn't update the search order."); + + deleteTestTempFilesIfExists(); + + // Get the old security keychain list to restore later + try (PrintStream printStream = new PrintStream(USER_KEYCHAIN_LIST)) { + ProcessTools.executeCommand("sh", "-c", "security list-keychains") + .shouldHaveExitValue(0).outputTo(printStream); + } + + try { + try (PrintStream printStream = new PrintStream(TEMPORARY_FILE)) { + SecurityTools.keytool(DEFAULT_KEYTOOL).shouldHaveExitValue(0) + .outputTo(printStream); + } + int oldPrivateKeyCount = countOccurrences(TEMPORARY_FILE, PRIVATE_KEY_ENTRY); + LOG_MSG("Found " + oldPrivateKeyCount + " private key entries in the " + + "Keychain keystore"); + + // Create the PKCS12 keystore containing 3 public/private key pairs + LOG_MSG("Creating PKCS12 keystore: " + PKCS12_KEYSTORE); + for (int i = 0; i < 3; i++) { + // Use legacy encryption and MAC algorithms, refer macOS open radar FB8988319 + // macOS security framework doesn't work with the latest algorithms + SecurityTools.keytool(String.format("-J-Dkeystore.pkcs12.legacy -genkeypair" + + " -storetype PKCS12 -keystore %s -storepass %s -keyalg rsa -dname " + + "CN=CN%d,OU=OU%d,O=O%d,ST=ST%d,C=US -alias 7133495-%d", + PKCS12_KEYSTORE, PWD, i, i, i, i, i)).shouldHaveExitValue(0); + } + + // Create the keychain + LOG_MSG("Creating keychain: " + KEYCHAIN_FILE); + ProcessTools.executeCommand("sh", "-c", String.format("security create-keychain" + + " -p %s %s", PWD, KEYCHAIN_FILE)).shouldHaveExitValue(0); + + // Unlock the keychain + LOG_MSG("Unlock keychain: " + KEYCHAIN_FILE); + ProcessTools.executeCommand("sh", "-c", String.format("security unlock-keychain" + + " -p %s %s", PWD, KEYCHAIN_FILE)).shouldHaveExitValue(0); + + // Import the key pairs from the PKCS12 keystore into the keychain + // The '-A' option is used to lower the keychain's access controls + LOG_MSG("Importing the key pairs from " + PKCS12_KEYSTORE + + " to " + KEYCHAIN_FILE); + ProcessTools.executeCommand("sh", "-c", String.format("security import %s -k %s" + + " -f pkcs12 -P %s -A", PKCS12_KEYSTORE, KEYCHAIN_FILE, PWD)).shouldHaveExitValue(0); + + // Generate a 2048-bit RSA keypair and import into the keychain + // Its private key is configured with non-default key usage settings + ProcessTools.executeCommand("sh", "-c", String.format("certtool ca k=%s " + + "< " + msg); + } +} diff --git a/test/jdk/sun/security/tools/keytool/ListKeychainStore.sh b/test/jdk/sun/security/tools/keytool/ListKeychainStore.sh deleted file mode 100644 index 6ab1be900653b..0000000000000 --- a/test/jdk/sun/security/tools/keytool/ListKeychainStore.sh +++ /dev/null @@ -1,188 +0,0 @@ -# -# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. -# 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 7133495 8041740 8062264 8046777 -# @summary [macosx] KeyChain KeyStore implementation retrieves only one private key entry - -if [ "${TESTJAVA}" = "" ] ; then - JAVAC_CMD=`which javac` - TESTJAVA=`dirname $JAVAC_CMD`/.. -fi - -if [ "${TESTSRC}" = "" ] ; then - TESTSRC="." -fi -if [ "${TESTCLASSES}" = "" ] ; then - TESTCLASSES=`pwd` -fi - -# Only run on MacOS -OS=`uname -s` -case "$OS" in - Darwin ) - ;; - * ) - echo "Will not run test on: ${OS}" - exit 0; - ;; -esac - -PWD="xxxxxx" -KEYTOOL="${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -storetype KeychainStore -keystore NONE -storepass $PWD" -TEMPORARY_P12="$TESTCLASSES/7133495.p12" -TEMPORARY_KC="$TESTCLASSES/7133495.keychain" -TEMPORARY_LIST="$TESTCLASSES/7133495.tmp" -CLEANUP_P12="rm -f $TEMPORARY_P12" -CLEANUP_KC="security delete-keychain $TEMPORARY_KC" -CLEANUP_LIST="rm -f $TEMPORARY_LIST" - -# Count the number of private key entries in the Keychain keystores - -COUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l` -echo "Found $COUNT private key entries in the Keychain keystores" - -# Create a temporary PKCS12 keystore containing 3 public/private keypairs - -RESULT=`$CLEANUP_P12` - -for i in X Y Z -do - ${TESTJAVA}/bin/keytool ${TESTTOOLVMOPTS} -genkeypair \ - -storetype PKCS12 \ - -keystore $TEMPORARY_P12 \ - -storepass $PWD \ - -keyalg rsa \ - -dname "CN=$i,OU=$i,O=$i,ST=$i,C=US" \ - -alias 7133495-$i - - if [ $? -ne 0 ]; then - echo "Error: cannot create keypair $i in the temporary PKCS12 keystore" - RESULT=`$CLEANUP_P12` - exit 1 - fi -done -echo "Created a temporary PKCS12 keystore: $TEMPORARY_P12" - -# Create a temporary keychain - -security create-keychain -p $PWD $TEMPORARY_KC -if [ $? -ne 0 ]; then - echo "Error: cannot create the temporary keychain" - RESULT=`$CLEANUP_P12` - exit 2 -fi -echo "Created a temporary keychain: $TEMPORARY_KC" - -# Unlock the temporary keychain - -security unlock-keychain -p $PWD $TEMPORARY_KC -if [ $? -ne 0 ]; then - echo "Error: cannot unlock the temporary keychain" - RESULT=`$CLEANUP_P12` - RESULT=`$CLEANUP_KC` - exit 3 -fi -echo "Unlocked the temporary keychain" - -# Import the keypairs from the PKCS12 keystore into the keychain -# (The '-A' option is used to lower the temporary keychain's access controls) - -security import $TEMPORARY_P12 -k $TEMPORARY_KC -f pkcs12 -P $PWD -A -if [ $? -ne 0 ]; then - echo "Error: cannot import keypairs from PKCS12 keystore into the keychain" - RESULT=`$CLEANUP_P12` - RESULT=`$CLEANUP_KC` - exit 4 -fi -echo "Imported keypairs from PKCS12 keystore into the keychain" - -# Generate a 2048-bit RSA keypair and import into the temporary keychain -# (its private key is configured with non-default key usage settings) - -certtool c k=$TEMPORARY_KC < $TEMPORARY_LIST -security list-keychains >> $TEMPORARY_LIST -security list-keychains -s `xargs < ${TEMPORARY_LIST}` -`$CLEANUP_LIST` -echo "Temporary keychain search order:" -security list-keychains - -# Recount the number of private key entries in the Keychain keystores -# (3 private keys imported from PKCS12, 1 private key generated by 'certtool') - -RECOUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l` -echo "Found $RECOUNT private key entries in the Keychain keystore" -if [ $RECOUNT -lt `expr $COUNT + 4` ]; then - echo "Error: expected >$COUNT private key entries in the Keychain keystores" - RESULT=`$CLEANUP_P12` - RESULT=`$CLEANUP_KC` - exit 5 -fi - -# Export a private key from the keychain (without supplying a password) -# Access controls have already been lowered (see 'security import ... -A' above) - -${TESTJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/ExportPrivateKeyNoPwd.java || exit 6 -${TESTJAVA}/bin/java ${TESTVMOPTS} ExportPrivateKeyNoPwd x -if [ $? -ne 0 ]; then - echo "Error exporting private key from the temporary keychain" - RESULT=`$CLEANUP_P12` - RESULT=`$CLEANUP_KC` - exit 6 -fi -echo "Exported a private key from the temporary keychain" - -RESULT=`$CLEANUP_P12` -if [ $? -ne 0 ]; then - echo "Error: cannot remove the temporary PKCS12 keystore" - exit 7 -fi -echo "Removed the temporary PKCS12 keystore" - -RESULT=`$CLEANUP_KC` -if [ $? -ne 0 ]; then - echo "Error: cannot remove the temporary keychain" - exit 8 -fi -echo "Removed the temporary keychain" - -exit 0 From 6ab5177b81f86172a8a5f820f6ef63b6f1a9b175 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Fri, 11 Aug 2023 21:25:42 +0000 Subject: [PATCH 020/341] 8308090: Add container tests for on-the-fly resource quota updates Backport-of: dc8bc6c98ca1f9b441cf71c641675fe29dda9162 --- .../containers/docker/LimitUpdateChecker.java | 57 +++++++ .../containers/docker/TestLimitsUpdating.java | 148 +++++++++++++++++ .../platform/docker/LimitUpdateChecker.java | 64 +++++++ .../platform/docker/TestLimitsUpdating.java | 156 ++++++++++++++++++ .../containers/docker/DockerTestUtils.java | 10 +- 5 files changed, 432 insertions(+), 3 deletions(-) create mode 100644 test/hotspot/jtreg/containers/docker/LimitUpdateChecker.java create mode 100644 test/hotspot/jtreg/containers/docker/TestLimitsUpdating.java create mode 100644 test/jdk/jdk/internal/platform/docker/LimitUpdateChecker.java create mode 100644 test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java diff --git a/test/hotspot/jtreg/containers/docker/LimitUpdateChecker.java b/test/hotspot/jtreg/containers/docker/LimitUpdateChecker.java new file mode 100644 index 0000000000000..f8c971b48177a --- /dev/null +++ b/test/hotspot/jtreg/containers/docker/LimitUpdateChecker.java @@ -0,0 +1,57 @@ +/* + * 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. + */ + +import java.io.File; +import java.io.FileOutputStream; +import jdk.test.whitebox.WhiteBox; + +// Check dynamic limits updating. HotSpot side. +public class LimitUpdateChecker { + + private static final File UPDATE_FILE = new File("/tmp", "limitsUpdated"); + private static final File STARTED_FILE = new File("/tmp", "started"); + + public static void main(String[] args) throws Exception { + System.out.println("LimitUpdateChecker: Entering"); + WhiteBox wb = WhiteBox.getWhiteBox(); + printMetrics(wb); // print initial limits + createStartedFile(); + while (!UPDATE_FILE.exists()) { + Thread.sleep(200); + } + System.out.println("'limitsUpdated' file appeared. Stopped loop."); + printMetrics(wb); // print limits after update + System.out.println("LimitUpdateChecker DONE."); + + } + + private static void printMetrics(WhiteBox wb) { + wb.printOsInfo(); + } + + private static void createStartedFile() throws Exception { + FileOutputStream fout = new FileOutputStream(STARTED_FILE); + fout.close(); + } +} diff --git a/test/hotspot/jtreg/containers/docker/TestLimitsUpdating.java b/test/hotspot/jtreg/containers/docker/TestLimitsUpdating.java new file mode 100644 index 0000000000000..e15ab9b2b81fa --- /dev/null +++ b/test/hotspot/jtreg/containers/docker/TestLimitsUpdating.java @@ -0,0 +1,148 @@ +/* + * 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 + * @bug 8308090 + * @key cgroups + * @summary Test container limits updating as they get updated at runtime without restart + * @requires docker.support + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox LimitUpdateChecker + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox + * @run driver TestLimitsUpdating + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.util.List; +import java.util.regex.Pattern; +import java.util.regex.Matcher; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; +import jdk.test.lib.containers.docker.Common; +import jdk.test.lib.containers.docker.DockerRunOptions; +import jdk.test.lib.containers.docker.DockerTestUtils; +import jdk.test.lib.process.OutputAnalyzer; + +public class TestLimitsUpdating { + private static final String TARGET_CONTAINER = "limitsUpdatingHS_" + Runtime.getRuntime().version().major(); + private static final String imageName = Common.imageName("limitsUpdating"); + + public static void main(String[] args) throws Exception { + if (!DockerTestUtils.canTestDocker()) { + return; + } + + Common.prepareWhiteBox(); + DockerTestUtils.buildJdkContainerImage(imageName); + + try { + testLimitUpdates(); + } finally { + if (!DockerTestUtils.RETAIN_IMAGE_AFTER_TEST) { + DockerTestUtils.removeDockerImage(imageName); + } + } + } + + private static void testLimitUpdates() throws Exception { + File sharedtmpdir = new File("test-sharedtmp"); + File flag = new File(sharedtmpdir, "limitsUpdated"); // shared with LimitUpdateChecker + File started = new File(sharedtmpdir, "started"); // shared with LimitUpdateChecker + sharedtmpdir.mkdir(); + flag.delete(); + started.delete(); + DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java", "LimitUpdateChecker"); + opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/"); + opts.addDockerOpts("--volume", sharedtmpdir.getAbsolutePath() + ":/tmp"); + opts.addDockerOpts("--cpu-period", "100000"); + opts.addDockerOpts("--cpu-quota", "200000"); + opts.addDockerOpts("--memory", "500m"); + opts.addDockerOpts("--memory-swap", "500m"); + opts.addDockerOpts("--name", TARGET_CONTAINER); + opts.addJavaOpts("-cp", "/test-classes/"); + Common.addWhiteBoxOpts(opts); + final OutputAnalyzer out[] = new OutputAnalyzer[1]; + Thread t1 = new Thread() { + public void run() { + try { + out[0] = DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0); + } catch (Exception e) { + e.printStackTrace(); + } + } + }; + t1.start(); + + // Wait for target container (that we later update) to complete its + // initial starting-up phase. Prints initial container limits. + while (!started.exists()) { + System.out.println("Wait for target container to start"); + Thread.sleep(100); + } + + final List containerCommand = getContainerUpdate(300_000, 100_000, "300m"); + // Run the update command so as to increase resources once the container signaled it has started. + Thread t2 = new Thread() { + public void run() { + try { + DockerTestUtils.execute(containerCommand).shouldHaveExitValue(0); + } catch (Exception e) { + e.printStackTrace(); + } + } + }; + t2.start(); + t2.join(); + + // Set the flag for the to-get updated container, indicating the update + // has completed. + FileOutputStream fout = new FileOutputStream(flag); + fout.close(); + + t1.join(); + + // Do assertions based on the output in target container + OutputAnalyzer targetOut = out[0]; + targetOut.shouldContain("active_processor_count: 2"); // initial value + targetOut.shouldContain("active_processor_count: 3"); // updated value + targetOut.shouldContain("memory_limit_in_bytes: 512000 k"); // initial value + targetOut.shouldContain("memory_and_swap_limit_in_bytes: 512000 k"); // initial value + targetOut.shouldContain("memory_limit_in_bytes: 307200 k"); // updated value + targetOut.shouldContain("memory_and_swap_limit_in_bytes: 307200 k"); // updated value + } + + private static List getContainerUpdate(int cpuQuota, int cpuPeriod, String memory) { + List cmd = DockerTestUtils.buildContainerCommand(); + cmd.add("update"); + cmd.add("--cpu-period=" + cpuPeriod); + cmd.add("--cpu-quota=" + cpuQuota); + cmd.add("--memory=" + memory); + cmd.add("--memory-swap=" + memory); // no swap + cmd.add(TARGET_CONTAINER); + return cmd; + } +} diff --git a/test/jdk/jdk/internal/platform/docker/LimitUpdateChecker.java b/test/jdk/jdk/internal/platform/docker/LimitUpdateChecker.java new file mode 100644 index 0000000000000..cb570b757cd5c --- /dev/null +++ b/test/jdk/jdk/internal/platform/docker/LimitUpdateChecker.java @@ -0,0 +1,64 @@ +/* + * 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. + */ + +import java.io.File; +import java.io.FileOutputStream; +import com.sun.management.OperatingSystemMXBean; +import java.lang.management.ManagementFactory; +import jdk.internal.platform.Metrics; + + +// Check dynamic limits updating. Metrics (java) side. +public class LimitUpdateChecker { + + private static final File UPDATE_FILE = new File("/tmp", "limitsUpdated"); + private static final File STARTED_FILE = new File("/tmp", "started"); + + public static void main(String[] args) throws Exception { + System.out.println("Running LimitUpdateChecker..."); + Metrics metrics = jdk.internal.platform.Container.metrics(); + OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); + printMetrics(osBean, metrics); // initial limits + createStartedFile(); + while (!UPDATE_FILE.exists()) { + Thread.sleep(200); + } + System.out.println("'limitsUpdated' file appeared. Stopped loop."); + printMetrics(osBean, metrics); // updated limits + System.out.println("LimitUpdateChecker DONE."); + } + + private static void printMetrics(OperatingSystemMXBean osBean, Metrics metrics) { + System.out.println(String.format("Runtime.availableProcessors: %d", Runtime.getRuntime().availableProcessors())); + System.out.println(String.format("OperatingSystemMXBean.getAvailableProcessors: %d", osBean.getAvailableProcessors())); + System.out.println("Metrics.getMemoryLimit() == " + metrics.getMemoryLimit()); + System.out.println(String.format("OperatingSystemMXBean.getTotalMemorySize: %d", osBean.getTotalMemorySize())); + } + + private static void createStartedFile() throws Exception { + FileOutputStream fout = new FileOutputStream(STARTED_FILE); + fout.close(); + } + +} diff --git a/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java b/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java new file mode 100644 index 0000000000000..22e03293c486e --- /dev/null +++ b/test/jdk/jdk/internal/platform/docker/TestLimitsUpdating.java @@ -0,0 +1,156 @@ +/* + * 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 + * @bug 8308090 + * @key cgroups + * @summary Test container limits updating as they get updated at runtime without restart + * @requires docker.support + * @library /test/lib + * @modules java.base/jdk.internal.platform + * @build LimitUpdateChecker + * @run driver TestLimitsUpdating + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.util.List; +import java.util.regex.Pattern; +import java.util.regex.Matcher; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; +import jdk.test.lib.containers.docker.Common; +import jdk.test.lib.containers.docker.DockerRunOptions; +import jdk.test.lib.containers.docker.DockerTestUtils; +import jdk.test.lib.process.OutputAnalyzer; + +public class TestLimitsUpdating { + private static final long M = 1024 * 1024; + private static final String TARGET_CONTAINER = "limitsUpdatingJDK_" + Runtime.getRuntime().version().major(); + private static final String imageName = Common.imageName("limitsUpdatingJDK"); + + public static void main(String[] args) throws Exception { + if (!DockerTestUtils.canTestDocker()) { + return; + } + + DockerTestUtils.buildJdkContainerImage(imageName); + + try { + testLimitUpdates(); + } finally { + if (!DockerTestUtils.RETAIN_IMAGE_AFTER_TEST) { + DockerTestUtils.removeDockerImage(imageName); + } + } + } + + private static void testLimitUpdates() throws Exception { + File sharedtmpdir = new File("jdk-sharedtmp"); + File flag = new File(sharedtmpdir, "limitsUpdated"); // shared with LimitUpdateChecker + File started = new File(sharedtmpdir, "started"); // shared with LimitUpdateChecker + sharedtmpdir.mkdir(); + flag.delete(); + started.delete(); + DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java", "LimitUpdateChecker"); + opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/"); + opts.addDockerOpts("--volume", sharedtmpdir.getAbsolutePath() + ":/tmp"); + opts.addDockerOpts("--cpu-period", "100000"); + opts.addDockerOpts("--cpu-quota", "200000"); + opts.addDockerOpts("--memory", "500m"); + opts.addDockerOpts("--memory-swap", "500m"); + opts.addDockerOpts("--name", TARGET_CONTAINER); + opts.addJavaOpts("-cp", "/test-classes/"); + // LimitUpdateChecker uses Metrics (jdk.internal.platform) for + // printing JDK container limits + opts.addJavaOpts("--add-exports"); + opts.addJavaOpts("java.base/jdk.internal.platform=ALL-UNNAMED"); + final OutputAnalyzer out[] = new OutputAnalyzer[1]; + Thread t1 = new Thread() { + public void run() { + try { + out[0] = DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0); + } catch (Exception e) { + e.printStackTrace(); + } + } + }; + t1.start(); + + // Wait for target container (that we later update) to complete its + // initial starting-up phase. Prints initial container limits using + // OS MXBean and Metrics API + while (!started.exists()) { + System.out.println("Wait for target container to start"); + Thread.sleep(100); + } + + final List containerCommand = getContainerUpdate(300_000, 100_000, "300m"); + // Run the update command so as to increase resources once the container signaled it has started. + Thread t2 = new Thread() { + public void run() { + try { + DockerTestUtils.execute(containerCommand).shouldHaveExitValue(0); + } catch (Exception e) { + e.printStackTrace(); + } + } + }; + t2.start(); + t2.join(); + + // Set the flag for the to-get updated container, indicating the update + // has completed. + FileOutputStream fout = new FileOutputStream(flag); + fout.close(); + + t1.join(); + + // Do assertions based on the output in target container + OutputAnalyzer targetOut = out[0]; + targetOut.shouldContain("Runtime.availableProcessors: 2"); // initial value + targetOut.shouldContain("OperatingSystemMXBean.getAvailableProcessors: 2"); // initial value + targetOut.shouldContain("Runtime.availableProcessors: 3"); // updated value + targetOut.shouldContain("OperatingSystemMXBean.getAvailableProcessors: 3"); // updated value + long memoryInBytes = 500 * M; + targetOut.shouldContain("Metrics.getMemoryLimit() == " + memoryInBytes); // initial value + targetOut.shouldContain("OperatingSystemMXBean.getTotalMemorySize: " + memoryInBytes); // initial value + long updatedValue = 300 * M; + targetOut.shouldContain("Metrics.getMemoryLimit() == " + updatedValue); // updated value + targetOut.shouldContain("OperatingSystemMXBean.getTotalMemorySize: " + updatedValue); // updated value + } + + private static List getContainerUpdate(int cpuQuota, int cpuPeriod, String memory) { + List cmd = DockerTestUtils.buildContainerCommand(); + cmd.add("update"); + cmd.add("--cpu-period=" + cpuPeriod); + cmd.add("--cpu-quota=" + cpuQuota); + cmd.add("--memory=" + memory); + cmd.add("--memory-swap=" + memory); // no swap + cmd.add(TARGET_CONTAINER); + return cmd; + } +} diff --git a/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java b/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java index 057348fb82b54..091fe8811cefa 100644 --- a/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java +++ b/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java @@ -202,9 +202,7 @@ private static void buildImage(String imageName, Path buildDir) throws Exception * @throws Exception */ public static List buildJavaCommand(DockerRunOptions opts) throws Exception { - List cmd = new ArrayList<>(); - - cmd.add(Container.ENGINE_COMMAND); + List cmd = buildContainerCommand(); cmd.add("run"); if (opts.tty) cmd.add("--tty=true"); @@ -227,6 +225,12 @@ public static List buildJavaCommand(DockerRunOptions opts) throws Except return cmd; } + public static List buildContainerCommand() { + List cmd = new ArrayList<>(); + cmd.add(Container.ENGINE_COMMAND); + return cmd; + } + /** * Run Java inside the docker image with specified parameters and options. * From d7b3306bce0d9d5f85472763e1ce9e1b7a8f8953 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Fri, 11 Aug 2023 21:26:18 +0000 Subject: [PATCH 021/341] 8310551: vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001.java timed out due to missing prompt Backport-of: c84866ac0dcda487fe2abc2a8841f237df0a395b --- .../nsk/jdb/interrupt/interrupt001/interrupt001.java | 4 ++-- .../nsk/jdb/interrupt/interrupt001/interrupt001a.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001.java index a2d46e4ac15be..73f251b71e998 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2020, 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 @@ -89,7 +89,7 @@ public static int run(String argv[], PrintStream out) { static final String LAST_BREAK = DEBUGGEE_CLASS + ".breakHere"; static final String MYTHREAD = "MyThread"; static final String DEBUGGEE_THREAD = DEBUGGEE_CLASS + "$" + MYTHREAD; - static final String DEBUGGEE_RESULT = DEBUGGEE_CLASS + ".notInterrupted.get()"; + static final String DEBUGGEE_RESULT = DEBUGGEE_CLASS + ".notInterrupted"; static int numThreads = nsk.jdb.interrupt.interrupt001.interrupt001a.numThreads; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001a.java index 973ee4974cd63..25016ce0f3763 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdb/interrupt/interrupt001/interrupt001a.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 @@ -56,8 +56,8 @@ public void run() { lock.wait(); } } catch (InterruptedException e) { - notInterrupted.decrementAndGet(); synchronized (waitnotify) { + notInterrupted--; waitnotify.notify(); } } @@ -83,7 +83,7 @@ static void breakHere () {} private JdbArgumentHandler argumentHandler; private Log log; - public static final AtomicInteger notInterrupted = new AtomicInteger(numThreads); + public static volatile int notInterrupted = numThreads; public int runIt(String args[], PrintStream out) { @@ -122,8 +122,8 @@ public int runIt(String args[], PrintStream out) { long waitTime = argumentHandler.getWaitTime() * 60 * 1000; long startTime = System.currentTimeMillis(); - while (notInterrupted.get() > 0 && System.currentTimeMillis() - startTime <= waitTime) { - synchronized (waitnotify) { + synchronized (waitnotify) { + while (notInterrupted > 0 && System.currentTimeMillis() - startTime <= waitTime) { try { waitnotify.wait(waitTime); } catch (InterruptedException e) { From 260f28761a87553fd634615df5ba3db5b76ae692 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 14 Aug 2023 08:11:33 +0000 Subject: [PATCH 022/341] 8293107: GHA: Bump to Ubuntu 22.04 8293098: GHA: Harmonize GCC version handling for host and cross builds 8293361: GHA: dump config.log in case of configure failure 8295213: Run GHA manually with user-specified make and configure arguments 8313428: GHA: Bump GCC versions for July 2023 updates 8313707: GHA: Bootstrap sysroots with --variant=minbase Reviewed-by: clanger Backport-of: d7536588b38e368eaa6395bcbcc6724a39303fc5 --- .github/workflows/build-cross-compile.yml | 31 ++++++++---- .github/workflows/build-linux.yml | 26 ++++++++-- .github/workflows/build-macos.yml | 13 ++++- .github/workflows/build-windows.yml | 13 ++++- .github/workflows/main.yml | 59 +++++++++++++++++++---- 5 files changed, 113 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index d4a31714d73c2..d698d8ccab539 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -29,17 +29,23 @@ on: workflow_call: inputs: gcc-major-version: - required: false + required: true type: string - default: '10' apt-gcc-version: + required: true + type: string + apt-gcc-cross-version: + required: true + type: string + extra-conf-options: + required: false + type: string + configure-arguments: required: false type: string - default: '10.4.0-4ubuntu1~22.04' - apt-gcc-cross-suffix: + make-arguments: required: false type: string - default: 'cross1' jobs: build-cross-compile: @@ -109,8 +115,8 @@ jobs: sudo apt-get install \ gcc-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ g++-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ - gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-version }}${{ inputs.apt-gcc-cross-suffix }} \ - g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-version }}${{ inputs.apt-gcc-cross-suffix }} \ + gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ + g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ libxrandr-dev libxtst-dev libcups2-dev libasound2-dev sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }} @@ -132,6 +138,7 @@ jobs: --verbose --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev --resolve-deps + --variant=minbase ${{ matrix.debian-version }} sysroot ${{ matrix.debian-repository }} @@ -157,12 +164,16 @@ jobs: --openjdk-target=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} --with-sysroot=sysroot --with-build-jdk=${{ steps.buildjdk.outputs.jdk-path }} - CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-10 - CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-10 + CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-${{ inputs.gcc-major-version }} + CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-${{ inputs.gcc-major-version }} + ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( + echo "Dumping config.log:" && + cat config.log && + exit 1) - name: 'Build' id: build uses: ./.github/actions/do-build with: - make-target: 'hotspot' + make-target: 'hotspot ${{ inputs.make-arguments }}' platform: linux-${{ matrix.target-cpu }} diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 5b1a6e87280ad..2f6368123d956 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -42,6 +42,13 @@ on: required: false type: string default: '[ "debug", "release" ]' + gcc-major-version: + required: true + type: string + gcc-package-suffix: + required: false + type: string + default: '' apt-gcc-version: required: true type: string @@ -51,11 +58,17 @@ on: apt-extra-packages: required: false type: string + configure-arguments: + required: false + type: string + make-arguments: + required: false + type: string jobs: build-linux: name: build - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false @@ -101,8 +114,8 @@ jobs: fi sudo apt-get update sudo apt-get install --only-upgrade apt - sudo apt-get install gcc-${{ inputs.apt-gcc-version }} g++-${{ inputs.apt-gcc-version }} libxrandr-dev${{ steps.arch.outputs.suffix }} libxtst-dev${{ steps.arch.outputs.suffix }} libcups2-dev${{ steps.arch.outputs.suffix }} libasound2-dev${{ steps.arch.outputs.suffix }} ${{ inputs.apt-extra-packages }} - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 + sudo apt-get install gcc-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }}=${{ inputs.apt-gcc-version }} g++-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }}=${{ inputs.apt-gcc-version }} libxrandr-dev${{ steps.arch.outputs.suffix }} libxtst-dev${{ steps.arch.outputs.suffix }} libcups2-dev${{ steps.arch.outputs.suffix }} libasound2-dev${{ steps.arch.outputs.suffix }} ${{ inputs.apt-extra-packages }} + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }} - name: 'Configure' run: > @@ -115,13 +128,16 @@ jobs: --with-gtest=${{ steps.gtest.outputs.path }} --enable-jtreg-failure-handler --with-zlib=system - ${{ inputs.extra-conf-options }} + ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( + echo "Dumping config.log:" && + cat config.log && + exit 1) - name: 'Build' id: build uses: ./.github/actions/do-build with: - make-target: '${{ inputs.make-target }}' + make-target: '${{ inputs.make-target }} ${{ inputs.make-arguments }}' platform: ${{ inputs.platform }} debug-suffix: '${{ matrix.suffix }}' diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index a19dcc3140d6d..80bd181867f7f 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -45,6 +45,12 @@ on: xcode-toolset-version: required: true type: string + configure-arguments: + required: false + type: string + make-arguments: + required: false + type: string jobs: build-macos: @@ -97,13 +103,16 @@ jobs: --with-gtest=${{ steps.gtest.outputs.path }} --enable-jtreg-failure-handler --with-zlib=system - ${{ inputs.extra-conf-options }} + ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( + echo "Dumping config.log:" && + cat config.log && + exit 1) - name: 'Build' id: build uses: ./.github/actions/do-build with: - make-target: '${{ inputs.make-target }}' + make-target: '${{ inputs.make-target }} ${{ inputs.make-arguments }}' platform: ${{ inputs.platform }} debug-suffix: '${{ matrix.suffix }}' diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index d8ff96712596c..121d683c715f4 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -48,6 +48,12 @@ on: msvc-toolset-architecture: required: true type: string + configure-arguments: + required: false + type: string + make-arguments: + required: false + type: string env: # These are needed to make the MSYS2 bash work properly @@ -124,7 +130,10 @@ jobs: --with-gtest=${{ steps.gtest.outputs.path }} --enable-jtreg-failure-handler --with-msvc-toolset-version=${{ inputs.msvc-toolset-version }} - ${{ inputs.extra-conf-options }} + ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( + echo "Dumping config.log:" && + cat config.log && + exit 1) env: # We need a minimal PATH on Windows # Set PATH to "", so just GITHUB_PATH is included @@ -134,7 +143,7 @@ jobs: id: build uses: ./.github/actions/do-build with: - make-target: '${{ inputs.make-target }}' + make-target: '${{ inputs.make-target }} ${{ inputs.make-arguments }}' platform: ${{ inputs.platform }} debug-suffix: '${{ matrix.suffix }}' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b67dbad62409c..421d3bfb056f6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,6 +36,12 @@ on: description: 'Platform(s) to execute on (comma separated, e.g. "linux-x64, macos, aarch64")' required: true default: 'linux-x64, linux-x86, linux-x64-variants, linux-cross-compile, macos-x64, macos-aarch64, windows-x64, windows-aarch64' + configure-arguments: + description: 'Additional configure arguments' + required: false + make-arguments: + description: 'Additional make arguments' + required: false concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -49,7 +55,7 @@ jobs: select: name: 'Select platforms' - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 outputs: linux-x64: ${{ steps.include.outputs.linux-x64 }} linux-x86: ${{ steps.include.outputs.linux-x86 }} @@ -121,7 +127,10 @@ jobs: uses: ./.github/workflows/build-linux.yml with: platform: linux-x64 - apt-gcc-version: '10=10.3.0-1ubuntu1~20.04' + gcc-major-version: '10' + apt-gcc-version: '10.5.0-1ubuntu1~22.04' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} # The linux-x64 jdk bundle is used as buildjdk for the cross-compile job if: needs.select.outputs.linux-x64 == 'true' || needs.select.outputs.linux-cross-compile == 'true' @@ -131,12 +140,16 @@ jobs: uses: ./.github/workflows/build-linux.yml with: platform: linux-x86 - apt-gcc-version: '10-multilib' + gcc-major-version: '10' + gcc-package-suffix: '-multilib' + apt-gcc-version: '10.5.0-1ubuntu1~22.04' apt-architecture: 'i386' # Some multilib libraries do not have proper inter-dependencies, so we have to # install their dependencies manually. apt-extra-packages: 'libfreetype6-dev:i386 libtiff-dev:i386 libcupsimage2-dev:i386' extra-conf-options: '--with-target-bits=32' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.linux-x86 == 'true' build-linux-x64-hs-nopch: @@ -147,8 +160,11 @@ jobs: platform: linux-x64 make-target: 'hotspot' debug-levels: '[ "debug" ]' - apt-gcc-version: '10=10.3.0-1ubuntu1~20.04' + gcc-major-version: '10' + apt-gcc-version: '10.5.0-1ubuntu1~22.04' extra-conf-options: '--disable-precompiled-headers' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.linux-x64-variants == 'true' build-linux-x64-hs-zero: @@ -159,8 +175,11 @@ jobs: platform: linux-x64 make-target: 'hotspot' debug-levels: '[ "debug" ]' - apt-gcc-version: '10=10.3.0-1ubuntu1~20.04' + gcc-major-version: '10' + apt-gcc-version: '10.5.0-1ubuntu1~22.04' extra-conf-options: '--with-jvm-variants=zero --disable-precompiled-headers' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.linux-x64-variants == 'true' build-linux-x64-hs-minimal: @@ -171,8 +190,11 @@ jobs: platform: linux-x64 make-target: 'hotspot' debug-levels: '[ "debug" ]' - apt-gcc-version: '10=10.3.0-1ubuntu1~20.04' + gcc-major-version: '10' + apt-gcc-version: '10.5.0-1ubuntu1~22.04' extra-conf-options: '--with-jvm-variants=minimal --disable-precompiled-headers' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.linux-x64-variants == 'true' build-linux-x64-hs-optimized: @@ -184,8 +206,11 @@ jobs: make-target: 'hotspot' # Technically this is not the "debug" level, but we can't inject a new matrix state for just this job debug-levels: '[ "debug" ]' - apt-gcc-version: '10=10.3.0-1ubuntu1~20.04' + gcc-major-version: '10' + apt-gcc-version: '10.5.0-1ubuntu1~22.04' extra-conf-options: '--with-debug-level=optimized --disable-precompiled-headers' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.linux-x64-variants == 'true' build-linux-cross-compile: @@ -194,6 +219,12 @@ jobs: - select - build-linux-x64 uses: ./.github/workflows/build-cross-compile.yml + with: + gcc-major-version: '10' + apt-gcc-version: '10.5.0-1ubuntu1~22.04' + apt-gcc-cross-version: '10.5.0-1ubuntu1~22.04cross1' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.linux-cross-compile == 'true' build-macos-x64: @@ -203,6 +234,8 @@ jobs: with: platform: macos-x64 xcode-toolset-version: '12.5.1' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.macos-x64 == 'true' build-macos-aarch64: @@ -213,6 +246,8 @@ jobs: platform: macos-aarch64 xcode-toolset-version: '12.5.1' extra-conf-options: '--openjdk-target=aarch64-apple-darwin' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.macos-aarch64 == 'true' build-windows-x64: @@ -223,6 +258,8 @@ jobs: platform: windows-x64 msvc-toolset-version: '14.29' msvc-toolset-architecture: 'x86.x64' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.windows-x64 == 'true' build-windows-aarch64: @@ -235,6 +272,8 @@ jobs: msvc-toolset-architecture: 'arm64' make-target: 'hotspot' extra-conf-options: '--openjdk-target=aarch64-unknown-cygwin' + configure-arguments: ${{ github.event.inputs.configure-arguments }} + make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.windows-aarch64 == 'true' ### @@ -249,7 +288,7 @@ jobs: with: platform: linux-x64 bootjdk-platform: linux-x64 - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 test-linux-x86: name: linux-x86 @@ -259,7 +298,7 @@ jobs: with: platform: linux-x86 bootjdk-platform: linux-x64 - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 test-macos-x64: name: macos-x64 @@ -284,7 +323,7 @@ jobs: # Remove bundles so they are not misconstrued as binary distributions from the JDK project remove-bundles: name: 'Remove bundle artifacts' - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 if: always() needs: - build-linux-x64 From 6e6bddffe84e962e532d9a79639082615ccc318e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 14 Aug 2023 08:19:36 +0000 Subject: [PATCH 023/341] 8297350: Update JMH devkit to 1.36 Backport-of: f26bd4e0e8b68de297a9ff93526cd7fac8668320 --- make/devkit/createJMHBundle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/devkit/createJMHBundle.sh b/make/devkit/createJMHBundle.sh index 5744863958c2e..904aefa82d336 100644 --- a/make/devkit/createJMHBundle.sh +++ b/make/devkit/createJMHBundle.sh @@ -26,7 +26,7 @@ # Create a bundle in the build directory, containing what's needed to # build and run JMH microbenchmarks from the OpenJDK build. -JMH_VERSION=1.35 +JMH_VERSION=1.36 COMMONS_MATH3_VERSION=3.2 JOPT_SIMPLE_VERSION=4.6 From ca0f148681114b64ba0b40ea77b89a5e9bc68657 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Mon, 14 Aug 2023 14:11:19 +0000 Subject: [PATCH 024/341] 8309088: security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.java fails Backport-of: 4c2e54fb055bee0af5cd838fdd32a0f7902d51e3 --- .../certification/AmazonCA.java | 810 ++++++++++-------- 1 file changed, 461 insertions(+), 349 deletions(-) diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.java index 3232be7b170d4..dec0ff8872a08 100644 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.java +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.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 @@ -51,266 +51,325 @@ public class AmazonCA { public static void main(String[] args) throws Exception { ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - boolean ocspEnabled = false; if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { pathValidator.enableCRLCheck(); } else { // OCSP check by default pathValidator.enableOCSPCheck(); - ocspEnabled = true; } - new AmazonCA_1().runTest(pathValidator, ocspEnabled); - new AmazonCA_2().runTest(pathValidator, ocspEnabled); - new AmazonCA_3().runTest(pathValidator, ocspEnabled); - new AmazonCA_4().runTest(pathValidator, ocspEnabled); + new AmazonCA_1().runTest(pathValidator); + new AmazonCA_2().runTest(pathValidator); + new AmazonCA_3().runTest(pathValidator); + new AmazonCA_4().runTest(pathValidator); } } class AmazonCA_1 { - // Owner: CN=Amazon, OU=Server CA 1A, O=Amazon, C=US + // Owner: CN=Amazon RSA 2048 M02, O=Amazon, C=US // Issuer: CN=Amazon Root CA 1, O=Amazon, C=US - // Serial number: 67f9457508c648c09ca652e71791830e72592 - // Valid from: Wed Oct 21 17:00:00 PDT 2015 until: Sat Oct 18 17:00:00 PDT 2025 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIERzCCAy+gAwIBAgITBn+UV1CMZIwJymUucXkYMOclkjANBgkqhkiG9w0BAQsF\n" + + // Serial number: 773124a4bcbd44ec7b53beaf194842d3a0fa1 + // Valid from: Tue Aug 23 15:25:30 PDT 2022 until: Fri Aug 23 15:25:30 PDT 2030 + private static final String INT_VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIEXjCCA0agAwIBAgITB3MSSkvL1E7HtTvq8ZSELToPoTANBgkqhkiG9w0BAQsF\n" + + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + + "b24gUm9vdCBDQSAxMB4XDTIyMDgyMzIyMjUzMFoXDTMwMDgyMzIyMjUzMFowPDEL\n" + + "MAkGA1UEBhMCVVMxDzANBgNVBAo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R8RV53PtR6r/6gNpqlzdo\n" + + "Zq4FKbADi1v9Bun8RY8D51uedRfjsbeodizeBB8nXmeyD33Ep7VATj4ozcd31YFV\n" + + "fgRhvTSxNrrTlNpWkUk0m3BMPv8sg381HhA6uEYokE5q9uws/3YkKqRiEz3TsaWm\n" + + "JqIRZhMbgAfp7O7FUwFIb7UIspogZSKxPIWJpxiPo3TcBambbVtQOcNRWz5qCQdD\n" + + "slI2yayq0n2TXoHyNCLEH8rpsJRVILFsg0jc7BaFrMnF462+ajSehgj12IidNeRN\n" + + "4zl+EoNaWdpnWndvSpAEkq2P\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Amazon RSA 2048 M01, O=Amazon, C=US + // Issuer: CN=Amazon Root CA 1, O=Amazon, C=US + // Serial number: 77312380b9d6688a33b1ed9bf9ccda68e0e0f + // Valid from: Tue Aug 23 15:21:28 PDT 2022 until: Fri Aug 23 15:21:28 PDT 2030 + private static final String INT_REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIEXjCCA0agAwIBAgITB3MSOAudZoijOx7Zv5zNpo4ODzANBgkqhkiG9w0BAQsF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + - "b24gUm9vdCBDQSAxMB4XDTE1MTAyMjAwMDAwMFoXDTI1MTAxOTAwMDAwMFowRjEL\n" + - "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEVMBMGA1UECxMMU2VydmVyIENB\n" + - "IDFBMQ8wDQYDVQQDEwZBbWF6b24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK\n" + - "AoIBAQCeQM3XCsIZunv8bSJxOqkc/ed87uL76FDB7teBNThDRB+1J7aITuadbNfH\n" + - "5ZfZykrdZ1qQLKxP6DwHOmJr9u2b4IxjUX9qUMuq4B02ghD2g6yU3YivEosZ7fpo\n" + - "srD2TBN29JpgPGrOrpOE+ArZuIpBjdKFinemu6fTDD0N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QMMAowCAYGZ4EMAQIBMA0GCSqGSIb3DQEBCwUAA4IB\n" + + "AQCtAN4CBSMuBjJitGuxlBbkEUDeK/pZwTXv4KqPK0G50fOHOQAd8j21p0cMBgbG\n" + + "kfMHVwLU7b0XwZCav0h1ogdPMN1KakK1DT0VwA/+hFvGPJnMV1Kx2G4S1ZaSk0uU\n" + + "5QfoiYIIano01J5k4T2HapKQmmOhS/iPtuo00wW+IMLeBuKMn3OLn005hcrOGTad\n" + + "hcmeyfhQP7Z+iKHvyoQGi1C0ClymHETx/chhQGDyYSWqB/THwnN15AwLQo0E5V9E\n" + + "SJlbe4mBlqeInUsNYugExNf+tOiybcrswBy8OFsd34XOW3rjSUtsuafd9AWySa3h\n" + + "xRRrwszrzX/WWGm6wyB+f7C4\n" + "-----END CERTIFICATE-----"; - // Owner: CN=good.sca1a.amazontrust.com - // Issuer: CN=Amazon, OU=Server CA 1A, O=Amazon, C=US - // Serial number: 75a5dd4b767bedc94a4239da65ed9dfef8218 - // Valid from: Fri Dec 17 12:21:50 PST 2021 until: Tue Jan 17 12:21:50 PST 2023 + // Owner: CN=valid.rootca1.demo.amazontrust.com + // Issuer: CN=Amazon RSA 2048 M02, O=Amazon, C=US + // Serial number: 60c6e837b2e7586d8464eb34f4a85fe + // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIEIDCCAwigAwIBAgITB1pd1LdnvtyUpCOdpl7Z3++CGDANBgkqhkiG9w0BAQsF\n" + - "ADBGMQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRUwEwYDVQQLEwxTZXJ2\n" + - "ZXIgQ0EgMUExDzANBgNVBAMTBkFtYXpvbjAeFw0yMTEyMTcyMDIxNTBaFw0yMzAx\n" + - "MTcyMDIxNTBaMCUxIzAhBgNVBAMTGmdvb2Quc2NhMWEuYW1hem9udHJ1c3QuY29t\n" + - "MIIBIjANBgkqhkiG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UotoeKSXJXdoIpqSr10bzMPX9SHvemgOUtzP3JNqWPHw1uW9YFyeDE6yWj/B13\n" + + "Xj1hv1cqYIwyaOZBerU/9PT5PaCn20AC9DHbc7iBv+zs+DYiqlAFJ1GVaprwLul4\n" + + "8wp3gnC3Hjb8NykydCo6vw0AJ2UzjpjiTyVZ93jITzLOiboOUa1gQGnojzWlYaet\n" + + "sXe+RDylBp/Wuj1ZS7v/etltzYm5GanPi4y/p7Ta3Uky6std/GM6XbPRdBEFboFR\n" + + "B2IP0divd9c74Q+tLgpsAz5yXm9LtYPMcEPC2YRN2PgBg67c5+A7eIOluuw=\n" + "-----END CERTIFICATE-----"; - // Owner: CN=revoked.sca1a.amazontrust.com - // Issuer: CN=Amazon, OU=Server CA 1A, O=Amazon, C=US - // Serial number: 75a5de4434092b2cd6ed81eb5e6248e1e5f2a - // Valid from: Fri Dec 17 12:25:17 PST 2021 until: Tue Jan 17 12:25:17 PST 2023 + // Owner: CN=revoked.rootca1.demo.amazontrust.com + // Issuer: CN=Amazon RSA 2048 M01, O=Amazon, C=US + // Serial number: e1023665b1268d788cc25bf69a9d05e + // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIEJjCCAw6gAwIBAgITB1pd5ENAkrLNbtgeteYkjh5fKjANBgkqhkiG9w0BAQsF\n" + - "ADBGMQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRUwEwYDVQQLEwxTZXJ2\n" + - "ZXIgQ0EgMUExDzANBgNVBAMTBkFtYXpvbjAeFw0yMTEyMTcyMDI1MTdaFw0yMzAx\n" + - "MTcyMDI1MTdaMCgxJjAkBgNVBAMTHXJldm9rZWQuc2NhMWEuYW1hem9udHJ1c3Qu\n" + - "Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqYk4ZkF9yJgRa0fL\n" + - "96gmxwlJlyvsQmqumxU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hMWEuYW1hem9udHJ1c3QuY29tMA4GA1Ud\n" + + "DwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwOwYDVR0f\n" + + "BDQwMjAwoC6gLIYqaHR0cDovL2NybC5yMm0wMS5hbWF6b250cnVzdC5jb20vcjJt\n" + + "MDEuY3JsMBMGA1UdIAQMMAowCAYGZ4EMAQIBMHUGCCsGAQUFBwEBBGkwZzAtBggr\n" + + "BgEFBQcwAYYhaHR0cDovL29jc3AucjJtMDEuYW1hem9udHJ1c3QuY29tMDYGCCsG\n" + + "AQUFBzAChipodHRwOi8vY3J0LnIybTAxLmFtYXpvbnRydXN0LmNvbS9yMm0wMS5j\n" + + "ZXIwDAYDVR0TAQH/BAIwADCCAX4GCisGAQQB1nkCBAIEggFuBIIBagFoAHYA7s3Q\n" + + "ZNXbGs7FXLedtM0TojKHRny87N7DUUhZRnEftZsAAAGIB72TggAABAMARzBFAiAZ\n" + + "naLbRHRuaRrE304GSuWX/79MU/e+SSlr0cNJ0kNNaAIhAPnz9HayL4txhkTEZiMs\n" + + "nttNnNqD17I0J17JLVOF4i/4AHYASLDja9qmRzQP5WoC+p0w6xxSActW3SyB2bu/\n" + + "qznYhHMAAAGIB72TmwAABAMARzBFAiEAgEqT7CYGQ/u36/3YcxBH78QfknI9kgcY\n" + + "sgJLkurUF6cCIFZZ/b803+ek6o+bmdV/uVx2UlskAyyolZ2okBAb6IscAHYA2ra/\n" + + "az+1tiKfm8K7XGvocJFxbLtRhIU0vaQ9MEjX+6sAAAGIB72TbQAABAMARzBFAiEA\n" + + "6z2RSoK263hvYF71rj1d0TpC70/6zagSRR4glHOT6IACICYvaMAnrCNSTSiZ20Wz\n" + + "Ju5roTippO3BWKhQYrTKZuu4MA0GCSqGSIb3DQEBCwUAA4IBAQB4S1JGulFpMIaP\n" + + "NtLUJmjWz8eexQdWLDVF+H8dd6xpZgpiYtig/Ynphzuk1IIF8DkT3CeK/9vrezgI\n" + + "igNjneN9B4eIuzi/rJzIKeUwpZ2k5D+36Ab4esseoc+TopmNerw8hidt2g818jER\n" + + "D71ppSMakeQFPGe/Hs2/cVa/G1DNVcU2XAut45yRZ/+xsZ0/mcBDVsG9P5uGCN5O\n" + + "7SAp4J959WnKDqgVuU9WowPE5IjmS9BAv2gjniFYdDV2yksyf7+8edHd1KfSVX06\n" + + "pLx6CuCVZGJFG4Q2Aa1YAh1Wvt9hqWeXXpNRO2/wChL5rhT4GajsrGepsk4bjxYX\n" + + "Wf2iZ8mX\n" + "-----END CERTIFICATE-----"; - public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { - // EE certificates don't have CRLDP extension - if (!ocspEnabled){ - pathValidator.validate(new String[]{INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - return; - } + public void runTest(ValidatePathWithParams pathValidator) throws Exception { // Validate valid - pathValidator.validate(new String[]{VALID, INT}, + pathValidator.validate(new String[]{VALID, INT_VALID}, ValidatePathWithParams.Status.GOOD, null, System.out); // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, + pathValidator.validate(new String[]{REVOKED, INT_REVOKED}, ValidatePathWithParams.Status.REVOKED, - "Fri Dec 17 12:28:05 PST 2021", System.out); + "Mon May 15 13:36:57 PDT 2023", System.out); } } class AmazonCA_2 { - // Owner: CN=Amazon, OU=Server CA 2A, O=Amazon, C=US + // Owner: CN=Amazon RSA 4096 M02, O=Amazon, C=US // Issuer: CN=Amazon Root CA 2, O=Amazon, C=US - // Serial number: 67f945755f187a91f8163f3e624620177ff38 - // Valid from: Wed Oct 21 17:00:00 PDT 2015 until: Sat Oct 18 17:00:00 PDT 2025 + // Serial number: 773125b0c34c3c940299a9f04a39e5a52ccd9 + // Valid from: Tue Aug 23 15:29:13 PDT 2022 until: Fri Aug 23 15:29:13 PDT 2030 private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIGRzCCBC+gAwIBAgITBn+UV1Xxh6kfgWPz5iRiAXf/ODANBgkqhkiG9w0BAQwF\n" + + "MIIGXjCCBEagAwIBAgITB3MSWww0w8lAKZqfBKOeWlLM2TANBgkqhkiG9w0BAQwF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + - "b24gUm9vdCBDQSAyMB4XDTE1MTAyMjAwMDAwMFoXDTI1MTAxOTAwMDAwMFowRjEL\n" + - "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEVMBMGA1UECxMMU2VydmVyIENB\n" + - "IDJBMQ8wDQYDVQQDEwZBbWF6b24wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK\n" + - "AoICAQC0P8hSLewmrZ41CCPBQytZs5NBFMq5ztbnMf+kZUp9S25LPfjNW3zgC/6E\n" + - "qCTWNVMMHhq7ez9IQJk48qbfBTLlZkuKnUWbA9vowrDfcxUN0mRE4B/TJbveXyTf\n" + - "vE91iDlqDrERecE9D8sdjzURrtHTp27lZdRkXFvfEVCq4hl3sHkzjodisaQthLp1\n" + - "gLsiA7vKt+8zcL4Aeq52UyYb8r4/jdZ3KaQp8O/T4VwDCRKm8ey3kttpJWaflci7\n" + - "eRzNjY7gE3NMANVXCeQwOBfH2GjINFCObmPsqiBuoAnsv2k5aQLNoU1OZk08ClXm\n" + - "mEZ2rI5qZUTX1HuefBJnpMkPugFCw8afaHnB13SkLE7wxX8SZRdDIe5WiwyDL1tR\n" + - "2+8lpz4JsMoFopHmD3GaHyjbN+hkOqHgLltwewOsiyM0u3CZphypN2KeD+1FLjnY\n" + - "TgdIAd1FRgK2ZXDDrEdjnsSEfShKf0l4mFPSBs9E3U6sLmubDRXKLLLpa/dF4eKu\n" + - "LEKS1bXYT28iM6D5gSCnzho5G4d18jQD/slmc5XmRo5Pig0RyBwDaLuxeIZuiJ0A\n" + - "J6YFhffbrLYF5dEQl0cU+t3VBK5u/o1WkWXsZawU038lWn/AXerodT/pAcrtWA4E\n" + - "NQEN09WEKMhZVPhq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tO/aybWp5QSH2csIwuvw5dkmpkc42iD57XHob\n" + + "5LbMJg99z3vQBmod/ipmOpND95/BeA2mllBZgZ53S0nvDXDzbzR9Fd81PAz9Qruo\n" + + "dOJKcD6plKQjZjkLzNh1v/RoCFO8kiJGE4UBMTM8FUk0DXH4bALII4wwmDelrSUu\n" + + "lKvDTDxZvPF4dbEXICNPd51EMGPgETxwboOV+bzWFVI0IWQ8PhZ2VuMPDk2taOMp\n" + + "NsuLtlYc2twPb9r/Hvgv7G6+ItpBHZwOVt1oI3pHbjMp7P3pOZSPr6G1WkNy9mX8\n" + + "rVc=\n" + "-----END CERTIFICATE-----"; - // Owner: CN=good.sca2a.amazontrust.com - // Issuer: CN=Amazon, OU=Server CA 2A, O=Amazon, C=US - // Serial number: 75a5dd7d82269ed466af69794f34050bdffa2 - // Valid from: Fri Dec 17 12:22:32 PST 2021 until: Tue Jan 17 12:22:32 PST 2023 + // Owner: CN=valid.rootca2.demo.amazontrust.com + // Issuer: CN=Amazon RSA 4096 M02, O=Amazon, C=US + // Serial number: 662f7646d76193cbb76946d111e49fa + // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIGIDCCBAigAwIBAgITB1pd19giae1GavaXlPNAUL3/ojANBgkqhkiG9w0BAQwF\n" + - "ADBGMQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRUwEwYDVQQLEwxTZXJ2\n" + - "ZXIgQ0EgMkExDzANBgNVBAMTBkFtYXpvbjAeFw0yMTEyMTcyMDIyMzJaFw0yMzAx\n" + - "MTcyMDIyMzJaMCUxIzAhBgNVBAMTGmdvb2Quc2NhMmEuYW1hem9udHJ1c3QuY29t\n" + - "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsCQonlc6fSTDJbH2y6wC\n" + - "mLeTD3noluSM4LPO53RgLTUvNqrxh/iy9jDGgYP2xN8GGngRI8C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f9DkspjKPDvMBokVrM4ak5AoxUjuru5qaia3nvbxq7XKO9/FGUaUaU8Xlsd\n" + + "V6Fo8VmNwFc88VCqOp8eI/IicHxMDLl8TKXMvr3CYh8A9nCeFGcV+4CL+7JF2t5K\n" + + "YvV5r074Wyk0QMlRVYMNDl0t+VAEoDJ7RRE+kEvplWcsX9S2wvr4HhkA4iChpwFm\n" + + "2UDTppHskSWyLsuNQvipn0zTzZ8RIxXd/ei0qCdhKmkV7x9cgbTiyXgaI7iJEtdo\n" + + "RvYNcXc2RmitWjY5Av8yJGOk0eYpCwRrBv6ughbtJe3NMrqUeTyrKidIEo9KnRSA\n" + + "rMokRbHunkroS97VkoK/9j9pNJki+qAH9XTLYWcm/5+cTSGRsN+escRgZwV6KWg/\n" + + "JQQe5LbwU2HHzNqWuk63GC/ngVlWXjaVFfbNVmYEKZFFazcZchesN1YyDu+WndOx\n" + + "+rTcuke2feOvQ4EnVviM0k85JZNiqPDH2iafAWyqZFUYTnb7XK3HhJflAniv/SLq\n" + + "DQfbJmtQtNHdJYgVmC1u2RT9gbJDIAj0ZI4vU2WVB5Hmd9F31un6jundEuG4+S4=\n" + "-----END CERTIFICATE-----"; - // Owner: CN=revoked.sca2a.amazontrust.com - // Issuer: CN=Amazon, OU=Server CA 2A, O=Amazon, C=US - // Serial number: 75a5df2d3387cfe5fd4cad9ff00f8c882b98d - // Valid from: Fri Dec 17 12:28:31 PST 2021 until: Tue Jan 17 12:28:31 PST 2023 + // Owner: CN=revoked.rootca2.demo.amazontrust.com + // Issuer: CN=Amazon RSA 4096 M02, O=Amazon, C=US + // Serial number: 788baa8f47bc5b1c624424216240fd3 + // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIGJjCCBA6gAwIBAgITB1pd8tM4fP5f1MrZ/wD4yIK5jTANBgkqhkiG9w0BAQwF\n" + - "ADBGMQswCQYDVQQGEwJVUzEPM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oDNo8sg1IqFNkECw3wqfeMPBcg38k6zjAxwRDcIx6U\n" + + "SwDl4d3sjrmy3gOFFXMCAwEAAaOCAxswggMXMB8GA1UdIwQYMBaAFJ5xHxodk6nZ\n" + + "LY7MSFM/A1TznuZmMB0GA1UdDgQWBBQXpWT7gMHO+HKoHM1gU1VQVnylRzBOBgNV\n" + + "HREERzBFgiRyZXZva2VkLnJvb3RjYTIuZGVtby5hbWF6b250cnVzdC5jb22CHXJl\n" + + "dm9rZWQuc2NhMmEuYW1hem9udHJ1c3QuY29tMA4GA1UdDwEB/wQEAwIFoDAdBgNV\n" + + "HSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwOwYDVR0fBDQwMjAwoC6gLIYqaHR0\n" + + "cDovL2NybC5yNG0wMi5hbWF6b250cnVzdC5jb20vcjRtMDIuY3JsMBMGA1UdIAQM\n" + + "MAowCAYGZ4EMAQIBMHUGCCsGAQUFBwEBBGkwZzAtBggrBgEFBQcwAYYhaHR0cDov\n" + + "L29jc3AucjRtMDIuYW1hem9udHJ1c3QuY29tMDYGCCsGAQUFBzAChipodHRwOi8v\n" + + "Y3J0LnI0bTAyLmFtYXpvbnRydXN0LmNvbS9yNG0wMi5jZXIwDAYDVR0TAQH/BAIw\n" + + "ADCCAX0GCisGAQQB1nkCBAIEggFtBIIBaQFnAHYA7s3QZNXbGs7FXLedtM0TojKH\n" + + "Rny87N7DUUhZRnEftZsAAAGIB72CzgAABAMARzBFAiEA2vPYIPfGJeynPaZHq/c0\n" + + "GGvyT6MpvFGMW0s0woLRT28CIEFbZbFSCnKugaqw9QDNi7vYmIF3Gyi3s6G2cCxY\n" + + "4RJXAHYASLDja9qmRzQP5WoC+p0w6xxSActW3SyB2bu/qznYhHMAAAGIB72DDgAA\n" + + "BAMARzBFAiAvfNcgtFEwk5C9dvMUYANbIAv0IOdF1new8Umn3cM+JwIhALbs/3L9\n" + + "0ndF7sRKDZmfronNruptFlrI528P5Qi2P528AHUA2ra/az+1tiKfm8K7XGvocJFx\n" + + "bLtRhIU0vaQ9MEjX+6sAAAGIB72CxQAABAMARjBEAiBKUns2FPbs0cThb6e7SnyL\n" + + "y4/qP3V1Q/ASt/ZDRTeEQQIgWSQO4Gsz32srtqYuTM9AsFd92WA44kJHincdcGVX\n" + + "XbIwDQYJKoZIhvcNAQEMBQADggIBAAnaNbn2wXylTCS7dtgB3rWdUf6hja1UDuvB\n" + + "uZEL2dUOvyXfVFLNxKdeWBPzqpwEBNNwPQXhoI97TXlyu2x60jLzQamoGoRQ3s0P\n" + + "NLhasLGEIQH/oYdMV/yp8EI8fUuRVE3xyw39FRqOrmsUFAnxNQmBO/09JM7sLcvS\n" + + "wwh14p9dFTTolJHgnL4ZEtmZxSddFG+GBSTJ/A7dVSmwIudwzd+goA6173BI6yeT\n" + + "hhQumLctQiOM7y1MzFeV8rL+oIpd2xuzyhKKT1EgvU6/wyt0Ib8QqsFsrXPnUOKk\n" + + "HAq3SeZyq35QUaTKoaH9L1iZMbSCG9Jm6FMb12SdAz53653tYvAiUS76oD8Jot13\n" + + "RZu5NUlWAVLLq0OaEtuGp0bh+cVtzVnCC9m1qa46YpY0SojpvSbakgQMMGIgDlT3\n" + + "wFE7tST4WlsDC1f/m+H9V5qz/j0U8D3eNNdowxPqx/JZq/sk9ZK5KyMFARrvM+fh\n" + + "YrVYjKt91mu7JaS4pPOyZmJ8OQ14EvrN7BXc7IkNrI1reeaRFe49k5DAETB8VmP5\n" + + "2F0SWou2KkgtJvU4Z7YjlZ2HNHnpjTK5KdPNpRSt7EUy2zn9NCNoyQhnws70FyXv\n" + + "oPFyG92lnUQOKaAUhVRwTr9fvnkdMOzSKg/spxi2Ogdzym5Jw68eguwi0dVqX2+9\n" + + "3zViP2aH\n" + "-----END CERTIFICATE-----"; - public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { - // EE certificates don't have CRLDP extension - if (!ocspEnabled){ - pathValidator.validate(new String[]{INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - return; - } + public void runTest(ValidatePathWithParams pathValidator) throws Exception { // Validate valid pathValidator.validate(new String[]{VALID, INT}, @@ -319,175 +378,228 @@ public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) t // Validate Revoked pathValidator.validate(new String[]{REVOKED, INT}, ValidatePathWithParams.Status.REVOKED, - "Fri Dec 17 12:29:36 PST 2021", System.out); + "Mon May 15 13:38:54 PDT 2023", System.out); } } class AmazonCA_3 { - // Owner: CN=Amazon, OU=Server CA 3A, O=Amazon, C=US + // Owner: CN=Amazon ECDSA 256 M02, O=Amazon, C=US // Issuer: CN=Amazon Root CA 3, O=Amazon, C=US - // Serial number: 67f945758fe55b9ee3f75831d47f07d226c8a - // Valid from: Wed Oct 21 17:00:00 PDT 2015 until: Sat Oct 18 17:00:00 PDT 2025 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIICuzCCAmGgAwIBAgITBn+UV1j+VbnuP3WDHUfwfSJsijAKBggqhkjOPQQDAjA5\n" + + // Serial number: 773126de2c2fafd2c47ad88b1566e0182046d + // Valid from: Tue Aug 23 15:33:24 PDT 2022 until: Fri Aug 23 15:33:24 PDT 2030 + private static final String INT_VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIC1DCCAnmgAwIBAgITB3MSbeLC+v0sR62IsVZuAYIEbTAKBggqhkjOPQQDAjA5\n" + + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + + "Um9vdCBDQSAzMB4XDTIyMDgyMzIyMzMyNFoXDTMwMDgyMzIyMzMyNFowPTELMAkG\n" + + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEdMBsGA1UEAxMUQW1hem9uIEVDRFNB\n" + + "IDI1NiBNMDIwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAS9vQLD4W/Kg4AnFRl8\n" + + "x/FUbLqtd5ICYjUijGsytF9hmgb/Dyk+Ebt4cw6rAlGbaiOLapSJKZiZr+UQdh3I\n" + + "QOr+o4IBWjCCAVYwEgYDVR0TAQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYw\n" + + "HQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMB0GA1UdDgQWBBS7eJrXaDMy\n" + + "nRq7bP2xNEwB3svQdTAfBgNVHSMEGDAWgBSrttvXBp43rDCGB5Fwx5zEGbF4wDB7\n" + + "BggrBgEFBQcBAQRvMG0wLwYIKwYBBQUHMAGGI2h0dHA6Ly9vY3NwLnJvb3RjYTMu\n" + + "YW1hem9udHJ1c3QuY29tMDoGCCsGAQUFBzAChi5odHRwOi8vY3J0LnJvb3RjYTMu\n" + + "YW1hem9udHJ1c3QuY29tL3Jvb3RjYTMuY2VyMD8GA1UdHwQ4MDYwNKAyoDCGLmh0\n" + + "dHA6Ly9jcmwucm9vdGNhMy5hbWF6b250cnVzdC5jb20vcm9vdGNhMy5jcmwwEwYD\n" + + "VR0gBAwwCjAIBgZngQwBAgEwCgYIKoZIzj0EAwIDSQAwRgIhAKSYEcDcp3kcPMzh\n" + + "OIYDWZOLu4InPod4fQhRTmc2zBAgAiEAmwdGE4AuNWhw9N8REhf82rJLNm7h9Myg\n" + + "TsR9Wu0bQYU=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Amazon ECDSA 256 M01, O=Amazon, C=US + // Issuer: CN=Amazon Root CA 3, O=Amazon, C=US + // Serial number: 773126684d577c0fcf8d3a342bea86f94fc8f + // Valid from: Tue Aug 23 15:31:46 PDT 2022 until: Fri Aug 23 15:31:46 PDT 2030 + private static final String INT_REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIC0zCCAnmgAwIBAgITB3MSZoTVd8D8+NOjQr6ob5T8jzAKBggqhkjOPQQDAjA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + - "Um9vdCBDQSAzMB4XDTE1MTAyMjAwMDAwMFoXDTI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CKDl4sBrUfjzVjot/lNba9kYzMKSHYv95CUDoMaF2h2KAqx65uLQ\n" + + "Y8ago4IBWjCCAVYwEgYDVR0TAQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYw\n" + + "HQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMB0GA1UdDgQWBBRPWfy8BhYo\n" + + "v6LI2wj7zxMkumlCXDAfBgNVHSMEGDAWgBSrttvXBp43rDCGB5Fwx5zEGbF4wDB7\n" + + "BggrBgEFBQcBAQRvMG0wLwYIKwYBBQUHMAGGI2h0dHA6Ly9vY3NwLnJvb3RjYTMu\n" + + "YW1hem9udHJ1c3QuY29tMDoGCCsGAQUFBzAChi5odHRwOi8vY3J0LnJvb3RjYTMu\n" + + "YW1hem9udHJ1c3QuY29tL3Jvb3RjYTMuY2VyMD8GA1UdHwQ4MDYwNKAyoDCGLmh0\n" + + "dHA6Ly9jcmwucm9vdGNhMy5hbWF6b250cnVzdC5jb20vcm9vdGNhMy5jcmwwEwYD\n" + + "VR0gBAwwCjAIBgZngQwBAgEwCgYIKoZIzj0EAwIDSAAwRQIhALRfxq3SQIhj5xA4\n" + + "S5UAY/KlKqayZDpnbBdCDH8Kqmf/AiAUVZddALefnqRe+ifxN2FUp461LL6/cgVM\n" + + "EH3Ty27f1Q==\n" + "-----END CERTIFICATE-----"; - // Owner: CN=good.sca3a.amazontrust.com - // Issuer: CN=Amazon, OU=Server CA 3A, O=Amazon, C=US - // Serial number: 75a5dd9ec12f37f4bbed4bada4b75164a642f - // Valid from: Fri Dec 17 12:23:00 PST 2021 until: Tue Jan 17 12:23:00 PST 2023 + // Owner: CN=valid.rootca3.demo.amazontrust.com + // Issuer: CN=Amazon ECDSA 256 M02, O=Amazon, C=US + // Serial number: 8e2f14864fb28e4a1da0f15a5118cc8 + // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MI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8Bqxy\n" + + "5ULMUO7GK3JEgcogJHMAdgBIsONr2qZHNA/lagL6nTDrHFIBy1bdLIHZu7+rOdiE\n" + + "cwAAAYgHvXLkAAAEAwBHMEUCIF7wDDmWxTHwBZM7Me8eOCM1aQ/g1c1rJg/I+NJa\n" + + "HkZYAiEA8p+IviuY5piHBELjUtVlZLiS9XSSMxpQNhUerqC/YFoAdQDatr9rP7W2\n" + + "Ip+bwrtca+hwkXFsu1GEhTS9pD0wSNf7qwAAAYgHvXKvAAAEAwBGMEQCIFLskZDs\n" + + "UG4+/88D/5/QbD9zT6ZmZlwXiPZ6H2YR/KiJAiBvi4vvNsb9KNAhJMgI2T2iCg9U\n" + + "CIru+US6y3ua7dKKDTAKBggqhkjOPQQDAgNHADBEAiAzvgzKV/kvBbKWCT1NNUBD\n" + + "AF9okIEcJx/ukFgzmYMwUQIgXeJeVf3izkxsgiEUSknwHsErLFs/cEme2PSRj2AW\n" + + "dYA=\n" + "-----END CERTIFICATE-----"; - // Owner: CN=revoked.sca3a.amazontrust.com - // Issuer: CN=Amazon, OU=Server CA 3A, O=Amazon, C=US - // Serial number: 75a5df9c88c0613777baba663000de147a26b - // Valid from: Fri Dec 17 12:30:04 PST 2021 until: Tue Jan 17 12:30:04 PST 2023 + // Owner: CN=revoked.rootca3.demo.amazontrust.com + // Issuer: CN=Amazon ECDSA 256 M01, O=Amazon, C=US + // Serial number: c458bfaeedae16a5e61fe64773fc898 + // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIICmzCCAkCgAwIBAgITB1pd+ciMBhN3e6umYwAN4UeiazAKBggqhkjOPQQDAjBG\n" + - "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRUwEwYDVQQLEwxTZXJ2ZXIg\n" + - "Q0EgM0ExDzANBgNVBAMTBkFtYXpvbjAeFw0yMTEyMTcyMDMwMDRaFw0yMzAxMTcy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Of+kRqk03NMAiB777hfoFCUMPrN0g8o5v6zp3T3qOhRnYY0TZN4q4NnMgB1\n" + + "ANq2v2s/tbYin5vCu1xr6HCRcWy7UYSFNL2kPTBI1/urAAABiAe9lN4AAAQDAEYw\n" + + "RAIgL0qoVbKLFD+Y3f/V6Rw+euZrPO6d1HEVPQGo7wLzkl8CIGHp3PQmmrEofl76\n" + + "4da7bY0L+csFW0sB8clN0KziMfe6MAoGCCqGSM49BAMCA0gAMEUCIQC+6VdX9X5g\n" + + "x3NSUmJ7py01Zxf26TNBv1ildxqesvZ/7wIgIrefriRzPiIFDHCUbdjk0VlmMwZR\n" + + "VzXXHINsGCiCKOs=\n" + "-----END CERTIFICATE-----"; - public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { - // EE certificates don't have CRLDP extension - if (!ocspEnabled){ - pathValidator.validate(new String[]{INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - return; - } + public void runTest(ValidatePathWithParams pathValidator) throws Exception { // Validate valid - pathValidator.validate(new String[]{VALID, INT}, + pathValidator.validate(new String[]{VALID, INT_VALID}, ValidatePathWithParams.Status.GOOD, null, System.out); // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, + pathValidator.validate(new String[]{REVOKED, INT_REVOKED}, ValidatePathWithParams.Status.REVOKED, - "Fri Dec 17 12:30:37 PST 2021", System.out); + "Mon May 15 13:41:22 PDT 2023", System.out); } } class AmazonCA_4 { - // Owner: CN=Amazon, OU=Server CA 4A, O=Amazon, C=US + // Owner: CN=Amazon ECDSA 384 M02, O=Amazon, C=US // Issuer: CN=Amazon Root CA 4, O=Amazon, C=US - // Serial number: 67f94575a8862a9072e3239c37ceba1274e18 - // Valid from: Wed Oct 21 17:00:00 PDT 2015 until: Sat Oct 18 17:00:00 PDT 2025 + // Serial number: 773127dfaa6b9e2b95538aa76dde4307f17c4 + // Valid from: Tue Aug 23 15:36:58 PDT 2022 until: Fri Aug 23 15:36:58 PDT 2030 private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIC+TCCAn6gAwIBAgITBn+UV1qIYqkHLjI5w3zroSdOGDAKBggqhkjOPQQDAzA5\n" + + "MIIDETCCApagAwIBAgITB3MSffqmueK5VTiqdt3kMH8XxDAKBggqhkjOPQQDAzA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + - "Um9vdCBDQSA0MB4XDTE1MTAyMjAwMDAwMFoXDTI1MTAxOTAwMDAwMFowRjELMAkG\n" + - "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEVMBMGA1UECxMMU2VydmVyIENBIDRB\n" + - "MQ8wDQYDVQQDEwZBbWF6b24wdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASRP0kIW0Ha\n" + - "7+ORvEVhIS5gIgkH66X5W9vBRTX14oG/1elIyI6LbFZ+E5KAufL0XoWJGI1WbPRm\n" + - "HW246FKSzF0wOEZZyxEROz6tuaVsnXRHRE76roS/Wr064uJpKH+Lv+SjggE5MIIB\n" + - "NTASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQU\n" + - "pSHN2+tTIZmqytlnQpQlsnv0wuMwHwYDVR0jBBgwFoAU0+zHOmVuzOHadppW+5zz\n" + - "hm1X5YEwewYIKwYBBQUHAQEEbzBtMC8GCCsGAQUFBzABhiNodHRwOi8vb2NzcC5y\n" + - "b290Y2E0LmFtYXpvbnRydXN0LmNvbTA6BggrBgEFBQcwAoYuaHR0cDovL2NydC5y\n" + - "b290Y2E0LmFtYXpvbnRydXN0LmNvbS9yb290Y2E0LmNlcjA/BgNVHR8EODA2MDSg\n" + - "MqAwhi5odHRwOi8vY3JsLnJvb3RjYTQuYW1hem9udHJ1c3QuY29tL3Jvb3RjYTQu\n" + - "Y3JsMBEGA1UdIAQKMAgwBgYEVR0gADAKBggqhkjOPQQDAwNpADBmAjEA59RAOBaj\n" + - "uh0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vO2W8KAjEApNdsZOCmk5uZBYiuCSBnDH3jyKhN6dWyuuHW\n" + + "9Wj7SxKnOU5+wYWZA0BQAv1KT62i\n" + "-----END CERTIFICATE-----"; - // Owner: CN=good.sca4a.amazontrust.com - // Issuer: CN=Amazon, OU=Server CA 4A, O=Amazon, C=US - // Serial number: 75a5ddc1a4ea5a18110454883269df9409bf5 - // Valid from: Fri Dec 17 12:23:29 PST 2021 until: Tue Jan 17 12:23:29 PST 2023 + // Owner: CN=valid.rootca4.demo.amazontrust.com + // Issuer: CN=Amazon ECDSA 384 M02, O=Amazon, C=US + // Serial number: f579bed3369f1a147ea5d0e8e6532d3 + // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIC0TCCAlegAwIBAgITB1pd3BpOpaGBEEVIgyad+UCb9TAKBggqhkjOPQQDAzBG\n" + - "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRUwEwYDVQQLEwxTZXJ2ZXIg\n" + - "Q0EgNEExDzANBgNVBAMTBkFtYXpvbjAeFw0yMTEyMTcyMDIzMjlaFw0yMzAxMTcy\n" + - "MDIzMjlaMCUxIzAhBgNVBAMTGmdvb2Quc2NhNGEuYW1hem9udHJ1c3QuY29tMHYw\n" + - "EAYHKoZIzj0CAQYFK4EEACIDYgAE7VpccYyJsD19xB1owlNs9PGkXkjptJZK6eFY\n" + - "q9Tc+CZLaOAhi47uuWsPwyIYB3vEIUXoWWKTvgycHhsmVQDQ2hLYMS+h9tQgnqVN\n" + - "TDYpEnnBa6AUbTKXtJDLG+z+7Kd7o4IBJjCCASIwDgYDVR0PAQH/BAQDAgeAMB0G\n" + - "A1UdDgQWBBRHzxN3jV4vU1PEmHmTqB8YXXoMYDAfBgNVHSMEGDAWgBSlIc3b61Mh\n" + - "marK2WdClCWye/TC4zAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwdQYI\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/waI6wQqfsQIwdCqaC+qN60JCnX09YKRD15eQjq1rN3w+llI+lEbS\n" + + "FSMsnoHJcqMZLo9s+4Rf0zS3\n" + "-----END CERTIFICATE-----"; - // Owner: CN=revoked.sca4a.amazontrust.com - // Issuer: CN=Amazon, OU=Server CA 4A, O=Amazon, C=US - // Serial number: 75a5e0442d0fed2b11850ed6746a2200bb4af - // Valid from: Fri Dec 17 12:32:23 PST 2021 until: Tue Jan 17 12:32:23 PST 2023 + // Owner: CN=revoked.rootca4.demo.amazontrust.com + // Issuer: CN=Amazon ECDSA 384 M02, O=Amazon, C=US + // Serial number: 4a5d392936b4decb818b7fb106ebbd8 + // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIC1zCCAl2gAwIBAgITB1peBELQ/tKxGFDtZ0aiIAu0rzAKBggqhkjOPQQDAzBG\n" + - "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRUwEwYDVQQLEwxTZXJ2ZXIg\n" + - "Q0EgNEExDzANBgNVBAMTBkFtYXpvbjAeFw0yMTEyMTcyMDMyMjNaFw0yMzAxMTcy\n" + - "MDMyMjNaMCgxJjAkBgNVBAMTHXJldm9rZWQuc2NhNGEuYW1hem9udHJ1c3QuY29t\n" + - "MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEqxQKCDKJYXzA0uR3jyfk/ZRyPAJolRNI\n" + - "xI3+vlQW7SqVs+MziCLFPuU68kf74a5/YFWK/bRdXrVue4IMbM8TKO2FwXIHn/Iw\n" + - "udkJIG+CdqnL4IlH+tFf+l47vRzMS0TQo4IBKTCCASUwDgYDVR0PAQH/BAQDAgeA\n" + - "MB0GA1UdDgQWBBR04rEvUxTzLh0OGHyMgrYanP7lqzAfBgNVHSMEGDAWgBSlIc3b\n" + - "61MhmarK2WdClCWye/TC4zAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwI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k/7zGNpGelKPr/UYV9AjASwdA32S8jIADxA8HrqiMsVYDFMnbU\n" + + "jLLwR6CTLtAcWtwVmoQ2x0usvTvN8YJBPoA=\n" + "-----END CERTIFICATE-----"; - public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { - // EE certificates don't have CRLDP extension - if (!ocspEnabled){ - pathValidator.validate(new String[]{INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - return; - } + public void runTest(ValidatePathWithParams pathValidator) throws Exception { // Validate valid pathValidator.validate(new String[]{VALID, INT}, @@ -496,6 +608,6 @@ public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) t // Validate Revoked pathValidator.validate(new String[]{REVOKED, INT}, ValidatePathWithParams.Status.REVOKED, - "Fri Dec 17 12:32:59 PST 2021", System.out); + "Mon May 15 13:42:48 PDT 2023", System.out); } } From 6985739a238db664050815f4de1fc56c803f5594 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 16 Aug 2023 08:16:16 +0000 Subject: [PATCH 025/341] 8304353: Add lib-test tier1 testing in GHA Backport-of: 57276101df79f07b14b914b36b1155cedec3eb3d --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 81735dd71e6c4..f4d4e93c1875c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -64,6 +64,7 @@ jobs: - 'hs/tier1 gc' - 'hs/tier1 runtime' - 'hs/tier1 serviceability' + - 'lib-test/tier1' include: - test-name: 'jdk/tier1 part 1' @@ -98,6 +99,10 @@ jobs: test-suite: 'test/hotspot/jtreg/:tier1_serviceability' debug-suffix: -debug + - test-name: 'lib-test/tier1' + test-suite: 'test/lib-test/:tier1' + debug-suffix: -debug + steps: - name: 'Checkout the JDK source' uses: actions/checkout@v3 From 75779ec29462f62e0f282258dde9ff35d475c396 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 16 Aug 2023 08:18:15 +0000 Subject: [PATCH 026/341] 8294149: JMH 1.34 and later requires jopt-simple 5.0.4 8277427: Update jib-profiles.js to use JMH 1.33 devkit 8280032: Update jib-profiles.js to use JMH 1.34 devkit Backport-of: 2283c3244f4fe475593d8a53613b5a3228bec356 --- make/conf/jib-profiles.js | 2 +- make/devkit/createJMHBundle.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index ef3aca5bbe38c..5bdfa9ba32ca8 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -1167,7 +1167,7 @@ var getJibProfilesDependencies = function (input, common) { jmh: { organization: common.organization, ext: "tar.gz", - revision: "1.28+1.0" + revision: "1.35+1.0" }, jcov: { diff --git a/make/devkit/createJMHBundle.sh b/make/devkit/createJMHBundle.sh index 904aefa82d336..7018ae23e55e1 100644 --- a/make/devkit/createJMHBundle.sh +++ b/make/devkit/createJMHBundle.sh @@ -28,7 +28,7 @@ JMH_VERSION=1.36 COMMONS_MATH3_VERSION=3.2 -JOPT_SIMPLE_VERSION=4.6 +JOPT_SIMPLE_VERSION=5.0.4 BUNDLE_NAME=jmh-$JMH_VERSION.tar.gz From 197d2dabd00efc97c471c54582c6325c722d7930 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 16 Aug 2023 08:33:35 +0000 Subject: [PATCH 027/341] 8299330: Minor improvements in MSYS2 Workflow handling Backport-of: cf00d09c8c37ee301e1c6657df45777647a834e9 --- .github/actions/get-msys2/action.yml | 4 ++-- .github/workflows/build-windows.yml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/actions/get-msys2/action.yml b/.github/actions/get-msys2/action.yml index 27726245c15dc..7dac1538536c6 100644 --- a/.github/actions/get-msys2/action.yml +++ b/.github/actions/get-msys2/action.yml @@ -35,11 +35,11 @@ runs: with: install: 'autoconf tar unzip zip make' path-type: minimal - location: msys2 + location: ${{ runner.tool_cache }}/msys2 # We can't run bash until this is completed, so stick with pwsh - name: 'Set MSYS2 path' run: | # Prepend msys2/msys64/usr/bin to the PATH - echo "$env:GITHUB_WORKSPACE/msys2/msys64/usr/bin" >> $env:GITHUB_PATH + echo "$env:RUNNER_TOOL_CACHE/msys2/msys64/usr/bin" >> $env:GITHUB_PATH shell: pwsh diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 121d683c715f4..6501d20c9ccb1 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -138,6 +138,7 @@ jobs: # We need a minimal PATH on Windows # Set PATH to "", so just GITHUB_PATH is included PATH: '' + shell: env /usr/bin/bash --login -eo pipefail {0} - name: 'Build' id: build From b9a72316112952e47b05a2a2310c82c7f54eebcf Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 16 Aug 2023 08:34:05 +0000 Subject: [PATCH 028/341] 8294956: GHA: qemu-debootstrap is deprecated, use the regular one Backport-of: c5f462e83b85ec53ec395622063a5b131aaf0827 --- .github/workflows/build-cross-compile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index d698d8ccab539..0ea0360dccdd6 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -133,7 +133,7 @@ jobs: - name: 'Create sysroot' run: > - sudo qemu-debootstrap + sudo debootstrap --arch=${{ matrix.debian-arch }} --verbose --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev From ba380adc85a52b278439051c57e0162bf604d13a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 16 Aug 2023 08:39:38 +0000 Subject: [PATCH 029/341] 8294941: GHA: Cut down cross-compilation sysroots Backport-of: a1747ef81a10e84177f474565193204ceaa0ede8 --- .github/workflows/build-cross-compile.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 0ea0360dccdd6..3256eaae0093e 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -149,7 +149,9 @@ jobs: # Prepare sysroot and remove unused files to minimize cache sudo chroot sysroot symlinks -cr . sudo chown ${USER} -R sysroot - rm -rf sysroot/{dev,proc,run,sys} + rm -rf sysroot/{dev,proc,run,sys,var} + rm -rf sysroot/usr/{sbin,bin,share} + rm -rf sysroot/usr/lib/{apt,udev,systemd} if: steps.get-cached-sysroot.outputs.cache-hit != 'true' - name: 'Configure' From 528e3b89263b7c99bfb72dc1c13e888714ea378b Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 16 Aug 2023 10:37:41 +0000 Subject: [PATCH 030/341] 8313402: C1: Incorrect LoadIndexed value numbering Backport-of: 46fbedb2be98a9b8aba042fa9f90c3b25c312cd6 --- src/hotspot/share/c1/c1_Instruction.hpp | 2 +- .../compiler/c1/TestLoadIndexedMismatch.java | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/compiler/c1/TestLoadIndexedMismatch.java diff --git a/src/hotspot/share/c1/c1_Instruction.hpp b/src/hotspot/share/c1/c1_Instruction.hpp index 858d4f606edaa..b24e18bf9a848 100644 --- a/src/hotspot/share/c1/c1_Instruction.hpp +++ b/src/hotspot/share/c1/c1_Instruction.hpp @@ -960,7 +960,7 @@ LEAF(LoadIndexed, AccessIndexed) ciType* declared_type() const; // generic; - HASHING3(LoadIndexed, true, type()->tag(), array()->subst(), index()->subst()) + HASHING3(LoadIndexed, true, elt_type(), array()->subst(), index()->subst()) }; diff --git a/test/hotspot/jtreg/compiler/c1/TestLoadIndexedMismatch.java b/test/hotspot/jtreg/compiler/c1/TestLoadIndexedMismatch.java new file mode 100644 index 0000000000000..d16b6b0c684ca --- /dev/null +++ b/test/hotspot/jtreg/compiler/c1/TestLoadIndexedMismatch.java @@ -0,0 +1,58 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * 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 8313402 + * @summary C1: Incorrect LoadIndexed value numbering + * @requires vm.compiler1.enabled + * @library /compiler/patches /test/lib + * @build java.base/java.lang.Helper + * @run main/othervm -Xbatch -XX:CompileThreshold=100 + * -XX:TieredStopAtLevel=1 + * compiler.c1.TestLoadIndexedMismatch + */ + +package compiler.c1; + +public class TestLoadIndexedMismatch { + static final byte[] ARR = {42, 42}; + static final char EXPECTED_CHAR = (char)(42*256 + 42); + + public static char work() { + // LoadIndexed (B) + byte b = ARR[0]; + // StringUTF16.charAt intrinsic, LoadIndexed (C) + char c = Helper.charAt(ARR, 0); + return c; + } + + public static void main(String[] args) { + for (int i = 0; i < 10_000; i++) { + char c = work(); + if (c != EXPECTED_CHAR) { + throw new IllegalStateException("Read: " + (int)c + ", expected: " + (int)EXPECTED_CHAR); + } + } + } +} From 4084a8181337999b87cf89950f2401b1b78204dc Mon Sep 17 00:00:00 2001 From: Ben Taylor Date: Wed, 16 Aug 2023 18:15:50 +0000 Subject: [PATCH 031/341] 8313796: AsyncGetCallTrace crash on unreadable interpreter method pointer Reviewed-by: stuefe Backport-of: 0e2c72d7a5206b7173af5bf69e21d21ea276bd94 --- src/hotspot/cpu/aarch64/frame_aarch64.cpp | 2 +- src/hotspot/cpu/arm/frame_arm.cpp | 2 +- src/hotspot/cpu/ppc/frame_ppc.cpp | 2 +- src/hotspot/cpu/riscv/frame_riscv.cpp | 2 +- src/hotspot/cpu/x86/frame_x86.cpp | 2 +- src/hotspot/share/runtime/frame.cpp | 9 +++++++++ src/hotspot/share/runtime/frame.hpp | 2 ++ 7 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/hotspot/cpu/aarch64/frame_aarch64.cpp b/src/hotspot/cpu/aarch64/frame_aarch64.cpp index f9299d2200624..418f2c3fe1c01 100644 --- a/src/hotspot/cpu/aarch64/frame_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/frame_aarch64.cpp @@ -551,7 +551,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const { // first the method - Method* m = *interpreter_frame_method_addr(); + Method* m = safe_interpreter_frame_method(); // validate the method we'd find in this potential sender if (!Method::is_valid_method(m)) return false; diff --git a/src/hotspot/cpu/arm/frame_arm.cpp b/src/hotspot/cpu/arm/frame_arm.cpp index 6b8f77bf08887..164e19eeb5bcc 100644 --- a/src/hotspot/cpu/arm/frame_arm.cpp +++ b/src/hotspot/cpu/arm/frame_arm.cpp @@ -468,7 +468,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const { // first the method - Method* m = *interpreter_frame_method_addr(); + Method* m = safe_interpreter_frame_method(); // validate the method we'd find in this potential sender if (!Method::is_valid_method(m)) return false; diff --git a/src/hotspot/cpu/ppc/frame_ppc.cpp b/src/hotspot/cpu/ppc/frame_ppc.cpp index dae75944542d8..a4cd0c86b1809 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.cpp +++ b/src/hotspot/cpu/ppc/frame_ppc.cpp @@ -316,7 +316,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const { // first the method - Method* m = *interpreter_frame_method_addr(); + Method* m = safe_interpreter_frame_method(); // validate the method we'd find in this potential sender if (!Method::is_valid_method(m)) return false; diff --git a/src/hotspot/cpu/riscv/frame_riscv.cpp b/src/hotspot/cpu/riscv/frame_riscv.cpp index 8123317a60958..3058c09d9d286 100644 --- a/src/hotspot/cpu/riscv/frame_riscv.cpp +++ b/src/hotspot/cpu/riscv/frame_riscv.cpp @@ -536,7 +536,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const { // do some validation of frame elements // first the method - Method* m = *interpreter_frame_method_addr(); + Method* m = safe_interpreter_frame_method(); // validate the method we'd find in this potential sender if (!Method::is_valid_method(m)) { return false; diff --git a/src/hotspot/cpu/x86/frame_x86.cpp b/src/hotspot/cpu/x86/frame_x86.cpp index aa5628a7f7e60..7a84a0328ab4b 100644 --- a/src/hotspot/cpu/x86/frame_x86.cpp +++ b/src/hotspot/cpu/x86/frame_x86.cpp @@ -557,7 +557,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const { // do some validation of frame elements // first the method - Method* m = *interpreter_frame_method_addr(); + Method* m = safe_interpreter_frame_method(); // validate the method we'd find in this potential sender if (!Method::is_valid_method(m)) return false; diff --git a/src/hotspot/share/runtime/frame.cpp b/src/hotspot/share/runtime/frame.cpp index 22b5708508988..46dde1569a125 100644 --- a/src/hotspot/share/runtime/frame.cpp +++ b/src/hotspot/share/runtime/frame.cpp @@ -46,6 +46,7 @@ #include "runtime/monitorChunk.hpp" #include "runtime/os.hpp" #include "runtime/sharedRuntime.hpp" +#include "runtime/safefetch.hpp" #include "runtime/signature.hpp" #include "runtime/stubCodeGenerator.hpp" #include "runtime/stubRoutines.hpp" @@ -243,6 +244,14 @@ bool frame::is_entry_frame_valid(JavaThread* thread) const { return (jfa->last_Java_sp() > sp()); } +Method* frame::safe_interpreter_frame_method() const { + Method** m_addr = interpreter_frame_method_addr(); + if (m_addr == nullptr) { + return nullptr; + } + return (Method*) SafeFetchN((intptr_t*) m_addr, 0); +} + bool frame::should_be_deoptimized() const { if (_deopt_state == is_deoptimized || !is_compiled_frame() ) return false; diff --git a/src/hotspot/share/runtime/frame.hpp b/src/hotspot/share/runtime/frame.hpp index 645e328bcb3e1..e0eac24028d0c 100644 --- a/src/hotspot/share/runtime/frame.hpp +++ b/src/hotspot/share/runtime/frame.hpp @@ -177,6 +177,8 @@ class frame { bool is_entry_frame_valid(JavaThread* thread) const; + Method* safe_interpreter_frame_method() const; + // All frames: // A low-level interface for vframes: From 41cadb7ab7bf1c77dc5222ab0f9a8e8dd17cfacf Mon Sep 17 00:00:00 2001 From: Ben Taylor Date: Fri, 18 Aug 2023 16:22:33 +0000 Subject: [PATCH 032/341] 8313765: Invalid CEN header (invalid zip64 extra data field size) Reviewed-by: andrew, serb Backport-of: 13f6450e2e70df4df8bd882def837fbd5bef1524 --- .../share/classes/java/util/zip/ZipFile.java | 52 +- .../classes/jdk/nio/zipfs/ZipFileSystem.java | 14 +- .../util/zip/ZipFile/CorruptedZipFiles.java | 7 +- .../ReadNonStandardExtraHeadersTest.java | 938 ++++++++++++++++++ 4 files changed, 998 insertions(+), 13 deletions(-) create mode 100644 test/jdk/java/util/zip/ZipFile/ReadNonStandardExtraHeadersTest.java diff --git a/src/java.base/share/classes/java/util/zip/ZipFile.java b/src/java.base/share/classes/java/util/zip/ZipFile.java index a2573f83f668b..d47a1d260262b 100644 --- a/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -69,7 +69,8 @@ import jdk.internal.ref.CleanerFactory; import jdk.internal.vm.annotation.Stable; import sun.nio.cs.UTF_8; -import sun.security.action.GetBooleanAction; +import sun.nio.fs.DefaultFileSystemProvider; +import sun.security.action.GetPropertyAction; import sun.security.util.SignatureFileVerifier; import static java.util.zip.ZipConstants64.*; @@ -123,11 +124,12 @@ public class ZipFile implements ZipConstants, Closeable { public static final int OPEN_DELETE = 0x4; /** - * Flag which specifies whether the validation of the Zip64 extra - * fields should be disabled + * Flag to specify whether the Extra ZIP64 validation should be + * disabled. */ - private static final boolean disableZip64ExtraFieldValidation = - GetBooleanAction.privilegedGetProperty("jdk.util.zip.disableZip64ExtraFieldValidation"); + private static final boolean DISABLE_ZIP64_EXTRA_VALIDATION = + getDisableZip64ExtraFieldValidation(); + /** * Opens a zip file for reading. * @@ -1086,6 +1088,21 @@ private int[] getMetaInfVersions() { } private static boolean isWindows; + /** + * Returns the value of the System property which indicates whether the + * Extra ZIP64 validation should be disabled. + */ + static boolean getDisableZip64ExtraFieldValidation() { + boolean result; + String value = GetPropertyAction.privilegedGetProperty( + "jdk.util.zip.disableZip64ExtraFieldValidation"); + if (value == null) { + result = false; + } else { + result = value.isEmpty() || value.equalsIgnoreCase("true"); + } + return result; + } static { SharedSecrets.setJavaUtilZipFileAccess( @@ -1204,7 +1221,7 @@ private int checkAndAddEntry(int pos, int index) } int elen = CENEXT(cen, pos); - if (elen > 0 && !disableZip64ExtraFieldValidation) { + if (elen > 0 && !DISABLE_ZIP64_EXTRA_VALIDATION) { long extraStartingOffset = pos + CENHDR + nlen; if ((int)extraStartingOffset != extraStartingOffset) { zerror("invalid CEN header (bad extra offset)"); @@ -1248,25 +1265,32 @@ private void checkExtraFields(int cenPos, int startingOffset, zerror("Invalid CEN header (extra data field size too long)"); } int currentOffset = startingOffset; - while (currentOffset < extraEndOffset) { + // Walk through each Extra Header. Each Extra Header Must consist of: + // Header ID - 2 bytes + // Data Size - 2 bytes: + while (currentOffset + Integer.BYTES <= extraEndOffset) { int tag = get16(cen, currentOffset); currentOffset += Short.BYTES; int tagBlockSize = get16(cen, currentOffset); + currentOffset += Short.BYTES; int tagBlockEndingOffset = currentOffset + tagBlockSize; // The ending offset for this tag block should not go past the // offset for the end of the extra field if (tagBlockEndingOffset > extraEndOffset) { - zerror("Invalid CEN header (invalid zip64 extra data field size)"); + zerror(String.format( + "Invalid CEN header (invalid extra data field size for " + + "tag: 0x%04x at %d)", + tag, cenPos)); } - currentOffset += Short.BYTES; if (tag == ZIP64_EXTID) { // Get the compressed size; long csize = CENSIZ(cen, cenPos); // Get the uncompressed size; long size = CENLEN(cen, cenPos); + checkZip64ExtraFieldValues(currentOffset, tagBlockSize, csize, size); } @@ -1290,6 +1314,16 @@ private void checkZip64ExtraFieldValues(int off, int blockSize, long csize, long size) throws ZipException { byte[] cen = this.cen; + // if ZIP64_EXTID blocksize == 0, which may occur with some older + // versions of Apache Ant and Commons Compress, validate csize and size + // to make sure neither field == ZIP64_MAGICVAL + if (blockSize == 0) { + if (csize == ZIP64_MAGICVAL || size == ZIP64_MAGICVAL) { + zerror("Invalid CEN header (invalid zip64 extra data field size)"); + } + // Only validate the ZIP64_EXTID data if the block size > 0 + return; + } // Validate the Zip64 Extended Information Extra Field (0x0001) // length. if (!isZip64ExtBlockSizeValid(blockSize)) { diff --git a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java index 886be5794bab4..422d6678e641c 100644 --- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java +++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java @@ -3078,10 +3078,22 @@ private void readExtra(ZipFileSystem zipfs) throws IOException { int sz = SH(extra, pos + 2); pos += 4; if (pos + sz > elen) { // invalid data - throw new ZipException("Invalid CEN header (invalid zip64 extra data field size)"); + throw new ZipException(String.format( + "Invalid CEN header (invalid extra data field size for " + + "tag: 0x%04x size: %d)", + tag, sz)); } switch (tag) { case EXTID_ZIP64 : + // if ZIP64_EXTID blocksize == 0, which may occur with some older + // versions of Apache Ant and Commons Compress, validate csize + // size, and locoff to make sure the fields != ZIP64_MAGICVAL + if (sz == 0) { + if (csize == ZIP64_MINVAL || size == ZIP64_MINVAL || locoff == ZIP64_MINVAL) { + throw new ZipException("Invalid CEN header (invalid zip64 extra data field size)"); + } + break; + } // Check to see if we have a valid block size if (!isZip64ExtBlockSizeValid(sz)) { throw new ZipException("Invalid CEN header (invalid zip64 extra data field size)"); diff --git a/test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java b/test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java index b969ecfd04ebd..a4627721c12ff 100644 --- a/test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java +++ b/test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4770745 6218846 6218848 6237956 + * @bug 4770745 6218846 6218848 6237956 8313765 * @summary test for correct detection and reporting of corrupted zip files * @author Martin Buchholz */ @@ -113,8 +113,9 @@ public static void main(String[] args) throws Exception { err.println("corrupted CENEXT 1"); bad = good.clone(); - bad[cenpos+CENEXT]++; - checkZipException(bad, ".*invalid zip64 extra data field size.*"); + bad[cenpos+CENEXT] = (byte)0xff; + bad[cenpos+CENEXT+1] = (byte)0xff; + checkZipException(bad, ".*extra data field size too long.*"); err.println("corrupted CENEXT 2"); bad = good.clone(); diff --git a/test/jdk/java/util/zip/ZipFile/ReadNonStandardExtraHeadersTest.java b/test/jdk/java/util/zip/ZipFile/ReadNonStandardExtraHeadersTest.java new file mode 100644 index 0000000000000..0298e748996ca --- /dev/null +++ b/test/jdk/java/util/zip/ZipFile/ReadNonStandardExtraHeadersTest.java @@ -0,0 +1,938 @@ +/* + * 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 java.io.IOException; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Formatter; +import java.util.Map; +import java.util.stream.Stream; +import java.util.zip.ZipFile; + +/* @test + * @bug 8313765 + * @summary Validate that a Zip File with an Extra Header with a data size + * of 0 can be read. + * @run main ReadNonStandardExtraHeadersTest + */ +public class ReadNonStandardExtraHeadersTest { + + /* + * Byte array holding a ZIP file which contains an + * Extra field header which has a data size of 0. + * + * ---------------#1-------------------- + * [Central Directory Header] + * 0x664: Signature : 0x02014b50 + * 0x668: Created Zip Spec : 0xa [1.0] + * 0x669: Created OS : 0x0 [MS-DOS] + * 0x66a: VerMadeby : 0xa [0, 1.0] + * 0x66b: VerExtract : 0xa [1.0] + * 0x66c: Flag : 0x800 + * 0x66e: Method : 0x0 [STORED] + * 0x670: Last Mod Time : 0x385ca437 [Thu Feb 28 20:33:46 EST 2008] + * 0x674: CRC : 0x694c6952 + * 0x678: Compressed Size : 0x624 + * 0x67c: Uncompressed Size: 0x624 + * 0x680: Name Length : 0x1b + * 0x682: Extra Length : 0x7 + * ->[tag=cafe, size=0] + * 0x684: Comment Length : 0x0 + * 0x686: Disk Start : 0x0 + * 0x688: Attrs : 0x0 + * 0x68a: AttrsEx : 0x0 + * 0x68e: Loc Header Offset: 0x0 + * 0x692: File Name : res/drawable/size_48x48.jpg + * + * [Local File Header] + * 0x0: Signature : 0x04034b50 + * 0x4: Version : 0xa [1.0] + * 0x6: Flag : 0x800 + * 0x8: Method : 0x0 [STORED] + * 0xa: LastMTime : 0x385ca437 [Thu Feb 28 20:33:46 EST 2008] + * 0xe: CRC : 0x694c6952 + * 0x12: CSize : 0x624 + * 0x16: Size : 0x624 + * 0x1a: Name Length : 0x1b [res/drawable/size_48x48.jpg] + * 0x1c: ExtraLength : 0x7 + * ->[tag=cafe, size=0] + * 0x1e: File Name : [res/drawable/size_48x48.jpg] + * [End Central Directory Header] + * Signature : 0x06054b50 + * ENDCEN Off : 0x6b4 + * Disk Entries: 0x1 + * Total Entries: 0x1 + * CEN Size : 0x50 + * Offset CEN : 0x664 + * Comment Len : 0x0 [] + */ + public static byte[] VALID_APK_FILE = { + (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0xa, (byte) 0x0, (byte) 0x0, (byte) 0x8, + (byte) 0x0, (byte) 0x0, (byte) 0x37, (byte) 0xa4, (byte) 0x5c, (byte) 0x38, (byte) 0x52, (byte) 0x69, + (byte) 0x4c, (byte) 0x69, (byte) 0x24, (byte) 0x6, (byte) 0x0, (byte) 0x0, (byte) 0x24, (byte) 0x6, + (byte) 0x0, (byte) 0x0, (byte) 0x1b, (byte) 0x0, (byte) 0x7, (byte) 0x0, (byte) 0x72, (byte) 0x65, + (byte) 0x73, (byte) 0x2f, (byte) 0x64, (byte) 0x72, (byte) 0x61, (byte) 0x77, (byte) 0x61, (byte) 0x62, + (byte) 0x6c, (byte) 0x65, (byte) 0x2f, (byte) 0x73, (byte) 0x69, (byte) 0x7a, (byte) 0x65, (byte) 0x5f, + (byte) 0x34, (byte) 0x38, (byte) 0x78, (byte) 0x34, (byte) 0x38, (byte) 0x2e, (byte) 0x6a, (byte) 0x70, + (byte) 0x67, (byte) 0xfe, (byte) 0xca, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xe0, (byte) 0x0, (byte) 0x10, (byte) 0x4a, (byte) 0x46, + (byte) 0x49, (byte) 0x46, (byte) 0x0, (byte) 0x1, (byte) 0x1, (byte) 0x1, (byte) 0x0, (byte) 0x48, + (byte) 0x0, (byte) 0x48, (byte) 0x0, (byte) 0x0, (byte) 0xff, (byte) 0xfe, (byte) 0x0, (byte) 0x16, + (byte) 0x28, (byte) 0x63, (byte) 0x29, (byte) 0x20, (byte) 0x32, (byte) 0x30, (byte) 0x30, (byte) 0x37, + (byte) 0x20, (byte) 0x50, (byte) 0x68, (byte) 0x69, (byte) 0x6c, (byte) 0x20, (byte) 0x44, (byte) 0x75, + (byte) 0x62, (byte) 0x61, (byte) 0x63, (byte) 0x68, (byte) 0xff, (byte) 0xdb, (byte) 0x0, (byte) 0x43, + (byte) 0x0, (byte) 0x6, (byte) 0x4, (byte) 0x5, (byte) 0x6, (byte) 0x5, (byte) 0x4, (byte) 0x6, + (byte) 0x6, (byte) 0x5, (byte) 0x6, (byte) 0x7, (byte) 0x7, (byte) 0x6, (byte) 0x8, (byte) 0xa, + (byte) 0x10, (byte) 0xa, (byte) 0xa, (byte) 0x9, (byte) 0x9, (byte) 0xa, (byte) 0x14, (byte) 0xe, + (byte) 0xf, (byte) 0xc, (byte) 0x10, (byte) 0x17, (byte) 0x14, (byte) 0x18, (byte) 0x18, (byte) 0x17, + (byte) 0x14, (byte) 0x16, (byte) 0x16, (byte) 0x1a, (byte) 0x1d, (byte) 0x25, (byte) 0x1f, (byte) 0x1a, + (byte) 0x1b, (byte) 0x23, (byte) 0x1c, (byte) 0x16, (byte) 0x16, (byte) 0x20, (byte) 0x2c, (byte) 0x20, + (byte) 0x23, (byte) 0x26, (byte) 0x27, (byte) 0x29, (byte) 0x2a, (byte) 0x29, (byte) 0x19, (byte) 0x1f, + (byte) 0x2d, (byte) 0x30, (byte) 0x2d, (byte) 0x28, (byte) 0x30, (byte) 0x25, (byte) 0x28, (byte) 0x29, + (byte) 0x28, (byte) 0xff, (byte) 0xdb, (byte) 0x0, (byte) 0x43, (byte) 0x1, (byte) 0x7, (byte) 0x7, + (byte) 0x7, (byte) 0xa, (byte) 0x8, (byte) 0xa, (byte) 0x13, (byte) 0xa, (byte) 0xa, (byte) 0x13, + (byte) 0x28, (byte) 0x1a, (byte) 0x16, (byte) 0x1a, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0xff, (byte) 0xc0, + (byte) 0x0, (byte) 0x11, (byte) 0x8, (byte) 0x0, (byte) 0x30, (byte) 0x0, (byte) 0x30, (byte) 0x3, + (byte) 0x1, (byte) 0x11, (byte) 0x0, (byte) 0x2, (byte) 0x11, (byte) 0x1, (byte) 0x3, (byte) 0x11, + (byte) 0x1, (byte) 0xff, (byte) 0xc4, (byte) 0x0, (byte) 0x1b, (byte) 0x0, (byte) 0x0, (byte) 0x2, + (byte) 0x2, (byte) 0x3, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x4, (byte) 0x5, + (byte) 0x6, (byte) 0x7, (byte) 0x1, (byte) 0x3, (byte) 0x8, (byte) 0x2, (byte) 0xff, (byte) 0xc4, + (byte) 0x0, (byte) 0x2e, (byte) 0x10, (byte) 0x0, (byte) 0x2, (byte) 0x2, (byte) 0x1, (byte) 0x2, + (byte) 0x4, (byte) 0x4, (byte) 0x5, (byte) 0x4, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x2, (byte) 0x3, (byte) 0x4, (byte) 0x11, + (byte) 0x0, (byte) 0x5, (byte) 0x6, (byte) 0x12, (byte) 0x21, (byte) 0x31, (byte) 0x41, (byte) 0x51, + (byte) 0x61, (byte) 0x71, (byte) 0x7, (byte) 0x13, (byte) 0x22, (byte) 0x42, (byte) 0x91, (byte) 0x33, + (byte) 0x62, (byte) 0x81, (byte) 0xa1, (byte) 0x52, (byte) 0xd1, (byte) 0xf0, (byte) 0xff, (byte) 0xc4, + (byte) 0x0, (byte) 0x1b, (byte) 0x1, (byte) 0x0, (byte) 0x1, (byte) 0x5, (byte) 0x1, (byte) 0x1, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x6, (byte) 0x2, (byte) 0x3, (byte) 0x4, (byte) 0x5, + (byte) 0x7, (byte) 0x1, (byte) 0x0, (byte) 0xff, (byte) 0xc4, (byte) 0x0, (byte) 0x33, (byte) 0x11, + (byte) 0x0, (byte) 0x1, (byte) 0x3, (byte) 0x2, (byte) 0x4, (byte) 0x4, (byte) 0x4, (byte) 0x4, + (byte) 0x5, (byte) 0x5, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x1, (byte) 0x0, (byte) 0x2, (byte) 0x3, (byte) 0x4, (byte) 0x11, (byte) 0x5, (byte) 0x12, + (byte) 0x21, (byte) 0x31, (byte) 0x13, (byte) 0x51, (byte) 0x61, (byte) 0x71, (byte) 0x6, (byte) 0x32, + (byte) 0x41, (byte) 0x81, (byte) 0x91, (byte) 0xa1, (byte) 0xb1, (byte) 0xc1, (byte) 0x7, (byte) 0x14, + (byte) 0x42, (byte) 0xd1, (byte) 0xf0, (byte) 0x22, (byte) 0x33, (byte) 0x62, (byte) 0xa2, (byte) 0xf1, + (byte) 0xff, (byte) 0xda, (byte) 0x0, (byte) 0xc, (byte) 0x3, (byte) 0x1, (byte) 0x0, (byte) 0x2, + (byte) 0x11, (byte) 0x3, (byte) 0x11, (byte) 0x0, (byte) 0x3f, (byte) 0x0, (byte) 0xb4, (byte) 0x11, + (byte) 0xf4, (byte) 0x4c, (byte) 0xa, (byte) 0x12, (byte) 0x7b, (byte) 0x16, (byte) 0x2e, (byte) 0x5d, + (byte) 0xaf, (byte) 0x46, (byte) 0xac, (byte) 0x96, (byte) 0x6e, (byte) 0xcf, (byte) 0x1c, (byte) 0x10, + (byte) 0x46, (byte) 0x32, (byte) 0xd2, (byte) 0x48, (byte) 0xd8, (byte) 0x3, (byte) 0x48, (byte) 0x96, + (byte) 0x46, (byte) 0x44, (byte) 0xd2, (byte) 0xf7, (byte) 0x9b, (byte) 0x0, (byte) 0x91, (byte) 0x5, + (byte) 0x24, (byte) 0xd5, (byte) 0x52, (byte) 0x8, (byte) 0x60, (byte) 0x69, (byte) 0x73, (byte) 0x8e, + (byte) 0xc0, (byte) 0x6f, (byte) 0xfc, (byte) 0xfa, (byte) 0x28, (byte) 0x26, (byte) 0xe5, (byte) 0xf1, + (byte) 0x5f, (byte) 0x6b, (byte) 0x82, (byte) 0x52, (byte) 0x9b, (byte) 0x7d, (byte) 0x3b, (byte) 0x17, + (byte) 0x0, (byte) 0x38, (byte) 0xe7, (byte) 0x62, (byte) 0x22, (byte) 0x53, (byte) 0xea, (byte) 0x32, + (byte) 0x9, (byte) 0xfc, (byte) 0x81, (byte) 0xaa, (byte) 0x19, (byte) 0xfc, (byte) 0x43, (byte) 0x13, + (byte) 0xd, (byte) 0xa3, (byte) 0x69, (byte) 0x77, (byte) 0xcb, (byte) 0xf7, (byte) 0x47, (byte) 0xb4, + (byte) 0x1f, (byte) 0x86, (byte) 0x95, (byte) 0xd3, (byte) 0xb7, (byte) 0x35, (byte) 0x4c, (byte) 0xad, + (byte) 0x8f, (byte) 0xa5, (byte) 0xb3, (byte) 0x1f, (byte) 0x7d, (byte) 0x40, (byte) 0xf8, (byte) 0x12, + (byte) 0x8a, (byte) 0xd9, (byte) 0x7e, (byte) 0x26, (byte) 0x6d, (byte) 0xb7, (byte) 0x98, (byte) 0x8b, + (byte) 0x95, (byte) 0x2c, (byte) 0xd3, (byte) 0x3, (byte) 0xbc, (byte) 0x9f, (byte) 0xaa, (byte) 0x8b, + (byte) 0xee, (byte) 0x40, (byte) 0xc8, (byte) 0xfc, (byte) 0x6b, (byte) 0xb4, (byte) 0xf8, (byte) 0xfc, + (byte) 0x52, (byte) 0x7f, (byte) 0x71, (byte) 0xa5, (byte) 0xbd, (byte) 0x77, (byte) 0x1e, (byte) 0xff, + (byte) 0x0, (byte) 0xf1, (byte) 0x7b, (byte) 0x10, (byte) 0xfc, (byte) 0x34, (byte) 0xc4, (byte) 0x29, + (byte) 0x9b, (byte) 0x9e, (byte) 0x9a, (byte) 0x46, (byte) 0xcb, (byte) 0xd3, (byte) 0xca, (byte) 0xef, + (byte) 0x6b, (byte) 0x92, (byte) 0xf, (byte) 0xc4, (byte) 0x29, (byte) 0xd4, (byte) 0x13, (byte) 0x47, + (byte) 0x62, (byte) 0x14, (byte) 0x9a, (byte) 0x9, (byte) 0x12, (byte) 0x58, (byte) 0x9c, (byte) 0x73, + (byte) 0x2b, (byte) 0xa1, (byte) 0x4, (byte) 0x30, (byte) 0xf3, (byte) 0x7, (byte) 0x57, (byte) 0xac, + (byte) 0x7b, (byte) 0x5e, (byte) 0xd0, (byte) 0xe6, (byte) 0x9b, (byte) 0x82, (byte) 0x80, (byte) 0x24, + (byte) 0x82, (byte) 0x48, (byte) 0x1e, (byte) 0x62, (byte) 0x95, (byte) 0xa5, (byte) 0xae, (byte) 0x1a, + (byte) 0x10, (byte) 0x45, (byte) 0x88, (byte) 0x3d, (byte) 0x42, (byte) 0xf7, (byte) 0x83, (byte) 0xae, + (byte) 0xdd, (byte) 0x75, (byte) 0xa1, (byte) 0x2, (byte) 0xd2, (byte) 0x47, (byte) 0x1a, (byte) 0x33, + (byte) 0xbb, (byte) 0x5, (byte) 0x45, (byte) 0x5, (byte) 0x99, (byte) 0x89, (byte) 0xc0, (byte) 0x0, + (byte) 0x77, (byte) 0x27, (byte) 0x49, (byte) 0xce, (byte) 0x0, (byte) 0xb9, (byte) 0x53, (byte) 0xcc, + (byte) 0x2e, (byte) 0x71, (byte) 0xb0, (byte) 0x17, (byte) 0x25, (byte) 0x73, (byte) 0xff, (byte) 0x0, + (byte) 0x1d, (byte) 0x71, (byte) 0x54, (byte) 0xfc, (byte) 0x4f, (byte) 0xba, (byte) 0x30, (byte) 0x46, + (byte) 0x64, (byte) 0xdb, (byte) 0x21, (byte) 0x62, (byte) 0x2b, (byte) 0xc5, (byte) 0xdb, (byte) 0x3f, + (byte) 0xbd, (byte) 0x87, (byte) 0xf9, (byte) 0x1f, (byte) 0xe8, (byte) 0x74, (byte) 0xf3, (byte) 0xc8, + (byte) 0x46, (byte) 0x25, (byte) 0x5e, (byte) 0xea, (byte) 0xb9, (byte) 0x3f, (byte) 0xc4, (byte) 0x6c, + (byte) 0x3e, (byte) 0xeb, (byte) 0x6d, (byte) 0xf0, (byte) 0xbf, (byte) 0x87, (byte) 0xa3, (byte) 0xc2, + (byte) 0xa0, (byte) 0x5, (byte) 0xc2, (byte) 0xf2, (byte) 0xbb, (byte) 0xcc, (byte) 0x7e, (byte) 0xc3, + (byte) 0xa0, (byte) 0xf9, (byte) 0x9d, (byte) 0x79, (byte) 0x59, (byte) 0xa, (byte) 0x2e, (byte) 0x7, + (byte) 0x4d, (byte) 0x54, (byte) 0x92, (byte) 0x8c, (byte) 0xd8, (byte) 0xdb, (byte) 0x29, (byte) 0x1f, + (byte) 0xe, (byte) 0x55, (byte) 0xbc, (byte) 0x86, (byte) 0x69, (byte) 0xea, (byte) 0x30, (byte) 0xc, + (byte) 0x22, (byte) 0x62, (byte) 0x63, (byte) 0x75, (byte) 0x24, (byte) 0x48, (byte) 0x83, (byte) 0xbe, + (byte) 0x7d, (byte) 0x3b, (byte) 0x75, (byte) 0x3e, (byte) 0x24, (byte) 0xe, (byte) 0xe4, (byte) 0x69, + (byte) 0xe8, (byte) 0xc, (byte) 0x8c, (byte) 0xbb, (byte) 0xd8, (byte) 0xa2, (byte) 0x56, (byte) 0x54, + (byte) 0xd3, (byte) 0x87, (byte) 0x32, (byte) 0x9, (byte) 0x4e, (byte) 0xae, (byte) 0x3a, (byte) 0x5b, + (byte) 0xd3, (byte) 0xaa, (byte) 0x7f, (byte) 0xc0, (byte) 0x7c, (byte) 0x5e, (byte) 0xdb, (byte) 0x2d, + (byte) 0xd1, (byte) 0x5, (byte) 0xd9, (byte) 0x11, (byte) 0x36, (byte) 0xb9, (byte) 0x64, (byte) 0xc3, + (byte) 0x87, (byte) 0x6c, (byte) 0x8, (byte) 0x89, (byte) 0xfb, (byte) 0x86, (byte) 0x7b, (byte) 0xf, + (byte) 0x3d, (byte) 0x59, (byte) 0xe1, (byte) 0x38, (byte) 0x8b, (byte) 0xa0, (byte) 0x7e, (byte) 0x43, + (byte) 0xe5, (byte) 0x3e, (byte) 0x9c, (byte) 0xba, (byte) 0xa1, (byte) 0x6f, (byte) 0x1b, (byte) 0x78, + (byte) 0x6e, (byte) 0x9a, (byte) 0xbe, (byte) 0x98, (byte) 0xd5, (byte) 0x5c, (byte) 0x36, (byte) 0x66, + (byte) 0xd, (byte) 0x9, (byte) 0xb0, (byte) 0xcd, (byte) 0x6f, (byte) 0xd2, (byte) 0x6f, (byte) 0xfe, + (byte) 0xbc, (byte) 0x8f, (byte) 0x4b, (byte) 0xab, (byte) 0xa6, (byte) 0xad, (byte) 0x9a, (byte) 0xf7, + (byte) 0x2b, (byte) 0xa4, (byte) 0xf4, (byte) 0xe7, (byte) 0x86, (byte) 0xc4, (byte) 0xf, (byte) 0xd5, + (byte) 0x65, (byte) 0x85, (byte) 0xc3, (byte) 0xab, (byte) 0x7b, (byte) 0x11, (byte) 0xd0, (byte) 0xe8, + (byte) 0xc5, (byte) 0xaf, (byte) 0xe, (byte) 0x17, (byte) 0x69, (byte) 0xba, (byte) 0xc2, (byte) 0xf2, + (byte) 0x16, (byte) 0x9b, (byte) 0x38, (byte) 0x59, (byte) 0x40, (byte) 0x78, (byte) 0xd6, (byte) 0xf3, + (byte) 0xa7, (byte) 0x8, (byte) 0xee, (byte) 0xe6, (byte) 0x33, (byte) 0xf5, (byte) 0x1a, (byte) 0xec, + (byte) 0xbd, (byte) 0x3c, (byte) 0x8f, (byte) 0x43, (byte) 0xfd, (byte) 0x13, (byte) 0xaa, (byte) 0xea, + (byte) 0xd9, (byte) 0x4f, (byte) 0x1, (byte) 0xe0, (byte) 0x72, (byte) 0x45, (byte) 0x78, (byte) 0x4c, + (byte) 0x2d, (byte) 0xfc, (byte) 0xf4, (byte) 0x39, (byte) 0xb6, (byte) 0xcc, (byte) 0x3e, (byte) 0x5b, + (byte) 0x7c, (byte) 0xd5, (byte) 0xb, (byte) 0x59, (byte) 0xb3, (byte) 0xa0, (byte) 0xd7, (byte) 0x85, + (byte) 0xb5, (byte) 0x53, (byte) 0x3e, (byte) 0xe9, (byte) 0xe6, (byte) 0xc6, (byte) 0x6a, (byte) 0x35, + (byte) 0xe4, (byte) 0x5d, (byte) 0xc1, (byte) 0x9d, (byte) 0x6b, (byte) 0xb0, (byte) 0x21, (byte) 0x9a, + (byte) 0x3c, (byte) 0x64, (byte) 0x7a, (byte) 0x8c, (byte) 0xe9, (byte) 0xa6, (byte) 0xe5, (byte) 0x7, + (byte) 0xfa, (byte) 0xb6, (byte) 0x53, (byte) 0xe5, (byte) 0x74, (byte) 0x9c, (byte) 0x33, (byte) 0xc2, + (byte) 0xf3, (byte) 0x75, (byte) 0x5b, (byte) 0xa5, (byte) 0xdf, (byte) 0x61, (byte) 0xda, (byte) 0x4f, + (byte) 0xc9, (byte) 0xb7, (byte) 0x3d, (byte) 0xc6, (byte) 0x4b, (byte) 0x32, (byte) 0x34, (byte) 0xb, + (byte) 0x65, (byte) 0x47, (byte) 0x53, (byte) 0x0, (byte) 0xc1, (byte) 0x18, (byte) 0xcf, (byte) 0x7f, + (byte) 0xbb, (byte) 0xa7, (byte) 0x99, (byte) 0xf5, (byte) 0x3a, (byte) 0x71, (byte) 0xb1, (byte) 0x49, + (byte) 0x35, (byte) 0xf2, (byte) 0x1d, (byte) 0x96, (byte) 0x6f, (byte) 0x8d, (byte) 0x62, (byte) 0x2f, + (byte) 0xa2, (byte) 0xc5, (byte) 0x44, (byte) 0xf1, (byte) 0x58, (byte) 0x90, (byte) 0xdb, (byte) 0x5b, + (byte) 0x70, (byte) 0xe, (byte) 0xbb, (byte) 0xf5, (byte) 0x6, (byte) 0xc5, (byte) 0x19, (byte) 0xc5, + (byte) 0xd4, (byte) 0xf6, (byte) 0xad, (byte) 0xbe, (byte) 0x18, (byte) 0x2d, (byte) 0x52, (byte) 0x13, + (byte) 0xd9, (byte) 0x2e, (byte) 0x3, (byte) 0x27, (byte) 0x2c, (byte) 0x79, (byte) 0x3c, (byte) 0x84, + (byte) 0x2, (byte) 0xf, (byte) 0x29, (byte) 0x39, (byte) 0xd, (byte) 0xea, (byte) 0x7d, (byte) 0x3b, + (byte) 0x75, (byte) 0xcb, (byte) 0x70, (byte) 0xe7, (byte) 0x75, (byte) 0xe2, (byte) 0x6, (byte) 0xdc, + (byte) 0xfd, (byte) 0x2, (byte) 0x8d, (byte) 0x84, (byte) 0xe2, (byte) 0x74, (byte) 0xfc, (byte) 0x73, + (byte) 0x55, (byte) 0x5d, (byte) 0x1b, (byte) 0xa6, (byte) 0x94, (byte) 0xed, (byte) 0xb1, (byte) 0xb7, + (byte) 0x60, (byte) 0x4f, (byte) 0xc3, (byte) 0x4d, (byte) 0x3d, (byte) 0x2, (byte) 0xb9, (byte) 0xf8, + (byte) 0x3, (byte) 0x88, (byte) 0xdb, (byte) 0x88, (byte) 0xf6, (byte) 0x48, (byte) 0x67, (byte) 0x6d, + (byte) 0xaf, (byte) 0x72, (byte) 0xa5, (byte) 0xcb, (byte) 0x1a, (byte) 0xab, (byte) 0x49, (byte) 0x6e, + (byte) 0x25, (byte) 0x45, (byte) 0x99, (byte) 0x80, (byte) 0xc3, (byte) 0x14, (byte) 0xc3, (byte) 0x12, + (byte) 0x46, (byte) 0x41, (byte) 0xee, (byte) 0x6, (byte) 0x8f, (byte) 0x68, (byte) 0xe7, (byte) 0x32, + (byte) 0xc4, (byte) 0xd2, (byte) 0x79, (byte) 0x6f, (byte) 0xe8, (byte) 0x4a, (byte) 0x2, (byte) 0xc5, + (byte) 0x29, (byte) 0x44, (byte) 0x15, (byte) 0x52, (byte) 0x34, (byte) 0x2, (byte) 0xd1, (byte) 0x72, + (byte) 0x43, (byte) 0x48, (byte) 0xb1, (byte) 0x0, (byte) 0xea, (byte) 0x1, (byte) 0x1d, (byte) 0x88, + (byte) 0x49, (byte) 0xae, (byte) 0xc0, (byte) 0x96, (byte) 0xea, (byte) 0x4f, (byte) 0x5a, (byte) 0x6f, + (byte) 0xd2, (byte) 0x9a, (byte) 0x36, (byte) 0x8d, (byte) 0xbd, (byte) 0x88, (byte) 0xc1, (byte) 0xd4, + (byte) 0x77, (byte) 0x8c, (byte) 0xcd, (byte) 0x2d, (byte) 0x3e, (byte) 0xaa, (byte) 0xce, (byte) 0x37, + (byte) 0x18, (byte) 0x9e, (byte) 0x24, (byte) 0x6e, (byte) 0xe0, (byte) 0xdf, (byte) 0xe0, (byte) 0xb9, + (byte) 0xfa, (byte) 0x4a, (byte) 0xf3, (byte) 0x50, (byte) 0xbd, (byte) 0x3d, (byte) 0x4b, (byte) 0x0, + (byte) 0xac, (byte) 0xd0, (byte) 0xb9, (byte) 0x46, (byte) 0x1e, (byte) 0xa3, (byte) 0xc7, (byte) 0xdb, + (byte) 0x42, (byte) 0xd3, (byte) 0x30, (byte) 0xb4, (byte) 0x90, (byte) 0x56, (byte) 0xaf, (byte) 0x86, + (byte) 0xd4, (byte) 0x89, (byte) 0x58, (byte) 0x1e, (byte) 0xd3, (byte) 0xa1, (byte) 0x4c, (byte) 0x76, + (byte) 0xe1, (byte) 0x1b, (byte) 0xdc, (byte) 0x84, (byte) 0xd9, (byte) 0x23, (byte) 0xe4, (byte) 0x2b, + (byte) 0x7, (byte) 0x91, (byte) 0x73, (byte) 0x8e, (byte) 0x65, (byte) 0x1d, (byte) 0x48, (byte) 0xf7, + (byte) 0x20, (byte) 0x11, (byte) 0xfc, (byte) 0xea, (byte) 0x31, (byte) 0xd1, (byte) 0x59, (byte) 0x55, + (byte) 0x36, (byte) 0x69, (byte) 0x20, (byte) 0x73, (byte) 0x62, (byte) 0x75, (byte) 0x9c, (byte) 0x74, + (byte) 0x1d, (byte) 0x2f, (byte) 0xa5, (byte) 0xfd, (byte) 0xb7, (byte) 0xf6, (byte) 0x52, (byte) 0x7b, + (byte) 0xd3, (byte) 0x52, (byte) 0xde, (byte) 0x52, (byte) 0x2b, (byte) 0x97, (byte) 0xab, (byte) 0x6, + (byte) 0x44, (byte) 0x95, (byte) 0x5a, (byte) 0x34, (byte) 0xce, (byte) 0x3e, (byte) 0x5a, (byte) 0x82, + (byte) 0xa0, (byte) 0x9f, (byte) 0xe, (byte) 0xfd, (byte) 0x7d, (byte) 0x87, (byte) 0xe7, (byte) 0x4c, + (byte) 0xc, (byte) 0xf1, (byte) 0x13, (byte) 0xc2, (byte) 0x36, (byte) 0xb8, (byte) 0x59, (byte) 0xdc, + (byte) 0xf8, (byte) 0x23, (byte) 0xdd, (byte) 0x59, (byte) 0x25, (byte) 0x2d, (byte) 0x35, (byte) 0xdd, + (byte) 0xc3, (byte) 0x0, (byte) 0x9e, (byte) 0xa7, (byte) 0x7b, (byte) 0x77, (byte) 0x20, (byte) 0xe9, + (byte) 0xd9, (byte) 0x1, (byte) 0x7e, (byte) 0xed, (byte) 0xcd, (byte) 0xd4, (byte) 0xc5, (byte) 0x16, + (byte) 0xcc, (byte) 0xcb, (byte) 0x60, (byte) 0xca, (byte) 0xe1, (byte) 0xd, (byte) 0x76, (byte) 0x24, + (byte) 0x16, (byte) 0x70, (byte) 0x70, (byte) 0x1, (byte) 0xfd, (byte) 0xd8, (byte) 0xc7, (byte) 0x5f, + (byte) 0x51, (byte) 0x9e, (byte) 0xd8, (byte) 0xd3, (byte) 0xd1, (byte) 0x42, (byte) 0x1, (byte) 0x11, + (byte) 0xbe, (byte) 0xf7, (byte) 0x3c, (byte) 0xb9, (byte) 0xfd, (byte) 0xd5, (byte) 0x9e, (byte) 0xd, + (byte) 0x1d, (byte) 0x4c, (byte) 0x14, (byte) 0xe7, (byte) 0x10, (byte) 0xa0, (byte) 0x94, (byte) 0x59, + (byte) 0xb7, (byte) 0xce, (byte) 0xc7, (byte) 0xed, (byte) 0xa6, (byte) 0xfa, (byte) 0xfa, (byte) 0x5c, + (byte) 0x6b, (byte) 0xe9, (byte) 0xd4, (byte) 0x9b, (byte) 0x2b, (byte) 0xe3, (byte) 0x82, (byte) 0x23, + (byte) 0x9a, (byte) 0xaf, (byte) 0xc, (byte) 0xd1, (byte) 0xa9, (byte) 0x6a, (byte) 0x8c, (byte) 0xd4, + (byte) 0x6c, (byte) 0x57, (byte) 0x4f, (byte) 0x97, (byte) 0x24, (byte) 0x32, (byte) 0xb2, (byte) 0x3f, + (byte) 0xd5, (byte) 0xdc, (byte) 0xb0, (byte) 0x64, (byte) 0x24, (byte) 0x15, (byte) 0x24, (byte) 0x92, + (byte) 0xe, (byte) 0x7f, (byte) 0x81, (byte) 0xa3, (byte) 0x8a, (byte) 0x48, (byte) 0xf8, (byte) 0x10, + (byte) 0xb6, (byte) 0x2e, (byte) 0x4b, (byte) 0x3c, (byte) 0xc5, (byte) 0xaa, (byte) 0xce, (byte) 0x21, + (byte) 0x5b, (byte) 0x25, (byte) 0x5b, (byte) 0xbf, (byte) 0x59, (byte) 0xbf, (byte) 0x61, (byte) 0xb0, + (byte) 0x1e, (byte) 0xc0, (byte) 0x4, (byte) 0xbe, (byte) 0x6a, (byte) 0xf9, (byte) 0xce, (byte) 0x35, + (byte) 0xe7, (byte) 0x35, (byte) 0x4b, (byte) 0x50, (byte) 0xe, (byte) 0x3c, (byte) 0xe1, (byte) 0x64, + (byte) 0xdc, (byte) 0xe5, (byte) 0x4b, (byte) 0x35, (byte) 0xf1, (byte) 0x15, (byte) 0xe0, (byte) 0x30, + (byte) 0x5b, (byte) 0xc2, (byte) 0x41, (byte) 0xe0, (byte) 0x1b, (byte) 0xfd, (byte) 0xff, (byte) 0x0, + (byte) 0xc2, (byte) 0xae, (byte) 0xae, (byte) 0x97, (byte) 0x89, (byte) 0xa8, (byte) 0xdd, (byte) 0x5d, + (byte) 0x61, (byte) 0x38, (byte) 0xb3, (byte) 0xa8, (byte) 0x8e, (byte) 0x57, (byte) 0x6a, (byte) 0xcf, + (byte) 0xa7, (byte) 0x6f, (byte) 0xd9, (byte) 0x40, (byte) 0xdf, (byte) 0x68, (byte) 0xdc, (byte) 0xab, + (byte) 0x37, (byte) 0x24, (byte) 0xd4, (byte) 0xa6, (byte) 0x38, (byte) 0xf1, (byte) 0x45, (byte) 0xe7, + (byte) 0x1f, (byte) 0x91, (byte) 0xaa, (byte) 0x39, (byte) 0x29, (byte) 0x65, (byte) 0x6e, (byte) 0xed, + (byte) 0x5a, (byte) 0x15, (byte) 0x1e, (byte) 0x37, (byte) 0x47, (byte) 0x30, (byte) 0xd2, (byte) 0x40, + (byte) 0x3b, (byte) 0x9b, (byte) 0x7d, (byte) 0x53, (byte) 0x3d, (byte) 0xaf, (byte) 0x67, (byte) 0xdd, + (byte) 0xf7, (byte) 0x14, (byte) 0x58, (byte) 0xaa, (byte) 0xd1, (byte) 0x9d, (byte) 0xd5, (byte) 0x49, + (byte) 0xc1, (byte) 0x65, (byte) 0xe5, (byte) 0x51, (byte) 0x9c, (byte) 0x7d, (byte) 0xc7, (byte) 0x3, + (byte) 0xc3, (byte) 0x4d, (byte) 0xb2, (byte) 0x92, (byte) 0x69, (byte) 0x8d, (byte) 0x98, (byte) 0xd2, + (byte) 0xa4, (byte) 0x49, (byte) 0x89, (byte) 0x61, (byte) 0x94, (byte) 0xf, (byte) 0x7d, (byte) 0x44, + (byte) 0x92, (byte) 0x0, (byte) 0xe7, (byte) 0xda, (byte) 0xfa, (byte) 0xdc, (byte) 0x9b, (byte) 0x6d, + (byte) 0xa0, (byte) 0xb9, (byte) 0x56, (byte) 0x47, (byte) 0x5, (byte) 0xf0, (byte) 0x2c, (byte) 0x5b, + (byte) 0x4d, (byte) 0x94, (byte) 0xdc, (byte) 0x37, (byte) 0x7, (byte) 0xf9, (byte) 0x97, (byte) 0x81, + (byte) 0xe6, (byte) 0x54, (byte) 0x89, (byte) 0x8a, (byte) 0xa2, (byte) 0x1f, (byte) 0x33, (byte) 0x8c, + (byte) 0x73, (byte) 0x1f, (byte) 0x7e, (byte) 0x9d, (byte) 0x4f, (byte) 0x7d, (byte) 0x5f, (byte) 0xd1, + (byte) 0x61, (byte) 0xdc, (byte) 0x1b, (byte) 0x3e, (byte) 0x53, (byte) 0x72, (byte) 0x36, (byte) 0x1c, + (byte) 0xbf, (byte) 0x9f, (byte) 0xe, (byte) 0xeb, (byte) 0x3a, (byte) 0xc7, (byte) 0xf1, (byte) 0xf8, + (byte) 0xab, (byte) 0x9e, (byte) 0xf6, (byte) 0xd1, (byte) 0x47, (byte) 0x90, (byte) 0x3b, (byte) 0xcc, + (byte) 0xed, (byte) 0x8b, (byte) 0xfb, (byte) 0x81, (byte) 0xa5, (byte) 0xbb, (byte) 0xdc, (byte) 0xf6, + (byte) 0xd4, (byte) 0x2b, (byte) 0x1e, (byte) 0x26, (byte) 0xe6, (byte) 0x41, (byte) 0x9e, (byte) 0xfa, + (byte) 0xb8, (byte) 0xe, (byte) 0xb8, (byte) 0x41, (byte) 0xce, (byte) 0x65, (byte) 0x8a, (byte) 0x5, + (byte) 0xea, (byte) 0x83, (byte) 0xe1, (byte) 0xa7, (byte) 0x4b, (byte) 0x41, (byte) 0x56, (byte) 0x65, + (byte) 0x2d, (byte) 0xbb, (byte) 0xb7, (byte) 0x7, (byte) 0x90, (byte) 0x12, (byte) 0x3c, (byte) 0x34, + (byte) 0xc3, (byte) 0xa3, (byte) 0xd5, (byte) 0x26, (byte) 0xeb, (byte) 0x4c, (byte) 0x5b, (byte) 0x6c, + (byte) 0x68, (byte) 0x73, (byte) 0xca, (byte) 0x33, (byte) 0xa4, (byte) 0xf0, (byte) 0xc0, (byte) 0x49, + (byte) 0x25, (byte) 0x1f, (byte) 0x14, (byte) 0x41, (byte) 0x40, (byte) 0xd7, (byte) 0x53, (byte) 0x64, + (byte) 0x22, (byte) 0x54, (byte) 0x79, (byte) 0x69, (byte) 0x4, (byte) 0xaf, (byte) 0x6, (byte) 0xa2, + (byte) 0xe2, (byte) 0xfa, (byte) 0x53, (byte) 0xd7, (byte) 0x5d, (byte) 0x1a, (byte) 0x4, (byte) 0xd3, + (byte) 0x85, (byte) 0xca, (byte) 0xff, (byte) 0xd9, (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, + (byte) 0xa, (byte) 0x0, (byte) 0xa, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x0, (byte) 0x0, + (byte) 0x37, (byte) 0xa4, (byte) 0x5c, (byte) 0x38, (byte) 0x52, (byte) 0x69, (byte) 0x4c, (byte) 0x69, + (byte) 0x24, (byte) 0x6, (byte) 0x0, (byte) 0x0, (byte) 0x24, (byte) 0x6, (byte) 0x0, (byte) 0x0, + (byte) 0x1b, (byte) 0x0, (byte) 0x7, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x2f, (byte) 0x64, (byte) 0x72, + (byte) 0x61, (byte) 0x77, (byte) 0x61, (byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0x2f, (byte) 0x73, + (byte) 0x69, (byte) 0x7a, (byte) 0x65, (byte) 0x5f, (byte) 0x34, (byte) 0x38, (byte) 0x78, (byte) 0x34, + (byte) 0x38, (byte) 0x2e, (byte) 0x6a, (byte) 0x70, (byte) 0x67, (byte) 0xfe, (byte) 0xca, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x5, (byte) 0x6, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x1, (byte) 0x0, + (byte) 0x50, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x64, (byte) 0x6, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, + }; + + /* + * Jar file created by Apache Commons-Compress which creates + * a CEN entry with a Zip64 extra header entry with a size of 0 + * ----------------#1-------------------- + * [Central Directory Header] + * 0x52b: Signature : 0x02014b50 + * 0x52f: Created Zip Spec : 0x2d [4.5] + * 0x530: Created OS : 0x3 [UNIX] + * 0x531: VerMadeby : 0x32d [3, 4.5] + * 0x532: VerExtract : 0x2d [4.5] + * 0x533: Flag : 0x800 + * 0x535: Method : 0x0 [STORED] + * 0x537: Last Mod Time : 0x570169c0 [Tue Aug 01 13:14:00 EDT 2023] + * 0x53b: CRC : 0x0 + * 0x53f: Compressed Size : 0x0 + * 0x543: Uncompressed Size: 0x0 + * 0x547: Name Length : 0x9 + * 0x549: Extra Length : 0x8 + * [tag=0x0001, sz=0, data= ] + * ->ZIP64: + * [tag=0xcafe, sz=0, data= ] + * ->[tag=cafe, size=0] + * 0x54b: Comment Length : 0x0 + * 0x54d: Disk Start : 0x0 + * 0x54f: Attrs : 0x0 + * 0x551: AttrsEx : 0x41ed0010 + * 0x555: Loc Header Offset: 0x0 + * 0x559: File Name : META-INF/ + */ + public static byte[] COMMONS_COMPRESS_JAR = { + (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, + (byte) 0x0, (byte) 0x0, (byte) 0xc0, (byte) 0x69, (byte) 0x1, (byte) 0x57, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0x9, (byte) 0x0, (byte) 0x18, (byte) 0x0, (byte) 0x4d, (byte) 0x45, + (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, (byte) 0x1, + (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xfe, (byte) 0xca, (byte) 0x0, (byte) 0x0, (byte) 0x50, + (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x8, + (byte) 0x0, (byte) 0xbd, (byte) 0x69, (byte) 0x1, (byte) 0x57, (byte) 0x71, (byte) 0xa7, (byte) 0x16, + (byte) 0x53, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0x14, (byte) 0x0, (byte) 0x14, (byte) 0x0, (byte) 0x4d, (byte) 0x45, (byte) 0x54, + (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, (byte) 0x4d, (byte) 0x41, + (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, (byte) 0x54, (byte) 0x2e, (byte) 0x4d, + (byte) 0x46, (byte) 0x1, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x68, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x5b, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xf3, (byte) 0x4d, (byte) 0xcc, + (byte) 0xcb, (byte) 0x4c, (byte) 0x4b, (byte) 0x2d, (byte) 0x2e, (byte) 0xd1, (byte) 0xd, (byte) 0x4b, + (byte) 0x2d, (byte) 0x2a, (byte) 0xce, (byte) 0xcc, (byte) 0xcf, (byte) 0xb3, (byte) 0x52, (byte) 0x30, + (byte) 0xd4, (byte) 0x33, (byte) 0xe0, (byte) 0xe5, (byte) 0x72, (byte) 0xcc, (byte) 0x43, (byte) 0x12, + (byte) 0x71, (byte) 0x2c, (byte) 0x48, (byte) 0x4c, (byte) 0xce, (byte) 0x48, (byte) 0x55, (byte) 0x0, + (byte) 0x8a, (byte) 0x1, (byte) 0x25, (byte) 0xd, (byte) 0xd, (byte) 0xf4, (byte) 0x2c, (byte) 0x78, + (byte) 0xb9, (byte) 0x9c, (byte) 0x8b, (byte) 0x52, (byte) 0x13, (byte) 0x4b, (byte) 0x52, (byte) 0x53, + (byte) 0x74, (byte) 0x9d, (byte) 0x2a, (byte) 0x81, (byte) 0x1a, (byte) 0x2c, (byte) 0xf4, (byte) 0xc, + (byte) 0xf4, (byte) 0x80, (byte) 0x12, (byte) 0xda, (byte) 0x46, (byte) 0xba, (byte) 0x66, (byte) 0xa, + (byte) 0x1a, (byte) 0xfe, (byte) 0x45, (byte) 0x89, (byte) 0xc9, (byte) 0x39, (byte) 0xa9, (byte) 0xa, + (byte) 0xce, (byte) 0xf9, (byte) 0x45, (byte) 0x5, (byte) 0xf9, (byte) 0x45, (byte) 0x89, (byte) 0x25, + (byte) 0x40, (byte) 0x3, (byte) 0x34, (byte) 0x79, (byte) 0xb9, (byte) 0x78, (byte) 0xb9, (byte) 0x0, + (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, + (byte) 0x8, (byte) 0x0, (byte) 0x61, (byte) 0x69, (byte) 0x1, (byte) 0x57, (byte) 0x16, (byte) 0x64, + (byte) 0x9c, (byte) 0xc5, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0x19, (byte) 0x0, (byte) 0x14, (byte) 0x0, (byte) 0x5a, (byte) 0x69, + (byte) 0x70, (byte) 0x46, (byte) 0x69, (byte) 0x6c, (byte) 0x65, (byte) 0x50, (byte) 0x72, (byte) 0x6f, + (byte) 0x70, (byte) 0x65, (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x54, (byte) 0x65, (byte) 0x73, + (byte) 0x74, (byte) 0x2e, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x1, + (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0xf, (byte) 0x7, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x4, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x85, (byte) 0x55, (byte) 0xcf, (byte) 0x53, (byte) 0xdb, + (byte) 0x46, (byte) 0x14, (byte) 0xfe, (byte) 0xd6, (byte) 0x3f, (byte) 0x90, (byte) 0x2d, (byte) 0x8b, + (byte) 0x38, (byte) 0x36, (byte) 0x21, (byte) 0xc1, (byte) 0x34, (byte) 0x4, (byte) 0x12, (byte) 0x70, + (byte) 0x63, (byte) 0xb0, (byte) 0x8d, (byte) 0xdb, (byte) 0x42, (byte) 0xd3, (byte) 0x36, (byte) 0xa6, + (byte) 0xf9, (byte) 0x45, (byte) 0x42, (byte) 0xb, (byte) 0x35, (byte) 0xe0, (byte) 0x62, (byte) 0x87, + (byte) 0xd4, (byte) 0xa4, (byte) 0x6d, (byte) 0x22, (byte) 0xdb, (byte) 0x4a, (byte) 0x22, (byte) 0x2a, + (byte) 0x4b, (byte) 0x1a, (byte) 0x49, (byte) 0x2e, (byte) 0x49, (byte) 0x67, (byte) 0x7a, (byte) 0xe8, + (byte) 0x4c, (byte) 0xcf, (byte) 0x9d, (byte) 0x69, (byte) 0xfe, (byte) 0x82, (byte) 0xde, (byte) 0x38, + (byte) 0xf5, (byte) 0x40, (byte) 0xe, (byte) 0x86, (byte) 0x94, (byte) 0x49, (byte) 0x73, (byte) 0xcb, + (byte) 0x21, (byte) 0xff, (byte) 0x51, (byte) 0x2f, (byte) 0xa5, (byte) 0x6f, (byte) 0x25, (byte) 0xc0, + (byte) 0x86, (byte) 0x98, (byte) 0x29, (byte) 0xcc, (byte) 0x68, (byte) 0x77, (byte) 0xdf, (byte) 0xee, + (byte) 0xf7, (byte) 0xbd, (byte) 0xf7, (byte) 0xbe, (byte) 0xf7, (byte) 0x76, (byte) 0xfd, (byte) 0xf6, + (byte) 0xdf, (byte) 0xbf, (byte) 0xfe, (byte) 0x6, (byte) 0x70, (byte) 0xb, (byte) 0xf, (byte) 0x45, + (byte) 0xf8, (byte) 0xe0, (byte) 0x17, (byte) 0x10, (byte) 0x90, (byte) 0x10, (byte) 0x44, (byte) 0xf, + (byte) 0xc3, (byte) 0xe9, (byte) 0x75, (byte) 0xf9, (byte) 0x47, (byte) 0x39, (byte) 0xa7, (byte) 0xc9, + (byte) 0xfa, (byte) 0xe3, (byte) 0xdc, (byte) 0x72, (byte) 0x75, (byte) 0x5d, (byte) 0xa9, (byte) 0x39, + (byte) 0xc, (byte) 0x3d, (byte) 0x33, (byte) 0xaa, (byte) 0xae, (byte) 0x3a, (byte) 0xd7, (byte) 0x18, + (byte) 0xfc, (byte) 0xa9, (byte) 0xf1, (byte) 0x55, (byte) 0x1, (byte) 0x21, (byte) 0x86, (byte) 0xbe, + (byte) 0x35, (byte) 0xd5, (byte) 0x9c, (byte) 0x53, (byte) 0x35, (byte) 0xa5, (byte) 0x68, (byte) 0x19, + (byte) 0xa6, (byte) 0x62, (byte) 0x39, (byte) 0xcf, (byte) 0xca, (byte) 0x8a, (byte) 0xed, (byte) 0x88, + (byte) 0x10, (byte) 0xe0, (byte) 0xe7, (byte) 0x9f, (byte) 0x88, (byte) 0x4, (byte) 0x89, (byte) 0x33, + (byte) 0x9d, (byte) 0xb2, (byte) 0x14, (byte) 0xb9, (byte) 0x5e, (byte) 0x52, (byte) 0xf5, (byte) 0xc7, + (byte) 0x9a, (byte) 0xc2, (byte) 0xcf, (byte) 0xa, (byte) 0x38, (byte) 0xc5, (byte) 0xd0, (byte) 0xef, + (byte) 0xb2, (byte) 0x37, (byte) 0x1d, (byte) 0x55, (byte) 0xcb, (byte) 0xfd, (byte) 0xa4, (byte) 0x9a, + (byte) 0xb9, (byte) 0x7d, (byte) 0x9a, (byte) 0x10, (byte) 0x4e, (byte) 0x33, (byte) 0x64, (byte) 0x72, + (byte) 0x77, (byte) 0x6d, (byte) 0xc5, (byte) 0xb2, (byte) 0x73, (byte) 0xda, (byte) 0xba, (byte) 0xac, + (byte) 0xd7, (byte) 0xf9, (byte) 0xe4, (byte) 0xb6, (byte) 0xb1, (byte) 0xa1, (byte) 0x6b, (byte) 0x86, + (byte) 0x5c, (byte) 0xb7, (byte) 0x73, (byte) 0x1b, (byte) 0xb5, (byte) 0x29, (byte) 0xab, (byte) 0x6e, + (byte) 0xca, (byte) 0xe4, (byte) 0x48, (byte) 0x53, (byte) 0xab, (byte) 0xf6, (byte) 0xe4, (byte) 0xba, + (byte) 0x6c, (byte) 0x89, (byte) 0xe8, (byte) 0x45, (byte) 0x9c, (byte) 0x47, (byte) 0xdc, (byte) 0x47, + (byte) 0x9c, (byte) 0xa9, (byte) 0x42, (byte) 0x3b, (byte) 0xe6, (byte) 0x92, (byte) 0x63, (byte) 0x91, + (byte) 0xc7, (byte) 0xfc, (byte) 0xf8, (byte) 0x6a, (byte) 0x18, (byte) 0xfd, (byte) 0x38, (byte) 0x2b, + (byte) 0xe0, (byte) 0x9c, (byte) 0x84, (byte) 0x1, (byte) 0x24, (byte) 0x8e, (byte) 0xa4, (byte) 0x55, + (byte) 0x7a, (byte) 0x66, (byte) 0x3b, (byte) 0x4a, (byte) 0x83, (byte) 0xb2, (byte) 0x31, (byte) 0x9a, + (byte) 0x94, (byte) 0x5c, (byte) 0xbf, (byte) 0x7, (byte) 0x56, (byte) 0x8d, (byte) 0x5c, (byte) 0x91, + (byte) 0x90, (byte) 0xe, (byte) 0xe1, (byte) 0x15, (byte) 0xb9, (byte) 0x91, (byte) 0xf, (byte) 0xe1, + (byte) 0x3d, (byte) 0xc2, (byte) 0xf0, (byte) 0xd8, (byte) 0x46, (byte) 0x92, (byte) 0xf6, (byte) 0x8, + (byte) 0x25, (byte) 0xa9, (byte) 0x2b, (byte) 0xf5, (byte) 0xa4, (byte) 0x2e, (byte) 0x62, (byte) 0x8, + (byte) 0x17, (byte) 0x4, (byte) 0xc, (byte) 0x4b, (byte) 0x18, (byte) 0xc1, (byte) 0x45, (byte) 0x52, + (byte) 0xa1, (byte) 0xb, (byte) 0x92, (byte) 0xd4, (byte) 0x32, (byte) 0xf9, (byte) 0xea, (byte) 0x11, + (byte) 0xc3, (byte) 0x4c, (byte) 0x97, (byte) 0xb8, (byte) 0xee, (byte) 0x17, (byte) 0x8e, (byte) 0xcb, + (byte) 0x9b, (byte) 0x1f, (byte) 0xef, (byte) 0x1a, (byte) 0x0, (byte) 0x4f, (byte) 0x70, (byte) 0x54, + (byte) 0xc2, (byte) 0x18, (byte) 0x17, (byte) 0x32, (byte) 0x58, (byte) 0xd3, (byte) 0xc, (byte) 0x9b, + (byte) 0xf4, (byte) 0x7b, (byte) 0xff, (byte) 0xc0, (byte) 0xa5, (byte) 0xb, (byte) 0x2f, (byte) 0x3f, + (byte) 0xb1, (byte) 0x8c, (byte) 0xd, (byte) 0xb9, (byte) 0xaa, (byte) 0x29, (byte) 0x22, (byte) 0x92, + (byte) 0x48, (byte) 0x49, (byte) 0x18, (byte) 0xc7, (byte) 0x4, (byte) 0x43, (byte) 0xaf, (byte) 0x5c, + (byte) 0xaf, (byte) 0x97, (byte) 0x9a, (byte) 0xa6, (byte) 0x69, (byte) 0x29, (byte) 0xb6, (byte) 0xad, + (byte) 0xd4, (byte) 0x19, (byte) 0x6, (byte) 0x3a, (byte) 0x63, (byte) 0x38, (byte) 0x44, (byte) 0xe4, + (byte) 0x79, (byte) 0x19, (byte) 0x33, (byte) 0x1d, (byte) 0x9, (byte) 0xcc, (byte) 0x2f, (byte) 0xdf, + (byte) 0x79, (byte) 0x5a, (byte) 0x53, (byte) 0x4c, (byte) 0x47, (byte) 0x35, (byte) 0x74, (byte) 0x1, + (byte) 0x93, (byte) 0xc, (byte) 0x83, (byte) 0x6d, (byte) 0xd0, (byte) 0x4a, (byte) 0x53, (byte) 0x77, + (byte) 0xd4, (byte) 0x86, (byte) 0x72, (byte) 0xb8, (byte) 0x2f, (byte) 0x22, (byte) 0x8b, (byte) 0xf, + (byte) 0xb8, (byte) 0xf2, (byte) 0x13, (byte) 0x2, (byte) 0x3e, (byte) 0x3a, (byte) 0xaa, (byte) 0xab, + (byte) 0x9b, (byte) 0x62, (byte) 0x4, (byte) 0xd3, (byte) 0xf8, (byte) 0x58, (byte) 0xc0, (byte) 0x15, + (byte) 0x9, (byte) 0x9f, (byte) 0xe0, (byte) 0x53, (byte) 0x86, (byte) 0xb8, (byte) 0xbb, (byte) 0xaf, + (byte) 0x93, (byte) 0x8f, (byte) 0x47, (byte) 0x24, (byte) 0x66, (byte) 0xae, (byte) 0x28, (byte) 0x3b, + (byte) 0x4f, (byte) 0x18, (byte) 0x7c, (byte) 0x6, (byte) 0xc9, (byte) 0x93, (byte) 0xff, (byte) 0x1f, + (byte) 0x79, (byte) 0xe, (byte) 0x2a, (byte) 0x59, (byte) 0x78, (byte) 0x97, (byte) 0x21, (byte) 0x1f, + (byte) 0xc1, (byte) 0x55, (byte) 0xe4, (byte) 0x5, (byte) 0xcc, (byte) 0x70, (byte) 0x27, (byte) 0x9f, + (byte) 0x53, (byte) 0xd6, (byte) 0xed, (byte) 0xae, (byte) 0x5a, (byte) 0x94, (byte) 0x4d, (byte) 0x86, + (byte) 0x58, (byte) 0x6a, (byte) 0x1f, (byte) 0x75, (byte) 0x60, (byte) 0x22, (byte) 0x39, (byte) 0xaf, + (byte) 0xe3, (byte) 0x86, (byte) 0x80, (byte) 0x9b, (byte) 0x12, (byte) 0x75, (byte) 0xfc, (byte) 0x2c, + (byte) 0x43, (byte) 0xe2, (byte) 0x28, (byte) 0x27, (byte) 0xaf, (byte) 0xb3, (byte) 0xd7, (byte) 0x15, + (byte) 0x36, (byte) 0x91, (byte) 0xe9, (byte) 0xca, (byte) 0x46, (byte) 0xdb, (byte) 0xc0, (byte) 0x70, + (byte) 0x3d, (byte) 0xd5, (byte) 0x2d, (byte) 0x82, (byte) 0x63, (byte) 0xfc, (byte) 0xc7, (byte) 0xa3, + (byte) 0x6c, (byte) 0x13, (byte) 0x50, (byte) 0x2b, (byte) 0xdd, (byte) 0x61, (byte) 0x88, (byte) 0x74, + (byte) 0x74, (byte) 0x11, (byte) 0x57, (byte) 0xe8, (byte) 0xb, (byte) 0x9, (byte) 0x5f, (byte) 0x62, + (byte) 0x9e, (byte) 0xee, (byte) 0x88, (byte) 0x63, (byte) 0xdc, (byte) 0xac, (byte) 0xda, (byte) 0x86, + (byte) 0xd6, (byte) 0x74, (byte) 0x14, (byte) 0x4f, (byte) 0x9a, (byte) 0xb3, (byte) 0xa9, (byte) 0x13, + (byte) 0x12, (byte) 0x9e, (byte) 0xc6, (byte) 0x57, (byte) 0x12, (byte) 0xa, (byte) 0x58, (byte) 0x64, + (byte) 0x8, (byte) 0x39, (byte) 0x86, (byte) 0xa7, (byte) 0xd, (byte) 0xc3, (byte) 0x99, (byte) 0x83, + (byte) 0xd3, (byte) 0x9d, (byte) 0x8a, (byte) 0x89, (byte) 0x58, (byte) 0xc6, (byte) 0xa8, (byte) 0x80, + (byte) 0x22, (byte) 0x55, (byte) 0xff, (byte) 0xa4, (byte) 0xa0, (byte) 0x42, (byte) 0x58, (byte) 0xa1, + (byte) 0x22, (byte) 0x27, (byte) 0x75, (byte) 0xfe, (byte) 0x3f, (byte) 0x46, (byte) 0x7f, (byte) 0xbc, + (byte) 0xc9, (byte) 0x97, (byte) 0x96, (byte) 0xcb, (byte) 0x1d, (byte) 0x8d, (byte) 0x9e, (byte) 0x46, + (byte) 0x59, (byte) 0xc2, (byte) 0x5d, (byte) 0xde, (byte) 0x7d, (byte) 0x51, (byte) 0xd3, (byte) 0x6b, + (byte) 0x4b, (byte) 0xb9, (byte) 0xf6, (byte) 0x43, (byte) 0xd9, (byte) 0x92, (byte) 0x6b, (byte) 0xa, + (byte) 0x5, (byte) 0xb0, (byte) 0x36, (byte) 0x5f, (byte) 0x7c, (byte) 0x30, (byte) 0x37, (byte) 0x5f, + (byte) 0xa0, (byte) 0xbc, (byte) 0xe2, (byte) 0xef, (byte) 0xba, (byte) 0x27, (byte) 0x5, (byte) 0x67, + (byte) 0xd, (byte) 0xdd, (byte) 0x76, (byte) 0x64, (byte) 0xdd, (byte) 0x59, (byte) 0x95, (byte) 0xb5, + (byte) 0x26, (byte) 0x9d, (byte) 0xf, (byte) 0xcc, (byte) 0x1a, (byte) 0x75, (byte) 0x1a, (byte) 0xa2, + (byte) 0x5, (byte) 0x55, (byte) 0x57, (byte) 0x96, (byte) 0x9a, (byte) 0x8d, (byte) 0xaa, (byte) 0x62, + (byte) 0x95, (byte) 0x79, (byte) 0x17, (byte) 0xd2, (byte) 0x46, (byte) 0x43, (byte) 0x56, (byte) 0x75, + (byte) 0x9e, (byte) 0x73, (byte) 0xb7, (byte) 0xba, (byte) 0xaf, (byte) 0x12, (byte) 0x91, (byte) 0xeb, + (byte) 0x95, (byte) 0xf4, (byte) 0xdd, (byte) 0x3f, (byte) 0x2f, (byte) 0x96, (byte) 0x8c, (byte) 0xa6, + (byte) 0x55, (byte) 0x73, (byte) 0x5f, (byte) 0x13, (byte) 0x4a, (byte) 0xae, (byte) 0xcb, (byte) 0x1b, + (byte) 0x34, (byte) 0xc9, (byte) 0x69, (byte) 0x70, (byte) 0x91, (byte) 0x1e, (byte) 0x21, (byte) 0x1f, + (byte) 0x3d, (byte) 0x6e, (byte) 0x54, (byte) 0x67, (byte) 0xac, (byte) 0xe2, (byte) 0x1e, (byte) 0x8d, + (byte) 0xdf, (byte) 0xd0, (byte) 0xca, (byte) 0x87, (byte) 0x28, (byte) 0xfc, (byte) 0x34, (byte) 0xa7, + (byte) 0x57, (byte) 0x8e, (byte) 0xbe, (byte) 0x15, (byte) 0xb2, (byte) 0xc, (byte) 0xd1, (byte) 0xc8, + (byte) 0x68, (byte) 0xc, (byte) 0x4e, (byte) 0x6c, (byte) 0x83, (byte) 0x6d, (byte) 0xb9, (byte) 0x80, + (byte) 0x35, (byte) 0xfa, (byte) 0xf6, (byte) 0xb8, (byte) 0xc6, (byte) 0x10, (byte) 0xc2, (byte) 0xb8, + (byte) 0x8f, (byte) 0x6f, (byte) 0xf7, (byte) 0x8f, (byte) 0x5e, (byte) 0x26, (byte) 0x38, (byte) 0xb7, + (byte) 0x46, (byte) 0x76, (byte) 0x21, (byte) 0x54, (byte) 0xb6, (byte) 0x11, (byte) 0x6e, (byte) 0x41, + (byte) 0x6c, (byte) 0x3, (byte) 0x44, (byte) 0xd7, (byte) 0x9b, (byte) 0x4, (byte) 0x7e, (byte) 0x67, + (byte) 0x7d, (byte) 0xfc, (byte) 0xed, (byte) 0xf3, (byte) 0x40, (byte) 0xec, (byte) 0xf, (byte) 0x9a, + (byte) 0x5, (byte) 0x69, (byte) 0xe7, (byte) 0xc5, (byte) 0x2e, (byte) 0x7a, (byte) 0x2b, (byte) 0xf1, + (byte) 0xe8, (byte) 0x36, (byte) 0x62, (byte) 0x85, (byte) 0x17, (byte) 0x38, (byte) 0x13, (byte) 0x1f, + (byte) 0xc, (byte) 0xbc, (byte) 0x82, (byte) 0xaf, (byte) 0xe2, (byte) 0x8f, (byte) 0x47, (byte) 0x4b, + (byte) 0x2d, (byte) 0x9c, (byte) 0xbf, (byte) 0x97, (byte) 0x6e, (byte) 0xe1, (byte) 0xd2, (byte) 0x26, + (byte) 0xfa, (byte) 0x16, (byte) 0xbd, (byte) 0x31, (byte) 0xbc, (byte) 0x94, (byte) 0xc9, (byte) 0xb6, + (byte) 0x70, (byte) 0x39, (byte) 0xf3, (byte) 0x7a, (byte) 0x13, (byte) 0xbd, (byte) 0x85, (byte) 0x5d, + (byte) 0x64, (byte) 0x2b, (byte) 0xe9, (byte) 0x6d, (byte) 0xe4, (byte) 0x5e, (byte) 0xc7, (byte) 0xa3, + (byte) 0xfe, (byte) 0x57, (byte) 0xf8, (byte) 0x70, (byte) 0x7, (byte) 0x53, (byte) 0x85, (byte) 0xf4, + (byte) 0xe, (byte) 0x3e, (byte) 0xdb, (byte) 0xc1, (byte) 0xb5, (byte) 0x45, (byte) 0xce, (byte) 0x73, + (byte) 0xdb, (byte) 0xe3, (byte) 0x49, (byte) 0xbf, (byte) 0xc4, (byte) 0x1c, (byte) 0xc3, (byte) 0x4b, + (byte) 0x2c, (byte) 0x30, (byte) 0xb8, (byte) 0x84, (byte) 0x99, (byte) 0x37, (byte) 0x18, (byte) 0xc9, + (byte) 0xb4, (byte) 0xb0, (byte) 0xb4, (byte) 0x89, (byte) 0xc4, (byte) 0x12, (byte) 0xcd, (byte) 0xe3, + (byte) 0xde, (byte) 0x3c, (byte) 0x72, (byte) 0x35, (byte) 0x90, (byte) 0x4d, (byte) 0x4, (byte) 0x88, + (byte) 0x3a, (byte) 0x4b, (byte) 0xd4, (byte) 0xa3, (byte) 0x2e, (byte) 0xfe, (byte) 0xeb, (byte) 0x13, + (byte) 0xf0, (byte) 0x2d, (byte) 0x94, (byte) 0xb6, (byte) 0x28, (byte) 0x72, (byte) 0x11, (byte) 0xe7, + (byte) 0x31, (byte) 0x4a, (byte) 0x4f, (byte) 0xcb, (byte) 0x18, (byte) 0x52, (byte) 0xd4, (byte) 0xd, + (byte) 0x49, (byte) 0xca, (byte) 0x63, (byte) 0xa, (byte) 0x57, (byte) 0x68, (byte) 0xb6, (byte) 0x82, + (byte) 0x6, (byte) 0x9e, (byte) 0xd2, (byte) 0xfa, (byte) 0x67, (byte) 0xfc, (byte) 0x82, (byte) 0x5f, + (byte) 0x69, (byte) 0x5c, (byte) 0xc0, (byte) 0x6f, (byte) 0xf8, (byte) 0x9d, (byte) 0xec, (byte) 0x3e, + (byte) 0x57, (byte) 0x8b, (byte) 0x39, (byte) 0xc4, (byte) 0xe8, (byte) 0x1b, (byte) 0x23, (byte) 0xf4, + (byte) 0x39, (byte) 0xc2, (byte) 0xf, (byte) 0x10, (byte) 0x43, (byte) 0x8c, (byte) 0x70, (byte) 0x83, + (byte) 0x84, (byte) 0x1c, (byte) 0xa0, (byte) 0xbb, (byte) 0x9a, (byte) 0xc0, (byte) 0xd, (byte) 0xb2, + (byte) 0x2e, (byte) 0x90, (byte) 0xf2, (byte) 0x2b, (byte) 0xb8, (byte) 0x40, (byte) 0x3c, (byte) 0xc3, + (byte) 0xc4, (byte) 0x34, (byte) 0x44, (byte) 0xf8, (byte) 0x4b, (byte) 0xc4, (byte) 0x30, (byte) 0x8c, + (byte) 0xe7, (byte) 0xf4, (byte) 0xac, (byte) 0xfe, (byte) 0x49, (byte) 0xd5, (byte) 0xdb, (byte) 0x22, + (byte) 0xd4, (byte) 0x77, (byte) 0xc4, (byte) 0xf2, (byte) 0x10, (byte) 0xd2, (byte) 0x1e, (byte) 0x4d, + (byte) 0x7d, (byte) 0x2, (byte) 0x4, (byte) 0x81, (byte) 0xa4, (byte) 0x65, (byte) 0x2, (byte) 0x92, + (byte) 0x7b, (byte) 0xfc, (byte) 0x47, (byte) 0xc6, (byte) 0x5b, (byte) 0xd3, (byte) 0xca, (byte) 0x35, + (byte) 0x5, (byte) 0xff, (byte) 0x1, (byte) 0xbb, (byte) 0x25, (byte) 0x20, (byte) 0x1d, (byte) 0xde, + (byte) 0x23, (byte) 0x7, (byte) 0xde, (byte) 0xde, (byte) 0xb4, (byte) 0x40, (byte) 0x57, (byte) 0xc0, + (byte) 0x3b, (byte) 0x1e, (byte) 0x41, (byte) 0xe0, (byte) 0xd0, (byte) 0x74, (byte) 0x80, (byte) 0x10, + (byte) 0xf6, (byte) 0x11, (byte) 0xc3, (byte) 0x54, (byte) 0xa7, (byte) 0xef, (byte) 0xdd, (byte) 0xce, + (byte) 0x78, (byte) 0xf0, (byte) 0x1f, (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, + (byte) 0x3, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x0, (byte) 0x0, (byte) 0xc0, + (byte) 0x69, (byte) 0x1, (byte) 0x57, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x9, + (byte) 0x0, (byte) 0x8, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0xed, (byte) 0x41, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x4d, (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, + (byte) 0x46, (byte) 0x2f, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xfe, (byte) 0xca, + (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, (byte) 0x3, + (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0xbd, (byte) 0x69, + (byte) 0x1, (byte) 0x57, (byte) 0x71, (byte) 0xa7, (byte) 0x16, (byte) 0x53, (byte) 0x5b, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x68, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x14, (byte) 0x0, + (byte) 0x4, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0xa4, (byte) 0x81, (byte) 0x3f, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x4d, (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, + (byte) 0x2f, (byte) 0x4d, (byte) 0x41, (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, + (byte) 0x54, (byte) 0x2e, (byte) 0x4d, (byte) 0x46, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, (byte) 0x3, (byte) 0x2d, (byte) 0x0, + (byte) 0x0, (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0x61, (byte) 0x69, (byte) 0x1, (byte) 0x57, + (byte) 0x16, (byte) 0x64, (byte) 0x9c, (byte) 0xc5, (byte) 0x0, (byte) 0x4, (byte) 0x0, (byte) 0x0, + (byte) 0xf, (byte) 0x7, (byte) 0x0, (byte) 0x0, (byte) 0x19, (byte) 0x0, (byte) 0x4, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0xa4, (byte) 0x81, (byte) 0xe0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x5a, (byte) 0x69, + (byte) 0x70, (byte) 0x46, (byte) 0x69, (byte) 0x6c, (byte) 0x65, (byte) 0x50, (byte) 0x72, (byte) 0x6f, + (byte) 0x70, (byte) 0x65, (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x54, (byte) 0x65, (byte) 0x73, + (byte) 0x74, (byte) 0x2e, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x1, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x6, (byte) 0x6, (byte) 0x2c, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2d, + (byte) 0x0, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xd0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2b, (byte) 0x5, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x6, (byte) 0x7, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xfb, (byte) 0x5, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, + (byte) 0x4b, (byte) 0x5, (byte) 0x6, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, + (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0xd0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2b, + (byte) 0x5, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + }; + + /* + * Jar file created by Ant specifying zip64mode="always" and createUnicodeExtraFields="always" + * ----------------#1-------------------- + * [Central Directory Header] + * 0x51b: Signature : 0x02014b50 + * 0x51f: Created Zip Spec : 0x2d [4.5] + * 0x520: Created OS : 0x3 [UNIX] + * 0x521: VerMadeby : 0x32d [3, 4.5] + * 0x522: VerExtract : 0x2d [4.5] + * 0x523: Flag : 0x800 + * 0x525: Method : 0x8 [DEFLATED] + * 0x527: Last Mod Time : 0x570b3767 [Fri Aug 11 06:59:14 EDT 2023] + * 0x52b: CRC : 0x5e4fa53f + * 0x52f: Compressed Size : 0xffffffff + * 0x533: Uncompressed Size: 0xffffffff + * 0x537: Name Length : 0x10 + * 0x539: Extra Length : 0x35 + * Extra data:[01, 00, 18, 00, 87, 04, 00, 00, 00, 00, 00, 00, c7, 02, 00, 00, 00, 00, 00, 00, 15, 01, 00, 00, 00, 00, 00, 00, 75, 70, 15, 00, 01, 94, 82, 60, 61, 52, 65, 61, 64, 41, 6e, 74, 4a, 61, 72, 2e, 63, 6c, 61, 73, 73] + * [tag=0x0001, sz=24] + * ->ZIP64: size *0x487 csize *0x2c7 LOC Off *0x115 + * [data= 87 04 00 00 00 00 00 00 c7 02 00 00 00 00 00 00 15 01 00 00 00 00 00 00 ] + * [tag=0x7075, sz=21] + * ->[Unknown tag] + * [data= 01 94 82 60 61 52 65 61 64 41 6e 74 4a 61 72 2e 63 6c 61 73 73 ] + * 0x53b: Comment Length : 0x0 + * 0x53d: Disk Start : 0x0 + * 0x53f: Attrs : 0x0 + * 0x541: AttrsEx : 0x81a40000 + * 0x545: Loc Header Offset: 0xffffffff + * 0x549: File Name : ReadAntJar.class + */ + public static byte[] ANT_ZIP64_UNICODE_EXTRA_JAR = { + + (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, + (byte) 0x0, (byte) 0x0, (byte) 0x18, (byte) 0x7e, (byte) 0xe, (byte) 0x57, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0x9, (byte) 0x0, (byte) 0x2a, (byte) 0x0, (byte) 0x4d, (byte) 0x45, + (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, (byte) 0x1, + (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xfe, (byte) 0xca, (byte) 0x0, (byte) 0x0, (byte) 0x75, + (byte) 0x70, (byte) 0xe, (byte) 0x0, (byte) 0x1, (byte) 0x8, (byte) 0xa1, (byte) 0x8c, (byte) 0x13, + (byte) 0x4d, (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, + (byte) 0x2f, (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, + (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0x17, (byte) 0x7e, (byte) 0xe, (byte) 0x57, (byte) 0x31, + (byte) 0x59, (byte) 0x76, (byte) 0x4d, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x14, (byte) 0x0, (byte) 0x31, (byte) 0x0, (byte) 0x4d, + (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, + (byte) 0x4d, (byte) 0x41, (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, (byte) 0x54, + (byte) 0x2e, (byte) 0x4d, (byte) 0x46, (byte) 0x1, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x6e, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x61, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, + (byte) 0x70, (byte) 0x19, (byte) 0x0, (byte) 0x1, (byte) 0x85, (byte) 0x85, (byte) 0x84, (byte) 0x2, + (byte) 0x4d, (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, + (byte) 0x2f, (byte) 0x4d, (byte) 0x41, (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, + (byte) 0x54, (byte) 0x2e, (byte) 0x4d, (byte) 0x46, (byte) 0xf3, (byte) 0x4d, (byte) 0xcc, (byte) 0xcb, + (byte) 0x4c, (byte) 0x4b, (byte) 0x2d, (byte) 0x2e, (byte) 0xd1, (byte) 0xd, (byte) 0x4b, (byte) 0x2d, + (byte) 0x2a, (byte) 0xce, (byte) 0xcc, (byte) 0xcf, (byte) 0xb3, (byte) 0x52, (byte) 0x30, (byte) 0xd4, + (byte) 0x33, (byte) 0xe0, (byte) 0xe5, (byte) 0x72, (byte) 0xcc, (byte) 0x43, (byte) 0x12, (byte) 0x71, + (byte) 0x2c, (byte) 0x48, (byte) 0x4c, (byte) 0xce, (byte) 0x48, (byte) 0x55, (byte) 0x0, (byte) 0x8a, + (byte) 0x1, (byte) 0x25, (byte) 0xd, (byte) 0xd, (byte) 0xf4, (byte) 0xc, (byte) 0x4d, (byte) 0x12, + (byte) 0x73, (byte) 0xa, (byte) 0x32, (byte) 0x12, (byte) 0x79, (byte) 0xb9, (byte) 0x9c, (byte) 0x8b, + (byte) 0x52, (byte) 0x13, (byte) 0x4b, (byte) 0x52, (byte) 0x53, (byte) 0x74, (byte) 0x9d, (byte) 0x2a, + (byte) 0x81, (byte) 0xda, (byte) 0x2c, (byte) 0xf4, (byte) 0x80, (byte) 0x32, (byte) 0x7a, (byte) 0x86, + (byte) 0xda, (byte) 0x46, (byte) 0xba, (byte) 0x66, (byte) 0xa, (byte) 0x1a, (byte) 0xfe, (byte) 0x45, + (byte) 0x89, (byte) 0xc9, (byte) 0x39, (byte) 0xa9, (byte) 0xa, (byte) 0xce, (byte) 0xf9, (byte) 0x45, + (byte) 0x5, (byte) 0xf9, (byte) 0x45, (byte) 0x89, (byte) 0x25, (byte) 0x40, (byte) 0x63, (byte) 0x34, + (byte) 0x79, (byte) 0xb9, (byte) 0x78, (byte) 0xb9, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x3, + (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0x67, + (byte) 0x37, (byte) 0xb, (byte) 0x57, (byte) 0x3f, (byte) 0xa5, (byte) 0x4f, (byte) 0x5e, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x10, + (byte) 0x0, (byte) 0x2d, (byte) 0x0, (byte) 0x52, (byte) 0x65, (byte) 0x61, (byte) 0x64, (byte) 0x41, + (byte) 0x6e, (byte) 0x74, (byte) 0x4a, (byte) 0x61, (byte) 0x72, (byte) 0x2e, (byte) 0x63, (byte) 0x6c, + (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x1, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x87, + (byte) 0x4, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xc7, + (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, + (byte) 0x70, (byte) 0x15, (byte) 0x0, (byte) 0x1, (byte) 0x94, (byte) 0x82, (byte) 0x60, (byte) 0x61, + (byte) 0x52, (byte) 0x65, (byte) 0x61, (byte) 0x64, (byte) 0x41, (byte) 0x6e, (byte) 0x74, (byte) 0x4a, + (byte) 0x61, (byte) 0x72, (byte) 0x2e, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, + (byte) 0x75, (byte) 0x53, (byte) 0x5b, (byte) 0x57, (byte) 0x12, (byte) 0x51, (byte) 0x18, (byte) 0xdd, + (byte) 0x3, (byte) 0xc3, (byte) 0x1c, (byte) 0x18, (byte) 0x47, (byte) 0x41, (byte) 0xcc, (byte) 0xb, + (byte) 0x96, (byte) 0x89, (byte) 0x25, (byte) 0x89, (byte) 0x17, (byte) 0xa0, (byte) 0x8b, (byte) 0x76, + (byte) 0x41, (byte) 0x33, (byte) 0xab, (byte) 0x95, (byte) 0x99, (byte) 0x21, (byte) 0xb4, (byte) 0x84, + (byte) 0x65, (byte) 0x8b, (byte) 0x7a, (byte) 0x1a, (byte) 0x61, (byte) 0xb2, (byte) 0x51, (byte) 0x98, + (byte) 0x99, (byte) 0x35, (byte) 0xc, (byte) 0x76, (byte) 0x79, (byte) 0xea, (byte) 0xa1, (byte) 0x7e, + (byte) 0x8b, (byte) 0xcf, (byte) 0xf6, (byte) 0x80, (byte) 0x6b, (byte) 0xe5, (byte) 0x2a, (byte) 0xdf, + (byte) 0x7c, (byte) 0xe8, (byte) 0x47, (byte) 0x65, (byte) 0xdf, (byte) 0x19, (byte) 0x50, (byte) 0xb0, + (byte) 0x65, (byte) 0x33, (byte) 0x8b, (byte) 0xef, (byte) 0x70, (byte) 0xbe, (byte) 0xb3, (byte) 0xf7, + (byte) 0xfe, (byte) 0x6e, (byte) 0x73, (byte) 0x7e, (byte) 0xff, (byte) 0xf9, (byte) 0xf1, (byte) 0xb, + (byte) 0xc0, (byte) 0x2c, (byte) 0x1e, (byte) 0xc9, (byte) 0x90, (byte) 0x31, (byte) 0xc6, (byte) 0x70, + (byte) 0x4d, (byte) 0x86, (byte) 0x7, (byte) 0x63, (byte) 0xdc, (byte) 0x5c, (byte) 0xf7, (byte) 0x63, + (byte) 0x9c, (byte) 0x21, (byte) 0x26, (byte) 0x43, (byte) 0xc2, (byte) 0x8d, (byte) 0x0, (byte) 0x26, + (byte) 0x10, (byte) 0xf7, (byte) 0x63, (byte) 0x92, (byte) 0x61, (byte) 0x4a, (byte) 0xc6, (byte) 0x34, + (byte) 0x66, (byte) 0xb8, (byte) 0x33, (byte) 0xc1, (byte) 0x90, (byte) 0x94, (byte) 0xd1, (byte) 0x8d, + (byte) 0x14, (byte) 0xc3, (byte) 0x4d, (byte) 0x3f, (byte) 0x6e, (byte) 0xc9, (byte) 0x8, (byte) 0xe2, + (byte) 0xb6, (byte) 0x0, (byte) 0x69, (byte) 0x41, (byte) 0x37, (byte) 0x74, (byte) 0x67, (byte) 0x51, + (byte) 0x80, (byte) 0x37, (byte) 0x3e, (byte) 0xb9, (byte) 0x21, (byte) 0x40, (byte) 0x7c, (byte) 0x6a, + (byte) 0x96, (byte) 0x35, (byte) 0x1, (byte) 0xc1, (byte) 0x8c, (byte) 0x6e, (byte) 0x68, (byte) 0xd9, + (byte) 0x7a, (byte) 0x75, (byte) 0x53, (byte) 0xb3, (byte) 0xb, (byte) 0xea, (byte) 0x66, (byte) 0x85, + (byte) 0x3c, (byte) 0x62, (byte) 0x55, (byte) 0xd5, (byte) 0xd, (byte) 0x1, (byte) 0x3, (byte) 0xf1, + (byte) 0xb7, (byte) 0x99, (byte) 0x6d, (byte) 0x75, (byte) 0x57, (byte) 0x4d, (byte) 0x55, (byte) 0x54, + (byte) 0x63, (byte) 0x2b, (byte) 0x95, (byte) 0x77, (byte) 0x6c, (byte) 0xdd, (byte) 0xd8, (byte) 0x9a, + (byte) 0xe7, (byte) 0x44, (byte) 0xbf, (byte) 0xad, (byte) 0xa9, (byte) 0xe5, (byte) 0x55, (byte) 0xd5, + (byte) 0xae, (byte) 0x9, (byte) 0xe8, (byte) 0xce, (byte) 0x3b, (byte) 0x6a, (byte) 0x69, (byte) 0x67, + (byte) 0x4d, (byte) 0xb5, (byte) 0x5c, (byte) 0x2a, (byte) 0xa5, (byte) 0xc8, (byte) 0x70, (byte) 0x87, + (byte) 0x12, (byte) 0xa3, (byte) 0xf0, (byte) 0x14, (byte) 0x59, (byte) 0x80, (byte) 0x9c, (byte) 0x37, + (byte) 0xeb, (byte) 0x76, (byte) 0x49, (byte) 0x5b, (byte) 0xd6, (byte) 0xb9, (byte) 0x6c, (byte) 0x70, + (byte) 0x9d, (byte) 0x68, (byte) 0x8f, (byte) 0xd, (byte) 0x87, (byte) 0x98, (byte) 0x49, (byte) 0xae, + (byte) 0xab, (byte) 0x20, (byte) 0x8c, (byte) 0x3e, (byte) 0xc2, (byte) 0xb4, (byte) 0xdd, (byte) 0xa, + (byte) 0x86, (byte) 0xb8, (byte) 0xa7, (byte) 0x47, (byte) 0x35, (byte) 0x9c, (byte) 0x6d, (byte) 0xd5, + (byte) 0x76, (byte) 0xb4, (byte) 0x9a, (byte) 0x43, (byte) 0x40, (byte) 0x5b, (byte) 0x40, (byte) 0xbf, + (byte) 0x9b, (byte) 0x46, (byte) 0xdd, (byte) 0xd1, (byte) 0x2b, (byte) 0xa9, (byte) 0xcf, (byte) 0xba, + (byte) 0x95, (byte) 0x7a, (byte) 0xa3, (byte) 0x5b, (byte) 0x5c, (byte) 0x91, (byte) 0xf3, (byte) 0x67, + (byte) 0x19, (byte) 0xe6, (byte) 0x14, (byte) 0xdc, (byte) 0xc5, (byte) 0x3d, (byte) 0x1, (byte) 0x83, + (byte) 0xb1, (byte) 0x5a, (byte) 0xd4, (byte) 0xb4, (byte) 0x34, (byte) 0x43, (byte) 0x2b, (byte) 0x47, + (byte) 0x77, (byte) 0x75, (byte) 0x35, (byte) 0xda, (byte) 0x2, (byte) 0xc5, (byte) 0xa8, (byte) 0x90, + (byte) 0x50, (byte) 0xbb, (byte) 0x8a, (byte) 0xdc, (byte) 0xe6, (byte) 0xb6, (byte) 0x56, (byte) 0x72, + (byte) 0x18, (byte) 0xee, (byte) 0x2b, (byte) 0x78, (byte) 0x80, (byte) 0xb4, (byte) 0x82, (byte) 0x79, + (byte) 0x1e, (byte) 0xaf, (byte) 0xaf, (byte) 0x7d, (byte) 0x5e, (byte) 0x78, (byte) 0x6f, (byte) 0x9b, + (byte) 0x1f, (byte) 0x78, (byte) 0x29, (byte) 0xa, (byte) 0x16, (byte) 0xf0, (byte) 0xf0, (byte) 0xf4, + (byte) 0x48, (byte) 0x37, (byte) 0x53, (byte) 0x2f, (byte) 0x72, (byte) 0xcf, (byte) 0x3e, (byte) 0x96, + (byte) 0x34, (byte) 0xcb, (byte) 0xd1, (byte) 0x4d, (byte) 0x12, (byte) 0x1c, (byte) 0x8e, (byte) 0x19, + (byte) 0xfc, (byte) 0x1d, (byte) 0xa7, (byte) 0x27, (byte) 0x4a, (byte) 0x51, (byte) 0xb3, (byte) 0xb9, + (byte) 0x42, (byte) 0x2b, (byte) 0x72, (byte) 0xcc, (byte) 0x50, (byte) 0xb0, (byte) 0xc8, (byte) 0x25, + (byte) 0x43, (byte) 0xff, (byte) 0x36, (byte) 0x8e, (byte) 0x8a, (byte) 0x88, (byte) 0x5f, (byte) 0xdc, + (byte) 0xcd, (byte) 0x4e, (byte) 0xe8, (byte) 0xa7, (byte) 0x9a, (byte) 0xa3, (byte) 0x55, (byte) 0x69, + (byte) 0x3e, (byte) 0x66, (byte) 0xdd, (byte) 0x21, (byte) 0x42, (byte) 0xe6, (byte) 0x34, (byte) 0xf8, + (byte) 0x2b, (byte) 0x2, (byte) 0x3b, (byte) 0x44, (byte) 0xd1, (byte) 0xd4, (byte) 0xea, (byte) 0x7c, + (byte) 0x47, (byte) 0x4e, (byte) 0x1d, (byte) 0x6e, (byte) 0x1a, (byte) 0xae, (byte) 0xc5, (byte) 0x77, + (byte) 0xef, (byte) 0x4, (byte) 0x2c, (byte) 0x5c, (byte) 0x10, (byte) 0xa7, (byte) 0x73, (byte) 0x90, + (byte) 0xcd, (byte) 0x16, (byte) 0xcc, (byte) 0x4f, (byte) 0xfe, (byte) 0x47, (byte) 0xdd, (byte) 0x57, + (byte) 0xaa, (byte) 0x98, (byte) 0x35, (byte) 0x9a, (byte) 0x56, (byte) 0xb7, (byte) 0x5a, (byte) 0x2e, + (byte) 0xe7, (byte) 0xeb, (byte) 0x96, (byte) 0x65, (byte) 0x6b, (byte) 0xb5, (byte) 0x9a, (byte) 0x56, + (byte) 0x16, (byte) 0x30, (byte) 0xd4, (byte) 0x29, (byte) 0x7b, (byte) 0xd6, (byte) 0x26, (byte) 0xb7, + (byte) 0x82, (byte) 0xa0, (byte) 0xd5, (byte) 0x54, (byte) 0xa0, (byte) 0x2f, (byte) 0xa1, (byte) 0x60, + (byte) 0xab, (byte) 0x25, (byte) 0xd, (byte) 0x63, (byte) 0xf4, (byte) 0x89, (byte) 0xca, (byte) 0xe0, + (byte) 0x8f, (byte) 0x17, (byte) 0x2, (byte) 0x9f, (byte) 0x32, (byte) 0xd9, (byte) 0x4b, (byte) 0xb4, + (byte) 0x1b, (byte) 0xa1, (byte) 0x55, (byte) 0xa0, (byte) 0xd5, (byte) 0x37, (byte) 0x75, (byte) 0x0, + (byte) 0x61, (byte) 0x9f, (byte) 0xfe, (byte) 0x50, (byte) 0x91, (byte) 0x64, (byte) 0x25, (byte) 0xd7, + (byte) 0x29, (byte) 0x21, (byte) 0x80, (byte) 0x1, (byte) 0xc, (byte) 0xb6, (byte) 0xa0, (byte) 0x13, + (byte) 0x24, (byte) 0xc1, (byte) 0xbd, (byte) 0x5d, (byte) 0x87, (byte) 0xf0, (byte) 0x14, (byte) 0xf, + (byte) 0xe0, (byte) 0x6d, (byte) 0x40, (byte) 0x6c, (byte) 0x13, (byte) 0xf8, (byte) 0x15, (byte) 0x0, + (byte) 0xfc, (byte) 0xb4, (byte) 0x6, (byte) 0xc8, (byte) 0x33, (byte) 0x74, (byte) 0xaa, (byte) 0x2f, + (byte) 0xac, (byte) 0x92, (byte) 0x8, (byte) 0xa3, (byte) 0x93, (byte) 0x6f, (byte) 0x61, (byte) 0x5f, + (byte) 0xe6, (byte) 0x10, (byte) 0x52, (byte) 0x71, (byte) 0xfa, (byte) 0x0, (byte) 0x6c, (byte) 0x4d, + (byte) 0xc8, (byte) 0x7e, (byte) 0x87, (byte) 0x3f, (byte) 0x1c, (byte) 0x10, (byte) 0x7f, (byte) 0x42, + (byte) 0x2e, (byte) 0x7a, (byte) 0xa7, (byte) 0xf3, (byte) 0xd, (byte) 0x74, (byte) 0xbd, (byte) 0x9e, + (byte) 0x39, (byte) 0xc6, (byte) 0xcb, (byte) 0xc4, (byte) 0x31, (byte) 0xfa, (byte) 0x67, (byte) 0x1a, + (byte) 0x50, (byte) 0xf6, (byte) 0xb0, (byte) 0x94, (byte) 0x16, (byte) 0x13, (byte) 0x11, (byte) 0xb1, + (byte) 0x81, (byte) 0x9e, (byte) 0x3d, (byte) 0xcc, (byte) 0x35, (byte) 0x3d, (byte) 0xc9, (byte) 0xb4, + (byte) 0x18, (byte) 0x11, (byte) 0xb3, (byte) 0x11, (byte) 0xf1, (byte) 0x28, (byte) 0xed, (byte) 0x23, + (byte) 0xe8, (byte) 0x48, (byte) 0x1b, (byte) 0x1a, (byte) 0x4e, (byte) 0x4b, (byte) 0x89, (byte) 0x88, + (byte) 0xe4, (byte) 0x42, (byte) 0x19, (byte) 0xf7, (byte) 0x44, (byte) 0x7c, (byte) 0x47, (byte) 0x7b, + (byte) 0x88, (byte) 0xac, (byte) 0xf1, (byte) 0x0, (byte) 0xa1, (byte) 0x73, (byte) 0x1, (byte) 0x1a, + (byte) 0xe8, (byte) 0xdd, (byte) 0xa7, (byte) 0x64, (byte) 0x26, (byte) 0xe8, (byte) 0x42, (byte) 0x26, + (byte) 0xe9, (byte) 0x1e, (byte) 0xf6, (byte) 0x60, (byte) 0x14, (byte) 0x4b, (byte) 0xad, (byte) 0x75, + (byte) 0x85, (byte) 0x12, (byte) 0x5c, (byte) 0xc7, (byte) 0x6, (byte) 0x8a, (byte) 0xb4, (byte) 0x5f, + (byte) 0xc2, (byte) 0xaa, (byte) 0xbb, (byte) 0xf7, (byte) 0x62, (byte) 0x7, (byte) 0x6, (byte) 0x5d, + (byte) 0x52, (byte) 0x8f, (byte) 0x5b, (byte) 0x5e, (byte) 0x12, (byte) 0x5d, (byte) 0x64, (byte) 0x15, + (byte) 0xf2, (byte) 0x72, (byte) 0x6, (byte) 0xe7, (byte) 0x4, (byte) 0x5d, (byte) 0xf6, (byte) 0xa, + (byte) 0xad, (byte) 0x3b, (byte) 0xd4, (byte) 0x4e, (byte) 0x8e, (byte) 0x34, (byte) 0x11, (byte) 0xc2, + (byte) 0x17, (byte) 0xf4, (byte) 0xe2, (byte) 0x2b, (byte) 0x15, (byte) 0x1e, (byte) 0x21, (byte) 0x74, + (byte) 0xe, (byte) 0xf2, (byte) 0x9, (byte) 0x11, (byte) 0x45, (byte) 0x86, (byte) 0x61, (byte) 0x86, + (byte) 0xcb, (byte) 0xc, (byte) 0x57, (byte) 0x18, (byte) 0xef, (byte) 0x36, (byte) 0x19, (byte) 0x79, + (byte) 0x99, (byte) 0xcc, (byte) 0x73, (byte) 0xfa, (byte) 0x9d, (byte) 0x10, (byte) 0x43, (byte) 0x3a, + (byte) 0x77, (byte) 0x7c, (byte) 0x6, (byte) 0xf1, (byte) 0x9e, (byte) 0x50, (byte) 0x64, (byte) 0x4f, + (byte) 0xf3, (byte) 0xc, (byte) 0x78, (byte) 0xc2, (byte) 0x70, (byte) 0xb5, (byte) 0x9f, (byte) 0x3a, + (byte) 0x3a, (byte) 0x4a, (byte) 0xb2, (byte) 0x1e, (byte) 0x44, (byte) 0xff, (byte) 0x2, (byte) 0x50, + (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, (byte) 0x3, (byte) 0x2d, (byte) 0x0, (byte) 0x0, + (byte) 0x8, (byte) 0x0, (byte) 0x0, (byte) 0x18, (byte) 0x7e, (byte) 0xe, (byte) 0x57, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x9, (byte) 0x0, (byte) 0x32, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0xed, + (byte) 0x41, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x4d, (byte) 0x45, (byte) 0x54, + (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, (byte) 0x1, (byte) 0x0, + (byte) 0x18, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0xfe, (byte) 0xca, (byte) 0x0, (byte) 0x0, (byte) 0x75, (byte) 0x70, + (byte) 0xe, (byte) 0x0, (byte) 0x1, (byte) 0x8, (byte) 0xa1, (byte) 0x8c, (byte) 0x13, (byte) 0x4d, + (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, + (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, (byte) 0x3, (byte) 0x2d, (byte) 0x0, + (byte) 0x0, (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0x17, (byte) 0x7e, (byte) 0xe, (byte) 0x57, + (byte) 0x31, (byte) 0x59, (byte) 0x76, (byte) 0x4d, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x14, (byte) 0x0, (byte) 0x39, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0xa4, (byte) 0x81, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x4d, (byte) 0x45, + (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, (byte) 0x4d, + (byte) 0x41, (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, (byte) 0x54, (byte) 0x2e, + (byte) 0x4d, (byte) 0x46, (byte) 0x1, (byte) 0x0, (byte) 0x18, (byte) 0x0, (byte) 0x6e, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x61, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x51, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, (byte) 0x70, + (byte) 0x19, (byte) 0x0, (byte) 0x1, (byte) 0x85, (byte) 0x85, (byte) 0x84, (byte) 0x2, (byte) 0x4d, + (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, + (byte) 0x4d, (byte) 0x41, (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, (byte) 0x54, + (byte) 0x2e, (byte) 0x4d, (byte) 0x46, (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, + (byte) 0x3, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0x67, + (byte) 0x37, (byte) 0xb, (byte) 0x57, (byte) 0x3f, (byte) 0xa5, (byte) 0x4f, (byte) 0x5e, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x10, + (byte) 0x0, (byte) 0x35, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xa4, (byte) 0x81, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0x52, (byte) 0x65, (byte) 0x61, (byte) 0x64, (byte) 0x41, (byte) 0x6e, (byte) 0x74, + (byte) 0x4a, (byte) 0x61, (byte) 0x72, (byte) 0x2e, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x73, + (byte) 0x73, (byte) 0x1, (byte) 0x0, (byte) 0x18, (byte) 0x0, (byte) 0x87, (byte) 0x4, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xc7, (byte) 0x2, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x15, (byte) 0x1, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, (byte) 0x70, (byte) 0x15, + (byte) 0x0, (byte) 0x1, (byte) 0x94, (byte) 0x82, (byte) 0x60, (byte) 0x61, (byte) 0x52, (byte) 0x65, + (byte) 0x61, (byte) 0x64, (byte) 0x41, (byte) 0x6e, (byte) 0x74, (byte) 0x4a, (byte) 0x61, (byte) 0x72, + (byte) 0x2e, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x50, (byte) 0x4b, + (byte) 0x6, (byte) 0x6, (byte) 0x2c, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x2d, (byte) 0x0, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x57, (byte) 0x1, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x37, (byte) 0x4, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, + (byte) 0x6, (byte) 0x7, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x8e, (byte) 0x5, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x5, (byte) 0x6, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x57, (byte) 0x1, + (byte) 0x0, (byte) 0x0, (byte) 0x37, (byte) 0x4, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + }; + + /* + * ----------------#1-------------------- + * [Central Directory Header] + * 0x47: Signature : 0x02014b50 + * 0x4b: Created Zip Spec : 0x2d [4.5] + * 0x4c: Created OS : 0x3 [UNIX] + * 0x4d: VerMadeby : 0x32d [3, 4.5] + * 0x4e: VerExtract : 0x2d [4.5] + * 0x4f: Flag : 0x800 + * 0x51: Method : 0x8 [DEFLATED] + * 0x53: Last Mod Time : 0x570375bc [Thu Aug 03 14:45:56 EDT 2023] + * 0x57: CRC : 0x0 + * 0x5b: Compressed Size : 0x2 + * 0x5f: Uncompressed Size: 0x0 + * * 0x63: Name Length : 0x5 + * 0x65: Extra Length : 0x12 + * Extra data:[01, 00, 00, 00, 75, 70, 0a, 00, 01, ba, f7, eb, c1, 61, 2e, 74, 78, 74] + * [tag=0x0001, sz=0] + * ->ZIP64: + * [tag=0x7075, sz=10] + * ->[Unknown tag] + * [data= 01 ba f7 eb c1 61 2e 74 78 74 ] + * 0x67: Comment Length : 0x0 + * 0x69: Disk Start : 0x0 + * 0x6b: Attrs : 0x0 + * 0x6d: AttrsEx : 0x81a40000 + * 0x71: Loc Header Offset: 0x0 + * 0x75: File Name : a.txt + */ + public static byte[] ANT_ZIP64_UNICODE_EXTRA_ZIP= { + (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, + (byte) 0x8, (byte) 0x0, (byte) 0xbc, (byte) 0x75, (byte) 0x3, (byte) 0x57, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0x5, (byte) 0x0, (byte) 0x22, (byte) 0x0, (byte) 0x61, (byte) 0x2e, + (byte) 0x74, (byte) 0x78, (byte) 0x74, (byte) 0x1, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, + (byte) 0x70, (byte) 0xa, (byte) 0x0, (byte) 0x1, (byte) 0xba, (byte) 0xf7, (byte) 0xeb, (byte) 0xc1, + (byte) 0x61, (byte) 0x2e, (byte) 0x74, (byte) 0x78, (byte) 0x74, (byte) 0x3, (byte) 0x0, (byte) 0x50, + (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, (byte) 0x3, (byte) 0x2d, (byte) 0x0, (byte) 0x0, + (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0xbc, (byte) 0x75, (byte) 0x3, (byte) 0x57, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x5, (byte) 0x0, (byte) 0x12, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xa4, + (byte) 0x81, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x61, (byte) 0x2e, (byte) 0x74, + (byte) 0x78, (byte) 0x74, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, (byte) 0x70, + (byte) 0xa, (byte) 0x0, (byte) 0x1, (byte) 0xba, (byte) 0xf7, (byte) 0xeb, (byte) 0xc1, (byte) 0x61, + (byte) 0x2e, (byte) 0x74, (byte) 0x78, (byte) 0x74, (byte) 0x50, (byte) 0x4b, (byte) 0x6, (byte) 0x6, + (byte) 0x2c, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x2d, (byte) 0x0, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x45, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x47, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x6, (byte) 0x7, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x8c, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x50, (byte) 0x4b, (byte) 0x5, (byte) 0x6, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x1, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x45, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x47, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + }; + + // Name of Zip file and Jar File used by the test + public static final Path VALID_APK = Path.of("working-apk.zip"); + public static final Path VALID_APACHE_COMPRESS_JAR = + Path.of("valid-apache-compress.jar"); + public static final Path VALID_ANT_JAR = + Path.of("valid-ant-zip64-unicode-extrafields.jar"); + public static final Path VALID_ANT_ZIP = + Path.of("valid-ant-zip64-unicode-extrafields.zip"); + /** + * Setup method used to create the Zip and Jar files used by the test + * @throws IOException if an error occurs + */ + public static void setup() throws IOException { + Files.deleteIfExists(VALID_APK); + Files.deleteIfExists(VALID_APACHE_COMPRESS_JAR); + Files.deleteIfExists(VALID_ANT_JAR); + Files.deleteIfExists(VALID_ANT_ZIP); + + // Create the Zip file to read + Files.write(VALID_APK, VALID_APK_FILE); + Files.write(VALID_APACHE_COMPRESS_JAR, COMMONS_COMPRESS_JAR); + Files.write(VALID_ANT_JAR, ANT_ZIP64_UNICODE_EXTRA_JAR); + Files.write(VALID_ANT_ZIP, ANT_ZIP64_UNICODE_EXTRA_ZIP); + + } + + /** + * Zip and Jars files to validate we can open + */ + private static Stream zipFilesToTest() { + return Stream.of(VALID_APK, VALID_APACHE_COMPRESS_JAR, VALID_ANT_JAR, VALID_ANT_ZIP); + } + + /** + * Validate that a Zip file which contains an extra header with a data size + * 0f 0 can be opened using ZipFile + * @throws IOException if an error occurs + */ + public void zipFilesToTest(Path jar) throws IOException { + try (ZipFile zf = new ZipFile(jar.toFile())) { + System.out.printf("%s opened%n", jar.toAbsolutePath()); + } catch (IOException ie) { + System.out.printf("%n%n%n$$$$ %s NOT opened%n", jar.toAbsolutePath()); + throw ie; + } + } + + /** + * Validate that a Zip file which contains an extra header with a data size + * 0f 0 can be opened using ZipFS + * @throws IOException if an error occurs + */ + public void readZipFSTest(Path jar) throws IOException { + try (FileSystem fs = FileSystems.newFileSystem(jar, Map.of())) { + System.out.printf("%s opened%n", jar.toAbsolutePath()); + } catch (IOException ie) { + System.out.printf("%n%n%n$$$$ %s NOT opened%n", jar.toAbsolutePath()); + throw ie; + } + } + /** + * Utility method which takes a byte array and converts to byte array + * declaration. For example: + *
+     *     {@code
+     *        var fooJar = Files.readAllBytes(Path.of("foo.jar"));
+     *        var result = createByteArray(fooJar, "FOOBYTES");
+     *        System.out.println(result);
+     *      }
+     * 
+ * + * @param bytes A byte array used to create a byte array declaration + * @param name Name to be used in the byte array declaration + * @return The formatted byte array declaration + */ + public static String createByteArray(byte[] bytes, String name) { + StringBuilder sb = new StringBuilder(bytes.length * 5); + Formatter fmt = new Formatter(sb); + fmt.format(" public static byte[] %s = {", name); + final int linelen = 8; + for (int i = 0; i < bytes.length; i++) { + if (i % linelen == 0) { + fmt.format("%n "); + } + fmt.format(" (byte) 0x%x,", bytes[i] & 0xff); + } + fmt.format("%n };%n"); + return sb.toString(); + } + + public static void main(String[] args) throws Exception { + setup(); + var test = new ReadNonStandardExtraHeadersTest(); + zipFilesToTest().forEach(path -> { + try { + test.zipFilesToTest(path); + test.readZipFSTest(path); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + } +} + From 4dca60e43a002a5664a465e28049f0f34834cbf1 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Fri, 18 Aug 2023 17:58:28 +0000 Subject: [PATCH 033/341] 8293166: jdk/jfr/jvm/TestDumpOnCrash.java fails on Linux ppc64le and Linux aarch64 Reviewed-by: mdoerr Backport-of: 5551cb66ba58cadce7291a95c5af662ade2cb7b8 --- test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java index 423764c88ea0f..926f918f4762f 100644 --- a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java +++ b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.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 @@ -113,6 +113,7 @@ private static long runProcess(Class crasher, String signal, boolean disk) th Process p = ProcessTools.createTestJvm( "-Xmx64m", "-XX:-CreateCoredumpOnCrash", + "-XX:-TieredCompilation", // Avoid secondary crashes (see JDK-8293166) "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:StartFlightRecording:" + flightRecordingOptions, crasher.getName(), From 0fa04fe58414a278666669662845553c7bda4e1e Mon Sep 17 00:00:00 2001 From: Dingli Zhang Date: Sun, 20 Aug 2023 07:05:33 +0000 Subject: [PATCH 034/341] 8309254: Implement fast-path for ASCII-compatible CharsetEncoders on RISC-V Reviewed-by: fyang Backport-of: 61bb014a8692305c705a4cf0361e319275c35ca3 --- .../cpu/riscv/c2_MacroAssembler_riscv.cpp | 36 +++++++++++++------ .../cpu/riscv/c2_MacroAssembler_riscv.hpp | 2 +- src/hotspot/cpu/riscv/matcher_riscv.hpp | 2 +- src/hotspot/cpu/riscv/riscv_v.ad | 24 ++++++++++--- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index 15220c4133e02..0c7b270d4bf1a 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -1500,26 +1500,39 @@ void C2_MacroAssembler::byte_array_inflate_v(Register src, Register dst, Registe // Compress char[] array to byte[]. // result: the array length if every element in array can be encoded; 0, otherwise. -void C2_MacroAssembler::char_array_compress_v(Register src, Register dst, Register len, Register result, Register tmp) { +void C2_MacroAssembler::char_array_compress_v(Register src, Register dst, Register len, + Register result, Register tmp) { Label done; - encode_iso_array_v(src, dst, len, result, tmp); + encode_iso_array_v(src, dst, len, result, tmp, false); beqz(len, done); mv(result, zr); bind(done); } -// result: the number of elements had been encoded. -void C2_MacroAssembler::encode_iso_array_v(Register src, Register dst, Register len, Register result, Register tmp) { - Label loop, DIFFERENCE, DONE; +// Intrinsic for +// +// - sun/nio/cs/ISO_8859_1$Encoder.implEncodeISOArray +// return the number of characters copied. +// - java/lang/StringUTF16.compress +// return zero (0) if copy fails, otherwise 'len'. +// +// This version always returns the number of characters copied. A successful +// copy will complete with the post-condition: 'res' == 'len', while an +// unsuccessful copy will exit with the post-condition: 0 <= 'res' < 'len'. +// +// Clobbers: src, dst, len, result, t0 +void C2_MacroAssembler::encode_iso_array_v(Register src, Register dst, Register len, + Register result, Register tmp, bool ascii) { + Label loop, fail, done; BLOCK_COMMENT("encode_iso_array_v {"); mv(result, 0); bind(loop); - mv(tmp, 0xff); + mv(tmp, ascii ? 0x7f : 0xff); vsetvli(t0, len, Assembler::e16, Assembler::m2); vle16_v(v2, src); - // if element > 0xff, stop + vmsgtu_vx(v1, v2, tmp); vfirst_m(tmp, v1); vmsbf_m(v0, v1); @@ -1528,18 +1541,19 @@ void C2_MacroAssembler::encode_iso_array_v(Register src, Register dst, Register vncvt_x_x_w(v1, v2, Assembler::v0_t); vse8_v(v1, dst, Assembler::v0_t); - bgez(tmp, DIFFERENCE); + // fail if char > 0x7f/0xff + bgez(tmp, fail); add(result, result, t0); add(dst, dst, t0); sub(len, len, t0); shadd(src, t0, src, t0, 1); bnez(len, loop); - j(DONE); + j(done); - bind(DIFFERENCE); + bind(fail); add(result, result, tmp); - bind(DONE); + bind(done); BLOCK_COMMENT("} encode_iso_array_v"); } diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp index e904249283a18..62101e55d3021 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.hpp @@ -171,7 +171,7 @@ void encode_iso_array_v(Register src, Register dst, Register len, Register result, - Register tmp); + Register tmp, bool ascii); void has_negatives_v(Register ary, Register len, Register result, Register tmp); diff --git a/src/hotspot/cpu/riscv/matcher_riscv.hpp b/src/hotspot/cpu/riscv/matcher_riscv.hpp index 23a75d2050260..0190a159726a1 100644 --- a/src/hotspot/cpu/riscv/matcher_riscv.hpp +++ b/src/hotspot/cpu/riscv/matcher_riscv.hpp @@ -159,7 +159,7 @@ } // Implements a variant of EncodeISOArrayNode that encode ASCII only - static const bool supports_encode_ascii_array = false; + static const bool supports_encode_ascii_array = true; // Returns pre-selection estimated size of a vector operation. static int vector_op_pre_select_sz_estimate(int vopc, BasicType ety, int vlen) { diff --git a/src/hotspot/cpu/riscv/riscv_v.ad b/src/hotspot/cpu/riscv/riscv_v.ad index 4359ea7c34bac..b3aa3d930746c 100644 --- a/src/hotspot/cpu/riscv/riscv_v.ad +++ b/src/hotspot/cpu/riscv/riscv_v.ad @@ -1935,17 +1935,33 @@ instruct vstring_inflate(Universe dummy, iRegP_R10 src, iRegP_R11 dst, iRegI_R12 instruct vencode_iso_array(iRegP_R12 src, iRegP_R11 dst, iRegI_R13 len, iRegI_R10 result, vReg_V1 v1, vReg_V2 v2, vReg_V3 v3, iRegLNoSp tmp) %{ - predicate(UseRVV); + predicate(UseRVV && !((EncodeISOArrayNode*)n)->is_ascii()); match(Set result (EncodeISOArray src (Binary dst len))); effect(TEMP_DEF result, USE_KILL src, USE_KILL dst, USE_KILL len, TEMP v1, TEMP v2, TEMP v3, TEMP tmp); - format %{ "Encode array $src,$dst,$len -> $result" %} + format %{ "Encode ISO array $src, $dst, $len -> $result # KILL $src, $dst, $len, $tmp, V1-V3" %} ins_encode %{ __ encode_iso_array_v($src$$Register, $dst$$Register, $len$$Register, - $result$$Register, $tmp$$Register); + $result$$Register, $tmp$$Register, false /* ascii */); %} - ins_pipe( pipe_class_memory ); + ins_pipe(pipe_class_memory); +%} + +instruct vencode_ascii_array(iRegP_R12 src, iRegP_R11 dst, iRegI_R13 len, iRegI_R10 result, + vReg_V1 v1, vReg_V2 v2, vReg_V3 v3, iRegLNoSp tmp) +%{ + predicate(UseRVV && ((EncodeISOArrayNode*)n)->is_ascii()); + match(Set result (EncodeISOArray src (Binary dst len))); + effect(TEMP_DEF result, USE_KILL src, USE_KILL dst, USE_KILL len, + TEMP v1, TEMP v2, TEMP v3, TEMP tmp); + + format %{ "Encode ASCII array $src, $dst, $len -> $result # KILL $src, $dst, $len, $tmp, V1-V3" %} + ins_encode %{ + __ encode_iso_array_v($src$$Register, $dst$$Register, $len$$Register, + $result$$Register, $tmp$$Register, true /* ascii */); + %} + ins_pipe(pipe_class_memory); %} // fast char[] to byte[] compression From 4087dbb67803761c21b312e3f68f35c5b883b6cf Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 21 Aug 2023 09:10:11 +0000 Subject: [PATCH 035/341] 8314118: Update JMH devkit to 1.37 Backport-of: 06aa3c5628e749188238dda3d41c776a5a2f7c81 --- make/devkit/createJMHBundle.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make/devkit/createJMHBundle.sh b/make/devkit/createJMHBundle.sh index 7018ae23e55e1..4a257577018f2 100644 --- a/make/devkit/createJMHBundle.sh +++ b/make/devkit/createJMHBundle.sh @@ -26,8 +26,8 @@ # Create a bundle in the build directory, containing what's needed to # build and run JMH microbenchmarks from the OpenJDK build. -JMH_VERSION=1.36 -COMMONS_MATH3_VERSION=3.2 +JMH_VERSION=1.37 +COMMONS_MATH3_VERSION=3.6.1 JOPT_SIMPLE_VERSION=5.0.4 BUNDLE_NAME=jmh-$JMH_VERSION.tar.gz From a6bbaaeb208af9010ba80776f9aeffb2e1bc5170 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 21 Aug 2023 09:11:54 +0000 Subject: [PATCH 036/341] 8314262: GHA: Cut down cross-compilation sysroots deeper Backport-of: 38687f1a3eb7d1c2e8aa43b85509ab7999fe0e40 --- .github/workflows/build-cross-compile.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 3256eaae0093e..edbbac42226ef 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -151,7 +151,8 @@ jobs: sudo chown ${USER} -R sysroot rm -rf sysroot/{dev,proc,run,sys,var} rm -rf sysroot/usr/{sbin,bin,share} - rm -rf sysroot/usr/lib/{apt,udev,systemd} + rm -rf sysroot/usr/lib/{apt,gcc,udev,systemd} + rm -rf sysroot/usr/libexec/gcc if: steps.get-cached-sysroot.outputs.cache-hit != 'true' - name: 'Configure' From 4dac2bd3be6b59de02a40b2f623cdd1101d66000 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 21 Aug 2023 09:12:24 +0000 Subject: [PATCH 037/341] 8313676: Amend TestLoadIndexedMismatch test to target intrinsic directly Backport-of: 4b192a8dc37297f0746c0c68322e0168d9f47771 --- test/hotspot/jtreg/compiler/c1/TestLoadIndexedMismatch.java | 4 ++-- .../jtreg/compiler/patches/java.base/java/lang/Helper.java | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/compiler/c1/TestLoadIndexedMismatch.java b/test/hotspot/jtreg/compiler/c1/TestLoadIndexedMismatch.java index d16b6b0c684ca..2f983692f3831 100644 --- a/test/hotspot/jtreg/compiler/c1/TestLoadIndexedMismatch.java +++ b/test/hotspot/jtreg/compiler/c1/TestLoadIndexedMismatch.java @@ -42,8 +42,8 @@ public class TestLoadIndexedMismatch { public static char work() { // LoadIndexed (B) byte b = ARR[0]; - // StringUTF16.charAt intrinsic, LoadIndexed (C) - char c = Helper.charAt(ARR, 0); + // StringUTF16.getChar intrinsic, LoadIndexed (C) + char c = Helper.getChar(ARR, 0); return c; } diff --git a/test/hotspot/jtreg/compiler/patches/java.base/java/lang/Helper.java b/test/hotspot/jtreg/compiler/patches/java.base/java/lang/Helper.java index ded4a58945d09..9a08c5b6043d9 100644 --- a/test/hotspot/jtreg/compiler/patches/java.base/java/lang/Helper.java +++ b/test/hotspot/jtreg/compiler/patches/java.base/java/lang/Helper.java @@ -72,6 +72,11 @@ public static char[] getChars(byte[] value, int srcBegin, int srcEnd, int dstSiz return dst; } + @jdk.internal.vm.annotation.ForceInline + public static char getChar(byte[] value, int index) { + return StringUTF16.getChar(value, index); + } + public static void putCharSB(byte[] val, int index, int c) { StringUTF16.putCharSB(val, index, c); } From d72596187614331aa5b0b10ea3dde195aa088dbe Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 21 Aug 2023 09:14:08 +0000 Subject: [PATCH 038/341] 8284273: Early crashes in os::print_context on AArch64 Reviewed-by: stuefe Backport-of: 83cec4b6cc25b9b0db751bbe873444259cdcb21c --- src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp | 8 +++++- .../os_cpu/bsd_aarch64/os_bsd_aarch64.cpp | 9 ++++++- src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp | 9 ++++++- src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp | 6 ++++- .../os_cpu/linux_aarch64/os_linux_aarch64.cpp | 18 +++++++++---- src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp | 11 +++++--- src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp | 6 +++++ .../os_cpu/linux_riscv/os_linux_riscv.cpp | 26 +++++++++++-------- .../os_cpu/linux_s390/os_linux_s390.cpp | 6 +++++ src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp | 7 +++++ .../os_cpu/linux_zero/os_linux_zero.cpp | 6 ++++- .../windows_aarch64/os_windows_aarch64.cpp | 8 +++++- .../os_cpu/windows_x86/os_windows_x86.cpp | 7 ++++- src/hotspot/share/runtime/os.hpp | 1 + src/hotspot/share/utilities/vmError.cpp | 14 +++++++--- 15 files changed, 113 insertions(+), 29 deletions(-) diff --git a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp index 3e1399f63c4e7..ccfa78f1996b0 100644 --- a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp +++ b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2021 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -447,6 +447,12 @@ void os::print_context(outputStream *st, const void *context) { } st->cr(); st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const ucontext_t* uc = (const ucontext_t*)context; intptr_t *sp = (intptr_t *)os::Aix::ucontext_get_sp(uc); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); diff --git a/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp b/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp index d9a54bf695d4e..6f8672c7223eb 100644 --- a/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp +++ b/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -420,6 +420,7 @@ void os::print_context(outputStream *st, const void *context) { if (context == NULL) return; const ucontext_t *uc = (const ucontext_t*)context; + st->print_cr("Registers:"); st->print( " x0=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 0]); st->print(" x1=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 1]); @@ -464,6 +465,12 @@ void os::print_context(outputStream *st, const void *context) { st->print( "pc=" INTPTR_FORMAT, (intptr_t)uc->context_pc); st->print(" cpsr=" INTPTR_FORMAT, (intptr_t)uc->context_cpsr); st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const ucontext_t* uc = (const ucontext_t*)context; intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc); st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp); diff --git a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp index ad48c6e474776..6ef7690f3bbce 100644 --- a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp +++ b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -801,6 +801,7 @@ void os::print_context(outputStream *st, const void *context) { if (context == NULL) return; const ucontext_t *uc = (const ucontext_t*)context; + st->print_cr("Registers:"); #ifdef AMD64 st->print( "RAX=" INTPTR_FORMAT, (intptr_t)uc->context_rax); @@ -844,6 +845,12 @@ void os::print_context(outputStream *st, const void *context) { #endif // AMD64 st->cr(); st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const ucontext_t* uc = (const ucontext_t*)context; intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc); st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp); diff --git a/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp b/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp index d85822bdec231..f018fe0e41afc 100644 --- a/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp +++ b/src/hotspot/os_cpu/bsd_zero/os_bsd_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -247,6 +247,10 @@ void os::print_context(outputStream* st, const void* context) { ShouldNotCallThis(); } +void os::print_tos_pc(outputStream *st, const void *context) { + ShouldNotCallThis(); +} + void os::print_register_info(outputStream *st, const void *context) { ShouldNotCallThis(); } diff --git a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp index 4b7dcd0f9a167..e79c194cf8c1e 100644 --- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp +++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -333,12 +333,18 @@ void os::print_context(outputStream *st, const void *context) { if (context == NULL) return; const ucontext_t *uc = (const ucontext_t*)context; + st->print_cr("Registers:"); for (int r = 0; r < 31; r++) { - st->print("R%-2d=", r); - print_location(st, uc->uc_mcontext.regs[r]); + st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]); } st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const ucontext_t* uc = (const ucontext_t*)context; intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); @@ -367,8 +373,10 @@ void os::print_register_info(outputStream *st, const void *context) { // this is only for the "general purpose" registers - for (int r = 0; r < 31; r++) - st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]); + for (int r = 0; r < 31; r++) { + st->print("R%-2d=", r); + print_location(st, uc->uc_mcontext.regs[r]); + } st->cr(); } diff --git a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp index 7df65bed1eef2..faee1803626b4 100644 --- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp +++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp @@ -434,6 +434,7 @@ size_t os::Posix::default_stack_size(os::ThreadType thr_type) { void os::print_context(outputStream *st, const void *context) { if (context == NULL) return; + const ucontext_t *uc = (const ucontext_t*)context; st->print_cr("Registers:"); @@ -445,6 +446,12 @@ void os::print_context(outputStream *st, const void *context) { // now print flag register st->print_cr(" %-4s = 0x%08lx", "cpsr",uc->uc_mcontext.arm_cpsr); st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const ucontext_t* uc = (const ucontext_t*)context; intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", p2i(sp)); @@ -463,8 +470,8 @@ void os::print_register_info(outputStream *st, const void *context) { if (context == NULL) return; const ucontext_t *uc = (const ucontext_t*)context; - intx* reg_area = (intx*)&uc->uc_mcontext.arm_r0; + intx* reg_area = (intx*)&uc->uc_mcontext.arm_r0; st->print_cr("Register to memory mapping:"); st->cr(); for (int r = 0; r < ARM_REGS_IN_CONTEXT; r++) { @@ -474,8 +481,6 @@ void os::print_register_info(outputStream *st, const void *context) { st->cr(); } - - typedef int64_t cmpxchg_long_func_t(int64_t, int64_t, volatile int64_t*); cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap; diff --git a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp index f1980bc0207da..468224b61dc4f 100644 --- a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp +++ b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp @@ -460,6 +460,12 @@ void os::print_context(outputStream *st, const void *context) { } st->cr(); st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const ucontext_t* uc = (const ucontext_t*)context; intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); diff --git a/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp index d672b57182f74..804b0c391548c 100644 --- a/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -342,17 +342,21 @@ static const char* reg_abi_names[] = { }; void os::print_context(outputStream *st, const void *context) { - if (context == NULL) { - return; - } + if (context == NULL) return; const ucontext_t *uc = (const ucontext_t*)context; + st->print_cr("Registers:"); for (int r = 0; r < 32; r++) { - st->print("%-*.*s=", 8, 8, reg_abi_names[r]); - print_location(st, uc->uc_mcontext.__gregs[r]); + st->print_cr("%-*.*s=" INTPTR_FORMAT, 8, 8, reg_abi_names[r], (uintptr_t)uc->uc_mcontext.__gregs[r]); } st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const ucontext_t* uc = (const ucontext_t*)context; intptr_t *frame_sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(frame_sp)); @@ -368,9 +372,7 @@ void os::print_context(outputStream *st, const void *context) { } void os::print_register_info(outputStream *st, const void *context) { - if (context == NULL) { - return; - } + if (context == NULL) return; const ucontext_t *uc = (const ucontext_t*)context; @@ -383,8 +385,10 @@ void os::print_register_info(outputStream *st, const void *context) { // this is only for the "general purpose" registers - for (int r = 0; r < 32; r++) - st->print_cr("%-*.*s=" INTPTR_FORMAT, 8, 8, reg_abi_names[r], (uintptr_t)uc->uc_mcontext.__gregs[r]); + for (int r = 0; r < 32; r++) { + st->print("%-*.*s=", 8, 8, reg_abi_names[r]); + print_location(st, uc->uc_mcontext.__gregs[r]); + } st->cr(); } diff --git a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp index 53b017d221725..02d104d921a92 100644 --- a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp +++ b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp @@ -433,6 +433,12 @@ void os::print_context(outputStream *st, const void *context) { } st->cr(); st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const ucontext_t* uc = (const ucontext_t*)context; intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp index 464a2fd660dca..e1aec8a4f18b7 100644 --- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp +++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp @@ -531,6 +531,7 @@ void os::print_context(outputStream *st, const void *context) { if (context == NULL) return; const ucontext_t *uc = (const ucontext_t*)context; + st->print_cr("Registers:"); #ifdef AMD64 st->print( "RAX=" INTPTR_FORMAT, (intptr_t)uc->uc_mcontext.gregs[REG_RAX]); @@ -576,6 +577,12 @@ void os::print_context(outputStream *st, const void *context) { #endif // AMD64 st->cr(); st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const ucontext_t* uc = (const ucontext_t*)context; intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); diff --git a/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp b/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp index 51a7fa8b0fc15..212e16809144f 100644 --- a/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp +++ b/src/hotspot/os_cpu/linux_zero/os_linux_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -290,6 +290,10 @@ void os::print_context(outputStream* st, const void* context) { ShouldNotCallThis(); } +void os::print_tos_pc(outputStream *st, const void *context) { + ShouldNotCallThis(); +} + void os::print_register_info(outputStream *st, const void *context) { ShouldNotCallThis(); } diff --git a/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp b/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp index 79b516dc08185..24fa22fda21b7 100644 --- a/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp +++ b/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Microsoft Corporation. All rights reserved. + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -203,6 +204,12 @@ void os::print_context(outputStream *st, const void *context) { st->print(", X28=" INTPTR_FORMAT, uc->X28); st->cr(); st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const CONTEXT* uc = (const CONTEXT*)context; intptr_t *sp = (intptr_t *)uc->Sp; st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); @@ -216,7 +223,6 @@ void os::print_context(outputStream *st, const void *context) { st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); st->cr(); - } void os::print_register_info(outputStream *st, const void *context) { diff --git a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp index feace2d6d29da..3566d8f5c7fa3 100644 --- a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp +++ b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp @@ -448,6 +448,12 @@ void os::print_context(outputStream *st, const void *context) { #endif // AMD64 st->cr(); st->cr(); +} + +void os::print_tos_pc(outputStream *st, const void *context) { + if (context == NULL) return; + + const CONTEXT* uc = (const CONTEXT*)context; intptr_t *sp = (intptr_t *)uc->REG_SP; st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); @@ -462,7 +468,6 @@ void os::print_context(outputStream *st, const void *context) { st->cr(); } - void os::print_register_info(outputStream *st, const void *context) { if (context == NULL) return; diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index 53a411afcc257..25df0eb372e47 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -693,6 +693,7 @@ class os: AllStatic { static void print_dll_info(outputStream* st); static void print_environment_variables(outputStream* st, const char** env_list); static void print_context(outputStream* st, const void* context); + static void print_tos_pc(outputStream* st, const void* context); static void print_register_info(outputStream* st, const void* context); static bool signal_sent_by_kill(const void* siginfo); static void print_siginfo(outputStream* st, const void* siginfo); diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 42e5fdf685d09..bcae7c7758325 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -901,6 +901,14 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } + STEP("printing registers") + + // printing registers + if (_verbose && _context) { + os::print_context(st, _context); + st->cr(); + } + STEP("printing register info") // decode register contents if possible @@ -910,11 +918,11 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP("printing registers, top of stack, instructions near pc") + STEP("printing top of stack, instructions near pc") - // registers, top of stack, instructions near pc + // printing top of stack, instructions near pc if (_verbose && _context) { - os::print_context(st, _context); + os::print_tos_pc(st, _context); st->cr(); } From 78bbd57d5bee4bd3eec670fab69a35588025d9a1 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 21 Aug 2023 09:16:06 +0000 Subject: [PATCH 039/341] 8309591: Socket.setOption(TCP_QUICKACK) uses wrong level Reviewed-by: phh Backport-of: 56a73a6f0f3d38379cecea1de5eacb751febca95 --- src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c b/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c index a10d9418e9dcf..ce603bb11f218 100644 --- a/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c +++ b/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c @@ -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 @@ -83,7 +83,7 @@ JNIEXPORT void JNICALL Java_jdk_net_LinuxSocketOptions_setQuickAck0 int optval; int rv; optval = (on ? 1 : 0); - rv = setsockopt(fd, SOL_SOCKET, TCP_QUICKACK, &optval, sizeof (optval)); + rv = setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &optval, sizeof (optval)); handleError(env, rv, "set option TCP_QUICKACK failed"); } @@ -96,7 +96,7 @@ JNIEXPORT jboolean JNICALL Java_jdk_net_LinuxSocketOptions_getQuickAck0 (JNIEnv *env, jobject unused, jint fd) { int on; socklen_t sz = sizeof (on); - int rv = getsockopt(fd, SOL_SOCKET, TCP_QUICKACK, &on, &sz); + int rv = getsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &on, &sz); handleError(env, rv, "get option TCP_QUICKACK failed"); return on != 0; } @@ -108,7 +108,7 @@ JNIEXPORT jboolean JNICALL Java_jdk_net_LinuxSocketOptions_getQuickAck0 */ JNIEXPORT jboolean JNICALL Java_jdk_net_LinuxSocketOptions_quickAckSupported0 (JNIEnv *env, jobject unused) { - return socketOptionSupported(SOL_SOCKET, TCP_QUICKACK); + return socketOptionSupported(IPPROTO_TCP, TCP_QUICKACK); } /* From 74a12fc23e1c342c8f05e2c3dd2f7d60c63c95b1 Mon Sep 17 00:00:00 2001 From: Feilong Jiang Date: Tue, 22 Aug 2023 12:37:48 +0000 Subject: [PATCH 040/341] 8314117: RISC-V: Incorrect VMReg encoding in RISCV64Frame.java Backport-of: 5c9162288570a140138a0055cd9c4e88fe40e69d --- .../classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java index df280005d7240..c573d77b0fbac 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/riscv64/RISCV64Frame.java @@ -1,7 +1,7 @@ /* * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, Red Hat Inc. - * Copyright (c) 2021, 2022, Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2021, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,7 @@ public class RISCV64Frame extends Frame { // Native frames private static final int NATIVE_FRAME_INITIAL_PARAM_OFFSET = 2; - private static VMReg fp = new VMReg(8); + private static VMReg fp = new VMReg(8 << 1); static { VM.registerVMInitializedObserver(new Observer() { From 994f16fe74f0050b7f474a86dd9088451bd554df Mon Sep 17 00:00:00 2001 From: Fei Yang Date: Tue, 22 Aug 2023 12:39:40 +0000 Subject: [PATCH 041/341] 8310873: Re-enable locked_create_entry symbol check in runtime/NMT/CheckForProperDetailStackTrace.java for RISC-V Backport-of: 87e6fab2c498558d4593f6c0537c998a61779aaf --- .../jtreg/runtime/NMT/CheckForProperDetailStackTrace.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java b/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java index b96e3a80abafc..1606f7fea564d 100644 --- a/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java +++ b/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.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 @@ -133,7 +133,7 @@ public static void main(String args[]) throws Exception { // It's ok for ARM not to have symbols, because it does not support NMT detail // when targeting thumb2. It's also ok for Windows not to have symbols, because // they are only available if the symbols file is included with the build. - if (Platform.isWindows() || Platform.isARM() || Platform.isRISCV64()) { + if (Platform.isWindows() || Platform.isARM()) { return; // we are done } output.reportDiagnosticSummary(); From b31f232f9acff5a08a18759e6ba408da64938b43 Mon Sep 17 00:00:00 2001 From: Ben Taylor Date: Tue, 22 Aug 2023 15:03:32 +0000 Subject: [PATCH 042/341] 8314677: Bump update version for OpenJDK: jdk-17.0.8.1 Reviewed-by: simonis, goetz --- .jcheck/conf | 2 +- make/conf/version-numbers.conf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.jcheck/conf b/.jcheck/conf index b8301502d7248..99abb5c00f2ef 100644 --- a/.jcheck/conf +++ b/.jcheck/conf @@ -1,7 +1,7 @@ [general] project=jdk-updates jbs=JDK -version=17.0.8 +version=17.0.8.1 [checks] error=author,committer,reviewers,merge,issues,executable,symlink,message,hg-tag,whitespace,problemlists diff --git a/make/conf/version-numbers.conf b/make/conf/version-numbers.conf index 488b0cac1ee76..f0c1714080b32 100644 --- a/make/conf/version-numbers.conf +++ b/make/conf/version-numbers.conf @@ -29,11 +29,11 @@ DEFAULT_VERSION_FEATURE=17 DEFAULT_VERSION_INTERIM=0 DEFAULT_VERSION_UPDATE=8 -DEFAULT_VERSION_PATCH=0 +DEFAULT_VERSION_PATCH=1 DEFAULT_VERSION_EXTRA1=0 DEFAULT_VERSION_EXTRA2=0 DEFAULT_VERSION_EXTRA3=0 -DEFAULT_VERSION_DATE=2023-07-18 +DEFAULT_VERSION_DATE=2023-08-24 DEFAULT_VERSION_CLASSFILE_MAJOR=61 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_VERSION_DOCS_API_SINCE=11 From 0f29caa372f605210b4569bf2be26a55946943b3 Mon Sep 17 00:00:00 2001 From: Ben Taylor Date: Wed, 23 Aug 2023 05:24:09 +0000 Subject: [PATCH 043/341] 8313765: Invalid CEN header (invalid zip64 extra data field size) Reviewed-by: simonis Backport-of: 13f6450e2e70df4df8bd882def837fbd5bef1524 --- .../share/classes/java/util/zip/ZipFile.java | 52 +- .../classes/jdk/nio/zipfs/ZipFileSystem.java | 14 +- .../util/zip/ZipFile/CorruptedZipFiles.java | 7 +- .../ReadNonStandardExtraHeadersTest.java | 938 ++++++++++++++++++ 4 files changed, 998 insertions(+), 13 deletions(-) create mode 100644 test/jdk/java/util/zip/ZipFile/ReadNonStandardExtraHeadersTest.java diff --git a/src/java.base/share/classes/java/util/zip/ZipFile.java b/src/java.base/share/classes/java/util/zip/ZipFile.java index a2573f83f668b..d47a1d260262b 100644 --- a/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -69,7 +69,8 @@ import jdk.internal.ref.CleanerFactory; import jdk.internal.vm.annotation.Stable; import sun.nio.cs.UTF_8; -import sun.security.action.GetBooleanAction; +import sun.nio.fs.DefaultFileSystemProvider; +import sun.security.action.GetPropertyAction; import sun.security.util.SignatureFileVerifier; import static java.util.zip.ZipConstants64.*; @@ -123,11 +124,12 @@ public class ZipFile implements ZipConstants, Closeable { public static final int OPEN_DELETE = 0x4; /** - * Flag which specifies whether the validation of the Zip64 extra - * fields should be disabled + * Flag to specify whether the Extra ZIP64 validation should be + * disabled. */ - private static final boolean disableZip64ExtraFieldValidation = - GetBooleanAction.privilegedGetProperty("jdk.util.zip.disableZip64ExtraFieldValidation"); + private static final boolean DISABLE_ZIP64_EXTRA_VALIDATION = + getDisableZip64ExtraFieldValidation(); + /** * Opens a zip file for reading. * @@ -1086,6 +1088,21 @@ private int[] getMetaInfVersions() { } private static boolean isWindows; + /** + * Returns the value of the System property which indicates whether the + * Extra ZIP64 validation should be disabled. + */ + static boolean getDisableZip64ExtraFieldValidation() { + boolean result; + String value = GetPropertyAction.privilegedGetProperty( + "jdk.util.zip.disableZip64ExtraFieldValidation"); + if (value == null) { + result = false; + } else { + result = value.isEmpty() || value.equalsIgnoreCase("true"); + } + return result; + } static { SharedSecrets.setJavaUtilZipFileAccess( @@ -1204,7 +1221,7 @@ private int checkAndAddEntry(int pos, int index) } int elen = CENEXT(cen, pos); - if (elen > 0 && !disableZip64ExtraFieldValidation) { + if (elen > 0 && !DISABLE_ZIP64_EXTRA_VALIDATION) { long extraStartingOffset = pos + CENHDR + nlen; if ((int)extraStartingOffset != extraStartingOffset) { zerror("invalid CEN header (bad extra offset)"); @@ -1248,25 +1265,32 @@ private void checkExtraFields(int cenPos, int startingOffset, zerror("Invalid CEN header (extra data field size too long)"); } int currentOffset = startingOffset; - while (currentOffset < extraEndOffset) { + // Walk through each Extra Header. Each Extra Header Must consist of: + // Header ID - 2 bytes + // Data Size - 2 bytes: + while (currentOffset + Integer.BYTES <= extraEndOffset) { int tag = get16(cen, currentOffset); currentOffset += Short.BYTES; int tagBlockSize = get16(cen, currentOffset); + currentOffset += Short.BYTES; int tagBlockEndingOffset = currentOffset + tagBlockSize; // The ending offset for this tag block should not go past the // offset for the end of the extra field if (tagBlockEndingOffset > extraEndOffset) { - zerror("Invalid CEN header (invalid zip64 extra data field size)"); + zerror(String.format( + "Invalid CEN header (invalid extra data field size for " + + "tag: 0x%04x at %d)", + tag, cenPos)); } - currentOffset += Short.BYTES; if (tag == ZIP64_EXTID) { // Get the compressed size; long csize = CENSIZ(cen, cenPos); // Get the uncompressed size; long size = CENLEN(cen, cenPos); + checkZip64ExtraFieldValues(currentOffset, tagBlockSize, csize, size); } @@ -1290,6 +1314,16 @@ private void checkZip64ExtraFieldValues(int off, int blockSize, long csize, long size) throws ZipException { byte[] cen = this.cen; + // if ZIP64_EXTID blocksize == 0, which may occur with some older + // versions of Apache Ant and Commons Compress, validate csize and size + // to make sure neither field == ZIP64_MAGICVAL + if (blockSize == 0) { + if (csize == ZIP64_MAGICVAL || size == ZIP64_MAGICVAL) { + zerror("Invalid CEN header (invalid zip64 extra data field size)"); + } + // Only validate the ZIP64_EXTID data if the block size > 0 + return; + } // Validate the Zip64 Extended Information Extra Field (0x0001) // length. if (!isZip64ExtBlockSizeValid(blockSize)) { diff --git a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java index 886be5794bab4..422d6678e641c 100644 --- a/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java +++ b/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java @@ -3078,10 +3078,22 @@ private void readExtra(ZipFileSystem zipfs) throws IOException { int sz = SH(extra, pos + 2); pos += 4; if (pos + sz > elen) { // invalid data - throw new ZipException("Invalid CEN header (invalid zip64 extra data field size)"); + throw new ZipException(String.format( + "Invalid CEN header (invalid extra data field size for " + + "tag: 0x%04x size: %d)", + tag, sz)); } switch (tag) { case EXTID_ZIP64 : + // if ZIP64_EXTID blocksize == 0, which may occur with some older + // versions of Apache Ant and Commons Compress, validate csize + // size, and locoff to make sure the fields != ZIP64_MAGICVAL + if (sz == 0) { + if (csize == ZIP64_MINVAL || size == ZIP64_MINVAL || locoff == ZIP64_MINVAL) { + throw new ZipException("Invalid CEN header (invalid zip64 extra data field size)"); + } + break; + } // Check to see if we have a valid block size if (!isZip64ExtBlockSizeValid(sz)) { throw new ZipException("Invalid CEN header (invalid zip64 extra data field size)"); diff --git a/test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java b/test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java index b969ecfd04ebd..a4627721c12ff 100644 --- a/test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java +++ b/test/jdk/java/util/zip/ZipFile/CorruptedZipFiles.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4770745 6218846 6218848 6237956 + * @bug 4770745 6218846 6218848 6237956 8313765 * @summary test for correct detection and reporting of corrupted zip files * @author Martin Buchholz */ @@ -113,8 +113,9 @@ public static void main(String[] args) throws Exception { err.println("corrupted CENEXT 1"); bad = good.clone(); - bad[cenpos+CENEXT]++; - checkZipException(bad, ".*invalid zip64 extra data field size.*"); + bad[cenpos+CENEXT] = (byte)0xff; + bad[cenpos+CENEXT+1] = (byte)0xff; + checkZipException(bad, ".*extra data field size too long.*"); err.println("corrupted CENEXT 2"); bad = good.clone(); diff --git a/test/jdk/java/util/zip/ZipFile/ReadNonStandardExtraHeadersTest.java b/test/jdk/java/util/zip/ZipFile/ReadNonStandardExtraHeadersTest.java new file mode 100644 index 0000000000000..0298e748996ca --- /dev/null +++ b/test/jdk/java/util/zip/ZipFile/ReadNonStandardExtraHeadersTest.java @@ -0,0 +1,938 @@ +/* + * 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 java.io.IOException; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Formatter; +import java.util.Map; +import java.util.stream.Stream; +import java.util.zip.ZipFile; + +/* @test + * @bug 8313765 + * @summary Validate that a Zip File with an Extra Header with a data size + * of 0 can be read. + * @run main ReadNonStandardExtraHeadersTest + */ +public class ReadNonStandardExtraHeadersTest { + + /* + * Byte array holding a ZIP file which contains an + * Extra field header which has a data size of 0. + * + * ---------------#1-------------------- + * [Central Directory Header] + * 0x664: Signature : 0x02014b50 + * 0x668: Created Zip Spec : 0xa [1.0] + * 0x669: Created OS : 0x0 [MS-DOS] + * 0x66a: VerMadeby : 0xa [0, 1.0] + * 0x66b: VerExtract : 0xa [1.0] + * 0x66c: Flag : 0x800 + * 0x66e: Method : 0x0 [STORED] + * 0x670: Last Mod Time : 0x385ca437 [Thu Feb 28 20:33:46 EST 2008] + * 0x674: CRC : 0x694c6952 + * 0x678: Compressed Size : 0x624 + * 0x67c: Uncompressed Size: 0x624 + * 0x680: Name Length : 0x1b + * 0x682: Extra Length : 0x7 + * ->[tag=cafe, size=0] + * 0x684: Comment Length : 0x0 + * 0x686: Disk Start : 0x0 + * 0x688: Attrs : 0x0 + * 0x68a: AttrsEx : 0x0 + * 0x68e: Loc Header Offset: 0x0 + * 0x692: File Name : res/drawable/size_48x48.jpg + * + * [Local File Header] + * 0x0: Signature : 0x04034b50 + * 0x4: Version : 0xa [1.0] + * 0x6: Flag : 0x800 + * 0x8: Method : 0x0 [STORED] + * 0xa: LastMTime : 0x385ca437 [Thu Feb 28 20:33:46 EST 2008] + * 0xe: CRC : 0x694c6952 + * 0x12: CSize : 0x624 + * 0x16: Size : 0x624 + * 0x1a: Name Length : 0x1b [res/drawable/size_48x48.jpg] + * 0x1c: ExtraLength : 0x7 + * ->[tag=cafe, size=0] + * 0x1e: File Name : [res/drawable/size_48x48.jpg] + * [End Central Directory Header] + * Signature : 0x06054b50 + * ENDCEN Off : 0x6b4 + * Disk Entries: 0x1 + * Total Entries: 0x1 + * CEN Size : 0x50 + * Offset CEN : 0x664 + * Comment Len : 0x0 [] + */ + public static byte[] VALID_APK_FILE = { + (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0xa, (byte) 0x0, (byte) 0x0, (byte) 0x8, + (byte) 0x0, (byte) 0x0, (byte) 0x37, (byte) 0xa4, (byte) 0x5c, (byte) 0x38, (byte) 0x52, (byte) 0x69, + (byte) 0x4c, (byte) 0x69, (byte) 0x24, (byte) 0x6, (byte) 0x0, (byte) 0x0, (byte) 0x24, (byte) 0x6, + (byte) 0x0, (byte) 0x0, (byte) 0x1b, (byte) 0x0, (byte) 0x7, (byte) 0x0, (byte) 0x72, (byte) 0x65, + (byte) 0x73, (byte) 0x2f, (byte) 0x64, (byte) 0x72, (byte) 0x61, (byte) 0x77, (byte) 0x61, (byte) 0x62, + (byte) 0x6c, (byte) 0x65, (byte) 0x2f, (byte) 0x73, (byte) 0x69, (byte) 0x7a, (byte) 0x65, (byte) 0x5f, + (byte) 0x34, (byte) 0x38, (byte) 0x78, (byte) 0x34, (byte) 0x38, (byte) 0x2e, (byte) 0x6a, (byte) 0x70, + (byte) 0x67, (byte) 0xfe, (byte) 0xca, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xe0, (byte) 0x0, (byte) 0x10, (byte) 0x4a, (byte) 0x46, + (byte) 0x49, (byte) 0x46, (byte) 0x0, (byte) 0x1, (byte) 0x1, (byte) 0x1, (byte) 0x0, (byte) 0x48, + (byte) 0x0, (byte) 0x48, (byte) 0x0, (byte) 0x0, (byte) 0xff, (byte) 0xfe, (byte) 0x0, (byte) 0x16, + (byte) 0x28, (byte) 0x63, (byte) 0x29, (byte) 0x20, (byte) 0x32, (byte) 0x30, (byte) 0x30, (byte) 0x37, + (byte) 0x20, (byte) 0x50, (byte) 0x68, (byte) 0x69, (byte) 0x6c, (byte) 0x20, (byte) 0x44, (byte) 0x75, + (byte) 0x62, (byte) 0x61, (byte) 0x63, (byte) 0x68, (byte) 0xff, (byte) 0xdb, (byte) 0x0, (byte) 0x43, + (byte) 0x0, (byte) 0x6, (byte) 0x4, (byte) 0x5, (byte) 0x6, (byte) 0x5, (byte) 0x4, (byte) 0x6, + (byte) 0x6, (byte) 0x5, (byte) 0x6, (byte) 0x7, (byte) 0x7, (byte) 0x6, (byte) 0x8, (byte) 0xa, + (byte) 0x10, (byte) 0xa, (byte) 0xa, (byte) 0x9, (byte) 0x9, (byte) 0xa, (byte) 0x14, (byte) 0xe, + (byte) 0xf, (byte) 0xc, (byte) 0x10, (byte) 0x17, (byte) 0x14, (byte) 0x18, (byte) 0x18, (byte) 0x17, + (byte) 0x14, (byte) 0x16, (byte) 0x16, (byte) 0x1a, (byte) 0x1d, (byte) 0x25, (byte) 0x1f, (byte) 0x1a, + (byte) 0x1b, (byte) 0x23, (byte) 0x1c, (byte) 0x16, (byte) 0x16, (byte) 0x20, (byte) 0x2c, (byte) 0x20, + (byte) 0x23, (byte) 0x26, (byte) 0x27, (byte) 0x29, (byte) 0x2a, (byte) 0x29, (byte) 0x19, (byte) 0x1f, + (byte) 0x2d, (byte) 0x30, (byte) 0x2d, (byte) 0x28, (byte) 0x30, (byte) 0x25, (byte) 0x28, (byte) 0x29, + (byte) 0x28, (byte) 0xff, (byte) 0xdb, (byte) 0x0, (byte) 0x43, (byte) 0x1, (byte) 0x7, (byte) 0x7, + (byte) 0x7, (byte) 0xa, (byte) 0x8, (byte) 0xa, (byte) 0x13, (byte) 0xa, (byte) 0xa, (byte) 0x13, + (byte) 0x28, (byte) 0x1a, (byte) 0x16, (byte) 0x1a, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, + (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0x28, (byte) 0xff, (byte) 0xc0, + (byte) 0x0, (byte) 0x11, (byte) 0x8, (byte) 0x0, (byte) 0x30, (byte) 0x0, (byte) 0x30, (byte) 0x3, + (byte) 0x1, (byte) 0x11, (byte) 0x0, (byte) 0x2, (byte) 0x11, (byte) 0x1, (byte) 0x3, (byte) 0x11, + (byte) 0x1, (byte) 0xff, (byte) 0xc4, (byte) 0x0, (byte) 0x1b, (byte) 0x0, (byte) 0x0, (byte) 0x2, + (byte) 0x2, (byte) 0x3, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x4, (byte) 0x5, + (byte) 0x6, (byte) 0x7, (byte) 0x1, (byte) 0x3, (byte) 0x8, (byte) 0x2, (byte) 0xff, (byte) 0xc4, + (byte) 0x0, (byte) 0x2e, (byte) 0x10, (byte) 0x0, (byte) 0x2, (byte) 0x2, (byte) 0x1, (byte) 0x2, + (byte) 0x4, (byte) 0x4, (byte) 0x5, (byte) 0x4, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x2, (byte) 0x3, (byte) 0x4, (byte) 0x11, + (byte) 0x0, (byte) 0x5, (byte) 0x6, (byte) 0x12, (byte) 0x21, (byte) 0x31, (byte) 0x41, (byte) 0x51, + (byte) 0x61, (byte) 0x71, (byte) 0x7, (byte) 0x13, (byte) 0x22, (byte) 0x42, (byte) 0x91, (byte) 0x33, + (byte) 0x62, (byte) 0x81, (byte) 0xa1, (byte) 0x52, (byte) 0xd1, (byte) 0xf0, (byte) 0xff, (byte) 0xc4, + (byte) 0x0, (byte) 0x1b, (byte) 0x1, (byte) 0x0, (byte) 0x1, (byte) 0x5, (byte) 0x1, (byte) 0x1, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x6, (byte) 0x2, (byte) 0x3, (byte) 0x4, (byte) 0x5, + (byte) 0x7, (byte) 0x1, (byte) 0x0, (byte) 0xff, (byte) 0xc4, (byte) 0x0, (byte) 0x33, (byte) 0x11, + (byte) 0x0, (byte) 0x1, (byte) 0x3, (byte) 0x2, (byte) 0x4, (byte) 0x4, (byte) 0x4, (byte) 0x4, + (byte) 0x5, (byte) 0x5, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x1, (byte) 0x0, (byte) 0x2, (byte) 0x3, (byte) 0x4, (byte) 0x11, (byte) 0x5, (byte) 0x12, + (byte) 0x21, (byte) 0x31, (byte) 0x13, (byte) 0x51, (byte) 0x61, (byte) 0x71, (byte) 0x6, (byte) 0x32, + (byte) 0x41, (byte) 0x81, (byte) 0x91, (byte) 0xa1, (byte) 0xb1, (byte) 0xc1, (byte) 0x7, (byte) 0x14, + (byte) 0x42, (byte) 0xd1, (byte) 0xf0, (byte) 0x22, (byte) 0x33, (byte) 0x62, (byte) 0xa2, (byte) 0xf1, + (byte) 0xff, (byte) 0xda, (byte) 0x0, (byte) 0xc, (byte) 0x3, (byte) 0x1, (byte) 0x0, (byte) 0x2, + (byte) 0x11, (byte) 0x3, (byte) 0x11, (byte) 0x0, (byte) 0x3f, (byte) 0x0, (byte) 0xb4, (byte) 0x11, + (byte) 0xf4, (byte) 0x4c, (byte) 0xa, (byte) 0x12, (byte) 0x7b, (byte) 0x16, (byte) 0x2e, (byte) 0x5d, + (byte) 0xaf, (byte) 0x46, (byte) 0xac, (byte) 0x96, (byte) 0x6e, (byte) 0xcf, (byte) 0x1c, (byte) 0x10, + (byte) 0x46, (byte) 0x32, (byte) 0xd2, (byte) 0x48, (byte) 0xd8, (byte) 0x3, (byte) 0x48, (byte) 0x96, + (byte) 0x46, (byte) 0x44, (byte) 0xd2, (byte) 0xf7, (byte) 0x9b, (byte) 0x0, (byte) 0x91, (byte) 0x5, + (byte) 0x24, (byte) 0xd5, (byte) 0x52, (byte) 0x8, (byte) 0x60, (byte) 0x69, (byte) 0x73, (byte) 0x8e, + (byte) 0xc0, (byte) 0x6f, (byte) 0xfc, (byte) 0xfa, (byte) 0x28, (byte) 0x26, (byte) 0xe5, (byte) 0xf1, + (byte) 0x5f, (byte) 0x6b, (byte) 0x82, (byte) 0x52, (byte) 0x9b, (byte) 0x7d, (byte) 0x3b, (byte) 0x17, + (byte) 0x0, (byte) 0x38, (byte) 0xe7, (byte) 0x62, (byte) 0x22, (byte) 0x53, (byte) 0xea, (byte) 0x32, + (byte) 0x9, (byte) 0xfc, (byte) 0x81, (byte) 0xaa, (byte) 0x19, (byte) 0xfc, (byte) 0x43, (byte) 0x13, + (byte) 0xd, (byte) 0xa3, (byte) 0x69, (byte) 0x77, (byte) 0xcb, (byte) 0xf7, (byte) 0x47, (byte) 0xb4, + (byte) 0x1f, (byte) 0x86, (byte) 0x95, (byte) 0xd3, (byte) 0xb7, (byte) 0x35, (byte) 0x4c, (byte) 0xad, + (byte) 0x8f, (byte) 0xa5, (byte) 0xb3, (byte) 0x1f, (byte) 0x7d, (byte) 0x40, (byte) 0xf8, (byte) 0x12, + (byte) 0x8a, (byte) 0xd9, (byte) 0x7e, (byte) 0x26, (byte) 0x6d, (byte) 0xb7, (byte) 0x98, (byte) 0x8b, + (byte) 0x95, (byte) 0x2c, (byte) 0xd3, (byte) 0x3, (byte) 0xbc, (byte) 0x9f, (byte) 0xaa, (byte) 0x8b, + (byte) 0xee, (byte) 0x40, (byte) 0xc8, (byte) 0xfc, (byte) 0x6b, (byte) 0xb4, (byte) 0xf8, (byte) 0xfc, + (byte) 0x52, (byte) 0x7f, (byte) 0x71, (byte) 0xa5, (byte) 0xbd, (byte) 0x77, (byte) 0x1e, (byte) 0xff, + (byte) 0x0, (byte) 0xf1, (byte) 0x7b, (byte) 0x10, (byte) 0xfc, (byte) 0x34, (byte) 0xc4, (byte) 0x29, + (byte) 0x9b, (byte) 0x9e, (byte) 0x9a, (byte) 0x46, (byte) 0xcb, (byte) 0xd3, (byte) 0xca, (byte) 0xef, + (byte) 0x6b, (byte) 0x92, (byte) 0xf, (byte) 0xc4, (byte) 0x29, (byte) 0xd4, (byte) 0x13, (byte) 0x47, + (byte) 0x62, (byte) 0x14, (byte) 0x9a, (byte) 0x9, (byte) 0x12, (byte) 0x58, (byte) 0x9c, (byte) 0x73, + (byte) 0x2b, (byte) 0xa1, (byte) 0x4, (byte) 0x30, (byte) 0xf3, (byte) 0x7, (byte) 0x57, (byte) 0xac, + (byte) 0x7b, (byte) 0x5e, (byte) 0xd0, (byte) 0xe6, (byte) 0x9b, (byte) 0x82, (byte) 0x80, (byte) 0x24, + (byte) 0x82, (byte) 0x48, (byte) 0x1e, (byte) 0x62, (byte) 0x95, (byte) 0xa5, (byte) 0xae, (byte) 0x1a, + (byte) 0x10, (byte) 0x45, (byte) 0x88, (byte) 0x3d, (byte) 0x42, (byte) 0xf7, (byte) 0x83, (byte) 0xae, + (byte) 0xdd, (byte) 0x75, (byte) 0xa1, (byte) 0x2, (byte) 0xd2, (byte) 0x47, (byte) 0x1a, (byte) 0x33, + (byte) 0xbb, (byte) 0x5, (byte) 0x45, (byte) 0x5, (byte) 0x99, (byte) 0x89, (byte) 0xc0, (byte) 0x0, + (byte) 0x77, (byte) 0x27, (byte) 0x49, (byte) 0xce, (byte) 0x0, (byte) 0xb9, (byte) 0x53, (byte) 0xcc, + (byte) 0x2e, (byte) 0x71, (byte) 0xb0, (byte) 0x17, (byte) 0x25, (byte) 0x73, (byte) 0xff, (byte) 0x0, + (byte) 0x1d, (byte) 0x71, (byte) 0x54, (byte) 0xfc, (byte) 0x4f, (byte) 0xba, (byte) 0x30, (byte) 0x46, + (byte) 0x64, (byte) 0xdb, (byte) 0x21, (byte) 0x62, (byte) 0x2b, (byte) 0xc5, (byte) 0xdb, (byte) 0x3f, + (byte) 0xbd, (byte) 0x87, (byte) 0xf9, (byte) 0x1f, (byte) 0xe8, (byte) 0x74, (byte) 0xf3, (byte) 0xc8, + (byte) 0x46, (byte) 0x25, (byte) 0x5e, (byte) 0xea, (byte) 0xb9, (byte) 0x3f, (byte) 0xc4, (byte) 0x6c, + (byte) 0x3e, (byte) 0xeb, (byte) 0x6d, (byte) 0xf0, (byte) 0xbf, (byte) 0x87, (byte) 0xa3, (byte) 0xc2, + (byte) 0xa0, (byte) 0x5, (byte) 0xc2, (byte) 0xf2, (byte) 0xbb, (byte) 0xcc, (byte) 0x7e, (byte) 0xc3, + (byte) 0xa0, (byte) 0xf9, (byte) 0x9d, (byte) 0x79, (byte) 0x59, (byte) 0xa, (byte) 0x2e, (byte) 0x7, + (byte) 0x4d, (byte) 0x54, (byte) 0x92, (byte) 0x8c, (byte) 0xd8, (byte) 0xdb, (byte) 0x29, (byte) 0x1f, + (byte) 0xe, (byte) 0x55, (byte) 0xbc, (byte) 0x86, (byte) 0x69, (byte) 0xea, (byte) 0x30, (byte) 0xc, + (byte) 0x22, (byte) 0x62, (byte) 0x63, (byte) 0x75, (byte) 0x24, (byte) 0x48, (byte) 0x83, (byte) 0xbe, + (byte) 0x7d, (byte) 0x3b, (byte) 0x75, (byte) 0x3e, (byte) 0x24, (byte) 0xe, (byte) 0xe4, (byte) 0x69, + (byte) 0xe8, (byte) 0xc, (byte) 0x8c, (byte) 0xbb, (byte) 0xd8, (byte) 0xa2, (byte) 0x56, (byte) 0x54, + (byte) 0xd3, (byte) 0x87, (byte) 0x32, (byte) 0x9, (byte) 0x4e, (byte) 0xae, (byte) 0x3a, (byte) 0x5b, + (byte) 0xd3, (byte) 0xaa, (byte) 0x7f, (byte) 0xc0, (byte) 0x7c, (byte) 0x5e, (byte) 0xdb, (byte) 0x2d, + (byte) 0xd1, (byte) 0x5, (byte) 0xd9, (byte) 0x11, (byte) 0x36, (byte) 0xb9, (byte) 0x64, (byte) 0xc3, + (byte) 0x87, (byte) 0x6c, (byte) 0x8, (byte) 0x89, (byte) 0xfb, (byte) 0x86, (byte) 0x7b, (byte) 0xf, + (byte) 0x3d, (byte) 0x59, (byte) 0xe1, (byte) 0x38, (byte) 0x8b, (byte) 0xa0, (byte) 0x7e, (byte) 0x43, + (byte) 0xe5, (byte) 0x3e, (byte) 0x9c, (byte) 0xba, (byte) 0xa1, (byte) 0x6f, (byte) 0x1b, (byte) 0x78, + (byte) 0x6e, (byte) 0x9a, (byte) 0xbe, (byte) 0x98, (byte) 0xd5, (byte) 0x5c, (byte) 0x36, (byte) 0x66, + (byte) 0xd, (byte) 0x9, (byte) 0xb0, (byte) 0xcd, (byte) 0x6f, (byte) 0xd2, (byte) 0x6f, (byte) 0xfe, + (byte) 0xbc, (byte) 0x8f, (byte) 0x4b, (byte) 0xab, (byte) 0xa6, (byte) 0xad, (byte) 0x9a, (byte) 0xf7, + (byte) 0x2b, (byte) 0xa4, (byte) 0xf4, (byte) 0xe7, (byte) 0x86, (byte) 0xc4, (byte) 0xf, (byte) 0xd5, + (byte) 0x65, (byte) 0x85, (byte) 0xc3, (byte) 0xab, (byte) 0x7b, (byte) 0x11, (byte) 0xd0, (byte) 0xe8, + (byte) 0xc5, (byte) 0xaf, (byte) 0xe, (byte) 0x17, (byte) 0x69, (byte) 0xba, (byte) 0xc2, (byte) 0xf2, + (byte) 0x16, (byte) 0x9b, (byte) 0x38, (byte) 0x59, (byte) 0x40, (byte) 0x78, (byte) 0xd6, (byte) 0xf3, + (byte) 0xa7, (byte) 0x8, (byte) 0xee, (byte) 0xe6, (byte) 0x33, (byte) 0xf5, (byte) 0x1a, (byte) 0xec, + (byte) 0xbd, (byte) 0x3c, (byte) 0x8f, (byte) 0x43, (byte) 0xfd, (byte) 0x13, (byte) 0xaa, (byte) 0xea, + (byte) 0xd9, (byte) 0x4f, (byte) 0x1, (byte) 0xe0, (byte) 0x72, (byte) 0x45, (byte) 0x78, (byte) 0x4c, + (byte) 0x2d, (byte) 0xfc, (byte) 0xf4, (byte) 0x39, (byte) 0xb6, (byte) 0xcc, (byte) 0x3e, (byte) 0x5b, + (byte) 0x7c, (byte) 0xd5, (byte) 0xb, (byte) 0x59, (byte) 0xb3, (byte) 0xa0, (byte) 0xd7, (byte) 0x85, + (byte) 0xb5, (byte) 0x53, (byte) 0x3e, (byte) 0xe9, (byte) 0xe6, (byte) 0xc6, (byte) 0x6a, (byte) 0x35, + (byte) 0xe4, (byte) 0x5d, (byte) 0xc1, (byte) 0x9d, (byte) 0x6b, (byte) 0xb0, (byte) 0x21, (byte) 0x9a, + (byte) 0x3c, (byte) 0x64, (byte) 0x7a, (byte) 0x8c, (byte) 0xe9, (byte) 0xa6, (byte) 0xe5, (byte) 0x7, + (byte) 0xfa, (byte) 0xb6, (byte) 0x53, (byte) 0xe5, (byte) 0x74, (byte) 0x9c, (byte) 0x33, (byte) 0xc2, + (byte) 0xf3, (byte) 0x75, (byte) 0x5b, (byte) 0xa5, (byte) 0xdf, (byte) 0x61, (byte) 0xda, (byte) 0x4f, + (byte) 0xc9, (byte) 0xb7, (byte) 0x3d, (byte) 0xc6, (byte) 0x4b, (byte) 0x32, (byte) 0x34, (byte) 0xb, + (byte) 0x65, (byte) 0x47, (byte) 0x53, (byte) 0x0, (byte) 0xc1, (byte) 0x18, (byte) 0xcf, (byte) 0x7f, + (byte) 0xbb, (byte) 0xa7, (byte) 0x99, (byte) 0xf5, (byte) 0x3a, (byte) 0x71, (byte) 0xb1, (byte) 0x49, + (byte) 0x35, (byte) 0xf2, (byte) 0x1d, (byte) 0x96, (byte) 0x6f, (byte) 0x8d, (byte) 0x62, (byte) 0x2f, + (byte) 0xa2, (byte) 0xc5, (byte) 0x44, (byte) 0xf1, (byte) 0x58, (byte) 0x90, (byte) 0xdb, (byte) 0x5b, + (byte) 0x70, (byte) 0xe, (byte) 0xbb, (byte) 0xf5, (byte) 0x6, (byte) 0xc5, (byte) 0x19, (byte) 0xc5, + (byte) 0xd4, (byte) 0xf6, (byte) 0xad, (byte) 0xbe, (byte) 0x18, (byte) 0x2d, (byte) 0x52, (byte) 0x13, + (byte) 0xd9, (byte) 0x2e, (byte) 0x3, (byte) 0x27, (byte) 0x2c, (byte) 0x79, (byte) 0x3c, (byte) 0x84, + (byte) 0x2, (byte) 0xf, (byte) 0x29, (byte) 0x39, (byte) 0xd, (byte) 0xea, (byte) 0x7d, (byte) 0x3b, + (byte) 0x75, (byte) 0xcb, (byte) 0x70, (byte) 0xe7, (byte) 0x75, (byte) 0xe2, (byte) 0x6, (byte) 0xdc, + (byte) 0xfd, (byte) 0x2, (byte) 0x8d, (byte) 0x84, (byte) 0xe2, (byte) 0x74, (byte) 0xfc, (byte) 0x73, + (byte) 0x55, (byte) 0x5d, (byte) 0x1b, (byte) 0xa6, (byte) 0x94, (byte) 0xed, (byte) 0xb1, (byte) 0xb7, + (byte) 0x60, (byte) 0x4f, (byte) 0xc3, (byte) 0x4d, (byte) 0x3d, (byte) 0x2, (byte) 0xb9, (byte) 0xf8, + (byte) 0x3, (byte) 0x88, (byte) 0xdb, (byte) 0x88, (byte) 0xf6, (byte) 0x48, (byte) 0x67, (byte) 0x6d, + (byte) 0xaf, (byte) 0x72, (byte) 0xa5, (byte) 0xcb, (byte) 0x1a, (byte) 0xab, (byte) 0x49, (byte) 0x6e, + (byte) 0x25, (byte) 0x45, (byte) 0x99, (byte) 0x80, (byte) 0xc3, (byte) 0x14, (byte) 0xc3, (byte) 0x12, + (byte) 0x46, (byte) 0x41, (byte) 0xee, (byte) 0x6, (byte) 0x8f, (byte) 0x68, (byte) 0xe7, (byte) 0x32, + (byte) 0xc4, (byte) 0xd2, (byte) 0x79, (byte) 0x6f, (byte) 0xe8, (byte) 0x4a, (byte) 0x2, (byte) 0xc5, + (byte) 0x29, (byte) 0x44, (byte) 0x15, (byte) 0x52, (byte) 0x34, (byte) 0x2, (byte) 0xd1, (byte) 0x72, + (byte) 0x43, (byte) 0x48, (byte) 0xb1, (byte) 0x0, (byte) 0xea, (byte) 0x1, (byte) 0x1d, (byte) 0x88, + (byte) 0x49, (byte) 0xae, (byte) 0xc0, (byte) 0x96, (byte) 0xea, (byte) 0x4f, (byte) 0x5a, (byte) 0x6f, + (byte) 0xd2, (byte) 0x9a, (byte) 0x36, (byte) 0x8d, (byte) 0xbd, (byte) 0x88, (byte) 0xc1, (byte) 0xd4, + (byte) 0x77, (byte) 0x8c, (byte) 0xcd, (byte) 0x2d, (byte) 0x3e, (byte) 0xaa, (byte) 0xce, (byte) 0x37, + (byte) 0x18, (byte) 0x9e, (byte) 0x24, (byte) 0x6e, (byte) 0xe0, (byte) 0xdf, (byte) 0xe0, (byte) 0xb9, + (byte) 0xfa, (byte) 0x4a, (byte) 0xf3, (byte) 0x50, (byte) 0xbd, (byte) 0x3d, (byte) 0x4b, (byte) 0x0, + (byte) 0xac, (byte) 0xd0, (byte) 0xb9, (byte) 0x46, (byte) 0x1e, (byte) 0xa3, (byte) 0xc7, (byte) 0xdb, + (byte) 0x42, (byte) 0xd3, (byte) 0x30, (byte) 0xb4, (byte) 0x90, (byte) 0x56, (byte) 0xaf, (byte) 0x86, + (byte) 0xd4, (byte) 0x89, (byte) 0x58, (byte) 0x1e, (byte) 0xd3, (byte) 0xa1, (byte) 0x4c, (byte) 0x76, + (byte) 0xe1, (byte) 0x1b, (byte) 0xdc, (byte) 0x84, (byte) 0xd9, (byte) 0x23, (byte) 0xe4, (byte) 0x2b, + (byte) 0x7, (byte) 0x91, (byte) 0x73, (byte) 0x8e, (byte) 0x65, (byte) 0x1d, (byte) 0x48, (byte) 0xf7, + (byte) 0x20, (byte) 0x11, (byte) 0xfc, (byte) 0xea, (byte) 0x31, (byte) 0xd1, (byte) 0x59, (byte) 0x55, + (byte) 0x36, (byte) 0x69, (byte) 0x20, (byte) 0x73, (byte) 0x62, (byte) 0x75, (byte) 0x9c, (byte) 0x74, + (byte) 0x1d, (byte) 0x2f, (byte) 0xa5, (byte) 0xfd, (byte) 0xb7, (byte) 0xf6, (byte) 0x52, (byte) 0x7b, + (byte) 0xd3, (byte) 0x52, (byte) 0xde, (byte) 0x52, (byte) 0x2b, (byte) 0x97, (byte) 0xab, (byte) 0x6, + (byte) 0x44, (byte) 0x95, (byte) 0x5a, (byte) 0x34, (byte) 0xce, (byte) 0x3e, (byte) 0x5a, (byte) 0x82, + (byte) 0xa0, (byte) 0x9f, (byte) 0xe, (byte) 0xfd, (byte) 0x7d, (byte) 0x87, (byte) 0xe7, (byte) 0x4c, + (byte) 0xc, (byte) 0xf1, (byte) 0x13, (byte) 0xc2, (byte) 0x36, (byte) 0xb8, (byte) 0x59, (byte) 0xdc, + (byte) 0xf8, (byte) 0x23, (byte) 0xdd, (byte) 0x59, (byte) 0x25, (byte) 0x2d, (byte) 0x35, (byte) 0xdd, + (byte) 0xc3, (byte) 0x0, (byte) 0x9e, (byte) 0xa7, (byte) 0x7b, (byte) 0x77, (byte) 0x20, (byte) 0xe9, + (byte) 0xd9, (byte) 0x1, (byte) 0x7e, (byte) 0xed, (byte) 0xcd, (byte) 0xd4, (byte) 0xc5, (byte) 0x16, + (byte) 0xcc, (byte) 0xcb, (byte) 0x60, (byte) 0xca, (byte) 0xe1, (byte) 0xd, (byte) 0x76, (byte) 0x24, + (byte) 0x16, (byte) 0x70, (byte) 0x70, (byte) 0x1, (byte) 0xfd, (byte) 0xd8, (byte) 0xc7, (byte) 0x5f, + (byte) 0x51, (byte) 0x9e, (byte) 0xd8, (byte) 0xd3, (byte) 0xd1, (byte) 0x42, (byte) 0x1, (byte) 0x11, + (byte) 0xbe, (byte) 0xf7, (byte) 0x3c, (byte) 0xb9, (byte) 0xfd, (byte) 0xd5, (byte) 0x9e, (byte) 0xd, + (byte) 0x1d, (byte) 0x4c, (byte) 0x14, (byte) 0xe7, (byte) 0x10, (byte) 0xa0, (byte) 0x94, (byte) 0x59, + (byte) 0xb7, (byte) 0xce, (byte) 0xc7, (byte) 0xed, (byte) 0xa6, (byte) 0xfa, (byte) 0xfa, (byte) 0x5c, + (byte) 0x6b, (byte) 0xe9, (byte) 0xd4, (byte) 0x9b, (byte) 0x2b, (byte) 0xe3, (byte) 0x82, (byte) 0x23, + (byte) 0x9a, (byte) 0xaf, (byte) 0xc, (byte) 0xd1, (byte) 0xa9, (byte) 0x6a, (byte) 0x8c, (byte) 0xd4, + (byte) 0x6c, (byte) 0x57, (byte) 0x4f, (byte) 0x97, (byte) 0x24, (byte) 0x32, (byte) 0xb2, (byte) 0x3f, + (byte) 0xd5, (byte) 0xdc, (byte) 0xb0, (byte) 0x64, (byte) 0x24, (byte) 0x15, (byte) 0x24, (byte) 0x92, + (byte) 0xe, (byte) 0x7f, (byte) 0x81, (byte) 0xa3, (byte) 0x8a, (byte) 0x48, (byte) 0xf8, (byte) 0x10, + (byte) 0xb6, (byte) 0x2e, (byte) 0x4b, (byte) 0x3c, (byte) 0xc5, (byte) 0xaa, (byte) 0xce, (byte) 0x21, + (byte) 0x5b, (byte) 0x25, (byte) 0x5b, (byte) 0xbf, (byte) 0x59, (byte) 0xbf, (byte) 0x61, (byte) 0xb0, + (byte) 0x1e, (byte) 0xc0, (byte) 0x4, (byte) 0xbe, (byte) 0x6a, (byte) 0xf9, (byte) 0xce, (byte) 0x35, + (byte) 0xe7, (byte) 0x35, (byte) 0x4b, (byte) 0x50, (byte) 0xe, (byte) 0x3c, (byte) 0xe1, (byte) 0x64, + (byte) 0xdc, (byte) 0xe5, (byte) 0x4b, (byte) 0x35, (byte) 0xf1, (byte) 0x15, (byte) 0xe0, (byte) 0x30, + (byte) 0x5b, (byte) 0xc2, (byte) 0x41, (byte) 0xe0, (byte) 0x1b, (byte) 0xfd, (byte) 0xff, (byte) 0x0, + (byte) 0xc2, (byte) 0xae, (byte) 0xae, (byte) 0x97, (byte) 0x89, (byte) 0xa8, (byte) 0xdd, (byte) 0x5d, + (byte) 0x61, (byte) 0x38, (byte) 0xb3, (byte) 0xa8, (byte) 0x8e, (byte) 0x57, (byte) 0x6a, (byte) 0xcf, + (byte) 0xa7, (byte) 0x6f, (byte) 0xd9, (byte) 0x40, (byte) 0xdf, (byte) 0x68, (byte) 0xdc, (byte) 0xab, + (byte) 0x37, (byte) 0x24, (byte) 0xd4, (byte) 0xa6, (byte) 0x38, (byte) 0xf1, (byte) 0x45, (byte) 0xe7, + (byte) 0x1f, (byte) 0x91, (byte) 0xaa, (byte) 0x39, (byte) 0x29, (byte) 0x65, (byte) 0x6e, (byte) 0xed, + (byte) 0x5a, (byte) 0x15, (byte) 0x1e, (byte) 0x37, (byte) 0x47, (byte) 0x30, (byte) 0xd2, (byte) 0x40, + (byte) 0x3b, (byte) 0x9b, (byte) 0x7d, (byte) 0x53, (byte) 0x3d, (byte) 0xaf, (byte) 0x67, (byte) 0xdd, + (byte) 0xf7, (byte) 0x14, (byte) 0x58, (byte) 0xaa, (byte) 0xd1, (byte) 0x9d, (byte) 0xd5, (byte) 0x49, + (byte) 0xc1, (byte) 0x65, (byte) 0xe5, (byte) 0x51, (byte) 0x9c, (byte) 0x7d, (byte) 0xc7, (byte) 0x3, + (byte) 0xc3, (byte) 0x4d, (byte) 0xb2, (byte) 0x92, (byte) 0x69, (byte) 0x8d, (byte) 0x98, (byte) 0xd2, + (byte) 0xa4, (byte) 0x49, (byte) 0x89, (byte) 0x61, (byte) 0x94, (byte) 0xf, (byte) 0x7d, (byte) 0x44, + (byte) 0x92, (byte) 0x0, (byte) 0xe7, (byte) 0xda, (byte) 0xfa, (byte) 0xdc, (byte) 0x9b, (byte) 0x6d, + (byte) 0xa0, (byte) 0xb9, (byte) 0x56, (byte) 0x47, (byte) 0x5, (byte) 0xf0, (byte) 0x2c, (byte) 0x5b, + (byte) 0x4d, (byte) 0x94, (byte) 0xdc, (byte) 0x37, (byte) 0x7, (byte) 0xf9, (byte) 0x97, (byte) 0x81, + (byte) 0xe6, (byte) 0x54, (byte) 0x89, (byte) 0x8a, (byte) 0xa2, (byte) 0x1f, (byte) 0x33, (byte) 0x8c, + (byte) 0x73, (byte) 0x1f, (byte) 0x7e, (byte) 0x9d, (byte) 0x4f, (byte) 0x7d, (byte) 0x5f, (byte) 0xd1, + (byte) 0x61, (byte) 0xdc, (byte) 0x1b, (byte) 0x3e, (byte) 0x53, (byte) 0x72, (byte) 0x36, (byte) 0x1c, + (byte) 0xbf, (byte) 0x9f, (byte) 0xe, (byte) 0xeb, (byte) 0x3a, (byte) 0xc7, (byte) 0xf1, (byte) 0xf8, + (byte) 0xab, (byte) 0x9e, (byte) 0xf6, (byte) 0xd1, (byte) 0x47, (byte) 0x90, (byte) 0x3b, (byte) 0xcc, + (byte) 0xed, (byte) 0x8b, (byte) 0xfb, (byte) 0x81, (byte) 0xa5, (byte) 0xbb, (byte) 0xdc, (byte) 0xf6, + (byte) 0xd4, (byte) 0x2b, (byte) 0x1e, (byte) 0x26, (byte) 0xe6, (byte) 0x41, (byte) 0x9e, (byte) 0xfa, + (byte) 0xb8, (byte) 0xe, (byte) 0xb8, (byte) 0x41, (byte) 0xce, (byte) 0x65, (byte) 0x8a, (byte) 0x5, + (byte) 0xea, (byte) 0x83, (byte) 0xe1, (byte) 0xa7, (byte) 0x4b, (byte) 0x41, (byte) 0x56, (byte) 0x65, + (byte) 0x2d, (byte) 0xbb, (byte) 0xb7, (byte) 0x7, (byte) 0x90, (byte) 0x12, (byte) 0x3c, (byte) 0x34, + (byte) 0xc3, (byte) 0xa3, (byte) 0xd5, (byte) 0x26, (byte) 0xeb, (byte) 0x4c, (byte) 0x5b, (byte) 0x6c, + (byte) 0x68, (byte) 0x73, (byte) 0xca, (byte) 0x33, (byte) 0xa4, (byte) 0xf0, (byte) 0xc0, (byte) 0x49, + (byte) 0x25, (byte) 0x1f, (byte) 0x14, (byte) 0x41, (byte) 0x40, (byte) 0xd7, (byte) 0x53, (byte) 0x64, + (byte) 0x22, (byte) 0x54, (byte) 0x79, (byte) 0x69, (byte) 0x4, (byte) 0xaf, (byte) 0x6, (byte) 0xa2, + (byte) 0xe2, (byte) 0xfa, (byte) 0x53, (byte) 0xd7, (byte) 0x5d, (byte) 0x1a, (byte) 0x4, (byte) 0xd3, + (byte) 0x85, (byte) 0xca, (byte) 0xff, (byte) 0xd9, (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, + (byte) 0xa, (byte) 0x0, (byte) 0xa, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x0, (byte) 0x0, + (byte) 0x37, (byte) 0xa4, (byte) 0x5c, (byte) 0x38, (byte) 0x52, (byte) 0x69, (byte) 0x4c, (byte) 0x69, + (byte) 0x24, (byte) 0x6, (byte) 0x0, (byte) 0x0, (byte) 0x24, (byte) 0x6, (byte) 0x0, (byte) 0x0, + (byte) 0x1b, (byte) 0x0, (byte) 0x7, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x72, (byte) 0x65, (byte) 0x73, (byte) 0x2f, (byte) 0x64, (byte) 0x72, + (byte) 0x61, (byte) 0x77, (byte) 0x61, (byte) 0x62, (byte) 0x6c, (byte) 0x65, (byte) 0x2f, (byte) 0x73, + (byte) 0x69, (byte) 0x7a, (byte) 0x65, (byte) 0x5f, (byte) 0x34, (byte) 0x38, (byte) 0x78, (byte) 0x34, + (byte) 0x38, (byte) 0x2e, (byte) 0x6a, (byte) 0x70, (byte) 0x67, (byte) 0xfe, (byte) 0xca, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x5, (byte) 0x6, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x1, (byte) 0x0, + (byte) 0x50, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x64, (byte) 0x6, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, + }; + + /* + * Jar file created by Apache Commons-Compress which creates + * a CEN entry with a Zip64 extra header entry with a size of 0 + * ----------------#1-------------------- + * [Central Directory Header] + * 0x52b: Signature : 0x02014b50 + * 0x52f: Created Zip Spec : 0x2d [4.5] + * 0x530: Created OS : 0x3 [UNIX] + * 0x531: VerMadeby : 0x32d [3, 4.5] + * 0x532: VerExtract : 0x2d [4.5] + * 0x533: Flag : 0x800 + * 0x535: Method : 0x0 [STORED] + * 0x537: Last Mod Time : 0x570169c0 [Tue Aug 01 13:14:00 EDT 2023] + * 0x53b: CRC : 0x0 + * 0x53f: Compressed Size : 0x0 + * 0x543: Uncompressed Size: 0x0 + * 0x547: Name Length : 0x9 + * 0x549: Extra Length : 0x8 + * [tag=0x0001, sz=0, data= ] + * ->ZIP64: + * [tag=0xcafe, sz=0, data= ] + * ->[tag=cafe, size=0] + * 0x54b: Comment Length : 0x0 + * 0x54d: Disk Start : 0x0 + * 0x54f: Attrs : 0x0 + * 0x551: AttrsEx : 0x41ed0010 + * 0x555: Loc Header Offset: 0x0 + * 0x559: File Name : META-INF/ + */ + public static byte[] COMMONS_COMPRESS_JAR = { + (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, + (byte) 0x0, (byte) 0x0, (byte) 0xc0, (byte) 0x69, (byte) 0x1, (byte) 0x57, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0x9, (byte) 0x0, (byte) 0x18, (byte) 0x0, (byte) 0x4d, (byte) 0x45, + (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, (byte) 0x1, + (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xfe, (byte) 0xca, (byte) 0x0, (byte) 0x0, (byte) 0x50, + (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x8, + (byte) 0x0, (byte) 0xbd, (byte) 0x69, (byte) 0x1, (byte) 0x57, (byte) 0x71, (byte) 0xa7, (byte) 0x16, + (byte) 0x53, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0x14, (byte) 0x0, (byte) 0x14, (byte) 0x0, (byte) 0x4d, (byte) 0x45, (byte) 0x54, + (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, (byte) 0x4d, (byte) 0x41, + (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, (byte) 0x54, (byte) 0x2e, (byte) 0x4d, + (byte) 0x46, (byte) 0x1, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x68, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x5b, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xf3, (byte) 0x4d, (byte) 0xcc, + (byte) 0xcb, (byte) 0x4c, (byte) 0x4b, (byte) 0x2d, (byte) 0x2e, (byte) 0xd1, (byte) 0xd, (byte) 0x4b, + (byte) 0x2d, (byte) 0x2a, (byte) 0xce, (byte) 0xcc, (byte) 0xcf, (byte) 0xb3, (byte) 0x52, (byte) 0x30, + (byte) 0xd4, (byte) 0x33, (byte) 0xe0, (byte) 0xe5, (byte) 0x72, (byte) 0xcc, (byte) 0x43, (byte) 0x12, + (byte) 0x71, (byte) 0x2c, (byte) 0x48, (byte) 0x4c, (byte) 0xce, (byte) 0x48, (byte) 0x55, (byte) 0x0, + (byte) 0x8a, (byte) 0x1, (byte) 0x25, (byte) 0xd, (byte) 0xd, (byte) 0xf4, (byte) 0x2c, (byte) 0x78, + (byte) 0xb9, (byte) 0x9c, (byte) 0x8b, (byte) 0x52, (byte) 0x13, (byte) 0x4b, (byte) 0x52, (byte) 0x53, + (byte) 0x74, (byte) 0x9d, (byte) 0x2a, (byte) 0x81, (byte) 0x1a, (byte) 0x2c, (byte) 0xf4, (byte) 0xc, + (byte) 0xf4, (byte) 0x80, (byte) 0x12, (byte) 0xda, (byte) 0x46, (byte) 0xba, (byte) 0x66, (byte) 0xa, + (byte) 0x1a, (byte) 0xfe, (byte) 0x45, (byte) 0x89, (byte) 0xc9, (byte) 0x39, (byte) 0xa9, (byte) 0xa, + (byte) 0xce, (byte) 0xf9, (byte) 0x45, (byte) 0x5, (byte) 0xf9, (byte) 0x45, (byte) 0x89, (byte) 0x25, + (byte) 0x40, (byte) 0x3, (byte) 0x34, (byte) 0x79, (byte) 0xb9, (byte) 0x78, (byte) 0xb9, (byte) 0x0, + (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, + (byte) 0x8, (byte) 0x0, (byte) 0x61, (byte) 0x69, (byte) 0x1, (byte) 0x57, (byte) 0x16, (byte) 0x64, + (byte) 0x9c, (byte) 0xc5, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0x19, (byte) 0x0, (byte) 0x14, (byte) 0x0, (byte) 0x5a, (byte) 0x69, + (byte) 0x70, (byte) 0x46, (byte) 0x69, (byte) 0x6c, (byte) 0x65, (byte) 0x50, (byte) 0x72, (byte) 0x6f, + (byte) 0x70, (byte) 0x65, (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x54, (byte) 0x65, (byte) 0x73, + (byte) 0x74, (byte) 0x2e, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x1, + (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0xf, (byte) 0x7, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x4, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x85, (byte) 0x55, (byte) 0xcf, (byte) 0x53, (byte) 0xdb, + (byte) 0x46, (byte) 0x14, (byte) 0xfe, (byte) 0xd6, (byte) 0x3f, (byte) 0x90, (byte) 0x2d, (byte) 0x8b, + (byte) 0x38, (byte) 0x36, (byte) 0x21, (byte) 0xc1, (byte) 0x34, (byte) 0x4, (byte) 0x12, (byte) 0x70, + (byte) 0x63, (byte) 0xb0, (byte) 0x8d, (byte) 0xdb, (byte) 0x42, (byte) 0xd3, (byte) 0x36, (byte) 0xa6, + (byte) 0xf9, (byte) 0x45, (byte) 0x42, (byte) 0xb, (byte) 0x35, (byte) 0xe0, (byte) 0x62, (byte) 0x87, + (byte) 0xd4, (byte) 0xa4, (byte) 0x6d, (byte) 0x22, (byte) 0xdb, (byte) 0x4a, (byte) 0x22, (byte) 0x2a, + (byte) 0x4b, (byte) 0x1a, (byte) 0x49, (byte) 0x2e, (byte) 0x49, (byte) 0x67, (byte) 0x7a, (byte) 0xe8, + (byte) 0x4c, (byte) 0xcf, (byte) 0x9d, (byte) 0x69, (byte) 0xfe, (byte) 0x82, (byte) 0xde, (byte) 0x38, + (byte) 0xf5, (byte) 0x40, (byte) 0xe, (byte) 0x86, (byte) 0x94, (byte) 0x49, (byte) 0x73, (byte) 0xcb, + (byte) 0x21, (byte) 0xff, (byte) 0x51, (byte) 0x2f, (byte) 0xa5, (byte) 0x6f, (byte) 0x25, (byte) 0xc0, + (byte) 0x86, (byte) 0x98, (byte) 0x29, (byte) 0xcc, (byte) 0x68, (byte) 0x77, (byte) 0xdf, (byte) 0xee, + (byte) 0xf7, (byte) 0xbd, (byte) 0xf7, (byte) 0xbe, (byte) 0xf7, (byte) 0x76, (byte) 0xfd, (byte) 0xf6, + (byte) 0xdf, (byte) 0xbf, (byte) 0xfe, (byte) 0x6, (byte) 0x70, (byte) 0xb, (byte) 0xf, (byte) 0x45, + (byte) 0xf8, (byte) 0xe0, (byte) 0x17, (byte) 0x10, (byte) 0x90, (byte) 0x10, (byte) 0x44, (byte) 0xf, + (byte) 0xc3, (byte) 0xe9, (byte) 0x75, (byte) 0xf9, (byte) 0x47, (byte) 0x39, (byte) 0xa7, (byte) 0xc9, + (byte) 0xfa, (byte) 0xe3, (byte) 0xdc, (byte) 0x72, (byte) 0x75, (byte) 0x5d, (byte) 0xa9, (byte) 0x39, + (byte) 0xc, (byte) 0x3d, (byte) 0x33, (byte) 0xaa, (byte) 0xae, (byte) 0x3a, (byte) 0xd7, (byte) 0x18, + (byte) 0xfc, (byte) 0xa9, (byte) 0xf1, (byte) 0x55, (byte) 0x1, (byte) 0x21, (byte) 0x86, (byte) 0xbe, + (byte) 0x35, (byte) 0xd5, (byte) 0x9c, (byte) 0x53, (byte) 0x35, (byte) 0xa5, (byte) 0x68, (byte) 0x19, + (byte) 0xa6, (byte) 0x62, (byte) 0x39, (byte) 0xcf, (byte) 0xca, (byte) 0x8a, (byte) 0xed, (byte) 0x88, + (byte) 0x10, (byte) 0xe0, (byte) 0xe7, (byte) 0x9f, (byte) 0x88, (byte) 0x4, (byte) 0x89, (byte) 0x33, + (byte) 0x9d, (byte) 0xb2, (byte) 0x14, (byte) 0xb9, (byte) 0x5e, (byte) 0x52, (byte) 0xf5, (byte) 0xc7, + (byte) 0x9a, (byte) 0xc2, (byte) 0xcf, (byte) 0xa, (byte) 0x38, (byte) 0xc5, (byte) 0xd0, (byte) 0xef, + (byte) 0xb2, (byte) 0x37, (byte) 0x1d, (byte) 0x55, (byte) 0xcb, (byte) 0xfd, (byte) 0xa4, (byte) 0x9a, + (byte) 0xb9, (byte) 0x7d, (byte) 0x9a, (byte) 0x10, (byte) 0x4e, (byte) 0x33, (byte) 0x64, (byte) 0x72, + (byte) 0x77, (byte) 0x6d, (byte) 0xc5, (byte) 0xb2, (byte) 0x73, (byte) 0xda, (byte) 0xba, (byte) 0xac, + (byte) 0xd7, (byte) 0xf9, (byte) 0xe4, (byte) 0xb6, (byte) 0xb1, (byte) 0xa1, (byte) 0x6b, (byte) 0x86, + (byte) 0x5c, (byte) 0xb7, (byte) 0x73, (byte) 0x1b, (byte) 0xb5, (byte) 0x29, (byte) 0xab, (byte) 0x6e, + (byte) 0xca, (byte) 0xe4, (byte) 0x48, (byte) 0x53, (byte) 0xab, (byte) 0xf6, (byte) 0xe4, (byte) 0xba, + (byte) 0x6c, (byte) 0x89, (byte) 0xe8, (byte) 0x45, (byte) 0x9c, (byte) 0x47, (byte) 0xdc, (byte) 0x47, + (byte) 0x9c, (byte) 0xa9, (byte) 0x42, (byte) 0x3b, (byte) 0xe6, (byte) 0x92, (byte) 0x63, (byte) 0x91, + (byte) 0xc7, (byte) 0xfc, (byte) 0xf8, (byte) 0x6a, (byte) 0x18, (byte) 0xfd, (byte) 0x38, (byte) 0x2b, + (byte) 0xe0, (byte) 0x9c, (byte) 0x84, (byte) 0x1, (byte) 0x24, (byte) 0x8e, (byte) 0xa4, (byte) 0x55, + (byte) 0x7a, (byte) 0x66, (byte) 0x3b, (byte) 0x4a, (byte) 0x83, (byte) 0xb2, (byte) 0x31, (byte) 0x9a, + (byte) 0x94, (byte) 0x5c, (byte) 0xbf, (byte) 0x7, (byte) 0x56, (byte) 0x8d, (byte) 0x5c, (byte) 0x91, + (byte) 0x90, (byte) 0xe, (byte) 0xe1, (byte) 0x15, (byte) 0xb9, (byte) 0x91, (byte) 0xf, (byte) 0xe1, + (byte) 0x3d, (byte) 0xc2, (byte) 0xf0, (byte) 0xd8, (byte) 0x46, (byte) 0x92, (byte) 0xf6, (byte) 0x8, + (byte) 0x25, (byte) 0xa9, (byte) 0x2b, (byte) 0xf5, (byte) 0xa4, (byte) 0x2e, (byte) 0x62, (byte) 0x8, + (byte) 0x17, (byte) 0x4, (byte) 0xc, (byte) 0x4b, (byte) 0x18, (byte) 0xc1, (byte) 0x45, (byte) 0x52, + (byte) 0xa1, (byte) 0xb, (byte) 0x92, (byte) 0xd4, (byte) 0x32, (byte) 0xf9, (byte) 0xea, (byte) 0x11, + (byte) 0xc3, (byte) 0x4c, (byte) 0x97, (byte) 0xb8, (byte) 0xee, (byte) 0x17, (byte) 0x8e, (byte) 0xcb, + (byte) 0x9b, (byte) 0x1f, (byte) 0xef, (byte) 0x1a, (byte) 0x0, (byte) 0x4f, (byte) 0x70, (byte) 0x54, + (byte) 0xc2, (byte) 0x18, (byte) 0x17, (byte) 0x32, (byte) 0x58, (byte) 0xd3, (byte) 0xc, (byte) 0x9b, + (byte) 0xf4, (byte) 0x7b, (byte) 0xff, (byte) 0xc0, (byte) 0xa5, (byte) 0xb, (byte) 0x2f, (byte) 0x3f, + (byte) 0xb1, (byte) 0x8c, (byte) 0xd, (byte) 0xb9, (byte) 0xaa, (byte) 0x29, (byte) 0x22, (byte) 0x92, + (byte) 0x48, (byte) 0x49, (byte) 0x18, (byte) 0xc7, (byte) 0x4, (byte) 0x43, (byte) 0xaf, (byte) 0x5c, + (byte) 0xaf, (byte) 0x97, (byte) 0x9a, (byte) 0xa6, (byte) 0x69, (byte) 0x29, (byte) 0xb6, (byte) 0xad, + (byte) 0xd4, (byte) 0x19, (byte) 0x6, (byte) 0x3a, (byte) 0x63, (byte) 0x38, (byte) 0x44, (byte) 0xe4, + (byte) 0x79, (byte) 0x19, (byte) 0x33, (byte) 0x1d, (byte) 0x9, (byte) 0xcc, (byte) 0x2f, (byte) 0xdf, + (byte) 0x79, (byte) 0x5a, (byte) 0x53, (byte) 0x4c, (byte) 0x47, (byte) 0x35, (byte) 0x74, (byte) 0x1, + (byte) 0x93, (byte) 0xc, (byte) 0x83, (byte) 0x6d, (byte) 0xd0, (byte) 0x4a, (byte) 0x53, (byte) 0x77, + (byte) 0xd4, (byte) 0x86, (byte) 0x72, (byte) 0xb8, (byte) 0x2f, (byte) 0x22, (byte) 0x8b, (byte) 0xf, + (byte) 0xb8, (byte) 0xf2, (byte) 0x13, (byte) 0x2, (byte) 0x3e, (byte) 0x3a, (byte) 0xaa, (byte) 0xab, + (byte) 0x9b, (byte) 0x62, (byte) 0x4, (byte) 0xd3, (byte) 0xf8, (byte) 0x58, (byte) 0xc0, (byte) 0x15, + (byte) 0x9, (byte) 0x9f, (byte) 0xe0, (byte) 0x53, (byte) 0x86, (byte) 0xb8, (byte) 0xbb, (byte) 0xaf, + (byte) 0x93, (byte) 0x8f, (byte) 0x47, (byte) 0x24, (byte) 0x66, (byte) 0xae, (byte) 0x28, (byte) 0x3b, + (byte) 0x4f, (byte) 0x18, (byte) 0x7c, (byte) 0x6, (byte) 0xc9, (byte) 0x93, (byte) 0xff, (byte) 0x1f, + (byte) 0x79, (byte) 0xe, (byte) 0x2a, (byte) 0x59, (byte) 0x78, (byte) 0x97, (byte) 0x21, (byte) 0x1f, + (byte) 0xc1, (byte) 0x55, (byte) 0xe4, (byte) 0x5, (byte) 0xcc, (byte) 0x70, (byte) 0x27, (byte) 0x9f, + (byte) 0x53, (byte) 0xd6, (byte) 0xed, (byte) 0xae, (byte) 0x5a, (byte) 0x94, (byte) 0x4d, (byte) 0x86, + (byte) 0x58, (byte) 0x6a, (byte) 0x1f, (byte) 0x75, (byte) 0x60, (byte) 0x22, (byte) 0x39, (byte) 0xaf, + (byte) 0xe3, (byte) 0x86, (byte) 0x80, (byte) 0x9b, (byte) 0x12, (byte) 0x75, (byte) 0xfc, (byte) 0x2c, + (byte) 0x43, (byte) 0xe2, (byte) 0x28, (byte) 0x27, (byte) 0xaf, (byte) 0xb3, (byte) 0xd7, (byte) 0x15, + (byte) 0x36, (byte) 0x91, (byte) 0xe9, (byte) 0xca, (byte) 0x46, (byte) 0xdb, (byte) 0xc0, (byte) 0x70, + (byte) 0x3d, (byte) 0xd5, (byte) 0x2d, (byte) 0x82, (byte) 0x63, (byte) 0xfc, (byte) 0xc7, (byte) 0xa3, + (byte) 0x6c, (byte) 0x13, (byte) 0x50, (byte) 0x2b, (byte) 0xdd, (byte) 0x61, (byte) 0x88, (byte) 0x74, + (byte) 0x74, (byte) 0x11, (byte) 0x57, (byte) 0xe8, (byte) 0xb, (byte) 0x9, (byte) 0x5f, (byte) 0x62, + (byte) 0x9e, (byte) 0xee, (byte) 0x88, (byte) 0x63, (byte) 0xdc, (byte) 0xac, (byte) 0xda, (byte) 0x86, + (byte) 0xd6, (byte) 0x74, (byte) 0x14, (byte) 0x4f, (byte) 0x9a, (byte) 0xb3, (byte) 0xa9, (byte) 0x13, + (byte) 0x12, (byte) 0x9e, (byte) 0xc6, (byte) 0x57, (byte) 0x12, (byte) 0xa, (byte) 0x58, (byte) 0x64, + (byte) 0x8, (byte) 0x39, (byte) 0x86, (byte) 0xa7, (byte) 0xd, (byte) 0xc3, (byte) 0x99, (byte) 0x83, + (byte) 0xd3, (byte) 0x9d, (byte) 0x8a, (byte) 0x89, (byte) 0x58, (byte) 0xc6, (byte) 0xa8, (byte) 0x80, + (byte) 0x22, (byte) 0x55, (byte) 0xff, (byte) 0xa4, (byte) 0xa0, (byte) 0x42, (byte) 0x58, (byte) 0xa1, + (byte) 0x22, (byte) 0x27, (byte) 0x75, (byte) 0xfe, (byte) 0x3f, (byte) 0x46, (byte) 0x7f, (byte) 0xbc, + (byte) 0xc9, (byte) 0x97, (byte) 0x96, (byte) 0xcb, (byte) 0x1d, (byte) 0x8d, (byte) 0x9e, (byte) 0x46, + (byte) 0x59, (byte) 0xc2, (byte) 0x5d, (byte) 0xde, (byte) 0x7d, (byte) 0x51, (byte) 0xd3, (byte) 0x6b, + (byte) 0x4b, (byte) 0xb9, (byte) 0xf6, (byte) 0x43, (byte) 0xd9, (byte) 0x92, (byte) 0x6b, (byte) 0xa, + (byte) 0x5, (byte) 0xb0, (byte) 0x36, (byte) 0x5f, (byte) 0x7c, (byte) 0x30, (byte) 0x37, (byte) 0x5f, + (byte) 0xa0, (byte) 0xbc, (byte) 0xe2, (byte) 0xef, (byte) 0xba, (byte) 0x27, (byte) 0x5, (byte) 0x67, + (byte) 0xd, (byte) 0xdd, (byte) 0x76, (byte) 0x64, (byte) 0xdd, (byte) 0x59, (byte) 0x95, (byte) 0xb5, + (byte) 0x26, (byte) 0x9d, (byte) 0xf, (byte) 0xcc, (byte) 0x1a, (byte) 0x75, (byte) 0x1a, (byte) 0xa2, + (byte) 0x5, (byte) 0x55, (byte) 0x57, (byte) 0x96, (byte) 0x9a, (byte) 0x8d, (byte) 0xaa, (byte) 0x62, + (byte) 0x95, (byte) 0x79, (byte) 0x17, (byte) 0xd2, (byte) 0x46, (byte) 0x43, (byte) 0x56, (byte) 0x75, + (byte) 0x9e, (byte) 0x73, (byte) 0xb7, (byte) 0xba, (byte) 0xaf, (byte) 0x12, (byte) 0x91, (byte) 0xeb, + (byte) 0x95, (byte) 0xf4, (byte) 0xdd, (byte) 0x3f, (byte) 0x2f, (byte) 0x96, (byte) 0x8c, (byte) 0xa6, + (byte) 0x55, (byte) 0x73, (byte) 0x5f, (byte) 0x13, (byte) 0x4a, (byte) 0xae, (byte) 0xcb, (byte) 0x1b, + (byte) 0x34, (byte) 0xc9, (byte) 0x69, (byte) 0x70, (byte) 0x91, (byte) 0x1e, (byte) 0x21, (byte) 0x1f, + (byte) 0x3d, (byte) 0x6e, (byte) 0x54, (byte) 0x67, (byte) 0xac, (byte) 0xe2, (byte) 0x1e, (byte) 0x8d, + (byte) 0xdf, (byte) 0xd0, (byte) 0xca, (byte) 0x87, (byte) 0x28, (byte) 0xfc, (byte) 0x34, (byte) 0xa7, + (byte) 0x57, (byte) 0x8e, (byte) 0xbe, (byte) 0x15, (byte) 0xb2, (byte) 0xc, (byte) 0xd1, (byte) 0xc8, + (byte) 0x68, (byte) 0xc, (byte) 0x4e, (byte) 0x6c, (byte) 0x83, (byte) 0x6d, (byte) 0xb9, (byte) 0x80, + (byte) 0x35, (byte) 0xfa, (byte) 0xf6, (byte) 0xb8, (byte) 0xc6, (byte) 0x10, (byte) 0xc2, (byte) 0xb8, + (byte) 0x8f, (byte) 0x6f, (byte) 0xf7, (byte) 0x8f, (byte) 0x5e, (byte) 0x26, (byte) 0x38, (byte) 0xb7, + (byte) 0x46, (byte) 0x76, (byte) 0x21, (byte) 0x54, (byte) 0xb6, (byte) 0x11, (byte) 0x6e, (byte) 0x41, + (byte) 0x6c, (byte) 0x3, (byte) 0x44, (byte) 0xd7, (byte) 0x9b, (byte) 0x4, (byte) 0x7e, (byte) 0x67, + (byte) 0x7d, (byte) 0xfc, (byte) 0xed, (byte) 0xf3, (byte) 0x40, (byte) 0xec, (byte) 0xf, (byte) 0x9a, + (byte) 0x5, (byte) 0x69, (byte) 0xe7, (byte) 0xc5, (byte) 0x2e, (byte) 0x7a, (byte) 0x2b, (byte) 0xf1, + (byte) 0xe8, (byte) 0x36, (byte) 0x62, (byte) 0x85, (byte) 0x17, (byte) 0x38, (byte) 0x13, (byte) 0x1f, + (byte) 0xc, (byte) 0xbc, (byte) 0x82, (byte) 0xaf, (byte) 0xe2, (byte) 0x8f, (byte) 0x47, (byte) 0x4b, + (byte) 0x2d, (byte) 0x9c, (byte) 0xbf, (byte) 0x97, (byte) 0x6e, (byte) 0xe1, (byte) 0xd2, (byte) 0x26, + (byte) 0xfa, (byte) 0x16, (byte) 0xbd, (byte) 0x31, (byte) 0xbc, (byte) 0x94, (byte) 0xc9, (byte) 0xb6, + (byte) 0x70, (byte) 0x39, (byte) 0xf3, (byte) 0x7a, (byte) 0x13, (byte) 0xbd, (byte) 0x85, (byte) 0x5d, + (byte) 0x64, (byte) 0x2b, (byte) 0xe9, (byte) 0x6d, (byte) 0xe4, (byte) 0x5e, (byte) 0xc7, (byte) 0xa3, + (byte) 0xfe, (byte) 0x57, (byte) 0xf8, (byte) 0x70, (byte) 0x7, (byte) 0x53, (byte) 0x85, (byte) 0xf4, + (byte) 0xe, (byte) 0x3e, (byte) 0xdb, (byte) 0xc1, (byte) 0xb5, (byte) 0x45, (byte) 0xce, (byte) 0x73, + (byte) 0xdb, (byte) 0xe3, (byte) 0x49, (byte) 0xbf, (byte) 0xc4, (byte) 0x1c, (byte) 0xc3, (byte) 0x4b, + (byte) 0x2c, (byte) 0x30, (byte) 0xb8, (byte) 0x84, (byte) 0x99, (byte) 0x37, (byte) 0x18, (byte) 0xc9, + (byte) 0xb4, (byte) 0xb0, (byte) 0xb4, (byte) 0x89, (byte) 0xc4, (byte) 0x12, (byte) 0xcd, (byte) 0xe3, + (byte) 0xde, (byte) 0x3c, (byte) 0x72, (byte) 0x35, (byte) 0x90, (byte) 0x4d, (byte) 0x4, (byte) 0x88, + (byte) 0x3a, (byte) 0x4b, (byte) 0xd4, (byte) 0xa3, (byte) 0x2e, (byte) 0xfe, (byte) 0xeb, (byte) 0x13, + (byte) 0xf0, (byte) 0x2d, (byte) 0x94, (byte) 0xb6, (byte) 0x28, (byte) 0x72, (byte) 0x11, (byte) 0xe7, + (byte) 0x31, (byte) 0x4a, (byte) 0x4f, (byte) 0xcb, (byte) 0x18, (byte) 0x52, (byte) 0xd4, (byte) 0xd, + (byte) 0x49, (byte) 0xca, (byte) 0x63, (byte) 0xa, (byte) 0x57, (byte) 0x68, (byte) 0xb6, (byte) 0x82, + (byte) 0x6, (byte) 0x9e, (byte) 0xd2, (byte) 0xfa, (byte) 0x67, (byte) 0xfc, (byte) 0x82, (byte) 0x5f, + (byte) 0x69, (byte) 0x5c, (byte) 0xc0, (byte) 0x6f, (byte) 0xf8, (byte) 0x9d, (byte) 0xec, (byte) 0x3e, + (byte) 0x57, (byte) 0x8b, (byte) 0x39, (byte) 0xc4, (byte) 0xe8, (byte) 0x1b, (byte) 0x23, (byte) 0xf4, + (byte) 0x39, (byte) 0xc2, (byte) 0xf, (byte) 0x10, (byte) 0x43, (byte) 0x8c, (byte) 0x70, (byte) 0x83, + (byte) 0x84, (byte) 0x1c, (byte) 0xa0, (byte) 0xbb, (byte) 0x9a, (byte) 0xc0, (byte) 0xd, (byte) 0xb2, + (byte) 0x2e, (byte) 0x90, (byte) 0xf2, (byte) 0x2b, (byte) 0xb8, (byte) 0x40, (byte) 0x3c, (byte) 0xc3, + (byte) 0xc4, (byte) 0x34, (byte) 0x44, (byte) 0xf8, (byte) 0x4b, (byte) 0xc4, (byte) 0x30, (byte) 0x8c, + (byte) 0xe7, (byte) 0xf4, (byte) 0xac, (byte) 0xfe, (byte) 0x49, (byte) 0xd5, (byte) 0xdb, (byte) 0x22, + (byte) 0xd4, (byte) 0x77, (byte) 0xc4, (byte) 0xf2, (byte) 0x10, (byte) 0xd2, (byte) 0x1e, (byte) 0x4d, + (byte) 0x7d, (byte) 0x2, (byte) 0x4, (byte) 0x81, (byte) 0xa4, (byte) 0x65, (byte) 0x2, (byte) 0x92, + (byte) 0x7b, (byte) 0xfc, (byte) 0x47, (byte) 0xc6, (byte) 0x5b, (byte) 0xd3, (byte) 0xca, (byte) 0x35, + (byte) 0x5, (byte) 0xff, (byte) 0x1, (byte) 0xbb, (byte) 0x25, (byte) 0x20, (byte) 0x1d, (byte) 0xde, + (byte) 0x23, (byte) 0x7, (byte) 0xde, (byte) 0xde, (byte) 0xb4, (byte) 0x40, (byte) 0x57, (byte) 0xc0, + (byte) 0x3b, (byte) 0x1e, (byte) 0x41, (byte) 0xe0, (byte) 0xd0, (byte) 0x74, (byte) 0x80, (byte) 0x10, + (byte) 0xf6, (byte) 0x11, (byte) 0xc3, (byte) 0x54, (byte) 0xa7, (byte) 0xef, (byte) 0xdd, (byte) 0xce, + (byte) 0x78, (byte) 0xf0, (byte) 0x1f, (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, + (byte) 0x3, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x0, (byte) 0x0, (byte) 0xc0, + (byte) 0x69, (byte) 0x1, (byte) 0x57, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x9, + (byte) 0x0, (byte) 0x8, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0xed, (byte) 0x41, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x4d, (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, + (byte) 0x46, (byte) 0x2f, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xfe, (byte) 0xca, + (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, (byte) 0x3, + (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0xbd, (byte) 0x69, + (byte) 0x1, (byte) 0x57, (byte) 0x71, (byte) 0xa7, (byte) 0x16, (byte) 0x53, (byte) 0x5b, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x68, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x14, (byte) 0x0, + (byte) 0x4, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0xa4, (byte) 0x81, (byte) 0x3f, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x4d, (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, + (byte) 0x2f, (byte) 0x4d, (byte) 0x41, (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, + (byte) 0x54, (byte) 0x2e, (byte) 0x4d, (byte) 0x46, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, (byte) 0x3, (byte) 0x2d, (byte) 0x0, + (byte) 0x0, (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0x61, (byte) 0x69, (byte) 0x1, (byte) 0x57, + (byte) 0x16, (byte) 0x64, (byte) 0x9c, (byte) 0xc5, (byte) 0x0, (byte) 0x4, (byte) 0x0, (byte) 0x0, + (byte) 0xf, (byte) 0x7, (byte) 0x0, (byte) 0x0, (byte) 0x19, (byte) 0x0, (byte) 0x4, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0xa4, (byte) 0x81, (byte) 0xe0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x5a, (byte) 0x69, + (byte) 0x70, (byte) 0x46, (byte) 0x69, (byte) 0x6c, (byte) 0x65, (byte) 0x50, (byte) 0x72, (byte) 0x6f, + (byte) 0x70, (byte) 0x65, (byte) 0x72, (byte) 0x74, (byte) 0x79, (byte) 0x54, (byte) 0x65, (byte) 0x73, + (byte) 0x74, (byte) 0x2e, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x1, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x6, (byte) 0x6, (byte) 0x2c, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2d, + (byte) 0x0, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xd0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2b, (byte) 0x5, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x6, (byte) 0x7, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xfb, (byte) 0x5, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, + (byte) 0x4b, (byte) 0x5, (byte) 0x6, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, + (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0xd0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2b, + (byte) 0x5, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + }; + + /* + * Jar file created by Ant specifying zip64mode="always" and createUnicodeExtraFields="always" + * ----------------#1-------------------- + * [Central Directory Header] + * 0x51b: Signature : 0x02014b50 + * 0x51f: Created Zip Spec : 0x2d [4.5] + * 0x520: Created OS : 0x3 [UNIX] + * 0x521: VerMadeby : 0x32d [3, 4.5] + * 0x522: VerExtract : 0x2d [4.5] + * 0x523: Flag : 0x800 + * 0x525: Method : 0x8 [DEFLATED] + * 0x527: Last Mod Time : 0x570b3767 [Fri Aug 11 06:59:14 EDT 2023] + * 0x52b: CRC : 0x5e4fa53f + * 0x52f: Compressed Size : 0xffffffff + * 0x533: Uncompressed Size: 0xffffffff + * 0x537: Name Length : 0x10 + * 0x539: Extra Length : 0x35 + * Extra data:[01, 00, 18, 00, 87, 04, 00, 00, 00, 00, 00, 00, c7, 02, 00, 00, 00, 00, 00, 00, 15, 01, 00, 00, 00, 00, 00, 00, 75, 70, 15, 00, 01, 94, 82, 60, 61, 52, 65, 61, 64, 41, 6e, 74, 4a, 61, 72, 2e, 63, 6c, 61, 73, 73] + * [tag=0x0001, sz=24] + * ->ZIP64: size *0x487 csize *0x2c7 LOC Off *0x115 + * [data= 87 04 00 00 00 00 00 00 c7 02 00 00 00 00 00 00 15 01 00 00 00 00 00 00 ] + * [tag=0x7075, sz=21] + * ->[Unknown tag] + * [data= 01 94 82 60 61 52 65 61 64 41 6e 74 4a 61 72 2e 63 6c 61 73 73 ] + * 0x53b: Comment Length : 0x0 + * 0x53d: Disk Start : 0x0 + * 0x53f: Attrs : 0x0 + * 0x541: AttrsEx : 0x81a40000 + * 0x545: Loc Header Offset: 0xffffffff + * 0x549: File Name : ReadAntJar.class + */ + public static byte[] ANT_ZIP64_UNICODE_EXTRA_JAR = { + + (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, + (byte) 0x0, (byte) 0x0, (byte) 0x18, (byte) 0x7e, (byte) 0xe, (byte) 0x57, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0x9, (byte) 0x0, (byte) 0x2a, (byte) 0x0, (byte) 0x4d, (byte) 0x45, + (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, (byte) 0x1, + (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xfe, (byte) 0xca, (byte) 0x0, (byte) 0x0, (byte) 0x75, + (byte) 0x70, (byte) 0xe, (byte) 0x0, (byte) 0x1, (byte) 0x8, (byte) 0xa1, (byte) 0x8c, (byte) 0x13, + (byte) 0x4d, (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, + (byte) 0x2f, (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, + (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0x17, (byte) 0x7e, (byte) 0xe, (byte) 0x57, (byte) 0x31, + (byte) 0x59, (byte) 0x76, (byte) 0x4d, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x14, (byte) 0x0, (byte) 0x31, (byte) 0x0, (byte) 0x4d, + (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, + (byte) 0x4d, (byte) 0x41, (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, (byte) 0x54, + (byte) 0x2e, (byte) 0x4d, (byte) 0x46, (byte) 0x1, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x6e, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x61, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, + (byte) 0x70, (byte) 0x19, (byte) 0x0, (byte) 0x1, (byte) 0x85, (byte) 0x85, (byte) 0x84, (byte) 0x2, + (byte) 0x4d, (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, + (byte) 0x2f, (byte) 0x4d, (byte) 0x41, (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, + (byte) 0x54, (byte) 0x2e, (byte) 0x4d, (byte) 0x46, (byte) 0xf3, (byte) 0x4d, (byte) 0xcc, (byte) 0xcb, + (byte) 0x4c, (byte) 0x4b, (byte) 0x2d, (byte) 0x2e, (byte) 0xd1, (byte) 0xd, (byte) 0x4b, (byte) 0x2d, + (byte) 0x2a, (byte) 0xce, (byte) 0xcc, (byte) 0xcf, (byte) 0xb3, (byte) 0x52, (byte) 0x30, (byte) 0xd4, + (byte) 0x33, (byte) 0xe0, (byte) 0xe5, (byte) 0x72, (byte) 0xcc, (byte) 0x43, (byte) 0x12, (byte) 0x71, + (byte) 0x2c, (byte) 0x48, (byte) 0x4c, (byte) 0xce, (byte) 0x48, (byte) 0x55, (byte) 0x0, (byte) 0x8a, + (byte) 0x1, (byte) 0x25, (byte) 0xd, (byte) 0xd, (byte) 0xf4, (byte) 0xc, (byte) 0x4d, (byte) 0x12, + (byte) 0x73, (byte) 0xa, (byte) 0x32, (byte) 0x12, (byte) 0x79, (byte) 0xb9, (byte) 0x9c, (byte) 0x8b, + (byte) 0x52, (byte) 0x13, (byte) 0x4b, (byte) 0x52, (byte) 0x53, (byte) 0x74, (byte) 0x9d, (byte) 0x2a, + (byte) 0x81, (byte) 0xda, (byte) 0x2c, (byte) 0xf4, (byte) 0x80, (byte) 0x32, (byte) 0x7a, (byte) 0x86, + (byte) 0xda, (byte) 0x46, (byte) 0xba, (byte) 0x66, (byte) 0xa, (byte) 0x1a, (byte) 0xfe, (byte) 0x45, + (byte) 0x89, (byte) 0xc9, (byte) 0x39, (byte) 0xa9, (byte) 0xa, (byte) 0xce, (byte) 0xf9, (byte) 0x45, + (byte) 0x5, (byte) 0xf9, (byte) 0x45, (byte) 0x89, (byte) 0x25, (byte) 0x40, (byte) 0x63, (byte) 0x34, + (byte) 0x79, (byte) 0xb9, (byte) 0x78, (byte) 0xb9, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x3, + (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0x67, + (byte) 0x37, (byte) 0xb, (byte) 0x57, (byte) 0x3f, (byte) 0xa5, (byte) 0x4f, (byte) 0x5e, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x10, + (byte) 0x0, (byte) 0x2d, (byte) 0x0, (byte) 0x52, (byte) 0x65, (byte) 0x61, (byte) 0x64, (byte) 0x41, + (byte) 0x6e, (byte) 0x74, (byte) 0x4a, (byte) 0x61, (byte) 0x72, (byte) 0x2e, (byte) 0x63, (byte) 0x6c, + (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x1, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x87, + (byte) 0x4, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xc7, + (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, + (byte) 0x70, (byte) 0x15, (byte) 0x0, (byte) 0x1, (byte) 0x94, (byte) 0x82, (byte) 0x60, (byte) 0x61, + (byte) 0x52, (byte) 0x65, (byte) 0x61, (byte) 0x64, (byte) 0x41, (byte) 0x6e, (byte) 0x74, (byte) 0x4a, + (byte) 0x61, (byte) 0x72, (byte) 0x2e, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, + (byte) 0x75, (byte) 0x53, (byte) 0x5b, (byte) 0x57, (byte) 0x12, (byte) 0x51, (byte) 0x18, (byte) 0xdd, + (byte) 0x3, (byte) 0xc3, (byte) 0x1c, (byte) 0x18, (byte) 0x47, (byte) 0x41, (byte) 0xcc, (byte) 0xb, + (byte) 0x96, (byte) 0x89, (byte) 0x25, (byte) 0x89, (byte) 0x17, (byte) 0xa0, (byte) 0x8b, (byte) 0x76, + (byte) 0x41, (byte) 0x33, (byte) 0xab, (byte) 0x95, (byte) 0x99, (byte) 0x21, (byte) 0xb4, (byte) 0x84, + (byte) 0x65, (byte) 0x8b, (byte) 0x7a, (byte) 0x1a, (byte) 0x61, (byte) 0xb2, (byte) 0x51, (byte) 0x98, + (byte) 0x99, (byte) 0x35, (byte) 0xc, (byte) 0x76, (byte) 0x79, (byte) 0xea, (byte) 0xa1, (byte) 0x7e, + (byte) 0x8b, (byte) 0xcf, (byte) 0xf6, (byte) 0x80, (byte) 0x6b, (byte) 0xe5, (byte) 0x2a, (byte) 0xdf, + (byte) 0x7c, (byte) 0xe8, (byte) 0x47, (byte) 0x65, (byte) 0xdf, (byte) 0x19, (byte) 0x50, (byte) 0xb0, + (byte) 0x65, (byte) 0x33, (byte) 0x8b, (byte) 0xef, (byte) 0x70, (byte) 0xbe, (byte) 0xb3, (byte) 0xf7, + (byte) 0xfe, (byte) 0x6e, (byte) 0x73, (byte) 0x7e, (byte) 0xff, (byte) 0xf9, (byte) 0xf1, (byte) 0xb, + (byte) 0xc0, (byte) 0x2c, (byte) 0x1e, (byte) 0xc9, (byte) 0x90, (byte) 0x31, (byte) 0xc6, (byte) 0x70, + (byte) 0x4d, (byte) 0x86, (byte) 0x7, (byte) 0x63, (byte) 0xdc, (byte) 0x5c, (byte) 0xf7, (byte) 0x63, + (byte) 0x9c, (byte) 0x21, (byte) 0x26, (byte) 0x43, (byte) 0xc2, (byte) 0x8d, (byte) 0x0, (byte) 0x26, + (byte) 0x10, (byte) 0xf7, (byte) 0x63, (byte) 0x92, (byte) 0x61, (byte) 0x4a, (byte) 0xc6, (byte) 0x34, + (byte) 0x66, (byte) 0xb8, (byte) 0x33, (byte) 0xc1, (byte) 0x90, (byte) 0x94, (byte) 0xd1, (byte) 0x8d, + (byte) 0x14, (byte) 0xc3, (byte) 0x4d, (byte) 0x3f, (byte) 0x6e, (byte) 0xc9, (byte) 0x8, (byte) 0xe2, + (byte) 0xb6, (byte) 0x0, (byte) 0x69, (byte) 0x41, (byte) 0x37, (byte) 0x74, (byte) 0x67, (byte) 0x51, + (byte) 0x80, (byte) 0x37, (byte) 0x3e, (byte) 0xb9, (byte) 0x21, (byte) 0x40, (byte) 0x7c, (byte) 0x6a, + (byte) 0x96, (byte) 0x35, (byte) 0x1, (byte) 0xc1, (byte) 0x8c, (byte) 0x6e, (byte) 0x68, (byte) 0xd9, + (byte) 0x7a, (byte) 0x75, (byte) 0x53, (byte) 0xb3, (byte) 0xb, (byte) 0xea, (byte) 0x66, (byte) 0x85, + (byte) 0x3c, (byte) 0x62, (byte) 0x55, (byte) 0xd5, (byte) 0xd, (byte) 0x1, (byte) 0x3, (byte) 0xf1, + (byte) 0xb7, (byte) 0x99, (byte) 0x6d, (byte) 0x75, (byte) 0x57, (byte) 0x4d, (byte) 0x55, (byte) 0x54, + (byte) 0x63, (byte) 0x2b, (byte) 0x95, (byte) 0x77, (byte) 0x6c, (byte) 0xdd, (byte) 0xd8, (byte) 0x9a, + (byte) 0xe7, (byte) 0x44, (byte) 0xbf, (byte) 0xad, (byte) 0xa9, (byte) 0xe5, (byte) 0x55, (byte) 0xd5, + (byte) 0xae, (byte) 0x9, (byte) 0xe8, (byte) 0xce, (byte) 0x3b, (byte) 0x6a, (byte) 0x69, (byte) 0x67, + (byte) 0x4d, (byte) 0xb5, (byte) 0x5c, (byte) 0x2a, (byte) 0xa5, (byte) 0xc8, (byte) 0x70, (byte) 0x87, + (byte) 0x12, (byte) 0xa3, (byte) 0xf0, (byte) 0x14, (byte) 0x59, (byte) 0x80, (byte) 0x9c, (byte) 0x37, + (byte) 0xeb, (byte) 0x76, (byte) 0x49, (byte) 0x5b, (byte) 0xd6, (byte) 0xb9, (byte) 0x6c, (byte) 0x70, + (byte) 0x9d, (byte) 0x68, (byte) 0x8f, (byte) 0xd, (byte) 0x87, (byte) 0x98, (byte) 0x49, (byte) 0xae, + (byte) 0xab, (byte) 0x20, (byte) 0x8c, (byte) 0x3e, (byte) 0xc2, (byte) 0xb4, (byte) 0xdd, (byte) 0xa, + (byte) 0x86, (byte) 0xb8, (byte) 0xa7, (byte) 0x47, (byte) 0x35, (byte) 0x9c, (byte) 0x6d, (byte) 0xd5, + (byte) 0x76, (byte) 0xb4, (byte) 0x9a, (byte) 0x43, (byte) 0x40, (byte) 0x5b, (byte) 0x40, (byte) 0xbf, + (byte) 0x9b, (byte) 0x46, (byte) 0xdd, (byte) 0xd1, (byte) 0x2b, (byte) 0xa9, (byte) 0xcf, (byte) 0xba, + (byte) 0x95, (byte) 0x7a, (byte) 0xa3, (byte) 0x5b, (byte) 0x5c, (byte) 0x91, (byte) 0xf3, (byte) 0x67, + (byte) 0x19, (byte) 0xe6, (byte) 0x14, (byte) 0xdc, (byte) 0xc5, (byte) 0x3d, (byte) 0x1, (byte) 0x83, + (byte) 0xb1, (byte) 0x5a, (byte) 0xd4, (byte) 0xb4, (byte) 0x34, (byte) 0x43, (byte) 0x2b, (byte) 0x47, + (byte) 0x77, (byte) 0x75, (byte) 0x35, (byte) 0xda, (byte) 0x2, (byte) 0xc5, (byte) 0xa8, (byte) 0x90, + (byte) 0x50, (byte) 0xbb, (byte) 0x8a, (byte) 0xdc, (byte) 0xe6, (byte) 0xb6, (byte) 0x56, (byte) 0x72, + (byte) 0x18, (byte) 0xee, (byte) 0x2b, (byte) 0x78, (byte) 0x80, (byte) 0xb4, (byte) 0x82, (byte) 0x79, + (byte) 0x1e, (byte) 0xaf, (byte) 0xaf, (byte) 0x7d, (byte) 0x5e, (byte) 0x78, (byte) 0x6f, (byte) 0x9b, + (byte) 0x1f, (byte) 0x78, (byte) 0x29, (byte) 0xa, (byte) 0x16, (byte) 0xf0, (byte) 0xf0, (byte) 0xf4, + (byte) 0x48, (byte) 0x37, (byte) 0x53, (byte) 0x2f, (byte) 0x72, (byte) 0xcf, (byte) 0x3e, (byte) 0x96, + (byte) 0x34, (byte) 0xcb, (byte) 0xd1, (byte) 0x4d, (byte) 0x12, (byte) 0x1c, (byte) 0x8e, (byte) 0x19, + (byte) 0xfc, (byte) 0x1d, (byte) 0xa7, (byte) 0x27, (byte) 0x4a, (byte) 0x51, (byte) 0xb3, (byte) 0xb9, + (byte) 0x42, (byte) 0x2b, (byte) 0x72, (byte) 0xcc, (byte) 0x50, (byte) 0xb0, (byte) 0xc8, (byte) 0x25, + (byte) 0x43, (byte) 0xff, (byte) 0x36, (byte) 0x8e, (byte) 0x8a, (byte) 0x88, (byte) 0x5f, (byte) 0xdc, + (byte) 0xcd, (byte) 0x4e, (byte) 0xe8, (byte) 0xa7, (byte) 0x9a, (byte) 0xa3, (byte) 0x55, (byte) 0x69, + (byte) 0x3e, (byte) 0x66, (byte) 0xdd, (byte) 0x21, (byte) 0x42, (byte) 0xe6, (byte) 0x34, (byte) 0xf8, + (byte) 0x2b, (byte) 0x2, (byte) 0x3b, (byte) 0x44, (byte) 0xd1, (byte) 0xd4, (byte) 0xea, (byte) 0x7c, + (byte) 0x47, (byte) 0x4e, (byte) 0x1d, (byte) 0x6e, (byte) 0x1a, (byte) 0xae, (byte) 0xc5, (byte) 0x77, + (byte) 0xef, (byte) 0x4, (byte) 0x2c, (byte) 0x5c, (byte) 0x10, (byte) 0xa7, (byte) 0x73, (byte) 0x90, + (byte) 0xcd, (byte) 0x16, (byte) 0xcc, (byte) 0x4f, (byte) 0xfe, (byte) 0x47, (byte) 0xdd, (byte) 0x57, + (byte) 0xaa, (byte) 0x98, (byte) 0x35, (byte) 0x9a, (byte) 0x56, (byte) 0xb7, (byte) 0x5a, (byte) 0x2e, + (byte) 0xe7, (byte) 0xeb, (byte) 0x96, (byte) 0x65, (byte) 0x6b, (byte) 0xb5, (byte) 0x9a, (byte) 0x56, + (byte) 0x16, (byte) 0x30, (byte) 0xd4, (byte) 0x29, (byte) 0x7b, (byte) 0xd6, (byte) 0x26, (byte) 0xb7, + (byte) 0x82, (byte) 0xa0, (byte) 0xd5, (byte) 0x54, (byte) 0xa0, (byte) 0x2f, (byte) 0xa1, (byte) 0x60, + (byte) 0xab, (byte) 0x25, (byte) 0xd, (byte) 0x63, (byte) 0xf4, (byte) 0x89, (byte) 0xca, (byte) 0xe0, + (byte) 0x8f, (byte) 0x17, (byte) 0x2, (byte) 0x9f, (byte) 0x32, (byte) 0xd9, (byte) 0x4b, (byte) 0xb4, + (byte) 0x1b, (byte) 0xa1, (byte) 0x55, (byte) 0xa0, (byte) 0xd5, (byte) 0x37, (byte) 0x75, (byte) 0x0, + (byte) 0x61, (byte) 0x9f, (byte) 0xfe, (byte) 0x50, (byte) 0x91, (byte) 0x64, (byte) 0x25, (byte) 0xd7, + (byte) 0x29, (byte) 0x21, (byte) 0x80, (byte) 0x1, (byte) 0xc, (byte) 0xb6, (byte) 0xa0, (byte) 0x13, + (byte) 0x24, (byte) 0xc1, (byte) 0xbd, (byte) 0x5d, (byte) 0x87, (byte) 0xf0, (byte) 0x14, (byte) 0xf, + (byte) 0xe0, (byte) 0x6d, (byte) 0x40, (byte) 0x6c, (byte) 0x13, (byte) 0xf8, (byte) 0x15, (byte) 0x0, + (byte) 0xfc, (byte) 0xb4, (byte) 0x6, (byte) 0xc8, (byte) 0x33, (byte) 0x74, (byte) 0xaa, (byte) 0x2f, + (byte) 0xac, (byte) 0x92, (byte) 0x8, (byte) 0xa3, (byte) 0x93, (byte) 0x6f, (byte) 0x61, (byte) 0x5f, + (byte) 0xe6, (byte) 0x10, (byte) 0x52, (byte) 0x71, (byte) 0xfa, (byte) 0x0, (byte) 0x6c, (byte) 0x4d, + (byte) 0xc8, (byte) 0x7e, (byte) 0x87, (byte) 0x3f, (byte) 0x1c, (byte) 0x10, (byte) 0x7f, (byte) 0x42, + (byte) 0x2e, (byte) 0x7a, (byte) 0xa7, (byte) 0xf3, (byte) 0xd, (byte) 0x74, (byte) 0xbd, (byte) 0x9e, + (byte) 0x39, (byte) 0xc6, (byte) 0xcb, (byte) 0xc4, (byte) 0x31, (byte) 0xfa, (byte) 0x67, (byte) 0x1a, + (byte) 0x50, (byte) 0xf6, (byte) 0xb0, (byte) 0x94, (byte) 0x16, (byte) 0x13, (byte) 0x11, (byte) 0xb1, + (byte) 0x81, (byte) 0x9e, (byte) 0x3d, (byte) 0xcc, (byte) 0x35, (byte) 0x3d, (byte) 0xc9, (byte) 0xb4, + (byte) 0x18, (byte) 0x11, (byte) 0xb3, (byte) 0x11, (byte) 0xf1, (byte) 0x28, (byte) 0xed, (byte) 0x23, + (byte) 0xe8, (byte) 0x48, (byte) 0x1b, (byte) 0x1a, (byte) 0x4e, (byte) 0x4b, (byte) 0x89, (byte) 0x88, + (byte) 0xe4, (byte) 0x42, (byte) 0x19, (byte) 0xf7, (byte) 0x44, (byte) 0x7c, (byte) 0x47, (byte) 0x7b, + (byte) 0x88, (byte) 0xac, (byte) 0xf1, (byte) 0x0, (byte) 0xa1, (byte) 0x73, (byte) 0x1, (byte) 0x1a, + (byte) 0xe8, (byte) 0xdd, (byte) 0xa7, (byte) 0x64, (byte) 0x26, (byte) 0xe8, (byte) 0x42, (byte) 0x26, + (byte) 0xe9, (byte) 0x1e, (byte) 0xf6, (byte) 0x60, (byte) 0x14, (byte) 0x4b, (byte) 0xad, (byte) 0x75, + (byte) 0x85, (byte) 0x12, (byte) 0x5c, (byte) 0xc7, (byte) 0x6, (byte) 0x8a, (byte) 0xb4, (byte) 0x5f, + (byte) 0xc2, (byte) 0xaa, (byte) 0xbb, (byte) 0xf7, (byte) 0x62, (byte) 0x7, (byte) 0x6, (byte) 0x5d, + (byte) 0x52, (byte) 0x8f, (byte) 0x5b, (byte) 0x5e, (byte) 0x12, (byte) 0x5d, (byte) 0x64, (byte) 0x15, + (byte) 0xf2, (byte) 0x72, (byte) 0x6, (byte) 0xe7, (byte) 0x4, (byte) 0x5d, (byte) 0xf6, (byte) 0xa, + (byte) 0xad, (byte) 0x3b, (byte) 0xd4, (byte) 0x4e, (byte) 0x8e, (byte) 0x34, (byte) 0x11, (byte) 0xc2, + (byte) 0x17, (byte) 0xf4, (byte) 0xe2, (byte) 0x2b, (byte) 0x15, (byte) 0x1e, (byte) 0x21, (byte) 0x74, + (byte) 0xe, (byte) 0xf2, (byte) 0x9, (byte) 0x11, (byte) 0x45, (byte) 0x86, (byte) 0x61, (byte) 0x86, + (byte) 0xcb, (byte) 0xc, (byte) 0x57, (byte) 0x18, (byte) 0xef, (byte) 0x36, (byte) 0x19, (byte) 0x79, + (byte) 0x99, (byte) 0xcc, (byte) 0x73, (byte) 0xfa, (byte) 0x9d, (byte) 0x10, (byte) 0x43, (byte) 0x3a, + (byte) 0x77, (byte) 0x7c, (byte) 0x6, (byte) 0xf1, (byte) 0x9e, (byte) 0x50, (byte) 0x64, (byte) 0x4f, + (byte) 0xf3, (byte) 0xc, (byte) 0x78, (byte) 0xc2, (byte) 0x70, (byte) 0xb5, (byte) 0x9f, (byte) 0x3a, + (byte) 0x3a, (byte) 0x4a, (byte) 0xb2, (byte) 0x1e, (byte) 0x44, (byte) 0xff, (byte) 0x2, (byte) 0x50, + (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, (byte) 0x3, (byte) 0x2d, (byte) 0x0, (byte) 0x0, + (byte) 0x8, (byte) 0x0, (byte) 0x0, (byte) 0x18, (byte) 0x7e, (byte) 0xe, (byte) 0x57, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x9, (byte) 0x0, (byte) 0x32, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0xed, + (byte) 0x41, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x4d, (byte) 0x45, (byte) 0x54, + (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, (byte) 0x1, (byte) 0x0, + (byte) 0x18, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0xfe, (byte) 0xca, (byte) 0x0, (byte) 0x0, (byte) 0x75, (byte) 0x70, + (byte) 0xe, (byte) 0x0, (byte) 0x1, (byte) 0x8, (byte) 0xa1, (byte) 0x8c, (byte) 0x13, (byte) 0x4d, + (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, + (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, (byte) 0x3, (byte) 0x2d, (byte) 0x0, + (byte) 0x0, (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0x17, (byte) 0x7e, (byte) 0xe, (byte) 0x57, + (byte) 0x31, (byte) 0x59, (byte) 0x76, (byte) 0x4d, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x14, (byte) 0x0, (byte) 0x39, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0xa4, (byte) 0x81, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x4d, (byte) 0x45, + (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, (byte) 0x4d, + (byte) 0x41, (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, (byte) 0x54, (byte) 0x2e, + (byte) 0x4d, (byte) 0x46, (byte) 0x1, (byte) 0x0, (byte) 0x18, (byte) 0x0, (byte) 0x6e, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x61, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x51, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, (byte) 0x70, + (byte) 0x19, (byte) 0x0, (byte) 0x1, (byte) 0x85, (byte) 0x85, (byte) 0x84, (byte) 0x2, (byte) 0x4d, + (byte) 0x45, (byte) 0x54, (byte) 0x41, (byte) 0x2d, (byte) 0x49, (byte) 0x4e, (byte) 0x46, (byte) 0x2f, + (byte) 0x4d, (byte) 0x41, (byte) 0x4e, (byte) 0x49, (byte) 0x46, (byte) 0x45, (byte) 0x53, (byte) 0x54, + (byte) 0x2e, (byte) 0x4d, (byte) 0x46, (byte) 0x50, (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, + (byte) 0x3, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0x67, + (byte) 0x37, (byte) 0xb, (byte) 0x57, (byte) 0x3f, (byte) 0xa5, (byte) 0x4f, (byte) 0x5e, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x10, + (byte) 0x0, (byte) 0x35, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xa4, (byte) 0x81, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0x52, (byte) 0x65, (byte) 0x61, (byte) 0x64, (byte) 0x41, (byte) 0x6e, (byte) 0x74, + (byte) 0x4a, (byte) 0x61, (byte) 0x72, (byte) 0x2e, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x73, + (byte) 0x73, (byte) 0x1, (byte) 0x0, (byte) 0x18, (byte) 0x0, (byte) 0x87, (byte) 0x4, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xc7, (byte) 0x2, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x15, (byte) 0x1, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, (byte) 0x70, (byte) 0x15, + (byte) 0x0, (byte) 0x1, (byte) 0x94, (byte) 0x82, (byte) 0x60, (byte) 0x61, (byte) 0x52, (byte) 0x65, + (byte) 0x61, (byte) 0x64, (byte) 0x41, (byte) 0x6e, (byte) 0x74, (byte) 0x4a, (byte) 0x61, (byte) 0x72, + (byte) 0x2e, (byte) 0x63, (byte) 0x6c, (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x50, (byte) 0x4b, + (byte) 0x6, (byte) 0x6, (byte) 0x2c, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x2d, (byte) 0x0, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x57, (byte) 0x1, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x37, (byte) 0x4, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, + (byte) 0x6, (byte) 0x7, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x8e, (byte) 0x5, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x5, (byte) 0x6, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x3, (byte) 0x0, (byte) 0x57, (byte) 0x1, + (byte) 0x0, (byte) 0x0, (byte) 0x37, (byte) 0x4, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + }; + + /* + * ----------------#1-------------------- + * [Central Directory Header] + * 0x47: Signature : 0x02014b50 + * 0x4b: Created Zip Spec : 0x2d [4.5] + * 0x4c: Created OS : 0x3 [UNIX] + * 0x4d: VerMadeby : 0x32d [3, 4.5] + * 0x4e: VerExtract : 0x2d [4.5] + * 0x4f: Flag : 0x800 + * 0x51: Method : 0x8 [DEFLATED] + * 0x53: Last Mod Time : 0x570375bc [Thu Aug 03 14:45:56 EDT 2023] + * 0x57: CRC : 0x0 + * 0x5b: Compressed Size : 0x2 + * 0x5f: Uncompressed Size: 0x0 + * * 0x63: Name Length : 0x5 + * 0x65: Extra Length : 0x12 + * Extra data:[01, 00, 00, 00, 75, 70, 0a, 00, 01, ba, f7, eb, c1, 61, 2e, 74, 78, 74] + * [tag=0x0001, sz=0] + * ->ZIP64: + * [tag=0x7075, sz=10] + * ->[Unknown tag] + * [data= 01 ba f7 eb c1 61 2e 74 78 74 ] + * 0x67: Comment Length : 0x0 + * 0x69: Disk Start : 0x0 + * 0x6b: Attrs : 0x0 + * 0x6d: AttrsEx : 0x81a40000 + * 0x71: Loc Header Offset: 0x0 + * 0x75: File Name : a.txt + */ + public static byte[] ANT_ZIP64_UNICODE_EXTRA_ZIP= { + (byte) 0x50, (byte) 0x4b, (byte) 0x3, (byte) 0x4, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x8, + (byte) 0x8, (byte) 0x0, (byte) 0xbc, (byte) 0x75, (byte) 0x3, (byte) 0x57, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0x5, (byte) 0x0, (byte) 0x22, (byte) 0x0, (byte) 0x61, (byte) 0x2e, + (byte) 0x74, (byte) 0x78, (byte) 0x74, (byte) 0x1, (byte) 0x0, (byte) 0x10, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, + (byte) 0x70, (byte) 0xa, (byte) 0x0, (byte) 0x1, (byte) 0xba, (byte) 0xf7, (byte) 0xeb, (byte) 0xc1, + (byte) 0x61, (byte) 0x2e, (byte) 0x74, (byte) 0x78, (byte) 0x74, (byte) 0x3, (byte) 0x0, (byte) 0x50, + (byte) 0x4b, (byte) 0x1, (byte) 0x2, (byte) 0x2d, (byte) 0x3, (byte) 0x2d, (byte) 0x0, (byte) 0x0, + (byte) 0x8, (byte) 0x8, (byte) 0x0, (byte) 0xbc, (byte) 0x75, (byte) 0x3, (byte) 0x57, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x2, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x5, (byte) 0x0, (byte) 0x12, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0xa4, + (byte) 0x81, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x61, (byte) 0x2e, (byte) 0x74, + (byte) 0x78, (byte) 0x74, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x75, (byte) 0x70, + (byte) 0xa, (byte) 0x0, (byte) 0x1, (byte) 0xba, (byte) 0xf7, (byte) 0xeb, (byte) 0xc1, (byte) 0x61, + (byte) 0x2e, (byte) 0x74, (byte) 0x78, (byte) 0x74, (byte) 0x50, (byte) 0x4b, (byte) 0x6, (byte) 0x6, + (byte) 0x2c, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x2d, (byte) 0x0, (byte) 0x2d, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x45, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x47, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x50, (byte) 0x4b, (byte) 0x6, (byte) 0x7, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x8c, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x50, (byte) 0x4b, (byte) 0x5, (byte) 0x6, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x1, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x45, (byte) 0x0, (byte) 0x0, (byte) 0x0, + (byte) 0x47, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, + }; + + // Name of Zip file and Jar File used by the test + public static final Path VALID_APK = Path.of("working-apk.zip"); + public static final Path VALID_APACHE_COMPRESS_JAR = + Path.of("valid-apache-compress.jar"); + public static final Path VALID_ANT_JAR = + Path.of("valid-ant-zip64-unicode-extrafields.jar"); + public static final Path VALID_ANT_ZIP = + Path.of("valid-ant-zip64-unicode-extrafields.zip"); + /** + * Setup method used to create the Zip and Jar files used by the test + * @throws IOException if an error occurs + */ + public static void setup() throws IOException { + Files.deleteIfExists(VALID_APK); + Files.deleteIfExists(VALID_APACHE_COMPRESS_JAR); + Files.deleteIfExists(VALID_ANT_JAR); + Files.deleteIfExists(VALID_ANT_ZIP); + + // Create the Zip file to read + Files.write(VALID_APK, VALID_APK_FILE); + Files.write(VALID_APACHE_COMPRESS_JAR, COMMONS_COMPRESS_JAR); + Files.write(VALID_ANT_JAR, ANT_ZIP64_UNICODE_EXTRA_JAR); + Files.write(VALID_ANT_ZIP, ANT_ZIP64_UNICODE_EXTRA_ZIP); + + } + + /** + * Zip and Jars files to validate we can open + */ + private static Stream zipFilesToTest() { + return Stream.of(VALID_APK, VALID_APACHE_COMPRESS_JAR, VALID_ANT_JAR, VALID_ANT_ZIP); + } + + /** + * Validate that a Zip file which contains an extra header with a data size + * 0f 0 can be opened using ZipFile + * @throws IOException if an error occurs + */ + public void zipFilesToTest(Path jar) throws IOException { + try (ZipFile zf = new ZipFile(jar.toFile())) { + System.out.printf("%s opened%n", jar.toAbsolutePath()); + } catch (IOException ie) { + System.out.printf("%n%n%n$$$$ %s NOT opened%n", jar.toAbsolutePath()); + throw ie; + } + } + + /** + * Validate that a Zip file which contains an extra header with a data size + * 0f 0 can be opened using ZipFS + * @throws IOException if an error occurs + */ + public void readZipFSTest(Path jar) throws IOException { + try (FileSystem fs = FileSystems.newFileSystem(jar, Map.of())) { + System.out.printf("%s opened%n", jar.toAbsolutePath()); + } catch (IOException ie) { + System.out.printf("%n%n%n$$$$ %s NOT opened%n", jar.toAbsolutePath()); + throw ie; + } + } + /** + * Utility method which takes a byte array and converts to byte array + * declaration. For example: + *
+     *     {@code
+     *        var fooJar = Files.readAllBytes(Path.of("foo.jar"));
+     *        var result = createByteArray(fooJar, "FOOBYTES");
+     *        System.out.println(result);
+     *      }
+     * 
+ * + * @param bytes A byte array used to create a byte array declaration + * @param name Name to be used in the byte array declaration + * @return The formatted byte array declaration + */ + public static String createByteArray(byte[] bytes, String name) { + StringBuilder sb = new StringBuilder(bytes.length * 5); + Formatter fmt = new Formatter(sb); + fmt.format(" public static byte[] %s = {", name); + final int linelen = 8; + for (int i = 0; i < bytes.length; i++) { + if (i % linelen == 0) { + fmt.format("%n "); + } + fmt.format(" (byte) 0x%x,", bytes[i] & 0xff); + } + fmt.format("%n };%n"); + return sb.toString(); + } + + public static void main(String[] args) throws Exception { + setup(); + var test = new ReadNonStandardExtraHeadersTest(); + zipFilesToTest().forEach(path -> { + try { + test.zipFilesToTest(path); + test.readZipFSTest(path); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + } +} + From 3f8e9953f200985958a93d4bf30c2f213c02efce Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 23 Aug 2023 06:28:38 +0000 Subject: [PATCH 044/341] 8314658: [17u] GHA: Sync up debian-version for cross-builds Reviewed-by: phh --- .github/workflows/build-cross-compile.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index edbbac42226ef..667cc842ef136 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -66,23 +66,23 @@ jobs: gnu-arch: aarch64 debian-arch: arm64 debian-repository: https://httpredir.debian.org/debian/ - debian-version: buster + debian-version: bullseye - target-cpu: arm gnu-arch: arm debian-arch: armhf debian-repository: https://httpredir.debian.org/debian/ - debian-version: buster + debian-version: bullseye gnu-abi: eabihf - target-cpu: s390x gnu-arch: s390x debian-arch: s390x debian-repository: https://httpredir.debian.org/debian/ - debian-version: buster + debian-version: bullseye - target-cpu: ppc64le gnu-arch: powerpc64le debian-arch: ppc64el debian-repository: https://httpredir.debian.org/debian/ - debian-version: buster + debian-version: bullseye - target-cpu: riscv64 gnu-arch: riscv64 debian-arch: riscv64 From d35a896350979d402af70c625a3b550178c10019 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 23 Aug 2023 06:30:50 +0000 Subject: [PATCH 045/341] 8293851: hs_err should print more stack in hex dump Backport-of: cbd0688b321ff88a405be4f7929d6862e543ab50 --- src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp | 5 ++--- src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp | 5 ++--- src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp | 5 ++--- src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp | 5 ++--- src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp | 5 ++--- src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp | 5 ++--- src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp | 5 ++--- src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp | 5 ++--- src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp | 5 ++--- src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp | 5 ++--- src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp | 5 ++--- src/hotspot/share/runtime/os.cpp | 5 +++++ src/hotspot/share/runtime/os.hpp | 3 ++- 13 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp index ccfa78f1996b0..241e3b5e64ae8 100644 --- a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp +++ b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp @@ -454,9 +454,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const ucontext_t* uc = (const ucontext_t*)context; - intptr_t *sp = (intptr_t *)os::Aix::ucontext_get_sp(uc); - st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); - print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t)); + address sp = (address)os::Aix::ucontext_get_sp(uc); + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp b/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp index 6f8672c7223eb..d5f412d399647 100644 --- a/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp +++ b/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp @@ -472,9 +472,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const ucontext_t* uc = (const ucontext_t*)context; - intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc); - st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp); - print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t)); + address sp = (address)os::Bsd::ucontext_get_sp(uc); + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp index 6ef7690f3bbce..d6f3156618eba 100644 --- a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp +++ b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp @@ -852,9 +852,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const ucontext_t* uc = (const ucontext_t*)context; - intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc); - st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp); - print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t)); + address sp = (address)os::Bsd::ucontext_get_sp(uc); + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp index e79c194cf8c1e..9d2ac34b45dac 100644 --- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp +++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp @@ -346,9 +346,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const ucontext_t* uc = (const ucontext_t*)context; - intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); - st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); - print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t)); + address sp = (address)os::Linux::ucontext_get_sp(uc); + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp index faee1803626b4..8dbe8658faf28 100644 --- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp +++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp @@ -453,9 +453,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const ucontext_t* uc = (const ucontext_t*)context; - intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); - st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", p2i(sp)); - print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t)); + address sp = (address)os::Linux::ucontext_get_sp(uc); + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp index 468224b61dc4f..a8c09851932e0 100644 --- a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp +++ b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp @@ -467,9 +467,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const ucontext_t* uc = (const ucontext_t*)context; - intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); - st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); - print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t)); + address sp = (address)os::Linux::ucontext_get_sp(uc); + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp index 804b0c391548c..681e03922bd57 100644 --- a/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp @@ -358,9 +358,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const ucontext_t* uc = (const ucontext_t*)context; - intptr_t *frame_sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); - st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(frame_sp)); - print_hex_dump(st, (address)frame_sp, (address)(frame_sp + 64), sizeof(intptr_t)); + address sp = (address)os::Linux::ucontext_get_sp(uc); + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp index 02d104d921a92..850f8d3d843b8 100644 --- a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp +++ b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp @@ -440,9 +440,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const ucontext_t* uc = (const ucontext_t*)context; - intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); - st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); - print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t)); + address sp = (address)os::Linux::ucontext_get_sp(uc); + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp index e1aec8a4f18b7..00e4f405617bf 100644 --- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp +++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp @@ -584,9 +584,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const ucontext_t* uc = (const ucontext_t*)context; - intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); - st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); - print_hex_dump(st, (address)sp, (address)(sp + 8), sizeof(intptr_t)); + address sp = (address)os::Linux::ucontext_get_sp(uc); + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp b/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp index 24fa22fda21b7..3fa960b4950f1 100644 --- a/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp +++ b/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp @@ -211,9 +211,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const CONTEXT* uc = (const CONTEXT*)context; - intptr_t *sp = (intptr_t *)uc->Sp; - st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); - print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t)); + address sp = (address)uc->Sp; + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp index 3566d8f5c7fa3..016e538a9da38 100644 --- a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp +++ b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp @@ -455,9 +455,8 @@ void os::print_tos_pc(outputStream *st, const void *context) { const CONTEXT* uc = (const CONTEXT*)context; - intptr_t *sp = (intptr_t *)uc->REG_SP; - st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); - print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t)); + address sp = (address)uc->REG_SP; + print_tos(st, sp); st->cr(); // Note: it may be unsafe to inspect memory near pc. For example, pc may diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index 045ed007ab1a1..369e5c4f5fabd 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -963,6 +963,11 @@ void os::print_dhm(outputStream* st, const char* startStr, long sec) { st->print_cr("%s %ld days %ld:%02ld hours", startStr, days, hours, minutes); } +void os::print_tos(outputStream* st, address sp) { + st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); + print_hex_dump(st, sp, sp + 512, sizeof(intptr_t)); +} + void os::print_instructions(outputStream* st, address pc, int unitsize) { st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc)); print_hex_dump(st, pc - 256, pc + 256, unitsize); diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index 25df0eb372e47..b378a4ee81058 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -694,12 +694,13 @@ class os: AllStatic { static void print_environment_variables(outputStream* st, const char** env_list); static void print_context(outputStream* st, const void* context); static void print_tos_pc(outputStream* st, const void* context); + static void print_tos(outputStream* st, address sp); + static void print_instructions(outputStream* st, address pc, int unitsize); static void print_register_info(outputStream* st, const void* context); static bool signal_sent_by_kill(const void* siginfo); static void print_siginfo(outputStream* st, const void* siginfo); static void print_signal_handlers(outputStream* st, char* buf, size_t buflen); static void print_date_and_time(outputStream* st, char* buf, size_t buflen); - static void print_instructions(outputStream* st, address pc, int unitsize); // helper for output of seconds in days , hours and months static void print_dhm(outputStream* st, const char* startStr, long sec); From 49ffbcf4bcfa74973b651980d97514ee942a82fe Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 23 Aug 2023 06:31:17 +0000 Subject: [PATCH 046/341] 8314501: Shenandoah: sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java fails Backport-of: 812f475bc4ea84225e8bbb0b5a677eed0af864dd --- .../share/classes/sun/jvm/hotspot/tools/HeapSummary.java | 7 +++---- .../jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java index eb1b8423add1d..6c87a2fbfe441 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java @@ -85,10 +85,8 @@ public void run() { printValMB("MetaspaceSize = ", getFlagValue("MetaspaceSize", flagMap)); printValMB("CompressedClassSpaceSize = ", getFlagValue("CompressedClassSpaceSize", flagMap)); printValMB("MaxMetaspaceSize = ", getFlagValue("MaxMetaspaceSize", flagMap)); - if (heap instanceof ShenandoahHeap) { - printValMB("ShenandoahRegionSize = ", ShenandoahHeapRegion.regionSizeBytes()); - } else { - printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes()); + if (heap instanceof G1CollectedHeap) { + printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes()); } System.out.println(); @@ -137,6 +135,7 @@ public void run() { long num_regions = sh.numOfRegions(); System.out.println("Shenandoah Heap:"); System.out.println(" regions = " + num_regions); + printValMB("region size = ", ShenandoahHeapRegion.regionSizeBytes()); printValMB("capacity = ", num_regions * ShenandoahHeapRegion.regionSizeBytes()); printValMB("used = ", sh.used()); printValMB("committed = ", sh.committed()); diff --git a/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java b/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java index 71d112157b214..119ab55afca7b 100644 --- a/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java +++ b/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java @@ -57,8 +57,7 @@ public class JMapHeapConfigTest { "NewRatio", "SurvivorRatio", "MetaspaceSize", - "CompressedClassSpaceSize", - "G1HeapRegionSize"}; + "CompressedClassSpaceSize"}; // Test can't deal with negative jlongs: // ignoring MaxMetaspaceSize From e83046409d81d074cd68dc823e794a852ed93cee Mon Sep 17 00:00:00 2001 From: Dan Lutker Date: Wed, 23 Aug 2023 18:42:34 +0000 Subject: [PATCH 047/341] 8314552: Fix javadoc tests to work with jtreg 7 Reviewed-by: phh, shade, andrew --- .../doclet/testSerialVersionUID/TestSerialVersionUID.java | 5 +++-- .../jdk/javadoc/doclet/testTagMisuse/TestTagMisuse.java | 5 +++-- .../jdk/javadoc/doclet/testThrows/TestThrows.java | 4 ++-- .../jdk/javadoc/doclet/testThrowsHead/TestThrowsHead.java | 5 +++-- .../doclet/testUnnamedPackage/TestUnnamedPackage.java | 8 +++++--- test/langtools/jdk/javadoc/tool/nonConstExprs/Test.java | 3 ++- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/test/langtools/jdk/javadoc/doclet/testSerialVersionUID/TestSerialVersionUID.java b/test/langtools/jdk/javadoc/doclet/testSerialVersionUID/TestSerialVersionUID.java index 541c6957a9b14..ca64de682e442 100644 --- a/test/langtools/jdk/javadoc/doclet/testSerialVersionUID/TestSerialVersionUID.java +++ b/test/langtools/jdk/javadoc/doclet/testSerialVersionUID/TestSerialVersionUID.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,8 @@ public static void main(String... args) throws Exception { @Test public void test() { - javadoc("-d", "out", + javadoc("-encoding", "UTF-8", + "-d", "out", testSrc("C.java")); checkExit(Exit.OK); diff --git a/test/langtools/jdk/javadoc/doclet/testTagMisuse/TestTagMisuse.java b/test/langtools/jdk/javadoc/doclet/testTagMisuse/TestTagMisuse.java index 8278abe90586d..1fea8a69edb08 100644 --- a/test/langtools/jdk/javadoc/doclet/testTagMisuse/TestTagMisuse.java +++ b/test/langtools/jdk/javadoc/doclet/testTagMisuse/TestTagMisuse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,8 @@ public static void main(String... args) throws Exception { @Test public void test() { - javadoc("-Xdoclint:none", + javadoc("-encoding", "UTF-8", + "-Xdoclint:none", "-d", "out", testSrc("TestTagMisuse.java")); checkExit(Exit.OK); diff --git a/test/langtools/jdk/javadoc/doclet/testThrows/TestThrows.java b/test/langtools/jdk/javadoc/doclet/testThrows/TestThrows.java index 57e88d60c9ecf..3f6a777a2a8f5 100644 --- a/test/langtools/jdk/javadoc/doclet/testThrows/TestThrows.java +++ b/test/langtools/jdk/javadoc/doclet/testThrows/TestThrows.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2020, 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 @@ -67,7 +67,7 @@ public interface C { } """); - javadoc("-d", base.resolve("out").toString(), + javadoc("-encoding", "UTF-8", "-d", base.resolve("out").toString(), "--no-platform-links", src.resolve("C.java").toString()); checkExit(Exit.OK); diff --git a/test/langtools/jdk/javadoc/doclet/testThrowsHead/TestThrowsHead.java b/test/langtools/jdk/javadoc/doclet/testThrowsHead/TestThrowsHead.java index 378f297bd53e8..a6b4b009c387c 100644 --- a/test/langtools/jdk/javadoc/doclet/testThrowsHead/TestThrowsHead.java +++ b/test/langtools/jdk/javadoc/doclet/testThrowsHead/TestThrowsHead.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2020, 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 @@ -44,7 +44,8 @@ public static void main(String... args) throws Exception { @Test public void test() { - javadoc("-d", "out", + javadoc("-encoding", "UTF-8", + "-d", "out", testSrc("C.java")); checkExit(Exit.OK); diff --git a/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java b/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java index a88260f3d56e7..05d2359990b8a 100644 --- a/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java +++ b/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.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 @@ -43,7 +43,8 @@ public static void main(String... args) throws Exception { @Test public void test() { - javadoc("-d", "out", + javadoc("-encoding", "UTF-8", + "-d", "out", "-sourcepath", testSrc("src1"), testSrc("src1/C.java")); checkExit(Exit.OK); @@ -130,7 +131,8 @@ public void test() { @Test public void testUse() { - javadoc("-d", "out-use", + javadoc("-encoding", "UTF-8", + "-d", "out-use", "-use", testSrc("src2/A.java"), testSrc("src2/B.java")); diff --git a/test/langtools/jdk/javadoc/tool/nonConstExprs/Test.java b/test/langtools/jdk/javadoc/tool/nonConstExprs/Test.java index 889945b236d08..f03c928849a31 100644 --- a/test/langtools/jdk/javadoc/tool/nonConstExprs/Test.java +++ b/test/langtools/jdk/javadoc/tool/nonConstExprs/Test.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 @@ -34,6 +34,7 @@ public class Test { public static void main(String... args) throws Exception { File testSrc = new File(System.getProperty("test.src")); String[] jdoc_args = { + "-encoding", "UTF-8", "-d", "out", new File(testSrc, Test.class.getSimpleName() + ".java").getPath() }; From 40add10f8ba99ee3da50e07c30340a8e15a7b86c Mon Sep 17 00:00:00 2001 From: Andrey Turbanov Date: Thu, 24 Aug 2023 17:00:08 +0000 Subject: [PATCH 048/341] 8299827: Add resolved IP address in connection exception for sockets Backport-of: 92d8326e4037605897d7c4eb4b3edb63a2fc11b0 --- .../classes/sun/net/util/SocketExceptions.java | 13 ++----------- test/jdk/java/net/Socket/ExceptionText.java | 10 ++++++---- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/java.base/share/classes/sun/net/util/SocketExceptions.java b/src/java.base/share/classes/sun/net/util/SocketExceptions.java index a47811fe80cdf..ee70c58b9ba0a 100644 --- a/src/java.base/share/classes/sun/net/util/SocketExceptions.java +++ b/src/java.base/share/classes/sun/net/util/SocketExceptions.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 @@ -67,16 +67,7 @@ public static IOException of(IOException e, SocketAddress addr) { } private static IOException ofInet(IOException e, InetSocketAddress addr) { - int port = addr.getPort(); - String host = addr.getHostString(); - StringBuilder sb = new StringBuilder(); - sb.append(e.getMessage()); - sb.append(": "); - sb.append(host); - sb.append(':'); - sb.append(Integer.toString(port)); - String enhancedMsg = sb.toString(); - return create(e, enhancedMsg); + return create(e, String.join(": ", e.getMessage(), addr.toString())); } private static IOException ofUnixDomain(IOException e, UnixDomainSocketAddress addr) { diff --git a/test/jdk/java/net/Socket/ExceptionText.java b/test/jdk/java/net/Socket/ExceptionText.java index c731b49e66528..7f565e9777c18 100644 --- a/test/jdk/java/net/Socket/ExceptionText.java +++ b/test/jdk/java/net/Socket/ExceptionText.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, 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,6 +57,7 @@ */ import java.io.IOException; +import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.nio.channels.AsynchronousSocketChannel; @@ -83,6 +84,7 @@ public static void main(String args[]) throws Exception { static final InetSocketAddress dest = Utils.refusingEndpoint(); static final String PORT = ":" + Integer.toString(dest.getPort()); static final String HOST = dest.getHostString(); + static final InetAddress ADDRESS = dest.getAddress(); static void test(boolean withProperty) { // Socket @@ -104,11 +106,11 @@ static void checkResult(IOException e, boolean withProperty) { throw new RuntimeException("Test failed: exception contains address info"); } } else { - if (!msg.contains(HOST) || !msg.contains(PORT)) { + if (!msg.contains(HOST) || !msg.contains(PORT) || + !msg.contains(ADDRESS.getHostAddress())) { if (e instanceof ClosedChannelException) return; // has no detail msg - System.err.println("msg = " + msg); - throw new RuntimeException("Test failed: exception does not contain address info"); + throw new RuntimeException("Test failed: message '" + msg + "' is missing address info " + dest); } } } From e070c31515c4ca3348757ca56fa8adf57e8cf5a2 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 25 Aug 2023 06:22:52 +0000 Subject: [PATCH 049/341] 8283724: Incorrect description for jtreg-failure-handler option Backport-of: 0901548833a0125f15fede64bc2e7dbe84fed42d --- make/autoconf/jdk-options.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index dea69dc71453d..db526547d865c 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -508,7 +508,7 @@ AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER], [ UTIL_ARG_ENABLE(NAME: jtreg-failure-handler, DEFAULT: auto, RESULT: BUILD_FAILURE_HANDLER, - DESC: [enable keeping of packaged modules in jdk image], + DESC: [enable building of the jtreg failure handler], DEFAULT_DESC: [enabled if jtreg is present], CHECKING_MSG: [if the jtreg failure handler should be built], CHECK_AVAILABLE: [ From e84d9ddf5ae065f87e1c2bb220deb0ffddc20221 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 25 Aug 2023 06:33:32 +0000 Subject: [PATCH 050/341] 8313701: GHA: RISC-V should use the official repository for bootstrap Reviewed-by: phh Backport-of: 538f9557b87f750264231f04bfbc91d15f8af8c0 --- .github/workflows/build-cross-compile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 667cc842ef136..1543b36fcd945 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -86,7 +86,7 @@ jobs: - target-cpu: riscv64 gnu-arch: riscv64 debian-arch: riscv64 - debian-repository: https://deb.debian.org/debian-ports + debian-repository: https://httpredir.debian.org/debian/ debian-version: sid steps: From d9985d033fcbec5afef20b3e7d8fdd97ad355123 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 25 Aug 2023 06:37:21 +0000 Subject: [PATCH 051/341] 8314730: GHA: Drop libfreetype6-dev transitional package in favor of libfreetype-dev Reviewed-by: stuefe Backport-of: 69d900d2ce97e5479020cff9a63c471d07e39989 --- .github/workflows/build-cross-compile.yml | 2 +- .github/workflows/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 1543b36fcd945..697f2d7ea672c 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -136,7 +136,7 @@ jobs: sudo debootstrap --arch=${{ matrix.debian-arch }} --verbose - --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev + --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype-dev,libpng-dev --resolve-deps --variant=minbase ${{ matrix.debian-version }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 421d3bfb056f6..05ceaa441feec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -146,7 +146,7 @@ jobs: apt-architecture: 'i386' # Some multilib libraries do not have proper inter-dependencies, so we have to # install their dependencies manually. - apt-extra-packages: 'libfreetype6-dev:i386 libtiff-dev:i386 libcupsimage2-dev:i386' + apt-extra-packages: 'libfreetype-dev:i386 libtiff-dev:i386 libcupsimage2-dev:i386' extra-conf-options: '--with-target-bits=32' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} From 142154084d318e423e7476abd45ace19316e90fe Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 25 Aug 2023 06:57:40 +0000 Subject: [PATCH 052/341] 8276651: java/lang/ProcessHandle tests fail with "RuntimeException: Input/output error" in java.lang.ProcessHandleImpl$Info.info0 Backport-of: d24b7b7026cf85f1aecf44f60819762872cfd5c1 --- .../macosx/native/libjava/ProcessHandleImpl_macosx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c b/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c index bc64cd1ae621e..30fa8eea2069a 100644 --- a/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c +++ b/src/java.base/macosx/native/libjava/ProcessHandleImpl_macosx.c @@ -272,7 +272,8 @@ void os_getCmdlineAndUserInfo(JNIEnv *env, jobject jinfo, pid_t pid) { mib[2] = pid; size = (size_t) maxargs; if (sysctl(mib, 3, args, &size, NULL, 0) == -1) { - if (errno != EINVAL) { + if (errno != EINVAL && errno != EIO) { + // If the pid is invalid, the information returned is empty and no exception JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", "sysctl failed"); } @@ -300,4 +301,3 @@ void os_getCmdlineAndUserInfo(JNIEnv *env, jobject jinfo, pid_t pid) { // Free the arg buffer free(args); } - From f667b356714fc55cd9f9ae3488d42193984a0eda Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 25 Aug 2023 13:19:44 +0000 Subject: [PATCH 053/341] 8293114: JVM should trim the native heap Reviewed-by: stuefe Backport-of: 9e4fc568a6f1a93c84a84d6cc5220c6eb4e546a5 --- src/hotspot/os/aix/os_aix.inline.hpp | 2 +- src/hotspot/os/bsd/os_bsd.inline.hpp | 2 +- src/hotspot/os/windows/os_windows.inline.hpp | 2 +- src/hotspot/share/classfile/stringTable.cpp | 2 + src/hotspot/share/classfile/symbolTable.cpp | 2 + src/hotspot/share/logging/logTag.hpp | 1 + src/hotspot/share/memory/arena.cpp | 2 + src/hotspot/share/prims/whitebox.cpp | 9 + src/hotspot/share/runtime/globals.hpp | 7 + src/hotspot/share/runtime/java.cpp | 3 + src/hotspot/share/runtime/synchronizer.cpp | 3 + src/hotspot/share/runtime/thread.cpp | 5 + src/hotspot/share/runtime/trimNativeHeap.cpp | 275 ++++++++++++++++ src/hotspot/share/runtime/trimNativeHeap.hpp | 69 ++++ src/hotspot/share/utilities/vmError.cpp | 17 +- .../gtest/runtime/test_trim_native.cpp | 101 ++++++ .../jtreg/gtest/NativeHeapTrimmerGtest.java | 32 ++ .../jtreg/runtime/os/TestTrimNative.java | 309 ++++++++++++++++++ .../dcmd/vm/TrimLibcHeapTest.java | 9 +- test/lib/jdk/test/whitebox/WhiteBox.java | 2 + 20 files changed, 847 insertions(+), 7 deletions(-) create mode 100644 src/hotspot/share/runtime/trimNativeHeap.cpp create mode 100644 src/hotspot/share/runtime/trimNativeHeap.hpp create mode 100644 test/hotspot/gtest/runtime/test_trim_native.cpp create mode 100644 test/hotspot/jtreg/gtest/NativeHeapTrimmerGtest.java create mode 100644 test/hotspot/jtreg/runtime/os/TestTrimNative.java diff --git a/src/hotspot/os/aix/os_aix.inline.hpp b/src/hotspot/os/aix/os_aix.inline.hpp index 88a39b4b3700c..489ae5a7e6eb4 100644 --- a/src/hotspot/os/aix/os_aix.inline.hpp +++ b/src/hotspot/os/aix/os_aix.inline.hpp @@ -47,7 +47,7 @@ inline bool os::must_commit_stack_guard_pages() { inline void os::map_stack_shadow_pages(address sp) { } -// stubbed-out trim-native support +// Trim-native support, stubbed out for now, may be enabled later inline bool os::can_trim_native_heap() { return false; } inline bool os::trim_native_heap(os::size_change_t* rss_change) { return false; } diff --git a/src/hotspot/os/bsd/os_bsd.inline.hpp b/src/hotspot/os/bsd/os_bsd.inline.hpp index 9fc70da1583a8..f59f48e889f76 100644 --- a/src/hotspot/os/bsd/os_bsd.inline.hpp +++ b/src/hotspot/os/bsd/os_bsd.inline.hpp @@ -51,7 +51,7 @@ inline bool os::must_commit_stack_guard_pages() { inline void os::map_stack_shadow_pages(address sp) { } -// stubbed-out trim-native support +// Trim-native support, stubbed out for now, may be enabled later inline bool os::can_trim_native_heap() { return false; } inline bool os::trim_native_heap(os::size_change_t* rss_change) { return false; } diff --git a/src/hotspot/os/windows/os_windows.inline.hpp b/src/hotspot/os/windows/os_windows.inline.hpp index 1fb2f393f8a83..3b4d193d431da 100644 --- a/src/hotspot/os/windows/os_windows.inline.hpp +++ b/src/hotspot/os/windows/os_windows.inline.hpp @@ -93,7 +93,7 @@ inline void os::PlatformMonitor::notify_all() { WakeAllConditionVariable(&_cond); } -// stubbed-out trim-native support +// Trim-native support, stubbed out for now, may be enabled later inline bool os::can_trim_native_heap() { return false; } inline bool os::trim_native_heap(os::size_change_t* rss_change) { return false; } diff --git a/src/hotspot/share/classfile/stringTable.cpp b/src/hotspot/share/classfile/stringTable.cpp index d2348f16adf2e..72c503415dc33 100644 --- a/src/hotspot/share/classfile/stringTable.cpp +++ b/src/hotspot/share/classfile/stringTable.cpp @@ -49,6 +49,7 @@ #include "runtime/safepointVerifiers.hpp" #include "runtime/timerTrace.hpp" #include "runtime/interfaceSupport.inline.hpp" +#include "runtime/trimNativeHeap.hpp" #include "services/diagnosticCommand.hpp" #include "utilities/concurrentHashTable.inline.hpp" #include "utilities/concurrentHashTableTasks.inline.hpp" @@ -431,6 +432,7 @@ void StringTable::clean_dead_entries(JavaThread* jt) { StringTableDeleteCheck stdc; StringTableDoDelete stdd; + NativeHeapTrimmer::SuspendMark sm("stringtable"); { TraceTime timer("Clean", TRACETIME_LOG(Debug, stringtable, perf)); while(bdt.do_task(jt, stdc, stdd)) { diff --git a/src/hotspot/share/classfile/symbolTable.cpp b/src/hotspot/share/classfile/symbolTable.cpp index 46b4a46babc82..bf0d8754c5628 100644 --- a/src/hotspot/share/classfile/symbolTable.cpp +++ b/src/hotspot/share/classfile/symbolTable.cpp @@ -37,6 +37,7 @@ #include "runtime/atomic.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/timerTrace.hpp" +#include "runtime/trimNativeHeap.hpp" #include "services/diagnosticCommand.hpp" #include "utilities/concurrentHashTable.inline.hpp" #include "utilities/concurrentHashTableTasks.inline.hpp" @@ -697,6 +698,7 @@ void SymbolTable::clean_dead_entries(JavaThread* jt) { SymbolTableDeleteCheck stdc; SymbolTableDoDelete stdd; + NativeHeapTrimmer::SuspendMark sm("symboltable"); { TraceTime timer("Clean", TRACETIME_LOG(Debug, symboltable, perf)); while (bdt.do_task(jt, stdc, stdd)) { diff --git a/src/hotspot/share/logging/logTag.hpp b/src/hotspot/share/logging/logTag.hpp index 53cd1d364339f..7f31b5e663ae4 100644 --- a/src/hotspot/share/logging/logTag.hpp +++ b/src/hotspot/share/logging/logTag.hpp @@ -187,6 +187,7 @@ LOG_TAG(timer) \ LOG_TAG(tlab) \ LOG_TAG(tracking) \ + LOG_TAG(trimnative) /* trim native heap */ \ LOG_TAG(unload) /* Trace unloading of classes */ \ LOG_TAG(unshareable) \ LOG_TAG(update) \ diff --git a/src/hotspot/share/memory/arena.cpp b/src/hotspot/share/memory/arena.cpp index 313c79dbd493d..790e86603dc13 100644 --- a/src/hotspot/share/memory/arena.cpp +++ b/src/hotspot/share/memory/arena.cpp @@ -30,6 +30,7 @@ #include "runtime/task.hpp" #include "runtime/threadCritical.hpp" #include "services/memTracker.hpp" +#include "runtime/trimNativeHeap.hpp" #include "utilities/ostream.hpp" //-------------------------------------------------------------------------------------- @@ -136,6 +137,7 @@ class ChunkPool: public CHeapObj { } static void clean() { + NativeHeapTrimmer::SuspendMark sm("chunk pool cleaner"); enum { BlocksToKeep = 5 }; _tiny_pool->free_all_but(BlocksToKeep); _small_pool->free_all_but(BlocksToKeep); diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 3fe1e9389de73..d5ff64cd0ebbf 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -2364,6 +2364,14 @@ WB_ENTRY(void, WB_UnlockCritical(JNIEnv* env, jobject wb)) GCLocker::unlock_critical(thread); WB_END +WB_ENTRY(void, WB_PreTouchMemory(JNIEnv* env, jobject wb, jlong addr, jlong size)) + void* const from = (void*)addr; + void* const to = (void*)(addr + size); + if (from > to) { + os::pretouch_memory(from, to, os::vm_page_size()); + } +WB_END + #define CC (char*) static JNINativeMethod methods[] = { @@ -2631,6 +2639,7 @@ static JNINativeMethod methods[] = { {CC"lockCritical", CC"()V", (void*)&WB_LockCritical}, {CC"unlockCritical", CC"()V", (void*)&WB_UnlockCritical}, + {CC"preTouchMemory", CC"(JJ)V", (void*)&WB_PreTouchMemory}, }; diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index d20e146187aec..83903a3ab729b 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -2093,6 +2093,13 @@ const intx ObjectAlignmentInBytes = 8; \ develop(bool, TraceOptimizedUpcallStubs, false, \ "Trace optimized upcall stub generation") \ + \ + product(uint, TrimNativeHeapInterval, 0, EXPERIMENTAL, \ + "Interval, in ms, at which the JVM will trim the native heap if " \ + "the platform supports that. Lower values will reclaim memory " \ + "more eagerly at the cost of higher overhead. A value of 0 " \ + "(default) disables native heap trimming.") \ + range(0, UINT_MAX) \ // end of RUNTIME_FLAGS diff --git a/src/hotspot/share/runtime/java.cpp b/src/hotspot/share/runtime/java.cpp index 8f8b6bd6cfd9b..5dc47c7c245ce 100644 --- a/src/hotspot/share/runtime/java.cpp +++ b/src/hotspot/share/runtime/java.cpp @@ -71,6 +71,7 @@ #include "runtime/task.hpp" #include "runtime/thread.inline.hpp" #include "runtime/timer.hpp" +#include "runtime/trimNativeHeap.hpp" #include "runtime/vmOperations.hpp" #include "runtime/vmThread.hpp" #include "runtime/vm_version.hpp" @@ -467,6 +468,8 @@ void before_exit(JavaThread* thread, bool halt) { StringDedup::stop(); } + NativeHeapTrimmer::cleanup(); + // Stop concurrent GC threads Universe::heap()->stop(); diff --git a/src/hotspot/share/runtime/synchronizer.cpp b/src/hotspot/share/runtime/synchronizer.cpp index 0e208369849a1..bf278ea844076 100644 --- a/src/hotspot/share/runtime/synchronizer.cpp +++ b/src/hotspot/share/runtime/synchronizer.cpp @@ -51,6 +51,7 @@ #include "runtime/synchronizer.hpp" #include "runtime/thread.inline.hpp" #include "runtime/timer.hpp" +#include "runtime/trimNativeHeap.hpp" #include "runtime/vframe.hpp" #include "runtime/vmThread.hpp" #include "utilities/align.hpp" @@ -1544,6 +1545,8 @@ size_t ObjectSynchronizer::deflate_idle_monitors() { } } + NativeHeapTrimmer::SuspendMark sm("monitor deletion"); + // After the handshake, safely free the ObjectMonitors that were // deflated in this cycle. size_t deleted_count = 0; diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index 6f64bc4908cf8..ece43e350a4b8 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -112,6 +112,7 @@ #include "runtime/threadWXSetters.inline.hpp" #include "runtime/timer.hpp" #include "runtime/timerTrace.hpp" +#include "runtime/trimNativeHeap.hpp" #include "runtime/vframe.inline.hpp" #include "runtime/vframeArray.hpp" #include "runtime/vframe_hp.hpp" @@ -3082,6 +3083,10 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { } #endif + if (NativeHeapTrimmer::enabled()) { + NativeHeapTrimmer::initialize(); + } + // Always call even when there are not JVMTI environments yet, since environments // may be attached late and JVMTI must track phases of VM execution JvmtiExport::enter_live_phase(); diff --git a/src/hotspot/share/runtime/trimNativeHeap.cpp b/src/hotspot/share/runtime/trimNativeHeap.cpp new file mode 100644 index 0000000000000..0ec2b93761fd3 --- /dev/null +++ b/src/hotspot/share/runtime/trimNativeHeap.cpp @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2023 SAP SE. All rights reserved. + * Copyright (c) 2023 Red Hat Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "logging/log.hpp" +#include "runtime/globals.hpp" +#include "runtime/globals_extension.hpp" +#include "runtime/mutex.hpp" +#include "runtime/mutexLocker.hpp" +#include "runtime/nonJavaThread.hpp" +#include "runtime/os.inline.hpp" +#include "runtime/safepoint.hpp" +#include "runtime/trimNativeHeap.hpp" +#include "utilities/debug.hpp" +#include "utilities/globalDefinitions.hpp" +#include "utilities/ostream.hpp" +#include "utilities/vmError.hpp" + +class NativeHeapTrimmerThread : public NamedThread { + + // Upper limit for the backoff during pending/in-progress safepoint. + // Chosen as reasonable value to balance the overheads of waking up + // during the safepoint, which might have undesired effects on latencies, + // and the accuracy in tracking the trimming interval. + static constexpr int64_t safepoint_poll_ms = 250; + + Monitor* const _lock; + bool _stop; + uint16_t _suspend_count; + + // Statistics + uint64_t _num_trims_performed; + + bool is_suspended() const { + assert(_lock->is_locked(), "Must be"); + return _suspend_count > 0; + } + + uint16_t inc_suspend_count() { + assert(_lock->is_locked(), "Must be"); + assert(_suspend_count < UINT16_MAX, "Sanity"); + return ++_suspend_count; + } + + uint16_t dec_suspend_count() { + assert(_lock->is_locked(), "Must be"); + assert(_suspend_count != 0, "Sanity"); + return --_suspend_count; + } + + bool is_stopped() const { + assert(_lock->is_locked(), "Must be"); + return _stop; + } + + bool at_or_nearing_safepoint() const { + return SafepointSynchronize::is_at_safepoint() || + SafepointSynchronize::is_synchronizing(); + } + + // in seconds + static double now() { return os::elapsedTime(); } + static double to_ms(double seconds) { return seconds * 1000.0; } + + struct LogStartStopMark { + void log(const char* s) { log_info(trimnative)("Native heap trimmer %s", s); } + LogStartStopMark() { log("start"); } + ~LogStartStopMark() { log("stop"); } + }; + + void run() override { + assert(NativeHeapTrimmer::enabled(), "Only call if enabled"); + + LogStartStopMark lssm; + + const double interval_secs = (double)TrimNativeHeapInterval / 1000; + + while (true) { + double tnow = now(); + double next_trim_time = tnow + interval_secs; + + unsigned times_suspended = 0; + unsigned times_waited = 0; + unsigned times_safepoint = 0; + + { + MonitorLocker ml(_lock, Mutex::_no_safepoint_check_flag); + if (_stop) return; + + while (at_or_nearing_safepoint() || is_suspended() || next_trim_time > tnow) { + if (is_suspended()) { + times_suspended ++; + ml.wait(0); // infinite + } else if (next_trim_time > tnow) { + times_waited ++; + const int64_t wait_ms = MAX2(1.0, to_ms(next_trim_time - tnow)); + ml.wait(wait_ms); + } else if (at_or_nearing_safepoint()) { + times_safepoint ++; + const int64_t wait_ms = MIN2(TrimNativeHeapInterval, safepoint_poll_ms); + ml.wait(wait_ms); + } + + if (_stop) return; + + tnow = now(); + } + } + + log_trace(trimnative)("Times: %u suspended, %u timed, %u safepoint", + times_suspended, times_waited, times_safepoint); + + execute_trim_and_log(tnow); + } + } + + // Execute the native trim, log results. + void execute_trim_and_log(double t1) { + assert(os::can_trim_native_heap(), "Unexpected"); + + os::size_change_t sc = { 0, 0 }; + LogTarget(Info, trimnative) lt; + const bool logging_enabled = lt.is_enabled(); + + // We only collect size change information if we are logging; save the access to procfs otherwise. + if (os::trim_native_heap(logging_enabled ? &sc : nullptr)) { + _num_trims_performed++; + if (logging_enabled) { + double t2 = now(); + if (sc.after != SIZE_MAX) { + const size_t delta = sc.after < sc.before ? (sc.before - sc.after) : (sc.after - sc.before); + const char sign = sc.after < sc.before ? '-' : '+'; + log_info(trimnative)("Periodic Trim (" UINT64_FORMAT "): " PROPERFMT "->" PROPERFMT " (%c" PROPERFMT ") %.3fms", + _num_trims_performed, + PROPERFMTARGS(sc.before), PROPERFMTARGS(sc.after), sign, PROPERFMTARGS(delta), + to_ms(t2 - t1)); + } else { + log_info(trimnative)("Periodic Trim (" UINT64_FORMAT "): complete (no details) %.3fms", + _num_trims_performed, + to_ms(t2 - t1)); + } + } + } + } + +public: + + NativeHeapTrimmerThread() : + _lock(new (std::nothrow) PaddedMonitor(Mutex::leaf, "NativeHeapTrimmer_lock", true, Mutex::_safepoint_check_never)), + _stop(false), + _suspend_count(0), + _num_trims_performed(0) + { + set_name("Native Heap Trimmer"); + if (os::create_thread(this, os::vm_thread)) { + os::start_thread(this); + } + } + + void suspend(const char* reason) { + assert(NativeHeapTrimmer::enabled(), "Only call if enabled"); + uint16_t n = 0; + { + MonitorLocker ml(_lock, Mutex::_no_safepoint_check_flag); + n = inc_suspend_count(); + // No need to wakeup trimmer + } + log_debug(trimnative)("Trim suspended for %s (%u suspend requests)", reason, n); + } + + void resume(const char* reason) { + assert(NativeHeapTrimmer::enabled(), "Only call if enabled"); + uint16_t n = 0; + { + MonitorLocker ml(_lock, Mutex::_no_safepoint_check_flag); + n = dec_suspend_count(); + if (n == 0) { + ml.notify_all(); // pause end + } + } + if (n == 0) { + log_debug(trimnative)("Trim resumed after %s", reason); + } else { + log_debug(trimnative)("Trim still suspended after %s (%u suspend requests)", reason, n); + } + } + + void stop() { + MonitorLocker ml(_lock, Mutex::_no_safepoint_check_flag); + _stop = true; + ml.notify_all(); + } + + void print_state(outputStream* st) const { + // Don't pull lock during error reporting + Mutex* const lock = VMError::is_error_reported() ? nullptr : _lock; + int64_t num_trims = 0; + bool stopped = false; + uint16_t suspenders = 0; + { + MutexLocker ml(lock, Mutex::_no_safepoint_check_flag); + num_trims = _num_trims_performed; + stopped = _stop; + suspenders = _suspend_count; + } + st->print_cr("Trims performed: " UINT64_FORMAT ", current suspend count: %d, stopped: %d", + num_trims, suspenders, stopped); + } + +}; // NativeHeapTrimmer + +static NativeHeapTrimmerThread* g_trimmer_thread = nullptr; + +void NativeHeapTrimmer::initialize() { + assert(g_trimmer_thread == nullptr, "Only once"); + if (TrimNativeHeapInterval > 0) { + if (!os::can_trim_native_heap()) { + FLAG_SET_ERGO(TrimNativeHeapInterval, 0); + log_warning(trimnative)("Native heap trim is not supported on this platform"); + return; + } + g_trimmer_thread = new NativeHeapTrimmerThread(); + log_info(trimnative)("Periodic native trim enabled (interval: %u ms)", TrimNativeHeapInterval); + } +} + +void NativeHeapTrimmer::cleanup() { + if (g_trimmer_thread != nullptr) { + g_trimmer_thread->stop(); + } +} + +void NativeHeapTrimmer::suspend_periodic_trim(const char* reason) { + if (g_trimmer_thread != nullptr) { + g_trimmer_thread->suspend(reason); + } +} + +void NativeHeapTrimmer::resume_periodic_trim(const char* reason) { + if (g_trimmer_thread != nullptr) { + g_trimmer_thread->resume(reason); + } +} + +void NativeHeapTrimmer::print_state(outputStream* st) { + if (g_trimmer_thread != nullptr) { + st->print_cr("Periodic native trim enabled (interval: %u ms)", TrimNativeHeapInterval); + g_trimmer_thread->print_state(st); + } else { + st->print_cr("Periodic native trim disabled"); + } +} diff --git a/src/hotspot/share/runtime/trimNativeHeap.hpp b/src/hotspot/share/runtime/trimNativeHeap.hpp new file mode 100644 index 0000000000000..06dc88ebb0899 --- /dev/null +++ b/src/hotspot/share/runtime/trimNativeHeap.hpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 SAP SE. All rights reserved. + * Copyright (c) 2023 Red Hat Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_RUNTIME_TRIMNATIVEHEAP_HPP +#define SHARE_RUNTIME_TRIMNATIVEHEAP_HPP + +#include "memory/allStatic.hpp" +#include "runtime/globals.hpp" + +class outputStream; + +class NativeHeapTrimmer : public AllStatic { + + // Pause periodic trim (if enabled). + static void suspend_periodic_trim(const char* reason); + + // Unpause periodic trim (if enabled). + static void resume_periodic_trim(const char* reason); + +public: + + static void initialize(); + static void cleanup(); + + static inline bool enabled() { return TrimNativeHeapInterval > 0; } + + static void print_state(outputStream* st); + + // Pause periodic trimming while in scope; when leaving scope, + // resume periodic trimming. + struct SuspendMark { + const char* const _reason; + SuspendMark(const char* reason = "unknown") : _reason(reason) { + if (NativeHeapTrimmer::enabled()) { + suspend_periodic_trim(_reason); + } + } + ~SuspendMark() { + if (NativeHeapTrimmer::enabled()) { + resume_periodic_trim(_reason); + } + } + }; +}; + +#endif // SHARE_RUNTIME_TRIMNATIVEHEAP_HPP diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index bcae7c7758325..f20a99638d493 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -50,6 +50,7 @@ #include "runtime/stackFrameStream.inline.hpp" #include "runtime/thread.inline.hpp" #include "runtime/threadSMR.hpp" +#include "runtime/trimNativeHeap.hpp" #include "runtime/vmThread.hpp" #include "runtime/vmOperations.hpp" #include "runtime/vm_version.hpp" @@ -1202,6 +1203,14 @@ void VMError::report(outputStream* st, bool _verbose) { STEP("Native Memory Tracking") if (_verbose) { MemTracker::error_report(st); + st->cr(); + } + + STEP("printing periodic trim state") + + if (_verbose) { + NativeHeapTrimmer::print_state(st); + st->cr(); } STEP("printing system") @@ -1387,10 +1396,14 @@ void VMError::print_vm_info(outputStream* st) { // STEP("Native Memory Tracking") MemTracker::error_report(st); + st->cr(); - // STEP("printing system") - + // STEP("printing periodic trim state") + NativeHeapTrimmer::print_state(st); st->cr(); + + + // STEP("printing system") st->print_cr("--------------- S Y S T E M ---------------"); st->cr(); diff --git a/test/hotspot/gtest/runtime/test_trim_native.cpp b/test/hotspot/gtest/runtime/test_trim_native.cpp new file mode 100644 index 0000000000000..327680e5b4f45 --- /dev/null +++ b/test/hotspot/gtest/runtime/test_trim_native.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2023 Red Hat Inc. All rights reserved. + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "runtime/os.hpp" +#include "runtime/trimNativeHeap.hpp" +#include "utilities/globalDefinitions.hpp" +#include "utilities/ostream.hpp" +#include "testutils.hpp" +#include "unittest.hpp" + +using ::testing::HasSubstr; + +// Check the state of the trimmer via print_state; returns the suspend count +static int check_trim_state() { + char buf [1024]; + stringStream ss(buf, sizeof(buf)); + NativeHeapTrimmer::print_state(&ss); + if (NativeHeapTrimmer::enabled()) { + assert(TrimNativeHeapInterval > 0, "Sanity"); + EXPECT_THAT(buf, HasSubstr("Periodic native trim enabled")); + + const char* s = ::strstr(buf, "Trims performed"); + EXPECT_NE(p2i(s), 0); + + uint64_t num_trims = 0; + int suspend_count = 0; + int stopped = 0; + EXPECT_EQ(::sscanf(s, "Trims performed: " UINT64_FORMAT ", current suspend count: %d, stopped: %d", + &num_trims, &suspend_count, &stopped), 3); + + // Number of trims we can reasonably expect should be limited + const double fudge_factor = 1.5; + const uint64_t elapsed_ms = (uint64_t)(os::elapsedTime() * fudge_factor * 1000.0); + const uint64_t max_num_trims = (elapsed_ms / TrimNativeHeapInterval) + 1; + EXPECT_LE(num_trims, max_num_trims); + + // We should not be stopped + EXPECT_EQ(stopped, 0); + + // Suspend count must not underflow + EXPECT_GE(suspend_count, 0); + return suspend_count; + + } else { + EXPECT_THAT(buf, HasSubstr("Periodic native trim disabled")); + EXPECT_THAT(buf, Not(HasSubstr("Trims performed"))); + return 0; + } +} + +TEST_VM(os, TrimNative) { + + if (!NativeHeapTrimmer::enabled()) { + return; + } + + // Try recursive pausing. This tests that we are able to pause, that pauses stack, + // and that stacking works within the same thread. + int c1 = 0, c2 = 0, c3 = 0; + { + NativeHeapTrimmer::SuspendMark sm1("Test1"); + c1 = check_trim_state(); + { + NativeHeapTrimmer::SuspendMark sm2("Test2"); + c2 = check_trim_state(); + { + NativeHeapTrimmer::SuspendMark sm3("Test3"); + c3 = check_trim_state(); + } + } + } + // We also check the state: the suspend count should go up. But since we don't know + // whether concurrent code will have increased the suspend count too, this is fuzzy and + // we must avoid intermittent false positives. + EXPECT_GT(c2, c1); + EXPECT_GT(c3, c2); +} diff --git a/test/hotspot/jtreg/gtest/NativeHeapTrimmerGtest.java b/test/hotspot/jtreg/gtest/NativeHeapTrimmerGtest.java new file mode 100644 index 0000000000000..7aa3dd8a32240 --- /dev/null +++ b/test/hotspot/jtreg/gtest/NativeHeapTrimmerGtest.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023 Red Hat, Inc. All rights reserved. + * 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 Run a subset of gtests with the native trimmer activated. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.xml + * @run main/native GTestWrapper --gtest_filter=os.trim* -Xlog:trimnative -XX:+UnlockExperimentalVMOptions -XX:TrimNativeHeapInterval=100 + */ diff --git a/test/hotspot/jtreg/runtime/os/TestTrimNative.java b/test/hotspot/jtreg/runtime/os/TestTrimNative.java new file mode 100644 index 0000000000000..50b6e56173478 --- /dev/null +++ b/test/hotspot/jtreg/runtime/os/TestTrimNative.java @@ -0,0 +1,309 @@ +/* + * Copyright (c) 2023 SAP SE. All rights reserved. + * Copyright (c) 2023 Red Hat, Inc. 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 + * 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=trimNative + * @requires (os.family=="linux") & !vm.musl + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run driver TestTrimNative trimNative + */ + +/* + * @test id=trimNativeHighInterval + * @summary High interval trimming should not even kick in for short program runtimes + * @requires (os.family=="linux") & !vm.musl + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run driver TestTrimNative trimNativeHighInterval + */ + +/* + * @test id=trimNativeLowInterval + * @summary Very low (sub-second) interval, nothing should explode + * @requires (os.family=="linux") & !vm.musl + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run driver TestTrimNative trimNativeLowInterval + */ + +/* + * @test id=testOffByDefault + * @summary Test that trimming is disabled by default + * @requires (os.family=="linux") & !vm.musl + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run driver TestTrimNative testOffByDefault + */ + +/* + * @test id=testOffExplicit + * @summary Test that trimming can be disabled explicitly + * @requires (os.family=="linux") & !vm.musl + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run driver TestTrimNative testOffExplicit + */ + +/* + * @test id=testOffOnNonCompliantPlatforms + * @summary Test that trimming is correctly reported as unavailable if unavailable + * @requires (os.family!="linux") | vm.musl + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run driver TestTrimNative testOffOnNonCompliantPlatforms + */ + +import jdk.test.lib.Platform; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +import java.io.IOException; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jdk.test.whitebox.WhiteBox; + +public class TestTrimNative { + + // Actual RSS increase is a lot larger than 4 MB. Depends on glibc overhead, and NMT malloc headers in debug VMs. + // We need small-grained allocations to make sure they actually increase RSS (all touched) and to see the + // glibc-retaining-memory effect. + static final int szAllocations = 128; + static final int totalAllocationsSize = 128 * 1024 * 1024; // 128 MB total + static final int numAllocations = totalAllocationsSize / szAllocations; + + static long[] ptrs = new long[numAllocations]; + + enum Unit { + B(1), K(1024), M(1024*1024), G(1024*1024*1024); + public final long size; + Unit(long size) { this.size = size; } + } + + private static String[] prepareOptions(String[] extraVMOptions, String[] programOptions) { + List allOptions = new ArrayList(); + if (extraVMOptions != null) { + allOptions.addAll(Arrays.asList(extraVMOptions)); + } + allOptions.add("-Xmx128m"); + allOptions.add("-Xms128m"); // Stabilize RSS + allOptions.add("-XX:+AlwaysPreTouch"); // Stabilize RSS + allOptions.add("-XX:+UnlockDiagnosticVMOptions"); // For whitebox + allOptions.add("-XX:+WhiteBoxAPI"); + allOptions.add("-Xbootclasspath/a:."); + allOptions.add("-XX:-ExplicitGCInvokesConcurrent"); // Invoke explicit GC on System.gc + allOptions.add("-Xlog:trimnative=debug"); + allOptions.add("--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED"); + if (programOptions != null) { + allOptions.addAll(Arrays.asList(programOptions)); + } + return allOptions.toArray(new String[0]); + } + + private static OutputAnalyzer runTestWithOptions(String[] extraOptions, String[] programOptions) throws IOException { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(prepareOptions(extraOptions, programOptions)); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + return output; + } + + private static void checkExpectedLogMessages(OutputAnalyzer output, boolean expectEnabled, + int expectedInterval) { + if (expectEnabled) { + output.shouldContain("Periodic native trim enabled (interval: " + expectedInterval + " ms"); + output.shouldContain("Native heap trimmer start"); + output.shouldContain("Native heap trimmer stop"); + } else { + output.shouldNotContain("Periodic native trim enabled"); + } + } + + /** + * Given JVM output, look for one or more log lines that describes a successful negative trim. The total amount + * of trims should be matching about what the test program allocated. + * @param output + * @param minTrimsExpected min number of periodic trim lines expected in UL log + * @param maxTrimsExpected min number of periodic trim lines expected in UL log + */ + private static void parseOutputAndLookForNegativeTrim(OutputAnalyzer output, int minTrimsExpected, + int maxTrimsExpected) { + output.reportDiagnosticSummary(); + List lines = output.asLines(); + Pattern pat = Pattern.compile(".*\\[trimnative\\] Periodic Trim \\(\\d+\\): (\\d+)([BKMG])->(\\d+)([BKMG]).*"); + int numTrimsFound = 0; + long rssReductionTotal = 0; + for (String line : lines) { + Matcher mat = pat.matcher(line); + if (mat.matches()) { + long rss1 = Long.parseLong(mat.group(1)) * Unit.valueOf(mat.group(2)).size; + long rss2 = Long.parseLong(mat.group(3)) * Unit.valueOf(mat.group(4)).size; + if (rss1 > rss2) { + rssReductionTotal += (rss1 - rss2); + } + numTrimsFound ++; + } + if (numTrimsFound > maxTrimsExpected) { + throw new RuntimeException("Abnormal high number of periodic trim attempts found (more than " + maxTrimsExpected + + "). Does the interval setting not work?"); + } + } + if (numTrimsFound < minTrimsExpected) { + throw new RuntimeException("We found fewer (periodic) trim lines in UL log than expected (expected at least " + minTrimsExpected + + ", found " + numTrimsFound + ")."); + } + if (maxTrimsExpected > 0) { + // This is very fuzzy. Test program malloced X bytes, then freed them again and trimmed. But the log line prints change in RSS. + // Which, of course, is influenced by a lot of other factors. But we expect to see *some* reasonable reduction in RSS + // due to trimming. + float fudge = 0.5f; + // On ppc, we see a vastly diminished return (~3M reduction instead of ~200), I suspect because of the underlying + // 64k pages lead to a different geometry. Manual tests with larger reclaim sizes show that autotrim works. For + // this test, we just reduce the fudge factor. + if (Platform.isPPC()) { // le and be both + fudge = 0.01f; + } + long expectedMinimalReduction = (long) (totalAllocationsSize * fudge); + if (rssReductionTotal < expectedMinimalReduction) { + throw new RuntimeException("We did not see the expected RSS reduction in the UL log. Expected (with fudge)" + + " to see at least a combined reduction of " + expectedMinimalReduction + "."); + } + } + } + + static class Tester { + public static void main(String[] args) throws Exception { + long sleeptime = Long.parseLong(args[0]); + + System.out.println("Will spike now..."); + WhiteBox wb = WhiteBox.getWhiteBox(); + for (int i = 0; i < numAllocations; i++) { + ptrs[i] = wb.NMTMalloc(szAllocations); + wb.preTouchMemory(ptrs[i], szAllocations); + } + for (int i = 0; i < numAllocations; i++) { + wb.NMTFree(ptrs[i]); + } + System.out.println("Done spiking."); + + System.out.println("GC..."); + System.gc(); + + // give GC time to react + System.out.println("Sleeping..."); + Thread.sleep(sleeptime); + System.out.println("Done."); + } + } + + public static void main(String[] args) throws Exception { + + if (args.length == 0) { + throw new RuntimeException("Argument error"); + } + + switch (args[0]) { + case "trimNative": { + long trimInterval = 500; // twice per second + long ms1 = System.currentTimeMillis(); + OutputAnalyzer output = runTestWithOptions( + new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=" + trimInterval }, + new String[] { TestTrimNative.Tester.class.getName(), "5000" } + ); + long ms2 = System.currentTimeMillis(); + long runtime_ms = ms2 - ms1; + + checkExpectedLogMessages(output, true, 500); + + long maxTrimsExpected = runtime_ms / trimInterval; + long minTrimsExpected = maxTrimsExpected / 2; + parseOutputAndLookForNegativeTrim(output, (int) minTrimsExpected, (int) maxTrimsExpected); + } break; + + case "trimNativeHighInterval": { + OutputAnalyzer output = runTestWithOptions( + new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=" + Integer.MAX_VALUE }, + new String[] { TestTrimNative.Tester.class.getName(), "5000" } + ); + checkExpectedLogMessages(output, true, Integer.MAX_VALUE); + // We should not see any trims since the interval would prevent them + parseOutputAndLookForNegativeTrim(output, 0, 0); + } break; + + case "trimNativeLowInterval": { + OutputAnalyzer output = runTestWithOptions( + new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=1" }, + new String[] { TestTrimNative.Tester.class.getName(), "0" } + ); + checkExpectedLogMessages(output, true, 1); + parseOutputAndLookForNegativeTrim(output, 1, 3000); + } break; + + case "testOffOnNonCompliantPlatforms": { + OutputAnalyzer output = runTestWithOptions( + new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=1" }, + new String[] { "-version" } + ); + checkExpectedLogMessages(output, false, 0); + parseOutputAndLookForNegativeTrim(output, 0, 0); + // The following output is expected to be printed with warning level, so it should not need -Xlog + output.shouldContain("[warning][trimnative] Native heap trim is not supported on this platform"); + } break; + + case "testOffExplicit": { + OutputAnalyzer output = runTestWithOptions( + new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=0" }, + new String[] { "-version" } + ); + checkExpectedLogMessages(output, false, 0); + parseOutputAndLookForNegativeTrim(output, 0, 0); + } break; + + case "testOffByDefault": { + OutputAnalyzer output = runTestWithOptions(null, new String[] { "-version" } ); + checkExpectedLogMessages(output, false, 0); + parseOutputAndLookForNegativeTrim(output, 0, 0); + } break; + + default: + throw new RuntimeException("Invalid test " + args[0]); + + } + } +} diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/TrimLibcHeapTest.java b/test/hotspot/jtreg/serviceability/dcmd/vm/TrimLibcHeapTest.java index 5c18d711c7ee7..63624221ce035 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/TrimLibcHeapTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/TrimLibcHeapTest.java @@ -22,6 +22,7 @@ * questions. */ +import jdk.test.lib.Platform; import org.testng.annotations.Test; import jdk.test.lib.dcmd.CommandExecutor; import jdk.test.lib.dcmd.JMXExecutor; @@ -31,7 +32,7 @@ * @test * @summary Test of diagnostic command VM.trim_libc_heap * @library /test/lib - * @requires (os.family=="linux") & !vm.musl + * @requires os.family == "linux" * @modules java.base/jdk.internal.misc * java.compiler * java.management @@ -42,7 +43,11 @@ public class TrimLibcHeapTest { public void run(CommandExecutor executor) { OutputAnalyzer output = executor.execute("System.trim_native_heap"); output.reportDiagnosticSummary(); - output.shouldMatch(".*Trim native heap: RSS\\+Swap: \\d+[BKM]->\\d+[BKM].*"); + if (Platform.isMusl()) { + output.shouldContain("Not available"); + } else { + output.shouldMatch("Trim native heap: RSS\\+Swap: \\d+[BKMG]->\\d+[BKMG] \\(-\\d+[BKMG]\\)"); + } } @Test diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index 118fc7d2b6b23..bc9434fa50832 100644 --- a/test/lib/jdk/test/whitebox/WhiteBox.java +++ b/test/lib/jdk/test/whitebox/WhiteBox.java @@ -654,4 +654,6 @@ public native int validateCgroup(String procCgroups, public native void lockCritical(); public native void unlockCritical(); + + public native void preTouchMemory(long addr, long size); } From 3c426c70edbfdfbce362740dca30005f8d781e53 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 25 Aug 2023 14:30:42 +0000 Subject: [PATCH 054/341] 8312525: New test runtime/os/TestTrimNative.java#trimNative is failing: did not see the expected RSS reduction Reviewed-by: mdoerr Backport-of: ad34be1f329edc8e7155983835cc70d733c014b8 --- src/hotspot/os/linux/trimCHeapDCmd.cpp | 4 ++ .../jtreg/runtime/os/TestTrimNative.java | 49 +++++++++++++++---- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/hotspot/os/linux/trimCHeapDCmd.cpp b/src/hotspot/os/linux/trimCHeapDCmd.cpp index 33dd6f3a5bdc7..26c066ffe5b6e 100644 --- a/src/hotspot/os/linux/trimCHeapDCmd.cpp +++ b/src/hotspot/os/linux/trimCHeapDCmd.cpp @@ -24,6 +24,7 @@ */ #include "precompiled.hpp" +#include "logging/log.hpp" #include "runtime/os.inline.hpp" #include "trimCHeapDCmd.hpp" #include "utilities/debug.hpp" @@ -42,6 +43,9 @@ void TrimCLibcHeapDCmd::execute(DCmdSource source, TRAPS) { const char sign = sc.after < sc.before ? '-' : '+'; _output->print_cr("RSS+Swap: " PROPERFMT "->" PROPERFMT " (%c" PROPERFMT ")", PROPERFMTARGS(sc.before), PROPERFMTARGS(sc.after), sign, PROPERFMTARGS(delta)); + // Also log if native trim log is active + log_info(trimnative)("Manual Trim: " PROPERFMT "->" PROPERFMT " (%c" PROPERFMT ")", + PROPERFMTARGS(sc.before), PROPERFMTARGS(sc.after), sign, PROPERFMTARGS(delta)); } else { _output->print_cr("(no details available)."); } diff --git a/test/hotspot/jtreg/runtime/os/TestTrimNative.java b/test/hotspot/jtreg/runtime/os/TestTrimNative.java index 50b6e56173478..5fa87ea903f69 100644 --- a/test/hotspot/jtreg/runtime/os/TestTrimNative.java +++ b/test/hotspot/jtreg/runtime/os/TestTrimNative.java @@ -34,6 +34,16 @@ * @run driver TestTrimNative trimNative */ +/* + * @test id=trimNativeStrict + * @requires (os.family=="linux") & !vm.musl + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run main/manual TestTrimNative trimNativeStrict + */ + /* * @test id=trimNativeHighInterval * @summary High interval trimming should not even kick in for short program runtimes @@ -56,6 +66,17 @@ * @run driver TestTrimNative trimNativeLowInterval */ +/* + * @test id=trimNativeLowIntervalStrict + * @summary Very low (sub-second) interval, nothing should explode (stricter test, manual mode) + * @requires (os.family=="linux") & !vm.musl + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run main/manual TestTrimNative trimNativeLowIntervalStrict + */ + /* * @test id=testOffByDefault * @summary Test that trimming is disabled by default @@ -161,9 +182,10 @@ private static void checkExpectedLogMessages(OutputAnalyzer output, boolean expe * @param output * @param minTrimsExpected min number of periodic trim lines expected in UL log * @param maxTrimsExpected min number of periodic trim lines expected in UL log + * @param strict: if true, expect RSS to go down; if false, just look for trims without looking at RSS. */ private static void parseOutputAndLookForNegativeTrim(OutputAnalyzer output, int minTrimsExpected, - int maxTrimsExpected) { + int maxTrimsExpected, boolean strict) { output.reportDiagnosticSummary(); List lines = output.asLines(); Pattern pat = Pattern.compile(".*\\[trimnative\\] Periodic Trim \\(\\d+\\): (\\d+)([BKMG])->(\\d+)([BKMG]).*"); @@ -188,7 +210,8 @@ private static void parseOutputAndLookForNegativeTrim(OutputAnalyzer output, int throw new RuntimeException("We found fewer (periodic) trim lines in UL log than expected (expected at least " + minTrimsExpected + ", found " + numTrimsFound + ")."); } - if (maxTrimsExpected > 0) { + System.out.println("Found " + numTrimsFound + " trims. Ok."); + if (strict && maxTrimsExpected > 0) { // This is very fuzzy. Test program malloced X bytes, then freed them again and trimmed. But the log line prints change in RSS. // Which, of course, is influenced by a lot of other factors. But we expect to see *some* reasonable reduction in RSS // due to trimming. @@ -203,6 +226,8 @@ private static void parseOutputAndLookForNegativeTrim(OutputAnalyzer output, int if (rssReductionTotal < expectedMinimalReduction) { throw new RuntimeException("We did not see the expected RSS reduction in the UL log. Expected (with fudge)" + " to see at least a combined reduction of " + expectedMinimalReduction + "."); + } else { + System.out.println("Found high enough RSS reduction from trims: " + rssReductionTotal); } } } @@ -238,8 +263,11 @@ public static void main(String[] args) throws Exception { throw new RuntimeException("Argument error"); } + boolean strictTesting = args[0].endsWith("Strict"); + switch (args[0]) { - case "trimNative": { + case "trimNative": + case "trimNativeStrict": { long trimInterval = 500; // twice per second long ms1 = System.currentTimeMillis(); OutputAnalyzer output = runTestWithOptions( @@ -253,7 +281,7 @@ public static void main(String[] args) throws Exception { long maxTrimsExpected = runtime_ms / trimInterval; long minTrimsExpected = maxTrimsExpected / 2; - parseOutputAndLookForNegativeTrim(output, (int) minTrimsExpected, (int) maxTrimsExpected); + parseOutputAndLookForNegativeTrim(output, (int) minTrimsExpected, (int) maxTrimsExpected, strictTesting); } break; case "trimNativeHighInterval": { @@ -263,16 +291,17 @@ public static void main(String[] args) throws Exception { ); checkExpectedLogMessages(output, true, Integer.MAX_VALUE); // We should not see any trims since the interval would prevent them - parseOutputAndLookForNegativeTrim(output, 0, 0); + parseOutputAndLookForNegativeTrim(output, 0, 0, strictTesting); } break; - case "trimNativeLowInterval": { + case "trimNativeLowInterval": + case "trimNativeLowIntervalStrict": { OutputAnalyzer output = runTestWithOptions( new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=1" }, new String[] { TestTrimNative.Tester.class.getName(), "0" } ); checkExpectedLogMessages(output, true, 1); - parseOutputAndLookForNegativeTrim(output, 1, 3000); + parseOutputAndLookForNegativeTrim(output, 1, 3000, strictTesting); } break; case "testOffOnNonCompliantPlatforms": { @@ -281,7 +310,7 @@ public static void main(String[] args) throws Exception { new String[] { "-version" } ); checkExpectedLogMessages(output, false, 0); - parseOutputAndLookForNegativeTrim(output, 0, 0); + parseOutputAndLookForNegativeTrim(output, 0, 0, strictTesting); // The following output is expected to be printed with warning level, so it should not need -Xlog output.shouldContain("[warning][trimnative] Native heap trim is not supported on this platform"); } break; @@ -292,13 +321,13 @@ public static void main(String[] args) throws Exception { new String[] { "-version" } ); checkExpectedLogMessages(output, false, 0); - parseOutputAndLookForNegativeTrim(output, 0, 0); + parseOutputAndLookForNegativeTrim(output, 0, 0, strictTesting); } break; case "testOffByDefault": { OutputAnalyzer output = runTestWithOptions(null, new String[] { "-version" } ); checkExpectedLogMessages(output, false, 0); - parseOutputAndLookForNegativeTrim(output, 0, 0); + parseOutputAndLookForNegativeTrim(output, 0, 0, strictTesting); } break; default: From fdc413029acf88e29015a9cb9b2d95dccfde0cfb Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 25 Aug 2023 15:30:00 +0000 Subject: [PATCH 055/341] 8314426: runtime/os/TestTrimNative.java is failing on slow machines Reviewed-by: stuefe Backport-of: 20e94784c9f7c30e95550c72aedb5e986a153114 --- test/hotspot/jtreg/runtime/os/TestTrimNative.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/runtime/os/TestTrimNative.java b/test/hotspot/jtreg/runtime/os/TestTrimNative.java index 5fa87ea903f69..f1aed48b88ec1 100644 --- a/test/hotspot/jtreg/runtime/os/TestTrimNative.java +++ b/test/hotspot/jtreg/runtime/os/TestTrimNative.java @@ -170,7 +170,6 @@ private static void checkExpectedLogMessages(OutputAnalyzer output, boolean expe if (expectEnabled) { output.shouldContain("Periodic native trim enabled (interval: " + expectedInterval + " ms"); output.shouldContain("Native heap trimmer start"); - output.shouldContain("Native heap trimmer stop"); } else { output.shouldNotContain("Periodic native trim enabled"); } @@ -251,7 +250,7 @@ public static void main(String[] args) throws Exception { System.gc(); // give GC time to react - System.out.println("Sleeping..."); + System.out.println("Sleeping for " + sleeptime + " ms..."); Thread.sleep(sleeptime); System.out.println("Done."); } @@ -296,12 +295,15 @@ public static void main(String[] args) throws Exception { case "trimNativeLowInterval": case "trimNativeLowIntervalStrict": { + long ms1 = System.currentTimeMillis(); OutputAnalyzer output = runTestWithOptions( new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=1" }, new String[] { TestTrimNative.Tester.class.getName(), "0" } ); + long ms2 = System.currentTimeMillis(); + int maxTrimsExpected = (int)(ms2 - ms1); // 1ms trim interval checkExpectedLogMessages(output, true, 1); - parseOutputAndLookForNegativeTrim(output, 1, 3000, strictTesting); + parseOutputAndLookForNegativeTrim(output, 1, (int)maxTrimsExpected, strictTesting); } break; case "testOffOnNonCompliantPlatforms": { From 7286bb8518543501045de4cf970094ac9c1af4fa Mon Sep 17 00:00:00 2001 From: Kimura Yukihiro Date: Sat, 26 Aug 2023 14:32:20 +0000 Subject: [PATCH 056/341] 8313815: The exception messages printed by jcmd ManagementAgent.start are corrupted on Japanese Windows Reviewed-by: kevinw, cjplummer, phh --- .../share/classes/sun/tools/attach/HotSpotVirtualMachine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java b/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java index 6eea1e4562c1c..1ebd7597e7676 100644 --- a/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java +++ b/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java @@ -356,7 +356,7 @@ int readInt(InputStream in) throws IOException { String readErrorMessage(InputStream in) throws IOException { String s; StringBuilder message = new StringBuilder(); - BufferedReader br = new BufferedReader(new InputStreamReader(in)); + BufferedReader br = new BufferedReader(new InputStreamReader(in,"UTF-8")); while ((s = br.readLine()) != null) { message.append(s); } From 4c123ac3146ccec1bb168751fc38d3fcdd973190 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Mon, 28 Aug 2023 05:26:18 +0000 Subject: [PATCH 057/341] 8295737: macOS: Print content cut off when width > height with portrait orientation Backport-of: d00a767047ec41e233e711dbc5fe7b8818e72f28 --- .../classes/sun/lwawt/macosx/CPrinterJob.java | 78 +++- .../PageFormat/PrintContentCutOffTest.java | 358 ++++++++++++++++++ 2 files changed, 433 insertions(+), 3 deletions(-) create mode 100644 test/jdk/java/awt/print/PageFormat/PrintContentCutOffTest.java diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java index 4849c16b79f0c..1931b8e3dd696 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java @@ -631,7 +631,8 @@ private PageFormat getPageFormat(int pageIndex) { } catch (Exception e) { return null; } - return page; + + return FlipPageFormat.flipPage(page); } private Printable getPrintable(int pageIndex) { @@ -731,7 +732,7 @@ private void printToPathGraphics( final PeekGraphics graphics, // Always an a Graphics2D pathGraphics = new CPrinterGraphics(delegate, printerJob); // Just stores delegate into an ivar Rectangle2D pageFormatArea = getPageFormatArea(page); initPrinterGraphics(pathGraphics, pageFormatArea); - painter.print(pathGraphics, page, pageIndex); + painter.print(pathGraphics, FlipPageFormat.getOriginal(page), pageIndex); delegate.dispose(); delegate = null; } catch (PrinterException pe) { throw new java.lang.reflect.UndeclaredThrowableException(pe); } @@ -758,7 +759,7 @@ private Object[] getPageformatPrintablePeekgraphics(final int pageIndex) { Runnable r = new Runnable() { public void run() { synchronized(ret) { try { Pageable pageable = getPageable(); - PageFormat pageFormat = pageable.getPageFormat(pageIndex); + PageFormat pageFormat = getPageFormat(pageIndex); if (pageFormat != null) { Printable printable = pageable.getPrintable(pageIndex); if (printable != null) { @@ -871,4 +872,75 @@ protected MediaPrintableArea getDefaultPrintableArea(PageFormat page, double w, (float) (paper.getImageableHeight() / dpi), MediaPrintableArea.INCH); } + + // MacOS NSPrintInfo class has one to one correspondence + // between a paper size and its orientation. + // NSPrintInfo with paper width less than height + // has portrait orientation. + // NSPrintInfo with paper width greater than height + // has landscape orientation. + // (w < h) <-> portrait + // (w > h) <-> landscape + // + // Java PageFormat class has the following relation with NSPrintInfo: + // 1. PageFormat: + // page size: width < height + // orientation: portrait + // NSPrintInfo: width < height (portrait orientation) + // 2. PageFormat: + // page size: width < height + // orientation: landscape + // NSPrintInfo: width > height (landscape orientation) + // + // FlipPageFormat class establishes correspondence between + // Java PageFormat class which page width is greater than height + // with NSPrintInfo in the following way: + // 3. PageFormat: + // page size: width > height + // orientation: portrait + // FlipPageFormat + // page size: width < height + // orientation: landscape + // NSPrintInfo: width > height (landscape orientation) + // 4. PageFormat: + // page size: width > height + // orientation: landscape + // FlipPageFormat + // page size: width < height + // orientation: portrait + // NSPrintInfo: width < height (portrait orientation) + // + // FlipPageFormat preserves the original PageFormat class + // to pass it to Printable.print(Graphics, PageFormat, int) + // method overridden by a user. + private static class FlipPageFormat extends PageFormat { + + private final PageFormat original; + + private FlipPageFormat(PageFormat original) { + this.original = original; + Paper paper = original.getPaper(); + Paper copyPaper = this.getPaper(); + copyPaper.setSize(paper.getHeight(), paper.getWidth()); + copyPaper.setImageableArea( + paper.getImageableY(), paper.getImageableX(), + paper.getImageableHeight(), paper.getImageableWidth()); + this.setPaper(copyPaper); + this.setOrientation((original.getOrientation() == PageFormat.PORTRAIT) + ? PageFormat.LANDSCAPE + : PageFormat.PORTRAIT); + } + + private static PageFormat getOriginal(PageFormat page) { + return (page instanceof FlipPageFormat) ? ((FlipPageFormat) page).original : page; + } + + private static PageFormat flipPage(PageFormat page) { + if (page == null) { + return null; + } + Paper paper = page.getPaper(); + return (paper.getWidth() > paper.getHeight()) ? new FlipPageFormat(page) : page; + } + } } diff --git a/test/jdk/java/awt/print/PageFormat/PrintContentCutOffTest.java b/test/jdk/java/awt/print/PageFormat/PrintContentCutOffTest.java new file mode 100644 index 0000000000000..d2362cdc81536 --- /dev/null +++ b/test/jdk/java/awt/print/PageFormat/PrintContentCutOffTest.java @@ -0,0 +1,358 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, BELLSOFT. All rights reserved. + * 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 8295737 + * @summary macOS: Print content cut off when width > height with portrait orientation + * @run main/othervm/manual PrintContentCutOffTest + */ + +import javax.swing.*; +import java.awt.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.font.FontRenderContext; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.File; +import java.io.IOException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import java.awt.print.Book; +import java.awt.image.BufferedImage; +import java.awt.print.Paper; + +import javax.print.PrintServiceLookup; +import javax.print.attribute.Size2DSyntax; +import javax.print.attribute.standard.MediaSize; +import javax.print.attribute.standard.MediaSizeName; + + +public class PrintContentCutOffTest { + + private static final String DESCRIPTION = + + " 1. To run the test it is required to have a virtual PDF printer" + + " or any other printer supporting A4 paper size.\n" + + " 2. Press Print button to print 4 rectangles.\n" + + " - rectangle with paper width is less than height, orientation portrait\n" + + " - rectangle with paper width is less than height, orientation landscape\n" + + " - rectangle with paper width is greater than height, orientation portrait\n" + + " - rectangle with paper width is greater than height, orientation landscape\n" + + " [Note: PageFormat size returns transformed Paper size according to the set orientation value.\n" + + " 3. Check that 4 printed rectangles (one per page) have fully drawn 8 vertical areas\n" + + " labeled from 1 to 8, and that the blue diagonal lines end at the corners of the yellow rectangle.\n" + + " [Note: those are the pass/fail criteria. The messages printed in red are only informative\n" + + " and should not be used as a reason to file a bug].\n" + + " 4. If so, press PASS button, otherwise press FAIL button.\n"; + + + private static final CountDownLatch testEndedSignal = new CountDownLatch(1); + private static final int testTimeout = 300000; + private static volatile String testFailureMsg; + private static volatile boolean testPassed; + private static volatile boolean testFinished; + + private static final double DOC_WIDTH; + private static final double DOC_HEIGHT; + + static { + MediaSize isoA4Size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A4); + float[] size = isoA4Size.getSize(Size2DSyntax.INCH); + + DOC_WIDTH = size[0] * 72.0; + DOC_HEIGHT = size[1] * 72.0; + } + + private static void paintImage(Graphics2D g, PageFormat page, int pageIndex) { + BufferedImage img = createImage(page, pageIndex); + g.drawImage(img, 0, 0, null); + } + + private static void appendToBook(PrinterJob job, Book book, double width, double height, int orientation) { + + PageFormat page = job.getPageFormat(null); + page.setOrientation(orientation); + Paper paper = page.getPaper(); + + paper.setSize(width, height); + paper.setImageableArea(0, 0, width, height); + + page.setPaper(paper); + page.setOrientation(orientation); + book.append(new TestPrintable(), page); + } + + private static void print(double width, double height) throws PrinterException { + PrinterJob job = PrinterJob.getPrinterJob(); + job.setPrintService(PrintServiceLookup.lookupDefaultPrintService()); + + Book book = new Book(); + appendToBook(job, book, width, height, PageFormat.PORTRAIT); + appendToBook(job, book, width, height, PageFormat.LANDSCAPE); + appendToBook(job, book, height, width, PageFormat.PORTRAIT); + appendToBook(job, book, height, width, PageFormat.LANDSCAPE); + + job.setPageable(book); + + if (job.printDialog()) { + job.print(); + } else { + throw new RuntimeException("Printing was canceled!"); + } + } + + private static String getOrientation(int orientation) { + switch (orientation) { + case PageFormat.LANDSCAPE: + return "LANDSCAPE"; + case PageFormat.PORTRAIT: + return "PORTRAIT"; + case PageFormat.REVERSE_LANDSCAPE: + return "REVERSE_LANDSCAPE"; + default: + return "UNKNOWN"; + } + } + + private static BufferedImage createImage(PageFormat page, int pageIndex) { + + int w = (int) page.getWidth(); + int h = (int) page.getHeight(); + + int x = 0; + int y = 0; + + BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); + Graphics2D g = img.createGraphics(); + + g.setClip(null); + + g.setColor(Color.ORANGE); + g.fillRect(x, y, w, h); + + g.setColor(Color.BLUE); + g.drawRect(x, y, w, h); + g.drawRect(x + 1, y + 1, w - 2, h - 2); + g.drawLine(x, y, x + w, y + h); + g.drawLine(x, y + h, x + w, y); + + g.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); + + int N = 8; + int dx = w / N; + + for (int i = 0; i < N; i++) { + int xx = i * dx + x; + g.setColor(Color.BLUE); + g.drawLine(xx, y, xx, y + h); + g.setColor(Color.BLUE); + g.drawString("" + (i + 1), xx + 3, y + h / 2); + } + + int NN = 5; + int arrX = x + w / 2 - 4; + g.setColor(Color.RED); + for (int i = 0; i < NN; i++) { + g.drawLine(arrX + i, y + h / 3, arrX + i, y + 2 * h / 3); + } + + int r = 7; + g.fillOval(arrX + NN / 2 - r, y + h / 3 - r - 5, 2 * r, 2 * r); + + g.setColor(Color.RED); + g.setFont(g.getFont().deriveFont(Font.BOLD, 16.0f)); + + int textX = x + w / 18; + int textY = y + h / 3; + int textDelta = h / 16; + + Paper paper = page.getPaper(); + String paperSize = String.format("Paper size: %dx%d", + (int) paper.getWidth(), (int) paper.getHeight()); + g.drawString(paperSize, textX, textY); + + String pageFormatSize = String.format("PageFormat size: %dx%d", w, h); + g.drawString(pageFormatSize, textX, textY + textDelta); + + String orientation = String.format("Orientation: %s", + getOrientation(page.getOrientation())); + g.drawString(orientation, textX, textY + 2 * textDelta); + + g.setColor(Color.BLACK); + g.setFont(g.getFont().deriveFont(28.0f)); + g.drawString(String.format("P:%d", pageIndex + 1), x + w / 2, y + 2 * h / 3); + + g.dispose(); + return img; + } + + private static class TestPrintable implements Printable { + + @Override + public int print(Graphics graphics, PageFormat pageFormat, int index) { + paintImage((Graphics2D) graphics, pageFormat, index); + return PAGE_EXISTS; + } + } + + public static void main(String[] args) throws Exception { + + SwingUtilities.invokeLater(() -> createAndShowTestDialog()); + + try { + if (!testEndedSignal.await(testTimeout, TimeUnit.MILLISECONDS)) { + throw new RuntimeException(String.format( + "Test timeout '%d ms' elapsed.", testTimeout)); + } + if (!testPassed) { + String failureMsg = testFailureMsg; + if ((failureMsg != null) && (!failureMsg.trim().isEmpty())) { + throw new RuntimeException(failureMsg); + } else { + throw new RuntimeException("Test failed."); + } + } + } catch (InterruptedException ie) { + throw new RuntimeException(ie); + } finally { + testFinished = true; + } + } + + private static void pass() { + testPassed = true; + testEndedSignal.countDown(); + } + + private static void fail(String failureMsg) { + testFailureMsg = failureMsg; + testPassed = false; + testEndedSignal.countDown(); + } + + private static String convertMillisToTimeStr(int millis) { + if (millis < 0) { + return "00:00:00"; + } + int hours = millis / 3600000; + int minutes = (millis - hours * 3600000) / 60000; + int seconds = (millis - hours * 3600000 - minutes * 60000) / 1000; + return String.format("%02d:%02d:%02d", hours, minutes, seconds); + } + + private static void createAndShowTestDialog() { + + final JDialog dialog = new JDialog(); + dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + dialog.dispose(); + fail("Main dialog was closed."); + } + }); + + final JLabel testTimeoutLabel = new JLabel(String.format( + "Test timeout: %s", convertMillisToTimeStr(testTimeout))); + final long startTime = System.currentTimeMillis(); + final Timer timer = new Timer(0, null); + timer.setDelay(1000); + timer.addActionListener((e) -> { + int leftTime = testTimeout - (int) (System.currentTimeMillis() - startTime); + if ((leftTime < 0) || testFinished) { + timer.stop(); + dialog.dispose(); + } + testTimeoutLabel.setText(String.format( + "Test timeout: %s", convertMillisToTimeStr(leftTime))); + }); + timer.start(); + + JTextArea textArea = new JTextArea(DESCRIPTION); + textArea.setEditable(false); + + final JButton testButton = new JButton("Print"); + final JButton passButton = new JButton("PASS"); + final JButton failButton = new JButton("FAIL"); + + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + new Thread(() -> { + try { + doTest(); + + SwingUtilities.invokeLater(() -> { + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + } catch (Throwable t) { + t.printStackTrace(); + dialog.dispose(); + fail("Exception occurred in a thread executing the test."); + } + }).start(); + }); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail("TitledBorder label is cut off"); + }); + + JPanel mainPanel = new JPanel(new BorderLayout()); + + JPanel labelPanel = new JPanel(new FlowLayout()); + labelPanel.add(testTimeoutLabel); + mainPanel.add(labelPanel, BorderLayout.NORTH); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + + dialog.pack(); + dialog.setVisible(true); + } + + private static void doTest() throws Exception { + SwingUtilities.invokeAndWait(() -> { + try { + print(DOC_WIDTH, DOC_HEIGHT); + } catch (PrinterException e) { + throw new RuntimeException(e); + } + }); + } +} From 47ed2e5b266b816b0566c537c51f7c502f6c293b Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Mon, 28 Aug 2023 15:13:25 +0000 Subject: [PATCH 058/341] 8311033: [macos] PrinterJob does not take into account Sides attribute Backport-of: a3d67231a71fbe37c509fcedd54c679b4644c0d9 --- .../classes/sun/lwawt/macosx/CPrinterJob.java | 19 ++ .../native/libawt_lwawt/awt/CPrinterJob.m | 42 +++ .../classes/sun/print/RasterPrinterJob.java | 2 + .../print/attribute/SidesAttributeTest.java | 272 ++++++++++++++++++ 4 files changed, 335 insertions(+) create mode 100644 test/jdk/javax/print/attribute/SidesAttributeTest.java diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java index 1931b8e3dd696..671ecae0184c8 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java @@ -45,6 +45,7 @@ import javax.print.attribute.standard.MediaSize; import javax.print.attribute.standard.MediaSizeName; import javax.print.attribute.standard.PageRanges; +import javax.print.attribute.standard.Sides; import javax.print.attribute.Attribute; import sun.java2d.*; @@ -684,6 +685,24 @@ private Rectangle2D getPageFormatArea(PageFormat page) { return pageFormatArea; } + private int getSides() { + return (this.sidesAttr == null) ? -1 : this.sidesAttr.getValue(); + } + + private void setSides(int sides) { + if (attributes == null) { + return; + } + + final Sides[] sidesTable = new Sides[] {Sides.ONE_SIDED, Sides.TWO_SIDED_LONG_EDGE, Sides.TWO_SIDED_SHORT_EDGE}; + + if (sides >= 0 && sides < sidesTable.length) { + Sides s = sidesTable[sides]; + attributes.add(s); + this.sidesAttr = s; + } + } + private boolean cancelCheck() { // This is called from the native side. diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m index db5c192c6c813..545138de71739 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m @@ -37,6 +37,10 @@ #import "GeomUtilities.h" #import "JNIUtilities.h" +#define ONE_SIDED 0 +#define TWO_SIDED_LONG_EDGE 1 +#define TWO_SIDED_SHORT_EDGE 2 + static jclass sjc_Paper = NULL; static jclass sjc_PageFormat = NULL; static jclass sjc_CPrinterJob = NULL; @@ -351,6 +355,24 @@ static void javaPageFormatToNSPrintInfo(JNIEnv* env, jobject srcPrintJob, jobjec [dstPrintInfo setPrinter:printer]; } +static jint duplexModeToSides(PMDuplexMode duplexMode) { + switch(duplexMode) { + case kPMDuplexNone: return ONE_SIDED; + case kPMDuplexTumble: return TWO_SIDED_SHORT_EDGE; + case kPMDuplexNoTumble: return TWO_SIDED_LONG_EDGE; + default: return -1; + } +} + +static PMDuplexMode sidesToDuplexMode(jint sides) { + switch(sides) { + case ONE_SIDED: return kPMDuplexNone; + case TWO_SIDED_SHORT_EDGE: return kPMDuplexTumble; + case TWO_SIDED_LONG_EDGE: return kPMDuplexNoTumble; + default: return kPMDuplexNone; + } +} + static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject dstPrinterJob, jobject dstPageable) { GET_CPRINTERJOB_CLASS(); @@ -360,6 +382,7 @@ static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject d DECLARE_METHOD(jm_setPageRangeAttribute, sjc_CPrinterJob, "setPageRangeAttribute", "(IIZ)V"); DECLARE_METHOD(jm_setPrintToFile, sjc_CPrinterJob, "setPrintToFile", "(Z)V"); DECLARE_METHOD(jm_setDestinationFile, sjc_CPrinterJob, "setDestinationFile", "(Ljava/lang/String;)V"); + DECLARE_METHOD(jm_setSides, sjc_CPrinterJob, "setSides", "(I)V"); // get the selected printer's name, and set the appropriate PrintService on the Java side NSString *name = [[src printer] name]; @@ -420,6 +443,12 @@ static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject d jFirstPage, jLastPage, isRangeSet); // AWT_THREADING Safe (known object) CHECK_EXCEPTION(); + PMDuplexMode duplexSetting; + if (PMGetDuplex(src.PMPrintSettings, &duplexSetting) == noErr) { + jint sides = duplexModeToSides(duplexSetting); + (*env)->CallVoidMethod(env, dstPrinterJob, jm_setSides, sides); // AWT_THREADING Safe (known object) + CHECK_EXCEPTION(); + } } } @@ -438,6 +467,8 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj DECLARE_METHOD(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I"); DECLARE_METHOD(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;"); DECLARE_METHOD(jm_getDestinationFile, sjc_CPrinterJob, "getDestinationFile", "()Ljava/lang/String;"); + DECLARE_METHOD(jm_getSides, sjc_CPrinterJob, "getSides", "()I"); + NSMutableDictionary* printingDictionary = [dst dictionary]; @@ -496,6 +527,17 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj } else { [dst setJobDisposition:NSPrintSpoolJob]; } + + jint sides = (*env)->CallIntMethod(env, srcPrinterJob, jm_getSides); + CHECK_EXCEPTION(); + + if (sides >= 0) { + PMDuplexMode duplexMode = sidesToDuplexMode(sides); + PMPrintSettings printSettings = dst.PMPrintSettings; + if (PMSetDuplex(printSettings, duplexMode) == noErr) { + [dst updateFromPMPrintSettings]; + } + } } /* diff --git a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java index 28f493c423e19..bfbb24463d4d2 100644 --- a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java +++ b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java @@ -1082,6 +1082,8 @@ public PrintService[] run() { return false; } + this.attributes = attributes; + if (!service.equals(newService)) { try { setPrintService(newService); diff --git a/test/jdk/javax/print/attribute/SidesAttributeTest.java b/test/jdk/javax/print/attribute/SidesAttributeTest.java new file mode 100644 index 0000000000000..60454f304076d --- /dev/null +++ b/test/jdk/javax/print/attribute/SidesAttributeTest.java @@ -0,0 +1,272 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, BELLSOFT. All rights reserved. + * 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 JDK-8311033 + * @summary [macos] PrinterJob does not take into account Sides attribute + * @run main/manual SidesAttributeTest + */ + +import javax.print.PrintService; +import javax.print.attribute.Attribute; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.Sides; +import javax.swing.*; +import java.awt.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +public class SidesAttributeTest { + + private static final long TIMEOUT = 10 * 60_000; + private static volatile boolean testPassed = true; + private static volatile boolean testFinished = false; + private static volatile boolean timeout = false; + + private static volatile int testCount; + private static volatile int testTotalCount; + + public static void main(String[] args) throws Exception { + + SwingUtilities.invokeLater(() -> { + + Set supportedSides = getSupportedSidesAttributes(); + if (supportedSides.size() > 1) { + testTotalCount = supportedSides.size(); + testPrint(Sides.ONE_SIDED, supportedSides); + testPrint(Sides.DUPLEX, supportedSides); + testPrint(Sides.TUMBLE, supportedSides); + } + testFinished = true; + }); + + long time = System.currentTimeMillis() + TIMEOUT; + + while (System.currentTimeMillis() < time) { + if (!testPassed || testFinished) { + break; + } + Thread.sleep(500); + } + + timeout = true; + + closeDialogs(); + + if (!testPassed) { + throw new Exception("Test failed!"); + } + + if (testCount != testTotalCount) { + throw new Exception( + "Timeout: " + testCount + " tests passed out from " + testTotalCount); + } + } + + private static void print(Sides sides) throws PrinterException { + PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet(); + attr.add(sides); + + for (Attribute attribute : attr.toArray()) { + System.out.printf("Used print request attribute: %s%n", attribute); + } + + PrinterJob job = PrinterJob.getPrinterJob(); + job.setPrintable(new SidesAttributePrintable(sides)); + + job.print(attr); + } + + private static class SidesAttributePrintable implements Printable { + + private final Sides sidesAttr; + + public SidesAttributePrintable(Sides sidesAttr) { + this.sidesAttr = sidesAttr; + } + + @Override + public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { + + if (pageIndex >= 2) { + return NO_SUCH_PAGE; + } + + int x = (int) (pageFormat.getImageableX() + pageFormat.getImageableWidth() / 10); + int y = (int) (pageFormat.getImageableY() + pageFormat.getImageableHeight() / 5); + + Graphics2D g = (Graphics2D) graphics; + String text = getPageText(sidesAttr, pageIndex + 1); + g.drawString(text, x, y); + return PAGE_EXISTS; + } + } + + private static String getPageText(Sides sides, int page) { + return String.format("Page: %d - %s", page, getSidesText(sides)); + } + + private static String getSidesText(Sides sides) { + if (Sides.ONE_SIDED.equals(sides)) { + return "ONE_SIDED"; + } else if (Sides.TWO_SIDED_SHORT_EDGE.equals(sides)) { + return "TWO_SIDED_SHORT_EDGE (TUMBLE)"; + } else if (Sides.TWO_SIDED_LONG_EDGE.equals(sides)) { + return "TWO_SIDED_LONG_EDGE (DUPLEX)"; + } + throw new RuntimeException("Unknown sides attribute: " + sides); + } + + private static String getSidesDescription(Sides sides) { + if (Sides.ONE_SIDED.equals(sides)) { + return "a one-sided document"; + } else if (Sides.TWO_SIDED_SHORT_EDGE.equals(sides)) { + return "double-sided document along the short edge of the paper"; + } else if (Sides.TWO_SIDED_LONG_EDGE.equals(sides)) { + return "double-sided document along the long edge of the paper"; + } + throw new RuntimeException("Unknown sides attribute: " + sides); + } + + private static Set getSupportedSidesAttributes() { + Set supportedSides = new HashSet<>(); + + PrinterJob printerJob = PrinterJob.getPrinterJob(); + PrintService service = printerJob.getPrintService(); + + Object obj = service.getSupportedAttributeValues(Sides.class, null, null); + if (obj instanceof Attribute[]) { + Attribute[] attr = (Attribute[]) obj; + Collections.addAll(supportedSides, attr); + } + + return supportedSides; + } + + private static void pass() { + testCount++; + } + + private static void fail(Sides sides) { + System.out.printf("Failed test: %s%n", getSidesText(sides)); + testPassed = false; + } + + private static void runPrint(Sides sides) { + try { + print(sides); + } catch (PrinterException e) { + fail(sides); + e.printStackTrace(); + } + } + + private static void testPrint(Sides sides, Set supportedSides) { + + if (!supportedSides.contains(sides) || !testPassed || timeout) { + return; + } + + String[] instructions = { + "Up to " + testTotalCount + " tests will run and it will test all the cases", + "supported by the printer.", + "", + "The test is " + (testCount + 1) + " from " + testTotalCount + ".", + "", + "On-screen inspection is not possible for this printing-specific", + "test therefore its only output is two printed pages (one or two sided).", + "To be able to run this test it is required to have a default", + "printer configured in your user environment.", + "", + "Visual inspection of the printed pages is needed.", + "A passing test will print 2 pages:", + " - the first page with the text: " + getPageText(sides, 1), + " - the second page with the text: " + getPageText(sides, 2), + "", + "The test fails if the pages are not printed according to the tested", + getSidesText(sides) + " attribute where " + getSidesDescription(sides), + "needs to be printed.", + "", + }; + + String title = String.format("Print %s sides test: %d from %d", + getSidesText(sides), testCount + 1, testTotalCount); + final JDialog dialog = new JDialog((Frame) null, title, Dialog.ModalityType.DOCUMENT_MODAL); + JTextArea textArea = new JTextArea(String.join("\n", instructions)); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + pass(); + dialog.dispose(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + fail(sides); + dialog.dispose(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + runPrint(sides); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("Dialog closing"); + fail(sides); + } + }); + } + + private static void closeDialogs() { + for (Window w : Dialog.getWindows()) { + w.dispose(); + } + } +} From 1d65a31dd43f69599d05c34ca19c49e0caba504a Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Tue, 29 Aug 2023 02:28:54 +0000 Subject: [PATCH 059/341] 8284772: GHA: Use GCC Major Version Dependencies Only Reviewed-by: shade Backport-of: 62defc3dfc4b9ba5adfe3189f34fe8b3f59b94a0 --- .github/workflows/build-cross-compile.yml | 14 ++++---------- .github/workflows/build-linux.yml | 5 +---- .github/workflows/main.yml | 8 -------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 697f2d7ea672c..a1d216922b70c 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -31,12 +31,6 @@ on: gcc-major-version: required: true type: string - apt-gcc-version: - required: true - type: string - apt-gcc-cross-version: - required: true - type: string extra-conf-options: required: false type: string @@ -113,10 +107,10 @@ jobs: sudo apt-get update sudo apt-get install --only-upgrade apt sudo apt-get install \ - gcc-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ - g++-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ - gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ - g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ + gcc-${{ inputs.gcc-major-version }} \ + g++-${{ inputs.gcc-major-version }} \ + gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} \ + g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} \ libxrandr-dev libxtst-dev libcups2-dev libasound2-dev sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }} diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 2f6368123d956..3ffa6170c7e2a 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -49,9 +49,6 @@ on: required: false type: string default: '' - apt-gcc-version: - required: true - type: string apt-architecture: required: false type: string @@ -114,7 +111,7 @@ jobs: fi sudo apt-get update sudo apt-get install --only-upgrade apt - sudo apt-get install gcc-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }}=${{ inputs.apt-gcc-version }} g++-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }}=${{ inputs.apt-gcc-version }} libxrandr-dev${{ steps.arch.outputs.suffix }} libxtst-dev${{ steps.arch.outputs.suffix }} libcups2-dev${{ steps.arch.outputs.suffix }} libasound2-dev${{ steps.arch.outputs.suffix }} ${{ inputs.apt-extra-packages }} + sudo apt-get install gcc-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} g++-${{ inputs.gcc-major-version }}${{ inputs.gcc-package-suffix }} libxrandr-dev${{ steps.arch.outputs.suffix }} libxtst-dev${{ steps.arch.outputs.suffix }} libcups2-dev${{ steps.arch.outputs.suffix }} libasound2-dev${{ steps.arch.outputs.suffix }} ${{ inputs.apt-extra-packages }} sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }} - name: 'Configure' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 05ceaa441feec..10f704fd27f31 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -128,7 +128,6 @@ jobs: with: platform: linux-x64 gcc-major-version: '10' - apt-gcc-version: '10.5.0-1ubuntu1~22.04' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} # The linux-x64 jdk bundle is used as buildjdk for the cross-compile job @@ -142,7 +141,6 @@ jobs: platform: linux-x86 gcc-major-version: '10' gcc-package-suffix: '-multilib' - apt-gcc-version: '10.5.0-1ubuntu1~22.04' apt-architecture: 'i386' # Some multilib libraries do not have proper inter-dependencies, so we have to # install their dependencies manually. @@ -161,7 +159,6 @@ jobs: make-target: 'hotspot' debug-levels: '[ "debug" ]' gcc-major-version: '10' - apt-gcc-version: '10.5.0-1ubuntu1~22.04' extra-conf-options: '--disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} @@ -176,7 +173,6 @@ jobs: make-target: 'hotspot' debug-levels: '[ "debug" ]' gcc-major-version: '10' - apt-gcc-version: '10.5.0-1ubuntu1~22.04' extra-conf-options: '--with-jvm-variants=zero --disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} @@ -191,7 +187,6 @@ jobs: make-target: 'hotspot' debug-levels: '[ "debug" ]' gcc-major-version: '10' - apt-gcc-version: '10.5.0-1ubuntu1~22.04' extra-conf-options: '--with-jvm-variants=minimal --disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} @@ -207,7 +202,6 @@ jobs: # Technically this is not the "debug" level, but we can't inject a new matrix state for just this job debug-levels: '[ "debug" ]' gcc-major-version: '10' - apt-gcc-version: '10.5.0-1ubuntu1~22.04' extra-conf-options: '--with-debug-level=optimized --disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} @@ -221,8 +215,6 @@ jobs: uses: ./.github/workflows/build-cross-compile.yml with: gcc-major-version: '10' - apt-gcc-version: '10.5.0-1ubuntu1~22.04' - apt-gcc-cross-version: '10.5.0-1ubuntu1~22.04cross1' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.linux-cross-compile == 'true' From d82de1c7aba95f7922434d485a9cf4761b71574d Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Tue, 29 Aug 2023 07:30:51 +0000 Subject: [PATCH 060/341] 8314517: some tests fail in case ipv6 is disabled on the machine Reviewed-by: mdoerr Backport-of: 703817d21f6fd8b24cc670695625dfdb09d3592c --- .../InetAddress/HostsFileOrderingTest.java | 7 ++++ .../InetAddress/InternalNameServiceTest.java | 25 ++++++------ .../InternalNameServiceWithHostsFileTest.java | 39 ++++++++++++------- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/test/jdk/java/net/InetAddress/HostsFileOrderingTest.java b/test/jdk/java/net/InetAddress/HostsFileOrderingTest.java index 9d51ebc436099..304180b6c489e 100644 --- a/test/jdk/java/net/InetAddress/HostsFileOrderingTest.java +++ b/test/jdk/java/net/InetAddress/HostsFileOrderingTest.java @@ -32,6 +32,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import jdk.test.lib.net.IPSupport; + import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.testng.Assert; @@ -39,6 +41,8 @@ /* @test * @bug 8244958 + * @library /test/lib + * @build jdk.test.lib.Platform jdk.test.lib.net.IPSupport * @summary Test that "jdk.net.hosts.file" NameService implementation returns addresses * with respect to "java.net.preferIPv4Stack" and "java.net.preferIPv6Addresses" system * property values @@ -106,6 +110,9 @@ static ExpectedOrder getExpectedOrderFromSystemProperties() { PREFER_IPV4_STACK_VALUE.equalsIgnoreCase("true")) { return ExpectedOrder.IPV4_ONLY; } + if (!IPSupport.hasIPv6()) { + return ExpectedOrder.IPV4_ONLY; + } if (PREFER_IPV6_ADDRESSES_VALUE != null) { return switch(PREFER_IPV6_ADDRESSES_VALUE.toLowerCase()) { diff --git a/test/jdk/java/net/InetAddress/InternalNameServiceTest.java b/test/jdk/java/net/InetAddress/InternalNameServiceTest.java index f8aff3f90a4d6..2122f2ab47ce2 100644 --- a/test/jdk/java/net/InetAddress/InternalNameServiceTest.java +++ b/test/jdk/java/net/InetAddress/InternalNameServiceTest.java @@ -27,6 +27,8 @@ * the system property jdk.net.hosts.file. This property specifies * a file name that contains address host mappings, similar to those in * /etc/hosts file. + * @library /test/lib + * @build jdk.test.lib.net.IPSupport * @run main/othervm -Djdk.net.hosts.file=TestHosts -Dsun.net.inetaddr.ttl=0 * InternalNameServiceTest */ @@ -38,6 +40,8 @@ import java.net.UnknownHostException; import java.util.Arrays; +import jdk.test.lib.net.IPSupport; + public class InternalNameServiceTest { static final String HOSTS_FILE_NAME = System.getProperty("jdk.net.hosts.file"); @@ -128,17 +132,16 @@ private static void testHostToIPAddressMappings(String hostsFileName) } // IPV6 tests - - // IPV6 tests - addMappingToHostsFile("host-ipv6.sample-domain", "::1", hostsFileName, - true); - testAddress = InetAddress.getByName("host-ipv6.sample-domain"); - retrievedIpAddr = testAddress.getAddress(); - if (!Arrays.equals(retrievedIpAddr, expectedIpAddrIpv6_1)) { - System.out.println("retrieved ipv6 addr == " + Arrays.toString(retrievedIpAddr)); - System.out.println("expected ipv6 addr == " + Arrays.toString(expectedIpAddrIpv6_1)); - throw new RuntimeException( - "retrieved IPV6 Addr not equal to expected IPV6 Addr"); + if (IPSupport.hasIPv6()) { + addMappingToHostsFile("host-ipv6.sample-domain", "::1", hostsFileName, true); + testAddress = InetAddress.getByName("host-ipv6.sample-domain"); + retrievedIpAddr = testAddress.getAddress(); + if (!Arrays.equals(retrievedIpAddr, expectedIpAddrIpv6_1)) { + System.out.println("retrieved ipv6 addr == " + Arrays.toString(retrievedIpAddr)); + System.out.println("expected ipv6 addr == " + Arrays.toString(expectedIpAddrIpv6_1)); + throw new RuntimeException( + "retrieved IPV6 Addr not equal to expected IPV6 Addr"); + } } } diff --git a/test/jdk/java/net/InetAddress/InternalNameServiceWithHostsFileTest.java b/test/jdk/java/net/InetAddress/InternalNameServiceWithHostsFileTest.java index 4e93ab8d7a8b7..35953195ea3c7 100644 --- a/test/jdk/java/net/InetAddress/InternalNameServiceWithHostsFileTest.java +++ b/test/jdk/java/net/InetAddress/InternalNameServiceWithHostsFileTest.java @@ -28,6 +28,8 @@ * a file name that contains address host mappings, similar to those in * /etc/hosts file. TestHosts-III file exist, with a set of ipv4 and ipv6 * mappings + * @library /test/lib + * @build jdk.test.lib.net.IPSupport * @run main/othervm -Djdk.net.hosts.file=${test.src}/TestHosts-III -Dsun.net.inetaddr.ttl=0 * InternalNameServiceWithHostsFileTest */ @@ -36,6 +38,8 @@ import java.net.UnknownHostException; import java.util.Arrays; +import jdk.test.lib.net.IPSupport; + public class InternalNameServiceWithHostsFileTest { public static void main(String args[]) throws Exception { // fe80::1 @@ -52,26 +56,31 @@ public static void main(String args[]) throws Exception { // 10.2.3.4 testHost.testDomain testHostsMapping(expectedIpv4Address, "testHost.testDomain"); - // ::1 ip6-localhost ip6-loopback - testHostsMapping(expectedIpv6LocalhostAddress, "ip6-localhost"); - // fe00::0 ip6-localnet - testHostsMapping(expectedIpv6LocalAddress, "ip6-localnet"); - // fe80::1 link-local-host - testHostsMapping(expectedIpv6Address, "link-local-host"); + + if (IPSupport.hasIPv6()) { + // ::1 ip6-localhost ip6-loopback + testHostsMapping(expectedIpv6LocalhostAddress, "ip6-localhost"); + // fe00::0 ip6-localnet + testHostsMapping(expectedIpv6LocalAddress, "ip6-localnet"); + // fe80::1 link-local-host + testHostsMapping(expectedIpv6Address, "link-local-host"); + } testReverseLookup("10.2.3.4", "testHost.testDomain"); - testReverseLookup("::1", "ip6-localhost"); - testReverseLookup("0:0:0:0:0:0:0:1", "ip6-localhost"); - testReverseLookup("0000:0000:0000:0000:0000:0000:0000:0001", "ip6-localhost"); + if (IPSupport.hasIPv6()) { + testReverseLookup("::1", "ip6-localhost"); + testReverseLookup("0:0:0:0:0:0:0:1", "ip6-localhost"); + testReverseLookup("0000:0000:0000:0000:0000:0000:0000:0001", "ip6-localhost"); - testReverseLookup("fe00::0", "ip6-localnet"); - testReverseLookup("fe00:0:0:0:0:0:0:0", "ip6-localnet"); - testReverseLookup("fe00:0000:0000:0000:0000:0000:0000:0000", "ip6-localnet"); + testReverseLookup("fe00::0", "ip6-localnet"); + testReverseLookup("fe00:0:0:0:0:0:0:0", "ip6-localnet"); + testReverseLookup("fe00:0000:0000:0000:0000:0000:0000:0000", "ip6-localnet"); - testReverseLookup("fe80::1", "link-local-host"); - testReverseLookup("fe80:000:0:00:0:000:00:1", "link-local-host"); - testReverseLookup("fe80:0000:0000:0000:0000:0000:0000:0001", "link-local-host"); + testReverseLookup("fe80::1", "link-local-host"); + testReverseLookup("fe80:000:0:00:0:000:00:1", "link-local-host"); + testReverseLookup("fe80:0000:0000:0000:0000:0000:0000:0001", "link-local-host"); + } } private static void testHostsMapping(byte[] expectedIpAddress, String hostName) From c91fb3f7a51461e24fee53187543333b1455accb Mon Sep 17 00:00:00 2001 From: Oli Gillespie Date: Tue, 29 Aug 2023 15:08:37 +0000 Subject: [PATCH 061/341] 8313874: JNI NewWeakGlobalRef throws exception for null arg Reviewed-by: phh Backport-of: 028b3ae1b162bd8f7c340bfa6e9487ca83697955 --- src/hotspot/share/prims/jni.cpp | 2 +- .../jtreg/runtime/jni/ReturnJNIWeak/ReturnJNIWeak.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp index 68a29f8bc7890..f5de70e28c1e3 100644 --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -2918,7 +2918,7 @@ JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref)) HOTSPOT_JNI_NEWWEAKGLOBALREF_ENTRY(env, ref); Handle ref_handle(thread, JNIHandles::resolve(ref)); jweak ret = JNIHandles::make_weak_global(ref_handle, AllocFailStrategy::RETURN_NULL); - if (ret == NULL) { + if (ret == NULL && ref_handle.not_null()) { THROW_OOP_(Universe::out_of_memory_error_c_heap(), NULL); } HOTSPOT_JNI_NEWWEAKGLOBALREF_RETURN(ret); diff --git a/test/hotspot/jtreg/runtime/jni/ReturnJNIWeak/ReturnJNIWeak.java b/test/hotspot/jtreg/runtime/jni/ReturnJNIWeak/ReturnJNIWeak.java index 2753024957735..e41a2a087e1ec 100644 --- a/test/hotspot/jtreg/runtime/jni/ReturnJNIWeak/ReturnJNIWeak.java +++ b/test/hotspot/jtreg/runtime/jni/ReturnJNIWeak/ReturnJNIWeak.java @@ -123,9 +123,19 @@ private static void testClear() throws Exception { } } + // Verify passing a null value returns null and doesn't throw. + private static void testNullValue() { + System.out.println("running testNullValue"); + registerObject(null); + if (getObject() != null) { + throw new RuntimeException("expected null"); + } + } + public static void main(String[] args) throws Exception { testSanity(); testSurvival(); testClear(); + testNullValue(); } } From a75e5de8ed4fe1f66e0c6dc714f54f2ef38c8c8d Mon Sep 17 00:00:00 2001 From: Oli Gillespie Date: Tue, 29 Aug 2023 15:10:50 +0000 Subject: [PATCH 062/341] 8313678: SymbolTable can leak Symbols during cleanup Reviewed-by: phh, shade Backport-of: 4b2703ad39f8160264eb30c797824cc93a6b56e2 --- src/hotspot/share/classfile/stringTable.cpp | 17 +++++++++++------ src/hotspot/share/classfile/symbolTable.cpp | 11 ++++++++--- src/hotspot/share/prims/resolvedMethodTable.cpp | 8 +++++--- src/hotspot/share/services/threadIdTable.cpp | 5 ++++- .../utilities/concurrentHashTable.inline.hpp | 12 ++++-------- .../gtest/classfile/test_symbolTable.cpp | 14 ++++++++++++++ .../utilities/test_concurrentHashtable.cpp | 10 ++++++++-- 7 files changed, 54 insertions(+), 23 deletions(-) diff --git a/src/hotspot/share/classfile/stringTable.cpp b/src/hotspot/share/classfile/stringTable.cpp index 72c503415dc33..1ace527d18d3a 100644 --- a/src/hotspot/share/classfile/stringTable.cpp +++ b/src/hotspot/share/classfile/stringTable.cpp @@ -151,11 +151,9 @@ class StringTableLookupJchar : StackObj { uintx get_hash() const { return _hash; } - bool equals(WeakHandle* value, bool* is_dead) { + bool equals(WeakHandle* value) { oop val_oop = value->peek(); if (val_oop == NULL) { - // dead oop, mark this hash dead for cleaning - *is_dead = true; return false; } bool equals = java_lang_String::equals(val_oop, _str, _len); @@ -166,6 +164,10 @@ class StringTableLookupJchar : StackObj { _found = Handle(_thread, value->resolve()); return true; } + bool is_dead(WeakHandle* value) { + oop val_oop = value->peek(); + return val_oop == NULL; + } }; class StringTableLookupOop : public StackObj { @@ -183,11 +185,9 @@ class StringTableLookupOop : public StackObj { return _hash; } - bool equals(WeakHandle* value, bool* is_dead) { + bool equals(WeakHandle* value) { oop val_oop = value->peek(); if (val_oop == NULL) { - // dead oop, mark this hash dead for cleaning - *is_dead = true; return false; } bool equals = java_lang_String::equals(_find(), val_oop); @@ -198,6 +198,11 @@ class StringTableLookupOop : public StackObj { _found = Handle(_thread, value->resolve()); return true; } + + bool is_dead(WeakHandle* value) { + oop val_oop = value->peek(); + return val_oop == NULL; + } }; static size_t ceil_log2(size_t val) { diff --git a/src/hotspot/share/classfile/symbolTable.cpp b/src/hotspot/share/classfile/symbolTable.cpp index bf0d8754c5628..3e3f949ae8a67 100644 --- a/src/hotspot/share/classfile/symbolTable.cpp +++ b/src/hotspot/share/classfile/symbolTable.cpp @@ -373,7 +373,11 @@ class SymbolTableLookup : StackObj { uintx get_hash() const { return _hash; } - bool equals(Symbol** value, bool* is_dead) { + // Note: When equals() returns "true", the symbol's refcount is incremented. This is + // needed to ensure that the symbol is kept alive before equals() returns to the caller, + // so that another thread cannot clean the symbol up concurrently. The caller is + // responsible for decrementing the refcount, when the symbol is no longer needed. + bool equals(Symbol** value) { assert(value != NULL, "expected valid value"); assert(*value != NULL, "value should point to a symbol"); Symbol *sym = *value; @@ -383,14 +387,15 @@ class SymbolTableLookup : StackObj { return true; } else { assert(sym->refcount() == 0, "expected dead symbol"); - *is_dead = true; return false; } } else { - *is_dead = (sym->refcount() == 0); return false; } } + bool is_dead(Symbol** value) { + return (*value)->refcount() == 0; + } }; class SymbolTableGet : public StackObj { diff --git a/src/hotspot/share/prims/resolvedMethodTable.cpp b/src/hotspot/share/prims/resolvedMethodTable.cpp index 215cf8e31ef81..c495209750bfc 100644 --- a/src/hotspot/share/prims/resolvedMethodTable.cpp +++ b/src/hotspot/share/prims/resolvedMethodTable.cpp @@ -126,11 +126,9 @@ class ResolvedMethodTableLookup : StackObj { uintx get_hash() const { return _hash; } - bool equals(WeakHandle* value, bool* is_dead) { + bool equals(WeakHandle* value) { oop val_oop = value->peek(); if (val_oop == NULL) { - // dead oop, mark this hash dead for cleaning - *is_dead = true; return false; } bool equals = _method == java_lang_invoke_ResolvedMethodName::vmtarget(val_oop); @@ -141,6 +139,10 @@ class ResolvedMethodTableLookup : StackObj { _found = Handle(_thread, value->resolve()); return true; } + bool is_dead(WeakHandle* value) { + oop val_oop = value->peek(); + return val_oop == NULL; + } }; diff --git a/src/hotspot/share/services/threadIdTable.cpp b/src/hotspot/share/services/threadIdTable.cpp index c108907854ebc..ffb29a81e70bb 100644 --- a/src/hotspot/share/services/threadIdTable.cpp +++ b/src/hotspot/share/services/threadIdTable.cpp @@ -192,13 +192,16 @@ class ThreadIdTableLookup : public StackObj { uintx get_hash() const { return _hash; } - bool equals(ThreadIdTableEntry** value, bool* is_dead) { + bool equals(ThreadIdTableEntry** value) { bool equals = primitive_equals(_tid, (*value)->tid()); if (!equals) { return false; } return true; } + bool is_dead(ThreadIdTableEntry** value) { + return false; + } }; class ThreadGet : public StackObj { diff --git a/src/hotspot/share/utilities/concurrentHashTable.inline.hpp b/src/hotspot/share/utilities/concurrentHashTable.inline.hpp index 660cdaa9d1b34..8e8d3a7f26857 100644 --- a/src/hotspot/share/utilities/concurrentHashTable.inline.hpp +++ b/src/hotspot/share/utilities/concurrentHashTable.inline.hpp @@ -451,9 +451,8 @@ inline bool ConcurrentHashTable:: assert(bucket->is_locked(), "Must be locked."); Node* const volatile * rem_n_prev = bucket->first_ptr(); Node* rem_n = bucket->first(); - bool have_dead = false; while (rem_n != NULL) { - if (lookup_f.equals(rem_n->value(), &have_dead)) { + if (lookup_f.equals(rem_n->value())) { bucket->release_assign_node_ptr(rem_n_prev, rem_n->next()); break; } else { @@ -540,9 +539,7 @@ inline void ConcurrentHashTable:: Node* const volatile * rem_n_prev = bucket->first_ptr(); Node* rem_n = bucket->first(); while (rem_n != NULL) { - bool is_dead = false; - lookup_f.equals(rem_n->value(), &is_dead); - if (is_dead) { + if (lookup_f.is_dead(rem_n->value())) { ndel[dels++] = rem_n; Node* next_node = rem_n->next(); bucket->release_assign_node_ptr(rem_n_prev, next_node); @@ -620,12 +617,11 @@ ConcurrentHashTable:: size_t loop_count = 0; Node* node = bucket->first(); while (node != NULL) { - bool is_dead = false; ++loop_count; - if (lookup_f.equals(node->value(), &is_dead)) { + if (lookup_f.equals(node->value())) { break; } - if (is_dead && !(*have_dead)) { + if (!(*have_dead) && lookup_f.is_dead(node->value())) { *have_dead = true; } node = node->next(); diff --git a/test/hotspot/gtest/classfile/test_symbolTable.cpp b/test/hotspot/gtest/classfile/test_symbolTable.cpp index 0f59844744176..85be30ff4798c 100644 --- a/test/hotspot/gtest/classfile/test_symbolTable.cpp +++ b/test/hotspot/gtest/classfile/test_symbolTable.cpp @@ -152,3 +152,17 @@ TEST_VM_FATAL_ERROR_MSG(SymbolTable, test_symbol_underflow, ".*refcount has gone my_symbol->decrement_refcount(); my_symbol->increment_refcount(); // Should crash even in PRODUCT mode } + +TEST_VM(SymbolTable, test_cleanup_leak) { + // Check that dead entry cleanup doesn't increment refcount of live entry in same bucket. + + // Create symbol and release ref, marking it available for cleanup. + Symbol* entry1 = SymbolTable::new_symbol("hash_collision_123"); + entry1->decrement_refcount(); + + // Create a new symbol in the same bucket, which will notice the dead entry and trigger cleanup. + // Note: relies on SymbolTable's use of String::hashCode which collides for these two values. + Symbol* entry2 = SymbolTable::new_symbol("hash_collision_397476851"); + + ASSERT_EQ(entry2->refcount(), 1) << "Symbol refcount just created is 1"; +} diff --git a/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp b/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp index cfc445a4add19..6e42bf9848892 100644 --- a/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp +++ b/test/hotspot/gtest/utilities/test_concurrentHashtable.cpp @@ -105,9 +105,12 @@ struct SimpleTestLookup { uintx get_hash() { return Pointer::get_hash(_val, NULL); } - bool equals(const uintptr_t* value, bool* is_dead) { + bool equals(const uintptr_t* value) { return _val == *value; } + bool is_dead(const uintptr_t* value) { + return false; + } }; struct ValueGet { @@ -533,9 +536,12 @@ struct TestLookup { uintx get_hash() { return TestInterface::get_hash(_val, NULL); } - bool equals(const uintptr_t* value, bool* is_dead) { + bool equals(const uintptr_t* value) { return _val == *value; } + bool is_dead(const uintptr_t* value) { + return false; + } }; static uintptr_t cht_get_copy(TestTable* cht, Thread* thr, TestLookup tl) { From f09ba7996581df64cc194b80a50f0da6b50c5636 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 30 Aug 2023 05:46:00 +0000 Subject: [PATCH 063/341] 8314020: Print instruction blocks in byte units Reviewed-by: phh Backport-of: a602624ef46908456052146d50467c60efa636c3 --- src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp | 2 +- src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp | 2 +- src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp | 2 +- src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp | 2 +- src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp | 2 +- src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp | 2 +- src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp | 2 +- src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp | 2 +- src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp | 2 +- src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp | 2 +- src/hotspot/share/runtime/os.hpp | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp index 241e3b5e64ae8..5d3fef366c21f 100644 --- a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp +++ b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp @@ -462,7 +462,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::Posix::ucontext_get_pc(uc); - print_instructions(st, pc, /*instrsize=*/4); + print_instructions(st, pc); st->cr(); // Try to decode the instructions. diff --git a/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp b/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp index d5f412d399647..8a73f1fd576fb 100644 --- a/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp +++ b/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp @@ -480,7 +480,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::Posix::ucontext_get_pc(uc); - print_instructions(st, pc, 4/*native instruction size*/); + print_instructions(st, pc); st->cr(); } diff --git a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp index d6f3156618eba..14f5cf5de4a77 100644 --- a/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp +++ b/src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp @@ -860,7 +860,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::Posix::ucontext_get_pc(uc); - print_instructions(st, pc, sizeof(char)); + print_instructions(st, pc); st->cr(); } diff --git a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp index 9d2ac34b45dac..5188f3c25da78 100644 --- a/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp +++ b/src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp @@ -354,7 +354,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::fetch_frame_from_context(uc).pc(); - print_instructions(st, pc, 4/*native instruction size*/); + print_instructions(st, pc); st->cr(); } diff --git a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp index 8dbe8658faf28..785e767ef10b7 100644 --- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp +++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp @@ -461,7 +461,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::Posix::ucontext_get_pc(uc); - print_instructions(st, pc, Assembler::InstructionSize); + print_instructions(st, pc); st->cr(); } diff --git a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp index a8c09851932e0..f8e6787505b73 100644 --- a/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp +++ b/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp @@ -475,7 +475,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::Posix::ucontext_get_pc(uc); - print_instructions(st, pc, /*instrsize=*/4); + print_instructions(st, pc); st->cr(); } diff --git a/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp index 681e03922bd57..06d704f7573d2 100644 --- a/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/os_linux_riscv.cpp @@ -366,7 +366,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::fetch_frame_from_context(uc).pc(); - print_instructions(st, pc, UseRVC ? sizeof(char) : (int)NativeInstruction::instruction_size); + print_instructions(st, pc); st->cr(); } diff --git a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp index 850f8d3d843b8..cec512c321933 100644 --- a/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp +++ b/src/hotspot/os_cpu/linux_s390/os_linux_s390.cpp @@ -448,7 +448,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::Posix::ucontext_get_pc(uc); - print_instructions(st, pc, /*intrsize=*/4); + print_instructions(st, pc); st->cr(); } diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp index 00e4f405617bf..3d56c648e4680 100644 --- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp +++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp @@ -592,7 +592,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::fetch_frame_from_context(uc).pc(); - print_instructions(st, pc, sizeof(char)); + print_instructions(st, pc); st->cr(); } diff --git a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp index 016e538a9da38..96de0c05af604 100644 --- a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp +++ b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp @@ -463,7 +463,7 @@ void os::print_tos_pc(outputStream *st, const void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::fetch_frame_from_context(uc).pc(); - print_instructions(st, pc, sizeof(char)); + print_instructions(st, pc); st->cr(); } diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index b378a4ee81058..81713b0f6443e 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -695,7 +695,7 @@ class os: AllStatic { static void print_context(outputStream* st, const void* context); static void print_tos_pc(outputStream* st, const void* context); static void print_tos(outputStream* st, address sp); - static void print_instructions(outputStream* st, address pc, int unitsize); + static void print_instructions(outputStream* st, address pc, int unitsize = 1); static void print_register_info(outputStream* st, const void* context); static bool signal_sent_by_kill(const void* siginfo); static void print_siginfo(outputStream* st, const void* siginfo); From 25efeccb05bc747aafafb45b0b6910103a53b2b9 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 30 Aug 2023 05:55:37 +0000 Subject: [PATCH 064/341] 8313262: C2: Sinking node may cause required cast to be dropped Backport-of: 1cee3b9fd9720e7938029a6992460b9053e65e57 --- src/hotspot/share/opto/loopopts.cpp | 2 +- .../TestSinkingNodeDropsNotNullCast.java | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/gc/shenandoah/compiler/TestSinkingNodeDropsNotNullCast.java diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index ca5dfa89498a1..64ba65d5fdbdc 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -1546,7 +1546,7 @@ void PhaseIdealLoop::try_sink_out_of_loop(Node* n) { // Find control for 'x' next to use but not inside inner loops. x_ctrl = place_outside_loop(x_ctrl, n_loop); // Replace all uses - if (u->is_ConstraintCast() && u->bottom_type()->higher_equal(_igvn.type(n)) && u->in(0) == x_ctrl) { + if (u->is_ConstraintCast() && _igvn.type(n)->higher_equal(u->bottom_type()) && u->in(0) == x_ctrl) { // If we're sinking a chain of data nodes, we might have inserted a cast to pin the use which is not necessary // anymore now that we're going to pin n as well _igvn.replace_node(u, x); diff --git a/test/hotspot/jtreg/gc/shenandoah/compiler/TestSinkingNodeDropsNotNullCast.java b/test/hotspot/jtreg/gc/shenandoah/compiler/TestSinkingNodeDropsNotNullCast.java new file mode 100644 index 0000000000000..4987f448aa5d1 --- /dev/null +++ b/test/hotspot/jtreg/gc/shenandoah/compiler/TestSinkingNodeDropsNotNullCast.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023, Red Hat, Inc. All rights reserved. + * 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 8313262 + * @summary Sinking node may cause required cast to be dropped + * @requires vm.gc.Shenandoah + * @run main/othervm -XX:-BackgroundCompilation -XX:+UseShenandoahGC TestSinkingNodeDropsNotNullCast + */ + +import java.util.Arrays; + +public class TestSinkingNodeDropsNotNullCast { + public static void main(String[] args) { + Object[] array1 = new Object[100]; + Object[] array2 = new Object[100]; + Arrays.fill(array2, new Object()); + for (int i = 0; i < 20_000; i++) { + test(array1); + test(array1); + test(array2); + } + } + + private static Object test(Object[] array) { + Object o; + int i = 1; + do { + synchronized (new Object()) { + } + o = array[i]; + if (o != null) { + if (o instanceof A) { + return ((A) o).field; + } else { + return o; + } + } + i++; + } while (i < 100); + return o; + } + + private static class A { + Object field; + } +} From a64639f4f9462c97980ae9a1e315272c1470d4b8 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 30 Aug 2023 07:56:50 +0000 Subject: [PATCH 065/341] 8312974: Bump update version for OpenJDK: jdk-17.0.10 Reviewed-by: shade --- .jcheck/conf | 2 +- make/conf/version-numbers.conf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.jcheck/conf b/.jcheck/conf index ab251de5d4f13..a2d6545b1f45d 100644 --- a/.jcheck/conf +++ b/.jcheck/conf @@ -1,7 +1,7 @@ [general] project=jdk-updates jbs=JDK -version=17.0.9 +version=17.0.10 [checks] error=author,committer,reviewers,merge,issues,executable,symlink,message,hg-tag,whitespace,problemlists diff --git a/make/conf/version-numbers.conf b/make/conf/version-numbers.conf index c188a694618ec..6c35e79d1be4f 100644 --- a/make/conf/version-numbers.conf +++ b/make/conf/version-numbers.conf @@ -28,12 +28,12 @@ DEFAULT_VERSION_FEATURE=17 DEFAULT_VERSION_INTERIM=0 -DEFAULT_VERSION_UPDATE=9 +DEFAULT_VERSION_UPDATE=10 DEFAULT_VERSION_PATCH=0 DEFAULT_VERSION_EXTRA1=0 DEFAULT_VERSION_EXTRA2=0 DEFAULT_VERSION_EXTRA3=0 -DEFAULT_VERSION_DATE=2023-10-17 +DEFAULT_VERSION_DATE=2024-01-16 DEFAULT_VERSION_CLASSFILE_MAJOR=61 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_VERSION_DOCS_API_SINCE=11 From 0bc4e7ec7c6b03000e8d0fb6238d9c6b68d85014 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 30 Aug 2023 08:52:38 +0000 Subject: [PATCH 066/341] 8292717: Clean up checking of testing requirements in configure Reviewed-by: clanger Backport-of: 16593cf51c3d994ba4a6d28ab97e519dfd53f37b --- make/autoconf/configure.ac | 18 ++-- make/autoconf/jdk-options.m4 | 23 ----- make/autoconf/lib-tests.m4 | 169 ++++++++++++++++++++++++++++++++++- make/autoconf/toolchain.m4 | 140 ----------------------------- 4 files changed, 176 insertions(+), 174 deletions(-) diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac index ebf43c363eab0..52baed8af935d 100644 --- a/make/autoconf/configure.ac +++ b/make/autoconf/configure.ac @@ -191,18 +191,15 @@ TOOLCHAIN_POST_DETECTION TOOLCHAIN_SETUP_BUILD_COMPILERS TOOLCHAIN_MISC_CHECKS -# Setup the JTReg Regression Test Harness. -TOOLCHAIN_SETUP_JTREG - -# Setup the Java Microbenchmark Harness (JMH) -LIB_TESTS_SETUP_JMH - -# Setup Jib dependency tool -TOOLCHAIN_SETUP_JIB - # After toolchain setup, we need to process some flags to be able to continue. FLAGS_POST_TOOLCHAIN +# Setup the tools needed to test the JDK (JTReg Regression Test Harness, +# Java Microbenchmark Harness (JMH) and the Jib dependency tool). +LIB_TESTS_SETUP_JTREG +LIB_TESTS_SETUP_JMH +LIB_TESTS_SETUP_JIB + # Now we can test some aspects on the target using configure macros. PLATFORM_SETUP_OPENJDK_TARGET_BITS PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS @@ -244,7 +241,8 @@ HOTSPOT_SETUP_MISC # ############################################################################### -JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER +LIB_TESTS_ENABLE_DISABLE_FAILURE_HANDLER + JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST JDKOPT_EXCLUDE_TRANSLATIONS JDKOPT_ENABLE_DISABLE_MANPAGES diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index db526547d865c..07f3da53abcf9 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -500,29 +500,6 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS], AC_SUBST(JLINK_KEEP_PACKAGED_MODULES) ]) -################################################################################ -# -# Check if building of the jtreg failure handler should be enabled. -# -AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER], -[ - UTIL_ARG_ENABLE(NAME: jtreg-failure-handler, DEFAULT: auto, - RESULT: BUILD_FAILURE_HANDLER, - DESC: [enable building of the jtreg failure handler], - DEFAULT_DESC: [enabled if jtreg is present], - CHECKING_MSG: [if the jtreg failure handler should be built], - CHECK_AVAILABLE: [ - AC_MSG_CHECKING([if the jtreg failure handler is available]) - if test "x$JT_HOME" != "x"; then - AC_MSG_RESULT([yes]) - else - AVAILABLE=false - AC_MSG_RESULT([no (jtreg not present)]) - fi - ]) - AC_SUBST(BUILD_FAILURE_HANDLER) -]) - ################################################################################ # # Enable or disable generation of the classlist at build time diff --git a/make/autoconf/lib-tests.m4 b/make/autoconf/lib-tests.m4 index c431341f4d899..0fd72c1c869cb 100644 --- a/make/autoconf/lib-tests.m4 +++ b/make/autoconf/lib-tests.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. # 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,6 +23,13 @@ # questions. # +################################################################################ +# Setup libraries and functionalities needed to test the JDK. +################################################################################ + +# Minimum supported version +JTREG_MINIMUM_VERSION=6.1 + ############################################################################### # # Setup and check for gtest framework source files @@ -118,3 +125,163 @@ AC_DEFUN_ONCE([LIB_TESTS_SETUP_JMH], AC_SUBST(JMH_COMMONS_MATH_JAR) AC_SUBST(JMH_VERSION) ]) + +# Setup the JTReg Regression Test Harness. +AC_DEFUN_ONCE([LIB_TESTS_SETUP_JTREG], +[ + AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg], + [Regression Test Harness @<:@probed@:>@])]) + + if test "x$with_jtreg" = xno; then + # jtreg disabled + AC_MSG_CHECKING([for jtreg test harness]) + AC_MSG_RESULT([no, disabled]) + elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then + if test -d "$with_jtreg"; then + # An explicit path is specified, use it. + JT_HOME="$with_jtreg" + else + case "$with_jtreg" in + *.zip ) + JTREG_SUPPORT_DIR=$CONFIGURESUPPORT_OUTPUTDIR/jtreg + $RM -rf $JTREG_SUPPORT_DIR + $MKDIR -p $JTREG_SUPPORT_DIR + $UNZIP -qq -d $JTREG_SUPPORT_DIR $with_jtreg + + # Try to find jtreg to determine JT_HOME path + JTREG_PATH=`$FIND $JTREG_SUPPORT_DIR | $GREP "/bin/jtreg"` + if test "x$JTREG_PATH" != x; then + JT_HOME=$($DIRNAME $($DIRNAME $JTREG_PATH)) + fi + ;; + * ) + ;; + esac + fi + UTIL_FIXUP_PATH([JT_HOME]) + if test ! -d "$JT_HOME"; then + AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist]) + fi + + if test ! -e "$JT_HOME/lib/jtreg.jar"; then + AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home]) + fi + + AC_MSG_CHECKING([for jtreg test harness]) + AC_MSG_RESULT([$JT_HOME]) + else + # Try to locate jtreg using the JT_HOME environment variable + if test "x$JT_HOME" != x; then + # JT_HOME set in environment, use it + if test ! -d "$JT_HOME"; then + AC_MSG_WARN([Ignoring JT_HOME pointing to invalid directory: $JT_HOME]) + JT_HOME= + else + if test ! -e "$JT_HOME/lib/jtreg.jar"; then + AC_MSG_WARN([Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME]) + JT_HOME= + else + AC_MSG_NOTICE([Located jtreg using JT_HOME from environment]) + fi + fi + fi + + if test "x$JT_HOME" = x; then + # JT_HOME is not set in environment, or was deemed invalid. + # Try to find jtreg on path + UTIL_LOOKUP_PROGS(JTREGEXE, jtreg) + if test "x$JTREGEXE" != x; then + # That's good, now try to derive JT_HOME + JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)` + if test ! -e "$JT_HOME/lib/jtreg.jar"; then + AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found]) + JT_HOME= + else + AC_MSG_NOTICE([Located jtreg using jtreg executable in path]) + fi + fi + fi + + AC_MSG_CHECKING([for jtreg test harness]) + if test "x$JT_HOME" != x; then + AC_MSG_RESULT([$JT_HOME]) + else + AC_MSG_RESULT([no, not found]) + + if test "x$with_jtreg" = xyes; then + AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.]) + fi + fi + fi + + UTIL_FIXUP_PATH(JT_HOME) + AC_SUBST(JT_HOME) + + # Verify jtreg version + if test "x$JT_HOME" != x; then + AC_MSG_CHECKING([jtreg version number]) + # jtreg -version looks like this: "jtreg 6.1+1-19" + # Extract actual version part ("6.1" in this case) + jtreg_version_full=`$JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2` + jtreg_version=${jtreg_version_full/%+*} + AC_MSG_RESULT([$jtreg_version]) + + # This is a simplified version of TOOLCHAIN_CHECK_COMPILER_VERSION + comparable_actual_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$jtreg_version"` + comparable_minimum_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$JTREG_MINIMUM_VERSION"` + if test $comparable_actual_version -lt $comparable_minimum_version ; then + AC_MSG_ERROR([jtreg version is too old, at least version $JTREG_MINIMUM_VERSION is required]) + fi + fi +]) + +# Setup the JIB dependency resolver +AC_DEFUN_ONCE([LIB_TESTS_SETUP_JIB], +[ + AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib], + [Jib dependency management tool @<:@not used@:>@])]) + + if test "x$with_jib" = xno || test "x$with_jib" = x; then + # jib disabled + AC_MSG_CHECKING([for jib]) + AC_MSG_RESULT(no) + elif test "x$with_jib" = xyes; then + AC_MSG_ERROR([Must supply a value to --with-jib]) + else + JIB_HOME="${with_jib}" + AC_MSG_CHECKING([for jib]) + AC_MSG_RESULT(${JIB_HOME}) + if test ! -d "${JIB_HOME}"; then + AC_MSG_ERROR([--with-jib must be a directory]) + fi + JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar) + if test ! -f "${JIB_JAR}"; then + AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}]) + fi + fi + + AC_SUBST(JIB_HOME) +]) + +################################################################################ +# +# Check if building of the jtreg failure handler should be enabled. +# +AC_DEFUN_ONCE([LIB_TESTS_ENABLE_DISABLE_FAILURE_HANDLER], +[ + UTIL_ARG_ENABLE(NAME: jtreg-failure-handler, DEFAULT: auto, + RESULT: BUILD_FAILURE_HANDLER, + DESC: [enable building of the jtreg failure handler], + DEFAULT_DESC: [enabled if jtreg is present], + CHECKING_MSG: [if the jtreg failure handler should be built], + CHECK_AVAILABLE: [ + AC_MSG_CHECKING([if the jtreg failure handler is available]) + if test "x$JT_HOME" != "x"; then + AC_MSG_RESULT([yes]) + else + AVAILABLE=false + AC_MSG_RESULT([no (jtreg not present)]) + fi + ]) + AC_SUBST(BUILD_FAILURE_HANDLER) +]) diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4 index 72710c7a7150f..e77476d85c298 100644 --- a/make/autoconf/toolchain.m4 +++ b/make/autoconf/toolchain.m4 @@ -58,9 +58,6 @@ TOOLCHAIN_MINIMUM_VERSION_xlc="" # Minimum supported linker versions, empty means unspecified TOOLCHAIN_MINIMUM_LD_VERSION_gcc="2.18" -# Minimum supported version -JTREG_MINIMUM_VERSION=6.1 - # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called. # Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER. # $1 - optional variable prefix for compiler and version variables (BUILD_) @@ -994,140 +991,3 @@ AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS], fi AC_SUBST(HOTSPOT_TOOLCHAIN_TYPE) ]) - -# Setup the JTReg Regression Test Harness. -AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], -[ - AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg], - [Regression Test Harness @<:@probed@:>@])]) - - if test "x$with_jtreg" = xno; then - # jtreg disabled - AC_MSG_CHECKING([for jtreg test harness]) - AC_MSG_RESULT([no, disabled]) - elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then - if test -d "$with_jtreg"; then - # An explicit path is specified, use it. - JT_HOME="$with_jtreg" - else - case "$with_jtreg" in - *.zip ) - JTREG_SUPPORT_DIR=$CONFIGURESUPPORT_OUTPUTDIR/jtreg - $RM -rf $JTREG_SUPPORT_DIR - $MKDIR -p $JTREG_SUPPORT_DIR - $UNZIP -qq -d $JTREG_SUPPORT_DIR $with_jtreg - - # Try to find jtreg to determine JT_HOME path - JTREG_PATH=`$FIND $JTREG_SUPPORT_DIR | $GREP "/bin/jtreg"` - if test "x$JTREG_PATH" != x; then - JT_HOME=$($DIRNAME $($DIRNAME $JTREG_PATH)) - fi - ;; - * ) - ;; - esac - fi - UTIL_FIXUP_PATH([JT_HOME]) - if test ! -d "$JT_HOME"; then - AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist]) - fi - - if test ! -e "$JT_HOME/lib/jtreg.jar"; then - AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home]) - fi - - AC_MSG_CHECKING([for jtreg test harness]) - AC_MSG_RESULT([$JT_HOME]) - else - # Try to locate jtreg using the JT_HOME environment variable - if test "x$JT_HOME" != x; then - # JT_HOME set in environment, use it - if test ! -d "$JT_HOME"; then - AC_MSG_WARN([Ignoring JT_HOME pointing to invalid directory: $JT_HOME]) - JT_HOME= - else - if test ! -e "$JT_HOME/lib/jtreg.jar"; then - AC_MSG_WARN([Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME]) - JT_HOME= - else - AC_MSG_NOTICE([Located jtreg using JT_HOME from environment]) - fi - fi - fi - - if test "x$JT_HOME" = x; then - # JT_HOME is not set in environment, or was deemed invalid. - # Try to find jtreg on path - UTIL_LOOKUP_PROGS(JTREGEXE, jtreg) - if test "x$JTREGEXE" != x; then - # That's good, now try to derive JT_HOME - JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)` - if test ! -e "$JT_HOME/lib/jtreg.jar"; then - AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found]) - JT_HOME= - else - AC_MSG_NOTICE([Located jtreg using jtreg executable in path]) - fi - fi - fi - - AC_MSG_CHECKING([for jtreg test harness]) - if test "x$JT_HOME" != x; then - AC_MSG_RESULT([$JT_HOME]) - else - AC_MSG_RESULT([no, not found]) - - if test "x$with_jtreg" = xyes; then - AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.]) - fi - fi - fi - - UTIL_FIXUP_PATH(JT_HOME) - AC_SUBST(JT_HOME) - - # Verify jtreg version - if test "x$JT_HOME" != x; then - AC_MSG_CHECKING([jtreg version number]) - # jtreg -version looks like this: "jtreg 6.1+1-19" - # Extract actual version part ("6.1" in this case) - jtreg_version_full=`$JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2` - jtreg_version=${jtreg_version_full/%+*} - AC_MSG_RESULT([$jtreg_version]) - - # This is a simplified version of TOOLCHAIN_CHECK_COMPILER_VERSION - comparable_actual_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$jtreg_version"` - comparable_minimum_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$JTREG_MINIMUM_VERSION"` - if test $comparable_actual_version -lt $comparable_minimum_version ; then - AC_MSG_ERROR([jtreg version is too old, at least version $JTREG_MINIMUM_VERSION is required]) - fi - fi -]) - -# Setup the JIB dependency resolver -AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JIB], -[ - AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib], - [Jib dependency management tool @<:@not used@:>@])]) - - if test "x$with_jib" = xno || test "x$with_jib" = x; then - # jib disabled - AC_MSG_CHECKING([for jib]) - AC_MSG_RESULT(no) - elif test "x$with_jib" = xyes; then - AC_MSG_ERROR([Must supply a value to --with-jib]) - else - JIB_HOME="${with_jib}" - AC_MSG_CHECKING([for jib]) - AC_MSG_RESULT(${JIB_HOME}) - if test ! -d "${JIB_HOME}"; then - AC_MSG_ERROR([--with-jib must be a directory]) - fi - JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar) - if test ! -f "${JIB_JAR}"; then - AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}]) - fi - fi - - AC_SUBST(JIB_HOME) -]) From 36817195e41e2c216cf9ed7641a1081b9b49ac23 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Wed, 30 Aug 2023 09:13:09 +0000 Subject: [PATCH 067/341] 8310233: Fix THP detection on Linux Reviewed-by: phh Backport-of: 37ca9024ef59d99cae0bd7e25b2e6d3c1e085f97 --- src/hotspot/os/linux/hugepages.cpp | 228 ++++++++++++++++++ src/hotspot/os/linux/hugepages.hpp | 110 +++++++++ src/hotspot/os/linux/os_linux.cpp | 204 ++++++---------- src/hotspot/os/linux/os_linux.hpp | 6 - .../share/utilities/globalDefinitions.hpp | 3 + .../runtime/os/HugePageConfiguration.java | 221 +++++++++++++++++ .../jtreg/runtime/os/HugePageDetection.java | 75 ++++++ 7 files changed, 716 insertions(+), 131 deletions(-) create mode 100644 src/hotspot/os/linux/hugepages.cpp create mode 100644 src/hotspot/os/linux/hugepages.hpp create mode 100644 test/hotspot/jtreg/runtime/os/HugePageConfiguration.java create mode 100644 test/hotspot/jtreg/runtime/os/HugePageDetection.java diff --git a/src/hotspot/os/linux/hugepages.cpp b/src/hotspot/os/linux/hugepages.cpp new file mode 100644 index 0000000000000..299c27a8c1ded --- /dev/null +++ b/src/hotspot/os/linux/hugepages.cpp @@ -0,0 +1,228 @@ +/* + * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "hugepages.hpp" + +#include "logging/log.hpp" +#include "logging/logStream.hpp" +#include "runtime/os.hpp" +#include "utilities/debug.hpp" +#include "utilities/globalDefinitions.hpp" +#include "utilities/ostream.hpp" + +#include + +StaticHugePageSupport::StaticHugePageSupport() : + _initialized(false), _pagesizes(), _default_hugepage_size(SIZE_MAX) {} + +os::PageSizes StaticHugePageSupport::pagesizes() const { + assert(_initialized, "Not initialized"); + return _pagesizes; +} + +size_t StaticHugePageSupport::default_hugepage_size() const { + assert(_initialized, "Not initialized"); + return _default_hugepage_size; +} + +// Scan /proc/meminfo and return value of Hugepagesize +static size_t scan_default_hugepagesize() { + size_t pagesize = 0; + + // large_page_size on Linux is used to round up heap size. x86 uses either + // 2M or 4M page, depending on whether PAE (Physical Address Extensions) + // mode is enabled. AMD64/EM64T uses 2M page in 64bit mode. IA64 can use + // page as large as 1G. + // + // Here we try to figure out page size by parsing /proc/meminfo and looking + // for a line with the following format: + // Hugepagesize: 2048 kB + // + // If we can't determine the value (e.g. /proc is not mounted, or the text + // format has been changed), we'll set largest page size to 0 + + FILE *fp = os::fopen("/proc/meminfo", "r"); + if (fp) { + while (!feof(fp)) { + int x = 0; + char buf[16]; + if (fscanf(fp, "Hugepagesize: %d", &x) == 1) { + if (x && fgets(buf, sizeof(buf), fp) && strcmp(buf, " kB\n") == 0) { + pagesize = x * K; + break; + } + } else { + // skip to next line + for (;;) { + int ch = fgetc(fp); + if (ch == EOF || ch == (int)'\n') break; + } + } + } + fclose(fp); + } + + return pagesize; +} + +// Given a file that contains a single (integral) number, return that number in (*out) and true; +// in case of an error, return false. +static bool read_number_file(const char* file, size_t* out) { + FILE* f = ::fopen(file, "r"); + bool rc = false; + if (f != nullptr) { + uint64_t i = 0; + if (::fscanf(f, SIZE_FORMAT, out) == 1) { + rc = true; + } + ::fclose(f); + } + return rc; +} + +static const char* const sys_hugepages = "/sys/kernel/mm/hugepages"; + +// Scan all directories in /sys/kernel/mm/hugepages/hugepages-xxxx +// to discover the available page sizes +static os::PageSizes scan_hugepages() { + + os::PageSizes pagesizes; + + DIR *dir = opendir(sys_hugepages); + + struct dirent *entry; + size_t pagesize; + while ((entry = readdir(dir)) != nullptr) { + if (entry->d_type == DT_DIR && + sscanf(entry->d_name, "hugepages-%zukB", &pagesize) == 1) { + // The kernel is using kB, hotspot uses bytes + // Add each found Large Page Size to page_sizes + pagesize *= K; + pagesizes.add(pagesize); + } + } + closedir(dir); + + return pagesizes; +} + +void StaticHugePageSupport::print_on(outputStream* os) { + if (_initialized) { + os->print_cr("Static hugepage support:"); + for (size_t s = _pagesizes.smallest(); s != 0; s = _pagesizes.next_larger(s)) { + os->print_cr(" hugepage size: " EXACTFMT, EXACTFMTARGS(s)); + } + os->print_cr(" default hugepage size: " EXACTFMT, EXACTFMTARGS(_default_hugepage_size)); + } else { + os->print_cr(" unknown."); + } +} + +void StaticHugePageSupport::scan_os() { + _pagesizes = scan_hugepages(); + _default_hugepage_size = scan_default_hugepagesize(); + assert(_pagesizes.contains(_default_hugepage_size), + "Unexpected configuration: default pagesize (" SIZE_FORMAT ") " + "has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size); + _initialized = true; + LogTarget(Info, pagesize) lt; + if (lt.is_enabled()) { + LogStream ls(lt); + print_on(&ls); + } +} + +THPSupport::THPSupport() : + _initialized(false), _mode(THPMode::never), _pagesize(SIZE_MAX) {} + + +THPMode THPSupport::mode() const { + assert(_initialized, "Not initialized"); + return _mode; +} + +size_t THPSupport::pagesize() const { + assert(_initialized, "Not initialized"); + return _pagesize; +} + +void THPSupport::scan_os() { + // Scan /sys/kernel/mm/transparent_hugepage/enabled + // see mm/huge_memory.c + _mode = THPMode::never; + const char* filename = "/sys/kernel/mm/transparent_hugepage/enabled"; + FILE* f = ::fopen(filename, "r"); + if (f != nullptr) { + char buf[64]; + char* s = fgets(buf, sizeof(buf), f); + assert(s == buf, "Should have worked"); + if (::strstr(buf, "[madvise]") != nullptr) { + _mode = THPMode::madvise; + } else if (::strstr(buf, "[always]") != nullptr) { + _mode = THPMode::always; + } else { + assert(::strstr(buf, "[never]") != nullptr, "Weird content of %s: %s", filename, buf); + } + fclose(f); + } + + // Scan large page size for THP from hpage_pmd_size + _pagesize = 0; + if (read_number_file("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", &_pagesize)) { + assert(_pagesize > 0, "Expected"); + } + _initialized = true; + + LogTarget(Info, pagesize) lt; + if (lt.is_enabled()) { + LogStream ls(lt); + print_on(&ls); + } +} + +void THPSupport::print_on(outputStream* os) { + if (_initialized) { + os->print_cr("Transparent hugepage (THP) support:"); + os->print_cr(" THP mode: %s", + (_mode == THPMode::always ? "always" : (_mode == THPMode::never ? "never" : "madvise"))); + os->print_cr(" THP pagesize: " EXACTFMT, EXACTFMTARGS(_pagesize)); + } else { + os->print_cr(" unknown."); + } +} + +StaticHugePageSupport HugePages::_static_hugepage_support; +THPSupport HugePages::_thp_support; + +void HugePages::initialize() { + _static_hugepage_support.scan_os(); + _thp_support.scan_os(); +} + +void HugePages::print_on(outputStream* os) { + _static_hugepage_support.print_on(os); + _thp_support.print_on(os); +} diff --git a/src/hotspot/os/linux/hugepages.hpp b/src/hotspot/os/linux/hugepages.hpp new file mode 100644 index 0000000000000..2f378fdc2249d --- /dev/null +++ b/src/hotspot/os/linux/hugepages.hpp @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023, Red Hat Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef OS_LINUX_HUGEPAGES_HPP +#define OS_LINUX_HUGEPAGES_HPP + +#include "memory/allStatic.hpp" +#include "runtime/os.hpp" // for os::PageSizes +#include "utilities/globalDefinitions.hpp" + +class outputStream; + +// Header contains the interface that reads OS information about +// available hugepage support: +// - class StaticHugePageSupport - about static (non-THP) hugepages +// - class THPSupport - about transparent huge pages +// and: +// - class HugePages - a static umbrella wrapper + +// Information about static (non-thp) hugepages +class StaticHugePageSupport { + bool _initialized; + + // All supported hugepage sizes (sizes for which entries exist + // in /sys/kernel/mm/hugepages/hugepage-xxx) + os::PageSizes _pagesizes; + + // Contains the default hugepage. The "default hugepage size" is the one that + // - is marked in /proc/meminfo as "Hugepagesize" + // - is the size one gets when using mmap(MAP_HUGETLB) when omitting size specifiers like MAP_HUGE_SHIFT) + size_t _default_hugepage_size; + +public: + StaticHugePageSupport(); + + void scan_os(); + + os::PageSizes pagesizes() const; + size_t default_hugepage_size() const; + void print_on(outputStream* os); +}; + +enum class THPMode { always, never, madvise }; + +// 2) for transparent hugepages +class THPSupport { + bool _initialized; + + // See /sys/kernel/mm/transparent_hugepages/enabled + THPMode _mode; + + // Contains the THP page size + size_t _pagesize; + +public: + + THPSupport(); + + // Queries the OS, fills in object + void scan_os(); + + THPMode mode() const; + size_t pagesize() const; + void print_on(outputStream* os); +}; + +// Umbrella static interface +class HugePages : public AllStatic { + + static StaticHugePageSupport _static_hugepage_support; + static THPSupport _thp_support; + +public: + + static const StaticHugePageSupport& static_info() { return _static_hugepage_support; } + static const THPSupport& thp_info() { return _thp_support; } + + static size_t default_static_hugepage_size() { return _static_hugepage_support.default_hugepage_size(); } + static bool supports_static_hugepages() { return default_static_hugepage_size() > 0; } + static THPMode thp_mode() { return _thp_support.mode(); } + static bool supports_thp() { return thp_mode() == THPMode::madvise || thp_mode() == THPMode::always; } + static size_t thp_pagesize() { return _thp_support.pagesize(); } + + static void initialize(); + static void print_on(outputStream* os); +}; + +#endif // OS_LINUX_HUGEPAGES_HPP diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 99dd4c824201a..0a7412f57e8e0 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -30,6 +30,7 @@ #include "code/vtableStubs.hpp" #include "compiler/compileBroker.hpp" #include "compiler/disassembler.hpp" +#include "hugepages.hpp" #include "interpreter/interpreter.hpp" #include "jvmtifiles/jvmti.h" #include "logging/log.hpp" @@ -166,7 +167,6 @@ int os::Linux::_page_size = -1; bool os::Linux::_supports_fast_thread_cpu_time = false; const char * os::Linux::_libc_version = NULL; const char * os::Linux::_libpthread_version = NULL; -size_t os::Linux::_default_large_page_size = 0; #ifdef __GLIBC__ os::Linux::mallinfo_func_t os::Linux::_mallinfo = NULL; @@ -879,7 +879,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, // Add an additional page to the stack size to reduce its chances of getting large page aligned // so that the stack does not get backed by a transparent huge page. - size_t default_large_page_size = os::Linux::default_large_page_size(); + size_t default_large_page_size = HugePages::default_static_hugepage_size(); if (default_large_page_size != 0 && stack_size >= default_large_page_size && is_aligned(stack_size, default_large_page_size)) { @@ -3614,7 +3614,7 @@ bool os::Linux::transparent_huge_pages_sanity_check(bool warn, } int os::Linux::hugetlbfs_page_size_flag(size_t page_size) { - if (page_size != default_large_page_size()) { + if (page_size != HugePages::default_static_hugepage_size()) { return (exact_log2(page_size) << MAP_HUGE_SHIFT); } return 0; @@ -3722,79 +3722,6 @@ static void set_coredump_filter(CoredumpFilterBit bit) { static size_t _large_page_size = 0; -static size_t scan_default_large_page_size() { - size_t default_large_page_size = 0; - - // large_page_size on Linux is used to round up heap size. x86 uses either - // 2M or 4M page, depending on whether PAE (Physical Address Extensions) - // mode is enabled. AMD64/EM64T uses 2M page in 64bit mode. IA64 can use - // page as large as 1G. - // - // Here we try to figure out page size by parsing /proc/meminfo and looking - // for a line with the following format: - // Hugepagesize: 2048 kB - // - // If we can't determine the value (e.g. /proc is not mounted, or the text - // format has been changed), we'll set largest page size to 0 - - FILE *fp = fopen("/proc/meminfo", "r"); - if (fp) { - while (!feof(fp)) { - int x = 0; - char buf[16]; - if (fscanf(fp, "Hugepagesize: %d", &x) == 1) { - if (x && fgets(buf, sizeof(buf), fp) && strcmp(buf, " kB\n") == 0) { - default_large_page_size = x * K; - break; - } - } else { - // skip to next line - for (;;) { - int ch = fgetc(fp); - if (ch == EOF || ch == (int)'\n') break; - } - } - } - fclose(fp); - } - - return default_large_page_size; -} - -static os::PageSizes scan_multiple_page_support() { - // Scan /sys/kernel/mm/hugepages - // to discover the available page sizes - const char* sys_hugepages = "/sys/kernel/mm/hugepages"; - os::PageSizes page_sizes; - - DIR *dir = opendir(sys_hugepages); - - struct dirent *entry; - size_t page_size; - while ((entry = readdir(dir)) != NULL) { - if (entry->d_type == DT_DIR && - sscanf(entry->d_name, "hugepages-%zukB", &page_size) == 1) { - // The kernel is using kB, hotspot uses bytes - // Add each found Large Page Size to page_sizes - page_sizes.add(page_size * K); - } - } - closedir(dir); - - LogTarget(Debug, pagesize) lt; - if (lt.is_enabled()) { - LogStream ls(lt); - ls.print("Large Page sizes: "); - page_sizes.print_on(&ls); - } - - return page_sizes; -} - -size_t os::Linux::default_large_page_size() { - return _default_large_page_size; -} - void warn_no_large_pages_configured() { if (!FLAG_IS_DEFAULT(UseLargePages)) { log_warning(pagesize)("UseLargePages disabled, no large pages configured and available on the system."); @@ -3847,10 +3774,29 @@ bool os::Linux::setup_large_page_type(size_t page_size) { return false; } +struct LargePageInitializationLoggerMark { + ~LargePageInitializationLoggerMark() { + LogTarget(Info, pagesize) lt; + if (lt.is_enabled()) { + LogStream ls(lt); + if (UseLargePages) { + ls.print_cr("UseLargePages=1, UseTransparentHugePages=%d, UseHugeTLBFS=%d, UseSHM=%d", + UseTransparentHugePages, UseHugeTLBFS, UseSHM); + ls.print("Large page support enabled. Usable page sizes: "); + os::page_sizes().print_on(&ls); + ls.print_cr(". Default large page size: " EXACTFMT ".", EXACTFMTARGS(os::large_page_size())); + } else { + ls.print("Large page support disabled."); + } + } + } +}; + void os::large_page_init() { - // Always initialize the default large page size even if large pages are not being used. - size_t default_large_page_size = scan_default_large_page_size(); - os::Linux::_default_large_page_size = default_large_page_size; + LargePageInitializationLoggerMark logger; + + // Query OS information first. + HugePages::initialize(); // 1) Handle the case where we do not want to use huge pages if (!UseLargePages && @@ -3871,7 +3817,8 @@ void os::large_page_init() { } // 2) check if large pages are configured - if (default_large_page_size == 0) { + if ( ( UseTransparentHugePages && HugePages::supports_thp() == false) || + (!UseTransparentHugePages && HugePages::supports_static_hugepages() == false) ) { // No large pages configured, return. warn_no_large_pages_configured(); UseLargePages = false; @@ -3880,57 +3827,64 @@ void os::large_page_init() { UseSHM = false; return; } - os::PageSizes all_large_pages = scan_multiple_page_support(); - - // 3) Consistency check and post-processing - - // It is unclear if /sys/kernel/mm/hugepages/ and /proc/meminfo could disagree. Manually - // re-add the default page size to the list of page sizes to be sure. - all_large_pages.add(default_large_page_size); - - // Check LargePageSizeInBytes matches an available page size and if so set _large_page_size - // using LargePageSizeInBytes as the maximum allowed large page size. If LargePageSizeInBytes - // doesn't match an available page size set _large_page_size to default_large_page_size - // and use it as the maximum. - if (FLAG_IS_DEFAULT(LargePageSizeInBytes) || - LargePageSizeInBytes == 0 || - LargePageSizeInBytes == default_large_page_size) { - _large_page_size = default_large_page_size; - log_info(pagesize)("Using the default large page size: " SIZE_FORMAT "%s", - byte_size_in_exact_unit(_large_page_size), - exact_unit_for_byte_size(_large_page_size)); + + if (UseTransparentHugePages) { + // In THP mode: + // - os::large_page_size() is the *THP page size* + // - os::pagesizes() has two members, the THP page size and the system page size + assert(HugePages::supports_thp() && HugePages::thp_pagesize() > 0, "Missing OS info"); + _large_page_size = HugePages::thp_pagesize(); + _page_sizes.add(_large_page_size); + _page_sizes.add(os::vm_page_size()); + } else { - if (all_large_pages.contains(LargePageSizeInBytes)) { - _large_page_size = LargePageSizeInBytes; - log_info(pagesize)("Overriding default large page size (" SIZE_FORMAT "%s) " - "using LargePageSizeInBytes: " SIZE_FORMAT "%s", - byte_size_in_exact_unit(default_large_page_size), - exact_unit_for_byte_size(default_large_page_size), - byte_size_in_exact_unit(_large_page_size), - exact_unit_for_byte_size(_large_page_size)); - } else { + + // In static hugepage mode: + // - os::large_page_size() is the default static hugepage size (/proc/meminfo "Hugepagesize") + // - os::pagesizes() contains all hugepage sizes the kernel supports, regardless whether there + // are pages configured in the pool or not (from /sys/kernel/hugepages/hugepage-xxxx ...) + os::PageSizes all_large_pages = HugePages::static_info().pagesizes(); + const size_t default_large_page_size = HugePages::default_static_hugepage_size(); + + // 3) Consistency check and post-processing + + // Check LargePageSizeInBytes matches an available page size and if so set _large_page_size + // using LargePageSizeInBytes as the maximum allowed large page size. If LargePageSizeInBytes + // doesn't match an available page size set _large_page_size to default_large_page_size + // and use it as the maximum. + if (FLAG_IS_DEFAULT(LargePageSizeInBytes) || + LargePageSizeInBytes == 0 || + LargePageSizeInBytes == default_large_page_size) { _large_page_size = default_large_page_size; - log_info(pagesize)("LargePageSizeInBytes is not a valid large page size (" SIZE_FORMAT "%s) " - "using the default large page size: " SIZE_FORMAT "%s", - byte_size_in_exact_unit(LargePageSizeInBytes), - exact_unit_for_byte_size(LargePageSizeInBytes), + log_info(pagesize)("Using the default large page size: " SIZE_FORMAT "%s", byte_size_in_exact_unit(_large_page_size), exact_unit_for_byte_size(_large_page_size)); + } else { + if (all_large_pages.contains(LargePageSizeInBytes)) { + _large_page_size = LargePageSizeInBytes; + log_info(pagesize)("Overriding default large page size (" SIZE_FORMAT "%s) " + "using LargePageSizeInBytes: " SIZE_FORMAT "%s", + byte_size_in_exact_unit(default_large_page_size), + exact_unit_for_byte_size(default_large_page_size), + byte_size_in_exact_unit(_large_page_size), + exact_unit_for_byte_size(_large_page_size)); + } else { + _large_page_size = default_large_page_size; + log_info(pagesize)("LargePageSizeInBytes is not a valid large page size (" SIZE_FORMAT "%s) " + "using the default large page size: " SIZE_FORMAT "%s", + byte_size_in_exact_unit(LargePageSizeInBytes), + exact_unit_for_byte_size(LargePageSizeInBytes), + byte_size_in_exact_unit(_large_page_size), + exact_unit_for_byte_size(_large_page_size)); + } } - } - // Populate _page_sizes with large page sizes less than or equal to - // _large_page_size. - for (size_t page_size = _large_page_size; page_size != 0; - page_size = all_large_pages.next_smaller(page_size)) { - _page_sizes.add(page_size); - } - - LogTarget(Info, pagesize) lt; - if (lt.is_enabled()) { - LogStream ls(lt); - ls.print("Usable page sizes: "); - _page_sizes.print_on(&ls); + // Populate _page_sizes with large page sizes less than or equal to + // _large_page_size. + for (size_t page_size = _large_page_size; page_size != 0; + page_size = all_large_pages.next_smaller(page_size)) { + _page_sizes.add(page_size); + } } // Now determine the type of large pages to use: diff --git a/src/hotspot/os/linux/os_linux.hpp b/src/hotspot/os/linux/os_linux.hpp index d618e72bf64af..dc83208f60387 100644 --- a/src/hotspot/os/linux/os_linux.hpp +++ b/src/hotspot/os/linux/os_linux.hpp @@ -50,8 +50,6 @@ class Linux { static GrowableArray* _cpu_to_node; static GrowableArray* _nindex_to_node; - static size_t _default_large_page_size; - protected: static julong _physical_memory; @@ -75,10 +73,6 @@ class Linux { static GrowableArray* cpu_to_node() { return _cpu_to_node; } static GrowableArray* nindex_to_node() { return _nindex_to_node; } - static size_t default_large_page_size(); - static size_t scan_default_large_page_size(); - static os::PageSizes scan_multiple_page_support(); - static bool setup_large_page_type(size_t page_size); static bool transparent_huge_pages_sanity_check(bool warn, size_t pages_size); static bool hugetlbfs_sanity_check(bool warn, size_t page_size); diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index dc756359967d9..eeb19980dbf5c 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -357,6 +357,9 @@ inline size_t byte_size_in_exact_unit(size_t s) { return s; } +#define EXACTFMT SIZE_FORMAT "%s" +#define EXACTFMTARGS(s) byte_size_in_exact_unit(s), exact_unit_for_byte_size(s) + // Memory size transition formatting. #define HEAP_CHANGE_FORMAT "%s: " SIZE_FORMAT "K(" SIZE_FORMAT "K)->" SIZE_FORMAT "K(" SIZE_FORMAT "K)" diff --git a/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java b/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java new file mode 100644 index 0000000000000..a0590b7739d7d --- /dev/null +++ b/test/hotspot/jtreg/runtime/os/HugePageConfiguration.java @@ -0,0 +1,221 @@ +/* + * 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. + */ + +import jdk.test.lib.process.OutputAnalyzer; + +import java.io.*; +import java.util.Set; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +class HugePageConfiguration { + + Set _staticHugePageSizes; + long _staticDefaultHugePageSize; + + enum THPMode {always, never, madvise, unknown} + THPMode _thpMode; + long _thpPageSize; + + public Set getStaticHugePageSizes() { + return _staticHugePageSizes; + } + + public long getStaticDefaultHugePageSize() { + return _staticDefaultHugePageSize; + } + + public THPMode getThpMode() { + return _thpMode; + } + + public long getThpPageSize() { + return _thpPageSize; + } + + public HugePageConfiguration(Set _staticHugePageSizes, long _staticDefaultHugePageSize, THPMode _thpMode, long _thpPageSize) { + this._staticHugePageSizes = _staticHugePageSizes; + this._staticDefaultHugePageSize = _staticDefaultHugePageSize; + this._thpMode = _thpMode; + this._thpPageSize = _thpPageSize; + } + + @Override + public String toString() { + return "Configuration{" + + "_staticHugePageSizes=" + _staticHugePageSizes + + ", _staticDefaultHugePageSize=" + _staticDefaultHugePageSize + + ", _thpMode=" + _thpMode + + ", _thpPageSize=" + _thpPageSize + + '}'; + } + + @Override + 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); + } + + private static long readDefaultHugePageSizeFromOS() { + Pattern pat = Pattern.compile("Hugepagesize: *(\\d+) +kB"); + long result = 0; + try (Scanner scanner = new Scanner(new File("/proc/meminfo"))) { + while (scanner.hasNextLine()) { + Matcher mat = pat.matcher(scanner.nextLine()); + if (mat.matches()) { + scanner.close(); + return Long.parseLong(mat.group(1)) * 1024; + } + } + } catch (FileNotFoundException e) { + System.out.println("Could not open /proc/meminfo"); + } + return 0; + } + + private static Set readSupportedHugePagesFromOS() { + TreeSet pagesizes = 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(); + Matcher mat = pat.matcher(name); + if (mat.matches()) { + long pagesize = Long.parseLong(mat.group(1)) * 1024; + pagesizes.add(pagesize); + } + } + } + return pagesizes; + } + + private static THPMode readTHPModeFromOS() { + THPMode mode = THPMode.unknown; + String file = "/sys/kernel/mm/transparent_hugepage/enabled"; + try (FileReader fr = new FileReader(file); + BufferedReader reader = new BufferedReader(fr)) { + String s = reader.readLine(); + if (s.contains("[never]")) { + mode = THPMode.never; + } else if (s.contains("[always]")) { + mode = THPMode.always; + } else if (s.contains("[madvise]")) { + mode = THPMode.madvise; + } else { + throw new RuntimeException("Unexpected content of " + file + ": " + s); + } + } catch (IOException e) { + System.out.println("Failed to read " + file); + mode = THPMode.unknown; + } + return mode; + } + + private static long readTHPPageSizeFromOS() { + long pagesize = 0; + String file = "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size"; + try (FileReader fr = new FileReader(file); + BufferedReader reader = new BufferedReader(fr)) { + String s = reader.readLine(); + pagesize = Long.parseLong(s); + } catch (IOException | NumberFormatException e) { /* ignored */ } + return pagesize; + } + + // Fill object with info read from proc file system + public static HugePageConfiguration readFromOS() { + return new HugePageConfiguration(readSupportedHugePagesFromOS(), + readDefaultHugePageSizeFromOS(), + readTHPModeFromOS(), + readTHPPageSizeFromOS()); + } + + private static long parseSIUnit(String num, String unit) { + long n = Long.parseLong(num); + return switch (unit) { + case "K" -> n * 1024; + case "M" -> n * 1024 * 1024; + case "G" -> n * 1024 * 1024 * 1024; + default -> throw new RuntimeException("Invalid unit " + unit); + }; + } + + public static HugePageConfiguration readFromJVMLog(OutputAnalyzer output) { + // Expects output from -Xlog:pagesize + // Example: + // [0.001s][info][pagesize] Static hugepage support: + // [0.001s][info][pagesize] hugepage size: 2M + // [0.001s][info][pagesize] hugepage size: 1G + // [0.001s][info][pagesize] default hugepage size: 2M + // [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<>(); + long defaultHugepageSize = 0; + THPMode thpMode = THPMode.never; + long thpPageSize = 0; + Pattern patternHugepageSize = Pattern.compile(".*\\[pagesize] *hugepage size: (\\d+)([KMG])"); + Pattern patternDefaultHugepageSize = Pattern.compile(".*\\[pagesize] *default hugepage size: (\\d+)([KMG]) *"); + Pattern patternTHPPageSize = Pattern.compile(".*\\[pagesize] *THP pagesize: (\\d+)([KMG])"); + Pattern patternTHPMode = Pattern.compile(".*\\[pagesize] *THP mode: (\\S+)"); + List lines = output.asLines(); + for (String s : lines) { + Matcher mat = patternHugepageSize.matcher(s); + if (mat.matches()) { + hugepages.add(parseSIUnit(mat.group(1), mat.group(2))); + continue; + } + if (defaultHugepageSize == 0) { + mat = patternDefaultHugepageSize.matcher(s); + if (mat.matches()) { + defaultHugepageSize = parseSIUnit(mat.group(1), mat.group(2)); + continue; + } + } + if (thpPageSize == 0) { + mat = patternTHPPageSize.matcher(s); + if (mat.matches()) { + thpPageSize = parseSIUnit(mat.group(1), mat.group(2)); + continue; + } + } + mat = patternTHPMode.matcher(s); + if (mat.matches()) { + thpMode = THPMode.valueOf(mat.group(1)); + } + } + + return new HugePageConfiguration(hugepages, defaultHugepageSize, thpMode, thpPageSize); + } + +} diff --git a/test/hotspot/jtreg/runtime/os/HugePageDetection.java b/test/hotspot/jtreg/runtime/os/HugePageDetection.java new file mode 100644 index 0000000000000..40d67198c5fcd --- /dev/null +++ b/test/hotspot/jtreg/runtime/os/HugePageDetection.java @@ -0,0 +1,75 @@ +/* + * 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 + * @summary Test that the JVM detects the OS hugepage/THP settings correctly. + * @library /test/lib + * @requires os.family == "linux" + * @modules java.base/jdk.internal.misc + * java.management + * @run driver HugePageDetection + */ + +import java.util.*; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class HugePageDetection { + + public static void main(String[] args) throws Exception { + + ArrayList finalargs = new ArrayList(); + String[] defaultArgs = { + "-Xlog:pagesize", "-Xmx64M", "-XX:-CreateCoredumpOnCrash" + }; + finalargs.addAll(Arrays.asList(defaultArgs)); + finalargs.add("-version"); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + new String[] {"-Xlog:pagesize", "-Xmx64M", "-version"}); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.reportDiagnosticSummary(); + output.shouldHaveExitValue(0); + + // The configuration detected by the JVM should match the OS settings + + HugePageConfiguration configurationFromOS = HugePageConfiguration.readFromOS(); + System.out.println("Configuration read from OS: " + configurationFromOS); + + HugePageConfiguration configurationFromLog = HugePageConfiguration.readFromJVMLog(output); + System.out.println("Configuration read from JVM log: " + configurationFromLog); + + if (configurationFromOS.equals(configurationFromLog)) { + System.out.println("Okay"); + } else { + throw new RuntimeException("Configurations differ"); + } + + // If we want to run + + } + +} From 0d4fbb460d8ed6bb2695cbaad8a345dfe4d6b005 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 30 Aug 2023 15:57:31 +0000 Subject: [PATCH 068/341] 8295229: Try to verify gtest version Backport-of: cd1357b0af0d4e3b459fcf88e67510502464bb90 --- doc/testing.html | 1 + doc/testing.md | 5 +++++ make/autoconf/lib-tests.m4 | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/testing.html b/doc/testing.html index e9ff786349743..047a7dc1ba71f 100644 --- a/doc/testing.html +++ b/doc/testing.html @@ -88,6 +88,7 @@

JTReg

Individual JTReg tests or directories containing JTReg tests can also be specified, like test/hotspot/jtreg/native_sanity/JniVersion.java or hotspot/jtreg/native_sanity. Just like for test root selection, you can either specify an absolute path (which can even point to JTReg tests outside the source tree), or a path relative to either the JDK top directory or the test directory. hotspot can be used as an alias for hotspot/jtreg here as well.

As long as the test groups or test paths can be uniquely resolved, you do not need to enter the jtreg: prefix. If this is not possible, or if you want to use a fully qualified test descriptor, add jtreg:, e.g. jtreg:test/hotspot/jtreg/native_sanity.

Gtest

+

Note: To be able to run the Gtest suite, you need to configure your build to be able to find a proper version of the gtest source. For details, see the section "Running Tests" in the build documentation.

Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just gtest, or as a fully qualified test descriptor gtest:all.

If you want, you can single out an individual test or a group of tests, for instance gtest:LogDecorations or gtest:LogDecorations.level_test_vm. This can be particularly useful if you want to run a shaky test repeatedly.

For Gtest, there is a separate test suite for each JVM variant. The JVM variant is defined by adding /<variant> to the test descriptor, e.g. gtest:Log/client. If you specify no variant, gtest will run once for each JVM variant present (e.g. server, client). So if you only have the server JVM present, then gtest:all will be equivalent to gtest:all/server.

diff --git a/doc/testing.md b/doc/testing.md index 7f11fb2b51195..34cd2b0bcafd6 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -142,6 +142,11 @@ use a fully qualified test descriptor, add `jtreg:`, e.g. ### Gtest +**Note:** To be able to run the Gtest suite, you need to configure your build to +be able to find a proper version of the gtest source. For details, see the +section ["Running Tests" in the build +documentation](building.html#running-tests). + Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just `gtest`, or as a fully qualified test descriptor `gtest:all`. diff --git a/make/autoconf/lib-tests.m4 b/make/autoconf/lib-tests.m4 index 0fd72c1c869cb..6c9570aa507d5 100644 --- a/make/autoconf/lib-tests.m4 +++ b/make/autoconf/lib-tests.m4 @@ -54,9 +54,25 @@ AC_DEFUN_ONCE([LIB_TESTS_SETUP_GTEST], AC_MSG_RESULT([no]) AC_MSG_ERROR([Can't find 'googlemock/include/gmock/gmock.h' under ${with_gtest} given with the --with-gtest option.]) else - GTEST_FRAMEWORK_SRC=${with_gtest} + GTEST_FRAMEWORK_SRC=$with_gtest AC_MSG_RESULT([$GTEST_FRAMEWORK_SRC]) UTIL_FIXUP_PATH([GTEST_FRAMEWORK_SRC]) + + # Try to verify version. We require 1.8.1, but this can not be directly + # determined. :-( Instead, there are different, incorrect version + # numbers we can look for. + GTEST_VERSION_1="`$GREP GOOGLETEST_VERSION $GTEST_FRAMEWORK_SRC/CMakeLists.txt | $SED -E -e 's/set\(GOOGLETEST_VERSION (.*)\)/\1/'`" + if test "x$GTEST_VERSION_1" != "x1.9.0"; then + AC_MSG_ERROR([gtest at $GTEST_FRAMEWORK_SRC does not seem to be version 1.8.1]) + fi + + # We cannot grep for "AC_IN*T" as a literal since then m4 will treat it as a macro + # and expand it. + # Additional [] needed to keep m4 from mangling shell constructs. + [ GTEST_VERSION_2="`$GREP -A1 ^.C_INIT $GTEST_FRAMEWORK_SRC/configure.ac | $TAIL -n 1 | $SED -E -e 's/ +\[(.*)],/\1/'`" ] + if test "x$GTEST_VERSION_2" != "x1.8.0"; then + AC_MSG_ERROR([gtest at $GTEST_FRAMEWORK_SRC does not seem to be version 1.8.1 B]) + fi fi fi fi From fbe3773a3256e1c663ba84cd0f5b67d0dcfc23c2 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Wed, 30 Aug 2023 17:56:16 +0000 Subject: [PATCH 069/341] 8312394: [linux] SIGSEGV if kernel was built without hugepage support Backport-of: 94eb44b192ba421692549a178c386ea34164ea50 --- src/hotspot/os/linux/hugepages.cpp | 36 +++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/hotspot/os/linux/hugepages.cpp b/src/hotspot/os/linux/hugepages.cpp index 299c27a8c1ded..ab1c74b2f3acb 100644 --- a/src/hotspot/os/linux/hugepages.cpp +++ b/src/hotspot/os/linux/hugepages.cpp @@ -111,20 +111,22 @@ static os::PageSizes scan_hugepages() { os::PageSizes pagesizes; - DIR *dir = opendir(sys_hugepages); - - struct dirent *entry; - size_t pagesize; - while ((entry = readdir(dir)) != nullptr) { - if (entry->d_type == DT_DIR && - sscanf(entry->d_name, "hugepages-%zukB", &pagesize) == 1) { - // The kernel is using kB, hotspot uses bytes - // Add each found Large Page Size to page_sizes - pagesize *= K; - pagesizes.add(pagesize); + DIR* dir = opendir(sys_hugepages); + + if (dir != nullptr) { + struct dirent *entry; + size_t pagesize; + while ((entry = readdir(dir)) != nullptr) { + if (entry->d_type == DT_DIR && + sscanf(entry->d_name, "hugepages-%zukB", &pagesize) == 1) { + // The kernel is using kB, hotspot uses bytes + // Add each found Large Page Size to page_sizes + pagesize *= K; + pagesizes.add(pagesize); + } } + closedir(dir); } - closedir(dir); return pagesizes; } @@ -142,11 +144,13 @@ void StaticHugePageSupport::print_on(outputStream* os) { } void StaticHugePageSupport::scan_os() { - _pagesizes = scan_hugepages(); _default_hugepage_size = scan_default_hugepagesize(); - assert(_pagesizes.contains(_default_hugepage_size), - "Unexpected configuration: default pagesize (" SIZE_FORMAT ") " - "has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size); + if (_default_hugepage_size > 0) { + _pagesizes = scan_hugepages(); + assert(_pagesizes.contains(_default_hugepage_size), + "Unexpected configuration: default pagesize (" SIZE_FORMAT ") " + "has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size); + } _initialized = true; LogTarget(Info, pagesize) lt; if (lt.is_enabled()) { From e6b87a7116dffd6f065589edd2821f182b265fa6 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Wed, 30 Aug 2023 17:59:40 +0000 Subject: [PATCH 070/341] 8312182: THPs cause huge RSS due to thread start timing issue 8310687: JDK-8303215 is incomplete Backport-of: 84b325b844c08809448a9c073a11443d9e3c3f8e --- src/hotspot/os/linux/globals_linux.hpp | 9 + src/hotspot/os/linux/os_linux.cpp | 58 ++++- .../os/THPsInThreadStackPreventionTest.java | 241 ++++++++++++++++++ 3 files changed, 301 insertions(+), 7 deletions(-) create mode 100644 test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java diff --git a/src/hotspot/os/linux/globals_linux.hpp b/src/hotspot/os/linux/globals_linux.hpp index 30a47e373d6cb..02257c7373213 100644 --- a/src/hotspot/os/linux/globals_linux.hpp +++ b/src/hotspot/os/linux/globals_linux.hpp @@ -98,6 +98,15 @@ "to disable both the override and the printouts." \ "See prctl(PR_SET_TIMERSLACK) for more info.") \ \ + product(bool, DisableTHPStackMitigation, false, DIAGNOSTIC, \ + "If THPs are unconditionally enabled on the system (mode " \ + "\"always\"), the JVM will prevent THP from forming in " \ + "thread stacks. This switch disables that mitigation and " \ + "allows THPs to form in thread stacks.") \ + \ + develop(bool, DelayThreadStartALot, false, \ + "Artificially delay thread starts randomly for testing.") \ + \ // end of RUNTIME_OS_FLAGS diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 0a7412f57e8e0..358e53eaf07d7 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -721,6 +721,10 @@ static void *thread_native_entry(Thread *thread) { assert(osthread->pthread_id() != 0, "pthread_id was not set as expected"); + if (DelayThreadStartALot) { + os::naked_short_sleep(100); + } + // call one more level start routine thread->call_run(); @@ -857,6 +861,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, // Calculate stack size if it's not specified by caller. size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); size_t guard_size = os::Linux::default_guard_size(thr_type); + // Configure glibc guard page. Must happen before calling // get_static_tls_area_size(), which uses the guard_size. pthread_attr_setguardsize(&attr, guard_size); @@ -877,13 +882,16 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, } assert(is_aligned(stack_size, os::vm_page_size()), "stack_size not aligned"); - // Add an additional page to the stack size to reduce its chances of getting large page aligned - // so that the stack does not get backed by a transparent huge page. - size_t default_large_page_size = HugePages::default_static_hugepage_size(); - if (default_large_page_size != 0 && - stack_size >= default_large_page_size && - is_aligned(stack_size, default_large_page_size)) { - stack_size += os::vm_page_size(); + if (!DisableTHPStackMitigation) { + // In addition to the glibc guard page that prevents inter-thread-stack hugepage + // coalescing (see comment in os::Linux::default_guard_size()), we also make + // sure the stack size itself is not huge-page-size aligned; that makes it much + // more likely for thread stack boundaries to be unaligned as well and hence + // protects thread stacks from being targeted by khugepaged. + if (HugePages::thp_pagesize() > 0 && + is_aligned(stack_size, HugePages::thp_pagesize())) { + stack_size += os::vm_page_size(); + } } int status = pthread_attr_setstacksize(&attr, stack_size); @@ -3135,6 +3143,27 @@ bool os::Linux::libnuma_init() { } size_t os::Linux::default_guard_size(os::ThreadType thr_type) { + + if (!DisableTHPStackMitigation) { + // If THPs are unconditionally enabled, the following scenario can lead to huge RSS + // - parent thread spawns, in quick succession, multiple child threads + // - child threads are slow to start + // - thread stacks of future child threads are adjacent and get merged into one large VMA + // by the kernel, and subsequently transformed into huge pages by khugepaged + // - child threads come up, place JVM guard pages, thus splinter the large VMA, splinter + // the huge pages into many (still paged-in) small pages. + // The result of that sequence are thread stacks that are fully paged-in even though the + // threads did not even start yet. + // We prevent that by letting the glibc allocate a guard page, which causes a VMA with different + // permission bits to separate two ajacent thread stacks and therefore prevent merging stacks + // into one VMA. + // + // Yes, this means we have two guard sections - the glibc and the JVM one - per thread. But the + // cost for that one extra protected page is dwarfed from a large win in performance and memory + // that avoiding interference by khugepaged buys us. + return os::vm_page_size(); + } + // Creating guard page is very expensive. Java thread has HotSpot // guard pages, only enable glibc guard page for non-Java threads. // (Remember: compiler thread is a Java thread, too!) @@ -3798,6 +3827,21 @@ void os::large_page_init() { // Query OS information first. HugePages::initialize(); + // If THPs are unconditionally enabled (THP mode "always"), khugepaged may attempt to + // coalesce small pages in thread stacks to huge pages. That costs a lot of memory and + // is usually unwanted for thread stacks. Therefore we attempt to prevent THP formation in + // thread stacks unless the user explicitly allowed THP formation by manually disabling + // -XX:+DisableTHPStackMitigation. + if (HugePages::thp_mode() == THPMode::always) { + if (DisableTHPStackMitigation) { + log_info(pagesize)("JVM will *not* prevent THPs in thread stacks. This may cause high RSS."); + } else { + log_info(pagesize)("JVM will attempt to prevent THPs in thread stacks."); + } + } else { + FLAG_SET_ERGO(DisableTHPStackMitigation, true); // Mitigation not needed + } + // 1) Handle the case where we do not want to use huge pages if (!UseLargePages && !UseTransparentHugePages && diff --git a/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java b/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java new file mode 100644 index 0000000000000..f16c5d66311b6 --- /dev/null +++ b/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java @@ -0,0 +1,241 @@ +/* + * 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=ENABLED + * @bug 8303215 8312182 + * @summary On THP=always systems, we prevent THPs from forming within thread stacks + * @library /test/lib + * @requires os.family == "linux" + * @requires vm.debug + * @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64" + * @modules java.base/jdk.internal.misc + * java.management + * @run driver THPsInThreadStackPreventionTest PATCH-ENABLED + */ + +/* + * @test id=DISABLED + * @bug 8303215 8312182 + * @summary On THP=always systems, we prevent THPs from forming within thread stacks (negative test) + * @library /test/lib + * @requires os.family == "linux" + * @requires vm.debug + * @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64" + * @modules java.base/jdk.internal.misc + * java.management + * @run main/manual THPsInThreadStackPreventionTest PATCH-DISABLED + */ +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jtreg.SkippedException; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Objects; +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; + +public class THPsInThreadStackPreventionTest { + + // We test the mitigation for "huge rss for THP=always" introduced with JDK-8312182 and JDK-8302015: + // + // We start a program that spawns a ton of threads with a stack size close to THP page size. The threads + // are idle and should not build up a lot of stack. The threads are started with an artificial delay + // between thread start and stack guardpage creation, which exacerbates the RSS bloat (for explanation + // please see 8312182). + // + // We then observe RSS of that program. We expect it to stay below a reasonable maximum. The unpatched + // version should show an RSS of ~2 GB (paying for the fully paged in thread stacks). The fixed variant should + // cost only ~200-400 MB. + + static final int numThreads = 1000; + static final long threadStackSizeMB = 2; // must be 2M + static final long heapSizeMB = 64; + static final long basicRSSOverheadMB = heapSizeMB + 150; + // A successful completion of this test would show not more than X KB per thread stack. + static final long acceptableRSSPerThreadStack = 128 * 1024; + static final long acceptableRSSForAllThreadStacks = numThreads * acceptableRSSPerThreadStack; + static final long acceptableRSSLimitMB = (acceptableRSSForAllThreadStacks / (1024 * 1024)) + basicRSSOverheadMB; + + private static class TestMain { + + static class Sleeper extends Thread { + CyclicBarrier barrier; + public Sleeper(CyclicBarrier barrier) { + this.barrier = barrier; + } + @Override + public void run() { + try { + barrier.await(); // wait for all siblings + barrier.await(); // wait main thread to print status + } catch (InterruptedException | BrokenBarrierException e) { + e.printStackTrace(); + } + } + } + + public static void main(String[] args) throws BrokenBarrierException, InterruptedException { + + // Fire up 1000 threads with 2M stack size each. + Sleeper[] threads = new Sleeper[numThreads]; + CyclicBarrier barrier = new CyclicBarrier(numThreads + 1); + + for (int i = 0; i < numThreads; i++) { + threads[i] = new Sleeper(barrier); + threads[i].start(); + } + + // Wait for all threads to come up + barrier.await(); + + // print status + String file = "/proc/self/status"; + try (FileReader fr = new FileReader(file); + BufferedReader reader = new BufferedReader(fr)) { + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + } catch (IOException | NumberFormatException e) { /* ignored */ } + + // Signal threads to stop + barrier.await(); + + } + } + + static class ProcSelfStatus { + + public long rssMB; + public long swapMB; + public int numLifeThreads; + + // Parse output from /proc/self/status + public static ProcSelfStatus parse(OutputAnalyzer o) { + ProcSelfStatus status = new ProcSelfStatus(); + String s = o.firstMatch("Threads:\\s*(\\d+)", 1); + Objects.requireNonNull(s); + status.numLifeThreads = Integer.parseInt(s); + s = o.firstMatch("VmRSS:\\s*(\\d+) kB", 1); + Objects.requireNonNull(s); + status.rssMB = Long.parseLong(s) / 1024; + s = o.firstMatch("VmSwap:\\s*(\\d+) kB", 1); + Objects.requireNonNull(s); + status.swapMB = Long.parseLong(s) / 1024; + return status; + } + } + + public static void main(String[] args) throws Exception { + + HugePageConfiguration config = HugePageConfiguration.readFromOS(); + // This issue is bound to THP=always + if (config.getThpMode() != HugePageConfiguration.THPMode.always) { + throw new SkippedException("Test only makes sense in THP \"always\" mode"); + } + + String[] defaultArgs = { + "-Xlog:pagesize", + "-Xmx" + heapSizeMB + "m", "-Xms" + heapSizeMB + "m", "-XX:+AlwaysPreTouch", // stabilize RSS + "-Xss" + threadStackSizeMB + "m", + "-XX:-CreateCoredumpOnCrash", + // This will delay the child threads before they create guard pages, thereby greatly increasing the + // chance of large VMA formation + hugepage coalescation; see JDK-8312182 + "-XX:+DelayThreadStartALot" + }; + ArrayList finalargs = new ArrayList<>(Arrays.asList(defaultArgs)); + + switch (args[0]) { + case "PATCH-ENABLED": { + finalargs.add(TestMain.class.getName()); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + + // this line indicates the mitigation is active: + output.shouldContain("[pagesize] JVM will attempt to prevent THPs in thread stacks."); + + ProcSelfStatus status = ProcSelfStatus.parse(output); + if (status.numLifeThreads < numThreads) { + throw new RuntimeException("Number of live threads lower than expected: " + status.numLifeThreads + ", expected " + numThreads); + } else { + System.out.println("Found " + status.numLifeThreads + " to be alive. Ok."); + } + + long rssPlusSwapMB = status.swapMB + status.rssMB; + + if (rssPlusSwapMB > acceptableRSSLimitMB) { + throw new RuntimeException("RSS+Swap larger than expected: " + rssPlusSwapMB + "m, expected at most " + acceptableRSSLimitMB + "m"); + } else { + if (rssPlusSwapMB < heapSizeMB) { // we pretouch the java heap, so we expect to see at least that: + throw new RuntimeException("RSS+Swap suspiciously low: " + rssPlusSwapMB + "m, expected at least " + heapSizeMB + "m"); + } + System.out.println("Okay: RSS+Swap=" + rssPlusSwapMB + ", within acceptable limit of " + acceptableRSSLimitMB); + } + } + break; + + case "PATCH-DISABLED": { + + // Only execute manually! this will allocate ~2gb of memory! + + // explicitly disable the no-THP-workaround: + finalargs.add("-XX:+UnlockDiagnosticVMOptions"); + finalargs.add("-XX:+DisableTHPStackMitigation"); + + finalargs.add(TestMain.class.getName()); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + output.shouldHaveExitValue(0); + + // We deliberately switched off mitigation, VM should tell us: + output.shouldContain("[pagesize] JVM will *not* prevent THPs in thread stacks. This may cause high RSS."); + + // Parse output from self/status + ProcSelfStatus status = ProcSelfStatus.parse(output); + if (status.numLifeThreads < numThreads) { + throw new RuntimeException("Number of live threads lower than expected (" + status.numLifeThreads + ", expected " + numThreads +")"); + } else { + System.out.println("Found " + status.numLifeThreads + " to be alive. Ok."); + } + + long rssPlusSwapMB = status.swapMB + status.rssMB; + + if (rssPlusSwapMB < acceptableRSSLimitMB) { + throw new RuntimeException("RSS+Swap lower than expected: " + rssPlusSwapMB + "m, expected more than " + acceptableRSSLimitMB + "m"); + } + break; + } + + default: throw new RuntimeException("Bad argument: " + args[0]); + } + } +} From e0b39c75416493c9a57b456e85a7f03bd9da7f9f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 31 Aug 2023 04:15:54 +0000 Subject: [PATCH 071/341] 8312535: MidiSystem.getSoundbank() throws unexpected SecurityException Backport-of: 87298d2ade41c689d3140981a123b0e9130fc651 --- .../sun/media/sound/JARSoundbankReader.java | 19 ++++--- .../GetSoundBankSecurityException.java | 50 +++++++++++++++++++ .../security.policy | 4 ++ 3 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 test/jdk/javax/sound/midi/Soundbanks/GetSoundBankSecurityException/GetSoundBankSecurityException.java create mode 100644 test/jdk/javax/sound/midi/Soundbanks/GetSoundBankSecurityException/security.policy diff --git a/src/java.desktop/share/classes/com/sun/media/sound/JARSoundbankReader.java b/src/java.desktop/share/classes/com/sun/media/sound/JARSoundbankReader.java index 16749e99b89dc..f64c9a2327c3a 100644 --- a/src/java.desktop/share/classes/com/sun/media/sound/JARSoundbankReader.java +++ b/src/java.desktop/share/classes/com/sun/media/sound/JARSoundbankReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ import java.io.InputStreamReader; import java.net.URL; import java.net.URLClassLoader; +import java.security.AccessController; import java.util.ArrayList; import java.util.Objects; @@ -40,6 +41,7 @@ import javax.sound.midi.spi.SoundbankReader; import sun.reflect.misc.ReflectUtil; +import sun.security.action.GetBooleanAction; /** * JarSoundbankReader is used to read soundbank object from jar files. @@ -48,12 +50,15 @@ */ public final class JARSoundbankReader extends SoundbankReader { - /* - * Name of the system property that enables the Jar soundbank loading - * true if jar sound bank is allowed to be loaded - * default is false + /** + * Value of the system property that enables the Jar soundbank loading + * {@code true} if jar sound bank is allowed to be loaded default is + * {@code false}. */ - private final static String JAR_SOUNDBANK_ENABLED = "jdk.sound.jarsoundbank"; + @SuppressWarnings("removal") + private static final boolean JAR_SOUNDBANK_ENABLED = + AccessController.doPrivileged( + new GetBooleanAction("jdk.sound.jarsoundbank")); private static boolean isZIP(URL url) { boolean ok = false; @@ -81,7 +86,7 @@ private static boolean isZIP(URL url) { public Soundbank getSoundbank(URL url) throws InvalidMidiDataException, IOException { Objects.requireNonNull(url); - if (!Boolean.getBoolean(JAR_SOUNDBANK_ENABLED) || !isZIP(url)) + if (!JAR_SOUNDBANK_ENABLED || !isZIP(url)) return null; ArrayList soundbanks = new ArrayList<>(); diff --git a/test/jdk/javax/sound/midi/Soundbanks/GetSoundBankSecurityException/GetSoundBankSecurityException.java b/test/jdk/javax/sound/midi/Soundbanks/GetSoundBankSecurityException/GetSoundBankSecurityException.java new file mode 100644 index 0000000000000..53f0450f48236 --- /dev/null +++ b/test/jdk/javax/sound/midi/Soundbanks/GetSoundBankSecurityException/GetSoundBankSecurityException.java @@ -0,0 +1,50 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; + +import javax.sound.midi.InvalidMidiDataException; +import javax.sound.midi.MidiSystem; + +/** + * @test + * @bug 8312535 + * @summary MidiSystem.getSoundbank() throws unexpected SecurityException + * @run main/othervm/policy=security.policy GetSoundBankSecurityException + */ +public final class GetSoundBankSecurityException { + + public static void main(String[] args) throws Exception { + File tempFile = new File("sound.bank"); + tempFile.createNewFile(); + try { + MidiSystem.getSoundbank(tempFile); + throw new RuntimeException("InvalidMidiDataException is expected"); + } catch (InvalidMidiDataException ignore) { + } finally { + Files.delete(Paths.get(tempFile.getAbsolutePath())); + } + } +} diff --git a/test/jdk/javax/sound/midi/Soundbanks/GetSoundBankSecurityException/security.policy b/test/jdk/javax/sound/midi/Soundbanks/GetSoundBankSecurityException/security.policy new file mode 100644 index 0000000000000..6c9c2a26aaf04 --- /dev/null +++ b/test/jdk/javax/sound/midi/Soundbanks/GetSoundBankSecurityException/security.policy @@ -0,0 +1,4 @@ +grant { + permission java.io.FilePermission "*", "read,write,delete"; + permission java.util.PropertyPermission "user.dir", "read"; +}; From 804ce093a4b7c31e7d14f7e396df46b65fb1a974 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Thu, 31 Aug 2023 04:54:00 +0000 Subject: [PATCH 072/341] 8312620: WSL Linux build crashes after JDK-8310233 Backport-of: 25058cd23ac9c8993e7acfd82728ee4c623f0914 --- src/hotspot/os/linux/hugepages.cpp | 17 +++++++++++++---- src/hotspot/os/linux/hugepages.hpp | 7 ++++++- ...etection.java => TestHugePageDetection.java} | 4 ++-- 3 files changed, 21 insertions(+), 7 deletions(-) rename test/hotspot/jtreg/runtime/os/{HugePageDetection.java => TestHugePageDetection.java} (97%) diff --git a/src/hotspot/os/linux/hugepages.cpp b/src/hotspot/os/linux/hugepages.cpp index ab1c74b2f3acb..f9f9dd497c7b6 100644 --- a/src/hotspot/os/linux/hugepages.cpp +++ b/src/hotspot/os/linux/hugepages.cpp @@ -36,7 +36,7 @@ #include StaticHugePageSupport::StaticHugePageSupport() : - _initialized(false), _pagesizes(), _default_hugepage_size(SIZE_MAX) {} + _initialized(false), _pagesizes(), _default_hugepage_size(SIZE_MAX), _inconsistent(false) {} os::PageSizes StaticHugePageSupport::pagesizes() const { assert(_initialized, "Not initialized"); @@ -141,15 +141,24 @@ void StaticHugePageSupport::print_on(outputStream* os) { } else { os->print_cr(" unknown."); } + if (_inconsistent) { + os->print_cr(" Support inconsistent. JVM will not use static hugepages."); + } } void StaticHugePageSupport::scan_os() { _default_hugepage_size = scan_default_hugepagesize(); if (_default_hugepage_size > 0) { _pagesizes = scan_hugepages(); - assert(_pagesizes.contains(_default_hugepage_size), - "Unexpected configuration: default pagesize (" SIZE_FORMAT ") " - "has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size); + // See https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt: /proc/meminfo should match + // /sys/kernel/mm/hugepages/hugepages-xxxx. However, we may run on a broken kernel (e.g. on WSL) + // that only exposes /proc/meminfo but not /sys/kernel/mm/hugepages. In that case, we are not + // sure about the state of hugepage support by the kernel, so we won't use static hugepages. + if (!_pagesizes.contains(_default_hugepage_size)) { + log_info(pagesize)("Unexpected configuration: default pagesize (" SIZE_FORMAT ") " + "has no associated directory in /sys/kernel/mm/hugepages..", _default_hugepage_size); + _inconsistent = true; + } } _initialized = true; LogTarget(Info, pagesize) lt; diff --git a/src/hotspot/os/linux/hugepages.hpp b/src/hotspot/os/linux/hugepages.hpp index 2f378fdc2249d..cb7c992d78950 100644 --- a/src/hotspot/os/linux/hugepages.hpp +++ b/src/hotspot/os/linux/hugepages.hpp @@ -52,6 +52,9 @@ class StaticHugePageSupport { // - is the size one gets when using mmap(MAP_HUGETLB) when omitting size specifiers like MAP_HUGE_SHIFT) size_t _default_hugepage_size; + // If true, the kernel support for hugepages is inconsistent + bool _inconsistent; + public: StaticHugePageSupport(); @@ -60,6 +63,8 @@ class StaticHugePageSupport { os::PageSizes pagesizes() const; size_t default_hugepage_size() const; void print_on(outputStream* os); + + bool inconsistent() const { return _inconsistent; } }; enum class THPMode { always, never, madvise }; @@ -98,7 +103,7 @@ class HugePages : public AllStatic { static const THPSupport& thp_info() { return _thp_support; } static size_t default_static_hugepage_size() { return _static_hugepage_support.default_hugepage_size(); } - static bool supports_static_hugepages() { return default_static_hugepage_size() > 0; } + static bool supports_static_hugepages() { return default_static_hugepage_size() > 0 && !_static_hugepage_support.inconsistent(); } static THPMode thp_mode() { return _thp_support.mode(); } static bool supports_thp() { return thp_mode() == THPMode::madvise || thp_mode() == THPMode::always; } static size_t thp_pagesize() { return _thp_support.pagesize(); } diff --git a/test/hotspot/jtreg/runtime/os/HugePageDetection.java b/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java similarity index 97% rename from test/hotspot/jtreg/runtime/os/HugePageDetection.java rename to test/hotspot/jtreg/runtime/os/TestHugePageDetection.java index 40d67198c5fcd..2dac98000f5af 100644 --- a/test/hotspot/jtreg/runtime/os/HugePageDetection.java +++ b/test/hotspot/jtreg/runtime/os/TestHugePageDetection.java @@ -29,14 +29,14 @@ * @requires os.family == "linux" * @modules java.base/jdk.internal.misc * java.management - * @run driver HugePageDetection + * @run driver TestHugePageDetection */ import java.util.*; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -public class HugePageDetection { +public class TestHugePageDetection { public static void main(String[] args) throws Exception { From eb639a25fd90428e45abad69e3ddb9220a37fc98 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Thu, 31 Aug 2023 11:50:25 +0000 Subject: [PATCH 073/341] 8312585: Rename DisableTHPStackMitigation flag to THPStackMitigation Backport-of: 226cdc696d933fbc174d07b0d9817246dbc0e06c --- src/hotspot/os/linux/globals_linux.hpp | 4 ++-- src/hotspot/os/linux/os_linux.cpp | 14 +++++++------- .../os/THPsInThreadStackPreventionTest.java | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hotspot/os/linux/globals_linux.hpp b/src/hotspot/os/linux/globals_linux.hpp index 02257c7373213..ff683cbde2963 100644 --- a/src/hotspot/os/linux/globals_linux.hpp +++ b/src/hotspot/os/linux/globals_linux.hpp @@ -98,10 +98,10 @@ "to disable both the override and the printouts." \ "See prctl(PR_SET_TIMERSLACK) for more info.") \ \ - product(bool, DisableTHPStackMitigation, false, DIAGNOSTIC, \ + product(bool, THPStackMitigation, true, DIAGNOSTIC, \ "If THPs are unconditionally enabled on the system (mode " \ "\"always\"), the JVM will prevent THP from forming in " \ - "thread stacks. This switch disables that mitigation and " \ + "thread stacks. When disabled, the absence of this mitigation"\ "allows THPs to form in thread stacks.") \ \ develop(bool, DelayThreadStartALot, false, \ diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 358e53eaf07d7..b4055b0e21632 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -882,7 +882,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, } assert(is_aligned(stack_size, os::vm_page_size()), "stack_size not aligned"); - if (!DisableTHPStackMitigation) { + if (THPStackMitigation) { // In addition to the glibc guard page that prevents inter-thread-stack hugepage // coalescing (see comment in os::Linux::default_guard_size()), we also make // sure the stack size itself is not huge-page-size aligned; that makes it much @@ -3144,7 +3144,7 @@ bool os::Linux::libnuma_init() { size_t os::Linux::default_guard_size(os::ThreadType thr_type) { - if (!DisableTHPStackMitigation) { + if (THPStackMitigation) { // If THPs are unconditionally enabled, the following scenario can lead to huge RSS // - parent thread spawns, in quick succession, multiple child threads // - child threads are slow to start @@ -3831,15 +3831,15 @@ void os::large_page_init() { // coalesce small pages in thread stacks to huge pages. That costs a lot of memory and // is usually unwanted for thread stacks. Therefore we attempt to prevent THP formation in // thread stacks unless the user explicitly allowed THP formation by manually disabling - // -XX:+DisableTHPStackMitigation. + // -XX:-THPStackMitigation. if (HugePages::thp_mode() == THPMode::always) { - if (DisableTHPStackMitigation) { - log_info(pagesize)("JVM will *not* prevent THPs in thread stacks. This may cause high RSS."); - } else { + if (THPStackMitigation) { log_info(pagesize)("JVM will attempt to prevent THPs in thread stacks."); + } else { + log_info(pagesize)("JVM will *not* prevent THPs in thread stacks. This may cause high RSS."); } } else { - FLAG_SET_ERGO(DisableTHPStackMitigation, true); // Mitigation not needed + FLAG_SET_ERGO(THPStackMitigation, false); // Mitigation not needed } // 1) Handle the case where we do not want to use huge pages diff --git a/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java b/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java index f16c5d66311b6..83d382f8ec634 100644 --- a/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java +++ b/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java @@ -208,7 +208,7 @@ public static void main(String[] args) throws Exception { // explicitly disable the no-THP-workaround: finalargs.add("-XX:+UnlockDiagnosticVMOptions"); - finalargs.add("-XX:+DisableTHPStackMitigation"); + finalargs.add("-XX:-THPStackMitigation"); finalargs.add(TestMain.class.getName()); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs); From 7f3f76f772a8f63e93bb0297fe4a45b14b9c790b Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 31 Aug 2023 14:03:10 +0000 Subject: [PATCH 074/341] 8286430: make test TEST="gtest:" exits with error when it shouldn't Backport-of: 63a1ec6e7c08fc21d5cded734637eeb80147079f --- make/RunTests.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/RunTests.gmk b/make/RunTests.gmk index 72dc41c237433..ebc96272d66ea 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -523,7 +523,7 @@ define SetupRunGtestTestBody $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR)))) $$(if $$(wildcard $$($1_RESULT_FILE)), \ $$(eval $1_TOTAL := $$(shell $$(AWK) '/==========.* tests? from .* \ - test cases? ran/ { print $$$$2 }' $$($1_RESULT_FILE))) \ + test (cases?|suites?) ran/ { print $$$$2 }' $$($1_RESULT_FILE))) \ $$(if $$($1_TOTAL), , $$(eval $1_TOTAL := 0)) \ $$(eval $1_PASSED := $$(shell $$(AWK) '/\[ PASSED \] .* tests?./ \ { print $$$$4 }' $$($1_RESULT_FILE))) \ From 8d704294d3d0d813a4665aae776c009e3ece8ae0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 31 Aug 2023 14:43:04 +0000 Subject: [PATCH 075/341] 8313626: C2 crash due to unexpected exception control flow Backport-of: f8203cb272e6136b784e5c43a500f6a0bfb19c8b --- src/hotspot/share/opto/doCall.cpp | 4 + .../parsing/MissingSafepointOnTryCatch.jasm | 111 ++++++++++++++++++ .../TestMissingSafepointOnTryCatch.java | 65 ++++++++++ 3 files changed, 180 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/parsing/MissingSafepointOnTryCatch.jasm create mode 100644 test/hotspot/jtreg/compiler/parsing/TestMissingSafepointOnTryCatch.java diff --git a/src/hotspot/share/opto/doCall.cpp b/src/hotspot/share/opto/doCall.cpp index d42f9367dac42..ed0d14348f301 100644 --- a/src/hotspot/share/opto/doCall.cpp +++ b/src/hotspot/share/opto/doCall.cpp @@ -979,6 +979,8 @@ void Parse::catch_inline_exceptions(SafePointNode* ex_map) { if (PrintOpto && WizardMode) { tty->print_cr(" Catching every inline exception bci:%d -> handler_bci:%d", bci(), handler_bci); } + // If this is a backwards branch in the bytecodes, add safepoint + maybe_add_safepoint(handler_bci); merge_exception(handler_bci); // jump to handler return; // No more handling to be done here! } @@ -1010,6 +1012,8 @@ void Parse::catch_inline_exceptions(SafePointNode* ex_map) { klass->print_name(); tty->cr(); } + // If this is a backwards branch in the bytecodes, add safepoint + maybe_add_safepoint(handler_bci); merge_exception(handler_bci); } set_control(not_subtype_ctrl); diff --git a/test/hotspot/jtreg/compiler/parsing/MissingSafepointOnTryCatch.jasm b/test/hotspot/jtreg/compiler/parsing/MissingSafepointOnTryCatch.jasm new file mode 100644 index 0000000000000..5d5fced0cb35b --- /dev/null +++ b/test/hotspot/jtreg/compiler/parsing/MissingSafepointOnTryCatch.jasm @@ -0,0 +1,111 @@ +/* + * 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. + */ + +public class MissingSafepointOnTryCatch version 52:0 { + + static Method m:"()V" { + return; + } + + static Method test1:"()V" stack 1 { + try t; + invokestatic m:"()V"; + return; + + catch t java/lang/Throwable; + stack_map class java/lang/Throwable; + athrow; + endtry t; + } + + static Method test2:"()V" stack 1 { + try t0; + try t1; + invokestatic m:"()V"; + endtry t1; + return; + + catch t1 java/lang/Exception; + stack_map class java/lang/Exception; + return; + + catch t0 java/lang/Throwable; + stack_map class java/lang/Throwable; + athrow; + endtry t0; + } + + public static Method th:"()V" + throws java/lang/Exception + stack 2 locals 0 + { + new class java/lang/Exception; + dup; + invokespecial Method java/lang/Exception."":"()V"; + athrow; + } + + static Method test3:"()V" stack 1 locals 2 { + try t; + invokestatic m:"()V"; + iconst_1; + istore_0; + iconst_0; + istore_1; + return; + catch t java/lang/Throwable; + stack_map class java/lang/Throwable; + invokestatic th:"()V"; + return; + endtry t; + } + + static Method test4:"()V" stack 2 locals 2 { + try t; + invokestatic m:"()V"; + iconst_1; + istore_0; + iconst_0; + istore_1; + return; + catch t java/lang/Throwable; + stack_map class java/lang/Throwable; + iconst_1; + istore_0; + invokestatic th:"()V"; + return; + endtry t; + } + + static Method testInfinite:"()V" stack 1 { + try t; + invokestatic th:"()V"; + return; + + catch t java/lang/Throwable; + stack_map class java/lang/Throwable; + athrow; + endtry t; + } + +} // end Class MissingSafepointOnTryCatch diff --git a/test/hotspot/jtreg/compiler/parsing/TestMissingSafepointOnTryCatch.java b/test/hotspot/jtreg/compiler/parsing/TestMissingSafepointOnTryCatch.java new file mode 100644 index 0000000000000..9a8a313579456 --- /dev/null +++ b/test/hotspot/jtreg/compiler/parsing/TestMissingSafepointOnTryCatch.java @@ -0,0 +1,65 @@ +/* + * 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 8313626 + * @summary assert(false) failed: malformed control flow to missing safepoint on backedge of a try-catch + * @library /test/lib + * @compile MissingSafepointOnTryCatch.jasm + * @run main/othervm -XX:CompileCommand=quiet + * -XX:CompileCommand=compileonly,MissingSafepointOnTryCatch::test* + * -XX:CompileCommand=dontinline,MissingSafepointOnTryCatch::m + * -XX:CompileCommand=inline,MissingSafepointOnTryCatch::th + * -XX:-TieredCompilation -Xcomp TestMissingSafepointOnTryCatch + */ + +import jdk.test.lib.Utils; + +public class TestMissingSafepointOnTryCatch { + + public static void infiniteLoop() { + try { + Thread thread = new Thread() { + public void run() { + MissingSafepointOnTryCatch.testInfinite(); + } + }; + thread.setDaemon(true); + thread.start(); + Thread.sleep(Utils.adjustTimeout(500)); + } catch (Exception e) {} + } + + public static void main(String[] args) { + try { + // to make sure java/lang/Exception class is resolved + MissingSafepointOnTryCatch.th(); + } catch (Exception e) {} + MissingSafepointOnTryCatch.test1(); + MissingSafepointOnTryCatch.test2(); + MissingSafepointOnTryCatch.test3(); + MissingSafepointOnTryCatch.test4(); + infiniteLoop(); + } +} From f85df30c92401376b060d769a5fb08844bbac3d4 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Thu, 31 Aug 2023 15:05:29 +0000 Subject: [PATCH 076/341] 8314139: TEST_BUG: runtime/os/THPsInThreadStackPreventionTest.java could fail on machine with large number of cores Backport-of: 733250288325bc663afc0376342d4c5a7a471cbd --- .../jtreg/runtime/os/THPsInThreadStackPreventionTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java b/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java index 83d382f8ec634..f5ec01e43a689 100644 --- a/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java +++ b/test/hotspot/jtreg/runtime/os/THPsInThreadStackPreventionTest.java @@ -165,6 +165,9 @@ public static void main(String[] args) throws Exception { "-Xmx" + heapSizeMB + "m", "-Xms" + heapSizeMB + "m", "-XX:+AlwaysPreTouch", // stabilize RSS "-Xss" + threadStackSizeMB + "m", "-XX:-CreateCoredumpOnCrash", + // Limits the number of JVM-internal threads, which depends on the available cores of the + // machine. RSS+Swap could exceed acceptableRSSLimitMB when JVM creates many internal threads. + "-XX:ActiveProcessorCount=2", // This will delay the child threads before they create guard pages, thereby greatly increasing the // chance of large VMA formation + hugepage coalescation; see JDK-8312182 "-XX:+DelayThreadStartALot" From 5b613e3ebed6c141146e743e64c894fe4f39421e Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Fri, 1 Sep 2023 15:53:41 +0000 Subject: [PATCH 077/341] 8312489: Increase jdk.jar.maxSignatureFileSize default which is too low for JARs such as WhiteSource/Mend unified agent jar Backport-of: e47a84f23dd2608c6f5748093eefe301fb5bf750 --- .../share/classes/java/util/jar/JarFile.java | 4 +++- .../sun/security/util/SignatureFileVerifier.java | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/java.base/share/classes/java/util/jar/JarFile.java b/src/java.base/share/classes/java/util/jar/JarFile.java index bd538649a4fff..70cf99504e44a 100644 --- a/src/java.base/share/classes/java/util/jar/JarFile.java +++ b/src/java.base/share/classes/java/util/jar/JarFile.java @@ -803,7 +803,9 @@ private byte[] getBytes(ZipEntry ze) throws IOException { throw new IOException("Unsupported size: " + uncompressedSize + " for JarEntry " + ze.getName() + ". Allowed max size: " + - SignatureFileVerifier.MAX_SIG_FILE_SIZE + " bytes"); + SignatureFileVerifier.MAX_SIG_FILE_SIZE + " bytes. " + + "You can use the jdk.jar.maxSignatureFileSize " + + "system property to increase the default value."); } int len = (int)uncompressedSize; int bytesRead; diff --git a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java index 4ea9255ba0a83..05acdcb94748b 100644 --- a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java +++ b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java @@ -856,16 +856,16 @@ private static int initializeMaxSigFileSize() { * the maximum allowed number of bytes for the signature-related files * in a JAR file. */ - Integer tmp = GetIntegerAction.privilegedGetProperty( - "jdk.jar.maxSignatureFileSize", 8000000); + int tmp = GetIntegerAction.privilegedGetProperty( + "jdk.jar.maxSignatureFileSize", 16000000); if (tmp < 0 || tmp > MAX_ARRAY_SIZE) { if (debug != null) { - debug.println("Default signature file size 8000000 bytes " + - "is used as the specified size for the " + - "jdk.jar.maxSignatureFileSize system property " + + debug.println("The default signature file size of 16000000 bytes " + + "will be used for the jdk.jar.maxSignatureFileSize " + + "system property since the specified value " + "is out of range: " + tmp); } - tmp = 8000000; + tmp = 16000000; } return tmp; } From a44f8b059847135ecd0618cb04abbb0d2be1d2d0 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Sat, 2 Sep 2023 08:15:10 +0000 Subject: [PATCH 078/341] 8314960: Add Certigna Root CA - 2 Reviewed-by: mbaesken Backport-of: e9ba8d5a0e74c7e61f963b9a295662899d0156dd --- make/data/cacerts/certignarootca | 43 +++ .../certification/CertignaCA.java | 227 -------------- .../certification/CertignaRoots.java | 293 ++++++++++++++++++ .../security/lib/cacerts/VerifyCACerts.java | 8 +- 4 files changed, 341 insertions(+), 230 deletions(-) create mode 100644 make/data/cacerts/certignarootca delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaCA.java create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaRoots.java diff --git a/make/data/cacerts/certignarootca b/make/data/cacerts/certignarootca new file mode 100644 index 0000000000000..b79092d0cb5a7 --- /dev/null +++ b/make/data/cacerts/certignarootca @@ -0,0 +1,43 @@ +Owner: CN=Certigna Root CA, OU=0002 48146308100036, O=Dhimyotis, C=FR +Issuer: CN=Certigna Root CA, OU=0002 48146308100036, O=Dhimyotis, C=FR +Serial number: cae91b89f155030da3e6416dc4e3a6e1 +Valid from: Tue Oct 01 08:32:27 GMT 2013 until: Sat Oct 01 08:32:27 GMT 2033 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAw +WjELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAw +MiA0ODE0NjMwODEwMDAzNjEZMBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0x +MzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjdaMFoxCzAJBgNVBAYTAkZSMRIwEAYD +VQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgxMDAwMzYxGTAX +BgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw +ggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sO +ty3tRQgXstmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXS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yjhDSSXcNMQH+pkV5a7XdrnxIxPTGRG +HVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH6 +0BGM+RFq7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncB +lA2c5uk5jR+mUYyZDDl34bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdi +o2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1 +gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS6Cvu5zHbugRqh5jnxV/v +faci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaYtlu3zM63 +Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayh +jWZSaX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw +3kAP+HwV96LOPNdeE4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0= +-----END CERTIFICATE----- diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaCA.java deleted file mode 100644 index 5e058233370b3..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaCA.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * 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 8245654 - * @summary Interoperability tests with Certigna Root CA from Dhimyotis - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath CertignaCA OCSP - * @run main/othervm -Djava.security.debug=certpath CertignaCA CRL - */ - -/* - * Obtain TLS test artifacts for Certigna Root CA from: - * - * Valid TLS Certificates: - * https://valid.servicesca.dhimyotis.com/ - * - * Revoked TLS Certificates: - * https://revoked.servicesca.dhimyotis.com/ - */ -public class CertignaCA { - - // Owner: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036, - // OU=0002 48146308100036, O=DHIMYOTIS, C=FR - // Issuer: CN=Certigna, O=Dhimyotis, C=FR - // Serial number: 6f82fa28acd6f784bb5b120ba87367ad - // Valid from: Wed Nov 25 03:33:52 PST 2015 until: Sat Nov 22 03:33:52 PST 2025 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIGFjCCBP6gAwIBAgIQb4L6KKzW94S7WxILqHNnrTANBgkqhkiG9w0BAQsFADA0\n" + - "MQswCQYDVQQGEwJGUjESMBAGA1UECgwJRGhpbXlvdGlzMREwDwYDVQQDDAhDZXJ0\n" + - "aWduYTAeFw0xNTExMjUxMTMzNTJaFw0yNTExMjIxMTMzNTJaMH0xCzAJBgNVBAYT\n" + - "AkZSMRIwEAYDVQQKDAlESElNWU9USVMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgx\n" + - "MDAwMzYxHTAbBgNVBGEMFE5UUkZSLTQ4MTQ2MzA4MTAwMDM2MR0wGwYDVQQDDBRD\n" + - "ZXJ0aWduYSBTZXJ2aWNlcyBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPAD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\n" + - "AAECMDAwLgYIKwYBBQUHAgEWImh0dHBzOi8vd3d3LmNlcnRpZ25hLmZyL2F1dG9y\n" + - "aXRlcy8wfAYIKwYBBQUHAQEEcDBuMDQGCCsGAQUFBzAChihodHRwOi8vYXV0b3Jp\n" + - "dGUuY2VydGlnbmEuZnIvY2VydGlnbmEuZGVyMDYGCCsGAQUFBzAChipodHRwOi8v\n" + - "YXV0b3JpdGUuZGhpbXlvdGlzLmNvbS9jZXJ0aWduYS5kZXIwYQYDVR0fBFowWDAp\n" + - "oCegJYYjaHR0cDovL2NybC5jZXJ0aWduYS5mci9jZXJ0aWduYS5jcmwwK6ApoCeG\n" + - "JWh0dHA6Ly9jcmwuZGhpbXlvdGlzLmNvbS9jZXJ0aWduYS5jcmwwDQYJKoZIhvcN\n" + - "AQELBQADggEBAGLft7gIuGPZVfg0cTM+HT2xAZFPDb/2+siH06x+dH044zMKbBIN\n" + - "bRzhKipwB1A3MW8FQjveE9tyrfyuqZE/X+o2SlGcdNV44ybYkxo4f6kcLEavV/IW\n" + - "+oFEnojZlhpksYcxrvQoEyqkAwshe8IS2KtZHKVACrt+XSs0lwvy7ALGmHaF7A4b\n" + - "y6cZWItA7Lhj8XWp+8tBJDj7HocRbWtxzEODdBuyMgJzFrNjc+97J0vH/K0+3yjm\n" + - "kczpKshMA0tM+MF9XDMN/MuwrPmUWGO/fHiqHgUp8yqeWtl1n44ZxkkK1t9GRwhn\n" + - "DWLv73/xhTmdhWYQ/reo0GbgBoLiltKmIJQ=\n" + - "-----END CERTIFICATE-----"; - - // Owner: SERIALNUMBER=S230100953, CN=valid.servicesca.dhimyotis.com, - // OU=0002 48146308100036, O=DHIMYOTIS, L=VILLENEUVE D'ASCQ, C=FR - // Issuer: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036, - // OU=0002 48146308100036, O=DHIMYOTIS, C=FR - // Serial number: 2959798fe2e0e7b43810169ae938bc5f - // Valid from: Sun Mar 13 16:00:00 PDT 2022 until: Mon Mar 13 15:59:59 PDT 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIIkzCCBnugAwIBAgIQKVl5j+Lg57Q4EBaa6Ti8XzANBgkqhkiG9w0BAQsFADB9\n" + - "MQswCQYDVQQGEwJGUjESMBAGA1UECgwJREhJTVlPVElTMRwwGgYDVQQLDBMwMDAy\n" + - "IDQ4MTQ2MzA4MTAwMDM2MR0wGwYDVQRhDBROVFJGUi00ODE0NjMwODEwMDAzNjEd\n" + - "MBsGA1UEAwwUQ2VydGlnbmEgU2VydmljZXMgQ0EwHhcNMjIwMzEzMjMwMDAwWhcN\n" + - "MjMwMzEzMjI1OTU5WjCBmTELMAkGA1UEBhMCRlIxGjAYBgNVBAcMEVZJTExFTkVV\n" + - "VkUgRCdBU0NRMRIwEAYDVQQKDAlESElNWU9USVMxHDAaBgNVBAsMEzAwMDIgNDgx\n" + - "NDYzMDgxMDAwMzYxJzAlBgNVBAMMHnZhbGlkLnNlcnZpY2VzY2EuZGhpbXlvdGlz\n" + - "LmNvbTETMBEGA1UEBRMKUzIzMDEwMDk1MzCCASIwDQYJKoZIhvcNAQEBBQADggEP\n" + - "ADCCAQoCggEBALpeGHbzRGnv1C0PdJS0nT+Cx98Pw8ctaw51m9Vlk2j8AFGZRu8r\n" + - "lX3noQYX0AIfcbk6KqPAreIvJQV0UgM5jxt3mIQF7iU+55MG4mWmSJgKDDq4b3ck\n" + - "WdBy0KpSBqLmB9sHyTNk9NilNu7VwG03HGIltWA2uQFJGC8CkxwAFpMCQ9RVYw2Z\n" + - "NkL/SsiPgrRLiCJZjesk1oAcLnLp7hbelfUB2Z71VmuDDlom7CsLvdN8eIG+Lj+V\n" + - "wkGmH6AbVGvbFniFDLCNDSJWCQ9AHeO+i0CM/wd2gBRSgm993p2YMxu5mVZjz/rp\n" + - "ELaCYjulvNZKvPIFoNe8qsxlXRWeqWaHuPsCAwEAAaOCA/AwggPsMIHkBggrBgEF\n" + - "BQcBAQSB1zCB1DA4BggrBgE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n" + - "gI0MfBHnjIp1nmNvCNmVIP52YrGQyC2JE7+GZUWTuwUVeDgBhiEZ\n" + - "-----END CERTIFICATE-----"; - - // Owner: SERIALNUMBER=S230120951, CN=revoked.servicesca.dhimyotis.com, - // OU=0002 48146308100036, O=DHIMYOTIS, L=VILLENEUVE D'ASCQ, C=FR - // Issuer: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036, - // OU=0002 48146308100036, O=DHIMYOTIS, C=FR - // Serial number: f88f2566b3dbf73763622db9b2bf9cc - // Valid from: Sun Mar 13 16:00:00 PDT 2022 until: Mon Mar 13 15:59:59 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIImTCCBoGgAwIBAgIQD4jyVms9v3N2NiLbmyv5zDANBgkqhkiG9w0BAQsFADB9\n" + - "MQswCQYDVQQGEwJGUjESMBAGA1UECgwJREhJTVlPVElTMRwwGgYDVQQLDBMwMDAy\n" + - "IDQ4MTQ2MzA4MTAwMDM2MR0wGwYDVQRhDBROVFJGUi00ODE0NjMwODEwMDAzNjEd\n" + - "MBsGA1UEAwwUQ2VydGlnbmEgU2VydmljZXMgQ0EwHhcNMjIwMzEzMjMwMDAwWhcN\n" + - "MjMwMzEzMjI1OTU5WjCBmzELMAkGA1UEBhMCRlIxGjAYBgNVBAcMEVZJTExFTkVV\n" + - "VkUgRCdBU0NRMRIwEAYDVQQKDAlESElNWU9USVMxHDAaBgNVBAsMEzAwMDIgNDgx\n" + - "NDYzMDgxMDAwMzYxKTAnBgNVBAMMIHJldm9rZWQuc2VydmljZXNjYS5kaGlteW90\n" + - "aXMuY29tMRMwEQYDVQQFEwpTMjMwMTIwOTUxMIIBIjANBgkqhkiG9w0BAQEFAAOC\n" + - "AQ8AMIIBCgKCAQEAouvIzemKChCjYICW+TzRigLkqaTdMLnaPlGaXyCCoEUS6nkK\n" + - "QnrwTgebf1X9/mwSAuvTo3Ck7CVgE8AMqsPTluSjezCJuED/F3HYy2YsbIhnVK/i\n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VydmljZXNjYS5jZXJ0aWduYS5jb22CIHJldm9rZWQuc2VydmljZXNjYS5kaGlt\n" + - "eW90aXMuY29tMB0GA1UdDgQWBBTGIed1eHBS8Z1H3PdMkItpjyjq2TCCAX0GCisG\n" + - "AQQB1nkCBAIEggFtBIIBaQFnAHcArfe++nz/EMiLnT2cHj4YarRnKV3PsQwkyoWG\n" + - "NOvcgooAAAF/h9g4MAAABAMASDBGAiEAp/1fQB730JrX9YGD3d1Uq7rTAL95tMKe\n" + - "G6kgUP1GEWoCIQCzi6feA3cImTH6tVZALNEmve/n8SVFAvD2AvX8ioCD9QB1AOg+\n" + - "0No+9QY1MudXKLyJa8kD08vREWvs62nhd31tBr1uAAABf4fYNHcAAAQDAEYwRAIg\n" + - "Dnd8oOV7/MuaiyR23qbdRVf1kBSsDxnLp1/vRdD0JTYCIAw7LuZalEVa/0KpuNHs\n" + - "NIdUJgV4Vioa2xkb9fdPIhtkAHUAs3N3B+GEUPhjhtYFqdwRCUp5LbFnDAuH3PAD\n" + - "Dnk2pZoAAAF/h9g7nwAABAMARjBEAiA80M1W3V3iKjm6Dwn+hKkmvGiuXZoM6o3f\n" + - "QJsZ2ZOx0QIgUiS3I83WzoCdD4qO9rlmDQhRD69CeVzCgLtkaTPz3JYwDQYJKoZI\n" + - "hvcNAQELBQADggIBADKub0gNyasTvURoYukQCllqDC+SvWA4TURBcmQMNjdVkreJ\n" + - "B3O91HZhTyhrCBJxybeIG89zuRI6rjTpHCQGFqtP7968NA3eUlxGGnAPpw6VbN47\n" + - "Ake+CRI9XnhxcKmTGm987DjtIBH42BedS59P1T56grZP5ysOog9Hz4eYo2ytbZqt\n" + - "P/DHggivymaaiIaBsqup8C7/XN3vVAa/yo1FeLJ48i1d0M9hjGBUFMajd8Y5+pE7\n" + - "p6Nb5mT1LXbetORYXMyG3MiJQPBAr1dLnRGnOZxc1Kxa1QwoAFQAFIXFpqfBwfHi\n" + - "NaSDdFS/wLbpe7UvtC8FWLq9sgITDEkPqDPCsbu8Vc7OxaMhBJ7HQGaAYMReGADG\n" + - "Elx9ffAc+dFR62zFnqMLouaEznZ7FVNmU3cYbrFVBvnGmoDRe0AKUoYv5DCiawUg\n" + - "qeQS69DgG7DOE5VIDaWX2Cevy81mz7O8EVQsyS15J/MUxzWfQpRaHUqkge6G9FSH\n" + - "hF/Nm48oWgpWop5aIF2O6bA/Bt1VvAWdypUPUr4gtpYIQoOQBzTFgBVWUeOTOImE\n" + - "avvpzSwGQfZkB7t5PcAQ+zYGxWq7fr30/qY3geePcXJCGWS6PXyj8lNn4CaJ2sMF\n" + - "GKxNJGD49/5uoxi3b3TzGUn/3eG2qP2RZoXZ6ZPLAo+moIy3XLwMoZm3Im8r\n" + - "-----END CERTIFICATE-----"; - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator; - String[] validChainToValidate; - String[] revChainToValidate; - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator = new ValidatePathWithParams(null); - pathValidator.enableCRLCheck(); - - validChainToValidate = new String[]{VALID, INT}; - revChainToValidate = new String[]{REVOKED, INT}; - } else { - // OCSP check by default - // int certificate doesn't specify OCSP responder - pathValidator = new ValidatePathWithParams(new String[]{INT}); - pathValidator.enableOCSPCheck(); - - validChainToValidate = new String[]{VALID}; - revChainToValidate = new String[]{REVOKED}; - } - - // Validate valid - pathValidator.validate(validChainToValidate, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(revChainToValidate, - ValidatePathWithParams.Status.REVOKED, - "Mon Mar 14 03:00:16 PDT 2022", System.out); - } -} - diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaRoots.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaRoots.java new file mode 100644 index 0000000000000..92744eac3d066 --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaRoots.java @@ -0,0 +1,293 @@ +/* + * 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 8245654 8314960 + * @summary Interoperability tests with Certigna Root CAs from Dhimyotis + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath CertignaRoots OCSP + * @run main/othervm -Djava.security.debug=certpath CertignaRoots CRL + */ + +/* + * Obtain TLS test artifacts for Certigna Root CAs from: + * + * Valid TLS Certificates: + * https://valid.servicesca.dhimyotis.com/ + * + * Revoked TLS Certificates: + * https://revoked.servicesca.dhimyotis.com/ + */ +public class CertignaRoots { + + // Owner: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036, + // OU=0002 48146308100036, O=DHIMYOTIS, C=FR + // Issuer: CN=Certigna Root CA, OU=0002 48146308100036, O=Dhimyotis, C=FR + // Serial number: fd30cf04344fc38dd90c4e70753d0623 + // Valid from: Wed Nov 25 03:37:21 PST 2015 until: Fri Jun 03 04:37:21 PDT 2033 + private static final String INT_CERTIGNA_ROOT_CA = "-----BEGIN CERTIFICATE-----\n" + + "MIIHETCCBPmgAwIBAgIRAP0wzwQ0T8ON2QxOcHU9BiMwDQYJKoZIhvcNAQELBQAw\n" + + "WjELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAw\n" + + "M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3DJMqo559m3QSS52DsShomHX/Txd0lJoZwepCE6X4KkG9FHjV\n" + + "WXyLgYFwCOcn+hkLhdpblms0wtjeSPITGOioSkefzhleJnDgJ9X4M3svd0HLTpJi\n" + + "lC1DmDZgdrXWITVdOoCogr2LFKNiGd0tbpKG533eKpfBALlm+afc6j73p1KhJEAn\n" + + "AfydDZqBRqv6+HHYplNDn/K2I1CZdkwaGrx3HOR/voGUi1sUI+hYbsPAFu8ZxrhD\n" + + "9UiysmLCfEUhqkbojony+L2mKsoLqyd24emQzn7GgMa7emlWX2jQUTwrD4SliZ2u\n" + + "OetVaZX5RLyqJWs4Igo/xye0xtMQN8INJ4hSZvnMQ1qFtuSRcQ==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036, + // OU=0002 48146308100036, O=DHIMYOTIS, C=FR + // Issuer: CN=Certigna, O=Dhimyotis, C=FR + // Serial number: 6f82fa28acd6f784bb5b120ba87367ad + // Valid from: Wed Nov 25 03:33:52 PST 2015 until: Sat Nov 22 03:33:52 PST 2025 + private static final String INT_CERTIGNA = "-----BEGIN CERTIFICATE-----\n" + + "MIIGFjCCBP6gAwIBAgIQb4L6KKzW94S7WxILqHNnrTANBgkqhkiG9w0BAQsFADA0\n" + + "MQswCQYDVQQGEwJGUjESMBAGA1UECgwJRGhpbXlvdGlzMREwDwYDVQQDDAhDZXJ0\n" + + "aWduYTAeFw0xNTExMjUxMTMzNTJaFw0yNTExMjIxMTMzNTJaMH0xCzAJBgNVBAYT\n" + + "AkZSMRIwEAYDVQQKDAlESElNWU9USVMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgx\n" + + "MDAwMzYxHTAbBgNVBGEMFE5UUkZSLTQ4MTQ2MzA4MTAwMDM2MR0wGwYDVQQDDBRD\n" + + "ZXJ0aWduYSBTZXJ2aWNlcyBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC\n" + + "ggIBALPM+7LpWBz9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EWImh0dHBzOi8vd3d3LmNlcnRpZ25hLmZyL2F1dG9y\n" + + "aXRlcy8wfAYIKwYBBQUHAQEEcDBuMDQGCCsGAQUFBzAChihodHRwOi8vYXV0b3Jp\n" + + "dGUuY2VydGlnbmEuZnIvY2VydGlnbmEuZGVyMDYGCCsGAQUFBzAChipodHRwOi8v\n" + + "YXV0b3JpdGUuZGhpbXlvdGlzLmNvbS9jZXJ0aWduYS5kZXIwYQYDVR0fBFowWDAp\n" + + "oCegJYYjaHR0cDovL2NybC5jZXJ0aWduYS5mci9jZXJ0aWduYS5jcmwwK6ApoCeG\n" + + "JWh0dHA6Ly9jcmwuZGhpbXlvdGlzLmNvbS9jZXJ0aWduYS5jcmwwDQYJKoZIhvcN\n" + + "AQELBQADggEBAGLft7gIuGPZVfg0cTM+HT2xAZFPDb/2+siH06x+dH044zMKbBIN\n" + + "bRzhKipwB1A3MW8FQjveE9tyrfyuqZE/X+o2SlGcdNV44ybYkxo4f6kcLEavV/IW\n" + + "+oFEnojZlhpksYcxrvQoEyqkAwshe8IS2KtZHKVACrt+XSs0lwvy7ALGmHaF7A4b\n" + + "y6cZWItA7Lhj8XWp+8tBJDj7HocRbWtxzEODdBuyMgJzFrNjc+97J0vH/K0+3yjm\n" + + "kczpKshMA0tM+MF9XDMN/MuwrPmUWGO/fHiqHgUp8yqeWtl1n44ZxkkK1t9GRwhn\n" + + "DWLv73/xhTmdhWYQ/reo0GbgBoLiltKmIJQ=\n" + + "-----END CERTIFICATE-----"; + + // Owner: SERIALNUMBER=S266241169, CN=valid.servicesca.dhimyotis.com, O=DHIMYOTIS, + // L=VILLENEUVE D'ASCQ, C=FR + // Issuer: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036, OU=0002 + // 48146308100036, O=DHIMYOTIS, C=FR + // Serial number: c641ef7b0340c21515d8c462e729dc0e + // Valid from: Thu Mar 09 15:00:00 PST 2023 until: Mon Mar 11 15:59:59 PDT 2024 + private static final String VALID = "-----BEGIN CERTIF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; + + // Owner: SERIALNUMBER=S266251168, CN=revoked.servicesca.certigna.com, O=DHIMYOTIS, + // L=VILLENEUVE D'ASCQ, C=FR + // Issuer: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036, OU=0002 + // 48146308100036, O=DHIMYOTIS, C=FR + // Serial number: e863f752a23a735e3ccf958abf18565b + // Valid from: Thu Mar 09 15:00:00 PST 2023 until: Fri Mar 08 14:59:59 PST 2024 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIIezCCBmOgAwIBAgIRAOhj91KiOnNePM+Vir8YVlswDQYJKoZIhvcNAQELBQAw\n" + + "fTELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURISU1ZT1RJUzEcMBoGA1UECwwTMDAw\n" + + "MiA0ODE0NjMwODEwMDAzNjEdMBsGA1UEYQwUTlRSRlItNDgxNDYzMDgxMDAwMzYx\n" + + "HTAbBgNVBAMMFENlcnRpZ25hIFNlcnZpY2VzIENBMB4XDTIzMDMwOTIzMDAwMFoX\n" + + "DTI0MDMwODIyNTk1OVowfDELMAkGA1UEBhMCRlIxGjAYBgNVBAcMEVZJTExFTkVV\n" + + "VkUgRCdBU0NRMRIwEAYDVQQKDAlESElNWU9USVMxKDAmBgNVBAMMH3Jldm9rZWQu\n" + + "c2VydmljZXNjYS5jZXJ0aWduYS5jb20xEzARBgNVBAUTClMyNjYyNTExNjgwggEi\n" + + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCBqKNjMkHqJ9EQa3CjuZ6EYMz6\n" + + "mWODrEucRcJDihYMigaV1oRyquGlFQ82ootXaK5bU+EYSMmUwbRpdZ9G/oZUn2+K\n" + + "MKAFDI+MoZoFhQC+2w0AzJycCf/hShUVxcRREKRKdfzv+k5YHj3e8ic16tGlTFXT\n" + + "IF1x3y2Uru7mzZARsZJqnRqaqPPghT/QlBpcA04yLi3iSpgO++mRrJxTUoUHlDw/\n" + + "a1nhqnDgH2yKN7tSfwFTetnXat6/UVt0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uaqawRRKMuNSnb2BVz0/\n" + + "keo1Kif/GSak+JUBpJ8hkJWygtrWCETUNfoseQhqo3gism0EGxJ04tBp+DRvfbrz\n" + + "X4aBgALRro3jSIR1Ibp+e0fxePwShy715SF2H4SfjvplTAKq5bwztZtQUkPR6fJ7\n" + + "5xT0f762c1yytKP1rHFMvzl6k7QWvC6zb2FeG5UqXJw3wFxxWsCuAUu5SPFfXdno\n" + + "5lIHTTV5rpZBN+PzTZsz\n" + + "-----END CERTIFICATE-----"; + + public static void main(String[] args) throws Exception { + // OCSP check by default + boolean ocspEnabled = args.length < 1 || !"CRL".equalsIgnoreCase(args[0]); + + // CN=Certigna + new CertignaCAs().runTest(ocspEnabled, + VALID, + REVOKED, + INT_CERTIGNA); + + // CN=Certigna Root CA + new CertignaCAs().runTest(ocspEnabled, + VALID, + REVOKED, + INT_CERTIGNA_ROOT_CA); + } +} + +class CertignaCAs { + public void runTest(boolean ocspEnabled, + final String VALID, + final String REVOKED, + final String INT_CERT) throws Exception { + + ValidatePathWithParams pathValidator; + String[] validChainToValidate; + String[] revChainToValidate; + + if (!ocspEnabled) { + pathValidator = new ValidatePathWithParams(null); + pathValidator.enableCRLCheck(); + + validChainToValidate = new String[]{VALID, INT_CERT}; + revChainToValidate = new String[]{REVOKED, INT_CERT}; + } else { + // int certificate doesn't specify OCSP responder + pathValidator = new ValidatePathWithParams(new String[]{INT_CERT}); + pathValidator.enableOCSPCheck(); + + validChainToValidate = new String[]{VALID}; + revChainToValidate = new String[]{REVOKED}; + } + + // Validate valid + pathValidator.validate(validChainToValidate, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(revChainToValidate, + ValidatePathWithParams.Status.REVOKED, + "Fri Mar 10 03:39:51 PST 2023", System.out); + } +} diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java index 794cf0520a9eb..02831a9deaf5c 100644 --- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java +++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java @@ -28,7 +28,7 @@ * 8209452 8209506 8210432 8195793 8216577 8222089 8222133 8222137 8222136 * 8223499 8225392 8232019 8234245 8233223 8225068 8225069 8243321 8243320 * 8243559 8225072 8258630 8259312 8256421 8225081 8225082 8225083 8245654 - * 8305975 8304760 8307134 8295894 + * 8305975 8304760 8307134 8295894 8314960 * @summary Check root CA entries in cacerts file */ import java.io.ByteArrayInputStream; @@ -47,12 +47,12 @@ public class VerifyCACerts { + File.separator + "security" + File.separator + "cacerts"; // The numbers of certs now. - private static final int COUNT = 96; + private static final int COUNT = 97; // SHA-256 of cacerts, can be generated with // shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95 private static final String CHECKSUM - = "9B:AF:A2:BD:88:C9:74:05:7F:DD:F3:97:85:21:18:4A:52:F0:07:CC:46:FD:2B:90:BA:FB:57:09:18:3B:66:0F"; + = "88:72:92:56:FF:E5:A3:E4:39:98:6D:18:0B:BA:CC:0B:66:CB:1D:6D:52:CE:D7:C8:AD:63:B7:F1:5F:02:24:52"; // Hex formatter to upper case with ":" delimiter private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase(); @@ -252,6 +252,8 @@ public class VerifyCACerts { "34:D8:A7:3E:E2:08:D9:BC:DB:0D:95:65:20:93:4B:4E:40:E6:94:82:59:6E:8B:6F:73:C8:42:6B:01:0A:6F:48"); put("gtsrootecccar4 [jdk]", "34:9D:FA:40:58:C5:E2:63:12:3B:39:8A:E7:95:57:3C:4E:13:13:C8:3F:E6:8F:93:55:6C:D5:E8:03:1B:3C:7D"); + put("certignarootca [jdk]", + "D4:8D:3D:23:EE:DB:50:A4:59:E5:51:97:60:1C:27:77:4B:9D:7B:18:C9:4D:5A:05:95:11:A1:02:50:B9:31:68"); } }; From c4612c12e63a2d8c79beacec528ea29bc8c1c058 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Mon, 4 Sep 2023 12:16:18 +0000 Subject: [PATCH 079/341] 8207166: jdk/jshell/JdiHangingLaunchExecutionControlTest.java - launch timeout Backport-of: 02dce24b59ab53f00309a71ee94f45067c880b5c --- test/langtools/jdk/jshell/HangingRemoteAgent.java | 11 +++++++---- .../jshell/JdiHangingLaunchExecutionControlTest.java | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/test/langtools/jdk/jshell/HangingRemoteAgent.java b/test/langtools/jdk/jshell/HangingRemoteAgent.java index e64f1c25ea387..515f98731a3bb 100644 --- a/test/langtools/jdk/jshell/HangingRemoteAgent.java +++ b/test/langtools/jdk/jshell/HangingRemoteAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. * 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,12 +30,15 @@ import jdk.jshell.spi.ExecutionControlProvider; /** - * Hang for three minutes (long enough to cause a timeout). + * HangingRemoteAgent main() runs in its loop for 2X the timeout + * we give the launcher to fail to attach. */ class HangingRemoteAgent extends RemoteExecutionControl { - private static final long DELAY = 4000L; - private static final int TIMEOUT = 2000; + private static float timeoutFactor = Float.parseFloat(System.getProperty("test.timeout.factor", "1.0")); + + private static final int TIMEOUT = (int)(2000 * timeoutFactor); + private static final long DELAY = TIMEOUT * 2L; private static final boolean INFRA_VERIFY = false; public static void main(String[] args) throws Exception { diff --git a/test/langtools/jdk/jshell/JdiHangingLaunchExecutionControlTest.java b/test/langtools/jdk/jshell/JdiHangingLaunchExecutionControlTest.java index 44354c5743356..577228d482090 100644 --- a/test/langtools/jdk/jshell/JdiHangingLaunchExecutionControlTest.java +++ b/test/langtools/jdk/jshell/JdiHangingLaunchExecutionControlTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. * 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 8169519 + * @bug 8169519 8207166 * @summary Tests for JDI connector timeout failure * @modules jdk.jshell/jdk.jshell jdk.jshell/jdk.jshell.spi jdk.jshell/jdk.jshell.execution * @build HangingRemoteAgent From 75e14419d29c1dc98bd040490e93ae8f6eee4e43 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 5 Sep 2023 14:17:28 +0000 Subject: [PATCH 080/341] 8314495: Update to use jtreg 7.3.1 Reviewed-by: mdoerr, clanger Backport-of: c50315de8f13d316a7de08be53716cd88fa801c4 --- make/autoconf/lib-tests.m4 | 2 +- make/conf/github-actions.conf | 2 +- make/conf/jib-profiles.js | 4 ++-- test/hotspot/jtreg/TEST.ROOT | 4 ++-- test/jaxp/TEST.ROOT | 2 +- test/jdk/TEST.ROOT | 2 +- test/langtools/TEST.ROOT | 2 +- test/lib-test/TEST.ROOT | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/make/autoconf/lib-tests.m4 b/make/autoconf/lib-tests.m4 index 6c9570aa507d5..43ed2aaaf3dba 100644 --- a/make/autoconf/lib-tests.m4 +++ b/make/autoconf/lib-tests.m4 @@ -28,7 +28,7 @@ ################################################################################ # Minimum supported version -JTREG_MINIMUM_VERSION=6.1 +JTREG_MINIMUM_VERSION=7.3.1 ############################################################################### # diff --git a/make/conf/github-actions.conf b/make/conf/github-actions.conf index 9be245534f9e1..746581ba97c64 100644 --- a/make/conf/github-actions.conf +++ b/make/conf/github-actions.conf @@ -26,7 +26,7 @@ # Versions and download locations for dependencies used by GitHub Actions (GHA) GTEST_VERSION=1.8.1 -JTREG_VERSION=6.1+3 +JTREG_VERSION=7.3.1+1 LINUX_X64_BOOT_JDK_EXT=tar.gz LINUX_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.6%2B10/OpenJDK17U-jdk_x64_linux_hotspot_17.0.6_10.tar.gz diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index 5bdfa9ba32ca8..5c4afc9fd0301 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -1156,9 +1156,9 @@ var getJibProfilesDependencies = function (input, common) { jtreg: { server: "jpg", product: "jtreg", - version: "6", + version: "7.3.1", build_number: "1", - file: "bundles/jtreg-6+1.zip", + file: "bundles/jtreg-7.3.1+1.zip", environment_name: "JT_HOME", environment_path: input.get("jtreg", "home_path") + "/bin", configure_args: "--with-jtreg=" + input.get("jtreg", "home_path"), diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT index 80b7f894d9149..36f7c78de2b86 100644 --- a/test/hotspot/jtreg/TEST.ROOT +++ b/test/hotspot/jtreg/TEST.ROOT @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2021, 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 @@ -79,7 +79,7 @@ requires.properties= \ jdk.containerized # Minimum jtreg version -requiredVersion=6+1 +requiredVersion=7.3.1+1 # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../../ notation to reach them diff --git a/test/jaxp/TEST.ROOT b/test/jaxp/TEST.ROOT index 6bda60fa441b5..a44ad3a7c0151 100644 --- a/test/jaxp/TEST.ROOT +++ b/test/jaxp/TEST.ROOT @@ -23,7 +23,7 @@ modules=java.xml groups=TEST.groups # Minimum jtreg version -requiredVersion=6+1 +requiredVersion=7.3.1+1 # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../ notation to reach them diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT index e5cfcdc58df75..3499b3030678c 100644 --- a/test/jdk/TEST.ROOT +++ b/test/jdk/TEST.ROOT @@ -71,7 +71,7 @@ requires.properties= \ jdk.containerized # Minimum jtreg version -requiredVersion=6+1 +requiredVersion=7.3.1+1 # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../ notation to reach them diff --git a/test/langtools/TEST.ROOT b/test/langtools/TEST.ROOT index 7a637baead8a5..b5503c4f71ed4 100644 --- a/test/langtools/TEST.ROOT +++ b/test/langtools/TEST.ROOT @@ -15,7 +15,7 @@ keys=intermittent randomness groups=TEST.groups # Minimum jtreg version -requiredVersion=6+1 +requiredVersion=7.3.1+1 # Use new module options useNewOptions=true diff --git a/test/lib-test/TEST.ROOT b/test/lib-test/TEST.ROOT index b95677fb90d55..9b91a0dfcc155 100644 --- a/test/lib-test/TEST.ROOT +++ b/test/lib-test/TEST.ROOT @@ -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 @@ -29,7 +29,7 @@ keys=randomness # Minimum jtreg version -requiredVersion=6+1 +requiredVersion=7.3.1+1 # Path to libraries in the topmost test directory. This is needed so @library # does not need ../../ notation to reach them From dc00ae47d7af47c1bdc77ef8fd829ab2eacc2eb1 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Tue, 5 Sep 2023 16:45:31 +0000 Subject: [PATCH 081/341] 8299658: C1 compilation crashes in LinearScan::resolve_exception_edge Backport-of: cf2d33ca2ee08c61596ab10b7602500a6931fa31 --- src/hotspot/share/c1/c1_LinearScan.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hotspot/share/c1/c1_LinearScan.cpp b/src/hotspot/share/c1/c1_LinearScan.cpp index 71648f62e141d..d3d38d11a900e 100644 --- a/src/hotspot/share/c1/c1_LinearScan.cpp +++ b/src/hotspot/share/c1/c1_LinearScan.cpp @@ -1953,6 +1953,14 @@ void LinearScan::resolve_exception_edge(XHandler* handler, int throwing_op_id, i // interval at the throwing instruction must be searched using the operands // of the phi function Value from_value = phi->operand_at(handler->phi_operand()); + if (from_value == nullptr) { + // We have reached here in a kotlin application running with JVMTI + // capability "can_access_local_variables". + // The illegal state is not yet propagated to this phi. Do it here. + phi->make_illegal(); + // We can skip the illegal phi edge. + return; + } // with phi functions it can happen that the same from_value is used in // multiple mappings, so notify move-resolver that this is allowed From 6b192d3b5e9eb0d76371dbe4c091f059d5abf845 Mon Sep 17 00:00:00 2001 From: Paul Hohensee Date: Thu, 7 Sep 2023 13:20:10 +0000 Subject: [PATCH 082/341] 8299677: Formatter.format might take a long time to format an integer or floating-point Reviewed-by: mdoerr Backport-of: 33412c102ce799ff2de3512df77e6e07d76acd36 --- .../share/classes/java/util/Formatter.java | 9 +- test/jdk/java/util/Formatter/Padding.java | 313 ++++++++++++++++++ 2 files changed, 317 insertions(+), 5 deletions(-) create mode 100644 test/jdk/java/util/Formatter/Padding.java diff --git a/src/java.base/share/classes/java/util/Formatter.java b/src/java.base/share/classes/java/util/Formatter.java index fd8920ff003b1..0436b7faf89b4 100644 --- a/src/java.base/share/classes/java/util/Formatter.java +++ b/src/java.base/share/classes/java/util/Formatter.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 @@ -4542,10 +4542,9 @@ private StringBuilder localizedMagnitude(StringBuilder sb, } // apply zero padding - if (width != -1 && f.contains(Flags.ZERO_PAD)) { - for (int k = sb.length(); k < width; k++) { - sb.insert(begin, zero); - } + if (width > sb.length() && f.contains(Flags.ZERO_PAD)) { + String zeros = String.valueOf(zero).repeat(width - sb.length()); + sb.insert(begin, zeros); } return sb; diff --git a/test/jdk/java/util/Formatter/Padding.java b/test/jdk/java/util/Formatter/Padding.java new file mode 100644 index 0000000000000..982b696792838 --- /dev/null +++ b/test/jdk/java/util/Formatter/Padding.java @@ -0,0 +1,313 @@ +/* + * 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 4906370 + * @summary Tests to excercise padding on int and double values, + * with various flag combinations. + * @run junit Padding + */ + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.params.provider.Arguments.arguments; + +public class Padding { + + static Arguments[] padding() { + return new Arguments[] { + /* blank padding, right adjusted, optional plus sign */ + arguments("12", "%1d", 12), + arguments("12", "%2d", 12), + arguments(" 12", "%3d", 12), + arguments(" 12", "%4d", 12), + arguments(" 12", "%5d", 12), + arguments(" 12", "%10d", 12), + + arguments("-12", "%1d", -12), + arguments("-12", "%2d", -12), + arguments("-12", "%3d", -12), + arguments(" -12", "%4d", -12), + arguments(" -12", "%5d", -12), + arguments(" -12", "%10d", -12), + + arguments("1.2", "%1.1f", 1.2), + arguments("1.2", "%2.1f", 1.2), + arguments("1.2", "%3.1f", 1.2), + arguments(" 1.2", "%4.1f", 1.2), + arguments(" 1.2", "%5.1f", 1.2), + arguments(" 1.2", "%10.1f", 1.2), + + arguments("-1.2", "%1.1f", -1.2), + arguments("-1.2", "%2.1f", -1.2), + arguments("-1.2", "%3.1f", -1.2), + arguments("-1.2", "%4.1f", -1.2), + arguments(" -1.2", "%5.1f", -1.2), + arguments(" -1.2", "%10.1f", -1.2), + + /* blank padding, right adjusted, mandatory plus sign */ + arguments("+12", "%+1d", 12), + arguments("+12", "%+2d", 12), + arguments("+12", "%+3d", 12), + arguments(" +12", "%+4d", 12), + arguments(" +12", "%+5d", 12), + arguments(" +12", "%+10d", 12), + + arguments("-12", "%+1d", -12), + arguments("-12", "%+2d", -12), + arguments("-12", "%+3d", -12), + arguments(" -12", "%+4d", -12), + arguments(" -12", "%+5d", -12), + arguments(" -12", "%+10d", -12), + + arguments("+1.2", "%+1.1f", 1.2), + arguments("+1.2", "%+2.1f", 1.2), + arguments("+1.2", "%+3.1f", 1.2), + arguments("+1.2", "%+4.1f", 1.2), + arguments(" +1.2", "%+5.1f", 1.2), + arguments(" +1.2", "%+10.1f", 1.2), + + arguments("-1.2", "%+1.1f", -1.2), + arguments("-1.2", "%+2.1f", -1.2), + arguments("-1.2", "%+3.1f", -1.2), + arguments("-1.2", "%+4.1f", -1.2), + arguments(" -1.2", "%+5.1f", -1.2), + arguments(" -1.2", "%+10.1f", -1.2), + + /* blank padding, right adjusted, mandatory blank sign */ + arguments(" 12", "% 1d", 12), + arguments(" 12", "% 2d", 12), + arguments(" 12", "% 3d", 12), + arguments(" 12", "% 4d", 12), + arguments(" 12", "% 5d", 12), + arguments(" 12", "% 10d", 12), + + arguments("-12", "% 1d", -12), + arguments("-12", "% 2d", -12), + arguments("-12", "% 3d", -12), + arguments(" -12", "% 4d", -12), + arguments(" -12", "% 5d", -12), + arguments(" -12", "% 10d", -12), + + arguments(" 1.2", "% 1.1f", 1.2), + arguments(" 1.2", "% 2.1f", 1.2), + arguments(" 1.2", "% 3.1f", 1.2), + arguments(" 1.2", "% 4.1f", 1.2), + arguments(" 1.2", "% 5.1f", 1.2), + arguments(" 1.2", "% 10.1f", 1.2), + + arguments("-1.2", "% 1.1f", -1.2), + arguments("-1.2", "% 2.1f", -1.2), + arguments("-1.2", "% 3.1f", -1.2), + arguments("-1.2", "% 4.1f", -1.2), + arguments(" -1.2", "% 5.1f", -1.2), + arguments(" -1.2", "% 10.1f", -1.2), + + /* blank padding, left adjusted, optional sign */ + arguments("12", "%-1d", 12), + arguments("12", "%-2d", 12), + arguments("12 ", "%-3d", 12), + arguments("12 ", "%-4d", 12), + arguments("12 ", "%-5d", 12), + arguments("12 ", "%-10d", 12), + + arguments("-12", "%-1d", -12), + arguments("-12", "%-2d", -12), + arguments("-12", "%-3d", -12), + arguments("-12 ", "%-4d", -12), + arguments("-12 ", "%-5d", -12), + arguments("-12 ", "%-10d", -12), + + arguments("1.2", "%-1.1f", 1.2), + arguments("1.2", "%-2.1f", 1.2), + arguments("1.2", "%-3.1f", 1.2), + arguments("1.2 ", "%-4.1f", 1.2), + arguments("1.2 ", "%-5.1f", 1.2), + arguments("1.2 ", "%-10.1f", 1.2), + + arguments("-1.2", "%-1.1f", -1.2), + arguments("-1.2", "%-2.1f", -1.2), + arguments("-1.2", "%-3.1f", -1.2), + arguments("-1.2", "%-4.1f", -1.2), + arguments("-1.2 ", "%-5.1f", -1.2), + arguments("-1.2 ", "%-10.1f", -1.2), + + /* blank padding, left adjusted, mandatory plus sign */ + arguments("+12", "%-+1d", 12), + arguments("+12", "%-+2d", 12), + arguments("+12", "%-+3d", 12), + arguments("+12 ", "%-+4d", 12), + arguments("+12 ", "%-+5d", 12), + arguments("+12 ", "%-+10d", 12), + + arguments("-12", "%-+1d", -12), + arguments("-12", "%-+2d", -12), + arguments("-12", "%-+3d", -12), + arguments("-12 ", "%-+4d", -12), + arguments("-12 ", "%-+5d", -12), + arguments("-12 ", "%-+10d", -12), + + arguments("+1.2", "%-+1.1f", 1.2), + arguments("+1.2", "%-+2.1f", 1.2), + arguments("+1.2", "%-+3.1f", 1.2), + arguments("+1.2", "%-+4.1f", 1.2), + arguments("+1.2 ", "%-+5.1f", 1.2), + arguments("+1.2 ", "%-+10.1f", 1.2), + + arguments("-1.2", "%-+1.1f", -1.2), + arguments("-1.2", "%-+2.1f", -1.2), + arguments("-1.2", "%-+3.1f", -1.2), + arguments("-1.2", "%-+4.1f", -1.2), + arguments("-1.2 ", "%-+5.1f", -1.2), + arguments("-1.2 ", "%-+10.1f", -1.2), + + /* blank padding, left adjusted, mandatory blank sign */ + arguments(" 12", "%- 1d", 12), + arguments(" 12", "%- 2d", 12), + arguments(" 12", "%- 3d", 12), + arguments(" 12 ", "%- 4d", 12), + arguments(" 12 ", "%- 5d", 12), + arguments(" 12 ", "%- 10d", 12), + + arguments("-12", "%- 1d", -12), + arguments("-12", "%- 2d", -12), + arguments("-12", "%- 3d", -12), + arguments("-12 ", "%- 4d", -12), + arguments("-12 ", "%- 5d", -12), + arguments("-12 ", "%- 10d", -12), + + arguments(" 1.2", "%- 1.1f", 1.2), + arguments(" 1.2", "%- 2.1f", 1.2), + arguments(" 1.2", "%- 3.1f", 1.2), + arguments(" 1.2", "%- 4.1f", 1.2), + arguments(" 1.2 ", "%- 5.1f", 1.2), + arguments(" 1.2 ", "%- 10.1f", 1.2), + + arguments("-1.2", "%- 1.1f", -1.2), + arguments("-1.2", "%- 2.1f", -1.2), + arguments("-1.2", "%- 3.1f", -1.2), + arguments("-1.2", "%- 4.1f", -1.2), + arguments("-1.2 ", "%- 5.1f", -1.2), + arguments("-1.2 ", "%- 10.1f", -1.2), + + /* zero padding, right adjusted, optional sign */ + arguments("12", "%01d", 12), + arguments("12", "%02d", 12), + arguments("012", "%03d", 12), + arguments("0012", "%04d", 12), + arguments("00012", "%05d", 12), + arguments("0000000012", "%010d", 12), + + arguments("-12", "%01d", -12), + arguments("-12", "%02d", -12), + arguments("-12", "%03d", -12), + arguments("-012", "%04d", -12), + arguments("-0012", "%05d", -12), + arguments("-000000012", "%010d", -12), + + arguments("1.2", "%01.1f", 1.2), + arguments("1.2", "%02.1f", 1.2), + arguments("1.2", "%03.1f", 1.2), + arguments("01.2", "%04.1f", 1.2), + arguments("001.2", "%05.1f", 1.2), + arguments("00000001.2", "%010.1f", 1.2), + + arguments("-1.2", "%01.1f", -1.2), + arguments("-1.2", "%02.1f", -1.2), + arguments("-1.2", "%03.1f", -1.2), + arguments("-1.2", "%04.1f", -1.2), + arguments("-01.2", "%05.1f", -1.2), + arguments("-0000001.2", "%010.1f", -1.2), + + /* zero padding, right adjusted, mandatory plus sign */ + arguments("+12", "%+01d", 12), + arguments("+12", "%+02d", 12), + arguments("+12", "%+03d", 12), + arguments("+012", "%+04d", 12), + arguments("+0012", "%+05d", 12), + arguments("+000000012", "%+010d", 12), + + arguments("-12", "%+01d", -12), + arguments("-12", "%+02d", -12), + arguments("-12", "%+03d", -12), + arguments("-012", "%+04d", -12), + arguments("-0012", "%+05d", -12), + arguments("-000000012", "%+010d", -12), + + arguments("+1.2", "%+01.1f", 1.2), + arguments("+1.2", "%+02.1f", 1.2), + arguments("+1.2", "%+03.1f", 1.2), + arguments("+1.2", "%+04.1f", 1.2), + arguments("+01.2", "%+05.1f", 1.2), + arguments("+0000001.2", "%+010.1f", 1.2), + + arguments("-1.2", "%+01.1f", -1.2), + arguments("-1.2", "%+02.1f", -1.2), + arguments("-1.2", "%+03.1f", -1.2), + arguments("-1.2", "%+04.1f", -1.2), + arguments("-01.2", "%+05.1f", -1.2), + arguments("-0000001.2", "%+010.1f", -1.2), + + /* zero padding, right adjusted, mandatory blank sign */ + arguments(" 12", "% 01d", 12), + arguments(" 12", "% 02d", 12), + arguments(" 12", "% 03d", 12), + arguments(" 012", "% 04d", 12), + arguments(" 0012", "% 05d", 12), + arguments(" 000000012", "% 010d", 12), + + arguments("-12", "% 01d", -12), + arguments("-12", "% 02d", -12), + arguments("-12", "% 03d", -12), + arguments("-012", "% 04d", -12), + arguments("-0012", "% 05d", -12), + arguments("-000000012", "% 010d", -12), + + arguments(" 1.2", "% 01.1f", 1.2), + arguments(" 1.2", "% 02.1f", 1.2), + arguments(" 1.2", "% 03.1f", 1.2), + arguments(" 1.2", "% 04.1f", 1.2), + arguments(" 01.2", "% 05.1f", 1.2), + arguments(" 0000001.2", "% 010.1f", 1.2), + + arguments("-1.2", "% 01.1f", -1.2), + arguments("-1.2", "% 02.1f", -1.2), + arguments("-1.2", "% 03.1f", -1.2), + arguments("-1.2", "% 04.1f", -1.2), + arguments("-01.2", "% 05.1f", -1.2), + arguments("-0000001.2", "% 010.1f", -1.2), + + }; + } + + @ParameterizedTest + @MethodSource + void padding(String expected, String format, Object value) { + assertEquals(expected, String.format(format, value)); + } + +} From bb2fcb894e59408f3e5df06e76974dca3e6f0595 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Thu, 7 Sep 2023 14:11:54 +0000 Subject: [PATCH 083/341] 8314024: SIGSEGV in PhaseIdealLoop::build_loop_late_post_work due to bad immediate dominator info Backport-of: ed1ea5fe7c6fad03ca96e7dece2127eab21a608a --- src/hotspot/share/opto/loopTransform.cpp | 4 ++ src/hotspot/share/opto/loopopts.cpp | 8 +++ .../loopopts/TestNodeSunkFromPreLoop.java | 71 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestNodeSunkFromPreLoop.java diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index 6b3c835e47e80..4d375708a3fa5 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -2830,6 +2830,8 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { continue; // Don't rce this check but continue looking for other candidates. } + assert(is_dominator(compute_early_ctrl(limit, limit_c), pre_end), "node pinned on loop exit test?"); + // Check for scaled induction variable plus an offset Node *offset = nullptr; @@ -2848,6 +2850,8 @@ int PhaseIdealLoop::do_range_check(IdealLoopTree *loop, Node_List &old_new) { if (is_dominator(ctrl, offset_c)) { continue; // Don't rce this check but continue looking for other candidates. } + + assert(is_dominator(compute_early_ctrl(offset, offset_c), pre_end), "node pinned on loop exit test?"); #ifdef ASSERT if (TraceRangeLimitCheck) { tty->print_cr("RC bool node%s", flip ? " flipped:" : ":"); diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 64ba65d5fdbdc..eb1da11123472 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -1697,6 +1697,14 @@ bool PhaseIdealLoop::ctrl_of_use_out_of_loop(const Node* n, Node* n_ctrl, IdealL if (n_loop->is_member(u_loop)) { return false; // Found use in inner loop } + // Sinking a node from a pre loop to its main loop pins the node between the pre and main loops. If that node is input + // to a check that's eliminated by range check elimination, it becomes input to an expression that feeds into the exit + // test of the pre loop above the point in the graph where it's pinned. + if (n_loop->_head->is_CountedLoop() && n_loop->_head->as_CountedLoop()->is_pre_loop() && + u_loop->_head->is_CountedLoop() && u_loop->_head->as_CountedLoop()->is_main_loop() && + n_loop->_next == get_loop(u_loop->_head->as_CountedLoop()->skip_strip_mined())) { + return false; + } return true; } diff --git a/test/hotspot/jtreg/compiler/loopopts/TestNodeSunkFromPreLoop.java b/test/hotspot/jtreg/compiler/loopopts/TestNodeSunkFromPreLoop.java new file mode 100644 index 0000000000000..a18ba7e8a5841 --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestNodeSunkFromPreLoop.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023, Red Hat, Inc. All rights reserved. + * 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 8314024 + * @requires vm.compiler2.enabled + * @summary Node used in check in main loop sunk from pre loop before RC elimination + * @run main/othervm -XX:-BackgroundCompilation -XX:-UseLoopPredicate TestNodeSunkFromPreLoop + * + */ + +public class TestNodeSunkFromPreLoop { + private static int unusedField; + + public static void main(String[] args) { + A object = new A(); + for (int i = 0; i < 20_000; i++) { + test(object, 1000, 0); + } + } + + private static int test(A object, int stop, int inv) { + int res = 0; + // pre/main/post loops created for this loop + for (int i = 0; i < stop; i++) { + // Optimized out. Delay transformation of loop above. + for (int j = 0; j < 10; j++) { + for (int k = 0; k < 10; k++) { + } + } + // null check in pre loop so field load also in pre loop + int v = object.field; + int v2 = (v + inv); + if (i > 1000) { + // never taken. v + inv has a use out of loop at an unc. + unusedField = v2; + } + // transformed in the main loop to i + (v + inv) + int v3 = (v + (i + inv)); + if (v3 > 1000) { + break; + } + } + return res; + } + + private static class A { + public int field; + } +} From be34f0b28ea8bdcbe55320f665960aad95f352f0 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 11 Sep 2023 10:47:29 +0000 Subject: [PATCH 084/341] 8271886: mark hotspot runtime/InvocationTests tests which ignore external VM flags Backport-of: ff7431eafea8bd763250f929aa35edcaae2fbc58 --- .../jtreg/runtime/InvocationTests/invocationC1Tests.java | 3 ++- .../jtreg/runtime/InvocationTests/invocationOldCHATests.java | 1 + .../jtreg/runtime/InvocationTests/invokeinterfaceTests.java | 3 ++- .../jtreg/runtime/InvocationTests/invokespecialTests.java | 3 ++- .../jtreg/runtime/InvocationTests/invokevirtualTests.java | 3 ++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java b/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java index 38b785de232a3..a5fe4b2a1481c 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test id=special * @bug 8226956 * @summary Run invocation tests against C1 compiler + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invocationOldCHATests.java b/test/hotspot/jtreg/runtime/InvocationTests/invocationOldCHATests.java index 4ae6d2157e5b4..2d4c2a38b2113 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invocationOldCHATests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invocationOldCHATests.java @@ -25,6 +25,7 @@ /* * @test id=special * @summary Run invocation tests with old CHA (-XX:-UseVtableBasedCHA) + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java b/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java index 7f449a7e4c4d6..9d8a164637e9a 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test id=current-int * @bug 8224137 * @summary Run invokeinterface invocation tests + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java b/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java index 2635f5ae54f79..564f83d822ec3 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test id=current-int * @bug 8224137 * @summary Run invokespecial invocation tests + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java b/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java index eb73dd8ccd719..9cc19b6081cf1 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test id=current-int * @bug 8224137 * @summary Run invokevirtual invocation tests + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.misc From f8f4943ac818af8b4b143699b53c55dc214c4a24 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 11 Sep 2023 13:53:49 +0000 Subject: [PATCH 085/341] 8244289: fatal error: Possible safepoint reached by thread that does not allow it Backport-of: 61932f49a58b73530e89e511874fbe2fbc343e99 --- .../share/jfr/recorder/service/jfrPostBox.cpp | 2 +- .../share/jfr/recorder/storage/jfrStorage.cpp | 5 +++-- src/hotspot/share/jfr/utilities/jfrTryLock.hpp | 16 +++++++--------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/hotspot/share/jfr/recorder/service/jfrPostBox.cpp b/src/hotspot/share/jfr/recorder/service/jfrPostBox.cpp index bfade7236b767..4c28cbb6c8e6e 100644 --- a/src/hotspot/share/jfr/recorder/service/jfrPostBox.cpp +++ b/src/hotspot/share/jfr/recorder/service/jfrPostBox.cpp @@ -101,7 +101,7 @@ void JfrPostBox::deposit(int new_messages) { void JfrPostBox::asynchronous_post(int msg) { assert(!is_synchronous(msg), "invariant"); deposit(msg); - JfrMonitorTryLock try_msg_lock(JfrMsg_lock); + JfrMutexTryLock try_msg_lock(JfrMsg_lock); if (try_msg_lock.acquired()) { JfrMsg_lock->notify_all(); } diff --git a/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp b/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp index f83132807dd0e..fd6e6fc94d71b 100644 --- a/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp +++ b/src/hotspot/share/jfr/recorder/storage/jfrStorage.cpp @@ -38,6 +38,7 @@ #include "jfr/utilities/jfrIterator.hpp" #include "jfr/utilities/jfrLinkedList.inline.hpp" #include "jfr/utilities/jfrTime.hpp" +#include "jfr/utilities/jfrTryLock.hpp" #include "jfr/writers/jfrNativeEventWriter.hpp" #include "logging/log.hpp" #include "runtime/mutexLocker.hpp" @@ -328,7 +329,8 @@ static void log_discard(size_t pre_full_count, size_t post_full_count, size_t am } void JfrStorage::discard_oldest(Thread* thread) { - if (JfrBuffer_lock->try_lock()) { + JfrMutexTryLock mutex(JfrBuffer_lock); + if (mutex.acquired()) { if (!control().should_discard()) { // another thread handled it return; @@ -350,7 +352,6 @@ void JfrStorage::discard_oldest(Thread* thread) { oldest->release(); // publish break; } - JfrBuffer_lock->unlock(); log_discard(num_full_pre_discard, control().full_count(), discarded_size); } } diff --git a/src/hotspot/share/jfr/utilities/jfrTryLock.hpp b/src/hotspot/share/jfr/utilities/jfrTryLock.hpp index 10b3c93f5dc3b..5c76fa6632114 100644 --- a/src/hotspot/share/jfr/utilities/jfrTryLock.hpp +++ b/src/hotspot/share/jfr/utilities/jfrTryLock.hpp @@ -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 @@ -50,25 +50,23 @@ class JfrTryLock { } }; -class JfrMonitorTryLock : public StackObj { +class JfrMutexTryLock : public StackObj { private: - Monitor* _lock; + Mutex* _mutex; bool _acquired; public: - JfrMonitorTryLock(Monitor* lock) : _lock(lock), _acquired(lock->try_lock()) {} - - ~JfrMonitorTryLock() { + JfrMutexTryLock(Mutex* mutex) : _mutex(mutex), _acquired(mutex->try_lock()) {} + ~JfrMutexTryLock() { if (_acquired) { - assert(_lock->owned_by_self(), "invariant"); - _lock->unlock(); + assert(_mutex->owned_by_self(), "invariant"); + _mutex->unlock(); } } bool acquired() const { return _acquired; } - }; #endif // SHARE_JFR_UTILITIES_JFRTRYLOCK_HPP From a5a3505537131058dcbb9b0c1c4ccf4347f2e0e9 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 11 Sep 2023 13:54:23 +0000 Subject: [PATCH 086/341] 8315549: CITime misreports code/total nmethod sizes Reviewed-by: phh Backport-of: ab12c5d32fede04cbbf8c86b6461a0c71404cd69 --- src/hotspot/share/compiler/compileBroker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index 0dd4831220480..db5f2b5e42f1a 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -2753,8 +2753,8 @@ void CompileBroker::print_times(bool per_compiler, bool aggregate) { int total_bailout_count = CompileBroker::_total_bailout_count; int total_invalidated_count = CompileBroker::_total_invalidated_count; - int nmethods_size = CompileBroker::_sum_nmethod_code_size; - int nmethods_code_size = CompileBroker::_sum_nmethod_size; + int nmethods_code_size = CompileBroker::_sum_nmethod_code_size; + int nmethods_size = CompileBroker::_sum_nmethod_size; tty->cr(); tty->print_cr("Accumulated compiler times"); From 4e9b6da251b620a488334061451c59c36703f7ec Mon Sep 17 00:00:00 2001 From: airsquared <36649395+airsquared@users.noreply.github.com> Date: Tue, 12 Sep 2023 13:17:33 +0000 Subject: [PATCH 087/341] 8309032: jpackage does not work for module projects unless --module-path is specified Backport-of: dfe764e3f85784752d69fd51306644732e808d38 --- .../jdk/jpackage/internal/LauncherData.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/LauncherData.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/LauncherData.java index 81c6baac87b14..d0ca34a8f62bb 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/LauncherData.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/LauncherData.java @@ -99,7 +99,7 @@ private LauncherData() { } private void verifyIsModular(boolean isModular) { - if ((moduleInfo != null) != isModular) { + if ((moduleInfo == null) == isModular) { throw new IllegalStateException(); } } @@ -259,14 +259,10 @@ private static String getMainModule(Map params) { private static String getStringParam(Map params, String paramName) { Optional value = Optional.ofNullable(params.get(paramName)); - if (value.isPresent()) { - return value.get().toString(); - } - return null; + return value.map(Object::toString).orElse(null); } - private static T getPathParam(Map params, - String paramName, Supplier func) throws ConfigException { + private static T getPathParam(String paramName, Supplier func) throws ConfigException { try { return func.get(); } catch (InvalidPathException ex) { @@ -278,7 +274,7 @@ private static T getPathParam(Map params, private static Path getPathParam(Map params, String paramName) throws ConfigException { - return getPathParam(params, paramName, () -> { + return getPathParam(paramName, () -> { String value = getStringParam(params, paramName); Path result = null; if (value != null) { @@ -297,7 +293,7 @@ private static List getModulePath(Map params) runtimePath = runtimePath.resolve("lib"); modulePath = Stream.of(modulePath, List.of(runtimePath)) .flatMap(List::stream) - .collect(Collectors.toUnmodifiableList()); + .toList(); } return modulePath; @@ -305,13 +301,9 @@ private static List getModulePath(Map params) private static List getPathListParameter(String paramName, Map params) throws ConfigException { - return getPathParam(params, paramName, () -> { - String value = (String) params.get(paramName); - return (value == null) ? List.of() : - List.of(value.split(File.pathSeparator)).stream() - .map(Path::of) - .collect(Collectors.toUnmodifiableList()); - }); + return getPathParam(paramName, () -> + params.get(paramName) instanceof String value ? + Stream.of(value.split(File.pathSeparator)).map(Path::of).toList() : List.of()); } private String qualifiedClassName; From 45b6bcac36c33c4faeea53070e7b43257e257321 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Wed, 13 Sep 2023 13:36:58 +0000 Subject: [PATCH 088/341] 8312625: Test serviceability/dcmd/vm/TrimLibcHeapTest.java failed: RSS use increased Backport-of: 117f42dbe9a78bcf43bdf3873d5d86a19a9092d3 --- test/hotspot/jtreg/serviceability/dcmd/vm/TrimLibcHeapTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/TrimLibcHeapTest.java b/test/hotspot/jtreg/serviceability/dcmd/vm/TrimLibcHeapTest.java index 63624221ce035..559de70219ed9 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/TrimLibcHeapTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/TrimLibcHeapTest.java @@ -46,7 +46,7 @@ public void run(CommandExecutor executor) { if (Platform.isMusl()) { output.shouldContain("Not available"); } else { - output.shouldMatch("Trim native heap: RSS\\+Swap: \\d+[BKMG]->\\d+[BKMG] \\(-\\d+[BKMG]\\)"); + output.shouldMatch("Trim native heap: RSS\\+Swap: \\d+[BKMG]->\\d+[BKMG] \\([+-]\\d+[BKMG]\\)"); } } From 444f8296b37d0ed36c2a9e7c4c9522fe88ce1de9 Mon Sep 17 00:00:00 2001 From: Evgeny Astigeevich Date: Wed, 13 Sep 2023 21:02:06 +0000 Subject: [PATCH 089/341] 8276711: compiler/codecache/cli tests failing when SegmentedCodeCache used with -Xint Backport-of: 7822cbce10e0c0c6f9bf521faebc89a0af20734e --- src/hotspot/share/code/codeCache.cpp | 2 +- .../share/compiler/compilerDefinitions.cpp | 7 +++++-- .../cli/TestSegmentedCodeCacheOption.java | 18 +++++++----------- .../codeheapsize/TestCodeHeapSizeOptions.java | 8 +------- .../cli/common/CodeCacheCLITestCase.java | 10 +++++----- 5 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index dae813a27b509..d99ddb778b3eb 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -354,7 +354,7 @@ bool CodeCache::heap_available(int code_blob_type) { if (!SegmentedCodeCache) { // No segmentation: use a single code heap return (code_blob_type == CodeBlobType::All); - } else if (Arguments::is_interpreter_only()) { + } else if (CompilerConfig::is_interpreter_only()) { // Interpreter only: we don't need any method code heaps return (code_blob_type == CodeBlobType::NonNMethod); } else if (CompilerConfig::is_c1_profiling()) { diff --git a/src/hotspot/share/compiler/compilerDefinitions.cpp b/src/hotspot/share/compiler/compilerDefinitions.cpp index 421997081a111..aa8fa6ab2adb9 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.cpp +++ b/src/hotspot/share/compiler/compilerDefinitions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -316,7 +316,6 @@ void CompilerConfig::set_compilation_policy_flags() { } } - if (CompileThresholdScaling < 0) { vm_exit_during_initialization("Negative value specified for CompileThresholdScaling", NULL); } @@ -523,6 +522,10 @@ bool CompilerConfig::check_args_consistency(bool status) { } FLAG_SET_CMDLINE(TieredCompilation, false); } + if (SegmentedCodeCache) { + warning("SegmentedCodeCache has no meaningful effect with -Xint"); + FLAG_SET_DEFAULT(SegmentedCodeCache, false); + } #if INCLUDE_JVMCI if (EnableJVMCI) { if (!FLAG_IS_DEFAULT(EnableJVMCI) || !FLAG_IS_DEFAULT(UseJVMCICompiler)) { diff --git a/test/hotspot/jtreg/compiler/codecache/cli/TestSegmentedCodeCacheOption.java b/test/hotspot/jtreg/compiler/codecache/cli/TestSegmentedCodeCacheOption.java index 83eea64b3f962..2a810abdd48df 100644 --- a/test/hotspot/jtreg/compiler/codecache/cli/TestSegmentedCodeCacheOption.java +++ b/test/hotspot/jtreg/compiler/codecache/cli/TestSegmentedCodeCacheOption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. * 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,6 +56,9 @@ public class TestSegmentedCodeCacheOption { private static final String[] UNEXPECTED_MESSAGES = new String[] { ".*" + SEGMENTED_CODE_CACHE + ".*" }; + private static final String[] XINT_EXPECTED_MESSAGE = new String[] { + "SegmentedCodeCache has no meaningful effect with -Xint" + }; private static enum TestCase { @@ -86,10 +89,11 @@ public void run() throws Throwable { // ... and even w/ Xint. testCaseExitCodeMessage = "It should be possible to use " + USE_SEGMENTED_CODE_CACHE + " in interpreted mode " - + "without any errors."; + + "but it produces a warning that it is ignored."; CommandLineOptionTest.verifyJVMStartup( - /* expected messages */ null, UNEXPECTED_MESSAGES, + XINT_EXPECTED_MESSAGE, + /* unexpected messages */ null, testCaseExitCodeMessage, testCaseWarningMessage, ExitCode.OK, false, INT_MODE, USE_SEGMENTED_CODE_CACHE); } @@ -117,14 +121,6 @@ public void run() throws Throwable { CommandLineOptionTest.prepareNumericFlag( BlobType.All.sizeOptionName, BELOW_THRESHOLD_CC_SIZE)); - // SCC could be explicitly enabled w/ Xint - errorMessage = String.format("It should be possible to " - + "explicitly enable %s in interpreted mode.", - SEGMENTED_CODE_CACHE); - - CommandLineOptionTest.verifyOptionValue(SEGMENTED_CODE_CACHE, - "true", errorMessage, false, INT_MODE, - USE_SEGMENTED_CODE_CACHE); // SCC could be explicitly enabled w/o TieredCompilation and w/ // small ReservedCodeCacheSize value errorMessage = String.format("It should be possible to " diff --git a/test/hotspot/jtreg/compiler/codecache/cli/codeheapsize/TestCodeHeapSizeOptions.java b/test/hotspot/jtreg/compiler/codecache/cli/codeheapsize/TestCodeHeapSizeOptions.java index 61c9cc69c034e..7ae62407ece7b 100644 --- a/test/hotspot/jtreg/compiler/codecache/cli/codeheapsize/TestCodeHeapSizeOptions.java +++ b/test/hotspot/jtreg/compiler/codecache/cli/codeheapsize/TestCodeHeapSizeOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. * 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,15 +63,9 @@ public class TestCodeHeapSizeOptions extends CodeCacheCLITestBase { private TestCodeHeapSizeOptions() { super(CodeCacheCLITestBase.OPTIONS_SET, - new CodeCacheCLITestCase(CodeCacheCLITestCase - .CommonDescriptions.INT_MODE.description, - GENERIC_RUNNER), new CodeCacheCLITestCase(CodeCacheCLITestCase .CommonDescriptions.NON_TIERED.description, GENERIC_RUNNER), - new CodeCacheCLITestCase(CodeCacheCLITestCase - .CommonDescriptions.TIERED_LEVEL_0.description, - GENERIC_RUNNER), new CodeCacheCLITestCase(CodeCacheCLITestCase .CommonDescriptions.TIERED_LEVEL_1.description, GENERIC_RUNNER), diff --git a/test/hotspot/jtreg/compiler/codecache/cli/common/CodeCacheCLITestCase.java b/test/hotspot/jtreg/compiler/codecache/cli/common/CodeCacheCLITestCase.java index 64ac38da2a0e4..eca5c70e0917b 100644 --- a/test/hotspot/jtreg/compiler/codecache/cli/common/CodeCacheCLITestCase.java +++ b/test/hotspot/jtreg/compiler/codecache/cli/common/CodeCacheCLITestCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. * 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,9 +66,9 @@ public final void run(CodeCacheOptions options) throws Throwable { public enum CommonDescriptions { /** * Verifies that in interpreted mode PrintCodeCache output contains - * only NonNMethod code heap. + * the whole code cache. Int mode disables SegmentedCodeCache with a warning. */ - INT_MODE(ONLY_SEGMENTED, EnumSet.of(BlobType.NonNMethod), USE_INT_MODE), + INT_MODE(ONLY_SEGMENTED, EnumSet.of(BlobType.All), USE_INT_MODE), /** * Verifies that with disabled SegmentedCodeCache PrintCodeCache output * contains only CodeCache's entry. @@ -87,11 +87,11 @@ public enum CommonDescriptions { false)), /** * Verifies that with TieredStopAtLevel=0 PrintCodeCache output will - * contain information about non-nmethods and non-profiled nmethods + * warn about SegmentedCodeCache and contain information about all * heaps only. */ TIERED_LEVEL_0(SEGMENTED_SERVER, - EnumSet.of(BlobType.NonNMethod, BlobType.MethodNonProfiled), + EnumSet.of(BlobType.All), CommandLineOptionTest.prepareBooleanFlag(TIERED_COMPILATION, true), CommandLineOptionTest.prepareNumericFlag(TIERED_STOP_AT, 0)), From 4ac28fc1407e80457b4d2b003e1b23d0158f8da9 Mon Sep 17 00:00:00 2001 From: Chad Rakoczy Date: Wed, 13 Sep 2023 21:03:53 +0000 Subject: [PATCH 090/341] 8285516: clearPassword should be called in a finally try block Backport-of: 36e4df9d66134ef160bbba0e59d0e3dbb183ba4b --- .../share/classes/sun/security/pkcs12/PKCS12KeyStore.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java index 07f1145e8d855..12afa2f94fad3 100644 --- a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java +++ b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java @@ -864,14 +864,14 @@ private SecretKey getPBEKey(char[] password) throws IOException { SecretKey skey = null; + PBEKeySpec keySpec = new PBEKeySpec(password); try { - PBEKeySpec keySpec = new PBEKeySpec(password); SecretKeyFactory skFac = SecretKeyFactory.getInstance("PBE"); skey = skFac.generateSecret(keySpec); - keySpec.clearPassword(); } catch (Exception e) { - throw new IOException("getSecretKey failed: " + - e.getMessage(), e); + throw new IOException("getSecretKey failed: " + e.getMessage(), e); + } finally { + keySpec.clearPassword(); } return skey; } From cc9a8e98e904213500ec3f60ddd0476976fdb1a5 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 14 Sep 2023 05:38:20 +0000 Subject: [PATCH 091/341] 8301701: java/net/DatagramSocket/DatagramSocketMulticasting.java should be hardened Reviewed-by: phh Backport-of: 5feb13b55d32fad8f533f52ee7bd63e2cf2d247c --- .../DatagramSocketMulticasting.java | 96 ++++++++++--------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/test/jdk/java/net/DatagramSocket/DatagramSocketMulticasting.java b/test/jdk/java/net/DatagramSocket/DatagramSocketMulticasting.java index 114078e2dbdb2..9276fc9a8e734 100644 --- a/test/jdk/java/net/DatagramSocket/DatagramSocketMulticasting.java +++ b/test/jdk/java/net/DatagramSocket/DatagramSocketMulticasting.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 @@ -27,10 +27,10 @@ * @library /test/lib * @build jdk.test.lib.NetworkConfiguration * jdk.test.lib.net.IPSupport - * @run main/othervm DatagramSocketMulticasting - * @run main/othervm -Djava.net.preferIPv4Stack=true DatagramSocketMulticasting - * @run main/othervm -Djdk.usePlainDatagramSocketImpl=true DatagramSocketMulticasting - * @run main/othervm -Djdk.usePlainDatagramSocketImpl=true -Djava.net.preferIPv4Stack=true DatagramSocketMulticasting + * @run junit/othervm DatagramSocketMulticasting + * @run junit/othervm -Djava.net.preferIPv4Stack=true DatagramSocketMulticasting + * @run junit/othervm -Djdk.usePlainDatagramSocketImpl=true DatagramSocketMulticasting + * @run junit/othervm -Djdk.usePlainDatagramSocketImpl=true -Djava.net.preferIPv4Stack=true DatagramSocketMulticasting */ import java.io.IOException; @@ -50,6 +50,7 @@ import jdk.test.lib.NetworkConfiguration; import jdk.test.lib.net.IPSupport; +import org.junit.jupiter.api.Test; import static java.net.StandardProtocolFamily.INET; import static java.net.StandardProtocolFamily.INET6; @@ -59,11 +60,16 @@ import static java.net.StandardSocketOptions.SO_REUSEADDR; import static jdk.test.lib.NetworkConfiguration.isSameInterface; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + public class DatagramSocketMulticasting { static final ProtocolFamily UNSPEC = () -> "UNSPEC"; + static final int MAX_TRIES = 3; - public static void main(String[] args) throws IOException { - IPSupport.throwSkippedExceptionIfNonOperational(); + @Test + public void main() throws IOException { + assumeTrue(IPSupport.currentConfigurationIsValid(), "Invalid networking configuration"); // IPv4 and IPv6 interfaces that support multicasting NetworkConfiguration config = NetworkConfiguration.probe(); @@ -134,13 +140,13 @@ static void testJoinGroup2(ProtocolFamily family, System.out.format("testJoinGroup2: local socket address: %s%n", s.getLocalSocketAddress()); // check network interface not set - assertTrue(s.getOption(IP_MULTICAST_IF) == null); + assertNull(s.getOption(IP_MULTICAST_IF)); // join on default interface s.joinGroup(new InetSocketAddress(group, 0), null); // join should not change the outgoing multicast interface - assertTrue(s.getOption(IP_MULTICAST_IF) == null); + assertNull(s.getOption(IP_MULTICAST_IF)); // already a member (exception not specified) assertThrows(SocketException.class, @@ -157,7 +163,7 @@ static void testJoinGroup2(ProtocolFamily family, s.joinGroup(new InetSocketAddress(group, 0), ni); // join should not change the outgoing multicast interface - assertTrue(s.getOption(IP_MULTICAST_IF) == null); + assertNull(s.getOption(IP_MULTICAST_IF)); // already a member (exception not specified) assertThrows(SocketException.class, @@ -234,7 +240,7 @@ static void testJoinGroup2(ProtocolFamily family, static void testNetworkInterface(DatagramSocket s, NetworkInterface ni) throws IOException { // default value - assertTrue(s.getOption(IP_MULTICAST_IF) == null); + assertNull(s.getOption(IP_MULTICAST_IF)); // setOption(IP_MULTICAST_IF) s.setOption(IP_MULTICAST_IF, ni); @@ -253,12 +259,12 @@ static void testNetworkInterface(DatagramSocket s, */ static void testTimeToLive(DatagramSocket s) throws IOException { // should be 1 by default - assertTrue(s.getOption(IP_MULTICAST_TTL) == 1); + assertEquals(1, s.getOption(IP_MULTICAST_TTL)); // setOption(IP_MULTICAST_TTL) for (int ttl = 0; ttl <= 2; ttl++) { s.setOption(IP_MULTICAST_TTL, ttl); - assertTrue(s.getOption(IP_MULTICAST_TTL) == ttl); + assertEquals(ttl, s.getOption(IP_MULTICAST_TTL)); } // bad values for IP_MULTICAST_TTL @@ -275,15 +281,15 @@ static void testTimeToLive(DatagramSocket s) throws IOException { */ static void testLoopbackMode(DatagramSocket s) throws IOException { // should be enabled by default - assertTrue(s.getOption(IP_MULTICAST_LOOP) == true); + assertTrue(s.getOption(IP_MULTICAST_LOOP)); // setLoopbackMode // setOption(IP_MULTICAST_LOOP) s.setOption(IP_MULTICAST_LOOP, false); // disable - assertTrue(s.getOption(IP_MULTICAST_LOOP) == false); + assertFalse(s.getOption(IP_MULTICAST_LOOP)); s.setOption(IP_MULTICAST_LOOP, true); // enable - assertTrue(s.getOption(IP_MULTICAST_LOOP) == true); + assertTrue(s.getOption(IP_MULTICAST_LOOP)); // bad values for IP_MULTICAST_LOOP assertThrows(IllegalArgumentException.class, @@ -300,23 +306,37 @@ static void testSendReceive(DatagramSocket s, InetAddress group) throws IOExcept System.out.println("testSendReceive"); // outgoing multicast interface needs to be set - assertTrue(s.getOption(IP_MULTICAST_IF) != null); + assertNotNull(s.getOption(IP_MULTICAST_IF)); SocketAddress target = new InetSocketAddress(group, s.getLocalPort()); - byte[] message = "hello".getBytes("UTF-8"); + String message = "testSendReceive"; + byte[] messageBytes = message.getBytes("UTF-8"); // send message to multicast group - DatagramPacket p = new DatagramPacket(message, message.length); + DatagramPacket p = new DatagramPacket(messageBytes, messageBytes.length); p.setSocketAddress(target); s.send(p); - // receive message + // receive message with retry in case of stray messages s.setSoTimeout(0); - p = new DatagramPacket(new byte[1024], 100); - s.receive(p); + for (int i = 1; i <= MAX_TRIES; i++) { + p = new DatagramPacket(new byte[1024], 100); + s.receive(p); + String messageReceived = new String(p.getData(), 0, p.getLength(), "UTF-8"); + + System.out.format( + "TestSendReceive iteration [%s], Received DatagramPacket [%s] from [%s]%n", + i, messageReceived, s.getLocalSocketAddress()); + + if (s.getLocalPort() == p.getPort()) { + assertEquals(message, messageReceived, + String.format("expected message %s, instead received %s%n", + message, messageReceived)); + break; + } - assertTrue(p.getLength() == message.length); - assertTrue(p.getPort() == s.getLocalPort()); + assertNotEquals(MAX_TRIES, i, "testSendReceive: too many retries"); + } } /** @@ -328,11 +348,11 @@ static void testSendNoReceive(DatagramSocket s, InetAddress group) throws IOExce System.out.println("testSendNoReceive"); // outgoing multicast interface needs to be set - assertTrue(s.getOption(IP_MULTICAST_IF) != null); + assertNotNull(s.getOption(IP_MULTICAST_IF)); SocketAddress target = new InetSocketAddress(group, s.getLocalPort()); long nano = System.nanoTime(); - String text = nano + ": hello"; + String text = nano + ": testSendNoReceive"; byte[] message = text.getBytes("UTF-8"); // send datagram to multicast group @@ -349,31 +369,13 @@ static void testSendNoReceive(DatagramSocket s, InetAddress group) throws IOExce if (Arrays.equals(p.getData(), p.getOffset(), p.getLength(), message, 0, message.length)) { throw new RuntimeException("message shouldn't have been received"); } else { - System.out.format("Received unexpected message from %s%n", p.getSocketAddress()); + String messageReceived = new String(p.getData(), 0, p.getLength(), "UTF-8"); + System.out.format("Received unexpected message %s from %s%n", + messageReceived, p.getSocketAddress()); } } catch (SocketTimeoutException expected) { break; } } } - - - static void assertTrue(boolean e) { - if (!e) throw new RuntimeException(); - } - - interface ThrowableRunnable { - void run() throws Exception; - } - - static void assertThrows(Class exceptionClass, ThrowableRunnable task) { - try { - task.run(); - throw new RuntimeException("Exception not thrown"); - } catch (Exception e) { - if (!exceptionClass.isInstance(e)) { - throw new RuntimeException("expected: " + exceptionClass + ", actual: " + e); - } - } - } } From 0ddf1ebe3df119be2029b12feee93d0128e7cae0 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 14 Sep 2023 07:23:36 +0000 Subject: [PATCH 092/341] 8315751: RandomTestBsi1999 fails often with timeouts on Linux ppc64le Backport-of: 9887cd8adc408a71b045b1a4891cc0d5dede7e0e --- test/jdk/java/util/Random/RandomTestBsi1999.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/util/Random/RandomTestBsi1999.java b/test/jdk/java/util/Random/RandomTestBsi1999.java index 8afe5df87f2f1..ab35f7e7874b2 100644 --- a/test/jdk/java/util/Random/RandomTestBsi1999.java +++ b/test/jdk/java/util/Random/RandomTestBsi1999.java @@ -43,9 +43,9 @@ /** * @test - * @summary test bit sequences produced by clases that implement interface RandomGenerator + * @summary test bit sequences produced by classes that implement interface RandomGenerator * @bug 8248862 - * @run main RandomTestBsi1999 + * @run main/othervm/timeout=400 RandomTestBsi1999 * @key randomness */ From 47f87189f3feac523e3f65cca19db735bacd5216 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 14 Sep 2023 15:34:13 +0000 Subject: [PATCH 093/341] 8314094: java/lang/ProcessHandle/InfoTest.java fails on Windows when run as user with Administrator privileges Backport-of: 69c9ec92d04a399946b2157690a1dc3fec517329 --- .../jdk/java/lang/ProcessHandle/InfoTest.java | 51 +++++++++++++------ 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/test/jdk/java/lang/ProcessHandle/InfoTest.java b/test/jdk/java/lang/ProcessHandle/InfoTest.java index e61b374e0cf4f..9901ee81592bb 100644 --- a/test/jdk/java/lang/ProcessHandle/InfoTest.java +++ b/test/jdk/java/lang/ProcessHandle/InfoTest.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 @@ -39,12 +39,13 @@ import java.util.Random; import java.util.concurrent.TimeUnit; -import jdk.test.lib.Platform; -import jdk.test.lib.Utils; import org.testng.Assert; import org.testng.TestNG; import org.testng.annotations.Test; +import jdk.test.lib.Platform; +import jdk.test.lib.Utils; + /* * @test * @bug 8077350 8081566 8081567 8098852 8136597 @@ -81,7 +82,6 @@ public class InfoTest { } // Main can be used to run the tests from the command line with only testng.jar. - @SuppressWarnings("raw_types") public static void main(String[] args) { Class[] testclass = {InfoTest.class}; TestNG testng = new TestNG(); @@ -160,11 +160,7 @@ public static void test2() { ProcessHandle.Info info = p1.info(); System.out.printf(" info: %s%n", info); - if (info.user().isPresent()) { - String user = info.user().get(); - Assert.assertNotNull(user, "User name"); - Assert.assertEquals(user, whoami, "User name"); - } + assertUser(info); Optional command = info.command(); if (command.isPresent()) { @@ -291,11 +287,8 @@ public static void test3() { ProcessHandle.Info info = p.info(); System.out.printf(" info: %s%n", info); - if (info.user().isPresent()) { - String user = info.user().get(); - Assert.assertNotNull(user); - Assert.assertEquals(user, whoami); - } + assertUser(info); + if (info.command().isPresent()) { String command = info.command().get(); String expected = "sleep"; @@ -397,7 +390,7 @@ public static void test5() { Instant end = Instant.now().plusMillis(500L); while (end.isBefore(Instant.now())) { // burn the cpu time checking the time - long x = r.nextLong(); + r.nextLong(); } if (self.info().totalCpuDuration().isPresent()) { Duration totalCpu = self.info().totalCpuDuration().get(); @@ -410,6 +403,7 @@ public static void test5() { } } } + /** * Check two Durations, the second should be greater than the first or * within the supplied Epsilon. @@ -443,4 +437,31 @@ static Process spawn(String command, String... args) throws IOException { pb.command(list); return pb.start(); } + + /** + * Asserts the expected process user. + * + * The Expected user is determined by creating a file and reading its owner, see static block above. + * + * On Windows, when run privileged as member of the Administrators group, this does not always + * work because new files can be owned by BUILTIN\Administrators instead, depending on system + * settings. In that case we resort to comparing System property user.name, which does not contain + * the domain name, though. + * + * @param info ProcessHanlde info object + */ + static void assertUser(ProcessHandle.Info info) { + if (!info.user().isPresent()) { + return; + } + String user = info.user().get(); + Assert.assertNotNull(user, "User name"); + if (Platform.isWindows() && "BUILTIN\\Administrators".equals(whoami)) { + int bsi = user.lastIndexOf("\\"); + Assert.assertEquals(bsi == -1 ? user : user.substring(bsi + 1), + System.getProperty("user.name"), "User name"); + } else { + Assert.assertEquals(user, whoami, "User name"); + } + } } From 4636018f02f68ff4e0347969077bc80ed26ce847 Mon Sep 17 00:00:00 2001 From: Ao Qi Date: Fri, 15 Sep 2023 07:45:10 +0000 Subject: [PATCH 094/341] 8315020: The macro definition for LoongArch64 zero build is not accurate. Reviewed-by: fyang Backport-of: 725ec0ce1b463b21cd4c5287cf4ccbee53ec7349 --- make/autoconf/platform.m4 | 2 ++ src/hotspot/os/linux/os_linux.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/make/autoconf/platform.m4 b/make/autoconf/platform.m4 index 5752d3bd1a6ad..eb66266262bf9 100644 --- a/make/autoconf/platform.m4 +++ b/make/autoconf/platform.m4 @@ -573,6 +573,8 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER], HOTSPOT_$1_CPU_DEFINE=S390 elif test "x$OPENJDK_$1_CPU" = xs390x; then HOTSPOT_$1_CPU_DEFINE=S390 + elif test "x$OPENJDK_$1_CPU" = xloongarch64; then + HOTSPOT_$1_CPU_DEFINE=LOONGARCH64 elif test "x$OPENJDK_$1_CPU" != x; then HOTSPOT_$1_CPU_DEFINE=$(echo $OPENJDK_$1_CPU | tr a-z A-Z) fi diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index b4055b0e21632..ee64272258f42 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -1799,11 +1799,11 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) { static Elf32_Half running_arch_code=EM_SH; #elif (defined RISCV) static Elf32_Half running_arch_code=EM_RISCV; -#elif (defined LOONGARCH) +#elif (defined LOONGARCH64) static Elf32_Half running_arch_code=EM_LOONGARCH; #else #error Method os::dll_load requires that one of following is defined:\ - AARCH64, ALPHA, ARM, AMD64, IA32, IA64, LOONGARCH, M68K, MIPS, MIPSEL, PARISC, __powerpc__, __powerpc64__, RISCV, S390, SH, __sparc + AARCH64, ALPHA, ARM, AMD64, IA32, IA64, LOONGARCH64, M68K, MIPS, MIPSEL, PARISC, __powerpc__, __powerpc64__, RISCV, S390, SH, __sparc #endif // Identify compatibility class for VM's architecture and library's architecture From af9d522e3f13afbac19813bcb168999093762cdf Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 15 Sep 2023 10:40:24 +0000 Subject: [PATCH 095/341] 8232933: Javac inferred type does not conform to equality constraint Reviewed-by: vromero Backport-of: 7a85441a85b2472215ca7bc66e636dff06d9ebf3 --- .../tools/javac/comp/InferenceContext.java | 11 +++++ .../DontMinimizeInfContextTest.java | 49 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 test/langtools/tools/javac/inference_context_min/DontMinimizeInfContextTest.java diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java index 94d95069c0306..6b0f7059868a2 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/InferenceContext.java @@ -338,6 +338,17 @@ InferenceContext min(List roots, boolean shouldSolve, Warner warn) { if (roots.length() == inferencevars.length()) { return this; } + /* if any of the inference vars is a captured variable bail out, this is because + * we could end up generating more than necessary captured variables in an outer + * inference context and then when we need to propagate back to an inner inference + * context that has been minimized it could be that some bounds constraints doesn't + * hold like subtyping constraints between bonds etc. + */ + for (Type iv : inferencevars) { + if (iv.hasTag(TypeTag.TYPEVAR) && ((TypeVar)iv).isCaptured()) { + return this; + } + } ReachabilityVisitor rv = new ReachabilityVisitor(); rv.scan(roots); if (rv.min.size() == inferencevars.length()) { diff --git a/test/langtools/tools/javac/inference_context_min/DontMinimizeInfContextTest.java b/test/langtools/tools/javac/inference_context_min/DontMinimizeInfContextTest.java new file mode 100644 index 0000000000000..407845551127c --- /dev/null +++ b/test/langtools/tools/javac/inference_context_min/DontMinimizeInfContextTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * 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 8232933 + * @summary Javac inferred type does not conform to equality constraint + * @compile DontMinimizeInfContextTest.java + */ + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +class DontMinimizeInfContextTest { + void m() { + List> a = new LinkedList<>(); + Map>> b = a.stream().collect( + Collectors.groupingBy(A::getval, Collectors.toList()) + ); + } + + class A { + String getval() { + return "s"; + } + } +} From 4d8549be8928feb89ea5e0fd0dc23e3d74e76a21 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 15 Sep 2023 10:42:44 +0000 Subject: [PATCH 096/341] 8299255: Unexpected round errors in FreetypeFontScaler Backport-of: 26868c1ac471c3b305b1d15e3075de0baa9319d2 --- .../native/libfontmanager/freetypeScaler.c | 10 +-- .../awt/FontClass/FontScalerRoundTest.java | 69 +++++++++++++++++++ 2 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 test/jdk/java/awt/FontClass/FontScalerRoundTest.java diff --git a/src/java.desktop/share/native/libfontmanager/freetypeScaler.c b/src/java.desktop/share/native/libfontmanager/freetypeScaler.c index 16dc9cd1e44fb..c7ef5679ae679 100644 --- a/src/java.desktop/share/native/libfontmanager/freetypeScaler.c +++ b/src/java.desktop/share/native/libfontmanager/freetypeScaler.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -507,10 +507,10 @@ Java_sun_font_FreetypeFontScaler_createScalerContextNative( ptsz = 1.0; } context->ptsz = (int)(ptsz * 64); - context->transform.xx = FloatToFTFixed((float)dmat[0]/ptsz); - context->transform.yx = -FloatToFTFixed((float)dmat[1]/ptsz); - context->transform.xy = -FloatToFTFixed((float)dmat[2]/ptsz); - context->transform.yy = FloatToFTFixed((float)dmat[3]/ptsz); + context->transform.xx = FloatToFTFixed((float)(dmat[0]/ptsz)); + context->transform.yx = -FloatToFTFixed((float)(dmat[1]/ptsz)); + context->transform.xy = -FloatToFTFixed((float)(dmat[2]/ptsz)); + context->transform.yy = FloatToFTFixed((float)(dmat[3]/ptsz)); context->aaType = aa; context->fmType = fm; diff --git a/test/jdk/java/awt/FontClass/FontScalerRoundTest.java b/test/jdk/java/awt/FontClass/FontScalerRoundTest.java new file mode 100644 index 0000000000000..499016835229c --- /dev/null +++ b/test/jdk/java/awt/FontClass/FontScalerRoundTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * 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 8299255 + * @summary Verify no round error in Font scaling + */ + +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.font.FontRenderContext; +import java.awt.font.LineMetrics; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; + +public class FontScalerRoundTest { + public static void main(String[] args) { + final double SCALE = 4096.0; + final double STEP = 0.0001; + final double LIMIT = STEP * 100.0; + + BufferedImage img = new BufferedImage(100, 100, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = img.createGraphics(); + FontRenderContext frc = g2d.getFontRenderContext(); + + Font font = new Font(Font.DIALOG, Font.PLAIN, 1); + float h1 = getScaledHeight(font, frc, SCALE); + float h2 = getScaledHeight(font, frc, SCALE + STEP); + float diff = Math.abs(h1 - h2); + + if (diff > LIMIT) { + throw new RuntimeException("Font metrix had round error " + + h1 + "," + h2); + } + } + + private static float getScaledHeight(Font font, + FontRenderContext frc, + double scale) { + AffineTransform at = new AffineTransform(scale, 0.0, 0.0, scale, + 0.0, 0.0); + Font transFont = font.deriveFont(at); + LineMetrics m = transFont.getLineMetrics("0", frc); + return m.getHeight(); + } +} + From a831b7aefb5968c5640ea0092ae7b63a6db9f0b8 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 15 Sep 2023 10:47:43 +0000 Subject: [PATCH 097/341] 8312555: Ideographic characters aren't stretched by AffineTransform.scale(2, 1) Ignore bitmaps embedded into fonts for non-uniform scales Backport-of: 62610203f18095cbd25b456f0622bad033a65a5d --- .../native/libfontmanager/freetypeScaler.c | 5 +- .../font/FontScaling/StretchedFontTest.java | 221 ++++++++++++++++++ 2 files changed, 224 insertions(+), 2 deletions(-) create mode 100644 test/jdk/java/awt/font/FontScaling/StretchedFontTest.java diff --git a/src/java.desktop/share/native/libfontmanager/freetypeScaler.c b/src/java.desktop/share/native/libfontmanager/freetypeScaler.c index 16dc9cd1e44fb..087169336c249 100644 --- a/src/java.desktop/share/native/libfontmanager/freetypeScaler.c +++ b/src/java.desktop/share/native/libfontmanager/freetypeScaler.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -530,7 +530,8 @@ Java_sun_font_FreetypeFontScaler_createScalerContextNative( if ((aa != TEXT_AA_ON) && (fm != TEXT_FM_ON) && !context->doBold && !context->doItalize && (context->transform.yx == 0) && (context->transform.xy == 0) && - (context->transform.xx > 0) && (context->transform.yy > 0)) + (context->transform.xx > 0) && (context->transform.yy > 0) && + (context->transform.xx == context->transform.yy)) { context->useSbits = 1; } diff --git a/test/jdk/java/awt/font/FontScaling/StretchedFontTest.java b/test/jdk/java/awt/font/FontScaling/StretchedFontTest.java new file mode 100644 index 0000000000000..da7c233f1c19e --- /dev/null +++ b/test/jdk/java/awt/font/FontScaling/StretchedFontTest.java @@ -0,0 +1,221 @@ +/* + * 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 java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.stream.Stream; + +import javax.imageio.ImageIO; + +import static java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment; +import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING; +import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB; +import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_OFF; +import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON; +import static java.awt.image.BufferedImage.TYPE_3BYTE_BGR; + +/* + * @test + * @bug 8312555 + * @summary Verifies that hieroglyphs are stretched by AffineTransform.scale(2, 1) + * @run main StretchedFontTest + */ +public final class StretchedFontTest { + private static final String TEXT = "\u6F22"; + private static final int FONT_SIZE = 20; + + private static final Color BACKGROUND = Color.WHITE; + private static final Color[] FOREGROUNDS = { + new Color(0xFF000000, true), + new Color(0x7F000000, true) + }; + + private static final AffineTransform STRETCH_TRANSFORM = + AffineTransform.getScaleInstance(2.0, 1.0); + + public static void main(String[] args) { + List errors = + Arrays.stream(getLocalGraphicsEnvironment() + .getAvailableFontFamilyNames(Locale.ENGLISH)) + .map(family -> new Font(family, Font.PLAIN, FONT_SIZE)) + .filter(font -> font.canDisplay(TEXT.codePointAt(0))) + .map(font -> font.deriveFont(STRETCH_TRANSFORM)) + .flatMap(StretchedFontTest::testFont) + .filter(Objects::nonNull) + .toList(); + + if (!errors.isEmpty()) { + errors.forEach(System.err::println); + throw new Error(errors.size() + " failure(s) found;" + + " the first one: " + errors.get(0)); + } + } + + /** + * Tests the font with a set of text antialiasing hints. + * + * @param font the font to test + * @return a stream of test results + * @see #testFont(Font, Object) + */ + private static Stream testFont(final Font font) { + return Stream.of(VALUE_TEXT_ANTIALIAS_OFF, + VALUE_TEXT_ANTIALIAS_ON, + VALUE_TEXT_ANTIALIAS_LCD_HRGB) + .flatMap(hint -> testFont(font, hint)); + } + + /** + * Tests the font with the specified text antialiasing hint and a set of + * foreground colors. + * + * @param font the font to test + * @param hint the text antialiasing hint to test + * @return a stream of test results + * @see #testFont(Font, Object, Color) + */ + private static Stream testFont(final Font font, final Object hint) { + return Stream.of(FOREGROUNDS) + .map(foreground -> testFont(font, hint, foreground)); + } + + /** + * Tests the font with the specified text antialiasing hint and + * foreground color. In case of failure, it saves the rendered + * image to a file. + * + * @param font the font to test + * @param hint the text antialiasing hint to test + * @param foreground the foreground color to use + * @return {@code null} if the text rendered correctly; otherwise, + * a {@code String} with the font family name, the value of + * the rendering hint and the color in hex + */ + private static String testFont(final Font font, + final Object hint, + final Color foreground) { + final Dimension size = getTextSize(font); + final BufferedImage image = + new BufferedImage(size.width, size.height, TYPE_3BYTE_BGR); + + final Graphics2D g2d = image.createGraphics(); + try { + g2d.setColor(BACKGROUND); + g2d.fillRect(0, 0, size.width, size.height); + + g2d.setRenderingHint(KEY_TEXT_ANTIALIASING, hint); + g2d.setColor(foreground); + g2d.setFont(font); + g2d.drawString(TEXT, 0, g2d.getFontMetrics(font).getAscent()); + } finally { + g2d.dispose(); + } + + if (verifyImage(image)) { + return null; + } + String fontName = font.getFontName(Locale.ENGLISH); + String hintValue = getHintString(hint); + String hexColor = String.format("0x%08x", foreground.getRGB()); + saveImage(image, fontName + "-" + hintValue + "-" + hexColor); + return "Font: " + fontName + ", Hint: " + hintValue + ", Color: " + hexColor; + } + + /** + * Verifies the rendered image of the hieroglyph. The hieroglyph + * should be stretched across the entire width of the image. + * If the right half of the image contains only pixels of the background + * color, the hieroglyph isn't stretched correctly + * — it's a failure. + * + * @param image the image to verify + * @return {@code true} if the hieroglyph is stretched correctly; or + * {@code false} if right half of the image contains only + * background-colored pixels, which means the hieroglyph isn't + * stretched. + */ + private static boolean verifyImage(final BufferedImage image) { + final int width = image.getWidth(); + final int height = image.getHeight(); + for (int x = width / 2; x < width; x++) { + for (int y = 0; y < height; y++) { + if (image.getRGB(x, y) != BACKGROUND.getRGB()) { + // Any other color but background means the glyph is stretched + return true; + } + } + } + + // The right side of the image is filled with the background color only, + // the glyph isn't stretched. + return false; + } + + private static String getHintString(final Object hint) { + if (hint == VALUE_TEXT_ANTIALIAS_OFF) { + return "off"; + } else if (hint == VALUE_TEXT_ANTIALIAS_ON) { + return "on"; + } else if (hint == VALUE_TEXT_ANTIALIAS_LCD_HRGB) { + return "lcd"; + } else { + throw new IllegalArgumentException("Unexpected hint: " + hint); + } + } + + private static final BufferedImage dummyImage = + new BufferedImage(5, 5, TYPE_3BYTE_BGR); + + private static Dimension getTextSize(final Font font) { + final Graphics g = dummyImage.getGraphics(); + try { + return g.getFontMetrics(font) + .getStringBounds(TEXT, g) + .getBounds() + .getSize(); + } finally { + g.dispose(); + } + } + + private static void saveImage(final BufferedImage image, + final String fileName) { + try { + ImageIO.write(image, + "png", + new File(fileName + ".png")); + } catch (IOException ignored) { + } + } +} From 35cf71fcef1d7a49990d4c47ead9564c0b363913 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 15 Sep 2023 14:08:05 +0000 Subject: [PATCH 098/341] 8301065: Handle control characters in java_lang_String::print Backport-of: 41d6be4d807921a91339029ae96e8dc14561bea6 --- src/hotspot/share/classfile/javaClasses.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index b10131af8772b..d5c31932e310f 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -819,8 +819,13 @@ void java_lang_String::print(oop java_string, outputStream* st) { st->print("\""); for (int index = 0; index < length; index++) { - st->print("%c", (!is_latin1) ? value->char_at(index) : - ((jchar) value->byte_at(index)) & 0xff ); + jchar c = (!is_latin1) ? value->char_at(index) : + ((jchar) value->byte_at(index)) & 0xff; + if (c < ' ') { + st->print("\\x%02X", c); // print control characters e.g. \x0A + } else { + st->print("%c", c); + } } st->print("\""); } From e12d0b59d22faf41e3d8188608a619a103e89d3c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 15 Sep 2023 14:10:49 +0000 Subject: [PATCH 099/341] 8311592: ECKeySizeParameterSpec causes too many exceptions on third party providers Backport-of: e554fdee254ce51d605fe127b73644620e87e23b --- .../classes/sun/security/util/KeyUtil.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/java.base/share/classes/sun/security/util/KeyUtil.java b/src/java.base/share/classes/sun/security/util/KeyUtil.java index a20ebffa5ff53..a62f92b7efc5a 100644 --- a/src/java.base/share/classes/sun/security/util/KeyUtil.java +++ b/src/java.base/share/classes/sun/security/util/KeyUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021, 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 @@ -144,17 +144,19 @@ public static final int getKeySize(Key key) { */ public static final int getKeySize(AlgorithmParameters parameters) { - String algorithm = parameters.getAlgorithm(); - switch (algorithm) { + switch (parameters.getAlgorithm()) { case "EC": - try { - ECKeySizeParameterSpec ps = parameters.getParameterSpec( + // ECKeySizeParameterSpec is SunEC internal only + if (parameters.getProvider().getName().equals("SunEC")) { + try { + ECKeySizeParameterSpec ps = parameters.getParameterSpec( ECKeySizeParameterSpec.class); - if (ps != null) { - return ps.getKeySize(); + if (ps != null) { + return ps.getKeySize(); + } + } catch (InvalidParameterSpecException ipse) { + // ignore } - } catch (InvalidParameterSpecException ipse) { - // ignore } try { From bc7699a3e58cdc6a5fe36622d864f2e76056b004 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 15 Sep 2023 14:12:55 +0000 Subject: [PATCH 100/341] 8304954: SegmentedCodeCache fails when using large pages Reviewed-by: phh Backport-of: cad6114e1c69bfebe5f7892c3e105b4c70d04398 --- src/hotspot/share/code/codeCache.cpp | 20 +++- src/hotspot/share/code/codeCache.hpp | 2 +- .../compiler/codecache/CheckLargePages.java | 98 +++++++++++++++++++ 3 files changed, 114 insertions(+), 6 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/codecache/CheckLargePages.java diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index d99ddb778b3eb..7f7a97da2c05b 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -291,9 +291,20 @@ void CodeCache::initialize_heaps() { FLAG_SET_ERGO(ProfiledCodeHeapSize, profiled_size); FLAG_SET_ERGO(NonProfiledCodeHeapSize, non_profiled_size); + const size_t ps = page_size(false, 8); + // Print warning if using large pages but not able to use the size given + if (UseLargePages) { + const size_t lg_ps = page_size(false, 1); + if (ps < lg_ps) { + log_warning(codecache)("Code cache size too small for " PROPERFMT " pages. " + "Reverting to smaller page size (" PROPERFMT ").", + PROPERFMTARGS(lg_ps), PROPERFMTARGS(ps)); + } + } + // If large page support is enabled, align code heaps according to large // page size to make sure that code cache is covered by large pages. - const size_t alignment = MAX2(page_size(false, 8), (size_t) os::vm_allocation_granularity()); + const size_t alignment = MAX2(ps, (size_t) os::vm_allocation_granularity()); non_nmethod_size = align_up(non_nmethod_size, alignment); profiled_size = align_down(profiled_size, alignment); non_profiled_size = align_down(non_profiled_size, alignment); @@ -305,7 +316,7 @@ void CodeCache::initialize_heaps() { // Non-nmethods // Profiled nmethods // ---------- low ------------ - ReservedCodeSpace rs = reserve_heap_memory(cache_size); + ReservedCodeSpace rs = reserve_heap_memory(cache_size, ps); ReservedSpace profiled_space = rs.first_part(profiled_size); ReservedSpace rest = rs.last_part(profiled_size); ReservedSpace non_method_space = rest.first_part(non_nmethod_size); @@ -332,9 +343,8 @@ size_t CodeCache::page_size(bool aligned, size_t min_pages) { } } -ReservedCodeSpace CodeCache::reserve_heap_memory(size_t size) { +ReservedCodeSpace CodeCache::reserve_heap_memory(size_t size, size_t rs_ps) { // Align and reserve space for code cache - const size_t rs_ps = page_size(); const size_t rs_align = MAX2(rs_ps, (size_t) os::vm_allocation_granularity()); const size_t rs_size = align_up(size, rs_align); ReservedCodeSpace rs(rs_size, rs_align, rs_ps); @@ -973,7 +983,7 @@ void CodeCache::initialize() { FLAG_SET_ERGO(NonNMethodCodeHeapSize, 0); FLAG_SET_ERGO(ProfiledCodeHeapSize, 0); FLAG_SET_ERGO(NonProfiledCodeHeapSize, 0); - ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize); + ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize, page_size(false, 8)); add_heap(rs, "CodeCache", CodeBlobType::All); } diff --git a/src/hotspot/share/code/codeCache.hpp b/src/hotspot/share/code/codeCache.hpp index ca3bae1df7e78..aca1668194a5e 100644 --- a/src/hotspot/share/code/codeCache.hpp +++ b/src/hotspot/share/code/codeCache.hpp @@ -109,7 +109,7 @@ class CodeCache : AllStatic { static CodeHeap* get_code_heap(int code_blob_type); // Returns the CodeHeap for the given CodeBlobType // Returns the name of the VM option to set the size of the corresponding CodeHeap static const char* get_code_heap_flag_name(int code_blob_type); - static ReservedCodeSpace reserve_heap_memory(size_t size); // Reserves one continuous chunk of memory for the CodeHeaps + static ReservedCodeSpace reserve_heap_memory(size_t size, size_t rs_ps); // Reserves one continuous chunk of memory for the CodeHeaps // Iteration static CodeBlob* first_blob(CodeHeap* heap); // Returns the first CodeBlob on the given CodeHeap diff --git a/test/hotspot/jtreg/compiler/codecache/CheckLargePages.java b/test/hotspot/jtreg/compiler/codecache/CheckLargePages.java new file mode 100644 index 0000000000000..8e2db5067d8c7 --- /dev/null +++ b/test/hotspot/jtreg/compiler/codecache/CheckLargePages.java @@ -0,0 +1,98 @@ +/* + * 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 8304954 + * @summary Code cache reservation should gracefully downgrade to using smaller pages if the code cache size is too small to host the requested page size. + * @requires os.family == "linux" + * @requires vm.gc != "Z" + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseLargePages -XX:LargePageSizeInBytes=1g compiler.codecache.CheckLargePages + */ + +package compiler.codecache; + +import jdk.test.lib.Asserts; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.whitebox.WhiteBox; + +import java.util.Arrays; +import java.util.List; + +public class CheckLargePages { + private final static WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + + 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( + "-XX:+UseLargePages", + "-XX:+SegmentedCodeCache", + "-XX:InitialCodeCacheSize=2g", + "-XX:ReservedCodeCacheSize=2g", + "-XX:LargePageSizeInBytes=1g", + "-Xlog:pagesize=info", + "-version"); + OutputAnalyzer out = new OutputAnalyzer(pb.start()); + out.shouldMatch("Code cache size too small for \\S* pages\\. Reverting to smaller page size \\((\\S*)\\)\\."); + out.shouldHaveExitValue(0); + // Parse page sizes to find next biggest page + String sizes = out.firstMatch("Usable page sizes:(.*)", 1); + List sizeList = Arrays.stream(sizes.trim().split("\\s*,\\s*")).map(CheckLargePages::parseMemoryString).sorted().toList(); + final int smallerPageSizeIndex = sizeList.indexOf(largePageSize) - 1; + Asserts.assertGreaterThanOrEqual(smallerPageSizeIndex, 0); + final long smallerPageSize = sizeList.get(smallerPageSizeIndex); + // Retrieve reverted page size from code cache warning + String revertedSizeString = out.firstMatch("Code cache size too small for (\\S*) pages. Reverting to smaller page size \\((\\S*)\\)\\.", 2); + Asserts.assertEquals(parseMemoryString(revertedSizeString), smallerPageSize); + } else { + System.out.println("1GB large pages not supported: UseLargePages=" + largePages + + (largePages ? ", largePageSize=" + largePageSize : "") + ". Skipping"); + } + } + + public static long parseMemoryString(String value) { + value = value.toUpperCase(); + long multiplier = 1; + if (value.endsWith("B")) { + multiplier = 1; + } else if (value.endsWith("K")) { + multiplier = 1024; + } else if (value.endsWith("M")) { + multiplier = 1024 * 1024; + } else if (value.endsWith("G")) { + multiplier = 1024 * 1024 * 1024; + } else { + throw new IllegalArgumentException("Expected memory string '" + value + "'to end with either of: B, K, M, G"); + } + + long longValue = Long.parseUnsignedLong(value.substring(0, value.length() - 1)); + + return longValue * multiplier; + } +} From 955dcb3b25bfbcb31b6a4eb5b53f57810cf0b8dc Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 15 Sep 2023 14:14:57 +0000 Subject: [PATCH 101/341] 8312573: Failure during CompileOnly parsing leads to ShouldNotReachHere Reviewed-by: phh Backport-of: 6f76b65ace50b2361221dddab120e91b057497c1 --- src/hotspot/share/compiler/compilerOracle.cpp | 19 ++----- .../parser/TestCompileOnly.java | 52 +++++++++++++++++++ 2 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/compilercontrol/parser/TestCompileOnly.java diff --git a/src/hotspot/share/compiler/compilerOracle.cpp b/src/hotspot/share/compiler/compilerOracle.cpp index 5149121c5bc79..7ebecc1527769 100644 --- a/src/hotspot/share/compiler/compilerOracle.cpp +++ b/src/hotspot/share/compiler/compilerOracle.cpp @@ -992,21 +992,10 @@ void CompilerOracle::parse_compile_only(char* line) { } } - if (*line == method_sep) { - if (className == NULL) { - className = ""; - c_match = MethodMatcher::Any; - } - } else { - // got foo or foo/bar - if (className == NULL) { - ShouldNotReachHere(); - } else { - // missing class name handled as "Any" class match - if (className[0] == '\0') { - c_match = MethodMatcher::Any; - } - } + if (className == nullptr || className[0] == '\0') { + // missing class name handled as "Any" class match + className = ""; + c_match = MethodMatcher::Any; } // each directive is terminated by , or NUL or . followed by NUL diff --git a/test/hotspot/jtreg/compiler/compilercontrol/parser/TestCompileOnly.java b/test/hotspot/jtreg/compiler/compilercontrol/parser/TestCompileOnly.java new file mode 100644 index 0000000000000..e129bf7ab481e --- /dev/null +++ b/test/hotspot/jtreg/compiler/compilercontrol/parser/TestCompileOnly.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. + * + * 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 8312573 + * @summary Test -XX:CompileOnly= with invalid arguments + * @library /test/lib / + * @run driver compiler.compilercontrol.parser.TestCompileOnly + */ + +package compiler.compilercontrol.parser; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class TestCompileOnly { + + public static void main(String[] args) throws Exception { + test(","); + test(" "); + test(", "); + test(" ,"); + test(",,"); + test(" "); + } + + public static void test(String compileOnlyCommand) throws Exception { + OutputAnalyzer output = ProcessTools.executeTestJvm("-XX:CompileOnly=" + compileOnlyCommand, "-version"); + output.shouldHaveExitValue(0); + } +} From fee0229a928a482483f2f4f679b6305fd7439f26 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 15 Sep 2023 14:17:47 +0000 Subject: [PATCH 102/341] 8312909: C1 should not inline through interface calls with non-subtype receiver Reviewed-by: phh Backport-of: ab1c212ac1097ae6e1122ef1aba47ca51eca11f2 --- src/hotspot/share/c1/c1_GraphBuilder.cpp | 9 +-- .../TestInvokeinterfaceWithBadReceiver.java | 60 +++++++++++++++++++ ...tInvokeinterfaceWithBadReceiverHelper.jasm | 44 ++++++++++++++ 3 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/c1/TestInvokeinterfaceWithBadReceiver.java create mode 100644 test/hotspot/jtreg/compiler/c1/TestInvokeinterfaceWithBadReceiverHelper.jasm diff --git a/src/hotspot/share/c1/c1_GraphBuilder.cpp b/src/hotspot/share/c1/c1_GraphBuilder.cpp index 3c2545ec6615e..d43b040a9b426 100644 --- a/src/hotspot/share/c1/c1_GraphBuilder.cpp +++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp @@ -2009,9 +2009,10 @@ void GraphBuilder::invoke(Bytecodes::Code code) { assert(singleton != declared_interface, "not a unique implementor"); cha_monomorphic_target = target->find_monomorphic_target(calling_klass, declared_interface, singleton); if (cha_monomorphic_target != NULL) { - if (cha_monomorphic_target->holder() != compilation()->env()->Object_klass()) { - ciInstanceKlass* holder = cha_monomorphic_target->holder(); - ciInstanceKlass* constraint = (holder->is_subtype_of(singleton) ? holder : singleton); // avoid upcasts + ciInstanceKlass* holder = cha_monomorphic_target->holder(); + ciInstanceKlass* constraint = (holder->is_subtype_of(singleton) ? holder : singleton); // avoid upcasts + if (holder != compilation()->env()->Object_klass() && + (!type_is_exact || receiver_klass->is_subtype_of(constraint))) { actual_recv = declared_interface; // insert a check it's really the expected class. @@ -2024,7 +2025,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) { dependency_recorder()->assert_unique_implementor(declared_interface, singleton); } else { - cha_monomorphic_target = NULL; // subtype check against Object is useless + cha_monomorphic_target = nullptr; } } } diff --git a/test/hotspot/jtreg/compiler/c1/TestInvokeinterfaceWithBadReceiver.java b/test/hotspot/jtreg/compiler/c1/TestInvokeinterfaceWithBadReceiver.java new file mode 100644 index 0000000000000..81f95430f527d --- /dev/null +++ b/test/hotspot/jtreg/compiler/c1/TestInvokeinterfaceWithBadReceiver.java @@ -0,0 +1,60 @@ +/* + * 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 8312909 + * @summary Test monomorphic interface call to with invalid receiver. + * @modules java.base/jdk.internal.vm.annotation + * @compile TestInvokeinterfaceWithBadReceiverHelper.jasm + * @run main/bootclasspath/othervm -XX:CompileCommand=compileonly,TestInvokeinterfaceWithBadReceiverHelper::test + * -Xcomp -XX:TieredStopAtLevel=1 TestInvokeinterfaceWithBadReceiver + */ + +import jdk.internal.vm.annotation.Stable; + +interface MyInterface { + public String get(); +} + +// Single implementor +class MyClass implements MyInterface { + @Stable + String field = "42"; + + public String get() { + return field; + } +} + +public class TestInvokeinterfaceWithBadReceiver { + + public static void main(String[] args) { + try { + TestInvokeinterfaceWithBadReceiverHelper.test(new MyClass()); + throw new RuntimeException("No IncompatibleClassChangeError thrown!"); + } catch (IncompatibleClassChangeError e) { + // Expected + } + } +} diff --git a/test/hotspot/jtreg/compiler/c1/TestInvokeinterfaceWithBadReceiverHelper.jasm b/test/hotspot/jtreg/compiler/c1/TestInvokeinterfaceWithBadReceiverHelper.jasm new file mode 100644 index 0000000000000..b975611a3930f --- /dev/null +++ b/test/hotspot/jtreg/compiler/c1/TestInvokeinterfaceWithBadReceiverHelper.jasm @@ -0,0 +1,44 @@ +/* + * 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. + * + */ + +super public class TestInvokeinterfaceWithBadReceiverHelper + version 51:0 +{ + public Method "":"()V" + stack 1 locals 1 + { + aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; + } + + public static Method test:"(LMyInterface;)Ljava/lang/String;" + stack 1 locals 2 + { + ldc String "42"; + invokeinterface InterfaceMethod MyInterface.get:"()Ljava/lang/String;", 1; + areturn; + } + +} // end Class TestInvokeinterfaceWithBadReceiverHelper From 1ce12c4f33d3d6905703d95df2574f4037dfd57d Mon Sep 17 00:00:00 2001 From: Long Yang Date: Fri, 15 Sep 2023 15:03:39 +0000 Subject: [PATCH 103/341] 8312065: Socket.connect does not timeout when profiling Reviewed-by: phh, vtewari, apangin --- src/java.base/aix/native/libnet/aix_close.c | 48 +++++----- .../linux/native/libnet/linux_close.c | 50 +++++------ .../macosx/native/libnet/bsd_close.c | 50 +++++------ test/jdk/java/net/Socket/B8312065.java | 88 +++++++++++++++++++ 4 files changed, 162 insertions(+), 74 deletions(-) create mode 100644 test/jdk/java/net/Socket/B8312065.java diff --git a/src/java.base/aix/native/libnet/aix_close.c b/src/java.base/aix/native/libnet/aix_close.c index f3069920b119d..736a4ed8c368e 100644 --- a/src/java.base/aix/native/libnet/aix_close.c +++ b/src/java.base/aix/native/libnet/aix_close.c @@ -388,50 +388,50 @@ int NET_SocketClose(int fd) { /************** Basic I/O operations here ***************/ /* - * Macro to perform a blocking IO operation. Restarts - * automatically if interrupted by signal (other than - * our wakeup signal) + * Macro to perform a blocking IO operation. + * If interrupted by signal (other than our wakeup signal), and if RETRY is true, + * then restarts automatically */ -#define BLOCKING_IO_RETURN_INT(FD, FUNC) { \ - int ret; \ - threadEntry_t self; \ - fdEntry_t *fdEntry = getFdEntry(FD); \ - if (fdEntry == NULL) { \ - errno = EBADF; \ - return -1; \ - } \ - do { \ - startOp(fdEntry, &self); \ - ret = FUNC; \ - endOp(fdEntry, &self); \ - } while (ret == -1 && errno == EINTR); \ - return ret; \ +#define BLOCKING_IO_RETURN_INT(FD, FUNC, RETRY) { \ + int ret; \ + threadEntry_t self; \ + fdEntry_t *fdEntry = getFdEntry(FD); \ + if (fdEntry == NULL) { \ + errno = EBADF; \ + return -1; \ + } \ + do { \ + startOp(fdEntry, &self); \ + ret = FUNC; \ + endOp(fdEntry, &self); \ + } while ((RETRY) && ret == -1 && errno == EINTR); \ + return ret; \ } int NET_Read(int s, void* buf, size_t len) { - BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0), JNI_TRUE ); } int NET_NonBlockingRead(int s, void* buf, size_t len) { - BLOCKING_IO_RETURN_INT(s, recv(s, buf, len, MSG_NONBLOCK)); + BLOCKING_IO_RETURN_INT(s, recv(s, buf, len, MSG_NONBLOCK), JNI_TRUE ); } int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen) { - BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) ); + BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen), JNI_TRUE ); } int NET_Send(int s, void *msg, int len, unsigned int flags) { - BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) ); + BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags), JNI_TRUE ); } int NET_SendTo(int s, const void *msg, int len, unsigned int flags, const struct sockaddr *to, int tolen) { - BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) ); + BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen), JNI_TRUE ); } int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) { - BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) ); + BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen), JNI_TRUE ); } int NET_Connect(int s, struct sockaddr *addr, int addrlen) { @@ -489,7 +489,7 @@ int NET_Connect(int s, struct sockaddr *addr, int addrlen) { } int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) { - BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) ); + BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout), JNI_FALSE ); } /* diff --git a/src/java.base/linux/native/libnet/linux_close.c b/src/java.base/linux/native/libnet/linux_close.c index 0d4e81e073197..aabdaad4e9252 100644 --- a/src/java.base/linux/native/libnet/linux_close.c +++ b/src/java.base/linux/native/libnet/linux_close.c @@ -345,58 +345,58 @@ int NET_SocketClose(int fd) { /************** Basic I/O operations here ***************/ /* - * Macro to perform a blocking IO operation. Restarts - * automatically if interrupted by signal (other than - * our wakeup signal) + * Macro to perform a blocking IO operation. + * If interrupted by signal (other than our wakeup signal), and if RETRY is true, + * then restarts automatically */ -#define BLOCKING_IO_RETURN_INT(FD, FUNC) { \ - int ret; \ - threadEntry_t self; \ - fdEntry_t *fdEntry = getFdEntry(FD); \ - if (fdEntry == NULL) { \ - errno = EBADF; \ - return -1; \ - } \ - do { \ - startOp(fdEntry, &self); \ - ret = FUNC; \ - endOp(fdEntry, &self); \ - } while (ret == -1 && errno == EINTR); \ - return ret; \ +#define BLOCKING_IO_RETURN_INT(FD, FUNC, RETRY) { \ + int ret; \ + threadEntry_t self; \ + fdEntry_t *fdEntry = getFdEntry(FD); \ + if (fdEntry == NULL) { \ + errno = EBADF; \ + return -1; \ + } \ + do { \ + startOp(fdEntry, &self); \ + ret = FUNC; \ + endOp(fdEntry, &self); \ + } while ((RETRY) && ret == -1 && errno == EINTR); \ + return ret; \ } int NET_Read(int s, void* buf, size_t len) { - BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0), JNI_TRUE ); } int NET_NonBlockingRead(int s, void* buf, size_t len) { - BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT) ); + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT), JNI_TRUE ); } int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen) { - BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) ); + BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen), JNI_TRUE ); } int NET_Send(int s, void *msg, int len, unsigned int flags) { - BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) ); + BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags), JNI_TRUE ); } int NET_SendTo(int s, const void *msg, int len, unsigned int flags, const struct sockaddr *to, int tolen) { - BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) ); + BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen), JNI_TRUE ); } int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) { - BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) ); + BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen), JNI_TRUE ); } int NET_Connect(int s, struct sockaddr *addr, int addrlen) { - BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) ); + BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen), JNI_TRUE ); } int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) { - BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) ); + BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout), JNI_FALSE ); } /* diff --git a/src/java.base/macosx/native/libnet/bsd_close.c b/src/java.base/macosx/native/libnet/bsd_close.c index 4a348b212f833..e4fd22b01fd56 100644 --- a/src/java.base/macosx/native/libnet/bsd_close.c +++ b/src/java.base/macosx/native/libnet/bsd_close.c @@ -349,58 +349,58 @@ int NET_SocketClose(int fd) { /************** Basic I/O operations here ***************/ /* - * Macro to perform a blocking IO operation. Restarts - * automatically if interrupted by signal (other than - * our wakeup signal) + * Macro to perform a blocking IO operation. + * If interrupted by signal (other than our wakeup signal), and if RETRY is true, + * then restarts automatically */ -#define BLOCKING_IO_RETURN_INT(FD, FUNC) { \ - int ret; \ - threadEntry_t self; \ - fdEntry_t *fdEntry = getFdEntry(FD); \ - if (fdEntry == NULL) { \ - errno = EBADF; \ - return -1; \ - } \ - do { \ - startOp(fdEntry, &self); \ - ret = FUNC; \ - endOp(fdEntry, &self); \ - } while (ret == -1 && errno == EINTR); \ - return ret; \ +#define BLOCKING_IO_RETURN_INT(FD, FUNC, RETRY) { \ + int ret; \ + threadEntry_t self; \ + fdEntry_t *fdEntry = getFdEntry(FD); \ + if (fdEntry == NULL) { \ + errno = EBADF; \ + return -1; \ + } \ + do { \ + startOp(fdEntry, &self); \ + ret = FUNC; \ + endOp(fdEntry, &self); \ + } while ((RETRY) && ret == -1 && errno == EINTR); \ + return ret; \ } int NET_Read(int s, void* buf, size_t len) { - BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0), JNI_TRUE ); } int NET_NonBlockingRead(int s, void* buf, size_t len) { - BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT)); + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, MSG_DONTWAIT), JNI_TRUE); } int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen) { - BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) ); + BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen), JNI_TRUE ); } int NET_Send(int s, void *msg, int len, unsigned int flags) { - BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) ); + BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags), JNI_TRUE ); } int NET_SendTo(int s, const void *msg, int len, unsigned int flags, const struct sockaddr *to, int tolen) { - BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) ); + BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen), JNI_TRUE ); } int NET_Accept(int s, struct sockaddr *addr, socklen_t *addrlen) { - BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) ); + BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen), JNI_TRUE ); } int NET_Connect(int s, struct sockaddr *addr, int addrlen) { - BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) ); + BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen), JNI_TRUE ); } int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) { - BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) ); + BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout), JNI_FALSE ); } /* diff --git a/test/jdk/java/net/Socket/B8312065.java b/test/jdk/java/net/Socket/B8312065.java new file mode 100644 index 0000000000000..118792eada3e9 --- /dev/null +++ b/test/jdk/java/net/Socket/B8312065.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2023, Alibaba Group Holding 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 + * @bug 8312065 + * @summary Socket.connect does not timeout as expected when profiling (i.e. keep receiving signal) + * @requires (os.family != "windows") + * @compile NativeThread.java + * @run main/othervm/native/timeout=120 -Djdk.net.usePlainSocketImpl B8312065 + */ + +import sun.misc.Signal; + +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketTimeoutException; +import java.util.concurrent.TimeUnit; + +public class B8312065 { + public static void main(String[] args) throws Exception { + System.loadLibrary("NativeThread"); + + // Setup SIGPIPE handler + Signal.handle(new Signal("PIPE"), System.out::println); + + long osThreadId = NativeThread.getID(); + + int timeoutMillis = 2000; + int n = 10; + Thread t = new Thread(() -> { + // Send SIGPIPE to the thread every second + for (int i = 0; i < n; i++) { + if (NativeThread.signal(osThreadId, NativeThread.SIGPIPE) != 0) { + System.out.println("Test FAILED: failed to send signal"); + System.exit(1); + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + System.out.println("Test FAILED: unexpected interrupt"); + System.exit(1); + } + } + System.out.println("Test FAILED: Socket.connect blocked " + n + " seconds, " + + "expected around " + timeoutMillis / 1000 + " seconds"); + System.exit(1); + }); + t.setDaemon(true); + t.start(); + + long startTime = System.nanoTime(); + + try { + Socket socket = new Socket(); + // There is no good way to mock SocketTimeoutException, just assume 192.168.255.255 is not in use + socket.connect(new InetSocketAddress("192.168.255.255", 8080), timeoutMillis); + } catch (SocketTimeoutException e) { + long duration = TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS); + if (duration >= timeoutMillis) { + System.out.println("Test passed"); + } else { + System.out.println("Test FAILED: duration " + duration + " ms, expected >= " + timeoutMillis + " ms"); + System.exit(1); + } + } + } +} From be52dc5f0c81cb7cea81bdf56629763fff04b06c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 20 Sep 2023 07:10:09 +0000 Subject: [PATCH 104/341] 8247351: [aarch64] NullPointerException during stack walking (clhsdb "where -a") Backport-of: 357fe09f2e46efa3343f6c8a57b8693dcd5dd43c --- .../share/classes/sun/jvm/hotspot/runtime/RegisterMap.java | 6 +++--- .../sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/RegisterMap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/RegisterMap.java index 237dfd8250871..a3f15f2be9992 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/RegisterMap.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/RegisterMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ public Address getLocation(VMReg reg) { Assert.that(0 <= i && i < regCount, "sanity check"); Assert.that(0 <= index && index < locationValidSize, "sanity check"); } - if ((locationValid[index] & (1 << i % locationValidTypeSize)) != 0) { + if ((locationValid[index] & (1L << i % locationValidTypeSize)) != 0) { return location[i]; } else { return getLocationPD(reg); @@ -162,7 +162,7 @@ public void setLocation(VMReg reg, Address loc) { Assert.that(updateMap, "updating map that does not need updating"); } location[i] = loc; - locationValid[index] |= (1 << (i % locationValidTypeSize)); + locationValid[index] |= (1L << (i % locationValidTypeSize)); } public boolean getIncludeArgumentOops() { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java index d58f7291f7954..3cd40d833cf2e 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2019, Red Hat Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -70,7 +70,7 @@ public class AARCH64Frame extends Frame { // Native frames private static final int NATIVE_FRAME_INITIAL_PARAM_OFFSET = 2; - private static VMReg fp = new VMReg(29); + private static VMReg fp = new VMReg(29 << 1); static { VM.registerVMInitializedObserver(new Observer() { From f908cee266f47a00fe37f4f7a603d7bb6791013a Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 20 Sep 2023 07:12:31 +0000 Subject: [PATCH 105/341] 8270447: [IR Framework] Add missing compilation level restriction when using FlipC1C2 stress option Backport-of: 36aefa351afeb5fd6b87060e06c1e8060afb87a0 --- .../lib/ir_framework/test/TestVM.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java b/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java index 57dc4236f3d5a..8a9874cb84e02 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java @@ -281,7 +281,7 @@ private void addBaseTests() { BaseTest baseTest = new BaseTest(test, shouldExcludeTest(m.getName())); allTests.add(baseTest); if (PRINT_VALID_IR_RULES) { - irMatchRulePrinter.emitRuleEncoding(m, baseTest.isSkipped()); + irMatchRulePrinter.emitRuleEncoding(m, baseTest.isSkipped()); } } catch (TestFormatException e) { // Failure logged. Continue and report later. @@ -462,19 +462,20 @@ private void dontCompileWithCompiler(Executable ex, Compiler compiler) { private void applyForceCompileCommand(Executable ex) { ForceCompile forceCompileAnno = getAnnotation(ex, ForceCompile.class); if (forceCompileAnno != null) { - CompLevel complevel = forceCompileAnno.value(); - TestFormat.check(complevel != CompLevel.SKIP && complevel != CompLevel.WAIT_FOR_COMPILATION, + CompLevel compLevel = forceCompileAnno.value(); + TestFormat.check(compLevel != CompLevel.SKIP && compLevel != CompLevel.WAIT_FOR_COMPILATION, "Cannot define compilation level SKIP or WAIT_FOR_COMPILATION in @ForceCompile at " + ex); - complevel = restrictCompLevel(forceCompileAnno.value()); + compLevel = restrictCompLevel(forceCompileAnno.value()); if (FLIP_C1_C2) { - complevel = complevel.flipCompLevel(); + compLevel = compLevel.flipCompLevel(); + compLevel = restrictCompLevel(compLevel.flipCompLevel()); } if (EXCLUDE_RANDOM) { - complevel = complevel.excludeCompilationRandomly(ex); + compLevel = compLevel.excludeCompilationRandomly(ex); } - if (complevel != CompLevel.SKIP) { - enqueueForCompilation(ex, complevel); - forceCompileMap.put(ex, complevel); + if (compLevel != CompLevel.SKIP) { + enqueueForCompilation(ex, compLevel); + forceCompileMap.put(ex, compLevel); } } } @@ -504,7 +505,7 @@ private void setupDeclaredTests() { } else { TestFormat.checkNoThrow(!m.isAnnotationPresent(IR.class), "Found @IR annotation on non-@Test method " + m); TestFormat.checkNoThrow(!m.isAnnotationPresent(Warmup.class) || getAnnotation(m, Run.class) != null, - "Found @Warmup annotation on non-@Test or non-@Run method " + m); + "Found @Warmup annotation on non-@Test or non-@Run method " + m); } } catch (TestFormatException e) { // Failure logged. Continue and report later. @@ -530,6 +531,7 @@ private void addDeclaredTest(Method m) { CompLevel compLevel = restrictCompLevel(testAnno.compLevel()); if (FLIP_C1_C2) { compLevel = compLevel.flipCompLevel(); + compLevel = restrictCompLevel(compLevel.flipCompLevel()); } if (EXCLUDE_RANDOM) { compLevel = compLevel.excludeCompilationRandomly(m); @@ -727,8 +729,8 @@ private void checkCustomRunTest(Method m, String testName, Method testMethod, De "Cannot use @Arguments at test method " + testMethod + " in combination with @Run method " + m); Warmup warmupAnno = getAnnotation(testMethod, Warmup.class); TestFormat.checkNoThrow(warmupAnno == null, - "Cannot set @Warmup at @Test method " + testMethod + " when used with its @Run method " - + m + ". Use @Warmup at @Run method instead."); + "Cannot set @Warmup at @Test method " + testMethod + " when used with its @Run method " + + m + ". Use @Warmup at @Run method instead."); Test testAnno = getAnnotation(testMethod, Test.class); TestFormat.checkNoThrow(runMode != RunMode.STANDALONE || testAnno.compLevel() == CompLevel.ANY, "Setting explicit compilation level for @Test method " + testMethod + " has no effect " @@ -864,7 +866,7 @@ enum TriState { public static void compile(Method m, CompLevel compLevel) { TestRun.check(compLevel != CompLevel.SKIP && compLevel != CompLevel.WAIT_FOR_COMPILATION, - "Invalid compilation request with level " + compLevel); + "Invalid compilation request with level " + compLevel); enqueueForCompilation(m, compLevel); } @@ -907,7 +909,7 @@ public static void assertDeoptimizedByC2(Method m) { */ private static boolean notUnstableDeoptAssertion(Method m, CompLevel level) { return (USE_COMPILER && !XCOMP && !IGNORE_COMPILER_CONTROLS && !TEST_C1 && - (!EXCLUDE_RANDOM || WHITE_BOX.isMethodCompilable(m, level.getValue(), false))); + (!EXCLUDE_RANDOM || WHITE_BOX.isMethodCompilable(m, level.getValue(), false))); } public static void assertCompiledByC1(Method m) { @@ -962,7 +964,7 @@ private static TriState compiledAtLevel(Method m, CompLevel level) { default -> throw new TestRunException("compiledAtLevel() should not be called with " + level); } } - if (!USE_COMPILER || XCOMP || TEST_C1 || IGNORE_COMPILER_CONTROLS || + if (!USE_COMPILER || XCOMP || TEST_C1 || IGNORE_COMPILER_CONTROLS || FLIP_C1_C2 || (EXCLUDE_RANDOM && !WHITE_BOX.isMethodCompilable(m, level.getValue(), false))) { return TriState.Maybe; } From f3ee6eadc772f1fad0971b5ef08aa36ce76158d4 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 20 Sep 2023 07:14:03 +0000 Subject: [PATCH 106/341] 8061729: Update java/net tests to eliminate dependency on sun.net.www.MessageHeader and some other internal APIs 8282017: sun/net/www/protocol/https/HttpsURLConnection/B6216082.java fails with "SocketException: Unexpected end of file from server" Backport-of: 0f3d3ac32c9d163a5d91c6839d313111c72f1ad4 --- .../www/http/HttpClient/ProxyFromCache.java | 25 +- .../net/www/http/HttpClient/RequestURI.java | 11 +- .../www/protocol/http/CloseOptionHeader.java | 32 +- .../protocol/http/HttpHeaderParserTest.java | 498 ++++++++++++++++++ .../sun/net/www/protocol/http/NTLMTest.java | 8 +- .../jdk/sun/net/www/protocol/http/NoNTLM.java | 18 +- .../www/protocol/http/RetryUponTimeout.java | 8 +- .../sun/net/www/protocol/http/UserAgent.java | 10 +- .../https/HttpsURLConnection/B6226610.java | 16 +- .../https/HttpsURLConnection/TunnelProxy.java | 11 +- .../jdk/test/lib/net/HttpHeaderParser.java | 390 ++++++++++++++ 11 files changed, 968 insertions(+), 59 deletions(-) create mode 100644 test/jdk/sun/net/www/protocol/http/HttpHeaderParserTest.java create mode 100644 test/lib/jdk/test/lib/net/HttpHeaderParser.java diff --git a/test/jdk/sun/net/www/http/HttpClient/ProxyFromCache.java b/test/jdk/sun/net/www/http/HttpClient/ProxyFromCache.java index f8885c637ed0e..6d2eaac126151 100644 --- a/test/jdk/sun/net/www/http/HttpClient/ProxyFromCache.java +++ b/test/jdk/sun/net/www/http/HttpClient/ProxyFromCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,14 +25,22 @@ * @test * @bug 6498566 * @summary URL.openConnection(Proxy.NO_PROXY) may connect through a proxy. - * @modules java.base/sun.net.www * @library /test/lib * @run main/othervm ProxyFromCache */ -import java.net.*; -import java.io.*; -import sun.net.www.MessageHeader; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.URL; + +import jdk.test.lib.net.HttpHeaderParser; import jdk.test.lib.net.URIBuilder; /* Creates a simple proxy and http server that just return 200 OK. @@ -135,15 +143,12 @@ public void run() { connectionCount++; InputStream is = sock.getInputStream(); OutputStream os = sock.getOutputStream(); - - MessageHeader headers = new MessageHeader (is); + HttpHeaderParser httpHeaderParser = new HttpHeaderParser(is); os.write(replyOK.getBytes("UTF-8")); - - headers = new MessageHeader (is); + httpHeaderParser = new HttpHeaderParser(is); // If we get here then we received a second request. connectionCount++; os.write(replyOK.getBytes("UTF-8")); - sock.close(); } catch (Exception e) { //e.printStackTrace(); diff --git a/test/jdk/sun/net/www/http/HttpClient/RequestURI.java b/test/jdk/sun/net/www/http/HttpClient/RequestURI.java index 667a0778abf60..a5b55989b12b9 100644 --- a/test/jdk/sun/net/www/http/HttpClient/RequestURI.java +++ b/test/jdk/sun/net/www/http/HttpClient/RequestURI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved. * 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,13 +25,14 @@ * @test * @bug 6469663 * @summary HTTP Request-URI contains fragment when connecting through proxy - * @modules java.base/sun.net.www + * @library /test/lib * @run main/othervm RequestURI */ import java.net.*; import java.io.*; -import sun.net.www.MessageHeader; + +import jdk.test.lib.net.HttpHeaderParser; // Create a Server listening on port 5001 to act as the proxy. Requests // never need to be forwared from it. We are only interested in the @@ -91,8 +92,8 @@ public void run() { InputStream is = sock.getInputStream(); OutputStream os = sock.getOutputStream(); - MessageHeader headers = new MessageHeader (is); - String requestLine = headers.getValue(0); + HttpHeaderParser headers = new HttpHeaderParser (is); + String requestLine = headers.getRequestDetails(); int first = requestLine.indexOf(' '); int second = requestLine.lastIndexOf(' '); diff --git a/test/jdk/sun/net/www/protocol/http/CloseOptionHeader.java b/test/jdk/sun/net/www/protocol/http/CloseOptionHeader.java index bc1ec86fee456..28bb8af30cd3b 100644 --- a/test/jdk/sun/net/www/protocol/http/CloseOptionHeader.java +++ b/test/jdk/sun/net/www/protocol/http/CloseOptionHeader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. * 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,16 +24,23 @@ /** * @test * @bug 6189206 - * @modules java.base/sun.net.www * @library /test/lib * @run main/othervm -Dhttp.keepAlive=false CloseOptionHeader * @summary HTTP client should set "Connection: close" header in request when keepalive is disabled */ -import java.net.*; -import java.util.*; -import java.io.*; -import sun.net.www.MessageHeader; +import java.io.BufferedOutputStream; +import java.io.InputStream; +import java.io.PrintStream; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.URL; +import java.util.List; + +import jdk.test.lib.net.HttpHeaderParser; import jdk.test.lib.net.URIBuilder; public class CloseOptionHeader implements Runnable { @@ -49,10 +56,15 @@ public void run() { /* check the request to find close connection option header */ InputStream is = s.getInputStream (); - MessageHeader mh = new MessageHeader(is); - String connHeader = mh.findValue("Connection"); - if (connHeader != null && connHeader.equalsIgnoreCase("close")) { - hasCloseHeader = true; + HttpHeaderParser mh = new HttpHeaderParser(is); + List connHeader = mh.getHeaderValue("Connection"); + if (connHeader != null) { + for(String value : connHeader) { + if (value.equalsIgnoreCase("close")) { + hasCloseHeader = true; + break; + } + } } PrintStream out = new PrintStream( diff --git a/test/jdk/sun/net/www/protocol/http/HttpHeaderParserTest.java b/test/jdk/sun/net/www/protocol/http/HttpHeaderParserTest.java new file mode 100644 index 0000000000000..245cd49d518f8 --- /dev/null +++ b/test/jdk/sun/net/www/protocol/http/HttpHeaderParserTest.java @@ -0,0 +1,498 @@ + + +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * 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 8061729 + * @library /test/lib + * @summary Sanity check that HttpHeaderParser works same as MessageHeader + * @modules java.base/sun.net.www java.base/sun.net.www.protocol.http:open + * @run testng/othervm HttpHeaderParserTest + */ + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import static java.lang.String.format; +import static java.nio.charset.StandardCharsets.ISO_8859_1; +import static java.nio.charset.StandardCharsets.US_ASCII; +import jdk.test.lib.net.HttpHeaderParser; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import sun.net.www.MessageHeader; + +public class HttpHeaderParserTest { + @DataProvider(name = "responses") + public Object[][] responses() { + List responses = new ArrayList<>(); + + String[] basic = + { "HTTP/1.1 200 OK\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" + + "Server: Apache/1.3.14 (Unix)\r\n" + + "Connection: close\r\n" + + "Content-Type: text/html; charset=iso-8859-1\r\n" + + "Content-Length: 10\r\n\r\n" + + "123456789", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 9\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "X-Header: U\u00ffU\r\n" + // value with U+00FF - Extended Latin-1 + "Content-Length: 9\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 9\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + // more than one SP after ':' + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length:\t10\r\n" + + "Content-Type:\ttext/html; charset=UTF-8\r\n\r\n" + // HT separator + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length:\t\t10\r\n" + + "Content-Type:\t\ttext/html; charset=UTF-8\r\n\r\n" + // more than one HT after ':' + "XXXXX", + + "HTTP/1.1 407 Proxy Authorization Required\r\n" + + "Proxy-Authenticate: Basic realm=\"a fake realm\"\r\n\r\n", + + "HTTP/1.1 401 Unauthorized\r\n" + + "WWW-Authenticate: Digest realm=\"wally land\" domain=/ " + + "nonce=\"2B7F3A2B\" qop=\"auth\"\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + "X-Foo:\r\n\r\n", // no value + + "HTTP/1.1 200 OK\r\n" + + "X-Foo:\r\n\r\n" + // no value, with response body + "Some Response Body", + + "HTTP/1.1 200 OK\r\n" + + "X-Foo:\r\n" + // no value, followed by another header + "Content-Length: 10\r\n\r\n" + + "Some Response Body", + + "HTTP/1.1 200 OK\r\n" + + "X-Foo:\r\n" + // no value, followed by another header, with response body + "Content-Length: 10\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + "X-Foo: chegar\r\n" + + "X-Foo: dfuchs\r\n" + // same header appears multiple times + "Content-Length: 0\r\n" + + "X-Foo: michaelm\r\n" + + "X-Foo: prappo\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + "X-Foo:\r\n" + // no value, same header appears multiple times + "X-Foo: dfuchs\r\n" + + "Content-Length: 0\r\n" + + "X-Foo: michaelm\r\n" + + "X-Foo: prappo\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-control: max-age=0, no-cache=\"set-cookie\"\r\n" + + "Content-Length: 132868\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n" + + "Date: Sun, 05 Nov 2017 22:24:03 GMT\r\n" + + "Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips Communique/4.2.2\r\n" + + "Set-Cookie: AWSELB=AF7927F5100F4202119876ED2436B5005EE;PATH=/;MAX-AGE=900\r\n" + + "Vary: Host,Accept-Encoding,User-Agent\r\n" + + "X-Mod-Pagespeed: 1.12.34.2-0\r\n" + + "Connection: keep-alive\r\n\r\n" + }; + Arrays.stream(basic).forEach(responses::add); + // add some tests where some of the CRLF are replaced + // by a single LF + Arrays.stream(basic) + .map(HttpHeaderParserTest::mixedCRLF) + .forEach(responses::add); + + String[] foldingTemplate = + { "HTTP/1.1 200 OK\r\n" + + "Content-Length: 9\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r' + " charset=UTF-8\r\n" + // one preceding SP + "Connection: close\r\n\r\n" + + "XXYYZZAABBCCDDEE", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 19\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r + " charset=UTF-8\r\n" + // more than one preceding SP + "Connection: keep-alive\r\n\r\n" + + "XXYYZZAABBCCDDEEFFGG", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 999\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r + "\tcharset=UTF-8\r\n" + // one preceding HT + "Connection: close\r\n\r\n" + + "XXYYZZAABBCCDDEE", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 54\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r + "\t\t\tcharset=UTF-8\r\n" + // more than one preceding HT + "Connection: keep-alive\r\n\r\n" + + "XXYYZZAABBCCDDEEFFGG", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: -1\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r + "\t \t \tcharset=UTF-8\r\n" + // mix of preceding HT and SP + "Connection: keep-alive\r\n\r\n" + + "XXYYZZAABBCCDDEEFFGGHH", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 65\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r + " \t \t charset=UTF-8\r\n" + // mix of preceding SP and HT + "Connection: keep-alive\r\n\r\n" + + "XXYYZZAABBCCDDEEFFGGHHII", + + "HTTP/1.1 401 Unauthorized\r\n" + + "WWW-Authenticate: Digest realm=\"wally land\"," + +"$NEWLINE domain=/," + +"$NEWLINE nonce=\"2B7F3A2B\"," + +"$NEWLINE\tqop=\"auth\"\r\n\r\n", + + }; + for (String newLineChar : new String[] { "\n", "\r", "\r\n" }) { + for (String template : foldingTemplate) + responses.add(template.replace("$NEWLINE", newLineChar)); + } + // add some tests where some of the CRLF are replaced + // by a single LF + for (String newLineChar : new String[] { "\n", "\r", "\r\n" }) { + for (String template : foldingTemplate) + responses.add(mixedCRLF(template).replace("$NEWLINE", newLineChar)); + } + + String[] bad = // much of this is to retain parity with legacy MessageHeaders + { "HTTP/1.1 200 OK\r\n" + + "Connection:\r\n\r\n", // empty value, no body + + "HTTP/1.1 200 OK\r\n" + + "Connection:\r\n\r\n" + // empty value, with body + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + ": no header\r\n\r\n", // no/empty header-name, no body, no following header + + "HTTP/1.1 200 OK\r\n" + + ": no; header\r\n" + // no/empty header-name, no body, following header + "Content-Length: 65\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + ": no header\r\n" + // no/empty header-name + "Content-Length: 65\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "X-foo: bar\r\n" + + " : no header\r\n" + // fold, not a blank header-name + "Content-Length: 65\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "X-foo: bar\r\n" + + " \t : no header\r\n" + // fold, not a blank header-name + "Content-Length: 65\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + ": no header\r\n\r\n" + // no/empty header-name, followed by header + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Conte\r" + + "nt-Length: 9\r\n" + // fold/bad header name ??? without preceding space + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXXYYZZ", + + "HTTP/1.0 404 Not Found\r\n" + + "header-without-colon\r\n\r\n", + + "HTTP/1.0 404 Not Found\r\n" + + "header-without-colon\r\n\r\n" + + "SOMEBODY", + + }; + Arrays.stream(bad).forEach(responses::add); + + return responses.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); + } + + static final AtomicInteger index = new AtomicInteger(); + static final AtomicInteger limit = new AtomicInteger(1); + static final AtomicBoolean useCRLF = new AtomicBoolean(); + // A small method to replace part of the CRLF present in a string + // with simple LF. The method uses a deterministic algorithm based + // on current values of static index/limit/useCRLF counters. + // These counters are used to produce a stream of substitutes that + // looks like this: + // LF CRLF LF LF CRLF CRLF LF LF LF CRLF CRLF CRLF (then repeat from start) + static final String mixedCRLF(String headers) { + int next; + int start = 0; + int last = headers.lastIndexOf("\r\n"); + String prev = ""; + StringBuilder res = new StringBuilder(); + while ((next = headers.indexOf("\r\n", start)) > 0) { + res.append(headers.substring(start, next)); + if ("\n".equals(prev) && next == last) { + // for some reason the legacy MessageHeader parser will + // not consume the final LF if the headers are terminated + // by instead of . It consume + // but leaves the last in the stream. + // Here we just make sure to avoid using + // as that would cause the legacy parser to consume + // 1 byte less than the Http1HeadersParser - which + // does consume the last , as it should. + // if this is the last CRLF and the previous one + // was replaced by LF then use LF. + res.append(prev); + } else { + prev = useCRLF.get() ? "\r\n" : "\n"; + res.append(prev); + } + // skip CRLF + start = next + 2; + + // The idea is to substitute some of the CRLF with LF. + // Rather than doing this randomly, always use the following + // sequence: + // LF CRLF LF LF CRLF CRLF LF LF LF CRLF CRLF CRLF + index.incrementAndGet(); + if (index.get() == limit.get()) { + index.set(0); + if (useCRLF.get()) limit.incrementAndGet(); + if (limit.get() > 3) limit.set(1); + useCRLF.set(!useCRLF.get()); + } + } + res.append(headers.substring(start)); + return res.toString(); + } + + + @Test(dataProvider = "responses") + public void verifyHeaders(String respString) throws Exception { + System.out.println("\ntesting:\n\t" + respString + .replace("\r\n", "") + .replace("\r", "") + .replace("\n","") + .replace("LF>", "LF>\n\t")); + byte[] bytes = respString.getBytes(ISO_8859_1); + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + MessageHeader m = new MessageHeader(bais); + Map> messageHeaderMap = m.getHeaders(); + int availableBytes = bais.available(); + + HttpHeaderParser decoder = new HttpHeaderParser(); + ByteArrayInputStream headerStream = new ByteArrayInputStream(bytes); + int initialBytes = headerStream.available(); + decoder.parse(headerStream); + System.out.printf("HttpHeaderParser parsed %d bytes out of %d%n", initialBytes - headerStream.available(), bytes.length); + Map> decoderMap1 = decoder.getHeaderMap(); + + + // assert status-line + String statusLine1 = messageHeaderMap.get(null).get(0); + String statusLine2 = decoder.getRequestDetails(); + if (statusLine1.startsWith("HTTP")) {// skip the case where MH's messes up the status-line + assertEquals(statusLine2, statusLine1, "Status-line not equal"); + } else { + assertTrue(statusLine2.startsWith("HTTP/1."), "Status-line not HTTP/1."); + } + + // remove the null'th entry with is the status-line + Map> map = new HashMap<>(); + for (Map.Entry> e : messageHeaderMap.entrySet()) { + if (e.getKey() != null) { + map.put(e.getKey(), e.getValue()); + } + } + messageHeaderMap = map; + + assertHeadersEqual(messageHeaderMap, decoderMap1, + "messageHeaderMap not equal to decoderMap1"); + + assertEquals(availableBytes, headerStream.available(), + String.format("stream available (%d) not equal to remaining (%d)", + availableBytes, headerStream.available())); + } + + @DataProvider(name = "errors") + public Object[][] errors() { + List responses = new ArrayList<>(); + + // These responses are parsed, somewhat, by MessageHeaders but give + // nonsensible results. They, correctly, fail with the Http1HeaderParser. + String[] bad = + {// "HTTP/1.1 402 Payment Required\r\n" + + // "Content-Length: 65\r\n\r", // missing trailing LF //TODO: incomplete + + "HTTP/1.1 402 Payment Required\r\n" + + "Content-Length: 65\r\n\rT\r\n\r\nGGGGGG", + + "HTTP/1.1 200OK\r\n\rT", + + "HTTP/1.1 200OK\rT", + + "HTTP/1.0 FOO\r\n", + + "HTTP/1.1 BAR\r\n", + + "HTTP/1.1 +99\r\n", + + "HTTP/1.1 -22\r\n", + + "HTTP/1.1 -20 \r\n", + + "HTTP/1.1 200 OK\r\n" + + "X-fo\u00ffo: foo\r\n" + // invalid char in name + "Content-Length: 5\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "HTTP/1.1 200 OK\r\n" + + "X-foo : bar\r\n" + // trim space after name + "Content-Length: 5\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + " X-foo: bar\r\n" + // trim space before name + "Content-Length: 5\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "X foo: bar\r\n" + // invalid space in name + "Content-Length: 5\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 5\r\n" + + "Content Type: text/html; charset=UTF-8\r\n\r\n" + // invalid space in name + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Conte\r" + + " nt-Length: 9\r\n" + // fold results in space in header name + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + " : no header\r\n" + // all blank header-name (not fold) + "Content-Length: 65\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + " \t : no header\r\n" + // all blank header-name (not fold) + "Content-Length: 65\r\n\r\n" + + "XXXXX", + + }; + Arrays.stream(bad).forEach(responses::add); + + return responses.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); + } + + @Test(dataProvider = "errors", expectedExceptions = IOException.class) + public void errors(String respString) throws IOException { + byte[] bytes = respString.getBytes(US_ASCII); + HttpHeaderParser decoder = new HttpHeaderParser(); + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + decoder.parse(bais); + } + + void assertHeadersEqual(Map> expected, + Map> actual, + String msg) { + + if (expected.equals(actual)) + return; + + assertEquals(expected.size(), actual.size(), + format("%s. Expected size %d, actual size %s. %nexpected= %s,%n actual=%s.", + msg, expected.size(), actual.size(), mapToString(expected), mapToString(actual))); + + for (Map.Entry> e : expected.entrySet()) { + String key = e.getKey(); + List values = e.getValue(); + + boolean found = false; + for (Map.Entry> other: actual.entrySet()) { + if (key.equalsIgnoreCase(other.getKey())) { + found = true; + List otherValues = other.getValue(); + assertEquals(values.size(), otherValues.size(), + format("%s. Expected list size %d, actual size %s", + msg, values.size(), otherValues.size())); + if (!(values.containsAll(otherValues) && otherValues.containsAll(values))) + assertTrue(false, format("Lists are unequal [%s] [%s]", values, otherValues)); + break; + } + } + assertTrue(found, format("header name, %s, not found in %s", key, actual)); + } + } + + static String mapToString(Map> map) { + StringBuilder sb = new StringBuilder(); + List sortedKeys = new ArrayList(map.keySet()); + Collections.sort(sortedKeys); + for (String key : sortedKeys) { + List values = map.get(key); + sb.append("\n\t" + key + " | " + values); + } + return sb.toString(); + } +} diff --git a/test/jdk/sun/net/www/protocol/http/NTLMTest.java b/test/jdk/sun/net/www/protocol/http/NTLMTest.java index 73d0cb98603d3..37282f15b03b9 100644 --- a/test/jdk/sun/net/www/protocol/http/NTLMTest.java +++ b/test/jdk/sun/net/www/protocol/http/NTLMTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ /* * @test * @bug 6520665 6357133 - * @modules java.base/sun.net.www * @library /test/lib * @run main/othervm NTLMTest * @summary 6520665 & 6357133: NTLM authentication issues. @@ -32,7 +31,8 @@ import java.net.*; import java.io.*; -import sun.net.www.MessageHeader; + +import jdk.test.lib.net.HttpHeaderParser; import jdk.test.lib.net.URIBuilder; public class NTLMTest @@ -160,7 +160,7 @@ static void handleConnection(Socket s, String[] resp, int start, int end) { OutputStream os = s.getOutputStream(); for (int i=start; i server // client <--- 401 ---- server try (Socket s = ss.accept()) { - new MessageHeader().parseHeader(s.getInputStream()); + new HttpHeaderParser().parse(s.getInputStream()); s.getOutputStream().write(reply.getBytes("US-ASCII")); } @@ -171,10 +171,10 @@ static void test(String... schemes) throws IOException { // client <--- 200 ---- server String auth; try (Socket s = ss.accept()) { - MessageHeader mh = new MessageHeader(); - mh.parseHeader(s.getInputStream()); + HttpHeaderParser mh = new HttpHeaderParser(); + mh.parse(s.getInputStream()); s.getOutputStream().write(OKAY.getBytes("US-ASCII")); - auth = mh.findValue("Authorization"); + auth = mh.getHeaderValue("Authorization").get(0); } // check Authorization header @@ -208,7 +208,7 @@ static void testNTLM() throws Exception { // client ---- GET ---> server // client <--- 401 ---- client try (Socket s = ss.accept()) { - new MessageHeader().parseHeader(s.getInputStream()); + new HttpHeaderParser().parse(s.getInputStream()); s.getOutputStream().write(reply.getBytes("US-ASCII")); } diff --git a/test/jdk/sun/net/www/protocol/http/RetryUponTimeout.java b/test/jdk/sun/net/www/protocol/http/RetryUponTimeout.java index bfda1663259f6..b2214780c2e8d 100644 --- a/test/jdk/sun/net/www/protocol/http/RetryUponTimeout.java +++ b/test/jdk/sun/net/www/protocol/http/RetryUponTimeout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * 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,13 +26,13 @@ * @bug 4772077 * @library /test/lib * @summary using defaultReadTimeout appear to retry request upon timeout - * @modules java.base/sun.net.www */ import java.net.*; import java.io.*; + +import jdk.test.lib.net.HttpHeaderParser; import jdk.test.lib.net.URIBuilder; -import sun.net.www.*; public class RetryUponTimeout implements Runnable { // run server @@ -42,7 +42,7 @@ public void run(){ for (int i = 0; i < 2; i++) { socket = server.accept(); InputStream is = socket.getInputStream (); - MessageHeader header = new MessageHeader (is); + HttpHeaderParser header = new HttpHeaderParser (is); count++; } } catch (Exception ex) { diff --git a/test/jdk/sun/net/www/protocol/http/UserAgent.java b/test/jdk/sun/net/www/protocol/http/UserAgent.java index 7db848824887a..40ff5d3106fc6 100644 --- a/test/jdk/sun/net/www/protocol/http/UserAgent.java +++ b/test/jdk/sun/net/www/protocol/http/UserAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test * @bug 4512200 * @library /test/lib - * @modules java.base/sun.net.www * @run main/othervm -Dhttp.agent=foo UserAgent * @run main/othervm -Dhttp.agent=foo -Djava.net.preferIPv6Addresses=true UserAgent * @summary HTTP header "User-Agent" format incorrect @@ -34,8 +33,9 @@ import java.io.*; import java.util.*; import java.net.*; + +import jdk.test.lib.net.HttpHeaderParser; import jdk.test.lib.net.URIBuilder; -import sun.net.www.MessageHeader; class Server extends Thread { Server (ServerSocket server) { @@ -46,8 +46,8 @@ public void run () { String version = System.getProperty ("java.version"); String expected = "foo Java/"+version; Socket s = server.accept (); - MessageHeader header = new MessageHeader (s.getInputStream()); - String v = header.findValue ("User-Agent"); + HttpHeaderParser header = new HttpHeaderParser (s.getInputStream()); + String v = header.getHeaderValue ("User-Agent").get(0); if (!expected.equals (v)) { error ("Got unexpected User-Agent: " + v); } else { diff --git a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java index ec75bcc3e113a..9fca12c995840 100644 --- a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java +++ b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @bug 6226610 6973030 * @summary HTTP tunnel connections send user headers to proxy - * @modules java.base/sun.net.www + * @library /test/lib * @run main/othervm B6226610 */ @@ -37,7 +37,9 @@ import java.io.*; import java.net.*; -import sun.net.www.MessageHeader; + +import jdk.test.lib.net.HttpHeaderParser; + public class B6226610 { static HeaderCheckerProxyTunnelServer proxy; @@ -138,21 +140,21 @@ public int getLocalPort() { private void processRequests() throws IOException { InputStream in = clientSocket.getInputStream(); - MessageHeader mheader = new MessageHeader(in); - String statusLine = mheader.getValue(0); + HttpHeaderParser mheader = new HttpHeaderParser(in); + String statusLine = mheader.getRequestDetails(); if (statusLine.startsWith("CONNECT")) { // retrieve the host and port info from the status-line retrieveConnectInfo(statusLine); - if (mheader.findValue("X-TestHeader") != null) { + if (mheader.getHeaderValue("X-TestHeader") != null) { System.out.println("Proxy should not receive user defined headers for tunneled requests"); failed = true; } // 6973030 String value; - if ((value = mheader.findValue("Proxy-Connection")) == null || + if ((value = mheader.getHeaderValue("Proxy-Connection").get(0)) == null || !value.equals("keep-alive")) { System.out.println("Proxy-Connection:keep-alive not being sent"); failed = true; diff --git a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java index 9573543fde119..9cec3987d9e03 100644 --- a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java +++ b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ import java.util.Iterator; import java.util.Set; -import sun.net.www.MessageHeader; +import jdk.test.lib.net.HttpHeaderParser; + public class TunnelProxy { @@ -260,9 +261,9 @@ private boolean read (SocketChannel chan, SelectionKey key) { boolean res; try { InputStream is = new BufferedInputStream (new NioInputStream (chan)); - String requestline = readLine (is); - MessageHeader mhead = new MessageHeader (is); - String[] req = requestline.split (" "); + HttpHeaderParser mHead = new HttpHeaderParser (is); + String requestLine = mHead.getRequestDetails(); + String[] req = requestLine.split (" "); if (req.length < 2) { /* invalid request line */ return false; diff --git a/test/lib/jdk/test/lib/net/HttpHeaderParser.java b/test/lib/jdk/test/lib/net/HttpHeaderParser.java new file mode 100644 index 0000000000000..71b3a84fdaa6f --- /dev/null +++ b/test/lib/jdk/test/lib/net/HttpHeaderParser.java @@ -0,0 +1,390 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.net; + +import java.io.IOException; +import java.io.InputStream; +import java.net.ProtocolException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import static java.util.Objects.requireNonNull; + +public class HttpHeaderParser { + private static final char CR = '\r'; + private static final char LF = '\n'; + private static final char HT = '\t'; + private static final char SP = ' '; + // ABNF primitives defined in RFC 7230 + private static boolean[] tchar = new boolean[256]; + private static boolean[] fieldvchar = new boolean[256]; + + static { + char[] allowedTokenChars = + ("!#$%&'*+-.^_`|~0123456789" + + "abcdefghijklmnopqrstuvwxyz" + + "ABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray(); + for (char c : allowedTokenChars) { + tchar[c] = true; + } + for (char c = 0x21; c <= 0xFF; c++) { + fieldvchar[c] = true; + } + fieldvchar[0x7F] = false; // a little hole (DEL) in the range + } + + private StringBuilder sb = new StringBuilder(); + + private Map > headerMap = new LinkedHashMap<>(); + private List keyList = new ArrayList<>(); + private String requestOrStatusLine; + private int responseCode; + private boolean eof; + + + + enum State { INITIAL, + STATUS_OR_REQUEST_LINE, + STATUS_OR_REQUEST_LINE_FOUND_CR, + STATUS_OR_REQUEST_LINE_FOUND_LF, + STATUS_OR_REQUEST_LINE_END, + STATUS_OR_REQUEST_LINE_END_CR, + STATUS_OR_REQUEST_LINE_END_LF, + HEADER, + HEADER_FOUND_CR, + HEADER_FOUND_LF, + HEADER_FOUND_CR_LF, + HEADER_FOUND_CR_LF_CR, + FINISHED } + + private HttpHeaderParser.State state = HttpHeaderParser.State.INITIAL; + + public HttpHeaderParser() { + } + + + public HttpHeaderParser(InputStream is) throws IOException, ProtocolException { + parse(is); + } + + public Map> getHeaderMap() { + return headerMap; + } + + public List getHeaderValue(String key) { + if(headerMap.containsKey(key.toLowerCase(Locale.ROOT))) { + return headerMap.get(key.toLowerCase(Locale.ROOT)); + } + return null; + } + public List getValue(int id) { + String key = keyList.get(id); + return headerMap.get(key); + } + + public String getRequestDetails() { + return requestOrStatusLine; + } + + /** + * Parses HTTP/1.X status-line or request-line and headers from the given input stream. + * @param input Containing the input stream of bytes representing request or response header data + * @return true if the end of the headers block has been reached + */ + public boolean parse(InputStream input) throws IOException { + requireNonNull(input, "null input"); + while (canContinueParsing()) { + switch (state) { + case INITIAL -> state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE; + case STATUS_OR_REQUEST_LINE -> readResumeStatusLine(input); + case STATUS_OR_REQUEST_LINE_FOUND_CR, STATUS_OR_REQUEST_LINE_FOUND_LF -> readStatusLineFeed(input); + case STATUS_OR_REQUEST_LINE_END -> maybeStartHeaders(input); + case STATUS_OR_REQUEST_LINE_END_CR, STATUS_OR_REQUEST_LINE_END_LF -> maybeEndHeaders(input); + case HEADER -> readResumeHeader(input); + case HEADER_FOUND_CR, HEADER_FOUND_LF -> resumeOrLF(input); + case HEADER_FOUND_CR_LF -> resumeOrSecondCR(input); + case HEADER_FOUND_CR_LF_CR -> resumeOrEndHeaders(input); + default -> throw new InternalError("Unexpected state: " + state); + } + } + return state == HttpHeaderParser.State.FINISHED; + } + + private boolean canContinueParsing() { + // some states don't require any input to transition + // to the next state. + return switch (state) { + case FINISHED -> false; + case STATUS_OR_REQUEST_LINE_FOUND_LF, STATUS_OR_REQUEST_LINE_END_LF, HEADER_FOUND_LF -> true; + default -> !eof; + }; + } + + /** + * Returns a character (char) corresponding to the next byte in the + * input, interpreted as an ISO-8859-1 encoded character. + *

+ * The ISO-8859-1 encoding is a 8-bit character coding that + * corresponds to the first 256 Unicode characters - from U+0000 to + * U+00FF. UTF-16 is backward compatible with ISO-8859-1 - which + * means each byte in the input should be interpreted as an unsigned + * value from [0, 255] representing the character code. + * + * @param input a {@code InputStream} containing input stream of Bytes. + * @return the next byte in the input, interpreted as an ISO-8859-1 + * encoded char + * @throws IOException + * if an I/O error occurs. + */ + private char get(InputStream input) throws IOException { + int c = input.read(); + if(c < 0) + eof = true; + return (char)(c & 0xFF); + } + + private void readResumeStatusLine(InputStream input) throws IOException { + char c; + while ((c = get(input)) != CR && !eof) { + if (c == LF) break; + sb.append(c); + } + if (c == CR) { + state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_FOUND_CR; + } else if (c == LF) { + state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_FOUND_LF; + } + } + + private void readStatusLineFeed(InputStream input) throws IOException { + char c = state == HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_FOUND_LF ? LF : get(input); + if (c != LF) { + throw protocolException("Bad trailing char, \"%s\", when parsing status line, \"%s\"", + c, sb.toString()); + } + requestOrStatusLine = sb.toString(); + sb = new StringBuilder(); + if (!requestOrStatusLine.startsWith("HTTP/1.")) { + if(!requestOrStatusLine.startsWith("GET") && !requestOrStatusLine.startsWith("POST") && + !requestOrStatusLine.startsWith("PUT") && !requestOrStatusLine.startsWith("DELETE") && + !requestOrStatusLine.startsWith("OPTIONS") && !requestOrStatusLine.startsWith("HEAD") && + !requestOrStatusLine.startsWith("PATCH") && !requestOrStatusLine.startsWith("CONNECT")) { + throw protocolException("Invalid request Or Status line: \"%s\"", requestOrStatusLine); + } else { //This is request + System.out.println("Request is :"+requestOrStatusLine); + } + } else { //This is response + if (requestOrStatusLine.length() < 12) { + throw protocolException("Invalid status line: \"%s\"", requestOrStatusLine); + } + try { + responseCode = Integer.parseInt(requestOrStatusLine.substring(9, 12)); + } catch (NumberFormatException nfe) { + throw protocolException("Invalid status line: \"%s\"", requestOrStatusLine); + } + // response code expected to be a 3-digit integer (RFC-2616, section 6.1.1) + if (responseCode < 100) { + throw protocolException("Invalid status line: \"%s\"", requestOrStatusLine); + } + } + state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END; + } + + private void maybeStartHeaders(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END; + assert sb.length() == 0; + char c = get(input); + if(!eof) { + if (c == CR) { + state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END_CR; + } else if (c == LF) { + state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END_LF; + } else { + sb.append(c); + state = HttpHeaderParser.State.HEADER; + } + } + } + + private void maybeEndHeaders(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END_CR || state == HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END_LF; + assert sb.length() == 0; + char c = state == HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END_LF ? LF : get(input); + if (c == LF) { + state = HttpHeaderParser.State.FINISHED; // no headers + } else { + throw protocolException("Unexpected \"%s\", after status line CR", c); + } + } + + private void readResumeHeader(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.HEADER; + assert !eof; + char c = get(input); + while (!eof) { + if (c == CR) { + state = HttpHeaderParser.State.HEADER_FOUND_CR; + break; + } else if (c == LF) { + state = HttpHeaderParser.State.HEADER_FOUND_LF; + break; + } + if (c == HT) + c = SP; + sb.append(c); + c = get(input); + } + } + + private void addHeaderFromString(String headerString) throws ProtocolException { + assert sb.length() == 0; + int idx = headerString.indexOf(':'); + if (idx == -1) + return; + String name = headerString.substring(0, idx); + + // compatibility with HttpURLConnection; + if (name.isEmpty()) return; + + if (!isValidName(name)) { + throw protocolException("Invalid header name \"%s\"", name); + } + String value = headerString.substring(idx + 1).trim(); + if (!isValidValue(value)) { + throw protocolException("Invalid header value \"%s: %s\"", name, value); + } + + keyList.add(name); + headerMap.computeIfAbsent(name.toLowerCase(Locale.US), + k -> new ArrayList<>()).add(value); + } + + private void resumeOrLF(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.HEADER_FOUND_CR || state == HttpHeaderParser.State.HEADER_FOUND_LF; + char c = state == HttpHeaderParser.State.HEADER_FOUND_LF ? LF : get(input); + if (!eof) { + if (c == LF) { + state = HttpHeaderParser.State.HEADER_FOUND_CR_LF; + } else if (c == SP || c == HT) { + sb.append(SP); // parity with MessageHeaders + state = HttpHeaderParser.State.HEADER; + } else { + sb = new StringBuilder(); + sb.append(c); + state = HttpHeaderParser.State.HEADER; + } + } + } + + private void resumeOrSecondCR(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.HEADER_FOUND_CR_LF; + char c = get(input); + if (!eof) { + if (c == CR || c == LF) { + if (sb.length() > 0) { + // no continuation line - flush + // previous header value. + String headerString = sb.toString(); + sb = new StringBuilder(); + addHeaderFromString(headerString); + } + if (c == CR) { + state = HttpHeaderParser.State.HEADER_FOUND_CR_LF_CR; + } else { + state = HttpHeaderParser.State.FINISHED; + } + } else if (c == SP || c == HT) { + assert sb.length() != 0; + sb.append(SP); // continuation line + state = HttpHeaderParser.State.HEADER; + } else { + if (sb.length() > 0) { + // no continuation line - flush + // previous header value. + String headerString = sb.toString(); + sb = new StringBuilder(); + addHeaderFromString(headerString); + } + sb.append(c); + state = HttpHeaderParser.State.HEADER; + } + } + } + + private void resumeOrEndHeaders(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.HEADER_FOUND_CR_LF_CR; + char c = get(input); + if (!eof) { + if (c == LF) { + state = HttpHeaderParser.State.FINISHED; + } else { + throw protocolException("Unexpected \"%s\", after CR LF CR", c); + } + } + } + + private ProtocolException protocolException(String format, Object ... args) { + return new ProtocolException(String.format(format, args)); + } + + /* + * Validates a RFC 7230 field-name. + */ + public boolean isValidName(String token) { + for (int i = 0; i < token.length(); i++) { + char c = token.charAt(i); + if (c > 255 || !tchar[c]) { + return false; + } + } + return !token.isEmpty(); + } + + /* + * Validates a RFC 7230 field-value. + * + * "Obsolete line folding" rule + * + * obs-fold = CRLF 1*( SP / HTAB ) + * + * is not permitted! + */ + public boolean isValidValue(String token) { + for (int i = 0; i < token.length(); i++) { + char c = token.charAt(i); + if (c > 255) { + return false; + } + if (c == ' ' || c == '\t') { + continue; + } else if (!fieldvchar[c]) { + return false; // forbidden byte + } + } + return true; + } +} From d2045f9cfa88cb8bea58e5476f5917464f966028 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 20 Sep 2023 07:16:52 +0000 Subject: [PATCH 107/341] 8265586: [windows] last button is not shown in AWT Frame with BorderLayout and MenuBar set. 8288993: Make AwtFramePackTest generic by removing @requires tag Backport-of: bbaeacb597a8acc2c88793a6231c53ea0453f4d4 --- .../native/libawt/windows/awt_Window.cpp | 14 +-- test/jdk/java/awt/Frame/AwtFramePackTest.java | 100 ++++++++++++++++++ 2 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 test/jdk/java/awt/Frame/AwtFramePackTest.java diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp b/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp index dbca3d778c8b7..7b80a13deb7c1 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp @@ -24,7 +24,6 @@ */ #include "awt.h" - #include #include "awt_Component.h" @@ -1396,6 +1395,9 @@ BOOL AwtWindow::UpdateInsets(jobject insets) RECT inside; int extraBottomInsets = 0; + // extra padded border for captioned windows + int extraPaddedBorderInsets = ::GetSystemMetrics(SM_CXPADDEDBORDER); + ::GetClientRect(GetHWnd(), &inside); ::GetWindowRect(GetHWnd(), &outside); @@ -1419,17 +1421,15 @@ BOOL AwtWindow::UpdateInsets(jobject insets) LONG style = GetStyle(); if (style & WS_THICKFRAME) { m_insets.left = m_insets.right = - ::GetSystemMetrics(SM_CXSIZEFRAME); + ::GetSystemMetrics(SM_CXSIZEFRAME) + extraPaddedBorderInsets; m_insets.top = m_insets.bottom = - ::GetSystemMetrics(SM_CYSIZEFRAME); + ::GetSystemMetrics(SM_CYSIZEFRAME) + extraPaddedBorderInsets; } else { m_insets.left = m_insets.right = - ::GetSystemMetrics(SM_CXDLGFRAME); + ::GetSystemMetrics(SM_CXDLGFRAME) + extraPaddedBorderInsets; m_insets.top = m_insets.bottom = - ::GetSystemMetrics(SM_CYDLGFRAME); + ::GetSystemMetrics(SM_CYDLGFRAME) + extraPaddedBorderInsets; } - - /* Add in title. */ m_insets.top += ::GetSystemMetrics(SM_CYCAPTION); } diff --git a/test/jdk/java/awt/Frame/AwtFramePackTest.java b/test/jdk/java/awt/Frame/AwtFramePackTest.java new file mode 100644 index 0000000000000..54fd330f3e424 --- /dev/null +++ b/test/jdk/java/awt/Frame/AwtFramePackTest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuBar; +import java.awt.Panel; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; + +/* + * @test + * @bug 8265586 + * @key headful + * @summary Tests whether insets are calculated correctly on Windows + * for AWT Frame by checking the actual and expected/preferred frame sizes. + * @run main AwtFramePackTest + */ + +public class AwtFramePackTest { + + private static Frame frame; + private static Robot robot; + + public static void main(String[] args) throws AWTException { + try { + robot = new Robot(); + robot.setAutoDelay(300); + + frame = new Frame(); + frame.setLayout(new BorderLayout()); + + Panel panel = new Panel(); + panel.add(new Button("Panel Button B1")); + panel.add(new Button("Panel Button B2")); + frame.add(panel, BorderLayout.CENTER); + + MenuBar mb = new MenuBar(); + Menu m = new Menu("Menu"); + mb.add(m); + frame.setMenuBar(mb); + + frame.pack(); + frame.setVisible(true); + + robot.delay(500); + robot.waitForIdle(); + + Dimension actualFrameSize = frame.getSize(); + Dimension expectedFrameSize = frame.getPreferredSize(); + + if (!actualFrameSize.equals(expectedFrameSize)) { + System.out.println("Expected frame size: "+ expectedFrameSize); + System.out.println("Actual frame size: "+ actualFrameSize); + saveScreenCapture(); + throw new RuntimeException("Expected and Actual frame size" + + " are different. frame.pack() does not work!!"); + } + } finally { + frame.dispose(); + } + } + + // for debugging purpose, saves screen capture when test fails. + private static void saveScreenCapture() { + BufferedImage image = robot.createScreenCapture(frame.getBounds()); + try { + ImageIO.write(image,"png", new File("Frame.png")); + } catch (IOException e) { + e.printStackTrace(); + } + } +} From a3e80262e2c9fdb7043de4786cb101c4f476b8e5 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 20 Sep 2023 07:19:18 +0000 Subject: [PATCH 108/341] 8294427: Check boxes and radio buttons have rendering issues on Windows in High DPI env Reviewed-by: phh Backport-of: a63afa4aa62863d1a199a0fb7d2f56ff8fcd04fd --- .../classes/sun/swing/CachedPainter.java | 7 +- .../sun/java/swing/plaf/windows/TMSchema.java | 15 +- .../sun/java/swing/plaf/windows/XPStyle.java | 57 ++++++-- .../classes/sun/awt/windows/ThemeReader.java | 128 ++++++++++++------ .../native/libawt/windows/ThemeReader.cpp | 53 +++----- 5 files changed, 162 insertions(+), 98 deletions(-) diff --git a/src/java.desktop/share/classes/sun/swing/CachedPainter.java b/src/java.desktop/share/classes/sun/swing/CachedPainter.java index 49d0bd6346735..9bc10efb83ef2 100644 --- a/src/java.desktop/share/classes/sun/swing/CachedPainter.java +++ b/src/java.desktop/share/classes/sun/swing/CachedPainter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2017, 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 @@ -314,8 +314,9 @@ public int getHeight(ImageObserver observer) { @Override public Image getResolutionVariant(double destWidth, double destHeight) { - int w = (int) Math.ceil(destWidth); - int h = (int) Math.ceil(destHeight); + int w = (int) Math.floor(destWidth + 0.5); + int h = (int) Math.floor(destHeight + 0.5); + return getImage(PainterMultiResolutionCachedImage.class, c, baseWidth, baseHeight, w, h, args); } diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/TMSchema.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/TMSchema.java index f45a077e91d3e..342ee913255f7 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/TMSchema.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/TMSchema.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, 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 @@ -40,10 +40,13 @@ package com.sun.java.swing.plaf.windows; -import java.awt.*; -import java.util.*; - -import javax.swing.*; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; +import java.awt.Point; +import java.util.EnumMap; +import javax.swing.JComponent; import sun.awt.windows.ThemeReader; @@ -55,7 +58,7 @@ * * @author Leif Samuelsson */ -class TMSchema { +public final class TMSchema { /** * An enumeration of the various Windows controls (also known as diff --git a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java index 45fc54c07a64d..5d80f732e2f66 100644 --- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java +++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/XPStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2021, 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 @@ -40,14 +40,41 @@ package com.sun.java.swing.plaf.windows; -import java.awt.*; -import java.awt.image.*; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.Image; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.awt.image.WritableRaster; import java.security.AccessController; -import java.util.*; - -import javax.swing.*; -import javax.swing.border.*; -import javax.swing.plaf.*; +import java.util.HashMap; + +import javax.swing.AbstractButton; +import javax.swing.CellRendererPane; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JRadioButton; +import javax.swing.JToolBar; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.border.AbstractBorder; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; +import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.InsetsUIResource; +import javax.swing.plaf.UIResource; import javax.swing.text.JTextComponent; import sun.awt.image.SunWritableRaster; @@ -55,8 +82,10 @@ import sun.security.action.GetPropertyAction; import sun.swing.CachedPainter; -import static com.sun.java.swing.plaf.windows.TMSchema.*; - +import static com.sun.java.swing.plaf.windows.TMSchema.Part; +import static com.sun.java.swing.plaf.windows.TMSchema.Prop; +import static com.sun.java.swing.plaf.windows.TMSchema.State; +import static com.sun.java.swing.plaf.windows.TMSchema.TypeEnum; /** * Implements Windows XP Styles for the Windows Look and Feel. @@ -675,6 +704,11 @@ protected void paintToImage(Component c, Image image, Graphics g, w = bi.getWidth(); h = bi.getHeight(); + // Get DPI to pass further to ThemeReader.paintBackground() + Graphics2D g2d = (Graphics2D) g; + AffineTransform at = g2d.getTransform(); + int dpi = (int)(at.getScaleX() * 96); + WritableRaster raster = bi.getRaster(); DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer(); // Note that stealData() requires a markDirty() afterwards @@ -682,7 +716,8 @@ protected void paintToImage(Component c, Image image, Graphics g, ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0), part.getControlName(c), part.getValue(), State.getValue(part, state), - 0, 0, w, h, w); + 0, 0, w, h, w, dpi); + SunWritableRaster.markDirty(dbi); } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java b/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java index 482a92fd885d4..e33deb5b46702 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2020, 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 @@ -30,11 +30,14 @@ import java.awt.Insets; import java.awt.Point; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import static com.sun.java.swing.plaf.windows.TMSchema.Part; + /** * Implements Theme Support for Windows XP. * @@ -44,7 +47,24 @@ */ public final class ThemeReader { - private static final Map widgetToTheme = new HashMap<>(); + private static final int defaultDPI = 96; + + /** + * List of widgets for which we need to get the part size for the current DPI. + */ + private static final List partSizeWidgets = + List.of("MENU", "BUTTON"); + + /** + * List of widget parts for which we need to get the part size for the current DPI. + */ + private static final List partSizeWidgetParts = + List.of(Part.BP_RADIOBUTTON.getValue(), + Part.BP_CHECKBOX.getValue(), + Part.MP_POPUPCHECK.getValue()); + + private static final Map> dpiAwareWidgetToTheme + = new HashMap<>(); // lock for the cache // reading should be done with readLock @@ -80,28 +100,30 @@ public static boolean isXPStyleEnabled() { return xpStyleEnabled; } + private static Long openThemeImpl(String widget, int dpi) { + Long theme; + int i = widget.indexOf("::"); + if (i > 0) { + // We're using the syntax "subAppName::controlName" here, as used by msstyles. + // See documentation for SetWindowTheme on MSDN. + setWindowTheme(widget.substring(0, i)); + theme = openTheme(widget.substring(i + 2), dpi); + setWindowTheme(null); + } else { + theme = openTheme(widget, dpi); + } + return theme; + } + // this should be called only with writeLock held - private static Long getThemeImpl(String widget) { - Long theme = widgetToTheme.get(widget); - if (theme == null) { - int i = widget.indexOf("::"); - if (i > 0) { - // We're using the syntax "subAppName::controlName" here, as used by msstyles. - // See documentation for SetWindowTheme on MSDN. - setWindowTheme(widget.substring(0, i)); - theme = openTheme(widget.substring(i+2)); - setWindowTheme(null); - } else { - theme = openTheme(widget); - } - widgetToTheme.put(widget, theme); - } - return theme; + private static Long getThemeImpl(String widget, int dpi) { + return dpiAwareWidgetToTheme.computeIfAbsent(dpi, key -> new HashMap<>()) + .computeIfAbsent(widget, w -> openThemeImpl(widget, dpi)); } // returns theme value // this method should be invoked with readLock locked - private static Long getTheme(String widget) { + private static Long getTheme(String widget, int dpi) { if (!isThemed) { throw new IllegalStateException("Themes are not loaded"); } @@ -111,10 +133,12 @@ private static Long getTheme(String widget) { try { if (!valid) { // Close old themes. - for (Long value : widgetToTheme.values()) { - closeTheme(value); + for (Map dpiVal : dpiAwareWidgetToTheme.values()) { + for (Long value : dpiVal.values()) { + closeTheme(value); + } } - widgetToTheme.clear(); + dpiAwareWidgetToTheme.clear(); valid = true; } } finally { @@ -123,13 +147,20 @@ private static Long getTheme(String widget) { } } + Long theme = null; + + Map widgetToTheme = dpiAwareWidgetToTheme.get(dpi); + + if (widgetToTheme != null) { + theme = widgetToTheme.get(widget); + } + // mostly copied from the javadoc for ReentrantReadWriteLock - Long theme = widgetToTheme.get(widget); if (theme == null) { readLock.unlock(); writeLock.lock(); try { - theme = getThemeImpl(widget); + theme = getThemeImpl(widget, dpi); } finally { readLock.lock(); writeLock.unlock();// Unlock write, still hold read @@ -139,14 +170,23 @@ private static Long getTheme(String widget) { } private static native void paintBackground(int[] buffer, long theme, - int part, int state, int x, - int y, int w, int h, int stride); + int part, int state, + int rectRight, int rectBottom, + int w, int h, int stride); public static void paintBackground(int[] buffer, String widget, - int part, int state, int x, int y, int w, int h, int stride) { + int part, int state, int x, int y, int w, int h, int stride, int dpi) { readLock.lock(); try { - paintBackground(buffer, getTheme(widget), part, state, x, y, w, h, stride); + /* For widgets and parts in the lists, we get the part size + for the current screen DPI to scale them better. */ + Dimension d = (partSizeWidgets.contains(widget) + && partSizeWidgetParts.contains(Integer.valueOf(part))) + ? getPartSize(getTheme(widget, dpi), part, state) + : new Dimension(w, h); + + paintBackground(buffer, getTheme(widget, dpi), part, state, + d.width, d.height, w, h, stride); } finally { readLock.unlock(); } @@ -158,7 +198,7 @@ private static native Insets getThemeMargins(long theme, int part, public static Insets getThemeMargins(String widget, int part, int state, int marginType) { readLock.lock(); try { - return getThemeMargins(getTheme(widget), part, state, marginType); + return getThemeMargins(getTheme(widget, defaultDPI), part, state, marginType); } finally { readLock.unlock(); } @@ -169,7 +209,7 @@ public static Insets getThemeMargins(String widget, int part, int state, int mar public static boolean isThemePartDefined(String widget, int part, int state) { readLock.lock(); try { - return isThemePartDefined(getTheme(widget), part, state); + return isThemePartDefined(getTheme(widget, defaultDPI), part, state); } finally { readLock.unlock(); } @@ -181,7 +221,7 @@ private static native Color getColor(long theme, int part, int state, public static Color getColor(String widget, int part, int state, int property) { readLock.lock(); try { - return getColor(getTheme(widget), part, state, property); + return getColor(getTheme(widget, defaultDPI), part, state, property); } finally { readLock.unlock(); } @@ -193,7 +233,7 @@ private static native int getInt(long theme, int part, int state, public static int getInt(String widget, int part, int state, int property) { readLock.lock(); try { - return getInt(getTheme(widget), part, state, property); + return getInt(getTheme(widget, defaultDPI), part, state, property); } finally { readLock.unlock(); } @@ -205,7 +245,7 @@ private static native int getEnum(long theme, int part, int state, public static int getEnum(String widget, int part, int state, int property) { readLock.lock(); try { - return getEnum(getTheme(widget), part, state, property); + return getEnum(getTheme(widget, defaultDPI), part, state, property); } finally { readLock.unlock(); } @@ -218,7 +258,7 @@ public static boolean getBoolean(String widget, int part, int state, int property) { readLock.lock(); try { - return getBoolean(getTheme(widget), part, state, property); + return getBoolean(getTheme(widget, defaultDPI), part, state, property); } finally { readLock.unlock(); } @@ -229,7 +269,7 @@ public static boolean getBoolean(String widget, int part, int state, public static boolean getSysBoolean(String widget, int property) { readLock.lock(); try { - return getSysBoolean(getTheme(widget), property); + return getSysBoolean(getTheme(widget, defaultDPI), property); } finally { readLock.unlock(); } @@ -241,7 +281,7 @@ private static native Point getPoint(long theme, int part, int state, public static Point getPoint(String widget, int part, int state, int property) { readLock.lock(); try { - return getPoint(getTheme(widget), part, state, property); + return getPoint(getTheme(widget, defaultDPI), part, state, property); } finally { readLock.unlock(); } @@ -254,7 +294,7 @@ public static Dimension getPosition(String widget, int part, int state, int property) { readLock.lock(); try { - return getPosition(getTheme(widget), part,state,property); + return getPosition(getTheme(widget, defaultDPI), part,state,property); } finally { readLock.unlock(); } @@ -266,13 +306,13 @@ private static native Dimension getPartSize(long theme, int part, public static Dimension getPartSize(String widget, int part, int state) { readLock.lock(); try { - return getPartSize(getTheme(widget), part, state); + return getPartSize(getTheme(widget, defaultDPI), part, state); } finally { readLock.unlock(); } } - private static native long openTheme(String widget); + private static native long openTheme(String widget, int dpi); private static native void closeTheme(long theme); @@ -285,8 +325,9 @@ public static long getThemeTransitionDuration(String widget, int part, int stateFrom, int stateTo, int propId) { readLock.lock(); try { - return getThemeTransitionDuration(getTheme(widget), - part, stateFrom, stateTo, propId); + return getThemeTransitionDuration(getTheme(widget, defaultDPI), + part, stateFrom, stateTo, + propId); } finally { readLock.unlock(); } @@ -299,8 +340,9 @@ public static Insets getThemeBackgroundContentMargins(String widget, int part, int state, int boundingWidth, int boundingHeight) { readLock.lock(); try { - return getThemeBackgroundContentMargins(getTheme(widget), - part, state, boundingWidth, boundingHeight); + return getThemeBackgroundContentMargins(getTheme(widget, defaultDPI), + part, state, + boundingWidth, boundingHeight); } finally { readLock.unlock(); } diff --git a/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp b/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp index d6b122cf3ea2d..4a32b8e5b894a 100644 --- a/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp +++ b/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp @@ -52,7 +52,7 @@ typedef HRESULT(__stdcall *PFNCLOSETHEMEDATA)(HTHEME hTheme); typedef HRESULT(__stdcall *PFNDRAWTHEMEBACKGROUND)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect); -typedef HTHEME(__stdcall *PFNOPENTHEMEDATA)(HWND hwnd, LPCWSTR pszClassList); +typedef HTHEME(__stdcall *PFNOPENTHEMEDATAFORDPI)(HWND hwnd, LPCWSTR pszClassList, UINT dpi); typedef HRESULT (__stdcall *PFNDRAWTHEMETEXT)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, @@ -96,7 +96,7 @@ typedef HRESULT (__stdcall *PFNGETTHEMETRANSITIONDURATION) (HTHEME hTheme, int iPartId, int iStateIdFrom, int iStateIdTo, int iPropId, DWORD *pdwDuration); -static PFNOPENTHEMEDATA OpenThemeDataFunc = NULL; +static PFNOPENTHEMEDATAFORDPI OpenThemeDataForDpiFunc = NULL; static PFNDRAWTHEMEBACKGROUND DrawThemeBackgroundFunc = NULL; static PFNCLOSETHEMEDATA CloseThemeDataFunc = NULL; static PFNDRAWTHEMETEXT DrawThemeTextFunc = NULL; @@ -122,8 +122,8 @@ BOOL InitThemes() { DTRACE_PRINTLN1("InitThemes hModThemes = %x\n", hModThemes); if(hModThemes) { DTRACE_PRINTLN("Loaded UxTheme.dll\n"); - OpenThemeDataFunc = (PFNOPENTHEMEDATA)GetProcAddress(hModThemes, - "OpenThemeData"); + OpenThemeDataForDpiFunc = (PFNOPENTHEMEDATAFORDPI)GetProcAddress( + hModThemes, "OpenThemeDataForDpi"); DrawThemeBackgroundFunc = (PFNDRAWTHEMEBACKGROUND)GetProcAddress( hModThemes, "DrawThemeBackground"); CloseThemeDataFunc = (PFNCLOSETHEMEDATA)GetProcAddress( @@ -158,7 +158,7 @@ BOOL InitThemes() { (PFNGETTHEMETRANSITIONDURATION)GetProcAddress(hModThemes, "GetThemeTransitionDuration"); - if(OpenThemeDataFunc + if(OpenThemeDataForDpiFunc && DrawThemeBackgroundFunc && CloseThemeDataFunc && DrawThemeTextFunc @@ -177,9 +177,12 @@ BOOL InitThemes() { && GetThemeTransitionDurationFunc ) { DTRACE_PRINTLN("Loaded function pointers.\n"); - // We need to make sure we can load the Theme. This may not be - // the case on a WinXP machine with classic mode enabled. - HTHEME hTheme = OpenThemeDataFunc(AwtToolkit::GetInstance().GetHWnd(), L"Button"); + // We need to make sure we can load the Theme. + // Use the default DPI value of 96 on windows. + constexpr unsigned int defaultDPI = 96; + HTHEME hTheme = OpenThemeDataForDpiFunc ( + AwtToolkit::GetInstance().GetHWnd(), + L"Button", defaultDPI); if(hTheme) { DTRACE_PRINTLN("Loaded Theme data.\n"); CloseThemeDataFunc(hTheme); @@ -242,7 +245,7 @@ static void assert_result(HRESULT hres, JNIEnv *env) { * Signature: (Ljava/lang/String;)J */ JNIEXPORT jlong JNICALL Java_sun_awt_windows_ThemeReader_openTheme -(JNIEnv *env, jclass klass, jstring widget) { +(JNIEnv *env, jclass klass, jstring widget, jint dpi) { LPCTSTR str = (LPCTSTR) JNU_GetStringPlatformChars(env, widget, NULL); if (str == NULL) { @@ -251,7 +254,9 @@ JNIEXPORT jlong JNICALL Java_sun_awt_windows_ThemeReader_openTheme } // We need to open the Theme on a Window that will stick around. // The best one for that purpose is the Toolkit window. - HTHEME htheme = OpenThemeDataFunc(AwtToolkit::GetInstance().GetHWnd(), str); + HTHEME htheme = OpenThemeDataForDpiFunc( + AwtToolkit::GetInstance().GetHWnd(), + str, dpi); JNU_ReleaseStringPlatformChars(env, widget, str); return (jlong) htheme; } @@ -384,7 +389,7 @@ static void copyDIBToBufferedImage(int *pDstBits, int *pSrcBits, */ JNIEXPORT void JNICALL Java_sun_awt_windows_ThemeReader_paintBackground (JNIEnv *env, jclass klass, jintArray array, jlong theme, jint part, jint state, - jint x, jint y, jint w, jint h, jint stride) { + jint rectRight, jint rectBottom, jint w, jint h, jint stride) { int *pDstBits=NULL; int *pSrcBits=NULL; @@ -430,8 +435,8 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_ThemeReader_paintBackground rect.left = 0; rect.top = 0; - rect.bottom = h; - rect.right = w; + rect.bottom = rectBottom; + rect.right = rectRight; ZeroMemory(pSrcBits,(BITS_PER_PIXEL>>3)*w*h); @@ -720,27 +725,6 @@ JNIEXPORT jobject JNICALL Java_sun_awt_windows_ThemeReader_getPosition return NULL; } -void rescale(SIZE *size) { - static int dpiX = -1; - static int dpiY = -1; - if (dpiX == -1 || dpiY == -1) { - HWND hWnd = ::GetDesktopWindow(); - HDC hDC = ::GetDC(hWnd); - dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX); - dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY); - ::ReleaseDC(hWnd, hDC); - } - - if (dpiX !=0 && dpiX != 96) { - float invScaleX = 96.0f / dpiX; - size->cx = ROUND_TO_INT(size->cx * invScaleX); - } - if (dpiY != 0 && dpiY != 96) { - float invScaleY = 96.0f / dpiY; - size->cy = ROUND_TO_INT(size->cy * invScaleY); - } -} - /* * Class: sun_awt_windows_ThemeReader * Method: getPartSize @@ -767,7 +751,6 @@ JNIEXPORT jobject JNICALL Java_sun_awt_windows_ThemeReader_getPartSize CHECK_NULL_RETURN(dimMID, NULL); } - rescale(&size); jobject dimObj = env->NewObject(dimClassID, dimMID, size.cx, size.cy); if (safe_ExceptionOccurred(env)) { env->ExceptionDescribe(); From 7588666d39c97de5514b78d1371c28b321906560 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 20 Sep 2023 07:22:13 +0000 Subject: [PATCH 109/341] 8313657: com.sun.jndi.ldap.Connection.cleanup does not close connections on SocketTimeoutErrors Backport-of: e56d3bc2dab3d32453b6eda66e8434953c436084 --- .../classes/com/sun/jndi/ldap/Connection.java | 53 +++++- .../com/sun/jndi/ldap/SocketCloseTest.java | 168 ++++++++++++++++++ 2 files changed, 212 insertions(+), 9 deletions(-) create mode 100644 test/jdk/com/sun/jndi/ldap/SocketCloseTest.java diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java index d8de2ddbb1e1f..ebb21bd8b759f 100644 --- a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java +++ b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, 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 @@ -639,14 +639,12 @@ void cleanup(Control[] reqCtls, boolean notifyParent) { ldapUnbind(reqCtls); } } finally { - try { - outStream.flush(); - sock.close(); - unpauseReader(); - } catch (IOException ie) { - if (debug) - System.err.println("Connection: problem closing socket: " + ie); - } + + flushAndCloseOutputStream(); + // 8313657 socket is not closed until GC is run + closeOpenedSocket(); + tryUnpauseReader(); + if (!notifyParent) { LdapRequest ldr = pendingRequests; while (ldr != null) { @@ -680,6 +678,43 @@ void cleanup(Control[] reqCtls, boolean notifyParent) { } } + // flush and close output stream + private void flushAndCloseOutputStream() { + try { + outStream.flush(); + } catch (IOException ioEx) { + if (debug) + System.err.println("Connection.flushOutputStream: OutputStream flush problem " + ioEx); + } + try { + outStream.close(); + } catch (IOException ioEx) { + if (debug) + System.err.println("Connection.closeOutputStream: OutputStream close problem " + ioEx); + } + } + + // close socket + private void closeOpenedSocket() { + try { + sock.close(); + } catch (IOException ioEx) { + if (debug) { + System.err.println("Connection.closeConnectionSocket: Socket close problem: " + ioEx); + System.err.println("Socket isClosed: " + sock.isClosed()); + } + } + } + + // unpause reader + private void tryUnpauseReader() { + try { + unpauseReader(); + } catch (IOException ioEx) { + if (debug) + System.err.println("Connection.tryUnpauseReader: unpauseReader problem " + ioEx); + } + } // Assume everything is "quiet" // "synchronize" might lead to deadlock so don't synchronize method diff --git a/test/jdk/com/sun/jndi/ldap/SocketCloseTest.java b/test/jdk/com/sun/jndi/ldap/SocketCloseTest.java new file mode 100644 index 0000000000000..a33beb6caccb5 --- /dev/null +++ b/test/jdk/com/sun/jndi/ldap/SocketCloseTest.java @@ -0,0 +1,168 @@ +/* + * 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 javax.naming.Context; +import javax.naming.directory.DirContext; +import javax.naming.directory.InitialDirContext; +import javax.net.SocketFactory; +import java.net.InetAddress; +import java.net.Socket; +import java.net.SocketAddress; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Hashtable; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +/* + * @test + * @bug 8313657 + * @summary make sure socket is closed when the error happens for OutputStream flushing + * The value of provider url can be random, not necessary to be the one in the code + * @library /test/lib + * @run main/othervm SocketCloseTest + */ + +public class SocketCloseTest { + public static String SOCKET_CLOSED_MSG = "The socket has been closed."; + public static String SOCKET_NOT_CLOSED_MSG = "The socket was not closed."; + public static String BAD_FLUSH = "Bad flush!"; + private static final byte[] BIND_RESPONSE = new byte[]{ + 48, 12, 2, 1, 1, 97, 7, 10, 1, 0, 4, 0, 4, 0 + }; + + public static void main(String[] args) throws Exception { + SocketCloseTest scTest = new SocketCloseTest(); + scTest.runCloseSocketScenario(); + } + + public void runCloseSocketScenario() throws Exception { + Hashtable props = new Hashtable<>(); + + props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + props.put(Context.PROVIDER_URL, "ldap://localhost:1389/o=example"); + props.put("java.naming.ldap.factory.socket", CustomSocketFactory.class.getName()); + try { + final DirContext ctx = new InitialDirContext(props); + } catch (Exception e) { + if (CustomSocketFactory.customSocket.closeMethodCalledCount() > 0) { + System.out.println(SOCKET_CLOSED_MSG); + } else { + System.out.println(SOCKET_NOT_CLOSED_MSG); + throw e; + } + } + } + + public static class CustomSocketFactory extends SocketFactory { + public static CustomSocket customSocket = new CustomSocket(); + + public static CustomSocketFactory getDefault() { + return new CustomSocketFactory(); + } + + @Override + public Socket createSocket() { + return customSocket; + } + + @Override + public Socket createSocket(String s, int timeout) { + return customSocket; + } + + @Override + public Socket createSocket(String host, int port, InetAddress localHost, + int localPort) { + return customSocket; + } + + @Override + public Socket createSocket(InetAddress host, int port) { + return customSocket; + } + + @Override + public Socket createSocket(InetAddress address, int port, + InetAddress localAddress, int localPort) { + return customSocket; + } + } + + private static class LdapInputStream extends InputStream { + private ByteArrayInputStream bos; + + public LdapInputStream() { + } + + @Override + public int read() throws IOException { + bos = new ByteArrayInputStream(BIND_RESPONSE); + return bos.read(); + } + } + + private static class LdapOutputStream extends OutputStream { + + @Override + public void write(int b) throws IOException { + System.out.println("output stream writing"); + } + + @Override + public void flush() throws IOException { + System.out.println(BAD_FLUSH); + throw new IOException(BAD_FLUSH); + } + } + + private static class CustomSocket extends Socket { + private int closeMethodCalled = 0; + private LdapOutputStream output = new LdapOutputStream(); + private LdapInputStream input = new LdapInputStream(); + + public void connect(SocketAddress address, int timeout) { + } + + public InputStream getInputStream() { + return input; + } + + public OutputStream getOutputStream() { + return output; + } + + public int closeMethodCalledCount() { + return closeMethodCalled; + } + + @Override + public void close() throws IOException { + closeMethodCalled++; + super.close(); + } + } +} From 1a68e525f4f1e91634a1c387be1027e971e33649 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 20 Sep 2023 07:24:26 +0000 Subject: [PATCH 110/341] 8314679: SA fails to properly attach to JVM after having just detached from a different JVM Reviewed-by: phh Backport-of: 38a9edfb7ee2d91ff52074137c5b69e27bcdbdc3 --- .../sun/jvm/hotspot/memory/FileMapInfo.java | 2 + .../sa/ClhsdbAttachDifferentJVMs.java | 91 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/FileMapInfo.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/FileMapInfo.java index 79961fd261b52..1055758b71ea6 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/FileMapInfo.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/FileMapInfo.java @@ -83,6 +83,8 @@ static Address get_CDSFileMapRegion(Type FileMapHeader_type, Address header, int } private static void initialize(TypeDataBase db) { + vTableTypeMap = null; // force vTableTypeMap to get re-initialized later + Type FileMapInfo_type = db.lookupType("FileMapInfo"); Type FileMapHeader_type = db.lookupType("FileMapHeader"); Type CDSFileMapRegion_type = db.lookupType("CDSFileMapRegion"); diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java new file mode 100644 index 0000000000000..1ed59b664299b --- /dev/null +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbAttachDifferentJVMs.java @@ -0,0 +1,91 @@ +/* + * 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 java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.test.lib.apps.LingeredApp; +import jtreg.SkippedException; + +/** + * @test + * @bug 8314679 + * @summary Test clhsdb attach, detach, and then attach to different JVM + * @requires vm.hasSA + * @library /test/lib + * @run main/othervm ClhsdbAttachDifferentJVMs + */ + +public class ClhsdbAttachDifferentJVMs { + + public static void main(String[] args) throws Exception { + System.out.println("Starting ClhsdbAttach test"); + + LingeredApp theApp1 = null; + LingeredApp theApp2 = null; + try { + ClhsdbLauncher test = new ClhsdbLauncher(); + theApp1 = LingeredApp.startApp(); + System.out.println("Started LingeredApp with pid " + theApp1.getPid()); + theApp2 = LingeredApp.startApp(); + System.out.println("Started LingeredApp with pid " + theApp2.getPid()); + String attach1 = "attach " + theApp1.getPid(); + String attach2 = "attach " + theApp2.getPid(); + + List cmds = List.of( + "where", + attach1, + "threads", + "detach", + attach2, + "jstack"); + + Map> expStrMap = new HashMap<>(); + expStrMap.put("where", List.of( + "Command not valid until attached to a VM")); + expStrMap.put(attach1, List.of( + "Attaching to process " + theApp1.getPid())); + expStrMap.put("threads", List.of( + "Reference Handler")); + expStrMap.put(attach2, List.of( + "Attaching to process " + theApp2.getPid())); + expStrMap.put("jstack", List.of( + "Reference Handler")); + + Map> unexpStrMap = new HashMap<>(); + unexpStrMap.put("jstack", List.of( + "WARNING")); + + test.run(-1, cmds, expStrMap, unexpStrMap); + } catch (SkippedException se) { + throw se; + } catch (Exception ex) { + throw new RuntimeException("Test ERROR " + ex, ex); + } finally { + LingeredApp.stopApp(theApp1); + LingeredApp.stopApp(theApp2); + } + System.out.println("Test PASSED"); + } +} From a06047acce82f60b5ca193a7b2aa329ed24b46f4 Mon Sep 17 00:00:00 2001 From: Sergey Chernyshev Date: Wed, 20 Sep 2023 10:24:15 +0000 Subject: [PATCH 111/341] 8168469: Memory leak in JceSecurity Backport-of: a284920b3432b00496a2a32a284a91a9bd49fb06 --- .../javax/crypto/JceSecurity.java.template | 71 ++++++++++++------- .../JceSecurity/VerificationResults.java | 59 +++++++++++++++ 2 files changed, 103 insertions(+), 27 deletions(-) create mode 100644 test/jdk/javax/crypto/JceSecurity/VerificationResults.java diff --git a/src/java.base/share/classes/javax/crypto/JceSecurity.java.template b/src/java.base/share/classes/javax/crypto/JceSecurity.java.template index 7a344e8e30665..bcdff388123aa 100644 --- a/src/java.base/share/classes/javax/crypto/JceSecurity.java.template +++ b/src/java.base/share/classes/javax/crypto/JceSecurity.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,10 @@ package javax.crypto; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; import java.io.*; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; import java.net.URL; import java.nio.file.*; import java.security.*; @@ -86,13 +89,16 @@ final class JceSecurity { // Map of the providers we already have verified. // If verified ok, value == PROVIDER_VERIFIED, otherwise // the cause of verification failure is stored as value. - private static final Map + private static final Map verificationResults = new ConcurrentHashMap<>(); // Map of the providers currently being verified private static final Map verifyingProviders = new IdentityHashMap<>(); + // weak references queued by GC + private static final ReferenceQueue queue = new ReferenceQueue<>(); + private static final boolean isRestricted; /* @@ -199,38 +205,51 @@ final class JceSecurity { * Return null if ok, failure Exception if verification failed. */ static Exception getVerificationResult(Provider p) { - IdentityWrapper pKey = new IdentityWrapper(p); - Object o = verificationResults.get(pKey); - // no mapping found - if (o == null) { - synchronized (JceSecurity.class) { - // check cache again in case the result is now available - o = verificationResults.get(pKey); - if (o == null) { + expungeStaleWrappers(); + WeakIdentityWrapper pKey = new WeakIdentityWrapper(p, queue); + try { + Object o = verificationResults.computeIfAbsent(pKey, new Function<>() { + public Object apply(WeakIdentityWrapper key) { + // no mapping found if (verifyingProviders.get(p) != null) { // recursion; return failure now - return new NoSuchProviderException - ("Recursion during verification"); + throw new IllegalStateException(); } + Object result; try { verifyingProviders.put(p, Boolean.FALSE); URL providerURL = getCodeBase(p.getClass()); verifyProvider(providerURL, p); - o = PROVIDER_VERIFIED; + result = PROVIDER_VERIFIED; } catch (Exception e) { - o = e; + result = e; } finally { verifyingProviders.remove(p); } - verificationResults.put(pKey, o); if (debug != null) { debug.println("Provider " + p.getName() + - " verification result: " + o); + " verification result: " + result); } + return result; } - } + }); + return (o == PROVIDER_VERIFIED? null : (Exception) o); + + } catch (IllegalStateException ise) { + // recursive update detected + return new NoSuchProviderException + ("Recursion during verification"); + } + } + + /** + * Removes weakly reachable keys from history. + */ + static void expungeStaleWrappers() { + WeakIdentityWrapper key; + while ((key = (WeakIdentityWrapper) queue.poll()) != null) { + verificationResults.remove(key); } - return (o == PROVIDER_VERIFIED? null : (Exception) o); } // return whether this provider is properly signed and can be used by JCE @@ -403,12 +422,13 @@ final class JceSecurity { return isRestricted; } - private static final class IdentityWrapper { + private static final class WeakIdentityWrapper extends WeakReference { - final Provider obj; + final int hash; - IdentityWrapper(Provider obj) { - this.obj = obj; + WeakIdentityWrapper(Provider obj, ReferenceQueue queue) { + super(obj, queue); + hash = System.identityHashCode(obj); } @Override @@ -416,15 +436,12 @@ final class JceSecurity { if (this == o) { return true; } - if (!(o instanceof IdentityWrapper)) { - return false; - } - return this.obj == ((IdentityWrapper)o).obj; + return o instanceof WeakIdentityWrapper w && get() == w.get(); } @Override public int hashCode() { - return System.identityHashCode(obj); + return hash; } } } diff --git a/test/jdk/javax/crypto/JceSecurity/VerificationResults.java b/test/jdk/javax/crypto/JceSecurity/VerificationResults.java new file mode 100644 index 0000000000000..9f87433a6b6a0 --- /dev/null +++ b/test/jdk/javax/crypto/JceSecurity/VerificationResults.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2023, BELLSOFT. All rights reserved. + * 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 8168469 + * @summary Memory leak in JceSecurity + * @compile --add-exports java.base/com.sun.crypto.provider=ALL-UNNAMED VerificationResults.java + * @run main/othervm -Xmx128m --add-exports java.base/com.sun.crypto.provider=ALL-UNNAMED VerificationResults + */ + +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; + +import com.sun.crypto.provider.SunJCE; + +public class VerificationResults { + + // approximate double the number of providers that fits in -Xmx128m heap + private static final int PROVIDERS_COUNT = 2000; + // the heap buffer size that triggers the OOME when the providers heap cannot be reclaimed + private static final int OOM_TRIGGER_SIZE = 10 * 1024 * 1024; + public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchPaddingException { + int i = 0; + try { + for (; i < PROVIDERS_COUNT; i++) { + SunJCE jceProvider = new SunJCE(); + Cipher c = Cipher.getInstance("AES", jceProvider); + char[] arr = new char[OOM_TRIGGER_SIZE]; + } + } catch (OutOfMemoryError e) { + System.out.println("Caught OOME - less than 10M heap left.\nCreated " + i + " SunJCE providers"); + throw e; + } + } +} From 05964ff828a4651f4109534c4d7c2fb8ae804122 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 20 Sep 2023 13:58:19 +0000 Subject: [PATCH 112/341] 8315863: [GHA] Update checkout action to use v4 Backport-of: b74805d38395ca8be9308d882bf6b84e93714849 --- .github/actions/get-gtest/action.yml | 2 +- .github/actions/get-jtreg/action.yml | 2 +- .github/workflows/build-cross-compile.yml | 2 +- .github/workflows/build-linux.yml | 2 +- .github/workflows/build-macos.yml | 2 +- .github/workflows/build-windows.yml | 2 +- .github/workflows/test.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/get-gtest/action.yml b/.github/actions/get-gtest/action.yml index 76faaea3bc9bb..1df1052285d2a 100644 --- a/.github/actions/get-gtest/action.yml +++ b/.github/actions/get-gtest/action.yml @@ -40,7 +40,7 @@ runs: var: GTEST_VERSION - name: 'Checkout GTest source' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: google/googletest ref: 'release-${{ steps.version.outputs.value }}' diff --git a/.github/actions/get-jtreg/action.yml b/.github/actions/get-jtreg/action.yml index 7c49b1054ecd5..1a6ffeb126b27 100644 --- a/.github/actions/get-jtreg/action.yml +++ b/.github/actions/get-jtreg/action.yml @@ -47,7 +47,7 @@ runs: key: jtreg-${{ steps.version.outputs.value }} - name: 'Checkout the JTReg source' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: openjdk/jtreg ref: jtreg-${{ steps.version.outputs.value }} diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index a1d216922b70c..8df4fd4b196da 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -85,7 +85,7 @@ jobs: steps: - name: 'Checkout the JDK source' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Get the BootJDK' id: bootjdk diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 3ffa6170c7e2a..b063b9f050934 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -78,7 +78,7 @@ jobs: steps: - name: 'Checkout the JDK source' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Get the BootJDK' id: bootjdk diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 80bd181867f7f..b03fcb144fdba 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -68,7 +68,7 @@ jobs: steps: - name: 'Checkout the JDK source' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Get the BootJDK' id: bootjdk diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 6501d20c9ccb1..8e2c0c8e63c14 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -79,7 +79,7 @@ jobs: steps: - name: 'Checkout the JDK source' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Get MSYS2' uses: ./.github/actions/get-msys2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4d4e93c1875c..3febb11b86b37 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -105,7 +105,7 @@ jobs: steps: - name: 'Checkout the JDK source' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Get MSYS2' uses: ./.github/actions/get-msys2 From ac2d89babee687f659efaced73b7d6048f5cdab5 Mon Sep 17 00:00:00 2001 From: Chad Rakoczy Date: Wed, 20 Sep 2023 15:40:22 +0000 Subject: [PATCH 113/341] 8311813: C1: Uninitialized PhiResolver::_loop field Backport-of: 489a32fe40e2a2c539296d51d4ffc0abc036d33c --- src/hotspot/share/c1/c1_LIRGenerator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hotspot/share/c1/c1_LIRGenerator.cpp b/src/hotspot/share/c1/c1_LIRGenerator.cpp index 97ff08ef7b1ba..4c33bcf30386e 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.cpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp @@ -77,6 +77,7 @@ void PhiResolverState::reset() { PhiResolver::PhiResolver(LIRGenerator* gen) : _gen(gen) , _state(gen->resolver_state()) + , _loop(nullptr) , _temp(LIR_OprFact::illegalOpr) { // reinitialize the shared state arrays From 4ebd8b337a7af85346ab2f99527644d3bde49e96 Mon Sep 17 00:00:00 2001 From: Elif Aslan Date: Wed, 20 Sep 2023 19:59:56 +0000 Subject: [PATCH 114/341] 8311514: Incorrect regex in TestMetaSpaceLog.java Backport-of: 9084b6c9d5b6550059fee39d6335fed467f1c45c --- test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java b/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java index af773a9d73813..659f7ed9a4771 100644 --- a/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java +++ b/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java @@ -58,7 +58,13 @@ public class TestMetaSpaceLog { // Do this once here. // Scan for Metaspace update notices as part of the GC log, e.g. in this form: // [gc,metaspace ] GC(0) Metaspace: 11895K(14208K)->11895K(14208K) NonClass: 10552K(12544K)->10552K(12544K) Class: 1343K(1664K)->1343K(1664K) - metaSpaceRegexp = Pattern.compile(".*Metaspace: ([0-9]+).*->([0-9]+).*"); + // This regex has to be up-to-date with the format used in hotspot to print metaspace change. + final String NUM_K = "\\d+K"; + final String GP_NUM_K = "(\\d+)K"; + final String BR_NUM_K = "\\(" + NUM_K + "\\)"; + final String SIZE_CHG = NUM_K + BR_NUM_K + "->" + NUM_K + BR_NUM_K; + metaSpaceRegexp = Pattern.compile(".* Metaspace: " + GP_NUM_K + BR_NUM_K + "->" + GP_NUM_K + BR_NUM_K + + "( NonClass: " + SIZE_CHG + " Class: " + SIZE_CHG + ")?$"); } public static void main(String[] args) throws Exception { From 6398e46ac21488dd3b73836ae0fe713e0552c55b Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 22 Sep 2023 07:36:36 +0000 Subject: [PATCH 115/341] 8273522: Rename test property vm.cds.archived.java.heap to vm.cds.write.archived.java.heap Reviewed-by: lucy Backport-of: 922e86f4ff28c7b17af8e7b5867a40fc76b7fdd7 --- src/hotspot/share/prims/whitebox.cpp | 4 ++-- test/hotspot/jtreg/TEST.ROOT | 2 +- test/hotspot/jtreg/runtime/cds/SharedStrings.java | 2 +- test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java | 2 +- .../jtreg/runtime/cds/SharedStringsRunAuto.java | 2 +- .../jtreg/runtime/cds/appcds/CommandLineFlagCombo.java | 2 +- .../appcds/cacheObject/ArchivedIntegerCacheTest.java | 2 +- .../appcds/cacheObject/ArchivedModuleComboTest.java | 2 +- .../appcds/cacheObject/ArchivedModuleCompareTest.java | 2 +- .../cacheObject/ArchivedModuleWithCustomImageTest.java | 2 +- .../cds/appcds/cacheObject/CheckCachedMirrorTest.java | 2 +- .../cds/appcds/cacheObject/DifferentHeapSizes.java | 2 +- .../cds/appcds/cacheObject/DumpTimeVerifyFailure.java | 4 ++-- .../runtime/cds/appcds/cacheObject/GCStressTest.java | 2 +- .../cds/appcds/cacheObject/HeapFragmentationTest.java | 2 +- .../cacheObject/MirrorWithReferenceFieldsTest.java | 2 +- .../cds/appcds/cacheObject/OpenArchiveRegion.java | 4 ++-- .../cds/appcds/cacheObject/PrimitiveTypesTest.java | 2 +- .../cds/appcds/cacheObject/RedefineClassTest.java | 2 +- .../javaldr/ExceptionDuringDumpAtObjectsInitPhase.java | 2 +- .../cds/appcds/javaldr/GCSharedStringsDuringDump.java | 2 +- .../cds/appcds/javaldr/HumongousDuringDump.java | 2 +- .../runtime/cds/appcds/sharedStrings/ExerciseGC.java | 2 +- .../runtime/cds/appcds/sharedStrings/FlagCombo.java | 4 ++-- .../cds/appcds/sharedStrings/IncompatibleOptions.java | 6 +++--- .../cds/appcds/sharedStrings/InternSharedString.java | 2 +- .../cds/appcds/sharedStrings/InvalidFileFormat.java | 4 ++-- .../runtime/cds/appcds/sharedStrings/LargePages.java | 2 +- .../cds/appcds/sharedStrings/LockSharedStrings.java | 2 +- .../cds/appcds/sharedStrings/SharedStringsBasic.java | 2 +- .../appcds/sharedStrings/SharedStringsBasicPlus.java | 2 +- .../appcds/sharedStrings/SharedStringsHumongous.java | 2 +- .../cds/appcds/sharedStrings/SharedStringsStress.java | 2 +- .../cds/appcds/sharedStrings/SharedStringsWbTest.java | 2 +- .../runtime/cds/appcds/sharedStrings/SysDictCrash.java | 2 +- .../ReplaceCriticalClassesForSubgraphs.java | 2 +- test/jtreg-ext/requires/VMProps.java | 10 ++++------ test/lib/jdk/test/whitebox/WhiteBox.java | 2 +- 38 files changed, 48 insertions(+), 50 deletions(-) diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index d5ff64cd0ebbf..5a610227e7c75 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -1962,7 +1962,7 @@ WB_ENTRY(jboolean, WB_IsJVMCISupportedByGC(JNIEnv* env)) #endif WB_END -WB_ENTRY(jboolean, WB_IsJavaHeapArchiveSupported(JNIEnv* env)) +WB_ENTRY(jboolean, WB_CanWriteJavaHeapArchive(JNIEnv* env)) return HeapShared::is_heap_object_archiving_allowed(); WB_END @@ -2585,7 +2585,7 @@ static JNINativeMethod methods[] = { {CC"isDTraceIncluded", CC"()Z", (void*)&WB_IsDTraceIncluded }, {CC"isC2OrJVMCIIncluded", CC"()Z", (void*)&WB_isC2OrJVMCIIncluded }, {CC"isJVMCISupportedByGC", CC"()Z", (void*)&WB_IsJVMCISupportedByGC}, - {CC"isJavaHeapArchiveSupported", CC"()Z", (void*)&WB_IsJavaHeapArchiveSupported }, + {CC"canWriteJavaHeapArchive", CC"()Z", (void*)&WB_CanWriteJavaHeapArchive }, {CC"cdsMemoryMappingFailed", CC"()Z", (void*)&WB_CDSMemoryMappingFailed }, {CC"clearInlineCaches0", CC"(Z)V", (void*)&WB_ClearInlineCaches }, diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT index 36f7c78de2b86..48e0cca902104 100644 --- a/test/hotspot/jtreg/TEST.ROOT +++ b/test/hotspot/jtreg/TEST.ROOT @@ -68,7 +68,7 @@ requires.properties= \ vm.rtm.compiler \ vm.cds \ vm.cds.custom.loaders \ - vm.cds.archived.java.heap \ + vm.cds.write.archived.java.heap \ vm.jvmti \ vm.graal.enabled \ vm.compiler1.enabled \ diff --git a/test/hotspot/jtreg/runtime/cds/SharedStrings.java b/test/hotspot/jtreg/runtime/cds/SharedStrings.java index 247a85714991b..7a4e9813c3965 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedStrings.java +++ b/test/hotspot/jtreg/runtime/cds/SharedStrings.java @@ -25,7 +25,7 @@ * @test * @summary Check to make sure that shared strings in the bootstrap CDS archive * are actually shared - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib * @build SharedStringsWb jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java b/test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java index 434cee789377e..c555268026d35 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java +++ b/test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java @@ -24,7 +24,7 @@ /** * @test SharedStringsDedup * @summary Test -Xshare:auto with shared strings and -XX:+UseStringDeduplication - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib * @run driver SharedStringsDedup */ diff --git a/test/hotspot/jtreg/runtime/cds/SharedStringsRunAuto.java b/test/hotspot/jtreg/runtime/cds/SharedStringsRunAuto.java index a2437a0231ddc..271fb2ec255f2 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedStringsRunAuto.java +++ b/test/hotspot/jtreg/runtime/cds/SharedStringsRunAuto.java @@ -24,7 +24,7 @@ /** * @test SharedStringsAuto * @summary Test -Xshare:auto with shared strings. - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib * @run driver SharedStringsRunAuto */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java b/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java index eb1822550cdf7..4384954c12c11 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java @@ -24,7 +24,7 @@ /* * @test CommandLineFlagCombo - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @comment This test explicitly chooses the type of GC to be used by sub-processes. It may conflict with the GC type set * via the -vmoptions command line option of JTREG. vm.gc==null will help the test case to discard the explicitly passed * vm options. diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java index 5dc05e2686c4f..2bcbe18e1ff3d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java @@ -25,7 +25,7 @@ /* * @test * @summary Test primitive box caches integrity in various scenarios (IntegerCache etc) - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox * @compile CheckIntegerCacheApp.java diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleComboTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleComboTest.java index 0b47319bf91dd..3b37bfde77a90 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleComboTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleComboTest.java @@ -25,7 +25,7 @@ /* * @test * @summary Test archived system module sub-graph and verify objects are archived. - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox * @compile CheckArchivedModuleApp.java diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleCompareTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleCompareTest.java index 00ef746123f61..d66ba68529005 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleCompareTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleCompareTest.java @@ -25,7 +25,7 @@ /* * @test * @summary Compare archived system modules with non-archived. - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @compile PrintSystemModulesApp.java * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar PrintSystemModulesApp diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java index a47c9488ce1a6..2b2115b847213 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java @@ -24,7 +24,7 @@ /* * @test * @summary Test archived module graph with custom runtime image - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox * @compile CheckArchivedModuleApp.java diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/CheckCachedMirrorTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/CheckCachedMirrorTest.java index 24648273fef55..8e8cfe51a751f 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/CheckCachedMirrorTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/CheckCachedMirrorTest.java @@ -25,7 +25,7 @@ /* * @test * @summary Test archived mirror - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @requires vm.cds.custom.loaders * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DifferentHeapSizes.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DifferentHeapSizes.java index 9c12b30023646..9b4987f889457 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DifferentHeapSizes.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DifferentHeapSizes.java @@ -25,7 +25,7 @@ /* * @test * @summary Test automatic relocation of archive heap regions dur to heap size changes. - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @compile ../test-classes/Hello.java * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DumpTimeVerifyFailure.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DumpTimeVerifyFailure.java index fe5c546493e0f..0ac5dbe672b8c 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DumpTimeVerifyFailure.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/DumpTimeVerifyFailure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @test * @summary Dump time should not crash if any class with shared strings fails verification due to missing dependencies. * @bug 8186789 - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @compile MyOuter.java MyException.java * @run driver DumpTimeVerifyFailure diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/GCStressTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/GCStressTest.java index ecf6ebea5d7ab..68811a841b004 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/GCStressTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/GCStressTest.java @@ -26,7 +26,7 @@ * @test * @key randomness * @summary - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox jdk.test.lib.Utils * @compile GCStressApp.java diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/HeapFragmentationTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/HeapFragmentationTest.java index f2ec91aee42f1..ca1df0c9487fb 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/HeapFragmentationTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/HeapFragmentationTest.java @@ -26,7 +26,7 @@ * @test * @summary Relocate CDS archived regions to the top of the G1 heap * @bug 8214455 - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @requires (sun.arch.data.model == "64" & os.maxMemory > 4g) * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build HeapFragmentationApp diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsTest.java index 0ab28b13b5b27..4c670ccba9b1f 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsTest.java @@ -25,7 +25,7 @@ /* * @test * @summary Test archived mirror with reference fields - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox * @compile MirrorWithReferenceFieldsApp.java diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/OpenArchiveRegion.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/OpenArchiveRegion.java index c2384db0943cb..2f24f589c0e25 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/OpenArchiveRegion.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/OpenArchiveRegion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ /* * @test * @summary Test open archive heap regions - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @comment This test explicitly chooses the type of GC to be used by sub-processes. It may conflict with the GC type set * via the -vmoptions command line option of JTREG. vm.gc==null will help the test case to discard the explicitly passed * vm options. diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/PrimitiveTypesTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/PrimitiveTypesTest.java index d367aecbd5625..f94ea15f8b127 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/PrimitiveTypesTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/PrimitiveTypesTest.java @@ -25,7 +25,7 @@ /* * @test * @summary Test archived primitive type mirrors - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox * @compile PrimitiveTypesApp.java diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/RedefineClassTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/RedefineClassTest.java index 3c8e09da74758..22cad07d56107 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/RedefineClassTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/RedefineClassTest.java @@ -26,7 +26,7 @@ * @test * @summary Redefine shared class. GC should not cause crash with cached resolved_references. * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes /test/hotspot/jtreg/runtime/cds/appcds/jvmti - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @requires vm.jvmti * @build jdk.test.whitebox.WhiteBox * RedefineClassApp diff --git a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/ExceptionDuringDumpAtObjectsInitPhase.java b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/ExceptionDuringDumpAtObjectsInitPhase.java index 2f3b18d1ae7a3..9238a832addcf 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/ExceptionDuringDumpAtObjectsInitPhase.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/ExceptionDuringDumpAtObjectsInitPhase.java @@ -26,7 +26,7 @@ * @test * @summary Out of memory When dumping the CDS archive * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @requires vm.jvmti * @run driver ExceptionDuringDumpAtObjectsInitPhase */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCSharedStringsDuringDump.java b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCSharedStringsDuringDump.java index 9062976c5369c..501e2398d9dc2 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCSharedStringsDuringDump.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/GCSharedStringsDuringDump.java @@ -27,7 +27,7 @@ * @summary Similar to GCDuringDumping.java, this test adds the -XX:SharedArchiveConfigFile * option for testing the interaction with GC and shared strings. * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @requires vm.jvmti * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDump.java b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDump.java index 7867b5b7b368e..267eb5b945248 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDump.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/javaldr/HumongousDuringDump.java @@ -26,7 +26,7 @@ * @test * @summary Test how CDS dumping handles the existence of humongous G1 regions. * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @requires vm.jvmti * @run driver/timeout=240 HumongousDuringDump */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ExerciseGC.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ExerciseGC.java index 29a5230c3b11f..77097e0b7a499 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ExerciseGC.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/ExerciseGC.java @@ -25,7 +25,7 @@ /* * @test * @summary Exercise GC with shared strings - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @build HelloStringGC jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/FlagCombo.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/FlagCombo.java index 886a46f1c1750..d53db6d6be6fa 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/FlagCombo.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/FlagCombo.java @@ -25,7 +25,7 @@ /** * @test * @summary Test relevant combinations of command line flags with shared strings - * @requires vm.cds.archived.java.heap & vm.hasJFR + * @requires vm.cds.write.archived.java.heap & vm.hasJFR * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build HelloString * @run driver FlagCombo @@ -35,7 +35,7 @@ * @test * @summary Test relevant combinations of command line flags with shared strings * @comment A special test excluding the case that requires JFR - * @requires vm.cds.archived.java.heap & !vm.hasJFR + * @requires vm.cds.write.archived.java.heap & !vm.hasJFR * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build HelloString * @run driver FlagCombo noJfr diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java index 496310555dd7c..8d3d75d9c084b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/IncompatibleOptions.java @@ -31,7 +31,7 @@ * @test * @summary Test options that are incompatible with use of shared strings * Also test mismatch in oops encoding between dump time and run time - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @comment This test explicitly chooses the type of GC to be used by sub-processes. It may conflict with the GC type set * via the -vmoptions command line option of JTREG. vm.gc==null will help the test case to discard the explicitly passed * vm options. @@ -46,7 +46,7 @@ /* * @test - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @requires (vm.gc=="null") * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox @@ -57,7 +57,7 @@ /* * @test - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @requires (vm.gc=="null") * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InternSharedString.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InternSharedString.java index 461c6cd98c678..83d1929751b11 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InternSharedString.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InternSharedString.java @@ -25,7 +25,7 @@ /* * @test * @summary Test shared strings together with string intern operation - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @compile InternStringTest.java * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InvalidFileFormat.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InvalidFileFormat.java index 463673aea0680..dfe374cd02ac1 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InvalidFileFormat.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/InvalidFileFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ /* * @test * @summary Check most common errors in file format - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build HelloString * @run driver InvalidFileFormat diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/LargePages.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/LargePages.java index 0a7d4d0a57b3e..bd1ee674bcdf8 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/LargePages.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/LargePages.java @@ -25,7 +25,7 @@ /* * @test * @summary Basic shared string test with large pages - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build HelloString * @run driver LargePages diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/LockSharedStrings.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/LockSharedStrings.java index 5e0d275e1ffd0..cb004c74f363b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/LockSharedStrings.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/LockSharedStrings.java @@ -25,7 +25,7 @@ /* * @test * @summary Test locking on shared strings - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @compile LockStringTest.java LockStringValueTest.java * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java index f116690ac0106..294b01c4c91ac 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java @@ -25,7 +25,7 @@ /* * @test * @summary Basic test for shared strings - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @build HelloString * @run driver SharedStringsBasic diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasicPlus.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasicPlus.java index c477e27fd0d6f..69cca750bc571 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasicPlus.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasicPlus.java @@ -25,7 +25,7 @@ /* * @test * @summary Basic plus test for shared strings - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @build HelloStringPlus jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsHumongous.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsHumongous.java index 83d82de5031cf..b863f609cafaf 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsHumongous.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsHumongous.java @@ -26,7 +26,7 @@ * @test * @summary Use a shared string allocated in a humongous G1 region. * @comment -- the following implies that G1 is used (by command-line or by default) - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @build HelloString diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsStress.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsStress.java index 13a0bc34f50f4..0a4148ee4877b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsStress.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsStress.java @@ -25,7 +25,7 @@ /* * @test * @summary Write a lots of shared strings. - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/hotspot/jtreg/runtime/cds/appcds /test/lib * @build HelloString * @run driver/timeout=500 SharedStringsStress diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsWbTest.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsWbTest.java index d11de88ffb9c5..1ab5e2f3ee962 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsWbTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsWbTest.java @@ -25,7 +25,7 @@ /* * @test * @summary White box test for shared strings - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox SharedStringsWb * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java index ab3473777f467..f15674171e453 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java @@ -26,7 +26,7 @@ * @test * @summary Regression test for JDK-8098821 * @bug 8098821 - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @run driver SysDictCrash */ diff --git a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java index ca321eab58d56..1a267665dd6a5 100644 --- a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java +++ b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java @@ -26,7 +26,7 @@ * @test * @summary Tests how CDS works when critical library classes are replaced with JVMTI ClassFileLoadHook * @library /test/lib - * @requires vm.cds.archived.java.heap + * @requires vm.cds.write.archived.java.heap * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox * @run main/othervm/native ReplaceCriticalClassesForSubgraphs diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index ec4ca37bd4bd9..08979baae6d86 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -111,7 +111,7 @@ public Map call() { // vm.cds is true if the VM is compiled with cds support. map.put("vm.cds", this::vmCDS); map.put("vm.cds.custom.loaders", this::vmCDSForCustomLoaders); - map.put("vm.cds.archived.java.heap", this::vmCDSForArchivedJavaHeap); + map.put("vm.cds.write.archived.java.heap", this::vmCDSCanWriteArchivedJavaHeap); // vm.graal.enabled is true if Graal is used as JIT map.put("vm.graal.enabled", this::isGraalEnabled); map.put("vm.compiler1.enabled", this::isCompiler1Enabled); @@ -386,12 +386,10 @@ protected String vmCDSForCustomLoaders() { } /** - * Check for CDS support for archived Java heap regions. - * - * @return true if CDS provides support for archive Java heap regions in the VM to be tested. + * @return true if this VM can write Java heap objects into the CDS archive */ - protected String vmCDSForArchivedJavaHeap() { - return "" + ("true".equals(vmCDS()) && WB.isJavaHeapArchiveSupported()); + protected String vmCDSCanWriteArchivedJavaHeap() { + return "" + ("true".equals(vmCDS()) && WB.canWriteJavaHeapArchive()); } /** diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index bc9434fa50832..517c47e87058e 100644 --- a/test/lib/jdk/test/whitebox/WhiteBox.java +++ b/test/lib/jdk/test/whitebox/WhiteBox.java @@ -600,7 +600,7 @@ public Object getMethodOption(Executable method, String name) { public native boolean isCDSIncluded(); public native boolean isJFRIncluded(); public native boolean isDTraceIncluded(); - public native boolean isJavaHeapArchiveSupported(); + public native boolean canWriteJavaHeapArchive(); public native Object getResolvedReferences(Class c); public native void linkClass(Class c); public native boolean areOpenArchiveHeapObjectsMapped(); From 06756c49b08a9287a28b61eedbc2992868433681 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 22 Sep 2023 07:40:36 +0000 Subject: [PATCH 116/341] 8288325: [windows] Actual and Preferred Size of AWT Non-resizable frame are different Backport-of: eca9749da01d732033c07f2bbb38800a9d80f18d --- .../native/libawt/windows/awt_Window.cpp | 24 +++------ test/jdk/java/awt/Frame/AwtFramePackTest.java | 52 +++++++++++++------ 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp b/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp index 7b80a13deb7c1..8da38d9c798af 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp @@ -1393,7 +1393,6 @@ BOOL AwtWindow::UpdateInsets(jobject insets) */ RECT outside; RECT inside; - int extraBottomInsets = 0; // extra padded border for captioned windows int extraPaddedBorderInsets = ::GetSystemMetrics(SM_CXPADDEDBORDER); @@ -1405,12 +1404,13 @@ BOOL AwtWindow::UpdateInsets(jobject insets) if (outside.right - outside.left > 0 && outside.bottom - outside.top > 0) { ::MapWindowPoints(GetHWnd(), 0, (LPPOINT)&inside, 2); m_insets.top = inside.top - outside.top; - m_insets.bottom = outside.bottom - inside.bottom + extraBottomInsets; + m_insets.bottom = outside.bottom - inside.bottom; m_insets.left = inside.left - outside.left; m_insets.right = outside.right - inside.right; } else { m_insets.top = -1; } + if (m_insets.left < 0 || m_insets.top < 0 || m_insets.right < 0 || m_insets.bottom < 0) { @@ -1418,18 +1418,11 @@ BOOL AwtWindow::UpdateInsets(jobject insets) jobject target = GetTarget(env); if (IsUndecorated() == FALSE) { /* Get outer frame sizes. */ - LONG style = GetStyle(); - if (style & WS_THICKFRAME) { - m_insets.left = m_insets.right = - ::GetSystemMetrics(SM_CXSIZEFRAME) + extraPaddedBorderInsets; - m_insets.top = m_insets.bottom = - ::GetSystemMetrics(SM_CYSIZEFRAME) + extraPaddedBorderInsets; - } else { - m_insets.left = m_insets.right = - ::GetSystemMetrics(SM_CXDLGFRAME) + extraPaddedBorderInsets; - m_insets.top = m_insets.bottom = - ::GetSystemMetrics(SM_CYDLGFRAME) + extraPaddedBorderInsets; - } + // System metrics are same for resizable & non-resizable frame. + m_insets.left = m_insets.right = + ::GetSystemMetrics(SM_CXFRAME) + extraPaddedBorderInsets; + m_insets.top = m_insets.bottom = + ::GetSystemMetrics(SM_CYFRAME) + extraPaddedBorderInsets; /* Add in title. */ m_insets.top += ::GetSystemMetrics(SM_CYCAPTION); } @@ -1437,7 +1430,7 @@ BOOL AwtWindow::UpdateInsets(jobject insets) /* fix for 4418125: Undecorated frames are off by one */ /* undo the -1 set above */ /* Additional fix for 5059656 */ - /* Also, 5089312: Window insets should be 0. */ + /* Also, 5089312: Window insets should be 0. */ ::memset(&m_insets, 0, sizeof(m_insets)); } @@ -1450,7 +1443,6 @@ BOOL AwtWindow::UpdateInsets(jobject insets) env->DeleteLocalRef(target); return FALSE; } - m_insets.bottom += extraBottomInsets; env->DeleteLocalRef(target); } diff --git a/test/jdk/java/awt/Frame/AwtFramePackTest.java b/test/jdk/java/awt/Frame/AwtFramePackTest.java index 54fd330f3e424..82290d6201bbc 100644 --- a/test/jdk/java/awt/Frame/AwtFramePackTest.java +++ b/test/jdk/java/awt/Frame/AwtFramePackTest.java @@ -39,21 +39,37 @@ * @test * @bug 8265586 * @key headful - * @summary Tests whether insets are calculated correctly on Windows - * for AWT Frame by checking the actual and expected/preferred frame sizes. + * @summary Tests whether correct native frame insets are obtained + * for Resizable & Non-Resizable AWT Frame by checking the actual + * and expected/preferred frame sizes. * @run main AwtFramePackTest */ - public class AwtFramePackTest { - private static Frame frame; private static Robot robot; + private static StringBuffer errorLog = new StringBuffer(); public static void main(String[] args) throws AWTException { - try { - robot = new Robot(); - robot.setAutoDelay(300); + robot = new Robot(); + robot.setAutoDelay(300); + + // Resizable frame + createAWTFrame(true); + robot.waitForIdle(); + robot.delay(500); + + // Non-Resizable frame + createAWTFrame(false); + + if (!errorLog.isEmpty()) { + throw new RuntimeException("Test failed due to the following" + + " one or more errors: \n" + errorLog); + } + } + + private static void createAWTFrame(boolean isResizable) { + try { frame = new Frame(); frame.setLayout(new BorderLayout()); @@ -67,32 +83,36 @@ public static void main(String[] args) throws AWTException { mb.add(m); frame.setMenuBar(mb); + frame.setResizable(isResizable); frame.pack(); frame.setVisible(true); - robot.delay(500); robot.waitForIdle(); + robot.delay(500); Dimension actualFrameSize = frame.getSize(); Dimension expectedFrameSize = frame.getPreferredSize(); if (!actualFrameSize.equals(expectedFrameSize)) { - System.out.println("Expected frame size: "+ expectedFrameSize); - System.out.println("Actual frame size: "+ actualFrameSize); - saveScreenCapture(); - throw new RuntimeException("Expected and Actual frame size" + - " are different. frame.pack() does not work!!"); + String frameType = isResizable ? "ResizableFrame" : "NonResizableFrame"; + System.out.println("Expected frame size: " + expectedFrameSize); + System.out.println("Actual frame size: " + actualFrameSize); + saveScreenCapture(frameType + ".png"); + errorLog.append(frameType + ": Expected and Actual frame size" + + " are different. frame.pack() does not work!! \n"); } } finally { - frame.dispose(); + if (frame != null) { + frame.dispose(); + } } } // for debugging purpose, saves screen capture when test fails. - private static void saveScreenCapture() { + private static void saveScreenCapture(String filename) { BufferedImage image = robot.createScreenCapture(frame.getBounds()); try { - ImageIO.write(image,"png", new File("Frame.png")); + ImageIO.write(image,"png", new File(filename)); } catch (IOException e) { e.printStackTrace(); } From 43ad5d28319cb9ff298d9ee4e0900e06507ce7a1 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 22 Sep 2023 07:42:34 +0000 Subject: [PATCH 117/341] 8314063: The socket is not closed in Connection::createSocket when the handshake failed for LDAP connection Backport-of: f2383b3cbd1096f0b38e89a3d876da2217511f11 --- .../classes/com/sun/jndi/ldap/Connection.java | 131 +++++---- .../ldap/LdapSSLHandshakeFailureTest.java | 249 ++++++++++++++++++ test/jdk/com/sun/jndi/ldap/ksWithSAN | Bin 0 -> 2240 bytes 3 files changed, 314 insertions(+), 66 deletions(-) create mode 100644 test/jdk/com/sun/jndi/ldap/LdapSSLHandshakeFailureTest.java create mode 100644 test/jdk/com/sun/jndi/ldap/ksWithSAN diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java index ebb21bd8b759f..f71b1bb14009b 100644 --- a/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java +++ b/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java @@ -280,79 +280,79 @@ private InetSocketAddress createInetSocketAddress(String host, int port) { private Socket createSocket(String host, int port, String socketFactory, int connectTimeout) throws Exception { - Socket socket = null; - - if (socketFactory != null) { + SocketFactory factory = getSocketFactory(socketFactory); + assert factory != null; + Socket socket = createConnectionSocket(host, port, factory, connectTimeout); - // create the factory + // the handshake for SSL connection with server and reset timeout for the socket + if (socket instanceof SSLSocket sslSocket) { + try { + initialSSLHandshake(sslSocket, connectTimeout); + } catch (Exception e) { + // 8314063 the socket is not closed after the failure of handshake + // close the socket while the error happened + closeOpenedSocket(socket); + throw e; + } + } + return socket; + } + private SocketFactory getSocketFactory(String socketFactoryName) throws Exception { + if (socketFactoryName == null) { + if (debug) { + System.err.println("Connection: using default SocketFactory"); + } + return SocketFactory.getDefault(); + } else { + if (debug) { + System.err.println("Connection: loading supplied SocketFactory: " + socketFactoryName); + } @SuppressWarnings("unchecked") Class socketFactoryClass = - (Class)Obj.helper.loadClass(socketFactory); + (Class) Obj.helper.loadClass(socketFactoryName); Method getDefault = - socketFactoryClass.getMethod("getDefault", new Class[]{}); + socketFactoryClass.getMethod("getDefault"); SocketFactory factory = (SocketFactory) getDefault.invoke(null, new Object[]{}); + return factory; + } + } - // create the socket - - if (connectTimeout > 0) { - - InetSocketAddress endpoint = - createInetSocketAddress(host, port); - - // unconnected socket - socket = factory.createSocket(); - - if (debug) { - System.err.println("Connection: creating socket with " + - "a timeout using supplied socket factory"); - } - - // connected socket - socket.connect(endpoint, connectTimeout); - } - - // continue (but ignore connectTimeout) - if (socket == null) { - if (debug) { - System.err.println("Connection: creating socket using " + - "supplied socket factory"); - } - // connected socket - socket = factory.createSocket(host, port); - } - } else { - - if (connectTimeout > 0) { - - InetSocketAddress endpoint = createInetSocketAddress(host, port); - - socket = new Socket(); + private Socket createConnectionSocket(String host, int port, SocketFactory factory, + int connectTimeout) throws Exception { + Socket socket = null; - if (debug) { - System.err.println("Connection: creating socket with " + - "a timeout"); - } - socket.connect(endpoint, connectTimeout); + if (connectTimeout > 0) { + // create unconnected socket and then connect it if timeout + // is supplied + InetSocketAddress endpoint = + createInetSocketAddress(host, port); + // unconnected socket + socket = factory.createSocket(); + // connect socket with a timeout + socket.connect(endpoint, connectTimeout); + if (debug) { + System.err.println("Connection: creating socket with " + + "a connect timeout"); } - - // continue (but ignore connectTimeout) - - if (socket == null) { - if (debug) { - System.err.println("Connection: creating socket"); - } - // connected socket - socket = new Socket(host, port); + } + if (socket == null) { + // create connected socket + socket = factory.createSocket(host, port); + if (debug) { + System.err.println("Connection: creating connected socket with" + + " no connect timeout"); } } + return socket; + } + + // For LDAP connect timeouts on LDAP over SSL connections must treat + // the SSL handshake following socket connection as part of the timeout. + // So explicitly set a socket read timeout, trigger the SSL handshake, + // then reset the timeout. + private void initialSSLHandshake(SSLSocket sslSocket , int connectTimeout) throws Exception { - // For LDAP connect timeouts on LDAP over SSL connections must treat - // the SSL handshake following socket connection as part of the timeout. - // So explicitly set a socket read timeout, trigger the SSL handshake, - // then reset the timeout. - if (socket instanceof SSLSocket) { - SSLSocket sslSocket = (SSLSocket) socket; if (!IS_HOSTNAME_VERIFICATION_DISABLED) { SSLParameters param = sslSocket.getSSLParameters(); param.setEndpointIdentificationAlgorithm("LDAPS"); @@ -365,8 +365,6 @@ private Socket createSocket(String host, int port, String socketFactory, sslSocket.startHandshake(); sslSocket.setSoTimeout(socketTimeout); } - } - return socket; } //////////////////////////////////////////////////////////////////////////// @@ -642,7 +640,7 @@ void cleanup(Control[] reqCtls, boolean notifyParent) { flushAndCloseOutputStream(); // 8313657 socket is not closed until GC is run - closeOpenedSocket(); + closeOpenedSocket(sock); tryUnpauseReader(); if (!notifyParent) { @@ -695,9 +693,10 @@ private void flushAndCloseOutputStream() { } // close socket - private void closeOpenedSocket() { + private void closeOpenedSocket(Socket socket) { try { - sock.close(); + if (socket != null && !socket.isClosed()) + socket.close(); } catch (IOException ioEx) { if (debug) { System.err.println("Connection.closeConnectionSocket: Socket close problem: " + ioEx); diff --git a/test/jdk/com/sun/jndi/ldap/LdapSSLHandshakeFailureTest.java b/test/jdk/com/sun/jndi/ldap/LdapSSLHandshakeFailureTest.java new file mode 100644 index 0000000000000..29f74d250f7e8 --- /dev/null +++ b/test/jdk/com/sun/jndi/ldap/LdapSSLHandshakeFailureTest.java @@ -0,0 +1,249 @@ +/* + * 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.net.URIBuilder; + +import javax.naming.Context; +import javax.naming.ldap.InitialLdapContext; +import javax.naming.ldap.LdapContext; +import javax.net.SocketFactory; +import javax.net.ssl.SSLServerSocketFactory; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketException; +import java.util.Hashtable; + +/* + * @test + * @bug 8314063 + * @library /test/lib + * @summary For LDAPs connection, if the value of com.sun.jndi.ldap.connect.timeout is + * set too small or not an optimal value for the system, after the socket is created and + * connected to the server, but the handshake between the client and server fails due to + * socket time out, the opened socket is not closed properly. In this test case, the server + * is forced to sleep ten seconds and connection time out for client is one second. This + * will allow the socket opened and connected, and give the chance for the handshake to be + * timed out. Before this fix, the socket is kept opened. Right now the exception will be + * caught and the socket will be closed. + * + * @run main/othervm LdapSSLHandshakeFailureTest LdapSSLHandshakeFailureTest$CustomSocketFactory true 6000 + * @run main/othervm LdapSSLHandshakeFailureTest -1000 true 6000 + * @run main/othervm LdapSSLHandshakeFailureTest -1000 false 6000 + * @run main/othervm LdapSSLHandshakeFailureTest 2000 false 6000 + * @run main/othervm LdapSSLHandshakeFailureTest 0 true 6000 + * @run main/othervm LdapSSLHandshakeFailureTest 0 false 6000 + * @run main/othervm LdapSSLHandshakeFailureTest true + * @run main/othervm LdapSSLHandshakeFailureTest false + */ + +public class LdapSSLHandshakeFailureTest { + private static String SOCKET_CLOSED_MSG = "The socket has been closed."; + + private static int serverSleepingTime = 5000; + + public static void main(String args[]) throws Exception { + + // Set the keystores + setKeyStore(); + boolean serverSlowDown = Boolean.valueOf(args[0]); + if (args.length == 2) { + serverSlowDown = Boolean.valueOf(args[1]); + } + + if (args.length == 3) { + serverSleepingTime = Integer.valueOf(args[2]); + } + + boolean hasCustomSocketFactory = args[0] + .equals("LdapSSLHandshakeFailureTest$CustomSocketFactory"); + // start the test server first. + try (TestServer server = new TestServer(serverSlowDown, serverSleepingTime)) { + server.start(); + Hashtable env = new Hashtable<>(); + env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + env.put("java.naming.ldap.version", "3"); + env.put(Context.PROVIDER_URL, URIBuilder.newBuilder() + .scheme("ldaps") + .loopback() + .port(server.getPortNumber()) + .buildUnchecked().toString()); + + if (hasCustomSocketFactory) { + env.put("java.naming.ldap.factory.socket", args[0]); + env.put("com.sun.jndi.ldap.connect.timeout", "1000"); + } + + if (args.length == 2 && !hasCustomSocketFactory) { + env.put("com.sun.jndi.ldap.connect.timeout", args[0]); + } + + env.put(Context.SECURITY_PROTOCOL, "ssl"); + env.put(Context.SECURITY_AUTHENTICATION, "Simple"); + env.put(Context.SECURITY_PRINCIPAL, "cn=principal"); + env.put(Context.SECURITY_CREDENTIALS, "123456"); + LdapContext ctx = null; + try { + ctx = new InitialLdapContext(env, null); + } catch (Exception e) { + if (CustomSocketFactory.customSocket.closeMethodCalledCount() > 0 + && hasCustomSocketFactory + && Boolean.valueOf(args[1])) { + System.out.println(SOCKET_CLOSED_MSG); + } else { + throw e; + } + } finally { + if (ctx != null) + ctx.close(); + } + } + } + + public static class CustomSocketFactory extends SocketFactory { + private static CustomSocket customSocket; + + public static CustomSocketFactory getDefault() { + return new CustomSocketFactory(); + } + + @Override + public Socket createSocket() throws SocketException { + customSocket = new CustomSocket(); + return customSocket; + } + + @Override + public Socket createSocket(String s, int timeout) { + return customSocket; + } + + @Override + public Socket createSocket(String host, int port, InetAddress localHost, + int localPort) { + return customSocket; + } + + @Override + public Socket createSocket(InetAddress host, int port) { + return customSocket; + } + + @Override + public Socket createSocket(InetAddress address, int port, + InetAddress localAddress, int localPort) { + return customSocket; + } + } + + private static class CustomSocket extends Socket { + private int closeMethodCalled = 0; + + public CustomSocket() { + closeMethodCalled = 0; + } + + public int closeMethodCalledCount() { + return closeMethodCalled; + } + + @Override + public void close() throws java.io.IOException { + closeMethodCalled++; + super.close(); + } + } + + private static void setKeyStore() { + + String fileName = "ksWithSAN", dir = System.getProperty("test.src", ".") + File.separator; + + System.setProperty("javax.net.ssl.keyStore", dir + fileName); + System.setProperty("javax.net.ssl.keyStorePassword", "welcome1"); + System.setProperty("javax.net.ssl.trustStore", dir + fileName); + System.setProperty("javax.net.ssl.trustStorePassword", "welcome1"); + } + + static class TestServer extends Thread implements AutoCloseable { + private boolean isForceToSleep; + private int sleepingTime; + private final ServerSocket serverSocket; + private final int PORT; + + private TestServer(boolean isForceToSleep, int sleepingTime) { + this.isForceToSleep = isForceToSleep; + this.sleepingTime = sleepingTime; + try { + SSLServerSocketFactory socketFactory = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); + serverSocket = socketFactory.createServerSocket(0, 0, InetAddress.getLoopbackAddress()); + PORT = serverSocket.getLocalPort(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + setDaemon(true); + } + + public int getPortNumber() { + return PORT; + } + + @Override + public void run() { + try (Socket socket = serverSocket.accept(); + InputStream in = socket.getInputStream(); + OutputStream out = socket.getOutputStream()) { + if (isForceToSleep) { + Thread.sleep(sleepingTime); + } + byte[] bindResponse = {0x30, 0x0C, 0x02, 0x01, 0x01, 0x61, 0x07, 0x0A, + 0x01, 0x00, 0x04, 0x00, 0x04, 0x00}; + // read the bindRequest + while (in.read() != -1) { + in.skip(in.available()); + break; + } + out.write(bindResponse); + out.flush(); + // ignore the further requests + while (in.read() != -1) { + in.skip(in.available()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void close() throws Exception { + if (serverSocket != null) { + serverSocket.close(); + } + } + } +} + + diff --git a/test/jdk/com/sun/jndi/ldap/ksWithSAN b/test/jdk/com/sun/jndi/ldap/ksWithSAN new file mode 100644 index 0000000000000000000000000000000000000000..9c028e7cec6522c90adac9bfa7b29f6052b0b1e0 GIT binary patch literal 2240 zcmcgt`8(7L7oW{w=FV6K^HR2ovW&iB7+q_kEBpFpDF!9$42FoPX+)Aiwk#0|Lzc2N zq^#MK7$RY^4%x~QU0&UHdG25E{_y$X^EuBs&)J@H_P*|Y1%W`21AzYmmv5-|< z761_t1cA6902Q_epy3DwI2Z<&hX{bdTp$<~#;LN~-*=U9(!Pq9Kt~#9K|V|z{WHg~ zG%dGEn6@U>YpDQiZ9myI-IRJyhVzT@VS{!|v%KRtrb>lY{RFKL*)F+2)fZer2QG)h@_QsS z?P|lRub#SW87PnvnP*2vTl%WwxQ3}bSv4OcWj!I1*}r>*pbX6<8nBu=dg&2RuQFj) zKn}YDid)G|Sn-b%cXCb~h%KNLL%5$7+4_x|)($<5S74Pb_7#`=)cZLexv`G$m5p|d z&w?O~(xNR|^5>k}LZj&4J7F0E$f&Wo&^&s#p+jArftu)HvDXP&!p0WCew&l!JJ#>^ zgbBteR#~V0UY%(?Bz*q0uWg6PXb^E~Eq*~v@0(ly_7HIvIFdcXD2B!lLOCJ=X37G|#`wzFe{+p+w#Bt_`Fs0#yaWR=;q1A5ktWp!DJE8|ODA+}tD) z5uc`A0n5241zj806|GC_eZ*$=mv1LVl`8y*vHbno&gV?b=C!clE&PmmdkH3XNwG=j z>~>4zBK;Y-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Oy5{I{5ia%<>|&2c`yhGy1T{RsP=9gM~WiDj4Lxd*ju) z?%s&w`hgd=Z=~Ts|dC7QKXh$Q>23@dbR|cXngK4_n5B@>pzDZ zw18q|^&NDhPqS_ka+12UB~nzryHE1O3{DSRm+GIq)`m!lh_4`N(*-RjmMX_H%qo>G PM>3~w?k6Bja+3Z9gk<0b literal 0 HcmV?d00001 From 1eac8a47cadbf9fe3fae5af1cdc99fc5ee72111c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 22 Sep 2023 08:06:34 +0000 Subject: [PATCH 118/341] 8271824: mark hotspot runtime/CompressedOops tests which ignore external VM flags Backport-of: 9e769090a020d58f2488dd77fb0681aa2d3856db --- .../jtreg/runtime/CompressedOops/CompressedClassPointers.java | 1 + .../jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java | 3 ++- .../runtime/CompressedOops/CompressedKlassPointerAndOops.java | 3 ++- test/hotspot/jtreg/runtime/CompressedOops/ObjectAlignment.java | 3 ++- .../jtreg/runtime/CompressedOops/UseCompressedOops.java | 1 + 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java index d4ba080c6f832..8e2033e732962 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java @@ -26,6 +26,7 @@ * @bug 8024927 * @summary Testing address of compressed class pointer space as best as possible. * @requires vm.bits == 64 & !vm.graal.enabled + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java index 1f95e67c4c947..5eaced668f0a2 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @bug 8022865 * @summary Tests for the -XX:CompressedClassSpaceSize command line option * @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java index 78275cf6f9f97..28c517bbca9c8 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedKlassPointerAndOops.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ * @modules java.base/jdk.internal.misc * java.management * @requires vm.bits == 64 + * @requires vm.flagless * @run driver CompressedKlassPointerAndOops */ diff --git a/test/hotspot/jtreg/runtime/CompressedOops/ObjectAlignment.java b/test/hotspot/jtreg/runtime/CompressedOops/ObjectAlignment.java index 2570b118d4f06..f9c6d6921aad6 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/ObjectAlignment.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/ObjectAlignment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8022865 * @summary Tests for the -XX:ObjectAlignmentInBytes command line option + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java b/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java index 49e468c7ba573..bf4d58232a840 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java @@ -25,6 +25,7 @@ * @test * @bug 8022865 * @summary Tests for different combination of UseCompressedOops options + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management From 3baaf7c96916aab8afd5c1071408568f28e8df11 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 22 Sep 2023 08:08:59 +0000 Subject: [PATCH 119/341] 8271890: mark hotspot runtime/Dictionary tests which ignore external VM flags Backport-of: cdf3d55c82844a3c8817f8cc33e85ca15a5ad930 --- test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java | 1 + .../jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java | 1 + 2 files changed, 2 insertions(+) diff --git a/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java b/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java index 2da7fd742f86b..493f02f30362f 100644 --- a/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java +++ b/test/hotspot/jtreg/runtime/Dictionary/CleanProtectionDomain.java @@ -24,6 +24,7 @@ /* * @test * @summary Verifies the creation and cleaup of entries in the Protection Domain Table + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java b/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java index 88a10c1feb24c..756bff98ffb2d 100644 --- a/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java +++ b/test/hotspot/jtreg/runtime/Dictionary/ProtectionDomainCacheTest.java @@ -26,6 +26,7 @@ * @bug 8151486 8218266 * @summary Call Class.forName() on the system classloader from a class loaded * from a custom classloader, using the current class's protection domain. + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * @build jdk.test.lib.Utils From 27c114fb3eb060b01bbb3c97a2050030c19290dd Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 22 Sep 2023 08:11:15 +0000 Subject: [PATCH 120/341] 8271891: mark hotspot runtime/Safepoint tests which ignore external VM flags Backport-of: 6c17e6deb2ab36c3db8577fb6bb2cf2738b58dd4 --- .../jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java | 1 + .../jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java | 1 + 2 files changed, 2 insertions(+) diff --git a/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java b/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java index bc31cee9a170d..33de13f6c451c 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java +++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java @@ -28,6 +28,7 @@ * @test TestAbortOnVMOperationTimeout * @bug 8181143 8269523 8307653 * @summary Check abort on VM timeout is working + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java b/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java index c2d451ccd6f39..e7e3cfca7818b 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java +++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortVMOnSafepointTimeout.java @@ -30,6 +30,7 @@ * @test TestAbortVMOnSafepointTimeout * @summary Check if VM can kill thread which doesn't reach safepoint. * @bug 8219584 8227528 + * @requires vm.flagless * @library /testlibrary /test/lib * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox From d6b110624590ba6b72979f3f5e345649fbaedf02 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 22 Sep 2023 08:13:53 +0000 Subject: [PATCH 121/341] 8193543: Regression automated test '/open/test/jdk/java/awt/TrayIcon/SystemTrayInstance/SystemTrayInstanceTest.java' fails Backport-of: 08024d9583d02398d986db0e9b32fe19a2b8fec2 --- test/jdk/ProblemList.txt | 1 - .../SystemTrayInstanceTest.java | 41 ++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 33af3a2bcff7f..ca0d0a0586ce8 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -209,7 +209,6 @@ java/awt/TrayIcon/ModalityTest/ModalityTest.java 8150540 windows-all,macosx-all java/awt/TrayIcon/MouseEventMask/MouseEventMaskTest.java 8150540 windows-all java/awt/TrayIcon/MouseMovedTest/MouseMovedTest.java 8150540 windows-all java/awt/TrayIcon/SecurityCheck/FunctionalityCheck/FunctionalityCheck.java 8150540 windows-all -java/awt/TrayIcon/SystemTrayInstance/SystemTrayInstanceTest.java 8193543 linux-all java/awt/TrayIcon/TrayIconEventModifiers/TrayIconEventModifiersTest.java 8150540 windows-all java/awt/TrayIcon/TrayIconEvents/TrayIconEventsTest.java 8150540 windows-all java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java 8150540 windows-all diff --git a/test/jdk/java/awt/TrayIcon/SystemTrayInstance/SystemTrayInstanceTest.java b/test/jdk/java/awt/TrayIcon/SystemTrayInstance/SystemTrayInstanceTest.java index f864d6aec8d9a..1805f190d3230 100644 --- a/test/jdk/java/awt/TrayIcon/SystemTrayInstance/SystemTrayInstanceTest.java +++ b/test/jdk/java/awt/TrayIcon/SystemTrayInstance/SystemTrayInstanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -import java.awt.*; +import java.awt.SystemTray; /* * @test @@ -30,12 +30,20 @@ * a proper instance is returned in supported platforms and a proper * exception is thrown in unsupported platforms * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + * @requires (os.family != "linux") * @run main/othervm -DSystemTraySupport=TRUE SystemTrayInstanceTest */ +/* + * @test + * @key headful + * @requires (os.family == "linux") + * @run main/othervm -DSystemTraySupport=MAYBE SystemTrayInstanceTest + */ + public class SystemTrayInstanceTest { - private static boolean supported = false; + private static boolean shouldSupport = false; public static void main(String[] args) throws Exception { String sysTraySupport = System.getProperty("SystemTraySupport"); @@ -43,30 +51,35 @@ public static void main(String[] args) throws Exception { throw new RuntimeException("SystemTray support status unknown!"); if ("TRUE".equals(sysTraySupport)) { - System.out.println("System tray is supported on the platform under test"); - supported = true; + System.out.println("System tray should be supported on this platform."); + shouldSupport = true; } new SystemTrayInstanceTest().doTest(); } - private void doTest() throws Exception { - boolean flag = SystemTray.isSupported(); - if (supported != flag) - throw new RuntimeException("FAIL: isSupported did not return the correct value"+ - (supported ? - "SystemTray is supported on the platform under test" : - "SystemTray is not supported on the platform under test") + - "SystemTray.isSupported() method returned " + flag); + private void doTest() { + boolean systemSupported = SystemTray.isSupported(); + if (shouldSupport && !systemSupported) { + throw new RuntimeException( + "FAIL: SystemTray is not supported on the platform under test, while it should." + ); + } - if (supported) { + if (shouldSupport || systemSupported) { SystemTray tray = SystemTray.getSystemTray(); + System.out.println("SystemTray instance received"); } else { + boolean exceptionThrown = false; try { SystemTray tray = SystemTray.getSystemTray(); } catch (UnsupportedOperationException uoe) { + exceptionThrown = true; System.out.println("UnsupportedOperationException thrown correctly"); } + if (!exceptionThrown) { + throw new RuntimeException("UnsupportedOperationException is not thrown"); + } } } } From 069743dcf867bde7651c0c7c96f45d0f42db94fd Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 22 Sep 2023 08:16:10 +0000 Subject: [PATCH 122/341] 8292636: (dc) Problem listing of java/nio/channels/DatagramChannel/Unref.java has incorrect issue ID Backport-of: 5ca268ca65f3619139abeddd1070306db406ccc1 --- test/jdk/ProblemList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index ca0d0a0586ce8..99d31ec74c450 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -597,7 +597,7 @@ java/net/ServerSocket/AcceptInheritHandle.java 8211854 aix-ppc6 # jdk_nio -java/nio/channels/DatagramChannel/Unref.java 8233519 generic-all +java/nio/channels/DatagramChannel/Unref.java 8233437 generic-all java/nio/channels/AsynchronousSocketChannel/StressLoopback.java 8211851 aix-ppc64 From 0e02204ff8e286bf5e25da10231e87f128210b5f Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 22 Sep 2023 08:18:11 +0000 Subject: [PATCH 123/341] 8314263: Signed jars triggering Logger finder recursion and StackOverflowError 8315696: SignedLoggerFinderTest.java test failed 8316087: Test SignedLoggerFinderTest.java is still failing Reviewed-by: lucy Backport-of: 7daae1fb4267f92b38f0152611d69b7b89691087 --- .../share/classes/java/lang/System.java | 10 +- .../jdk/internal/logger/BootstrapLogger.java | 53 ++- .../jdk/internal/logger/LazyLoggers.java | 33 +- .../internal/logger/LoggerFinderLoader.java | 60 +++- .../services/java.lang.System$LoggerFinder | 1 + .../PlatformRecursiveLoadingTest.java | 94 ++++++ .../RecursiveLoadingTest.java | 92 ++++++ .../RecursiveLoading/SimpleLoggerFinder.java | 132 ++++++++ .../services/java.lang.System$LoggerFinder | 1 + .../SignedLoggerFinderTest.java | 307 ++++++++++++++++++ .../SimpleLoggerFinder.java | 74 +++++ .../jdk/internal/event/EventHelper.java | 155 +++++++++ .../SignedLoggerFinderTest/logging.properties | 14 + .../BootstrapLoggerAPIsTest.java | 7 +- .../BootstrapLogger/BootstrapLoggerTest.java | 5 +- .../internal/BootstrapLogger/LogStream.java | 4 +- .../BootstrapLoggerUtils.java | 8 +- 17 files changed, 1010 insertions(+), 40 deletions(-) create mode 100644 test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/META-INF/services/java.lang.System$LoggerFinder create mode 100644 test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/PlatformRecursiveLoadingTest.java create mode 100644 test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/RecursiveLoadingTest.java create mode 100644 test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/SimpleLoggerFinder.java create mode 100644 test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/META-INF/services/java.lang.System$LoggerFinder create mode 100644 test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/SignedLoggerFinderTest.java create mode 100644 test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/SimpleLoggerFinder.java create mode 100644 test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/java.base/share/classes/jdk/internal/event/EventHelper.java create mode 100644 test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/logging.properties rename test/jdk/java/lang/System/LoggerFinder/{internal/BootstrapLogger => lib}/BootstrapLoggerUtils.java (89%) diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java index c78014a9c951a..c31da48b88c7a 100644 --- a/src/java.base/share/classes/java/lang/System.java +++ b/src/java.base/share/classes/java/lang/System.java @@ -66,6 +66,7 @@ import java.util.function.Supplier; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; +import jdk.internal.logger.LoggerFinderLoader.TemporaryLoggerFinder; import jdk.internal.misc.Unsafe; import jdk.internal.util.StaticProperty; import jdk.internal.module.ModuleBootstrap; @@ -1713,13 +1714,16 @@ static LoggerFinder accessProvider() { // We do not need to synchronize: LoggerFinderLoader will // always return the same instance, so if we don't have it, // just fetch it again. - if (service == null) { + LoggerFinder finder = service; + if (finder == null) { PrivilegedAction pa = () -> LoggerFinderLoader.getLoggerFinder(); - service = AccessController.doPrivileged(pa, null, + finder = AccessController.doPrivileged(pa, null, LOGGERFINDER_PERMISSION); + if (finder instanceof TemporaryLoggerFinder) return finder; + service = finder; } - return service; + return finder; } } diff --git a/src/java.base/share/classes/jdk/internal/logger/BootstrapLogger.java b/src/java.base/share/classes/jdk/internal/logger/BootstrapLogger.java index 3c99d832b0afe..f351b52968d8b 100644 --- a/src/java.base/share/classes/jdk/internal/logger/BootstrapLogger.java +++ b/src/java.base/share/classes/jdk/internal/logger/BootstrapLogger.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,6 @@ import java.util.function.Supplier; import java.lang.System.LoggerFinder; import java.lang.System.Logger; -import java.lang.System.Logger.Level; import java.lang.ref.WeakReference; import java.util.Objects; import java.util.concurrent.ExecutionException; @@ -227,9 +226,19 @@ static void flush() { // The accessor in which this logger is temporarily set. final LazyLoggerAccessor holder; + // tests whether the logger is invoked by the loading thread before + // the LoggerFinder is loaded; can be null; + final BooleanSupplier isLoadingThread; + + // returns true if the logger is invoked by the loading thread before the + // LoggerFinder service is loaded + boolean isLoadingThread() { + return isLoadingThread != null && isLoadingThread.getAsBoolean(); + } - BootstrapLogger(LazyLoggerAccessor holder) { + BootstrapLogger(LazyLoggerAccessor holder, BooleanSupplier isLoadingThread) { this.holder = holder; + this.isLoadingThread = isLoadingThread; } // Temporary data object storing log events @@ -505,14 +514,15 @@ static LogEvent valueOf(BootstrapLogger bootstrap, PlatformLogger.Level level, static void log(LogEvent log, PlatformLogger.Bridge logger) { final SecurityManager sm = System.getSecurityManager(); if (sm == null || log.acc == null) { - log.log(logger); + BootstrapExecutors.submit(() -> log.log(logger)); } else { // not sure we can actually use lambda here. We may need to create // an anonymous class. Although if we reach here, then it means // the VM is booted. - AccessController.doPrivileged((PrivilegedAction) () -> { - log.log(logger); return null; - }, log.acc); + BootstrapExecutors.submit(() -> + AccessController.doPrivileged((PrivilegedAction) () -> { + log.log(logger); return null; + }, log.acc)); } } @@ -559,8 +569,9 @@ public String getName() { * @return true if the VM is still bootstrapping. */ boolean checkBootstrapping() { - if (isBooted()) { + if (isBooted() && !isLoadingThread()) { BootstrapExecutors.flush(); + holder.getConcreteLogger(this); return false; } return true; @@ -935,10 +946,16 @@ private static boolean useSurrogateLoggers() { // - the logging backend is a custom backend // - the logging backend is JUL, there is no custom config, // and the LogManager has not been initialized yet. - public static synchronized boolean useLazyLoggers() { - return !BootstrapLogger.isBooted() - || DetectBackend.detectedBackend == LoggingBackend.CUSTOM - || useSurrogateLoggers(); + public static boolean useLazyLoggers() { + // Note: avoid triggering the initialization of the DetectBackend class + // while holding the BootstrapLogger class monitor + if (!BootstrapLogger.isBooted() || + DetectBackend.detectedBackend == LoggingBackend.CUSTOM) { + return true; + } + synchronized (BootstrapLogger.class) { + return useSurrogateLoggers(); + } } // Called by LazyLoggerAccessor. This method will determine whether @@ -946,9 +963,9 @@ public static synchronized boolean useLazyLoggers() { // a SurrogateLogger (if JUL is the default backend and there // is no custom JUL configuration and LogManager is not yet initialized), // or a logger returned by the loaded LoggerFinder (all other cases). - static Logger getLogger(LazyLoggerAccessor accessor) { - if (!BootstrapLogger.isBooted()) { - return new BootstrapLogger(accessor); + static Logger getLogger(LazyLoggerAccessor accessor, BooleanSupplier isLoading) { + if (!BootstrapLogger.isBooted() || isLoading != null && isLoading.getAsBoolean()) { + return new BootstrapLogger(accessor, isLoading); } else { if (useSurrogateLoggers()) { // JUL is the default backend, there is no custom configuration, @@ -964,6 +981,12 @@ static Logger getLogger(LazyLoggerAccessor accessor) { } } + // trigger class initialization outside of holding lock + static void ensureBackendDetected() { + assert VM.isBooted() : "VM is not booted"; + // triggers detection of the backend + var backend = DetectBackend.detectedBackend; + } // If the backend is JUL, and there is no custom configuration, and // nobody has attempted to call LogManager.getLogManager() yet, then diff --git a/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java b/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java index c7f24a70b5962..2c62496287668 100644 --- a/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java +++ b/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.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 @@ -32,6 +32,9 @@ import java.lang.System.Logger; import java.lang.ref.WeakReference; import java.util.Objects; +import java.util.function.BooleanSupplier; + +import jdk.internal.logger.LoggerFinderLoader.TemporaryLoggerFinder; import jdk.internal.misc.VM; import sun.util.logging.PlatformLogger; @@ -110,6 +113,9 @@ static final class LazyLoggerAccessor implements LoggerAccessor { // We need to pass the actual caller module when creating the logger. private final WeakReference moduleRef; + // whether this is the loading thread, can be null + private final BooleanSupplier isLoadingThread; + // The name of the logger that will be created lazyly final String name; // The plain logger SPI object - null until it is accessed for the @@ -122,16 +128,24 @@ static final class LazyLoggerAccessor implements LoggerAccessor { private LazyLoggerAccessor(String name, LazyLoggerFactories factories, Module module) { + this(name, factories, module, null); + } + + private LazyLoggerAccessor(String name, + LazyLoggerFactories factories, + Module module, BooleanSupplier isLoading) { + this(Objects.requireNonNull(name), Objects.requireNonNull(factories), - Objects.requireNonNull(module), null); + Objects.requireNonNull(module), isLoading, null); } private LazyLoggerAccessor(String name, LazyLoggerFactories factories, - Module module, Void unused) { + Module module, BooleanSupplier isLoading, Void unused) { this.name = name; this.factories = factories; this.moduleRef = new WeakReference<>(module); + this.isLoadingThread = isLoading; } /** @@ -162,7 +176,7 @@ public Logger wrapped() { // BootstrapLogger has the logic to decide whether to invoke the // SPI or use a temporary (BootstrapLogger or SimpleConsoleLogger) // logger. - wrapped = BootstrapLogger.getLogger(this); + wrapped = BootstrapLogger.getLogger(this, isLoadingThread); synchronized(this) { // if w has already been in between, simply drop 'wrapped'. setWrappedIfNotSet(wrapped); @@ -194,7 +208,7 @@ public PlatformLogger.Bridge platform() { // BootstrapLogger has the logic to decide whether to invoke the // SPI or use a temporary (BootstrapLogger or SimpleConsoleLogger) // logger. - final Logger wrapped = BootstrapLogger.getLogger(this); + final Logger wrapped = BootstrapLogger.getLogger(this, isLoadingThread); synchronized(this) { // if w has already been set, simply drop 'wrapped'. setWrappedIfNotSet(wrapped); @@ -282,10 +296,10 @@ Logger createLogger() { * Creates a new lazy logger accessor for the named logger. The given * factories will be use when it becomes necessary to actually create * the logger. - * @param An interface that extends {@link Logger}. * @param name The logger name. * @param factories The factories that should be used to create the * wrapped logger. + * @param module The module for which the logger is being created * @return A new LazyLoggerAccessor. */ public static LazyLoggerAccessor makeAccessor(String name, @@ -340,6 +354,7 @@ private static LoggerFinder accessLoggerFinder() { prov = sm == null ? LoggerFinder.getLoggerFinder() : AccessController.doPrivileged( (PrivilegedAction)LoggerFinder::getLoggerFinder); + if (prov instanceof TemporaryLoggerFinder) return prov; provider = prov; } return prov; @@ -359,7 +374,6 @@ public Logger apply(String name, Module module) { new LazyLoggerFactories<>(loggerSupplier); - // A concrete implementation of Logger that delegates to a System.Logger, // but only creates the System.Logger instance lazily when it's used for // the first time. @@ -377,6 +391,11 @@ private JdkLazyLogger(LazyLoggerAccessor holder, Void unused) { } } + static Logger makeLazyLogger(String name, Module module, BooleanSupplier isLoading) { + final LazyLoggerAccessor holder = new LazyLoggerAccessor(name, factories, module, isLoading); + return new JdkLazyLogger(holder, null); + } + /** * Gets a logger from the LoggerFinder. Creates the actual concrete * logger. diff --git a/src/java.base/share/classes/jdk/internal/logger/LoggerFinderLoader.java b/src/java.base/share/classes/jdk/internal/logger/LoggerFinderLoader.java index dbf4ccca128e4..9cf1b5b3c43f2 100644 --- a/src/java.base/share/classes/jdk/internal/logger/LoggerFinderLoader.java +++ b/src/java.base/share/classes/jdk/internal/logger/LoggerFinderLoader.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 @@ -25,6 +25,8 @@ package jdk.internal.logger; import java.io.FilePermission; +import java.lang.System.Logger; +import java.lang.System.LoggerFinder; import java.security.AccessController; import java.security.Permission; import java.security.PrivilegedAction; @@ -32,6 +34,9 @@ import java.util.Locale; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; +import java.util.function.BooleanSupplier; + +import jdk.internal.vm.annotation.Stable; import sun.security.util.SecurityConstants; import sun.security.action.GetPropertyAction; @@ -64,13 +69,28 @@ private LoggerFinderLoader() { throw new InternalError("LoggerFinderLoader cannot be instantiated"); } - + // record the loadingThread while loading the backend + static volatile Thread loadingThread; // Return the loaded LoggerFinder, or load it if not already loaded. private static System.LoggerFinder service() { if (service != null) return service; + // ensure backend is detected before attempting to load the finder + BootstrapLogger.ensureBackendDetected(); synchronized(lock) { if (service != null) return service; - service = loadLoggerFinder(); + Thread currentThread = Thread.currentThread(); + if (loadingThread == currentThread) { + // recursive attempt to load the backend while loading the backend + // use a temporary logger finder that returns special BootstrapLogger + // which will wait until loading is finished + return TemporaryLoggerFinder.INSTANCE; + } + loadingThread = currentThread; + try { + service = loadLoggerFinder(); + } finally { + loadingThread = null; + } } // Since the LoggerFinder is already loaded - we can stop using // temporary loggers. @@ -78,6 +98,12 @@ private static System.LoggerFinder service() { return service; } + // returns true if called by the thread that loads the LoggerFinder, while + // loading the LoggerFinder. + static boolean isLoadingThread() { + return loadingThread != null && loadingThread == Thread.currentThread(); + } + // Get configuration error policy private static ErrorPolicy configurationErrorPolicy() { String errorPolicy = @@ -116,6 +142,34 @@ private static Iterator findLoggerFinderProviders() { return iterator; } + public static final class TemporaryLoggerFinder extends LoggerFinder { + private TemporaryLoggerFinder() {} + @Stable + private LoggerFinder loadedService; + + private static final BooleanSupplier isLoadingThread = new BooleanSupplier() { + @Override + public boolean getAsBoolean() { + return LoggerFinderLoader.isLoadingThread(); + } + }; + private static final TemporaryLoggerFinder INSTANCE = new TemporaryLoggerFinder(); + + @Override + public Logger getLogger(String name, Module module) { + if (loadedService == null) { + loadedService = service; + if (loadedService == null) { + return LazyLoggers.makeLazyLogger(name, module, isLoadingThread); + } + } + assert loadedService != null; + assert !LoggerFinderLoader.isLoadingThread(); + assert loadedService != this; + return LazyLoggers.getLogger(name, module); + } + } + // Loads the LoggerFinder using ServiceLoader. If no LoggerFinder // is found returns the default (possibly JUL based) implementation private static System.LoggerFinder loadLoggerFinder() { diff --git a/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/META-INF/services/java.lang.System$LoggerFinder b/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/META-INF/services/java.lang.System$LoggerFinder new file mode 100644 index 0000000000000..2471db0e95747 --- /dev/null +++ b/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/META-INF/services/java.lang.System$LoggerFinder @@ -0,0 +1 @@ +loggerfinder.SimpleLoggerFinder diff --git a/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/PlatformRecursiveLoadingTest.java b/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/PlatformRecursiveLoadingTest.java new file mode 100644 index 0000000000000..43c00050d2f6f --- /dev/null +++ b/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/PlatformRecursiveLoadingTest.java @@ -0,0 +1,94 @@ +/* + * 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 8314263 + * @summary Creating a logger while loading the Logger finder + * triggers recursion and StackOverflowError + * @modules java.base/sun.util.logging java.base/jdk.internal.logger:+open + * @library ../lib + * @compile RecursiveLoadingTest.java SimpleLoggerFinder.java + * @run main/othervm PlatformRecursiveLoadingTest + */ + +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.logging.LogRecord; + +import sun.util.logging.PlatformLogger; + +public class PlatformRecursiveLoadingTest { + + /** + * This test triggers recursion by calling `System.getLogger` in the class init and constructor + * of a custom LoggerFinder. Without the fix, this is expected to throw + * java.lang.NoClassDefFoundError: Could not initialize class jdk.internal.logger.LoggerFinderLoader$ErrorPolicy + * caused by: java.lang.StackOverflowError + */ + public static void main(String[] args) throws Throwable { + PlatformLogger.getLogger("main").info("in main"); + // allow time to let bootstrap logger flush data + BootstrapLoggerUtils.awaitPending(); + List logs = loggerfinder.SimpleLoggerFinder.LOGS; + logs.stream().map(SimpleLogRecord::of).forEach(System.out::println); + logs.stream().map(SimpleLogRecord::of).forEach(SimpleLogRecord::check); + assertEquals(String.valueOf(logs.size()), String.valueOf(3)); + } + + static List asList(Object[] params) { + return params == null ? null : Arrays.asList(params); + } + + record SimpleLogRecord(String message, Instant instant, String loggerName, + java.util.logging.Level level, List params, + String resourceBundleName, long seqNumber, + String sourceClassName, String methodName, Throwable thrown) { + SimpleLogRecord(LogRecord record) { + this(record.getMessage(), record.getInstant(), record.getLoggerName(), record.getLevel(), + asList(record.getParameters()), record.getResourceBundleName(), record.getSequenceNumber(), + record.getSourceClassName(), record.getSourceMethodName(), record.getThrown()); + } + static SimpleLogRecord of(Object o) { + return (o instanceof LogRecord record) ? new SimpleLogRecord(record) : null; + } + static SimpleLogRecord check(SimpleLogRecord record) { + if (record.loggerName.equals("dummy")) { + assertEquals(record.sourceClassName, "jdk.internal.logger.BootstrapLogger$LogEvent"); + assertEquals(record.methodName(), "log"); + } + if (record.loggerName.equals("main")) { + assertEquals(record.sourceClassName, PlatformRecursiveLoadingTest.class.getName()); + assertEquals(record.methodName, "main"); + } + return record; + } + } + + private static void assertEquals(String received, String expected) { + if (!expected.equals(received)) { + throw new RuntimeException("Received: " + received); + } + } +} diff --git a/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/RecursiveLoadingTest.java b/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/RecursiveLoadingTest.java new file mode 100644 index 0000000000000..014d9be457d80 --- /dev/null +++ b/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/RecursiveLoadingTest.java @@ -0,0 +1,92 @@ +/* + * 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 8314263 + * @summary Creating a logger while loading the Logger finder + * triggers recursion and StackOverflowError + * @modules java.base/jdk.internal.logger:+open + * @library ../lib + * @compile RecursiveLoadingTest.java SimpleLoggerFinder.java + * @run main/othervm RecursiveLoadingTest + */ + +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.logging.LogRecord; + +public class RecursiveLoadingTest { + + /** + * This test triggers recursion by calling `System.getLogger` in the class init and constructor + * of a custom LoggerFinder. Without the fix, this is expected to throw + * java.lang.NoClassDefFoundError: Could not initialize class jdk.internal.logger.LoggerFinderLoader$ErrorPolicy + * caused by: java.lang.StackOverflowError + */ + public static void main(String[] args) throws Throwable { + System.getLogger("main").log(System.Logger.Level.INFO, "in main"); + // allow time to let bootstrap logger flush data + BootstrapLoggerUtils.awaitPending(); + List logs = loggerfinder.SimpleLoggerFinder.LOGS; + logs.stream().map(SimpleLogRecord::of).forEach(System.out::println); + logs.stream().map(SimpleLogRecord::of).forEach(SimpleLogRecord::check); + assertEquals(String.valueOf(logs.size()), String.valueOf(3)); + } + + static List asList(Object[] params) { + return params == null ? null : Arrays.asList(params); + } + + record SimpleLogRecord(String message, Instant instant, String loggerName, + java.util.logging.Level level, List params, + String resourceBundleName, long seqNumber, + String sourceClassName, String methodName, Throwable thrown) { + SimpleLogRecord(LogRecord record) { + this(record.getMessage(), record.getInstant(), record.getLoggerName(), record.getLevel(), + asList(record.getParameters()), record.getResourceBundleName(), record.getSequenceNumber(), + record.getSourceClassName(), record.getSourceMethodName(), record.getThrown()); + } + static SimpleLogRecord of(Object o) { + return (o instanceof LogRecord record) ? new SimpleLogRecord(record) : null; + } + static SimpleLogRecord check(SimpleLogRecord record) { + if (record.loggerName.equals("dummy")) { + assertEquals(record.sourceClassName, "jdk.internal.logger.BootstrapLogger$LogEvent"); + assertEquals(record.methodName(), "log"); + } + if (record.loggerName.equals("main")) { + assertEquals(record.sourceClassName, RecursiveLoadingTest.class.getName()); + assertEquals(record.methodName, "main"); + } + return record; + } + } + + private static void assertEquals(String received, String expected) { + if (!expected.equals(received)) { + throw new RuntimeException("Received: " + received); + } + } +} diff --git a/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/SimpleLoggerFinder.java b/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/SimpleLoggerFinder.java new file mode 100644 index 0000000000000..bfa89bbbdae29 --- /dev/null +++ b/test/jdk/java/lang/System/LoggerFinder/RecursiveLoading/SimpleLoggerFinder.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package loggerfinder; + +import java.lang.*; +import java.util.*; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Handler; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +public class SimpleLoggerFinder extends System.LoggerFinder { + + public static final CopyOnWriteArrayList LOGS = new CopyOnWriteArrayList<>(); + static { + try { + long sleep = new Random().nextLong(1000L) + 1L; + // simulate a slow load service + Thread.sleep(sleep); + System.getLogger("dummy") + .log(System.Logger.Level.INFO, + "Logger finder service load sleep value: " + sleep); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + private final Map loggers = new ConcurrentHashMap<>(); + public SimpleLoggerFinder() { + System.getLogger("dummy") + .log(System.Logger.Level.INFO, + "Logger finder service created"); + } + + @Override + public System.Logger getLogger(String name, Module module) { + return loggers.computeIfAbsent(name, SimpleLogger::new); + } + + private static class SimpleLogger implements System.Logger { + private final java.util.logging.Logger logger; + + private static final class SimpleHandler extends Handler { + @Override + public void publish(LogRecord record) { + LOGS.add(record); + } + @Override public void flush() { } + @Override public void close() { } + } + + public SimpleLogger(String name) { + logger = Logger.getLogger(name); + logger.addHandler(new SimpleHandler()); + } + + @Override + public String getName() { + return logger.getName(); + } + + java.util.logging.Level level(Level level) { + return switch (level) { + case ALL -> java.util.logging.Level.ALL; + case DEBUG -> java.util.logging.Level.FINE; + case TRACE -> java.util.logging.Level.FINER; + case INFO -> java.util.logging.Level.INFO; + case WARNING -> java.util.logging.Level.WARNING; + case ERROR -> java.util.logging.Level.SEVERE; + case OFF -> java.util.logging.Level.OFF; + }; + } + + @Override + public boolean isLoggable(Level level) { + return logger.isLoggable(level(level)); + } + + @Override + public void log(Level level, ResourceBundle bundle, String msg, Throwable thrown) { + var julLevel = level(level); + if (!logger.isLoggable(julLevel)) return; + if (bundle != null) { + logger.logrb(julLevel, bundle, msg, thrown); + } else { + logger.log(julLevel, msg, thrown); + } + } + + @Override + public void log(Level level, ResourceBundle bundle, String format, Object... params) { + var julLevel = level(level); + if (!logger.isLoggable(julLevel)) return; + if (params == null) { + if (bundle == null) { + logger.log(julLevel, format); + } else { + logger.logrb(julLevel, bundle, format); + } + } else { + if (bundle == null) { + logger.log(julLevel, format, params); + } else { + logger.logrb(julLevel, bundle, format, params); + } + } + } + } +} + diff --git a/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/META-INF/services/java.lang.System$LoggerFinder b/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/META-INF/services/java.lang.System$LoggerFinder new file mode 100644 index 0000000000000..2471db0e95747 --- /dev/null +++ b/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/META-INF/services/java.lang.System$LoggerFinder @@ -0,0 +1 @@ +loggerfinder.SimpleLoggerFinder diff --git a/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/SignedLoggerFinderTest.java b/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/SignedLoggerFinderTest.java new file mode 100644 index 0000000000000..d9d8c88f9108d --- /dev/null +++ b/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/SignedLoggerFinderTest.java @@ -0,0 +1,307 @@ +/* + * 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 8314263 + * @summary Signed jars triggering Logger finder recursion and StackOverflowError + * @library /test/lib ../lib + * @compile/module=java.base share/classes/jdk/internal/event/EventHelper.java + * @modules java.base/jdk.internal.logger:+open + * @build jdk.test.lib.compiler.CompilerUtils + * jdk.test.lib.process.* + * jdk.test.lib.util.JarUtils + * jdk.test.lib.JDKToolLauncher + * @compile SignedLoggerFinderTest.java SimpleLoggerFinder.java + * @run main SignedLoggerFinderTest init + * @run main SignedLoggerFinderTest init sign + */ + +import java.io.File; +import java.nio.file.*; +import java.security.*; +import java.util.*; +import java.util.function.*; +import java.util.jar.*; + +import jdk.test.lib.JDKToolFinder; +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.Utils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.util.JarUtils; + +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static java.util.Arrays.asList; + +public class SignedLoggerFinderTest { + + /** + * This test triggers recursion in the broken JDK. The error can + * manifest in a few different ways. + * One error seen is "java.lang.NoClassDefFoundError: + * Could not initialize class jdk.internal.logger.LoggerFinderLoader$ErrorPolicy" + * + * The original reported error was a StackOverflow (also seen in different iterations + * of this run). Running test in signed and unsigned jar mode for sanity coverage. + * The current bug only manifests when jars are signed. + */ + + private static boolean init = false; + private static boolean signJars = false; + private static boolean mutliThreadLoad = false; + private static volatile boolean testComplete = false; + + private static final String KEYSTORE = "8314263.keystore"; + private static final String ALIAS = "JavaTest"; + private static final String STOREPASS = "changeit"; + private static final String KEYPASS = "changeit"; + private static final String DNAME = "CN=sample"; + private static final String CUSTOM_LOGGER_FINDER_NAME = + "loggerfinder.SimpleLoggerFinder"; + private static final String CUSTOM_LOGGER_NAME = + "loggerfinder.SimpleLoggerFinder$SimpleLogger"; + private static final String INTERNAL_LOGGER_FINDER_NAME = + "sun.util.logging.internal.LoggingProviderImpl"; + private static final String INTERNAL_LOGGER_NAME = + "sun.util.logging.internal.LoggingProviderImpl$JULWrapper"; + private static final Path jarPath1 = + Path.of(System.getProperty("test.classes", "."), "SimpleLoggerFinder.jar"); + private static final Path jarPath2 = + Path.of(System.getProperty("test.classes", "."), "SimpleLoggerFinder2.jar"); + + public static void main(String[] args) throws Throwable { + init = args.length >=1 && args[0].equals("init"); + signJars = args.length >=2 && args[1].equals("sign"); + + // init only passed in by jtreg test run, initialize the environment + // for the subsequent test run + if (init) { + initialize(); + launchTest(false, false); + launchTest(false, true); + launchTest(true, false); + launchTest(true, true); + + } else { + // set up complete. Run the code to trigger the recursion + // We're in the JVM launched by ProcessTools.executeCommand + boolean multiThreadLoad = Boolean.getBoolean("multiThreadLoad"); + boolean withCustomLoggerFinder = Boolean.getBoolean("withCustomLoggerFinder"); + + if (multiThreadLoad) { + long sleep = new Random().nextLong(100L) + 1L; + System.out.println("multi thread load sleep value: " + sleep); + new Thread(runnableWithSleep( + () -> System.getLogger("logger" + System.currentTimeMillis()), + sleep, "System.getLogger type: ")).start(); + new Thread(runnableWithSleep( + () -> System.LoggerFinder.getLoggerFinder(), + sleep, "System.getLoggerFinder type: ")).start(); + } + + if (withCustomLoggerFinder) { + JarFile jf = new JarFile(jarPath1.toString(), true); + jf.getInputStream(jf.getJarEntry("loggerfinder/SimpleLoggerFinder.class")); + JarFile jf2 = new JarFile(jarPath2.toString(), true); + jf2.getInputStream(jf.getJarEntry("loggerfinder/SimpleLoggerFinder.class")); + } else { + // some other call to prod LoggerFinder loading + System.getLogger("random" + System.currentTimeMillis()); + System.LoggerFinder.getLoggerFinder(); + } + Security.setProperty("test_1", "test"); + + // some extra sanity checks + if (withCustomLoggerFinder) { + assertEquals(System.LoggerFinder.getLoggerFinder().getClass().getName(), + CUSTOM_LOGGER_FINDER_NAME); + System.Logger testLogger = System.getLogger("jdk.event.security"); + assertEquals(testLogger.getClass().getName(), CUSTOM_LOGGER_NAME); + } else { + assertEquals(System.LoggerFinder.getLoggerFinder().getClass().getName(), + INTERNAL_LOGGER_FINDER_NAME); + System.Logger testLogger = System.getLogger("jdk.event.security"); + assertEquals(testLogger.getClass().getName(), INTERNAL_LOGGER_NAME); + } + testComplete = true; + + // LoggerFinder should be initialized, trigger a simple log call + Security.setProperty("test_2", "test"); + // allow time to let bootstrap logger flush data + BootstrapLoggerUtils.awaitPending(); + } + } + + // helper to create the inner test. Run config variations with the LoggerFinder jars + // on the classpath and with other threads running System.Logger calls during load + private static void launchTest(boolean multiThreadLoad, boolean withCustomLoggerFinder) { + List cmds = new ArrayList<>(); + cmds.add(JDKToolFinder.getJDKTool("java")); + cmds.addAll(asList(Utils.getTestJavaOpts())); + if (withCustomLoggerFinder) { + cmds.addAll(List.of("-classpath", + System.getProperty("test.classes") + File.pathSeparator + + jarPath1.toString() + File.pathSeparator + jarPath2.toString(), + "-Dtest.classes=" + System.getProperty("test.classes"))); + } else { + cmds.addAll(List.of("-classpath", + System.getProperty("test.classes"))); + } + + Path patches = Paths.get(System.getProperty("test.classes"), "patches", "java.base"); + cmds.addAll(List.of( + // patch of EventHelper to log at INFO level (for bootstrap logger) + "--patch-module", "java.base=" + patches.toString(), + // allow test to access internal bootstrap logger functionality + "--add-opens=java.base/jdk.internal.logger=ALL-UNNAMED", + // following debug property seems useful to tickle the issue + "-Dsun.misc.URLClassPath.debug=true", + // console logger level to capture event output + "-Djdk.system.logger.level=DEBUG", + // useful for debug purposes + "-Djdk.logger.finder.error=DEBUG", + // enable logging to verify correct output + "-Djava.util.logging.config.file=" + + Path.of(System.getProperty("test.src", "."), "logging.properties"))); + if (multiThreadLoad) { + cmds.add("-DmultiThreadLoad=true"); + } + if (withCustomLoggerFinder) { + cmds.add("-DwithCustomLoggerFinder=true"); + } + cmds.addAll(List.of( + "SignedLoggerFinderTest", + "no-init")); + + try { + OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(cmds.stream() + .filter(t -> !t.isEmpty()) + .toArray(String[]::new)) + .shouldHaveExitValue(0); + if (withCustomLoggerFinder) { + outputAnalyzer + .shouldContain("TEST LOGGER: [test_1, test]") + .shouldContain("TEST LOGGER: [test_2, test]"); + } else { + outputAnalyzer + .shouldContain("SecurityPropertyModification: key:test_1") + .shouldContain("SecurityPropertyModification: key:test_2"); + } + if (withCustomLoggerFinder && signJars) { + // X509 cert generated during verification of signed jar file + outputAnalyzer + .shouldContain(DNAME); + } + + } catch (Throwable t) { + throw new RuntimeException("Unexpected fail.", t); + } + } + + private static Runnable runnableWithSleep(Supplier s, long sleep, String desc) { + return () -> { + while(!testComplete) { + System.out.println(desc + s.get().getClass().getName()); + try { + Thread.sleep(sleep); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + }; + } + + private static void initialize() throws Throwable { + if (signJars) { + genKey(); + } + + Path classes = Paths.get(System.getProperty("test.classes", "")); + JarUtils.createJarFile(jarPath1, + classes, + classes.resolve("loggerfinder/SimpleLoggerFinder.class"), + classes.resolve("loggerfinder/SimpleLoggerFinder$SimpleLogger.class")); + + JarUtils.updateJarFile(jarPath1, Path.of(System.getProperty("test.src")), + Path.of("META-INF", "services", "java.lang.System$LoggerFinder")); + if (signJars) { + signJar(jarPath1.toString()); + } + // multiple signed jars with services to have ServiceLoader iteration + Files.copy(jarPath1, jarPath2, REPLACE_EXISTING); + } + + private static void genKey() throws Throwable { + String keytool = JDKToolFinder.getJDKTool("keytool"); + Files.deleteIfExists(Paths.get(KEYSTORE)); + ProcessTools.executeCommand(keytool, + "-J-Duser.language=en", + "-J-Duser.country=US", + "-genkey", + "-keyalg", "rsa", + "-alias", ALIAS, + "-keystore", KEYSTORE, + "-keypass", KEYPASS, + "-dname", DNAME, + "-storepass", STOREPASS + ).shouldHaveExitValue(0); + } + + + private static OutputAnalyzer signJar(String jarName) throws Throwable { + List args = new ArrayList<>(); + args.add("-verbose"); + args.add(jarName); + args.add(ALIAS); + + return jarsigner(args); + } + + private static OutputAnalyzer jarsigner(List extra) + throws Throwable { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jarsigner") + .addVMArg("-Duser.language=en") + .addVMArg("-Duser.country=US") + .addToolArg("-keystore") + .addToolArg(KEYSTORE) + .addToolArg("-storepass") + .addToolArg(STOREPASS) + .addToolArg("-keypass") + .addToolArg(KEYPASS); + for (String s : extra) { + if (s.startsWith("-J")) { + launcher.addVMArg(s.substring(2)); + } else { + launcher.addToolArg(s); + } + } + return ProcessTools.executeCommand(launcher.getCommand()); + } + + private static void assertEquals(String received, String expected) { + if (!expected.equals(received)) { + throw new RuntimeException("Received: " + received); + } + } +} diff --git a/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/SimpleLoggerFinder.java b/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/SimpleLoggerFinder.java new file mode 100644 index 0000000000000..f8e021f40734b --- /dev/null +++ b/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/SimpleLoggerFinder.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package loggerfinder; + +import java.lang.*; +import java.util.*; + +public class SimpleLoggerFinder extends System.LoggerFinder { + + static { + try { + long sleep = new Random().nextLong(1000L) + 1L; + System.out.println("Logger finder service load sleep value: " + sleep); + // simulate a slow load service + Thread.sleep(sleep); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + @Override + public System.Logger getLogger(String name, Module module) { + return new SimpleLogger(name); + } + + private static class SimpleLogger implements System.Logger { + private final String name; + + public SimpleLogger(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } + + @Override + public boolean isLoggable(Level level) { + return true; + } + + @Override + public void log(Level level, ResourceBundle bundle, String msg, Throwable thrown) { + System.out.println("TEST LOGGER: " + msg); + } + + @Override + public void log(Level level, ResourceBundle bundle, String format, Object... params) { + System.out.println("TEST LOGGER: " + Arrays.asList(params)); + + } + } +} diff --git a/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/java.base/share/classes/jdk/internal/event/EventHelper.java b/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/java.base/share/classes/jdk/internal/event/EventHelper.java new file mode 100644 index 0000000000000..4e9e3f7bff5d2 --- /dev/null +++ b/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/java.base/share/classes/jdk/internal/event/EventHelper.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.event; + +import jdk.internal.access.JavaUtilJarAccess; +import jdk.internal.access.SharedSecrets; + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; +import java.time.Duration; +import java.time.Instant; +import java.util.Date; +import java.util.stream.Collectors; +import java.util.stream.LongStream; + +/** + * A helper class to have events logged to a JDK Event Logger. + */ + +public final class EventHelper { + + private static final JavaUtilJarAccess JUJA = SharedSecrets.javaUtilJarAccess(); + private static volatile boolean loggingSecurity; + private static volatile System.Logger securityLogger; + private static final VarHandle LOGGER_HANDLE; + static { + System.err.println("Patch version of EventHelper loaded"); + try { + LOGGER_HANDLE = + MethodHandles.lookup().findStaticVarHandle( + EventHelper.class, "securityLogger", System.Logger.class); + } catch (ReflectiveOperationException e) { + throw new Error(e); + } + } + // a patch module to help this test ensure events are logged when + // bootstrap logger is in use + private static final System.Logger.Level LOG_LEVEL = System.Logger.Level.INFO; + + // helper class used for logging security related events for now + private static final String SECURITY_LOGGER_NAME = "jdk.event.security"; + + + public static void logTLSHandshakeEvent(Instant start, + String peerHost, + int peerPort, + String cipherSuite, + String protocolVersion, + long peerCertId) { + assert securityLogger != null; + String prepend = getDurationString(start); + securityLogger.log(LOG_LEVEL, prepend + + " TLSHandshake: {0}:{1,number,#}, {2}, {3}, {4,number,#}", + peerHost, peerPort, protocolVersion, cipherSuite, peerCertId); + } + + public static void logSecurityPropertyEvent(String key, + String value) { + + assert securityLogger != null; + securityLogger.log(LOG_LEVEL, + "SecurityPropertyModification: key:{0}, value:{1}", key, value); + } + + public static void logX509ValidationEvent(long anchorCertId, + long[] certIds) { + assert securityLogger != null; + String codes = LongStream.of(certIds) + .mapToObj(Long::toString) + .collect(Collectors.joining(", ")); + securityLogger.log(LOG_LEVEL, + "ValidationChain: {0,number,#}, {1}", anchorCertId, codes); + } + + public static void logX509CertificateEvent(String algId, + String serialNum, + String subject, + String issuer, + String keyType, + int length, + long certId, + long beginDate, + long endDate) { + assert securityLogger != null; + securityLogger.log(LOG_LEVEL, "X509Certificate: Alg:{0}, Serial:{1}" + + ", Subject:{2}, Issuer:{3}, Key type:{4}, Length:{5,number,#}" + + ", Cert Id:{6,number,#}, Valid from:{7}, Valid until:{8}", + algId, serialNum, subject, issuer, keyType, length, + certId, new Date(beginDate), new Date(endDate)); + } + + /** + * Method to calculate a duration timestamp for events which measure + * the start and end times of certain operations. + * @param start Instant indicating when event started recording + * @return A string representing duraction from start time to + * time of this method call. Empty string is start is null. + */ + private static String getDurationString(Instant start) { + if (start != null) { + if (start.equals(Instant.MIN)) { + return "N/A"; + } + Duration duration = Duration.between(start, Instant.now()); + long micros = duration.toNanos() / 1_000; + if (micros < 1_000_000) { + return "duration = " + (micros / 1_000.0) + " ms:"; + } else { + return "duration = " + ((micros / 1_000) / 1_000.0) + " s:"; + } + } else { + return ""; + } + } + + /** + * Helper to determine if security events are being logged + * at a preconfigured logging level. The configuration value + * is read once at class initialization. + * + * @return boolean indicating whether an event should be logged + */ + public static boolean isLoggingSecurity() { + // Avoid a bootstrap issue where the commitEvent attempts to + // trigger early loading of System Logger but where + // the verification process still has JarFiles locked + if (securityLogger == null && !JUJA.isInitializing()) { + LOGGER_HANDLE.compareAndSet( null, System.getLogger(SECURITY_LOGGER_NAME)); + loggingSecurity = securityLogger.isLoggable(LOG_LEVEL); + } + return loggingSecurity; + } + +} diff --git a/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/logging.properties b/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/logging.properties new file mode 100644 index 0000000000000..33595267e5e13 --- /dev/null +++ b/test/jdk/java/lang/System/LoggerFinder/SignedLoggerFinderTest/logging.properties @@ -0,0 +1,14 @@ +############################################################ +# Configuration file for log testing +# +############################################################ + +handlers= java.util.logging.ConsoleHandler + +.level= FINE + +java.util.logging.ConsoleHandler.level = FINE +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + +jdk.event.security.level = FINE + diff --git a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java b/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java index 19b100960e5a0..d38d0943928f0 100644 --- a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerAPIsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 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 @@ -29,7 +29,7 @@ import java.util.Enumeration; import java.util.List; import java.util.ResourceBundle; -import java.util.Set; + import jdk.internal.logger.BootstrapLogger; import jdk.internal.logger.LazyLoggers; @@ -38,9 +38,10 @@ * @bug 8144460 8144214 * @summary Cover the logXX and LogEvent.valueOf APIs of BootstrapLogger * and logXX APIs of SimpleConsoleLogger. + * @library ../../lib * @modules java.base/jdk.internal.logger:+open * java.base/sun.util.logging - * @build BootstrapLoggerUtils LogStream + * @build LogStream * @run main/othervm BootstrapLoggerAPIsTest */ diff --git a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java b/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java index 3ddf32f12df09..9f17478f35f75 100644 --- a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java +++ b/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.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 @@ -53,9 +53,10 @@ * @summary JDK implementation specific unit test for JDK internal artifacts. Tests the behavior of bootstrap loggers (and SimpleConsoleLoggers * too). + * @library ../../lib * @modules java.base/jdk.internal.logger:+open * java.logging - * @build BootstrapLoggerUtils LogStream + * @build LogStream * @run main/othervm BootstrapLoggerTest NO_SECURITY * @run main/othervm -Djava.security.manager=allow BootstrapLoggerTest SECURE * @run main/othervm/timeout=120 -Djava.security.manager=allow BootstrapLoggerTest SECURE_AND_WAIT diff --git a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/LogStream.java b/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/LogStream.java index d6e218a2a438f..a7f20fc79481a 100644 --- a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/LogStream.java +++ b/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/LogStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 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 @@ -25,8 +25,6 @@ import java.io.OutputStream; import java.io.PrintStream; -import jdk.internal.logger.BootstrapLogger; - /** * We use an instance of this class to check what the logging system has printed * on System.err. diff --git a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerUtils.java b/test/jdk/java/lang/System/LoggerFinder/lib/BootstrapLoggerUtils.java similarity index 89% rename from test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerUtils.java rename to test/jdk/java/lang/System/LoggerFinder/lib/BootstrapLoggerUtils.java index 0e78b588e99c6..2e551f9449146 100644 --- a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerUtils.java +++ b/test/jdk/java/lang/System/LoggerFinder/lib/BootstrapLoggerUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 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 @@ -28,7 +28,7 @@ import jdk.internal.logger.BootstrapLogger; -class BootstrapLoggerUtils { +public final class BootstrapLoggerUtils { private static final Field IS_BOOTED; private static final Method AWAIT_PENDING; @@ -46,11 +46,11 @@ class BootstrapLoggerUtils { } } - static void setBootedHook(BooleanSupplier supplier) throws IllegalAccessException { + public static void setBootedHook(BooleanSupplier supplier) throws IllegalAccessException { IS_BOOTED.set(null, supplier); } - static void awaitPending() { + public static void awaitPending() { try { AWAIT_PENDING.invoke(null); } catch (IllegalAccessException | IllegalArgumentException From 125ae25ebcb7e7f989f9d2da4a82e7d680c25431 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 22 Sep 2023 15:48:18 +0000 Subject: [PATCH 124/341] 8314045: ArithmeticException in GaloisCounterMode Backport-of: f41c267f859c305a2d01c629dbc56692322f81e2 --- .../crypto/provider/GaloisCounterMode.java | 7 +++ .../provider/Cipher/AEAD/GCMShortInput.java | 58 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMShortInput.java diff --git a/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java b/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java index 7cad5ec9c822a..f6f335c66f185 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java @@ -1430,6 +1430,13 @@ public int doFinal(ByteBuffer src, ByteBuffer dst) len += buffer.remaining(); } + // Check that input data is long enough to fit the expected tag. + if (len < 0) { + throw new AEADBadTagException("Input data too short to " + + "contain an expected tag length of " + tagLenBytes + + "bytes"); + } + checkDataLength(len); // Save GHASH context to allow the tag to be checked even though diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMShortInput.java b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMShortInput.java new file mode 100644 index 0000000000000..d01cbfb1e1927 --- /dev/null +++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMShortInput.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023, Alphabet LLC. All rights reserved. + * 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 8314045 + * @summary ArithmeticException in GaloisCounterMode + */ + +import java.nio.ByteBuffer; + +import javax.crypto.AEADBadTagException; +import javax.crypto.Cipher; +import javax.crypto.spec.GCMParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +public class GCMShortInput { + + public static void main(String args[]) throws Exception { + SecretKeySpec keySpec = + new SecretKeySpec( + new byte[] { + 88, 26, 43, -100, -24, -29, -70, 10, 34, -85, 52, 101, 45, -68, -105, + -123 + }, + "AES"); + GCMParameterSpec params = + new GCMParameterSpec(8 * 16, new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); + Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); + cipher.init(Cipher.DECRYPT_MODE, keySpec, params); + try { + cipher.doFinal(ByteBuffer.allocate(0), ByteBuffer.allocate(0)); + throw new AssertionError("AEADBadTagException expected"); + } catch (AEADBadTagException e) { + // expected + } + } +} From 93071dcd2341d79431a87a43e51268d20c2046a3 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 22 Sep 2023 15:48:59 +0000 Subject: [PATCH 125/341] 8316178: Better diagnostic header for CodeBlobs Backport-of: d575968b4bde74bd557cb84e89f0fa0f96b04087 --- src/hotspot/share/code/codeBlob.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/code/codeBlob.cpp b/src/hotspot/share/code/codeBlob.cpp index ef0ec837a7354..41a582f43ec1a 100644 --- a/src/hotspot/share/code/codeBlob.cpp +++ b/src/hotspot/share/code/codeBlob.cpp @@ -189,7 +189,8 @@ void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const cha if (PrintStubCode) { ttyLocker ttyl; tty->print_cr("- - - [BEGIN] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); - tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, (intptr_t) stub); + tty->print_cr("Decoding %s " PTR_FORMAT " [" PTR_FORMAT ", " PTR_FORMAT "] (%d bytes)", + stub_id, p2i(stub), p2i(stub->code_begin()), p2i(stub->code_end()), stub->code_size()); Disassembler::decode(stub->code_begin(), stub->code_end(), tty); if ((stub->oop_maps() != NULL) && AbstractDisassembler::show_structs()) { tty->print_cr("- - - [OOP MAPS]- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); From d6eec8d4c07dc402a3e7abcfe372d23cbef596af Mon Sep 17 00:00:00 2001 From: Elif Aslan <116521601+elifaslan1@users.noreply.github.com> Date: Fri, 22 Sep 2023 18:13:31 +0000 Subject: [PATCH 126/341] 8276036: The value of full_count in the message of insufficient codecache is wrong Backport-of: 61cb4bc6b0252536364a86f38ff2e5c8c7ab610b --- src/hotspot/share/code/codeCache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index 7f7a97da2c05b..bca8b7dc9d046 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -1263,7 +1263,9 @@ void CodeCache::report_codemem_full(int code_blob_type, bool print) { CodeHeap* heap = get_code_heap(code_blob_type); assert(heap != NULL, "heap is null"); - if ((heap->full_count() == 0) || print) { + heap->report_full(); + + if ((heap->full_count() == 1) || print) { // Not yet reported for this heap, report if (SegmentedCodeCache) { ResourceMark rm; @@ -1300,15 +1302,13 @@ void CodeCache::report_codemem_full(int code_blob_type, bool print) { tty->print("%s", s.as_string()); } - if (heap->full_count() == 0) { + if (heap->full_count() == 1) { if (PrintCodeHeapAnalytics) { CompileBroker::print_heapinfo(tty, "all", 4096); // details, may be a lot! } } } - heap->report_full(); - EventCodeCacheFull event; if (event.should_commit()) { event.set_codeBlobType((u1)code_blob_type); From 93211bd424cd86ccd0c9be0d838cc802764a1506 Mon Sep 17 00:00:00 2001 From: Masanori Yano Date: Mon, 25 Sep 2023 06:34:54 +0000 Subject: [PATCH 127/341] 8293579: tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java fails on Japanese Windows platform Backport-of: 121d4a5119f98adf30fa759563eec843a6e37d61 --- .../jdk/jpackage/tests/UnicodeArgsTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java index 10e2e38ec5cd9..7b945f0873113 100644 --- a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java +++ b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * 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,19 @@ public final class UnicodeArgsTest { @Parameter("false") @Test public void test8246042(boolean onCommandLine) { - final String testString = new String(Character.toChars(0x00E9)); + final String testString; + + String encoding = System.getProperty("native.encoding"); + switch (encoding) { + default: + testString = new String(Character.toChars(0x00E9)); + break; + + case "MS932": + case "SJIS": + testString = new String(Character.toChars(0x3042)); + break; + } TKit.trace(String.format("Test string code points: %s", testString .codePoints() From 43f64d1a2298adf94068f90a58395cecc190b39b Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 09:15:00 +0000 Subject: [PATCH 128/341] 8271893: mark hotspot runtime/PerfMemDestroy/PerfMemDestroy.java test as ignoring external VM flags Backport-of: 359c7084a1bc3a568c9b815debe3c1786eca9d1e --- test/hotspot/jtreg/runtime/PerfMemDestroy/PerfMemDestroy.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/PerfMemDestroy/PerfMemDestroy.java b/test/hotspot/jtreg/runtime/PerfMemDestroy/PerfMemDestroy.java index a2e3362644ed4..2040c755576e8 100644 --- a/test/hotspot/jtreg/runtime/PerfMemDestroy/PerfMemDestroy.java +++ b/test/hotspot/jtreg/runtime/PerfMemDestroy/PerfMemDestroy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8030955 * @summary Allow multiple calls to PerfMemory::destroy() without asserting. + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management From d2f4ac1f8e8c441b7d2fd20fdd5dac65ba7e23c7 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 09:17:01 +0000 Subject: [PATCH 129/341] 8271905: mark hotspot runtime/Metaspace tests which ignore external VM flags Backport-of: 3ab95d19174100f440e2274d5b2c3119fb55e9e1 --- .../jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java | 1 + test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java index 1ee578755880d..eb8698295f92a 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java +++ b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeEnvVarTest.java @@ -25,6 +25,7 @@ * @test * @bug 8260349 * @summary test that setting via the env-var and options file shows up as expected + * @requires vm.flagless * @library /test/lib * @run driver MaxMetaspaceSizeEnvVarTest */ diff --git a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java index fd589cba0a0f8..32aaa34db50b6 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java +++ b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ /* * @test MaxMetaspaceSizeTest * @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true + * @requires vm.flagless * @bug 8087291 * @library /test/lib * @run driver MaxMetaspaceSizeTest From e96105a561b71c4a7e79339d70156e33c306e938 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 09:23:18 +0000 Subject: [PATCH 130/341] 8271904: mark hotspot runtime/ClassFile tests which ignore external VM flags Backport-of: e882087f7abb21eb776af8c14bc62e7624ebb7f3 --- test/hotspot/jtreg/runtime/ClassFile/FormatCheckingTest.java | 3 ++- test/hotspot/jtreg/runtime/ClassFile/JsrRewriting.java | 1 + .../jtreg/runtime/ClassFile/OomWhileParsingRepeatedJsr.java | 1 + .../hotspot/jtreg/runtime/ClassFile/TestCheckedExceptions.java | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/ClassFile/FormatCheckingTest.java b/test/hotspot/jtreg/runtime/ClassFile/FormatCheckingTest.java index a4655915d3655..0ff1f0a65be01 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/FormatCheckingTest.java +++ b/test/hotspot/jtreg/runtime/ClassFile/FormatCheckingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8148854 * @summary Ensure class name loaded by app class loader is format checked by default + * @requires vm.flagless * @library /test/lib * @compile BadHelloWorld.jcod * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/runtime/ClassFile/JsrRewriting.java b/test/hotspot/jtreg/runtime/ClassFile/JsrRewriting.java index 5f52754d598a1..92a9c74c2761a 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/JsrRewriting.java +++ b/test/hotspot/jtreg/runtime/ClassFile/JsrRewriting.java @@ -32,6 +32,7 @@ * @bug 7053586 * @bug 7185550 * @bug 7149464 + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.desktop diff --git a/test/hotspot/jtreg/runtime/ClassFile/OomWhileParsingRepeatedJsr.java b/test/hotspot/jtreg/runtime/ClassFile/OomWhileParsingRepeatedJsr.java index d63be2c41afb4..3f1d04c3d6dd0 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/OomWhileParsingRepeatedJsr.java +++ b/test/hotspot/jtreg/runtime/ClassFile/OomWhileParsingRepeatedJsr.java @@ -33,6 +33,7 @@ * @bug 7037122 * @bug 7123945 * @bug 8016029 + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.desktop diff --git a/test/hotspot/jtreg/runtime/ClassFile/TestCheckedExceptions.java b/test/hotspot/jtreg/runtime/ClassFile/TestCheckedExceptions.java index bbe905d1b2d58..a6f64e96bb66c 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/TestCheckedExceptions.java +++ b/test/hotspot/jtreg/runtime/ClassFile/TestCheckedExceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ * clause does not cause the JVM to assert nor throw an exception. * Also, test that logging can be used to print a message about bogus * classes in method throws clauses. + * @requires vm.flagless * @library /test/lib * @compile CheckedExceptions.jcod * @run driver TestCheckedExceptions From 43240a8e98573c30f8d29a593a966220a62ec638 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 09:25:30 +0000 Subject: [PATCH 131/341] 8272099: mark hotspot runtime/Monitor tests which ignore external VM flags Backport-of: c495ede2c2df405e6eec0e205cd67401d7826c4c --- .../jtreg/runtime/Monitor/MonitorUsedDeflationThresholdTest.java | 1 + .../hotspot/jtreg/runtime/Monitor/SyncOnValueBasedClassTest.java | 1 + 2 files changed, 2 insertions(+) diff --git a/test/hotspot/jtreg/runtime/Monitor/MonitorUsedDeflationThresholdTest.java b/test/hotspot/jtreg/runtime/Monitor/MonitorUsedDeflationThresholdTest.java index 0a6b602faf8ab..5dd01e4262bcd 100644 --- a/test/hotspot/jtreg/runtime/Monitor/MonitorUsedDeflationThresholdTest.java +++ b/test/hotspot/jtreg/runtime/Monitor/MonitorUsedDeflationThresholdTest.java @@ -29,6 +29,7 @@ * @test * @bug 8226416 * @summary Test the MonitorUsedDeflationThreshold and NoAsyncDeflationProgressMax options. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver MonitorUsedDeflationThresholdTest diff --git a/test/hotspot/jtreg/runtime/Monitor/SyncOnValueBasedClassTest.java b/test/hotspot/jtreg/runtime/Monitor/SyncOnValueBasedClassTest.java index e095594333eda..6caff48bd8ffc 100644 --- a/test/hotspot/jtreg/runtime/Monitor/SyncOnValueBasedClassTest.java +++ b/test/hotspot/jtreg/runtime/Monitor/SyncOnValueBasedClassTest.java @@ -30,6 +30,7 @@ * @test * @bug 8242263 * @summary Exercise DiagnoseSyncOnValueBasedClasses diagnostic flag + * @requires vm.flagless * @library /test/lib * @run driver/timeout=180000 SyncOnValueBasedClassTest */ From 1f868146b6558abc2e62ef26c4ea6b974fd01cc8 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 09:27:14 +0000 Subject: [PATCH 132/341] 8272551: mark hotspot runtime/modules tests which ignore external VM flags Backport-of: fe7219710243dbb3b5bc4ad6ef3e93d0d203d4f7 --- .../jtreg/runtime/modules/ClassLoaderNoUnnamedModuleTest.java | 1 + .../jtreg/runtime/modules/IgnoreModulePropertiesTest.java | 1 + test/hotspot/jtreg/runtime/modules/ModuleOptionsTest.java | 3 ++- test/hotspot/jtreg/runtime/modules/ModuleOptionsWarn.java | 3 ++- .../runtime/modules/ModuleStress/ExportModuleStressTest.java | 3 ++- .../jtreg/runtime/modules/ModuleStress/ModuleStress.java | 1 + .../jtreg/runtime/modules/ModuleStress/ModuleStressGC.java | 1 + test/hotspot/jtreg/runtime/modules/ModulesSymLink.java | 1 + .../jtreg/runtime/modules/PatchModule/PatchModule2Dirs.java | 1 + .../jtreg/runtime/modules/PatchModule/PatchModuleCDS.java | 1 + .../runtime/modules/PatchModule/PatchModuleDupJavaBase.java | 3 ++- .../runtime/modules/PatchModule/PatchModuleDupModule.java | 3 ++- .../jtreg/runtime/modules/PatchModule/PatchModuleJavaBase.java | 1 + .../jtreg/runtime/modules/PatchModule/PatchModuleTest.java | 1 + .../jtreg/runtime/modules/PatchModule/PatchModuleTestJar.java | 1 + .../runtime/modules/PatchModule/PatchModuleTestJarDir.java | 1 + .../jtreg/runtime/modules/PatchModule/PatchModuleTraceCL.java | 1 + .../runtime/modules/Visibility/PatchModuleVisibility.java | 1 + .../jtreg/runtime/modules/Visibility/XbootcpNoVisibility.java | 1 + .../jtreg/runtime/modules/Visibility/XbootcpVisibility.java | 1 + 20 files changed, 25 insertions(+), 5 deletions(-) diff --git a/test/hotspot/jtreg/runtime/modules/ClassLoaderNoUnnamedModuleTest.java b/test/hotspot/jtreg/runtime/modules/ClassLoaderNoUnnamedModuleTest.java index f82085e9ce403..91017b3070218 100644 --- a/test/hotspot/jtreg/runtime/modules/ClassLoaderNoUnnamedModuleTest.java +++ b/test/hotspot/jtreg/runtime/modules/ClassLoaderNoUnnamedModuleTest.java @@ -25,6 +25,7 @@ * @test * @bug 8202758 * @summary Ensure that if the JVM encounters a ClassLoader whose unnamedModule field is not set an InternalError results. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile ClassLoaderNoUnnamedModule.java diff --git a/test/hotspot/jtreg/runtime/modules/IgnoreModulePropertiesTest.java b/test/hotspot/jtreg/runtime/modules/IgnoreModulePropertiesTest.java index 8df2e90844394..a3c9c8ac6eeb7 100644 --- a/test/hotspot/jtreg/runtime/modules/IgnoreModulePropertiesTest.java +++ b/test/hotspot/jtreg/runtime/modules/IgnoreModulePropertiesTest.java @@ -25,6 +25,7 @@ * @test * @bug 8136930 * @summary Test that the VM ignores explicitly specified module internal properties. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver IgnoreModulePropertiesTest diff --git a/test/hotspot/jtreg/runtime/modules/ModuleOptionsTest.java b/test/hotspot/jtreg/runtime/modules/ModuleOptionsTest.java index 3f9894ddf08cb..140b910391051 100644 --- a/test/hotspot/jtreg/runtime/modules/ModuleOptionsTest.java +++ b/test/hotspot/jtreg/runtime/modules/ModuleOptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @bug 8136930 * @summary Test that the VM only recognizes the last specified --list-modules * options but accumulates --add-module values. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver ModuleOptionsTest diff --git a/test/hotspot/jtreg/runtime/modules/ModuleOptionsWarn.java b/test/hotspot/jtreg/runtime/modules/ModuleOptionsWarn.java index 5920e6f4be336..5e6b526b5a319 100644 --- a/test/hotspot/jtreg/runtime/modules/ModuleOptionsWarn.java +++ b/test/hotspot/jtreg/runtime/modules/ModuleOptionsWarn.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8162415 * @summary Test warnings for ignored properties. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver ModuleOptionsWarn diff --git a/test/hotspot/jtreg/runtime/modules/ModuleStress/ExportModuleStressTest.java b/test/hotspot/jtreg/runtime/modules/ModuleStress/ExportModuleStressTest.java index 778a14bd5ed80..ce9246e83c6d1 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, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8156871 * @summary package in the boot layer is repeatedly exported to unique module created in layers on top of the boot layer + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile ../CompilerUtils.java diff --git a/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStress.java b/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStress.java index edf53e4c8f678..bc23a0383abe0 100644 --- a/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStress.java +++ b/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStress.java @@ -25,6 +25,7 @@ * @test * @bug 8159262 * @summary Test differing scenarios where a module's readability list and a package's exportability list should be walked + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile ../AccessCheck/ModuleLibrary.java diff --git a/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStressGC.java b/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStressGC.java index 1e34e7158130f..05b9cf7c2ef99 100644 --- a/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStressGC.java +++ b/test/hotspot/jtreg/runtime/modules/ModuleStress/ModuleStressGC.java @@ -25,6 +25,7 @@ * @test * @bug 8159262 * @summary layers over the boot layer are repeatedly created, during this iteration, GCs are forced to verify correct walk of module and package lists. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile ../CompilerUtils.java diff --git a/test/hotspot/jtreg/runtime/modules/ModulesSymLink.java b/test/hotspot/jtreg/runtime/modules/ModulesSymLink.java index 8cb4679b31c30..5dcbc31546602 100644 --- a/test/hotspot/jtreg/runtime/modules/ModulesSymLink.java +++ b/test/hotspot/jtreg/runtime/modules/ModulesSymLink.java @@ -28,6 +28,7 @@ * @summary Test with symbolic linked lib/modules * @bug 8220095 * @requires os.family == "linux" | os.family == "mac" + * @requires vm.flagless * @library /test/lib * @modules java.management * jdk.jlink diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModule2Dirs.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModule2Dirs.java index 7818a2989f85c..b582314411da4 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModule2Dirs.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModule2Dirs.java @@ -24,6 +24,7 @@ /* * @test * @summary Make sure --patch-module works with multiple directories. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile PatchModule2DirsMain.java diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleCDS.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleCDS.java index d081be2e6fdaa..109f6cf2616f8 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleCDS.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleCDS.java @@ -25,6 +25,7 @@ * @test * @requires vm.cds * @summary test that --patch-module works with CDS + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.jartool/sun.tools.jar diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupJavaBase.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupJavaBase.java index 0d41e199735cc..a256a1f6c8583 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, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * 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 * @summary VM exit initialization results if java.base is specificed more than once to --patch-module. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver PatchModuleDupJavaBase diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupModule.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleDupModule.java index d310124b7f138..a454dcb152781 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, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * 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 * @summary Module system initialization exception results if a module is specificed twice to --patch-module. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver PatchModuleDupModule diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleJavaBase.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleJavaBase.java index 8ab91e6670ede..58aef0fb87766 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleJavaBase.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleJavaBase.java @@ -25,6 +25,7 @@ * @test * @bug 8130399 * @summary Make sure --patch-module works for java.base. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile PatchModuleMain.java diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTest.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTest.java index b0eb7f25ef3a6..045f156c9d8a3 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTest.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTest.java @@ -25,6 +25,7 @@ * @test * @bug 8130399 * @summary Make sure --patch-module works for modules besides java.base. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile PatchModuleMain.java diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJar.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJar.java index 6f343e9c24a99..ed9e2b0ea8be5 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJar.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJar.java @@ -24,6 +24,7 @@ /* * @test * @summary Make sure --patch-module works when a jar file is specified for a module + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.jartool/sun.tools.jar diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJarDir.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJarDir.java index 344db7db5e182..2b2952b1e2347 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJarDir.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTestJarDir.java @@ -24,6 +24,7 @@ /* * @test * @summary Make sure --patch-module works when a jar file and a directory is specified for a module + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * jdk.jartool/sun.tools.jar diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTraceCL.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTraceCL.java index 5f89955c422fc..f98f85cce9a5a 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTraceCL.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleTraceCL.java @@ -26,6 +26,7 @@ * @bug 8069469 * @summary Make sure -Xlog:class+load=info works properly with "modules" jimage, --patch-module, and with -Xbootclasspath/a + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile PatchModuleMain.java diff --git a/test/hotspot/jtreg/runtime/modules/Visibility/PatchModuleVisibility.java b/test/hotspot/jtreg/runtime/modules/Visibility/PatchModuleVisibility.java index bbabd09bf80db..f11d52b46f0ab 100644 --- a/test/hotspot/jtreg/runtime/modules/Visibility/PatchModuleVisibility.java +++ b/test/hotspot/jtreg/runtime/modules/Visibility/PatchModuleVisibility.java @@ -26,6 +26,7 @@ * @summary Ensure that a newly introduced java.base package placed within the --patch-module * directory is considered part of the boot loader's visibility boundary * @requires !(os.family == "windows") + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpNoVisibility.java b/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpNoVisibility.java index 6a19832aa042d..9d10fe6488c43 100644 --- a/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpNoVisibility.java +++ b/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpNoVisibility.java @@ -25,6 +25,7 @@ * @test * @summary Ensure that a class defined within a java.base package can not * be located via -Xbootclasspath/a + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpVisibility.java b/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpVisibility.java index a4e0760cdebe6..df20c356c92e1 100644 --- a/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpVisibility.java +++ b/test/hotspot/jtreg/runtime/modules/Visibility/XbootcpVisibility.java @@ -26,6 +26,7 @@ * @summary Ensure that a package whose module has not been defined to the boot loader * is correctly located with -Xbootclasspath/a * @requires !(os.family == "windows") + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management From ef0fc3ea9463b6e1723715506de9867be580c6d3 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 09:29:22 +0000 Subject: [PATCH 133/341] 8271073: Improve testing with VM option VerifyArchivedFields Reviewed-by: lucy Backport-of: b98290444a4594d0164d6f313c506287282d1929 --- src/hotspot/share/cds/heapShared.cpp | 25 +++++---- src/hotspot/share/gc/shared/gc_globals.hpp | 8 ++- .../jtreg/runtime/cds/appcds/TestCommon.java | 2 + .../cacheObject/VerifyArchivedFields.java | 53 +++++++++++++++++++ test/lib/jdk/test/lib/cds/CDSTestUtils.java | 7 +++ 5 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/cacheObject/VerifyArchivedFields.java diff --git a/src/hotspot/share/cds/heapShared.cpp b/src/hotspot/share/cds/heapShared.cpp index 3e50dd7506b27..709282028a265 100644 --- a/src/hotspot/share/cds/heapShared.cpp +++ b/src/hotspot/share/cds/heapShared.cpp @@ -658,7 +658,7 @@ void HeapShared::serialize_subgraph_info_table_header(SerializeClosure* soc) { } static void verify_the_heap(Klass* k, const char* which) { - if (VerifyArchivedFields) { + if (VerifyArchivedFields > 0) { ResourceMark rm; log_info(cds, heap)("Verify heap %s initializing static field(s) in %s", which, k->external_name()); @@ -666,15 +666,20 @@ static void verify_the_heap(Klass* k, const char* which) { VM_Verify verify_op; VMThread::execute(&verify_op); - if (!FLAG_IS_DEFAULT(VerifyArchivedFields)) { - // If VerifyArchivedFields has a non-default value (e.g., specified on the command-line), do - // more expensive checks. - if (is_init_completed()) { - FlagSetting fs1(VerifyBeforeGC, true); - FlagSetting fs2(VerifyDuringGC, true); - FlagSetting fs3(VerifyAfterGC, true); - Universe::heap()->collect(GCCause::_java_lang_system_gc); - } + if (VerifyArchivedFields > 1 && is_init_completed()) { + // At this time, the oop->klass() of some archived objects in the heap may not + // have been loaded into the system dictionary yet. Nevertheless, oop->klass() should + // have enough information (object size, oop maps, etc) so that a GC can be safely + // performed. + // + // -XX:VerifyArchivedFields=2 force a GC to happen in such an early stage + // to check for GC safety. + log_info(cds, heap)("Trigger GC %s initializing static field(s) in %s", + which, k->external_name()); + FlagSetting fs1(VerifyBeforeGC, true); + FlagSetting fs2(VerifyDuringGC, true); + FlagSetting fs3(VerifyAfterGC, true); + Universe::heap()->collect(GCCause::_java_lang_system_gc); } } } diff --git a/src/hotspot/share/gc/shared/gc_globals.hpp b/src/hotspot/share/gc/shared/gc_globals.hpp index 5146a5484cf7b..41a3f9f46d1fd 100644 --- a/src/hotspot/share/gc/shared/gc_globals.hpp +++ b/src/hotspot/share/gc/shared/gc_globals.hpp @@ -524,8 +524,12 @@ product(bool, VerifyDuringGC, false, DIAGNOSTIC, \ "Verify memory system during GC (between phases)") \ \ - product(bool, VerifyArchivedFields, trueInDebug, DIAGNOSTIC, \ - "Verify memory when archived oop fields are loaded from CDS)") \ + product(int, VerifyArchivedFields, 0, DIAGNOSTIC, \ + "Verify memory when archived oop fields are loaded from CDS; " \ + "0: No check; " \ + "1: Basic verification with VM_Verify (no side effects); " \ + "2: Detailed verification by forcing a GC (with side effects)") \ + range(0, 2) \ \ product(ccstrlist, VerifyGCType, "", DIAGNOSTIC, \ "GC type(s) to verify when Verify*GC is enabled." \ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java b/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java index 24b957b31bf49..c540a23e01ee8 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java @@ -412,6 +412,8 @@ public static OutputAnalyzer runWithArchive(AppCDSOptions opts) cmd.add(opts.appJar); } + CDSTestUtils.addVerifyArchivedFields(cmd); + for (String s : opts.suffix) cmd.add(s); if (RUN_WITH_JFR) { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/VerifyArchivedFields.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/VerifyArchivedFields.java new file mode 100644 index 0000000000000..80eebf60811c1 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/VerifyArchivedFields.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * 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 run with -XX:VerifyArchivedFields=2 for more expensive verification + * of the archived heap objects. + * @requires vm.cds.write.archived.java.heap + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes + * @build Hello + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar Hello.jar Hello + * @run driver VerifyArchivedFields + */ + +import jdk.test.lib.helpers.ClassFileInstaller; + +public class VerifyArchivedFields { + // Note: -XX:VerifyArchivedFields=2 will force a GC every time when + // HeapShared::initialize_from_archived_subgraph(Klass* k, ...) is called. This ensures + // that it's safe to do a GC even when the oop->klass() of some archived heap objects + // are not yet loaded into the system dictionary. + public static void main(String[] args) throws Exception { + TestCommon.test(ClassFileInstaller.getJarPath("Hello.jar"), + TestCommon.list("Hello"), + "-XX:+UnlockDiagnosticVMOptions", + "-XX:VerifyArchivedFields=2", + "-Xlog:cds=debug", + "-Xlog:cds+heap=debug", + "-Xlog:gc*=debug", + "Hello"); + } +} diff --git a/test/lib/jdk/test/lib/cds/CDSTestUtils.java b/test/lib/jdk/test/lib/cds/CDSTestUtils.java index 5dceac0afbdee..9840da9fa89cb 100644 --- a/test/lib/jdk/test/lib/cds/CDSTestUtils.java +++ b/test/lib/jdk/test/lib/cds/CDSTestUtils.java @@ -399,6 +399,12 @@ public static OutputAnalyzer runWithArchive(String... cliPrefix) .addPrefix(cliPrefix) ); } + // Enable basic verification (VerifyArchivedFields=1, no side effects) for all CDS + // tests to make sure the archived heap objects are mapped/loaded properly. + public static void addVerifyArchivedFields(ArrayList cmd) { + cmd.add("-XX:+UnlockDiagnosticVMOptions"); + cmd.add("-XX:VerifyArchivedFields=1"); + } // Execute JVM with CDS archive, specify CDSOptions public static OutputAnalyzer runWithArchive(CDSOptions opts) @@ -416,6 +422,7 @@ public static OutputAnalyzer runWithArchive(CDSOptions opts) opts.archiveName = getDefaultArchiveName(); cmd.add("-XX:SharedArchiveFile=" + opts.archiveName); } + addVerifyArchivedFields(cmd); if (opts.useVersion) cmd.add("-version"); From 11639f7acb433db57603ac83a0e2b463c7540833 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 09:31:26 +0000 Subject: [PATCH 134/341] 8202790: DnD test DisposeFrameOnDragTest.java does not clean up Backport-of: 102a305f73d52d8e378de46c3c0b170db0f2c8af --- test/jdk/ProblemList.txt | 1 - .../DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 99d31ec74c450..93f50d5c750c3 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -464,7 +464,6 @@ java/awt/JAWT/JAWT.sh 8197798 windows-all,linux-all java/awt/Debug/DumpOnKey/DumpOnKey.java 8202667 windows-all java/awt/Focus/WindowUpdateFocusabilityTest/WindowUpdateFocusabilityTest.java 8202926 linux-all java/awt/datatransfer/ConstructFlavoredObjectTest/ConstructFlavoredObjectTest.java 8202860 linux-all -java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java 8202790 macosx-all,linux-all java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.java 8202882,8255898 linux-all,macosx-all java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java 8202931 macosx-all,linux-all java/awt/Focus/NonFocusableBlockedOwnerTest/NonFocusableBlockedOwnerTest.java 7124275 macosx-all diff --git a/test/jdk/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java b/test/jdk/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java index 33d666b3c071c..f4003858e3f86 100644 --- a/test/jdk/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java +++ b/test/jdk/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java @@ -49,6 +49,7 @@ public class DisposeFrameOnDragTest { private static JTextArea textArea; + private static JFrame background; public static void main(String[] args) throws Throwable { @@ -72,14 +73,20 @@ public void run() { Util.drag(testRobot, new Point((int) loc.x + 3, (int) loc.y + 3), new Point((int) loc.x + 40, (int) loc.y + 40), - InputEvent.BUTTON1_MASK); + InputEvent.BUTTON1_DOWN_MASK); Util.waitForIdle(testRobot); testRobot.delay(200); + background.dispose(); } private static void constructTestUI() { + background = new JFrame("Background"); + background.setBounds(100, 100, 100, 100); + background.setUndecorated(true); + background.setVisible(true); + final JFrame frame = new JFrame("Test frame"); textArea = new JTextArea("Drag Me!"); try { From c70d9b08c11a951a59db1c0ff18414b3f519c2cb Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 11:46:34 +0000 Subject: [PATCH 135/341] 8286474: Drop --enable-preview from Sealed Classes related tests Backport-of: d547a707bf1f9e252213fdab7eaf076b5cf884b4 --- .../reflect/sealed_classes/SealedClassesReflectionTest.java | 6 +++--- .../reflect/sealed_classes/TestSecurityManagerChecks.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/jdk/java/lang/reflect/sealed_classes/SealedClassesReflectionTest.java b/test/jdk/java/lang/reflect/sealed_classes/SealedClassesReflectionTest.java index 27d20567464f8..03caebb49e8f3 100644 --- a/test/jdk/java/lang/reflect/sealed_classes/SealedClassesReflectionTest.java +++ b/test/jdk/java/lang/reflect/sealed_classes/SealedClassesReflectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * 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,8 +25,8 @@ * @test * @bug 8227046 * @summary reflection test for sealed classes - * @compile --enable-preview -source ${jdk.version} SealedClassesReflectionTest.java - * @run testng/othervm --enable-preview SealedClassesReflectionTest + * @compile SealedClassesReflectionTest.java + * @run testng/othervm SealedClassesReflectionTest */ import java.lang.annotation.*; diff --git a/test/jdk/java/lang/reflect/sealed_classes/TestSecurityManagerChecks.java b/test/jdk/java/lang/reflect/sealed_classes/TestSecurityManagerChecks.java index 0b9508702d0fc..a45a3f122d1ca 100644 --- a/test/jdk/java/lang/reflect/sealed_classes/TestSecurityManagerChecks.java +++ b/test/jdk/java/lang/reflect/sealed_classes/TestSecurityManagerChecks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,8 +28,8 @@ * @library /test/lib * @modules java.compiler * @build jdk.test.lib.compiler.CompilerUtils jdk.test.lib.compiler.ModuleInfoMaker TestSecurityManagerChecks - * @run main/othervm -Djava.security.manager=allow --enable-preview TestSecurityManagerChecks named - * @run main/othervm -Djava.security.manager=allow --enable-preview TestSecurityManagerChecks unnamed + * @run main/othervm -Djava.security.manager=allow TestSecurityManagerChecks named + * @run main/othervm -Djava.security.manager=allow TestSecurityManagerChecks unnamed */ import java.io.IOException; From df411a8151c92b508c3535f8299918329a8e15b2 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 11:48:56 +0000 Subject: [PATCH 136/341] 8285867: Convert applet manual tests SelectionVisible.java to Frame and automate Backport-of: 44a60ce1724dc3e39faf1d7a68de2e6376894534 --- .../SelectionVisible/SelectionVisible.html | 42 ---------- .../SelectionVisible/SelectionVisible.java | 76 ++++++++++++------- .../SelectionVisible/SelectionVisible.html | 42 ---------- .../SelectionVisible/SelectionVisible.java | 72 +++++++++++------- 4 files changed, 91 insertions(+), 141 deletions(-) delete mode 100644 test/jdk/java/awt/TextArea/SelectionVisible/SelectionVisible.html delete mode 100644 test/jdk/java/awt/TextField/SelectionVisible/SelectionVisible.html diff --git a/test/jdk/java/awt/TextArea/SelectionVisible/SelectionVisible.html b/test/jdk/java/awt/TextArea/SelectionVisible/SelectionVisible.html deleted file mode 100644 index efa092ba9cc4a..0000000000000 --- a/test/jdk/java/awt/TextArea/SelectionVisible/SelectionVisible.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - SelectionVisible - - - -

SelectionVisible
Bugid: 4082144

- - - - diff --git a/test/jdk/java/awt/TextArea/SelectionVisible/SelectionVisible.java b/test/jdk/java/awt/TextArea/SelectionVisible/SelectionVisible.java index 08698d815c151..bcd48874597e7 100644 --- a/test/jdk/java/awt/TextArea/SelectionVisible/SelectionVisible.java +++ b/test/jdk/java/awt/TextArea/SelectionVisible/SelectionVisible.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,42 +21,62 @@ * questions. */ - -import java.applet.Applet; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Panel; +import java.awt.Frame; import java.awt.TextArea; +import java.lang.reflect.InvocationTargetException; + +import static java.awt.EventQueue.invokeAndWait; + +/* + @test + @key headful + @bug 4082144 7150100 + @summary Ensures that TextArea.select() works when called + before setVisible() + @run main SelectionVisible +*/ -public final class SelectionVisible extends Applet { +public class SelectionVisible { - private TextArea ta; + private static TextArea ta; + private static Frame frame; - @Override - public void init() { + public static void createTestUI() { + frame = new Frame("Test 4082144 7150100"); ta = new TextArea(4, 20); ta.setText("01234\n56789"); ta.select(3, 9); - final TextArea instruction = new TextArea("INSTRUCTIONS:\n" - + "The text 34567 should be selected in the TextArea.\n" - + "If this is what you observe, then the test passes.\n" - + "Otherwise, the test fails.", 40, 5, - TextArea.SCROLLBARS_NONE); - instruction.setEditable(false); - instruction.setPreferredSize(new Dimension(300, 70)); - final Panel panel = new Panel(); - panel.setLayout(new FlowLayout()); - panel.add(ta); - setLayout(new BorderLayout()); - add(instruction, BorderLayout.CENTER); - add(panel, BorderLayout.PAGE_END); - } + frame.add(ta); + frame.setLocationRelativeTo(null); + frame.pack(); + frame.setVisible(true); - @Override - public void start() { - setVisible(true); ta.requestFocus(); } + + public static void test() throws InterruptedException, + InvocationTargetException { + String selectedText = ta.getSelectedText(); + System.out.println("selectedText : " + selectedText); + invokeAndWait(SelectionVisible::disposeFrame); + if (!selectedText.equals("34\n567")) { + throw new RuntimeException("Expected '34\n567' to be " + + "selected text, but got " + selectedText); + } + System.out.println("Test passed"); + } + + public static void disposeFrame() { + if (frame != null) { + frame.dispose(); + } + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + invokeAndWait(SelectionVisible::createTestUI); + test(); + } + } diff --git a/test/jdk/java/awt/TextField/SelectionVisible/SelectionVisible.html b/test/jdk/java/awt/TextField/SelectionVisible/SelectionVisible.html deleted file mode 100644 index 31490d16f0bfd..0000000000000 --- a/test/jdk/java/awt/TextField/SelectionVisible/SelectionVisible.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - SelectionVisible - - - -

SelectionVisible
Bugid: 4082144

- - - - diff --git a/test/jdk/java/awt/TextField/SelectionVisible/SelectionVisible.java b/test/jdk/java/awt/TextField/SelectionVisible/SelectionVisible.java index cccec8eb347f6..913dc78126e3b 100644 --- a/test/jdk/java/awt/TextField/SelectionVisible/SelectionVisible.java +++ b/test/jdk/java/awt/TextField/SelectionVisible/SelectionVisible.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,43 +21,57 @@ * questions. */ - -import java.applet.Applet; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Panel; -import java.awt.TextArea; +import java.awt.Frame; import java.awt.TextField; +import java.lang.reflect.InvocationTargetException; + +import static java.awt.EventQueue.invokeAndWait; +/* + @test + @key headful + @bug 4082144 7150100 + @summary Ensures that TextField.select() works when called + before setVisible() + @run main SelectionVisible + */ -public final class SelectionVisible extends Applet { +public class SelectionVisible { - TextField tf; + private static Frame frame; + private static TextField tf; - @Override - public void init() { + public static void createTestUI() { + frame = new Frame("Test TextField.select()"); tf = new TextField(20); tf.setText("0123456789"); tf.select(0, 6); + frame.add(tf); + frame.setSize(200,200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void test() throws InterruptedException, + InvocationTargetException { + String selectedText = tf.getSelectedText(); + System.out.println("Selected Text : " + selectedText); + invokeAndWait(SelectionVisible::disposeFrame); + if (!selectedText.equals("012345")) { + throw new RuntimeException("Expected 012345 to be selected but " + + "got " + selectedText); + } + System.out.println("Test passed"); + } - final TextArea ta = new TextArea("INSTRUCTIONS:\n" - + "The text 012345 should be selected in the TextField.\n" - + "If this is what you observe, then the test passes.\n" - + "Otherwise, the test fails.", 40, 5, - TextArea.SCROLLBARS_NONE); - ta.setEditable(false); - ta.setPreferredSize(new Dimension(300, 70)); - final Panel panel = new Panel(); - panel.setLayout(new FlowLayout()); - panel.add(tf); - setLayout(new BorderLayout()); - add(ta, BorderLayout.CENTER); - add(panel, BorderLayout.PAGE_END); + private static void disposeFrame() { + if (frame != null) { + frame.dispose(); + } } - @Override - public void start() { - setVisible(true); - tf.requestFocus(); + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + invokeAndWait(SelectionVisible::createTestUI); + test(); } } From 04878e44582024a8ce33829dfcb34b42d230e9b3 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 12:08:33 +0000 Subject: [PATCH 137/341] 8286969: Add a new test library API to execute kinit in SecurityTools.java Backport-of: dbda0e2bda5d8ba86f068684941a05387947d993 --- test/lib/jdk/test/lib/SecurityTools.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/lib/jdk/test/lib/SecurityTools.java b/test/lib/jdk/test/lib/SecurityTools.java index e105c42d06d7b..ee786eb365c50 100644 --- a/test/lib/jdk/test/lib/SecurityTools.java +++ b/test/lib/jdk/test/lib/SecurityTools.java @@ -223,6 +223,18 @@ public static OutputAnalyzer klist(String args) throws Exception { return execute(getProcessBuilder("klist", makeList(args))); } + /** + * Runs kinit. + * + * @param args arguments to kinit in a single string. The string is + * converted to be List with makeList. + * @return an {@link OutputAnalyzer} object + * @throws Exception if there is an error + */ + public static OutputAnalyzer kinit(String args) throws Exception { + return execute(getProcessBuilder("kinit", makeList(args))); + } + /** * Runs jar. * From 80d12cc2fc4d267cf294b601b9576a7c7abd26c9 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 12:10:57 +0000 Subject: [PATCH 138/341] 8289584: (fs) Print size values in java/nio/file/FileStore/Basic.java when they differ by > 1GiB Backport-of: e291a67e96970d80a9915f8a23afffed6e0b8ded --- test/jdk/java/nio/file/FileStore/Basic.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/jdk/java/nio/file/FileStore/Basic.java b/test/jdk/java/nio/file/FileStore/Basic.java index 4a6bbabdc52f9..8c62565c9c4e3 100644 --- a/test/jdk/java/nio/file/FileStore/Basic.java +++ b/test/jdk/java/nio/file/FileStore/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. * 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,10 +57,13 @@ static void assertTrue(boolean okay) { throw new RuntimeException("Assertion failed"); } - static void checkWithin1GB(long value1, long value2) { - long diff = Math.abs(value1 - value2); - if (diff > G) - throw new RuntimeException("values differ by more than 1GB"); + static void checkWithin1GB(long expected, long actual) { + long diff = Math.abs(actual - expected); + if (diff > G) { + String msg = String.format("|actual %d - expected %d| = %d (%f G)", + actual, expected, diff, (float)diff/G); + throw new RuntimeException(msg); + } } static void doTests(Path dir) throws IOException { From 2ac844b23238fa017314e98ce860b389dfa51326 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Sep 2023 12:13:14 +0000 Subject: [PATCH 139/341] 8292381: java/net/httpclient/SpecialHeadersTest.java fails with "ERROR: Shutting down connection: HTTP/2 client stopped" Backport-of: 256b52387b7267c234f03aac19422e59a77d956f --- .../net/httpclient/HttpServerAdapters.java | 19 + .../net/httpclient/SpecialHeadersTest.java | 452 +++++++++++++----- 2 files changed, 347 insertions(+), 124 deletions(-) diff --git a/test/jdk/java/net/httpclient/HttpServerAdapters.java b/test/jdk/java/net/httpclient/HttpServerAdapters.java index b52d764c7da94..3029d374028b8 100644 --- a/test/jdk/java/net/httpclient/HttpServerAdapters.java +++ b/test/jdk/java/net/httpclient/HttpServerAdapters.java @@ -45,6 +45,7 @@ import java.util.List; import java.util.ListIterator; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; @@ -105,6 +106,16 @@ public static abstract class HttpTestRequestHeaders { public abstract Set>> entrySet(); public abstract List get(String name); public abstract boolean containsKey(String name); + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof HttpTestRequestHeaders other)) return false; + return Objects.equals(entrySet(), other.entrySet()); + } + @Override + public int hashCode() { + return Objects.hashCode(entrySet()); + } public static HttpTestRequestHeaders of(Headers headers) { return new Http1TestRequestHeaders(headers); @@ -138,6 +149,10 @@ public List get(String name) { public boolean containsKey(String name) { return headers.containsKey(name); } + @Override + public String toString() { + return String.valueOf(headers); + } } private static final class Http2TestRequestHeaders extends HttpTestRequestHeaders { private final HttpHeaders headers; @@ -160,6 +175,10 @@ public List get(String name) { public boolean containsKey(String name) { return headers.firstValue(name).isPresent(); } + @Override + public String toString() { + return String.valueOf(headers); + } } } diff --git a/test/jdk/java/net/httpclient/SpecialHeadersTest.java b/test/jdk/java/net/httpclient/SpecialHeadersTest.java index 0fdd86d9ad24c..abfd997acb026 100644 --- a/test/jdk/java/net/httpclient/SpecialHeadersTest.java +++ b/test/jdk/java/net/httpclient/SpecialHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. * 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,12 @@ import com.sun.net.httpserver.HttpsConfigurator; import com.sun.net.httpserver.HttpsServer; import jdk.test.lib.net.SimpleSSLContext; +import org.testng.ITestContext; +import org.testng.ITestResult; +import org.testng.SkipException; +import org.testng.annotations.AfterClass; import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -70,8 +75,20 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Function; +import java.util.stream.Collectors; + +import static java.lang.System.err; import static java.lang.System.out; import static java.net.http.HttpClient.Builder.NO_PROXY; import static java.net.http.HttpClient.Version.HTTP_2; @@ -140,6 +157,142 @@ public Object[][] variants() { } static final int ITERATION_COUNT = 3; // checks upgrade and re-use + // a shared executor helps reduce the amount of threads created by the test + static final TestExecutor executor = new TestExecutor(Executors.newCachedThreadPool()); + static final ConcurrentMap FAILURES = new ConcurrentHashMap<>(); + static volatile boolean tasksFailed; + static final AtomicLong serverCount = new AtomicLong(); + static final AtomicLong clientCount = new AtomicLong(); + static final long start = System.nanoTime(); + public static String now() { + long now = System.nanoTime() - start; + long secs = now / 1000_000_000; + long mill = (now % 1000_000_000) / 1000_000; + long nan = now % 1000_000; + return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); + } + + final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + private volatile HttpClient sharedClient; + + static class TestExecutor implements Executor { + final AtomicLong tasks = new AtomicLong(); + Executor executor; + TestExecutor(Executor executor) { + this.executor = executor; + } + + @Override + public void execute(Runnable command) { + long id = tasks.incrementAndGet(); + executor.execute(() -> { + try { + command.run(); + } catch (Throwable t) { + tasksFailed = true; + out.printf(now() + "Task %s failed: %s%n", id, t); + err.printf(now() + "Task %s failed: %s%n", id, t); + FAILURES.putIfAbsent("Task " + id, t); + throw t; + } + }); + } + + public void shutdown() throws InterruptedException { + if (executor instanceof ExecutorService service) { + service.shutdown(); + service.awaitTermination(1000, TimeUnit.MILLISECONDS); + } + } + + + } + + protected boolean stopAfterFirstFailure() { + return Boolean.getBoolean("jdk.internal.httpclient.debug"); + } + + final AtomicReference skiptests = new AtomicReference<>(); + void checkSkip() { + var skip = skiptests.get(); + if (skip != null) throw skip; + } + static String name(ITestResult result) { + var params = result.getParameters(); + return result.getName() + + (params == null ? "()" : Arrays.toString(result.getParameters())); + } + + @BeforeMethod + void beforeMethod(ITestContext context) { + if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { + if (skiptests.get() == null) { + SkipException skip = new SkipException("some tests failed"); + skip.setStackTrace(new StackTraceElement[0]); + skiptests.compareAndSet(null, skip); + } + } + } + + @AfterClass + static final void printFailedTests(ITestContext context) { + out.println("\n========================="); + var failed = context.getFailedTests().getAllResults().stream() + .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + FAILURES.putAll(failed); + try { + out.printf("%n%sCreated %d servers and %d clients%n", + now(), serverCount.get(), clientCount.get()); + if (FAILURES.isEmpty()) return; + out.println("Failed tests: "); + FAILURES.entrySet().forEach((e) -> { + out.printf("\t%s: %s%n", e.getKey(), e.getValue()); + e.getValue().printStackTrace(out); + }); + if (tasksFailed) { + out.println("WARNING: Some tasks failed"); + } + } finally { + out.println("\n=========================\n"); + } + } + + private HttpClient makeNewClient() { + clientCount.incrementAndGet(); + return HttpClient.newBuilder() + .proxy(NO_PROXY) + .executor(executor) + .sslContext(sslContext) + .build(); + } + + static volatile String lastMethod; + HttpClient newHttpClient(String method, boolean share) { + if (!share) return TRACKER.track(makeNewClient()); + HttpClient shared = sharedClient; + String last = lastMethod; + if (shared != null && Objects.equals(last, method)) return shared; + synchronized (this) { + shared = sharedClient; + last = lastMethod; + if (!Objects.equals(last, method)) { + // reset sharedClient to avoid side effects + // between methods. This is needed to keep the test + // expectation that the first HTTP/2 clear request + // will be an upgrade + if (shared != null) { + TRACKER.track(shared); + shared = sharedClient = null; + } + } + if (shared == null) { + shared = sharedClient = makeNewClient(); + last = lastMethod = method; + } + return shared; + } + } + static String userAgent() { return "Java-http-client/" + System.getProperty("java.version"); @@ -167,48 +320,54 @@ void test(String uriString, HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { - if (!sameClient || client == null) - client = HttpClient.newBuilder() - .proxy(NO_PROXY) - .sslContext(sslContext) - .build(); - - HttpRequest.Builder requestBuilder = HttpRequest.newBuilder(uri); - if (!useDefault) { - requestBuilder.header(name, value); - } - HttpRequest request = requestBuilder.build(); - HttpResponse resp = client.send(request, BodyHandlers.ofString()); - - out.println("Got response: " + resp); - out.println("Got body: " + resp.body()); - assertEquals(resp.statusCode(), 200, - "Expected 200, got:" + resp.statusCode()); - - boolean isInitialRequest = i == 0; - boolean isSecure = uri.getScheme().equalsIgnoreCase("https"); - boolean isHTTP2 = resp.version() == HTTP_2; - boolean isNotH2CUpgrade = isSecure || (sameClient == true && !isInitialRequest); - boolean isDefaultHostHeader = name.equalsIgnoreCase("host") && useDefault; - - // By default, HTTP/2 sets the `:authority:` pseudo-header, instead - // of the `Host` header. Therefore, there should be no "X-Host" - // header in the response, except the response to the h2c Upgrade - // request which will have been sent through HTTP/1.1. - - if (isDefaultHostHeader && isHTTP2 && isNotH2CUpgrade) { - assertTrue(resp.headers().firstValue("X-" + key).isEmpty()); - assertTrue(resp.headers().allValues("X-" + key).isEmpty()); - out.println("No X-" + key + " header received, as expected"); - } else { - String receivedHeaderString = value == null ? null - : resp.headers().firstValue("X-"+key).get(); - out.println("Got X-" + key + ": " + resp.headers().allValues("X-"+key)); - if (value != null) { - assertEquals(receivedHeaderString, value); - assertEquals(resp.headers().allValues("X-"+key), List.of(value)); + try { + if (!sameClient || client == null) + client = newHttpClient("test", sameClient); + + HttpRequest.Builder requestBuilder = HttpRequest.newBuilder(uri); + if (!useDefault) { + requestBuilder.header(name, value); + } + HttpRequest request = requestBuilder.build(); + HttpResponse resp = client.send(request, BodyHandlers.ofString()); + + out.println("Got response: " + resp); + out.println("Got body: " + resp.body()); + assertEquals(resp.statusCode(), 200, + "Expected 200, got:" + resp.statusCode()); + + boolean isInitialRequest = i == 0; + boolean isSecure = uri.getScheme().equalsIgnoreCase("https"); + boolean isHTTP2 = resp.version() == HTTP_2; + boolean isNotH2CUpgrade = isSecure || (sameClient == true && !isInitialRequest); + boolean isDefaultHostHeader = name.equalsIgnoreCase("host") && useDefault; + + // By default, HTTP/2 sets the `:authority:` pseudo-header, instead + // of the `Host` header. Therefore, there should be no "X-Host" + // header in the response, except the response to the h2c Upgrade + // request which will have been sent through HTTP/1.1. + + if (isDefaultHostHeader && isHTTP2 && isNotH2CUpgrade) { + assertTrue(resp.headers().firstValue("X-" + key).isEmpty()); + assertTrue(resp.headers().allValues("X-" + key).isEmpty()); + out.println("No X-" + key + " header received, as expected"); } else { - assertEquals(resp.headers().allValues("X-"+key).size(), 0); + String receivedHeaderString = value == null ? null + : resp.headers().firstValue("X-" + key).orElse(null); + out.println("Got X-" + key + ": " + resp.headers().allValues("X-" + key)); + if (value != null) { + assertEquals(receivedHeaderString, value); + assertEquals(resp.headers().allValues("X-" + key), List.of(value)); + } else { + assertEquals(resp.headers().allValues("X-" + key).size(), 0); + } + } + } finally { + if (!sameClient) { + client = null; + System.gc(); + var error = TRACKER.check(500); + if (error != null) throw error; } } } @@ -223,42 +382,61 @@ void testHomeMadeIllegalHeader(String uriString, out.println("\n--- Starting "); final URI uri = URI.create(uriString); - HttpClient client = HttpClient.newBuilder() - .proxy(NO_PROXY) - .sslContext(sslContext) - .build(); + HttpClient client = newHttpClient("testHomeMadeIllegalHeader", sameClient); - // Test a request which contains an illegal header created - HttpRequest req = new HttpRequest() { - @Override public Optional bodyPublisher() { - return Optional.of(BodyPublishers.noBody()); - } - @Override public String method() { - return "GET"; - } - @Override public Optional timeout() { - return Optional.empty(); - } - @Override public boolean expectContinue() { - return false; - } - @Override public URI uri() { - return uri; - } - @Override public Optional version() { - return Optional.empty(); + try { + // Test a request which contains an illegal header created + HttpRequest req = new HttpRequest() { + @Override + public Optional bodyPublisher() { + return Optional.of(BodyPublishers.noBody()); + } + + @Override + public String method() { + return "GET"; + } + + @Override + public Optional timeout() { + return Optional.empty(); + } + + @Override + public boolean expectContinue() { + return false; + } + + @Override + public URI uri() { + return uri; + } + + @Override + public Optional version() { + return Optional.empty(); + } + + @Override + public HttpHeaders headers() { + Map> map = Map.of("upgrade", List.of("http://foo.com")); + return HttpHeaders.of(map, (x, y) -> true); + } + }; + + try { + HttpResponse response = client.send(req, BodyHandlers.ofString()); + Assert.fail("Unexpected reply: " + response); + } catch (IllegalArgumentException ee) { + out.println("Got IAE as expected"); } - @Override public HttpHeaders headers() { - Map> map = Map.of("upgrade", List.of("http://foo.com")); - return HttpHeaders.of(map, (x, y) -> true); + } finally { + if (!sameClient) { + client = null; + System.gc(); + var error = TRACKER.check(500); + if (error != null) throw error; } - }; - - try { - HttpResponse response = client.send(req, BodyHandlers.ofString()); - Assert.fail("Unexpected reply: " + response); - } catch (IllegalArgumentException ee) { - out.println("Got IAE as expected"); } } @@ -276,52 +454,59 @@ void testAsync(String uriString, String headerNameAndValue, boolean sameClient) HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { - if (!sameClient || client == null) - client = HttpClient.newBuilder() - .proxy(NO_PROXY) - .sslContext(sslContext) - .build(); - - HttpRequest.Builder requestBuilder = HttpRequest.newBuilder(uri); - if (!useDefault) { - requestBuilder.header(name, value); - } - HttpRequest request = requestBuilder.build(); - - boolean isInitialRequest = i == 0; - boolean isSecure = uri.getScheme().equalsIgnoreCase("https"); - boolean isNotH2CUpgrade = isSecure || (sameClient == true && !isInitialRequest); - boolean isDefaultHostHeader = name.equalsIgnoreCase("host") && useDefault; - - client.sendAsync(request, BodyHandlers.ofString()) - .thenApply(response -> { - out.println("Got response: " + response); - out.println("Got body: " + response.body()); - assertEquals(response.statusCode(), 200); - return response;}) - .thenAccept(resp -> { - // By default, HTTP/2 sets the `:authority:` pseudo-header, instead - // of the `Host` header. Therefore, there should be no "X-Host" - // header in the response, except the response to the h2c Upgrade - // request which will have been sent through HTTP/1.1. - - if (isDefaultHostHeader && resp.version() == HTTP_2 && isNotH2CUpgrade) { - assertTrue(resp.headers().firstValue("X-" + key).isEmpty()); - assertTrue(resp.headers().allValues("X-" + key).isEmpty()); - out.println("No X-" + key + " header received, as expected"); - } else { - String receivedHeaderString = value == null ? null - : resp.headers().firstValue("X-"+key).get(); - out.println("Got X-" + key + ": " + resp.headers().allValues("X-"+key)); - if (value != null) { - assertEquals(receivedHeaderString, value); - assertEquals(resp.headers().allValues("X-" + key), List.of(value)); + try { + if (!sameClient || client == null) + client = newHttpClient("testAsync", sameClient); + + HttpRequest.Builder requestBuilder = HttpRequest.newBuilder(uri); + if (!useDefault) { + requestBuilder.header(name, value); + } + HttpRequest request = requestBuilder.build(); + + boolean isInitialRequest = i == 0; + boolean isSecure = uri.getScheme().equalsIgnoreCase("https"); + boolean isNotH2CUpgrade = isSecure || (sameClient == true && !isInitialRequest); + boolean isDefaultHostHeader = name.equalsIgnoreCase("host") && useDefault; + + client.sendAsync(request, BodyHandlers.ofString()) + .thenApply(response -> { + out.println("Got response: " + response); + out.println("Got body: " + response.body()); + assertEquals(response.statusCode(), 200); + return response; + }) + .thenAccept(resp -> { + // By default, HTTP/2 sets the `:authority:` pseudo-header, instead + // of the `Host` header. Therefore, there should be no "X-Host" + // header in the response, except the response to the h2c Upgrade + // request which will have been sent through HTTP/1.1. + + if (isDefaultHostHeader && resp.version() == HTTP_2 && isNotH2CUpgrade) { + assertTrue(resp.headers().firstValue("X-" + key).isEmpty()); + assertTrue(resp.headers().allValues("X-" + key).isEmpty()); + out.println("No X-" + key + " header received, as expected"); } else { - assertEquals(resp.headers().allValues("X-" + key).size(), 1); + String receivedHeaderString = value == null ? null + : resp.headers().firstValue("X-" + key).orElse(null); + out.println("Got X-" + key + ": " + resp.headers().allValues("X-" + key)); + if (value != null) { + assertEquals(receivedHeaderString, value); + assertEquals(resp.headers().allValues("X-" + key), List.of(value)); + } else { + assertEquals(resp.headers().allValues("X-" + key).size(), 1); + } } - } - }) - .join(); + }) + .join(); + } finally { + if (!sameClient) { + client = null; + System.gc(); + var error = TRACKER.check(500); + if (error != null) throw error; + } + } } } @@ -364,10 +549,27 @@ public void setup() throws Exception { @AfterTest public void teardown() throws Exception { - httpTestServer.stop(); - httpsTestServer.stop(); - http2TestServer.stop(); - https2TestServer.stop(); + HttpClient shared = sharedClient; + String sharedClientName = + shared == null ? null : shared.toString(); + if (shared != null) TRACKER.track(shared); + shared = sharedClient = null; + Thread.sleep(100); + AssertionError fail = TRACKER.check(500); + try { + httpTestServer.stop(); + httpsTestServer.stop(); + http2TestServer.stop(); + https2TestServer.stop(); + executor.shutdown(); + } finally { + if (fail != null) { + if (sharedClientName != null) { + err.println("Shared client name is: " + sharedClientName); + } + throw fail; + } + } } /** A handler that returns, as its body, the exact received request URI. @@ -379,9 +581,11 @@ static class HttpUriStringHandler implements HttpTestHandler { public void handle(HttpTestExchange t) throws IOException { URI uri = t.getRequestURI(); String uriString = uri.toString(); - out.println("Http1UriStringHandler received, uri: " + uriString); + out.println("HttpUriStringHandler received, uri: " + uriString); String query = uri.getQuery(); String headerName = query.substring(query.indexOf("=")+1).trim(); + out.println("HttpUriStringHandler received, headerName: " + headerName + + "\n\theaders: " + t.getRequestHeaders()); try (InputStream is = t.getRequestBody(); OutputStream os = t.getResponseBody()) { is.readAllBytes(); From 1d618a30ee57e5bfd4b98107a239b54de3d057bf Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 26 Sep 2023 06:45:55 +0000 Subject: [PATCH 140/341] 8271892: mark hotspot runtime/PrintStringTableStats/PrintStringTableStatsTest.java test as ignoring external VM flags Backport-of: 9654fd73cd72e12cdb6934727f251dddacc18654 --- .../PrintStringTableStats/PrintStringTableStatsTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/PrintStringTableStats/PrintStringTableStatsTest.java b/test/hotspot/jtreg/runtime/PrintStringTableStats/PrintStringTableStatsTest.java index f72a808889656..1425e3e6eb103 100644 --- a/test/hotspot/jtreg/runtime/PrintStringTableStats/PrintStringTableStatsTest.java +++ b/test/hotspot/jtreg/runtime/PrintStringTableStats/PrintStringTableStatsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ /* * @test PrintStringTableStatsTest * @bug 8211821 + * @requires vm.flagless * @library /test/lib * @run driver PrintStringTableStatsTest */ From 52962e4a4fccfbb67ad0ebef7ac0039351029707 Mon Sep 17 00:00:00 2001 From: Soumadipta Roy Date: Tue, 26 Sep 2023 14:39:59 +0000 Subject: [PATCH 141/341] 8315770: serviceability/sa/TestJmapCoreMetaspace.java should run with -XX:-VerifyDependencies Backport-of: 877731d2a20249ce4724a071ba2da1faa56daca4 --- test/hotspot/jtreg/serviceability/sa/TestJmapCore.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java index 1acb962c49480..e00cb43ddbbd4 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java @@ -73,6 +73,9 @@ public static void main(String[] args) throws Throwable { static void test(String type) throws Throwable { ProcessBuilder pb = ProcessTools.createTestJvm("-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. + Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "--show-version", TestJmapCore.class.getName(), type); // If we are going to force a core dump, apply "ulimit -c unlimited" if we can. From 04d0906153ba0f8e075c16223d786d7a85b4ad44 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 27 Sep 2023 07:00:16 +0000 Subject: [PATCH 142/341] 8311631: When multiple users run tools/jpackage/share/LicenseTest.java, Permission denied for writing /var/tmp/*.files Backport-of: acf28f4cd902d58587b0722094a60bd395f979e7 --- .../classes/jdk/jpackage/internal/resources/template.spec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.spec b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.spec index 8737e1c8ea5e7..3538d2776f85a 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.spec +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.spec @@ -30,9 +30,9 @@ Requires: PACKAGE_DEFAULT_DEPENDENCIES PACKAGE_CUSTOM_DEPENDENCIES #build time will substantially increase and it may require unpack200/system java to install %define __jar_repack %{nil} -%define package_filelist %{_tmppath}/%{name}.files -%define app_filelist %{_tmppath}/%{name}.app.files -%define filesystem_filelist %{_tmppath}/%{name}.filesystem.files +%define package_filelist %{_builddir}/%{name}.files +%define app_filelist %{_builddir}/%{name}.app.files +%define filesystem_filelist %{_builddir}/%{name}.filesystem.files %define default_filesystem / /opt /usr /usr/bin /usr/lib /usr/local /usr/local/bin /usr/local/lib From 084a7977599b14926ae82e0506827db722b07fce Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 07:30:16 +0000 Subject: [PATCH 143/341] 8272552: mark hotspot runtime/cds tests which ignore external VM flags Backport-of: 989f39f8106a22498053a4ca5f2becf8df5f2420 --- test/hotspot/jtreg/runtime/cds/MaxMetaspaceSize.java | 1 + test/hotspot/jtreg/runtime/cds/SharedStrings.java | 1 + test/hotspot/jtreg/runtime/cds/appcds/MoveJDKTest.java | 1 + .../jtreg/runtime/cds/appcds/VerifyWithDefaultArchive.java | 1 + .../appcds/cacheObject/ArchivedModuleWithCustomImageTest.java | 1 + .../jtreg/runtime/cds/appcds/jcmd/JCmdTestDynamicDump.java | 1 + 6 files changed, 6 insertions(+) diff --git a/test/hotspot/jtreg/runtime/cds/MaxMetaspaceSize.java b/test/hotspot/jtreg/runtime/cds/MaxMetaspaceSize.java index cbae5d22e3c3b..c59449d6b1c52 100644 --- a/test/hotspot/jtreg/runtime/cds/MaxMetaspaceSize.java +++ b/test/hotspot/jtreg/runtime/cds/MaxMetaspaceSize.java @@ -24,6 +24,7 @@ /** * @test * @requires vm.cds + * @requires vm.flagless * @bug 8067187 8200078 * @summary Testing CDS dumping with the -XX:MaxMetaspaceSize= option * @library /test/lib diff --git a/test/hotspot/jtreg/runtime/cds/SharedStrings.java b/test/hotspot/jtreg/runtime/cds/SharedStrings.java index 7a4e9813c3965..bda830401f05a 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedStrings.java +++ b/test/hotspot/jtreg/runtime/cds/SharedStrings.java @@ -26,6 +26,7 @@ * @summary Check to make sure that shared strings in the bootstrap CDS archive * are actually shared * @requires vm.cds.write.archived.java.heap + * @requires vm.flagless * @library /test/lib * @build SharedStringsWb jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/MoveJDKTest.java b/test/hotspot/jtreg/runtime/cds/appcds/MoveJDKTest.java index ba8acf0c9703e..c5ad8e53873a0 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/MoveJDKTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/MoveJDKTest.java @@ -27,6 +27,7 @@ * @summary Test that CDS still works when the JDK is moved to a new directory * @bug 8272345 * @requires vm.cds + * @requires vm.flagless * @comment This test doesn't work on Windows because it depends on symlinks * @requires os.family != "windows" * @library /test/lib diff --git a/test/hotspot/jtreg/runtime/cds/appcds/VerifyWithDefaultArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/VerifyWithDefaultArchive.java index 0ac2d0b8f15e3..aa65bb38b1cfe 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/VerifyWithDefaultArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/VerifyWithDefaultArchive.java @@ -26,6 +26,7 @@ * @test * @bug 8264337 * @summary test default cds archive when turning on VerifySharedSpaces + * @requires vm.flagless * @requires vm.cds * @library /test/lib * @run driver VerifyWithDefaultArchive diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java index 2b2115b847213..fbad2ed459f12 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedModuleWithCustomImageTest.java @@ -25,6 +25,7 @@ * @test * @summary Test archived module graph with custom runtime image * @requires vm.cds.write.archived.java.heap + * @requires vm.flagless * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @build jdk.test.whitebox.WhiteBox * @compile CheckArchivedModuleApp.java diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jcmd/JCmdTestDynamicDump.java b/test/hotspot/jtreg/runtime/cds/appcds/jcmd/JCmdTestDynamicDump.java index 6a988f0689b13..c745c866fbe3f 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jcmd/JCmdTestDynamicDump.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jcmd/JCmdTestDynamicDump.java @@ -27,6 +27,7 @@ * @bug 8259070 * @summary Test jcmd to dump dynamic shared archive. * @requires vm.cds + * @requires vm.flagless * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @modules jdk.jcmd/sun.tools.common:+open * @compile ../test-classes/Hello.java JCmdTestDumpBase.java From 919964a5677c6752e2ab59ed2e9c4ebd51c449aa Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 07:36:25 +0000 Subject: [PATCH 144/341] 8272291: mark hotspot runtime/logging tests which ignore external VM flags Backport-of: 05d64da7f32e5960550d5ec76fa2fba5c972d9b3 --- .../jtreg/runtime/logging/ClassInitializationTest.java | 1 + test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java | 3 ++- test/hotspot/jtreg/runtime/logging/ClassResolutionTest.java | 1 + test/hotspot/jtreg/runtime/logging/CompressedOopsTest.java | 5 +++-- test/hotspot/jtreg/runtime/logging/CondyIndyTest.java | 1 + test/hotspot/jtreg/runtime/logging/DefaultMethodsTest.java | 3 ++- test/hotspot/jtreg/runtime/logging/ExceptionsTest.java | 3 ++- test/hotspot/jtreg/runtime/logging/ItablesTest.java | 3 ++- .../hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java | 1 + test/hotspot/jtreg/runtime/logging/ModulesTest.java | 3 ++- test/hotspot/jtreg/runtime/logging/MonitorInflationTest.java | 3 ++- test/hotspot/jtreg/runtime/logging/MonitorMismatchTest.java | 1 + test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java | 3 ++- .../runtime/logging/ProtectionDomainVerificationTest.java | 1 + test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java | 1 + test/hotspot/jtreg/runtime/logging/SafepointTest.java | 3 ++- test/hotspot/jtreg/runtime/logging/StackWalkTest.java | 3 ++- test/hotspot/jtreg/runtime/logging/StartupTimeTest.java | 3 ++- test/hotspot/jtreg/runtime/logging/ThreadLoggingTest.java | 1 + test/hotspot/jtreg/runtime/logging/VMOperationTest.java | 3 ++- test/hotspot/jtreg/runtime/logging/VerificationTest.java | 3 ++- test/hotspot/jtreg/runtime/logging/VtablesTest.java | 3 ++- .../runtime/logging/loadLibraryTest/LoadLibraryTest.java | 1 + 23 files changed, 38 insertions(+), 15 deletions(-) diff --git a/test/hotspot/jtreg/runtime/logging/ClassInitializationTest.java b/test/hotspot/jtreg/runtime/logging/ClassInitializationTest.java index b88d3620f47d0..e4153a8f392ba 100644 --- a/test/hotspot/jtreg/runtime/logging/ClassInitializationTest.java +++ b/test/hotspot/jtreg/runtime/logging/ClassInitializationTest.java @@ -25,6 +25,7 @@ /* * @test ClassInitializationTest * @bug 8142976 + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile BadMap50.jasm diff --git a/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java b/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java index eadbc94a1bdee..3fd7695337733 100644 --- a/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java +++ b/test/hotspot/jtreg/runtime/logging/ClassLoadUnloadTest.java @@ -25,7 +25,7 @@ /* * @test ClassLoadUnloadTest * @bug 8142506 - * @requires vm.opt.final.ClassUnloading + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @library classes @@ -78,6 +78,7 @@ static ProcessBuilder exec(String... args) throws Exception { Collections.addAll(argsList, args); Collections.addAll(argsList, "-Xmn8m"); Collections.addAll(argsList, "-Dtest.class.path=" + System.getProperty("test.class.path", ".")); + Collections.addAll(argsList, "-XX:+ClassUnloading"); Collections.addAll(argsList, ClassUnloadTestMain.class.getName()); return ProcessTools.createJavaProcessBuilder(argsList); } diff --git a/test/hotspot/jtreg/runtime/logging/ClassResolutionTest.java b/test/hotspot/jtreg/runtime/logging/ClassResolutionTest.java index 770515bd12dc3..05155e5108fc1 100644 --- a/test/hotspot/jtreg/runtime/logging/ClassResolutionTest.java +++ b/test/hotspot/jtreg/runtime/logging/ClassResolutionTest.java @@ -25,6 +25,7 @@ /* * @test ClassResolutionTest * @bug 8144874 + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver ClassResolutionTest diff --git a/test/hotspot/jtreg/runtime/logging/CompressedOopsTest.java b/test/hotspot/jtreg/runtime/logging/CompressedOopsTest.java index c04734ebc4bd9..ee1a4997900af 100644 --- a/test/hotspot/jtreg/runtime/logging/CompressedOopsTest.java +++ b/test/hotspot/jtreg/runtime/logging/CompressedOopsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,8 @@ /* * @test * @bug 8149991 - * @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true + * @requires vm.bits == 64 + * @requires vm.flagless * @summary -Xlog:gc+heap+coops=info should have output from the code * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/runtime/logging/CondyIndyTest.java b/test/hotspot/jtreg/runtime/logging/CondyIndyTest.java index f04fcfa9cba84..f94f5e5cb2077 100644 --- a/test/hotspot/jtreg/runtime/logging/CondyIndyTest.java +++ b/test/hotspot/jtreg/runtime/logging/CondyIndyTest.java @@ -24,6 +24,7 @@ /* * @test * @summary Test -Xlog:methodhandles with a test that contains both a condy and indy. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile CondyIndyMathOperation.jasm diff --git a/test/hotspot/jtreg/runtime/logging/DefaultMethodsTest.java b/test/hotspot/jtreg/runtime/logging/DefaultMethodsTest.java index 1f5ed9b5f6e3c..2ea7e6bb07a35 100644 --- a/test/hotspot/jtreg/runtime/logging/DefaultMethodsTest.java +++ b/test/hotspot/jtreg/runtime/logging/DefaultMethodsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8139564 8203960 * @summary defaultmethods=debug should have logging from each of the statements in the code + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/ExceptionsTest.java b/test/hotspot/jtreg/runtime/logging/ExceptionsTest.java index ab61fb8b7c3af..976478253ee6d 100644 --- a/test/hotspot/jtreg/runtime/logging/ExceptionsTest.java +++ b/test/hotspot/jtreg/runtime/logging/ExceptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8141211 8147477 * @summary exceptions=info output should have an exception message for interpreter methods + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/ItablesTest.java b/test/hotspot/jtreg/runtime/logging/ItablesTest.java index fb94256bf9464..009986285a47b 100644 --- a/test/hotspot/jtreg/runtime/logging/ItablesTest.java +++ b/test/hotspot/jtreg/runtime/logging/ItablesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ * @summary itables=trace should have logging from each of the statements * in the code * @requires vm.debug + * @requires vm.flagless * @library /test/lib * @compile ClassB.java * ItablesVtableTest.java diff --git a/test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java b/test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java index 1de943cce1b04..eb7f0e1867b2c 100644 --- a/test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java +++ b/test/hotspot/jtreg/runtime/logging/LoaderConstraintsTest.java @@ -25,6 +25,7 @@ /* * @test LoaderConstraintsTest * @bug 8149996 + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib classes * @build test.Empty diff --git a/test/hotspot/jtreg/runtime/logging/ModulesTest.java b/test/hotspot/jtreg/runtime/logging/ModulesTest.java index 6ebb73cf20ff4..5d30fa3a6a4a9 100644 --- a/test/hotspot/jtreg/runtime/logging/ModulesTest.java +++ b/test/hotspot/jtreg/runtime/logging/ModulesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * 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 * @summary -Xlog:module should emit logging output + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/MonitorInflationTest.java b/test/hotspot/jtreg/runtime/logging/MonitorInflationTest.java index 568055617f9c6..85f025469b4e8 100644 --- a/test/hotspot/jtreg/runtime/logging/MonitorInflationTest.java +++ b/test/hotspot/jtreg/runtime/logging/MonitorInflationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8133885 * @summary monitorinflation=trace should have logging from each of the statements in the code + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/MonitorMismatchTest.java b/test/hotspot/jtreg/runtime/logging/MonitorMismatchTest.java index cf44ffdaa77d9..ac54ab8c2ca64 100644 --- a/test/hotspot/jtreg/runtime/logging/MonitorMismatchTest.java +++ b/test/hotspot/jtreg/runtime/logging/MonitorMismatchTest.java @@ -25,6 +25,7 @@ /* * @test MonitorMismatchTest * @bug 8150084 + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile MonitorMismatchHelper.jasm diff --git a/test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java b/test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java index 3ac25d9f2605a..bf6e3faed5987 100644 --- a/test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java +++ b/test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8151939 * @summary os+cpu output should contain some os,cpu information + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/ProtectionDomainVerificationTest.java b/test/hotspot/jtreg/runtime/logging/ProtectionDomainVerificationTest.java index 06f46b6eef5db..9d89de8b67b23 100644 --- a/test/hotspot/jtreg/runtime/logging/ProtectionDomainVerificationTest.java +++ b/test/hotspot/jtreg/runtime/logging/ProtectionDomainVerificationTest.java @@ -24,6 +24,7 @@ /* * @test ProtectionDomainVerificationTest * @bug 8149064 + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @run driver ProtectionDomainVerificationTest diff --git a/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java b/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java index 3318b4d696fca..82859b38f15a9 100644 --- a/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java +++ b/test/hotspot/jtreg/runtime/logging/SafepointCleanupTest.java @@ -25,6 +25,7 @@ * @test * @bug 8149991 * @summary safepoint+cleanup=info should have output from the code + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/SafepointTest.java b/test/hotspot/jtreg/runtime/logging/SafepointTest.java index b0cba9a50946e..b79a46ca68644 100644 --- a/test/hotspot/jtreg/runtime/logging/SafepointTest.java +++ b/test/hotspot/jtreg/runtime/logging/SafepointTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8140348 * @summary safepoint=trace should have output from each log statement in the code + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/StackWalkTest.java b/test/hotspot/jtreg/runtime/logging/StackWalkTest.java index 0b6721a7f50c2..b72358842d916 100644 --- a/test/hotspot/jtreg/runtime/logging/StackWalkTest.java +++ b/test/hotspot/jtreg/runtime/logging/StackWalkTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @test StackWalkTest * @bug 8160064 * @summary -Xlog:stackwalk should produce logging from the source code + * @requires vm.flagless * @library /test/lib * @run driver StackWalkTest */ diff --git a/test/hotspot/jtreg/runtime/logging/StartupTimeTest.java b/test/hotspot/jtreg/runtime/logging/StartupTimeTest.java index e4daa74f6198a..2066331cb772d 100644 --- a/test/hotspot/jtreg/runtime/logging/StartupTimeTest.java +++ b/test/hotspot/jtreg/runtime/logging/StartupTimeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8148630 * @summary -Xlog:startuptime should produce logging from the source code + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/ThreadLoggingTest.java b/test/hotspot/jtreg/runtime/logging/ThreadLoggingTest.java index 13f656af7a679..82a189a92cbe2 100644 --- a/test/hotspot/jtreg/runtime/logging/ThreadLoggingTest.java +++ b/test/hotspot/jtreg/runtime/logging/ThreadLoggingTest.java @@ -26,6 +26,7 @@ * @test * @bug 8149036 8150619 * @summary os+thread output should contain logging calls for thread start stop attaches detaches + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/VMOperationTest.java b/test/hotspot/jtreg/runtime/logging/VMOperationTest.java index a971e16df0dda..873ed6e67924a 100644 --- a/test/hotspot/jtreg/runtime/logging/VMOperationTest.java +++ b/test/hotspot/jtreg/runtime/logging/VMOperationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8143157 * @summary vmoperation=debug should have logging output + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/VerificationTest.java b/test/hotspot/jtreg/runtime/logging/VerificationTest.java index 61140aaae326d..0a7f01f86b7e4 100644 --- a/test/hotspot/jtreg/runtime/logging/VerificationTest.java +++ b/test/hotspot/jtreg/runtime/logging/VerificationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8150083 8234656 * @summary test enabling and disabling verification logging and verification log levels + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/logging/VtablesTest.java b/test/hotspot/jtreg/runtime/logging/VtablesTest.java index 083a46dcebbf4..bc525cf253475 100644 --- a/test/hotspot/jtreg/runtime/logging/VtablesTest.java +++ b/test/hotspot/jtreg/runtime/logging/VtablesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ * @summary vtables=trace should have logging from each of the statements in the code * @library /test/lib * @requires vm.debug + * @requires vm.flagless * @compile ClassB.java * p1/A.java * p2/B.jcod diff --git a/test/hotspot/jtreg/runtime/logging/loadLibraryTest/LoadLibraryTest.java b/test/hotspot/jtreg/runtime/logging/loadLibraryTest/LoadLibraryTest.java index cc63aaf87f20a..5fe8386eb0ee2 100644 --- a/test/hotspot/jtreg/runtime/logging/loadLibraryTest/LoadLibraryTest.java +++ b/test/hotspot/jtreg/runtime/logging/loadLibraryTest/LoadLibraryTest.java @@ -25,6 +25,7 @@ * @test * @bug 8187305 * @summary Tests logging of shared library loads and unloads. + * @requires vm.flagless * @library /test/lib * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox From 858c53b90ea918434b3176e8f6fb690e30830423 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 07:42:45 +0000 Subject: [PATCH 145/341] 8274211: Test man page that options are documented Backport-of: 734d1fbd33be0aa20b26e6e8c776709f478069de --- .../jdk/javadoc/tool/CheckManPageOptions.java | 287 ++++++++++++++++++ 1 file changed, 287 insertions(+) create mode 100644 test/langtools/jdk/javadoc/tool/CheckManPageOptions.java diff --git a/test/langtools/jdk/javadoc/tool/CheckManPageOptions.java b/test/langtools/jdk/javadoc/tool/CheckManPageOptions.java new file mode 100644 index 0000000000000..f876d92b7dd27 --- /dev/null +++ b/test/langtools/jdk/javadoc/tool/CheckManPageOptions.java @@ -0,0 +1,287 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * 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 8274211 + * @summary Test man page that options are documented + * @modules jdk.javadoc/jdk.javadoc.internal.tool:+open + * @run main CheckManPageOptions + */ + +import jdk.javadoc.doclet.Doclet; +import jdk.javadoc.doclet.StandardDoclet; +import jdk.javadoc.internal.tool.ToolOptions; + +import java.io.IOException; +import java.io.PrintStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.TreeSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * Checks the set of options found by fuzzy-parsing the troff or Markdown versions + * of the javadoc man page against the set of options declared in the source code. + */ +public class CheckManPageOptions { + public static void main(String... args) throws Exception { + new CheckManPageOptions().run(args); + } + + static final PrintStream out = System.err; + + // FIXME: JDK-8274295, JDK-8266666 + List MISSING_IN_MAN_PAGE = List.of( + "--legal-notices", + "--link-platform-properties", + "--no-platform-links", + "--since", + "--since-label", + "--snippet-path"); + + void run(String... args) throws Exception { + var file = args.length == 0 ? findDefaultFile() : Path.of(args[0]); + out.println("File: " + file); + out.println(); + + var manPageOptions = getManPageOptions(file); + out.println("Man page options: " + manPageOptions); + out.println(); + + var toolOptions = getToolOptions(); + out.println("ToolOptions: " + toolOptions); + out.println(); + + var docletOptions = getDocletOptions(); + out.println("DocletOptions: " + docletOptions); + out.println(); + + var toolDocletOnly = new TreeSet(); + toolDocletOnly.addAll(toolOptions); + toolDocletOnly.addAll(docletOptions); + toolDocletOnly.removeAll(manPageOptions); + toolDocletOnly.removeAll(MISSING_IN_MAN_PAGE); + if (!toolDocletOnly.isEmpty()) { + error("The following options are defined by the tool or doclet, but not defined in the man page:\n" + + toSimpleList(toolDocletOnly)); + } + + var manPageOnly = new TreeSet(); + manPageOnly.addAll(manPageOptions); + manPageOnly.removeAll(toolOptions); + manPageOnly.removeAll(docletOptions); + if (!manPageOnly.isEmpty()) { + error("The following options are defined in the man page, but not defined by the tool or doclet:\n" + + toSimpleList(manPageOnly)); + } + + if (!MISSING_IN_MAN_PAGE.isEmpty()) { + var notMissing = new TreeSet<>(MISSING_IN_MAN_PAGE); + notMissing.retainAll(manPageOptions); + if (!notMissing.isEmpty()) { + error("The following options were declared as missing, but were found on the man page:\n" + + toSimpleList(notMissing)); + } + + out.println("NOTE: the following options are currently excluded and need to be documented in the man page:"); + out.println(toSimpleList(MISSING_IN_MAN_PAGE)); + } + + if (errors > 0) { + out.println(errors + " errors found"); + throw new Exception(errors + " errors found"); + } + } + + int errors = 0; + void error(String message) { + ("Error: " + message).lines().forEach(out::println); + errors++; + } + + String toSimpleList(Collection items) { + return items.stream().collect(Collectors.joining(", ", " ", "")); + } + + Path findDefaultFile() { + return findRootDir().resolve("src/jdk.javadoc/share/man/javadoc.1"); + } + + Path findRootDir() { + Path dir = Path.of(System.getProperty("test.src", ".")).toAbsolutePath(); + while (dir != null) { + if (Files.exists(dir.resolve("src"))) { + return dir; + } else { + Path openDir = dir.resolve("open"); + if (Files.exists(openDir.resolve("src"))) { + return openDir; + } + } + dir = dir.getParent(); + } + throw new IllegalStateException("cannot find root dir"); + } + + List getToolOptions() throws Error { + try { + Class toolOptionsClass = ToolOptions.class; + + Constructor constr = toolOptionsClass.getDeclaredConstructor(); + constr.setAccessible(true); + + Method getSupportedOptions = toolOptionsClass.getMethod("getSupportedOptions"); + Class toolOptionClass = List.of(toolOptionsClass.getDeclaredClasses()).stream() + .filter(c -> c.getSimpleName().equals("ToolOption")) + .findFirst() + .orElseThrow(); + + Field kindField = toolOptionClass.getDeclaredField("kind"); + kindField.setAccessible(true); + Method getNames = toolOptionClass.getDeclaredMethod("getNames"); + getNames.setAccessible(true); + + ToolOptions t = constr.newInstance(); + var list = new ArrayList(); + var options = (List) getSupportedOptions.invoke(t); + for (var option : options) { + Object kind = kindField.get(option); + if (kind.toString().equals("HIDDEN")) { + continue; + } + + @SuppressWarnings("unchecked") + var oNames = (List) getNames.invoke(option); + oNames.stream() + .filter(o -> !o.equals("@")) + .forEach(list::add); + } + return list; + } catch (ReflectiveOperationException e) { + throw new Error(e); + } + } + + List getDocletOptions() { + StandardDoclet d = new StandardDoclet(); + d.init(Locale.getDefault(), null); + return getDocletOptions(d); + } + + List getDocletOptions(Doclet d) { + return d.getSupportedOptions().stream() + .filter(o -> o.getKind() != Doclet.Option.Kind.OTHER) + .flatMap(o -> o.getNames().stream()) + .map(n -> n.replaceAll(":$", "")) + .toList(); + } + + List getManPageOptions(Path file) throws IOException { + String page = Files.readString(file); + String name = file.getFileName().toString(); + String extn = name.substring(name.lastIndexOf('.')); + return switch (extn) { + case ".1" -> parseNRoff(page); + case ".md" -> parseMarkdown(page); + default -> throw new IllegalArgumentException(file.toString()); + }; + } + + List parseNRoff(String page) { + var list = new ArrayList(); + + // In the troff man page, options are defined in one of two forms: + // 1. options delegated to javac appear in pairs of lines of the form + // .IP \[bu] 2 + // \f[CB]\-.... + // 2. options implemented by the tool or doclet appear in lines of the form + // .B \f[CB]\-... + + Pattern p1 = Pattern.compile("\\R" + Pattern.quote(".IP \\[bu] 2") + "\\R" + Pattern.quote("\\f[CB]\\-") + ".*"); + Pattern p2 = Pattern.compile("\\R" + Pattern.quote(".B \\f[CB]\\-") + ".*"); + Pattern outer = Pattern.compile("(" + p1.pattern() + "|" + p2.pattern() + ")"); + Matcher outerMatcher = outer.matcher(page); + + // In the defining areas, option names are represented as follows: + // \f[CB]OPTION\f[R] or \f[CB]OPTION: + // where OPTION is the shortest string not containing whitespace or colon, + // and in which all '-' characters are escaped with a single backslash. + + Pattern inner = Pattern.compile("\\s\\\\f\\[CB](\\\\-[^ :]+?)(:|\\\\f\\[R])"); + + while (outerMatcher.find()) { + String lines = outerMatcher.group(); + out.println("found:" + lines + "\n"); + + Matcher innerMatcher = inner.matcher(lines); + while (innerMatcher.find()) { + String option = innerMatcher.group(1).replace("\\-", "-"); + list.add(option); + } + } + + return list; + } + + List parseMarkdown(String page) { + var list = new ArrayList(); + // In the Markdown man page, options are defined in one of two forms: + // 1. options delegated to javac appear in lines of the form + // - `-... + // 2. options implemented by the tool or doclet appear in lines of the form + // `-...` + + Pattern p1 = Pattern.compile("\\R- `-.*"); + Pattern p2 = Pattern.compile("\\R`-.*"); + Pattern outer = Pattern.compile("(" + p1.pattern() + "|" + p2.pattern() + ")"); + Matcher outerMatcher = outer.matcher(page); + + // In the defining areas, option names are represented as follows: + // `OPTION` + // where OPTION is the shortest string not containing whitespace or colon + Pattern inner = Pattern.compile("\\s`([^:`]+)"); + + while (outerMatcher.find()) { + String lines = outerMatcher.group(); + out.println("found:" + lines + "\n"); + + Matcher innerMatcher = inner.matcher(lines); + while (innerMatcher.find()) { + String option = innerMatcher.group(1); + list.add(option); + } + } + + return list; + } + } From 4e6d34ffcd2349f019810ac93534c340d0d005de Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 07:44:54 +0000 Subject: [PATCH 146/341] 8275440: Remove VirtualSpaceList::is_full() Backport-of: c9e65f8ef926c3796867558afa536770eed71cd6 --- src/hotspot/share/memory/metaspace/virtualSpaceList.cpp | 9 --------- src/hotspot/share/memory/metaspace/virtualSpaceList.hpp | 4 ---- .../hotspot/gtest/metaspace/test_chunkManager_stress.cpp | 4 ++-- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp b/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp index d3c5ec1cef56c..d796b97c9eb14 100644 --- a/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp +++ b/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp @@ -200,15 +200,6 @@ bool VirtualSpaceList::contains(const MetaWord* p) const { return false; } -// Returns true if the vslist is not expandable and no more root chunks -// can be allocated. -bool VirtualSpaceList::is_full() const { - if (!_can_expand && _first_node != NULL && _first_node->free_words() == 0) { - return true; - } - return false; -} - // Convenience methods to return the global class-space chunkmanager // and non-class chunkmanager, respectively. VirtualSpaceList* VirtualSpaceList::vslist_class() { diff --git a/src/hotspot/share/memory/metaspace/virtualSpaceList.hpp b/src/hotspot/share/memory/metaspace/virtualSpaceList.hpp index a173e71c63eb7..b69e041ad5426 100644 --- a/src/hotspot/share/memory/metaspace/virtualSpaceList.hpp +++ b/src/hotspot/share/memory/metaspace/virtualSpaceList.hpp @@ -128,10 +128,6 @@ class VirtualSpaceList : public CHeapObj { // Returns true if this pointer is contained in one of our nodes. bool contains(const MetaWord* p) const; - // Returns true if the list is not expandable and no more root chunks - // can be allocated. - bool is_full() const; - // Convenience methods to return the global class-space vslist // and non-class vslist, respectively. static VirtualSpaceList* vslist_class(); diff --git a/test/hotspot/gtest/metaspace/test_chunkManager_stress.cpp b/test/hotspot/gtest/metaspace/test_chunkManager_stress.cpp index f084f6107e4da..d62ec6c055eb8 100644 --- a/test/hotspot/gtest/metaspace/test_chunkManager_stress.cpp +++ b/test/hotspot/gtest/metaspace/test_chunkManager_stress.cpp @@ -61,9 +61,9 @@ class ChunkManagerRandomChunkAllocTest { return max_chunks; } - // Return true if, after an allocation error happened, a reserve error seems likely. + // Return true if, after an allocation error happened, a reserve error seems possible. bool could_be_reserve_error() { - return _context.vslist().is_full(); + return _context.reserve_limit() < max_uintx; } // Return true if, after an allocation error happened, a commit error seems likely. From f79ed4da39ea88833326c23ea8460fc2e931e552 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 07:50:31 +0000 Subject: [PATCH 147/341] 8281874: Can't unpack msi installers from test/jdk/tools/jpackage/windows/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java test Backport-of: 81645521c81c7363d199e5051d51043146058a91 --- .../jdk/tools/jpackage/windows/WinShortcutPromptTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java b/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java index f64aefe8843d3..33d9a661ca34c 100644 --- a/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java +++ b/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,13 +122,13 @@ private void setPackageName(JPackageCommand cmd) { StringBuilder sb = new StringBuilder(cmd.name()); sb.append("With"); if (withShortcutPrompt) { - sb.append("ShortcutPrompt"); + sb.append("P"); } if (withStartMenuShortcut) { - sb.append("StartMenu"); + sb.append("M"); } if (withDesktopShortcut) { - sb.append("Desktop"); + sb.append("D"); } cmd.setArgumentValue("--name", sb.toString()); } From cbdacc28c8221d3a54c4088b9278dfe5e9f0d4bc Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 07:52:37 +0000 Subject: [PATCH 148/341] 8282011: test/jdk/tools/jpackage/windows/WinL10nTest.java test fails if light.exe is not in %PATH% Backport-of: 0b00ce17cd6b530d9394e79ac8b07208cd4b92f5 --- test/jdk/tools/jpackage/windows/WinL10nTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/jdk/tools/jpackage/windows/WinL10nTest.java b/test/jdk/tools/jpackage/windows/WinL10nTest.java index 4171da208a46c..4f7e726a3afef 100644 --- a/test/jdk/tools/jpackage/windows/WinL10nTest.java +++ b/test/jdk/tools/jpackage/windows/WinL10nTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * 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,8 +94,11 @@ public static List data() { private final static Stream getLightCommandLine( Executor.Result result) { - return result.getOutput().stream() - .filter(s -> s.trim().startsWith("light.exe")); + return result.getOutput().stream().filter(s -> { + s = s.trim(); + return s.startsWith("light.exe") || ((s.contains("\\light.exe ") + && s.contains(" -out "))); + }); } @Test From 035b3f5715322689e9ac71b64af53af7e4bbe895 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 07:54:35 +0000 Subject: [PATCH 149/341] 8286473: Drop --enable-preview from Record related tests Backport-of: 73c5e993e17f7435553edae79a1e8d70ece5493d --- .../lang/invoke/unreflect/TEST.properties | 24 ------------------- test/jdk/java/nio/Buffer/BulkPutBuffer.java | 6 ++--- test/jdk/sun/misc/UnsafeFieldOffsets.java | 6 ++--- 3 files changed, 6 insertions(+), 30 deletions(-) delete mode 100644 test/jdk/java/lang/invoke/unreflect/TEST.properties diff --git a/test/jdk/java/lang/invoke/unreflect/TEST.properties b/test/jdk/java/lang/invoke/unreflect/TEST.properties deleted file mode 100644 index 2ab57ceb5d66a..0000000000000 --- a/test/jdk/java/lang/invoke/unreflect/TEST.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. -# 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. -# - -enablePreview=true diff --git a/test/jdk/java/nio/Buffer/BulkPutBuffer.java b/test/jdk/java/nio/Buffer/BulkPutBuffer.java index c5c4d0bcd6de6..d1d10ebff87aa 100644 --- a/test/jdk/java/nio/Buffer/BulkPutBuffer.java +++ b/test/jdk/java/nio/Buffer/BulkPutBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * 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,8 +51,8 @@ * @test * @bug 8219014 8245121 * @summary Ensure that a bulk put of a buffer into another is correct. - * @compile --enable-preview -source ${jdk.version} BulkPutBuffer.java - * @run testng/othervm --enable-preview BulkPutBuffer + * @compile BulkPutBuffer.java + * @run testng/othervm BulkPutBuffer */ public class BulkPutBuffer { static final long SEED = System.nanoTime(); diff --git a/test/jdk/sun/misc/UnsafeFieldOffsets.java b/test/jdk/sun/misc/UnsafeFieldOffsets.java index e2c63c350f408..725e59ec42df4 100644 --- a/test/jdk/sun/misc/UnsafeFieldOffsets.java +++ b/test/jdk/sun/misc/UnsafeFieldOffsets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,8 @@ * @summary Ensure that sun.misc.Unsafe::objectFieldOffset and staticFieldOffset * throw UnsupportedOperationException on Field of a hidden or record class * @modules jdk.unsupported - * @compile --enable-preview -source ${jdk.version} UnsafeFieldOffsets.java - * @run testng/othervm --enable-preview UnsafeFieldOffsets + * @compile UnsafeFieldOffsets.java + * @run testng/othervm UnsafeFieldOffsets */ import sun.misc.Unsafe; From 6bdd611a43bfaaceda5fa94e3bd5f63719ad6743 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 07:56:50 +0000 Subject: [PATCH 150/341] 8286475: Drop --enable-preview from instanceof pattern matching related tests Backport-of: 8c977050aa20a7e9a6d0d83d18dce25defcc7a46 --- .../tools/javac/ConditionalExpressionResolvePending.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/langtools/tools/javac/ConditionalExpressionResolvePending.java b/test/langtools/tools/javac/ConditionalExpressionResolvePending.java index 274ce271575e7..ac2a1de44d985 100644 --- a/test/langtools/tools/javac/ConditionalExpressionResolvePending.java +++ b/test/langtools/tools/javac/ConditionalExpressionResolvePending.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @build toolbox.ToolBox toolbox.JavacTask * @build combo.ComboTestHelper * @compile ConditionalExpressionResolvePending.java - * @run main/othervm --enable-preview ConditionalExpressionResolvePending + * @run main/othervm ConditionalExpressionResolvePending */ import combo.ComboInstance; From c345ffa1e729570a471e8ea8302f222ba744076e Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 08:00:29 +0000 Subject: [PATCH 151/341] 8288961: jpackage: test MSI installation fix Backport-of: c67149be4bd4922f9e6a55eb17deca684941d535 --- .../tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java index a3f67e01d4601..1e6080101b36d 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java @@ -92,7 +92,7 @@ static PackageHandlers createMsiPackageHandlers() { BiConsumer installMsi = (cmd, install) -> { cmd.verifyIsOfType(PackageType.WIN_MSI); runMsiexecWithRetries(Executor.of("msiexec", "/qn", "/norestart", - install ? "/i" : "/x").addArgument(cmd.outputBundle())); + install ? "/i" : "/x").addArgument(cmd.outputBundle().normalize())); }; PackageHandlers msi = new PackageHandlers(); From 94c154e8997f1893bd12e0763fd32e97122af6ff Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 08:02:47 +0000 Subject: [PATCH 152/341] 8292261: adjust timeouts in JLI GetObjectSizeIntrinsicsTest.java Backport-of: 8a0c3e53d541395ac32d656ac64d20ca0b9a187c --- .../jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java b/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java index 5140888ea70cf..369f1fc34a244 100644 --- a/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java +++ b/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java @@ -278,12 +278,12 @@ * * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * - * @run main/othervm -Xmx8g + * @run main/othervm/timeout=240 -Xmx8g * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:. * -Xint * -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest large * - * @run main/othervm -Xmx8g + * @run main/othervm/timeout=240 -Xmx8g * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:. * -Xbatch -XX:TieredStopAtLevel=1 * -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest large From 23457a664ce00de33fdb6846ff31f489e6dd2177 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 08:05:06 +0000 Subject: [PATCH 153/341] 8297798: Timeout with DTLSOverDatagram test template Backport-of: 4b313b51b1787113961c289a41708e31fa19cacc --- .../javax/net/ssl/DTLS/DTLSOverDatagram.java | 179 +++++++----------- .../javax/net/ssl/DTLS/InvalidRecords.java | 33 ++-- 2 files changed, 79 insertions(+), 133 deletions(-) diff --git a/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java b/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java index 0118bcb381077..1820dbe54237a 100644 --- a/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java +++ b/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ * @run main/othervm DTLSOverDatagram */ +import java.io.IOException; import java.nio.*; import java.net.*; import java.util.*; @@ -42,6 +43,7 @@ import jdk.test.lib.security.SSLContextBuilder; import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicBoolean; import jdk.test.lib.hexdump.HexPrinter; @@ -50,8 +52,6 @@ */ public class DTLSOverDatagram { - private static final int MAX_HANDSHAKE_LOOPS = 200; - private static final int MAX_APP_READ_LOOPS = 60; private static final int SOCKET_TIMEOUT = 10 * 1000; // in millis private static final int BUFFER_SIZE = 1024; private static final int MAXIMUM_PACKET_SIZE = 1024; @@ -75,8 +75,9 @@ public class DTLSOverDatagram { private static final ByteBuffer CLIENT_APP = ByteBuffer.wrap("Hi Server, I'm Client".getBytes()); - private static Exception clientException = null; - private static Exception serverException = null; + private final AtomicBoolean exceptionOccurred = new AtomicBoolean(false); + + private final CountDownLatch serverStarted = new CountDownLatch(1); /* * ============================================================= * The test case @@ -148,18 +149,12 @@ void handshake(SSLEngine engine, DatagramSocket socket, SocketAddress peerAddr, String side) throws Exception { boolean endLoops = false; - int loops = MAX_HANDSHAKE_LOOPS; + int loops = 0; engine.beginHandshake(); - while (!endLoops && - (serverException == null) && (clientException == null)) { - - if (--loops < 0) { - throw new RuntimeException( - "Too many loops to produce handshake packets"); - } + while (!endLoops && !exceptionOccurred.get()) { SSLEngineResult.HandshakeStatus hs = engine.getHandshakeStatus(); - log(side, "=======handshake(" + loops + ", " + hs + ")======="); + log(side, "=======handshake(" + ++loops + ", " + hs + ")======="); switch (hs) { case NEED_UNWRAP, NEED_UNWRAP_AGAIN -> { @@ -313,16 +308,10 @@ void deliverAppData(SSLEngine engine, DatagramSocket socket, void receiveAppData(SSLEngine engine, DatagramSocket socket, ByteBuffer expectedApp) throws Exception { - int loops = MAX_APP_READ_LOOPS; - while ((serverException == null) && (clientException == null)) { - if (--loops < 0) { - throw new RuntimeException( - "Too much loops to receive application data"); - } - + while (!exceptionOccurred.get()) { byte[] buf = new byte[BUFFER_SIZE]; - DatagramPacket packet = new DatagramPacket(buf, buf.length); - socket.receive(packet); + DatagramPacket packet = readFromSocket(socket, buf); + ByteBuffer netBuffer = ByteBuffer.wrap(buf, 0, packet.getLength()); ByteBuffer recBuffer = ByteBuffer.allocate(BUFFER_SIZE); SSLEngineResult rs = engine.unwrap(netBuffer, recBuffer); @@ -338,19 +327,31 @@ void receiveAppData(SSLEngine engine, } } + /* + Some tests failed with receive time-out errors when the client tried to read + from the server. The server thread had exited normally so the read _should_ + succeed. So let's try to read a couple of times before giving up. + */ + DatagramPacket readFromSocket(DatagramSocket socket, byte[] buffer) throws IOException { + for (int i = 1 ; i <= 2 ; ++i) { + try { + DatagramPacket packet = new DatagramPacket(buffer, buffer.length); + socket.receive(packet); + return packet; + } catch (SocketTimeoutException exc) { + System.out.println("Attempt " + i + ": Timeout occurred reading from socket."); + } + } + throw new IOException("Did not receive data after 2 attempts."); + } + // produce handshake packets boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, String side, List packets) throws Exception { boolean endLoops = false; - int loops = MAX_HANDSHAKE_LOOPS / 2; - while (!endLoops && - (serverException == null) && (clientException == null)) { - - if (--loops < 0) { - throw new RuntimeException( - "Too many loops to produce handshake packets"); - } + int loops = 0; + while (!endLoops && !exceptionOccurred.get()) { ByteBuffer oNet = ByteBuffer.allocate(32768); ByteBuffer oApp = ByteBuffer.allocate(0); @@ -360,7 +361,7 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, SSLEngineResult.Status rs = r.getStatus(); SSLEngineResult.HandshakeStatus hs = r.getHandshakeStatus(); log(side, "----produce handshake packet(" + - loops + ", " + rs + ", " + hs + ")----"); + ++loops + ", " + rs + ", " + hs + ")----"); verifySSLEngineResultStatus(r, side); @@ -518,10 +519,6 @@ SSLContext getDTLSContext() throws Exception { * The remainder is support stuff to kickstart the testing. */ - // Will the handshaking and application data exchange succeed? - public boolean isGoodJob() { - return true; - } public final void runTest(DTLSOverDatagram testCase) throws Exception { InetSocketAddress serverSocketAddress = new InetSocketAddress @@ -541,97 +538,51 @@ public final void runTest(DTLSOverDatagram testCase) throws Exception { InetSocketAddress clientSocketAddr = new InetSocketAddress( InetAddress.getLoopbackAddress(), clientSocket.getLocalPort()); - ExecutorService pool = Executors.newFixedThreadPool(2); - Future server, client; + ExecutorService pool = Executors.newFixedThreadPool(1); + Future server; - try { - server = pool.submit(new ServerCallable( + server = pool.submit(() -> runServer( testCase, serverSocket, clientSocketAddr)); - client = pool.submit(new ClientCallable( - testCase, clientSocket, serverSocketAddr)); - } finally { - pool.shutdown(); - } - - boolean failed = false; + pool.shutdown(); - // wait for client to finish - try { - System.out.println("Client finished: " + client.get()); - } catch (CancellationException | InterruptedException - | ExecutionException e) { - System.out.println("Exception on client side: "); - e.printStackTrace(System.out); - failed = true; - } - - // wait for server to finish - try { - System.out.println("Client finished: " + server.get()); - } catch (CancellationException | InterruptedException - | ExecutionException e) { - System.out.println("Exception on server side: "); - e.printStackTrace(System.out); - failed = true; - } - - if (failed) { - throw new RuntimeException("Test failed"); - } + runClient(testCase, clientSocket, serverSocketAddr); + server.get(); } } - record ServerCallable(DTLSOverDatagram testCase, DatagramSocket socket, - InetSocketAddress clientSocketAddr) implements Callable { + Void runServer(DTLSOverDatagram testCase, DatagramSocket socket, + InetSocketAddress clientSocketAddr) throws Exception { + try { + serverStarted.countDown(); + testCase.doServerSide(socket, clientSocketAddr); - @Override - public String call() throws Exception { - try { - testCase.doServerSide(socket, clientSocketAddr); - } catch (Exception e) { - System.out.println("Exception in ServerCallable.call():"); - e.printStackTrace(System.out); - serverException = e; - - if (testCase.isGoodJob()) { - throw e; - } else { - return "Well done, server!"; - } - } + } catch (Exception exc) { + exceptionOccurred.set(true); - if (testCase.isGoodJob()) { - return "Well done, server!"; - } else { - throw new Exception("No expected exception"); - } + // log for debugging clarity + System.out.println("Unexpected exception in server"); + exc.printStackTrace(System.err); + throw exc; } + + return null; } - record ClientCallable(DTLSOverDatagram testCase, DatagramSocket socket, - InetSocketAddress serverSocketAddr) implements Callable { + private void runClient(DTLSOverDatagram testCase, DatagramSocket socket, + InetSocketAddress serverSocketAddr) throws Exception { + if(!serverStarted.await(5, TimeUnit.SECONDS)) { + throw new Exception("Server did not start within 5 seconds."); + } - @Override - public String call() throws Exception { - try { - testCase.doClientSide(socket, serverSocketAddr); - } catch (Exception e) { - System.out.println("Exception in ClientCallable.call():"); - e.printStackTrace(System.out); - clientException = e; - - if (testCase.isGoodJob()) { - throw e; - } else { - return "Well done, client!"; - } - } + try { + testCase.doClientSide(socket, serverSocketAddr); + } catch (Exception exc) { + exceptionOccurred.set(true); - if (testCase.isGoodJob()) { - return "Well done, client!"; - } else { - throw new Exception("No expected exception"); - } + // log for debugging clarity + System.out.println("Unexpected exception in client."); + exc.printStackTrace(System.err); + throw exc; } } diff --git a/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java b/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java index af5bdc3613406..304cb0695d618 100644 --- a/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java +++ b/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. * 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,27 +36,32 @@ import java.net.DatagramPacket; import java.net.SocketAddress; +import java.util.concurrent.atomic.AtomicBoolean; /** - * Test that if handshake messages are crasged, the handshake would fail + * Test that if handshake messages are changed, the handshake would fail * because of handshaking hash verification. */ public class InvalidRecords extends DTLSOverDatagram { - boolean needInvalidRecords = true; + private static final AtomicBoolean needInvalidRecords = new AtomicBoolean(true); public static void main(String[] args) throws Exception { InvalidRecords testCase = new InvalidRecords(); testCase.runTest(testCase); - } - @Override - public boolean isGoodJob() { - return false; + if (needInvalidRecords.get()) { + // if this is true, the createHandshakePacket() method + // was NOT called twice to create ClientHello messages + throw new RuntimeException( + "The invalid handshake packet was not" + + " rejected as it should have been."); + } } + @Override DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) { - if ((ba.length >= 60) && + if (needInvalidRecords.get() && (ba.length >= 60) && (ba[0x00] == (byte)0x16) && (ba[0x0D] == (byte)0x01) && (ba[0x3B] == (byte)0x00) && (ba[0x3C] > 0)) { @@ -65,18 +70,8 @@ DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) { // ba[0x3B]: length of session ID // ba[0x3C]: length of cookie - if (!needInvalidRecords) { - // The 2nd ClientHello with cookie. The 1st one should be - // rejected as expected. - // - // This may happen if the last few bytes of the packet are - // for supported_version extension. - throw new RuntimeException( - "the crashed handshake message was rejected as expected"); - } - // ClientHello with cookie - needInvalidRecords = false; + needInvalidRecords.set(false); System.out.println("invalidate ClientHello message"); if (ba[ba.length - 1] == (byte)0xFF) { ba[ba.length - 1] = (byte)0xFE; From cdbce9c49dae3e7176362f1f954bf771af6fac92 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 08:10:03 +0000 Subject: [PATCH 154/341] 8249826: 5 javax/net/ssl/SSLEngine tests use @ignore w/o bug-id Backport-of: bf9a8ce0bb975a3d50e92148f92850ef930d64b0 --- test/jdk/ProblemList.txt | 7 +++++++ test/jdk/javax/net/ssl/SSLEngine/Basics.java | 2 -- test/jdk/javax/net/ssl/SSLEngine/CheckStatus.java | 2 +- test/jdk/javax/net/ssl/SSLEngine/ConnectionTest.java | 1 - test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java | 2 +- .../javax/net/ssl/SSLEngine/IllegalHandshakeMessage.java | 1 - test/jdk/javax/net/ssl/SSLEngine/IllegalRecordVersion.java | 2 +- test/jdk/javax/net/ssl/SSLEngine/TestAllSuites.java | 3 +-- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 93f50d5c750c3..5d866ccb9bddd 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -635,6 +635,13 @@ sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic- javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x64 +javax/net/ssl/SSLEngine/TestAllSuites.java 8298874 generic-all +javax/net/ssl/SSLEngine/IllegalRecordVersion.java 8298873 generic-all +javax/net/ssl/SSLEngine/EngineCloseOnAlert.java 8298868 generic-all +javax/net/ssl/SSLEngine/ConnectionTest.java 8298869 generic-all +javax/net/ssl/SSLEngine/CheckStatus.java 8298872 generic-all +javax/net/ssl/SSLEngine/Basics.java 8298867 generic-all + sun/security/smartcardio/TestChannel.java 8039280 generic-all sun/security/smartcardio/TestConnect.java 8039280 generic-all sun/security/smartcardio/TestConnectAgain.java 8039280 generic-all diff --git a/test/jdk/javax/net/ssl/SSLEngine/Basics.java b/test/jdk/javax/net/ssl/SSLEngine/Basics.java index 6e38c884e06ab..177422cb489c3 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/Basics.java +++ b/test/jdk/javax/net/ssl/SSLEngine/Basics.java @@ -26,8 +26,6 @@ * @bug 4495742 * @summary Add non-blocking SSL/TLS functionality, usable with any * I/O abstraction - * @ignore JSSE supported cipher suites are changed with CR 6916074, - * need to update this test case in JDK 7 soon * * This is intended to test many of the basic API calls to the SSLEngine * interface. This doesn't really exercise much of the SSL code. diff --git a/test/jdk/javax/net/ssl/SSLEngine/CheckStatus.java b/test/jdk/javax/net/ssl/SSLEngine/CheckStatus.java index ec3a96c2b3522..69d1e07621f87 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/CheckStatus.java +++ b/test/jdk/javax/net/ssl/SSLEngine/CheckStatus.java @@ -25,7 +25,7 @@ * @test * @bug 4948079 * @summary SSLEngineResult needs updating [none yet] - * @ignore the dependent implementation details are changed + * * @run main/othervm -Djsse.enableCBCProtection=false CheckStatus * * @author Brad Wetmore diff --git a/test/jdk/javax/net/ssl/SSLEngine/ConnectionTest.java b/test/jdk/javax/net/ssl/SSLEngine/ConnectionTest.java index d6e32eff5def5..a18444ccc7ac5 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/ConnectionTest.java +++ b/test/jdk/javax/net/ssl/SSLEngine/ConnectionTest.java @@ -26,7 +26,6 @@ * @bug 4495742 * @summary Add non-blocking SSL/TLS functionality, usable with any * I/O abstraction - * @ignore the dependent implementation details are changed * @author Brad Wetmore * * @run main/othervm ConnectionTest diff --git a/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java b/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java index 8d60396fb917c..1ddd9edfa5954 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java +++ b/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java @@ -26,7 +26,7 @@ * @bug 8133632 * @summary javax.net.ssl.SSLEngine does not properly handle received * SSL fatal alerts - * @ignore the dependent implementation details are changed + * * @run main/othervm EngineCloseOnAlert */ diff --git a/test/jdk/javax/net/ssl/SSLEngine/IllegalHandshakeMessage.java b/test/jdk/javax/net/ssl/SSLEngine/IllegalHandshakeMessage.java index 475879a32622f..5dc19f1475efb 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/IllegalHandshakeMessage.java +++ b/test/jdk/javax/net/ssl/SSLEngine/IllegalHandshakeMessage.java @@ -30,7 +30,6 @@ * @test * @bug 8180643 * @summary Illegal handshake message - * @ignore the dependent implementation details are changed * @run main/othervm IllegalHandshakeMessage */ diff --git a/test/jdk/javax/net/ssl/SSLEngine/IllegalRecordVersion.java b/test/jdk/javax/net/ssl/SSLEngine/IllegalRecordVersion.java index aeb4c50aac904..cab265287909f 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/IllegalRecordVersion.java +++ b/test/jdk/javax/net/ssl/SSLEngine/IllegalRecordVersion.java @@ -28,7 +28,7 @@ * @test * @bug 8042449 * @summary Issue for negative byte major record version - * @ignore the dependent implementation details are changed + * * @run main/othervm IllegalRecordVersion */ diff --git a/test/jdk/javax/net/ssl/SSLEngine/TestAllSuites.java b/test/jdk/javax/net/ssl/SSLEngine/TestAllSuites.java index 9c633b58f7051..3285479a86ca9 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/TestAllSuites.java +++ b/test/jdk/javax/net/ssl/SSLEngine/TestAllSuites.java @@ -24,8 +24,7 @@ /* * @test * @bug 4495742 - * @ignore JSSE supported cipher suites are changed with CR 6916074, - * need to update this test case in JDK 7 soon + * * @run main/timeout=180 TestAllSuites * @summary Add non-blocking SSL/TLS functionality, usable with any * I/O abstraction From 1b5139bfe1438a8acda36611b2a6bde56b58ed5d Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 08:15:05 +0000 Subject: [PATCH 155/341] 8298735: Some tools/jpackage/windows/* tests fails with jtreg test timeout Backport-of: 3c99e786ab4f89448f8d2a6eaf532255a8a560bf --- test/jdk/tools/jpackage/windows/WinDirChooserTest.java | 2 +- test/jdk/tools/jpackage/windows/WinInstallerIconTest.java | 2 +- test/jdk/tools/jpackage/windows/WinInstallerUiTest.java | 2 +- test/jdk/tools/jpackage/windows/WinMenuGroupTest.java | 2 +- test/jdk/tools/jpackage/windows/WinMenuTest.java | 2 +- test/jdk/tools/jpackage/windows/WinPerUserInstallTest.java | 2 +- test/jdk/tools/jpackage/windows/WinScriptTest.java | 2 +- test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java | 2 +- test/jdk/tools/jpackage/windows/WinShortcutTest.java | 2 +- test/jdk/tools/jpackage/windows/WinUrlTest.java | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/jdk/tools/jpackage/windows/WinDirChooserTest.java b/test/jdk/tools/jpackage/windows/WinDirChooserTest.java index 2c5384f35615b..355b89dba3eda 100644 --- a/test/jdk/tools/jpackage/windows/WinDirChooserTest.java +++ b/test/jdk/tools/jpackage/windows/WinDirChooserTest.java @@ -42,7 +42,7 @@ * @build WinDirChooserTest * @requires (os.family == "windows") * @modules jdk.jpackage/jdk.jpackage.internal - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinDirChooserTest */ diff --git a/test/jdk/tools/jpackage/windows/WinInstallerIconTest.java b/test/jdk/tools/jpackage/windows/WinInstallerIconTest.java index 450a98a40f46f..63194d6b25680 100644 --- a/test/jdk/tools/jpackage/windows/WinInstallerIconTest.java +++ b/test/jdk/tools/jpackage/windows/WinInstallerIconTest.java @@ -44,7 +44,7 @@ * @build WinInstallerIconTest * @requires (os.family == "windows") * @modules jdk.jpackage/jdk.jpackage.internal - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinInstallerIconTest */ diff --git a/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java b/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java index c6631bc008afc..99c6eb490d5ec 100644 --- a/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java +++ b/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java @@ -45,7 +45,7 @@ * @build WinInstallerUiTest * @requires (os.family == "windows") * @modules jdk.jpackage/jdk.jpackage.internal - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinInstallerUiTest */ public class WinInstallerUiTest { diff --git a/test/jdk/tools/jpackage/windows/WinMenuGroupTest.java b/test/jdk/tools/jpackage/windows/WinMenuGroupTest.java index b8b748a6ca1e9..5950418f6096c 100644 --- a/test/jdk/tools/jpackage/windows/WinMenuGroupTest.java +++ b/test/jdk/tools/jpackage/windows/WinMenuGroupTest.java @@ -45,7 +45,7 @@ * @requires (os.family == "windows") * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinMenuGroupTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinMenuGroupTest */ diff --git a/test/jdk/tools/jpackage/windows/WinMenuTest.java b/test/jdk/tools/jpackage/windows/WinMenuTest.java index e39a16465fe84..a28d28e24ece7 100644 --- a/test/jdk/tools/jpackage/windows/WinMenuTest.java +++ b/test/jdk/tools/jpackage/windows/WinMenuTest.java @@ -42,7 +42,7 @@ * @requires (os.family == "windows") * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinMenuTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinMenuTest */ diff --git a/test/jdk/tools/jpackage/windows/WinPerUserInstallTest.java b/test/jdk/tools/jpackage/windows/WinPerUserInstallTest.java index 2020c27975b41..5d97bb9357e27 100644 --- a/test/jdk/tools/jpackage/windows/WinPerUserInstallTest.java +++ b/test/jdk/tools/jpackage/windows/WinPerUserInstallTest.java @@ -43,7 +43,7 @@ * @requires (os.family == "windows") * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinPerUserInstallTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinPerUserInstallTest */ diff --git a/test/jdk/tools/jpackage/windows/WinScriptTest.java b/test/jdk/tools/jpackage/windows/WinScriptTest.java index 5e8c00bbddb26..775102cd0141c 100644 --- a/test/jdk/tools/jpackage/windows/WinScriptTest.java +++ b/test/jdk/tools/jpackage/windows/WinScriptTest.java @@ -42,7 +42,7 @@ * @requires (os.family == "windows") * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinScriptTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinScriptTest */ diff --git a/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java b/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java index 33d9a661ca34c..6c27b6852eb3d 100644 --- a/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java +++ b/test/jdk/tools/jpackage/windows/WinShortcutPromptTest.java @@ -43,7 +43,7 @@ * @build WinShortcutPromptTest * @requires (os.family == "windows") * @modules jdk.jpackage/jdk.jpackage.internal - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinShortcutPromptTest */ public class WinShortcutPromptTest { diff --git a/test/jdk/tools/jpackage/windows/WinShortcutTest.java b/test/jdk/tools/jpackage/windows/WinShortcutTest.java index f50f07a89052d..3efa8b68817d0 100644 --- a/test/jdk/tools/jpackage/windows/WinShortcutTest.java +++ b/test/jdk/tools/jpackage/windows/WinShortcutTest.java @@ -43,7 +43,7 @@ * @requires (os.family == "windows") * @modules jdk.jpackage/jdk.jpackage.internal * @compile WinShortcutTest.java - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinShortcutTest */ diff --git a/test/jdk/tools/jpackage/windows/WinUrlTest.java b/test/jdk/tools/jpackage/windows/WinUrlTest.java index 8e1ffad85704a..208d16d931adc 100644 --- a/test/jdk/tools/jpackage/windows/WinUrlTest.java +++ b/test/jdk/tools/jpackage/windows/WinUrlTest.java @@ -46,7 +46,7 @@ * @build WinUrlTest * @requires (os.family == "windows") * @modules jdk.jpackage/jdk.jpackage.internal - * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main * --jpt-run=WinUrlTest */ public class WinUrlTest { From 80c8ce78133e15ee166c7fdfee63a152dc08ea48 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 08:17:19 +0000 Subject: [PATCH 156/341] 8304174: Remove delays from httpserver tests Backport-of: 450567031ec32846c9a8f157eb56bd099b17b5a5 --- test/jdk/com/sun/net/httpserver/DateFormatterTest.java | 4 ++-- test/jdk/com/sun/net/httpserver/HttpServerTest.java | 4 ++-- test/jdk/com/sun/net/httpserver/SelCacheTest.java | 7 +++---- test/jdk/com/sun/net/httpserver/Test.java | 8 +------- test/jdk/com/sun/net/httpserver/Test1.java | 7 +++---- test/jdk/com/sun/net/httpserver/Test10.java | 5 ++--- test/jdk/com/sun/net/httpserver/Test11.java | 4 ++-- test/jdk/com/sun/net/httpserver/Test12.java | 7 +++---- test/jdk/com/sun/net/httpserver/Test13.java | 7 +++---- test/jdk/com/sun/net/httpserver/Test14.java | 4 ++-- test/jdk/com/sun/net/httpserver/Test2.java | 4 ++-- test/jdk/com/sun/net/httpserver/Test3.java | 5 ++--- test/jdk/com/sun/net/httpserver/Test4.java | 5 ++--- test/jdk/com/sun/net/httpserver/Test5.java | 5 ++--- test/jdk/com/sun/net/httpserver/Test6.java | 5 ++--- test/jdk/com/sun/net/httpserver/Test6a.java | 5 ++--- test/jdk/com/sun/net/httpserver/Test7.java | 5 ++--- test/jdk/com/sun/net/httpserver/Test7a.java | 5 ++--- test/jdk/com/sun/net/httpserver/Test8.java | 5 ++--- test/jdk/com/sun/net/httpserver/Test8a.java | 5 ++--- test/jdk/com/sun/net/httpserver/Test9.java | 7 +++---- test/jdk/com/sun/net/httpserver/Test9a.java | 5 ++--- test/jdk/com/sun/net/httpserver/TestLogging.java | 5 ++--- .../bugs/8199849/BasicAuthenticatorCharset.java | 4 ++-- .../net/httpserver/bugs/8199849/TestHttpUnicode.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6339483.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6341616.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6361557.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6393710.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6401598.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6431193.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6433018.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6526158.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6526913.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6529200.java | 10 +++++----- test/jdk/com/sun/net/httpserver/bugs/B6744329.java | 4 ++-- test/jdk/com/sun/net/httpserver/bugs/B6886436.java | 6 +++--- test/jdk/com/sun/net/httpserver/bugs/B8211420.java | 4 ++-- .../bugs/HttpExchange/AutoCloseableHttpExchange.java | 4 ++-- test/lib/jdk/test/lib/net/SimpleHttpServer.java | 4 ++-- 40 files changed, 88 insertions(+), 111 deletions(-) diff --git a/test/jdk/com/sun/net/httpserver/DateFormatterTest.java b/test/jdk/com/sun/net/httpserver/DateFormatterTest.java index 47ff79e26e792..bda3421660c04 100644 --- a/test/jdk/com/sun/net/httpserver/DateFormatterTest.java +++ b/test/jdk/com/sun/net/httpserver/DateFormatterTest.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 @@ -87,7 +87,7 @@ public void setUp() throws IOException, URISyntaxException { @AfterTest public void cleanUp() { - server.stop(1); + server.stop(0); } @Test diff --git a/test/jdk/com/sun/net/httpserver/HttpServerTest.java b/test/jdk/com/sun/net/httpserver/HttpServerTest.java index f2d604cbdcb5e..b272bafc24139 100644 --- a/test/jdk/com/sun/net/httpserver/HttpServerTest.java +++ b/test/jdk/com/sun/net/httpserver/HttpServerTest.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 @@ -60,7 +60,7 @@ public void handle(HttpExchange ex) throws IOException { sendHttpStatusCode(HTTP_STATUS_CODE_OK, ex); System.out.println("Stopping server ..."); - server.stop(1); + server.stop(0); serverStopped.countDown(); } diff --git a/test/jdk/com/sun/net/httpserver/SelCacheTest.java b/test/jdk/com/sun/net/httpserver/SelCacheTest.java index 74b6d09a139c7..644e64419e0e2 100644 --- a/test/jdk/com/sun/net/httpserver/SelCacheTest.java +++ b/test/jdk/com/sun/net/httpserver/SelCacheTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,9 +89,8 @@ public static void main(String[] args) throws Exception { test(false, "https", root+"/test1", loopback, httpsport, "largefile.txt", 2730088); System.out.println("OK"); } finally { - delay(); - s1.stop(2); - s2.stop(2); + s1.stop(0); + s2.stop(0); executor.shutdown(); } } diff --git a/test/jdk/com/sun/net/httpserver/Test.java b/test/jdk/com/sun/net/httpserver/Test.java index 6a734a6ad5628..f46e668168f6e 100644 --- a/test/jdk/com/sun/net/httpserver/Test.java +++ b/test/jdk/com/sun/net/httpserver/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, 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 @@ -35,10 +35,4 @@ static void enableLogging() { logger.setLevel(Level.ALL); logger.addHandler(h); } - - static void delay () { - try { - Thread.sleep (1000); - } catch (Exception e) {} - } } diff --git a/test/jdk/com/sun/net/httpserver/Test1.java b/test/jdk/com/sun/net/httpserver/Test1.java index bc42c1b45ab56..c4059cfaa7a4b 100644 --- a/test/jdk/com/sun/net/httpserver/Test1.java +++ b/test/jdk/com/sun/net/httpserver/Test1.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 @@ -96,11 +96,10 @@ public static void main (String[] args) throws Exception { test (false, "https", root+"/test1", httpsport, "largefile.txt", 2730088); System.out.println ("OK"); } finally { - delay(); if (s1 != null) - s1.stop(2); + s1.stop(0); if (s2 != null) - s2.stop(2); + s2.stop(0); if (executor != null) executor.shutdown (); } diff --git a/test/jdk/com/sun/net/httpserver/Test10.java b/test/jdk/com/sun/net/httpserver/Test10.java index c15ddc48d6fe0..d43480e8b8df4 100644 --- a/test/jdk/com/sun/net/httpserver/Test10.java +++ b/test/jdk/com/sun/net/httpserver/Test10.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved. * 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,9 +57,8 @@ public static void main (String[] args) throws Exception { doClient(port); System.out.println ("OK"); } finally { - delay(); if (server != null) - server.stop(2); + server.stop(0); if (exec != null) exec.shutdown(); } diff --git a/test/jdk/com/sun/net/httpserver/Test11.java b/test/jdk/com/sun/net/httpserver/Test11.java index d8a58bb36b09c..9d9036d034857 100644 --- a/test/jdk/com/sun/net/httpserver/Test11.java +++ b/test/jdk/com/sun/net/httpserver/Test11.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 @@ -78,7 +78,7 @@ public static void main (String[] args) throws Exception { System.out.println ("OK"); } finally { s.shutdown(); - server.stop(2); + server.stop(0); } } } diff --git a/test/jdk/com/sun/net/httpserver/Test12.java b/test/jdk/com/sun/net/httpserver/Test12.java index 95e179db19819..91354d38f8871 100644 --- a/test/jdk/com/sun/net/httpserver/Test12.java +++ b/test/jdk/com/sun/net/httpserver/Test12.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 @@ -88,11 +88,10 @@ public static void main (String[] args) throws Exception { join (r); System.out.println ("OK"); } finally { - delay(); if (s1 != null) - s1.stop(2); + s1.stop(0); if (s2 != null) - s2.stop(2); + s2.stop(0); if (executor != null) executor.shutdown (); } diff --git a/test/jdk/com/sun/net/httpserver/Test13.java b/test/jdk/com/sun/net/httpserver/Test13.java index 138acd8710539..f0ee7a8e6c61f 100644 --- a/test/jdk/com/sun/net/httpserver/Test13.java +++ b/test/jdk/com/sun/net/httpserver/Test13.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 @@ -93,11 +93,10 @@ public static void main (String[] args) throws Exception { join (r); System.out.println ("OK"); } finally { - delay(); if (s1 != null) - s1.stop(2); + s1.stop(0); if (s2 != null) - s2.stop(2); + s2.stop(0); if (executor != null) executor.shutdown (); } diff --git a/test/jdk/com/sun/net/httpserver/Test14.java b/test/jdk/com/sun/net/httpserver/Test14.java index 8e023f9cd5af9..532078e82156b 100644 --- a/test/jdk/com/sun/net/httpserver/Test14.java +++ b/test/jdk/com/sun/net/httpserver/Test14.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 @@ -114,7 +114,7 @@ public static void main (String[] args) throws Exception { output = output + (char)x; } error = !output.equals (test_output); - server.stop(2); + server.stop(0); executor.shutdown(); if (error ) { throw new RuntimeException ("test failed error"); diff --git a/test/jdk/com/sun/net/httpserver/Test2.java b/test/jdk/com/sun/net/httpserver/Test2.java index 296d8b4b19dbd..dd675c8933fe8 100644 --- a/test/jdk/com/sun/net/httpserver/Test2.java +++ b/test/jdk/com/sun/net/httpserver/Test2.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 @@ -79,7 +79,7 @@ public boolean checkCredentials (String username, String pw) { while (is.read()!= -1) { c ++; } - server.stop(2); + server.stop(0); executor.shutdown(); if (error ) { throw new RuntimeException ("test failed error"); diff --git a/test/jdk/com/sun/net/httpserver/Test3.java b/test/jdk/com/sun/net/httpserver/Test3.java index 7e40b9505fe3c..a9dab54a388bd 100644 --- a/test/jdk/com/sun/net/httpserver/Test3.java +++ b/test/jdk/com/sun/net/httpserver/Test3.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 @@ -64,9 +64,8 @@ public static void main (String[] args) throws Exception { doClient(port); System.out.println ("OK"); } finally { - delay(); if (server != null) - server.stop(2); + server.stop(0); if (exec != null) exec.shutdown(); } diff --git a/test/jdk/com/sun/net/httpserver/Test4.java b/test/jdk/com/sun/net/httpserver/Test4.java index e6527f272db90..996614c0a4cca 100644 --- a/test/jdk/com/sun/net/httpserver/Test4.java +++ b/test/jdk/com/sun/net/httpserver/Test4.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 @@ -62,9 +62,8 @@ public static void main (String[] args) throws Exception { doClient(port); System.out.println ("OK"); } finally { - delay(); if (server != null) - server.stop(2); + server.stop(0); if (exec != null) exec.shutdown(); } diff --git a/test/jdk/com/sun/net/httpserver/Test5.java b/test/jdk/com/sun/net/httpserver/Test5.java index 31c42f12e7211..b57778a522663 100644 --- a/test/jdk/com/sun/net/httpserver/Test5.java +++ b/test/jdk/com/sun/net/httpserver/Test5.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 @@ -63,9 +63,8 @@ public static void main (String[] args) throws Exception { doClient(port); System.out.println ("OK"); } finally { - delay (); if (server != null) - server.stop(2); + server.stop(0); if (exec != null) exec.shutdown(); } diff --git a/test/jdk/com/sun/net/httpserver/Test6.java b/test/jdk/com/sun/net/httpserver/Test6.java index f13277e4994be..cf49cead89b6c 100644 --- a/test/jdk/com/sun/net/httpserver/Test6.java +++ b/test/jdk/com/sun/net/httpserver/Test6.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 @@ -81,8 +81,7 @@ public static void main (String[] args) throws Exception { if (error) { throw new RuntimeException ("test failed error"); } - delay(); - server.stop(2); + server.stop(0); executor.shutdown(); System.out.println ("OK"); diff --git a/test/jdk/com/sun/net/httpserver/Test6a.java b/test/jdk/com/sun/net/httpserver/Test6a.java index 73daf0a5f1b9a..bbe107f5e2fdd 100644 --- a/test/jdk/com/sun/net/httpserver/Test6a.java +++ b/test/jdk/com/sun/net/httpserver/Test6a.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 @@ -86,8 +86,7 @@ public static void main (String[] args) throws Exception { if (error) { throw new RuntimeException ("test failed error"); } - delay(); - server.stop(2); + server.stop(0); executor.shutdown(); System.out.println ("OK"); diff --git a/test/jdk/com/sun/net/httpserver/Test7.java b/test/jdk/com/sun/net/httpserver/Test7.java index e022109578dcd..2c204a8a60b5d 100644 --- a/test/jdk/com/sun/net/httpserver/Test7.java +++ b/test/jdk/com/sun/net/httpserver/Test7.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 @@ -80,8 +80,7 @@ public static void main (String[] args) throws Exception { if (error) { throw new RuntimeException ("test failed error"); } - delay(); - server.stop(2); + server.stop(0); executor.shutdown(); System.out.println ("OK"); diff --git a/test/jdk/com/sun/net/httpserver/Test7a.java b/test/jdk/com/sun/net/httpserver/Test7a.java index 65e8998f9d8a3..5ff01ade9a035 100644 --- a/test/jdk/com/sun/net/httpserver/Test7a.java +++ b/test/jdk/com/sun/net/httpserver/Test7a.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 @@ -89,8 +89,7 @@ public static void main (String[] args) throws Exception { if (error) { throw new RuntimeException ("test failed error"); } - delay(); - server.stop(2); + server.stop(0); executor.shutdown(); System.out.println ("OK"); diff --git a/test/jdk/com/sun/net/httpserver/Test8.java b/test/jdk/com/sun/net/httpserver/Test8.java index 343421e8adce1..0dfc35e50f434 100644 --- a/test/jdk/com/sun/net/httpserver/Test8.java +++ b/test/jdk/com/sun/net/httpserver/Test8.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 @@ -80,8 +80,7 @@ public static void main (String[] args) throws Exception { if (error) { throw new RuntimeException ("test failed error"); } - delay(); - server.stop(2); + server.stop(0); executor.shutdown(); System.out.println ("OK"); diff --git a/test/jdk/com/sun/net/httpserver/Test8a.java b/test/jdk/com/sun/net/httpserver/Test8a.java index 06cffa913aa92..6c642f7c22aa3 100644 --- a/test/jdk/com/sun/net/httpserver/Test8a.java +++ b/test/jdk/com/sun/net/httpserver/Test8a.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 @@ -99,8 +99,7 @@ public static void main (String[] args) throws Exception { } is.close(); } finally { - delay(); - if (server != null) server.stop(2); + if (server != null) server.stop(0); if (executor != null) executor.shutdown(); } if (error) { diff --git a/test/jdk/com/sun/net/httpserver/Test9.java b/test/jdk/com/sun/net/httpserver/Test9.java index d989d7d4d3cbe..af491d2233f28 100644 --- a/test/jdk/com/sun/net/httpserver/Test9.java +++ b/test/jdk/com/sun/net/httpserver/Test9.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 @@ -100,11 +100,10 @@ public static void main (String[] args) throws Exception { System.out.println ("OK"); } finally { - delay(); if (s1 != null) - s1.stop(2); + s1.stop(0); if (s2 != null) - s2.stop(2); + s2.stop(0); if (executor != null) executor.shutdown (); } diff --git a/test/jdk/com/sun/net/httpserver/Test9a.java b/test/jdk/com/sun/net/httpserver/Test9a.java index 66b044e8d9a73..fc061886d1e73 100644 --- a/test/jdk/com/sun/net/httpserver/Test9a.java +++ b/test/jdk/com/sun/net/httpserver/Test9a.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 @@ -96,9 +96,8 @@ public static void main (String[] args) throws Exception { System.out.println ("OK"); } finally { - delay(); if (server != null) - server.stop(2); + server.stop(0); if (executor != null) executor.shutdown(); } diff --git a/test/jdk/com/sun/net/httpserver/TestLogging.java b/test/jdk/com/sun/net/httpserver/TestLogging.java index 4f45197872cc0..0dd1fe00dc545 100644 --- a/test/jdk/com/sun/net/httpserver/TestLogging.java +++ b/test/jdk/com/sun/net/httpserver/TestLogging.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -105,9 +105,8 @@ public static void main (String[] args) throws Exception { os.close(); is.close(); s.close(); System.out.println ("OK"); } finally { - delay(); if (s1 != null) - s1.stop(2); + s1.stop(0); if (executor != null) executor.shutdown(); } diff --git a/test/jdk/com/sun/net/httpserver/bugs/8199849/BasicAuthenticatorCharset.java b/test/jdk/com/sun/net/httpserver/bugs/8199849/BasicAuthenticatorCharset.java index 4c520c91b77a6..675786242115b 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/8199849/BasicAuthenticatorCharset.java +++ b/test/jdk/com/sun/net/httpserver/bugs/8199849/BasicAuthenticatorCharset.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 @@ -181,7 +181,7 @@ public static void main(String[] args) throws Exception { connectAndAuth("/test3/defaultCharset.html", 200); } - testHttpServer.stop(2); + testHttpServer.stop(0); executor.shutdown(); // should fail once with UNICODE_PW and unsupporting character set diff --git a/test/jdk/com/sun/net/httpserver/bugs/8199849/TestHttpUnicode.java b/test/jdk/com/sun/net/httpserver/bugs/8199849/TestHttpUnicode.java index a31958d7dae85..bd608e71ca25c 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/8199849/TestHttpUnicode.java +++ b/test/jdk/com/sun/net/httpserver/bugs/8199849/TestHttpUnicode.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 @@ -94,7 +94,7 @@ public boolean checkCredentials(String username, String pw) { InputStream is = testConnection.getInputStream(); while (is.read() != -1) ; } finally { - testHttpServer.stop(2); + testHttpServer.stop(0); } } } diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6339483.java b/test/jdk/com/sun/net/httpserver/bugs/B6339483.java index d2a62155a9537..2bfa8ad3efc08 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6339483.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6339483.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 @@ -66,7 +66,7 @@ public static void main (String[] args) throws Exception { c ++; } } catch (IOException e) { - server.stop(2); + server.stop(0); executor.shutdown(); System.out.println ("OK"); } diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6341616.java b/test/jdk/com/sun/net/httpserver/bugs/B6341616.java index d8239481c3d27..82222faf08b37 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6341616.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6341616.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 @@ -75,7 +75,7 @@ public boolean checkCredentials (String username, String pw) { c ++; } } catch (IOException e) { - server.stop(2); + server.stop(0); executor.shutdown(); System.out.println ("OK"); } diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6361557.java b/test/jdk/com/sun/net/httpserver/bugs/B6361557.java index 0b5ef9488f802..57e831ec693d0 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6361557.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6361557.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -126,7 +126,7 @@ public static void main (String[] args) throws Exception { break; } } - server.stop (1); + server.stop(0); selector.close(); executor.shutdown (); diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6393710.java b/test/jdk/com/sun/net/httpserver/bugs/B6393710.java index 1eb4c2b64400c..89170e9aad94a 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6393710.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6393710.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,7 +96,7 @@ public boolean checkCredentials (String user, String pass) { ok = false; } finally { s.close(); - server.stop(2); + server.stop(0); } if (requests != 1) { diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6401598.java b/test/jdk/com/sun/net/httpserver/bugs/B6401598.java index 7a4477adbbadf..3a7821dbf5123 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6401598.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6401598.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -130,7 +130,7 @@ public static void main(String[] args) { } catch (Exception e) { throw new AssertionError("Unexpected exception: " + e, e); } finally { - server.stop (1); + server.stop(0); exec.shutdown(); } } diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6431193.java b/test/jdk/com/sun/net/httpserver/bugs/B6431193.java index be9e75f7c3f5b..9be9759054b9a 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6431193.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6431193.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,7 +85,7 @@ public void handle(HttpExchange t) throws IOException { .toURL(); InputStream is = url.openConnection(Proxy.NO_PROXY).getInputStream(); read (is); - server.stop (1); + server.stop(0); if (error) { throw new RuntimeException ("error in test"); } diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6433018.java b/test/jdk/com/sun/net/httpserver/bugs/B6433018.java index 6ae6607dec146..1a8e52cc34cf8 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6433018.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6433018.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,7 @@ public static void main(String[] args) throws Exception { os.write(cmd.getBytes()); finished.await(30, TimeUnit.SECONDS); } finally { - server.stop(2); + server.stop(0); } if (finished.getCount() != 0) diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6526158.java b/test/jdk/com/sun/net/httpserver/bugs/B6526158.java index 5207d07e7ccbf..c38f12b49c315 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6526158.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6526158.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,7 @@ public static void main (String[] args) throws Exception { } is.close(); } finally { - server.stop(2); + server.stop(0); executor.shutdown(); } if (error) { diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6526913.java b/test/jdk/com/sun/net/httpserver/bugs/B6526913.java index a8c4fe64f12af..4fb2efd67f8e8 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6526913.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6526913.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. * 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 { } is.close(); } finally { - server.stop(2); + server.stop(0); executor.shutdown(); } if (error) { diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6529200.java b/test/jdk/com/sun/net/httpserver/bugs/B6529200.java index 8c86fc93daae4..3ce792ffcd7f8 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6529200.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6529200.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. * 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 { /* test will timeout otherwise */ } } catch (SocketTimeoutException e) { - server.stop (2); + server.stop(0); executor.shutdown (); throw new RuntimeException ("Test failed in test1"); } @@ -92,20 +92,20 @@ public static void main (String[] args) throws Exception { buf[i++] = (byte)c; } } catch (SocketTimeoutException e) { - server.stop (2); + server.stop(0); executor.shutdown (); throw new RuntimeException ("Test failed in test2"); } String ss = new String (buf, "ISO-8859-1"); if (ss.indexOf ("\r\n\r\nhello world") == -1) { - server.stop (2); + server.stop(0); executor.shutdown (); throw new RuntimeException ("Test failed in test2: wrong string"); } System.out.println (ss); is.close (); - server.stop (2); + server.stop(0); executor.shutdown(); } diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6744329.java b/test/jdk/com/sun/net/httpserver/bugs/B6744329.java index b0ecc4f480bc1..9a782fd6c9474 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6744329.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6744329.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 @@ -72,7 +72,7 @@ public static void main (String[] args) throws Exception { e.printStackTrace(); error = true; } - server.stop(2); + server.stop(0); executor.shutdown(); if (error) { throw new RuntimeException ("Test failed"); diff --git a/test/jdk/com/sun/net/httpserver/bugs/B6886436.java b/test/jdk/com/sun/net/httpserver/bugs/B6886436.java index 710c27d4daa6b..050d2b20d5dbd 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B6886436.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B6886436.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,11 +74,11 @@ public static void main (String[] args) throws Exception { is.close (); } catch (IOException e) { - server.stop(2); + server.stop(0); executor.shutdown(); throw new RuntimeException ("Test failed"); } - server.stop(2); + server.stop(0); executor.shutdown(); System.out.println ("OK"); } diff --git a/test/jdk/com/sun/net/httpserver/bugs/B8211420.java b/test/jdk/com/sun/net/httpserver/bugs/B8211420.java index 7c7e13ba3b295..1a322e7945dc6 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/B8211420.java +++ b/test/jdk/com/sun/net/httpserver/bugs/B8211420.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, 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 @@ -86,7 +86,7 @@ public static void main(String[] args) throws Exception { throw new RuntimeException("Content-length not present or has wrong value"); System.out.println("OK"); } finally { - server.stop(2); + server.stop(0); executor.shutdown(); } } diff --git a/test/jdk/com/sun/net/httpserver/bugs/HttpExchange/AutoCloseableHttpExchange.java b/test/jdk/com/sun/net/httpserver/bugs/HttpExchange/AutoCloseableHttpExchange.java index f53bd9765ffb1..b25854c592134 100644 --- a/test/jdk/com/sun/net/httpserver/bugs/HttpExchange/AutoCloseableHttpExchange.java +++ b/test/jdk/com/sun/net/httpserver/bugs/HttpExchange/AutoCloseableHttpExchange.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 @@ -101,7 +101,7 @@ public static void main(String[] args) throws Exception { connectAndCheck("/test"); } latch.await(); - testHttpServer.stop(2); + testHttpServer.stop(0); executor.shutdown(); if (exchangeCloseFail.get()) diff --git a/test/lib/jdk/test/lib/net/SimpleHttpServer.java b/test/lib/jdk/test/lib/net/SimpleHttpServer.java index a347e383b358e..312df96a64bff 100644 --- a/test/lib/jdk/test/lib/net/SimpleHttpServer.java +++ b/test/lib/jdk/test/lib/net/SimpleHttpServer.java @@ -1,6 +1,6 @@ /* - * 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 @@ -71,7 +71,7 @@ public void start() throws IOException, URISyntaxException { } public void stop() { - httpServer.stop(2); + httpServer.stop(0); executor.shutdown(); } From b382b09b6c55274071d0b26a0796625ece9fc0f6 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 27 Sep 2023 08:19:33 +0000 Subject: [PATCH 157/341] 8316206: Test StretchedFontTest.java fails for Baekmuk font Ignore broken fonts, i.e. the fonts for which GlyphVector(TEXT).getVisualBounds().isEmpty() returns true Backport-of: 00f585bd22f527eca0107a9b4ed366f25754f0be --- .../font/FontScaling/StretchedFontTest.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/awt/font/FontScaling/StretchedFontTest.java b/test/jdk/java/awt/font/FontScaling/StretchedFontTest.java index da7c233f1c19e..84544767872d3 100644 --- a/test/jdk/java/awt/font/FontScaling/StretchedFontTest.java +++ b/test/jdk/java/awt/font/FontScaling/StretchedFontTest.java @@ -26,6 +26,7 @@ import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.font.FontRenderContext; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.io.File; @@ -61,15 +62,19 @@ public final class StretchedFontTest { new Color(0x7F000000, true) }; + /** Locale for getting font names. */ + private static final Locale ENGLISH_LOCALE = Locale.ENGLISH; + private static final AffineTransform STRETCH_TRANSFORM = AffineTransform.getScaleInstance(2.0, 1.0); public static void main(String[] args) { List errors = Arrays.stream(getLocalGraphicsEnvironment() - .getAvailableFontFamilyNames(Locale.ENGLISH)) + .getAvailableFontFamilyNames(ENGLISH_LOCALE)) .map(family -> new Font(family, Font.PLAIN, FONT_SIZE)) .filter(font -> font.canDisplay(TEXT.codePointAt(0))) + .filter(font -> !isBrokenFont(font)) .map(font -> font.deriveFont(STRETCH_TRANSFORM)) .flatMap(StretchedFontTest::testFont) .filter(Objects::nonNull) @@ -82,6 +87,26 @@ public static void main(String[] args) { } } + /** + * Checks whether the font renders the glyph in {@code TEXT} and + * returns {@code true} if the glyph isn't rendered. + * + * @param font the font to test + * @return {@code true} if the visual bounds of {@code TEXT} are empty, and + * {@code false} otherwise + */ + private static boolean isBrokenFont(final Font font) { + final boolean empty = + font.createGlyphVector(new FontRenderContext(null, false, false), + TEXT) + .getVisualBounds() + .isEmpty(); + if (empty) { + System.err.println("Broken font: " + font.getFontName(ENGLISH_LOCALE)); + } + return empty; + } + /** * Tests the font with a set of text antialiasing hints. * @@ -145,7 +170,7 @@ private static String testFont(final Font font, if (verifyImage(image)) { return null; } - String fontName = font.getFontName(Locale.ENGLISH); + String fontName = font.getFontName(ENGLISH_LOCALE); String hintValue = getHintString(hint); String hexColor = String.format("0x%08x", foreground.getRGB()); saveImage(image, fontName + "-" + hintValue + "-" + hexColor); From 64be3f029a4113407a62ade085e802fad3691be0 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Wed, 27 Sep 2023 09:26:25 +0000 Subject: [PATCH 158/341] 8313792: Verify 4th party information in src/jdk.internal.le/share/legal/jline.md Backport-of: 87a6acbeee1673526bfc5f8692e0949cb113e841 --- src/jdk.internal.le/share/legal/jline.md | 253 ----------------------- 1 file changed, 253 deletions(-) diff --git a/src/jdk.internal.le/share/legal/jline.md b/src/jdk.internal.le/share/legal/jline.md index 4e5d344b4d156..6840c69cfc02b 100644 --- a/src/jdk.internal.le/share/legal/jline.md +++ b/src/jdk.internal.le/share/legal/jline.md @@ -38,257 +38,4 @@ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -4th Party Dependency -============= -org.fusesource.jansi version 2.4.0 -org.apache.sshd 2.9.2 -org.apache.felix.gogo.runtime 1.1.6 -org.apache.felix.gogo.jline 1.1.8 -============= -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -============= -juniversalchardet - -The library is subject to the Mozilla Public License Version 1.1. - -Alternatively, the library may be used under the terms of either the GNU General Public License Version 2 or later, or the GNU Lesser General Public License 2.1 or later. - -================ - -slf4j - -SLF4J source code and binaries are distributed under the MIT license. - - -Copyright (c) 2004-2023 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -These terms are identical to those of the MIT License, also called the X License -or the X11 License, which is a simple, permissive non-copyleft free software license. -It is deemed compatible with virtually all types of licenses, commercial or otherwise. -In particular, the Free Software Foundation has declared it compatible with GNU GPL. -It is also known to be approved by the Apache Software Foundation as compatible with -Apache Software License. - From e7fc89db52a1ca4ce4c347612b19b8054b1c8d76 Mon Sep 17 00:00:00 2001 From: Ilya Gavrilin Date: Wed, 27 Sep 2023 17:04:06 +0000 Subject: [PATCH 159/341] 8313322: RISC-V: implement MD5 intrinsic Reviewed-by: fyang Backport-of: b093880acd89d8d0bccd4b8b260b721f4dcfc161 --- .../cpu/riscv/macroAssembler_riscv.cpp | 16 + .../cpu/riscv/macroAssembler_riscv.hpp | 5 +- src/hotspot/cpu/riscv/register_riscv.hpp | 68 +++- src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 372 ++++++++++++++++++ src/hotspot/cpu/riscv/stubRoutines_riscv.hpp | 4 +- src/hotspot/cpu/riscv/vm_version_riscv.cpp | 5 +- 6 files changed, 463 insertions(+), 7 deletions(-) diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 0e7f3ea69cd3f..dc3dfde30d427 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -1776,6 +1776,22 @@ void MacroAssembler::ror_imm(Register dst, Register src, uint32_t shift, Registe orr(dst, dst, tmp); } +// rotate left with shift bits, 32-bit version +void MacroAssembler::rolw_imm(Register dst, Register src, uint32_t shift, Register tmp) { + if (UseZbb) { + // no roliw available + roriw(dst, src, 32 - shift); + return; + } + + assert_different_registers(dst, tmp); + assert_different_registers(src, tmp); + assert(shift < 32, "shift amount must be < 32"); + srliw(tmp, src, 32 - shift); + slliw(dst, src, shift); + orr(dst, dst, tmp); +} + void MacroAssembler::andi(Register Rd, Register Rn, int64_t imm, Register tmp) { if (is_simm12(imm)) { and_imm12(Rd, Rn, imm); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index d92031192ab0a..718469db6d9ec 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -568,7 +568,9 @@ class MacroAssembler: public Assembler { void NAME(Register Rs1, Register Rs2, const address dest) { \ assert_cond(dest != NULL); \ int64_t offset = dest - pc(); \ - guarantee(is_simm13(offset) && ((offset % 2) == 0), "offset is invalid."); \ + guarantee(is_simm13(offset) && is_even(offset), \ + "offset is invalid: is_simm_13: %s offset: " INT64_FORMAT, \ + BOOL_TO_STR(is_simm13(offset)), offset); \ Assembler::NAME(Rs1, Rs2, offset); \ } \ INSN_ENTRY_RELOC(void, NAME(Register Rs1, Register Rs2, address dest, relocInfo::relocType rtype)) \ @@ -740,6 +742,7 @@ class MacroAssembler: public Assembler { void revb(Register Rd, Register Rs, Register tmp1 = t0, Register tmp2 = t1); // reverse bytes in doubleword void ror_imm(Register dst, Register src, uint32_t shift, Register tmp = t0); + void rolw_imm(Register dst, Register src, uint32_t, Register tmp = t0); void andi(Register Rd, Register Rn, int64_t imm, Register tmp = t0); void orptr(Address adr, RegisterOrConstant src, Register tmp1 = t0, Register tmp2 = t1); diff --git a/src/hotspot/cpu/riscv/register_riscv.hpp b/src/hotspot/cpu/riscv/register_riscv.hpp index 8fa9e4237ffab..65020bca7b048 100644 --- a/src/hotspot/cpu/riscv/register_riscv.hpp +++ b/src/hotspot/cpu/riscv/register_riscv.hpp @@ -27,6 +27,8 @@ #define CPU_RISCV_REGISTER_RISCV_HPP #include "asm/register.hpp" +#include "utilities/population_count.hpp" +#include "utilities/powerOfTwo.hpp" #define CSR_FFLAGS 0x001 // Floating-Point Accrued Exceptions. #define CSR_FRM 0x002 // Floating-Point Dynamic Rounding Mode. @@ -318,6 +320,8 @@ class ConcreteRegisterImpl : public AbstractRegisterImpl { static const int max_vpr; }; +template class RegSetIterator; + // A set of registers template class AbstractRegSet { @@ -325,7 +329,7 @@ class AbstractRegSet { AbstractRegSet(uint32_t bitset) : _bitset(bitset) { } - public: +public: AbstractRegSet() : _bitset(0) { } AbstractRegSet(RegImpl r1) : _bitset(1 << r1->encoding()) { } @@ -375,11 +379,73 @@ class AbstractRegSet { return AbstractRegSet(bits); } + uint size() const { return population_count(_bitset); } + uint32_t bits() const { return _bitset; } + +private: + + RegImpl first(); + +public: + + friend class RegSetIterator; + + RegSetIterator begin(); }; typedef AbstractRegSet RegSet; typedef AbstractRegSet FloatRegSet; typedef AbstractRegSet VectorRegSet; +template +class RegSetIterator { + AbstractRegSet _regs; + +public: + RegSetIterator(AbstractRegSet x): _regs(x) {} + RegSetIterator(const RegSetIterator& mit) : _regs(mit._regs) {} + + RegSetIterator& operator++() { + RegImpl r = _regs.first(); + if (r->is_valid()) + _regs -= r; + return *this; + } + + bool operator==(const RegSetIterator& rhs) const { + return _regs.bits() == rhs._regs.bits(); + } + bool operator!=(const RegSetIterator& rhs) const { + return ! (rhs == *this); + } + + RegImpl operator*() { + return _regs.first(); + } +}; + +template +inline RegSetIterator AbstractRegSet::begin() { + return RegSetIterator(*this); +} + +template <> +inline Register AbstractRegSet::first() { + uint32_t first = _bitset & -_bitset; + return first ? as_Register(exact_log2(first)) : noreg; +} + +template <> +inline FloatRegister AbstractRegSet::first() { + uint32_t first = _bitset & -_bitset; + return first ? as_FloatRegister(exact_log2(first)) : fnoreg; +} + +template<> +inline VectorRegister AbstractRegSet::first() { + uint32_t first = _bitset & -_bitset; + return first ? as_VectorRegister(exact_log2(first)) : vnoreg; +} + #endif // CPU_RISCV_REGISTER_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index a008d1d8bef55..0416f6bca6d99 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -3686,6 +3686,373 @@ class StubGenerator: public StubCodeGenerator { }; #endif // COMPILER2 + // Set of L registers that correspond to a contiguous memory area. + // Each 64-bit register typically corresponds to 2 32-bit integers. + template + class RegCache { + private: + MacroAssembler *_masm; + Register _regs[L]; + + public: + RegCache(MacroAssembler *masm, RegSet rs): _masm(masm) { + assert(rs.size() == L, "%u registers are used to cache %u 4-byte data", rs.size(), 2 * L); + auto it = rs.begin(); + for (auto &r: _regs) { + r = *it; + ++it; + } + } + + void gen_loads(Register base) { + for (uint i = 0; i < L; i += 1) { + __ ld(_regs[i], Address(base, 8 * i)); + } + } + + // Generate code extracting i-th unsigned word (4 bytes). + void get_u32(Register dest, uint i, Register rmask32) { + assert(i < 2 * L, "invalid i: %u", i); + + if (i % 2 == 0) { + __ andr(dest, _regs[i / 2], rmask32); + } else { + __ srli(dest, _regs[i / 2], 32); + } + } + }; + + typedef RegCache<8> BufRegCache; + + // a += rtmp1 + x + ac; + // a = Integer.rotateLeft(a, s) + b; + void m5_FF_GG_HH_II_epilogue(BufRegCache& reg_cache, + Register a, Register b, Register c, Register d, + int k, int s, int t, + Register rtmp1, Register rtmp2, Register rmask32) { + // rtmp1 = rtmp1 + x + ac + reg_cache.get_u32(rtmp2, k, rmask32); + __ addw(rtmp1, rtmp1, rtmp2); + __ li(rtmp2, t); + __ addw(rtmp1, rtmp1, rtmp2); + + // a += rtmp1 + x + ac + __ addw(a, a, rtmp1); + + // a = Integer.rotateLeft(a, s) + b; + __ rolw_imm(a, a, s, rtmp1); + __ addw(a, a, b); + } + + // a += ((b & c) | ((~b) & d)) + x + ac; + // a = Integer.rotateLeft(a, s) + b; + void md5_FF(BufRegCache& reg_cache, + Register a, Register b, Register c, Register d, + int k, int s, int t, + Register rtmp1, Register rtmp2, Register rmask32) { + // rtmp1 = b & c + __ andr(rtmp1, b, c); + + // rtmp2 = (~b) & d + __ notr(rtmp2, b); + __ andr(rtmp2, rtmp2, d); + + // rtmp1 = (b & c) | ((~b) & d) + __ orr(rtmp1, rtmp1, rtmp2); + + m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, + rtmp1, rtmp2, rmask32); + } + + // a += ((b & d) | (c & (~d))) + x + ac; + // a = Integer.rotateLeft(a, s) + b; + void md5_GG(BufRegCache& reg_cache, + Register a, Register b, Register c, Register d, + int k, int s, int t, + Register rtmp1, Register rtmp2, Register rmask32) { + // rtmp1 = b & d + __ andr(rtmp1, b, d); + + // rtmp2 = (c & (~d)) + __ notr(rtmp2, d); + __ andr(rtmp2, rtmp2, c); + + // rtmp1 = (b & d) | (c & (~d)) + __ orr(rtmp1, rtmp1, rtmp2); + + m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, + rtmp1, rtmp2, rmask32); + } + + // a += ((b ^ c) ^ d) + x + ac; + // a = Integer.rotateLeft(a, s) + b; + void md5_HH(BufRegCache& reg_cache, + Register a, Register b, Register c, Register d, + int k, int s, int t, + Register rtmp1, Register rtmp2, Register rmask32) { + // rtmp1 = (b ^ c) ^ d + __ xorr(rtmp1, b, c); + __ xorr(rtmp1, rtmp1, d); + + m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, + rtmp1, rtmp2, rmask32); + } + + // a += (c ^ (b | (~d))) + x + ac; + // a = Integer.rotateLeft(a, s) + b; + void md5_II(BufRegCache& reg_cache, + Register a, Register b, Register c, Register d, + int k, int s, int t, + Register rtmp1, Register rtmp2, Register rmask32) { + // rtmp1 = c ^ (b | (~d)) + __ notr(rtmp2, d); + __ orr(rtmp1, b, rtmp2); + __ xorr(rtmp1, c, rtmp1); + + m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, + rtmp1, rtmp2, rmask32); + } + + // Arguments: + // + // Inputs: + // c_rarg0 - byte[] source+offset + // c_rarg1 - int[] SHA.state + // c_rarg2 - int offset (multi_block == True) + // c_rarg3 - int limit (multi_block == True) + // + // Registers: + // x0 zero (zero) + // x1 ra (return address) + // x2 sp (stack pointer) + // x3 gp (global pointer) + // x4 tp (thread pointer) + // x5 t0 state0 + // x6 t1 state1 + // x7 t2 state2 + // x8 f0/s0 (frame pointer) + // x9 s1 state3 [saved-reg] + // x10 a0 rtmp1 / c_rarg0 + // x11 a1 rtmp2 / c_rarg1 + // x12 a2 a / c_rarg2 + // x13 a3 b / c_rarg3 + // x14 a4 c + // x15 a5 d + // x16 a6 buf + // x17 a7 state + // x18 s2 ofs [saved-reg] (multi_block == True) + // x19 s3 limit [saved-reg] (multi_block == True) + // x20 s4 + // x21 s5 + // x22 s6 mask32 [saved-reg] + // x23 s7 + // x24 s8 buf0 [saved-reg] + // x25 s9 buf1 [saved-reg] + // x26 s10 buf2 [saved-reg] + // x27 s11 buf3 [saved-reg] + // x28 t3 buf4 + // x29 t4 buf5 + // x30 t5 buf6 + // x31 t6 buf7 + address generate_md5_implCompress(bool multi_block, const char *name) { + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", name); + address start = __ pc(); + + // rotation constants + const int S11 = 7; + const int S12 = 12; + const int S13 = 17; + const int S14 = 22; + const int S21 = 5; + const int S22 = 9; + const int S23 = 14; + const int S24 = 20; + const int S31 = 4; + const int S32 = 11; + const int S33 = 16; + const int S34 = 23; + const int S41 = 6; + const int S42 = 10; + const int S43 = 15; + const int S44 = 21; + + Register buf_arg = c_rarg0; // a0 + Register state_arg = c_rarg1; // a1 + Register ofs_arg = c_rarg2; // a2 + Register limit_arg = c_rarg3; // a3 + + // we'll copy the args to these registers to free up a0-a3 + // to use for other values manipulated by instructions + // that can be compressed + Register buf = x16; // a6 + Register state = x17; // a7 + Register ofs = x18; // s2 + Register limit = x19; // s3 + + // using x12->15 to allow compressed instructions + Register a = x12; // a2 + Register b = x13; // a3 + Register c = x14; // a4 + Register d = x15; // a5 + + Register state0 = x5; // t0 + Register state1 = x6; // t1 + Register state2 = x7; // t2 + Register state3 = x9; // s1 + + // using x9->x11 to allow compressed instructions + Register rtmp1 = x10; // a0 + Register rtmp2 = x11; // a1 + + const int64_t MASK_32 = 0xffffffff; + Register rmask32 = x22; // s6 + + RegSet reg_cache_saved_regs = RegSet::of(x24, x25, x26, x27); // s8, s9, s10, s11 + RegSet reg_cache_regs; + reg_cache_regs += reg_cache_saved_regs; + reg_cache_regs += RegSet::of(x28, x29, x30, x31); // t3, t4, t5, t6 + BufRegCache reg_cache(_masm, reg_cache_regs); + + RegSet saved_regs; + if (multi_block) { + saved_regs += RegSet::of(ofs, limit); + } + saved_regs += RegSet::of(state3, rmask32); + saved_regs += reg_cache_saved_regs; + + __ push_reg(saved_regs, sp); + + __ mv(buf, buf_arg); + __ mv(state, state_arg); + if (multi_block) { + __ mv(ofs, ofs_arg); + __ mv(limit, limit_arg); + } + __ li(rmask32, MASK_32); + + // to minimize the number of memory operations: + // read the 4 state 4-byte values in pairs, with a single ld, + // and split them into 2 registers + __ ld(state0, Address(state)); + __ srli(state1, state0, 32); + __ andr(state0, state0, rmask32); + __ ld(state2, Address(state, 8)); + __ srli(state3, state2, 32); + __ andr(state2, state2, rmask32); + + Label md5_loop; + __ BIND(md5_loop); + + reg_cache.gen_loads(buf); + + __ mv(a, state0); + __ mv(b, state1); + __ mv(c, state2); + __ mv(d, state3); + + // Round 1 + md5_FF(reg_cache, a, b, c, d, 0, S11, 0xd76aa478, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, d, a, b, c, 1, S12, 0xe8c7b756, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, c, d, a, b, 2, S13, 0x242070db, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, b, c, d, a, 3, S14, 0xc1bdceee, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, a, b, c, d, 4, S11, 0xf57c0faf, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, d, a, b, c, 5, S12, 0x4787c62a, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, c, d, a, b, 6, S13, 0xa8304613, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, b, c, d, a, 7, S14, 0xfd469501, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, a, b, c, d, 8, S11, 0x698098d8, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, d, a, b, c, 9, S12, 0x8b44f7af, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, c, d, a, b, 10, S13, 0xffff5bb1, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, b, c, d, a, 11, S14, 0x895cd7be, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, a, b, c, d, 12, S11, 0x6b901122, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, d, a, b, c, 13, S12, 0xfd987193, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, c, d, a, b, 14, S13, 0xa679438e, rtmp1, rtmp2, rmask32); + md5_FF(reg_cache, b, c, d, a, 15, S14, 0x49b40821, rtmp1, rtmp2, rmask32); + + // Round 2 + md5_GG(reg_cache, a, b, c, d, 1, S21, 0xf61e2562, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, d, a, b, c, 6, S22, 0xc040b340, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, c, d, a, b, 11, S23, 0x265e5a51, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, b, c, d, a, 0, S24, 0xe9b6c7aa, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, a, b, c, d, 5, S21, 0xd62f105d, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, d, a, b, c, 10, S22, 0x02441453, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, c, d, a, b, 15, S23, 0xd8a1e681, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, b, c, d, a, 4, S24, 0xe7d3fbc8, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, a, b, c, d, 9, S21, 0x21e1cde6, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, d, a, b, c, 14, S22, 0xc33707d6, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, c, d, a, b, 3, S23, 0xf4d50d87, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, b, c, d, a, 8, S24, 0x455a14ed, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, a, b, c, d, 13, S21, 0xa9e3e905, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, d, a, b, c, 2, S22, 0xfcefa3f8, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, c, d, a, b, 7, S23, 0x676f02d9, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, b, c, d, a, 12, S24, 0x8d2a4c8a, rtmp1, rtmp2, rmask32); + + // Round 3 + md5_HH(reg_cache, a, b, c, d, 5, S31, 0xfffa3942, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, d, a, b, c, 8, S32, 0x8771f681, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, c, d, a, b, 11, S33, 0x6d9d6122, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, b, c, d, a, 14, S34, 0xfde5380c, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, a, b, c, d, 1, S31, 0xa4beea44, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, d, a, b, c, 4, S32, 0x4bdecfa9, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, c, d, a, b, 7, S33, 0xf6bb4b60, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, b, c, d, a, 10, S34, 0xbebfbc70, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, a, b, c, d, 13, S31, 0x289b7ec6, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, d, a, b, c, 0, S32, 0xeaa127fa, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, c, d, a, b, 3, S33, 0xd4ef3085, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, b, c, d, a, 6, S34, 0x04881d05, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, a, b, c, d, 9, S31, 0xd9d4d039, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, d, a, b, c, 12, S32, 0xe6db99e5, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, c, d, a, b, 15, S33, 0x1fa27cf8, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, b, c, d, a, 2, S34, 0xc4ac5665, rtmp1, rtmp2, rmask32); + + // Round 4 + md5_II(reg_cache, a, b, c, d, 0, S41, 0xf4292244, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, d, a, b, c, 7, S42, 0x432aff97, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, c, d, a, b, 14, S43, 0xab9423a7, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, b, c, d, a, 5, S44, 0xfc93a039, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, a, b, c, d, 12, S41, 0x655b59c3, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, d, a, b, c, 3, S42, 0x8f0ccc92, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, c, d, a, b, 10, S43, 0xffeff47d, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, b, c, d, a, 1, S44, 0x85845dd1, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, a, b, c, d, 8, S41, 0x6fa87e4f, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, d, a, b, c, 15, S42, 0xfe2ce6e0, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, c, d, a, b, 6, S43, 0xa3014314, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, b, c, d, a, 13, S44, 0x4e0811a1, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, a, b, c, d, 4, S41, 0xf7537e82, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, d, a, b, c, 11, S42, 0xbd3af235, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, c, d, a, b, 2, S43, 0x2ad7d2bb, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, b, c, d, a, 9, S44, 0xeb86d391, rtmp1, rtmp2, rmask32); + + __ addw(state0, state0, a); + __ addw(state1, state1, b); + __ addw(state2, state2, c); + __ addw(state3, state3, d); + + if (multi_block) { + __ addi(buf, buf, 64); + __ addi(ofs, ofs, 64); + // if (ofs <= limit) goto m5_loop + __ bge(limit, ofs, md5_loop); + __ mv(c_rarg0, ofs); // return ofs + } + + // to minimize the number of memory operations: + // write back the 4 state 4-byte values in pairs, with a single sd + __ andr(state0, state0, rmask32); + __ slli(state1, state1, 32); + __ orr(state0, state0, state1); + __ sd(state0, Address(state)); + __ andr(state2, state2, rmask32); + __ slli(state3, state3, 32); + __ orr(state2, state2, state3); + __ sd(state2, Address(state, 8)); + + __ pop_reg(saved_regs, sp); + __ ret(); + + return (address) start; + } + // Continuation point for throwing of implicit exceptions that are // not handled in the current activation. Fabricates an exception // oop and initiates normal exception dispatching in this @@ -3882,6 +4249,11 @@ class StubGenerator: public StubCodeGenerator { generate_string_indexof_stubs(); + if (UseMD5Intrinsics) { + StubRoutines::_md5_implCompress = generate_md5_implCompress(false, "md5_implCompress"); + StubRoutines::_md5_implCompressMB = generate_md5_implCompress(true, "md5_implCompressMB"); + } + BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod(); if (bs_nm != NULL) { StubRoutines::riscv::_method_entry_barrier = generate_method_entry_barrier(); diff --git a/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp b/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp index 51f07819c33a1..2d2dac1b53d2d 100644 --- a/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp +++ b/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp @@ -36,8 +36,8 @@ static bool returns_to_call_stub(address return_pc) { } enum platform_dependent_constants { - code_size1 = 19000, // simply increase if too small (assembler will crash if too small) - code_size2 = 28000 // simply increase if too small (assembler will crash if too small) + code_size1 = 20000, // simply increase if too small (assembler will crash if too small) + code_size2 = 30000 // simply increase if too small (assembler will crash if too small) }; class riscv { diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index 63eb94d018bc7..1f66b29816a4f 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -111,9 +111,8 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseCRC32CIntrinsics, false); } - if (UseMD5Intrinsics) { - warning("MD5 intrinsics are not available on this CPU."); - FLAG_SET_DEFAULT(UseMD5Intrinsics, false); + if (FLAG_IS_DEFAULT(UseMD5Intrinsics)) { + FLAG_SET_DEFAULT(UseMD5Intrinsics, true); } if (UseRVV) { From 8961594f8baebb75a17086cc29f43e1c36aae6ab Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 28 Sep 2023 09:06:44 +0000 Subject: [PATCH 160/341] 8300997: Add curl support to createJMHBundle.sh Backport-of: 61775c85b0989e4de310290e9441851f32cb84a3 --- make/devkit/createJMHBundle.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/make/devkit/createJMHBundle.sh b/make/devkit/createJMHBundle.sh index 4a257577018f2..c3c97947dabf0 100644 --- a/make/devkit/createJMHBundle.sh +++ b/make/devkit/createJMHBundle.sh @@ -1,6 +1,6 @@ #!/bin/bash -e # -# 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 @@ -40,10 +40,22 @@ mkdir -p $BUILD_DIR $JAR_DIR cd $JAR_DIR rm -f * -wget https://repo.maven.apache.org/maven2/org/apache/commons/commons-math3/$COMMONS_MATH3_VERSION/commons-math3-$COMMONS_MATH3_VERSION.jar -wget https://repo.maven.apache.org/maven2/net/sf/jopt-simple/jopt-simple/$JOPT_SIMPLE_VERSION/jopt-simple-$JOPT_SIMPLE_VERSION.jar -wget https://repo.maven.apache.org/maven2/org/openjdk/jmh/jmh-core/$JMH_VERSION/jmh-core-$JMH_VERSION.jar -wget https://repo.maven.apache.org/maven2/org/openjdk/jmh/jmh-generator-annprocess/$JMH_VERSION/jmh-generator-annprocess-$JMH_VERSION.jar +fetchJar() { + url="https://repo.maven.apache.org/maven2/$1/$2/$3/$2-$3.jar" + if command -v curl > /dev/null; then + curl -O --fail $url + elif command -v wget > /dev/null; then + wget $url + else + echo "Could not find either curl or wget" + exit 1 + fi +} + +fetchJar org/apache/commons commons-math3 $COMMONS_MATH3_VERSION +fetchJar net/sf/jopt-simple jopt-simple $JOPT_SIMPLE_VERSION +fetchJar org/openjdk/jmh jmh-core $JMH_VERSION +fetchJar org/openjdk/jmh jmh-generator-annprocess $JMH_VERSION tar -cvzf ../$BUNDLE_NAME * From 4ecf818acd56a2d396839c1def4bfadf53811d2c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 28 Sep 2023 09:07:11 +0000 Subject: [PATCH 161/341] 8276054: JMH benchmarks for Fences Backport-of: 5a768f75c9cb013edbf6c61e79820bd180cad4ba --- .../org/openjdk/bench/vm/fences/Multiple.java | 85 ++++++++++++++ .../bench/vm/fences/MultipleWithLoads.java | 111 ++++++++++++++++++ .../bench/vm/fences/MultipleWithStores.java | 105 +++++++++++++++++ .../bench/vm/fences/SafePublishing.java | 80 +++++++++++++ .../org/openjdk/bench/vm/fences/Single.java | 70 +++++++++++ 5 files changed, 451 insertions(+) create mode 100644 test/micro/org/openjdk/bench/vm/fences/Multiple.java create mode 100644 test/micro/org/openjdk/bench/vm/fences/MultipleWithLoads.java create mode 100644 test/micro/org/openjdk/bench/vm/fences/MultipleWithStores.java create mode 100644 test/micro/org/openjdk/bench/vm/fences/SafePublishing.java create mode 100644 test/micro/org/openjdk/bench/vm/fences/Single.java diff --git a/test/micro/org/openjdk/bench/vm/fences/Multiple.java b/test/micro/org/openjdk/bench/vm/fences/Multiple.java new file mode 100644 index 0000000000000..fd6c80431d05c --- /dev/null +++ b/test/micro/org/openjdk/bench/vm/fences/Multiple.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2021, Red Hat, Inc. All rights reserved. + * 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 org.openjdk.bench.vm.fences; + +import org.openjdk.jmh.annotations.*; + +import java.lang.invoke.VarHandle; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(3) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +public class Multiple { + + @Benchmark + public void plain() { + // Do nothing + } + + @Benchmark + public void loadLoad() { + VarHandle.loadLoadFence(); + VarHandle.loadLoadFence(); + VarHandle.loadLoadFence(); + VarHandle.loadLoadFence(); + } + + @Benchmark + public void storeStore() { + VarHandle.storeStoreFence(); + VarHandle.storeStoreFence(); + VarHandle.storeStoreFence(); + VarHandle.storeStoreFence(); + } + + @Benchmark + public void acquire() { + VarHandle.acquireFence(); + VarHandle.acquireFence(); + VarHandle.acquireFence(); + VarHandle.acquireFence(); + } + + @Benchmark + public void release() { + VarHandle.releaseFence(); + VarHandle.releaseFence(); + VarHandle.releaseFence(); + VarHandle.releaseFence(); + } + + @Benchmark + public void full() { + VarHandle.fullFence(); + VarHandle.fullFence(); + VarHandle.fullFence(); + VarHandle.fullFence(); + } + +} diff --git a/test/micro/org/openjdk/bench/vm/fences/MultipleWithLoads.java b/test/micro/org/openjdk/bench/vm/fences/MultipleWithLoads.java new file mode 100644 index 0000000000000..b4cf6975c0afe --- /dev/null +++ b/test/micro/org/openjdk/bench/vm/fences/MultipleWithLoads.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2021, Red Hat, Inc. All rights reserved. + * 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 org.openjdk.bench.vm.fences; + +import org.openjdk.jmh.annotations.*; + +import java.lang.invoke.VarHandle; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(3) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +public class MultipleWithLoads { + + int x, y, z; + + @Benchmark + public int plain() { + int t1 = x + y + z; + int t2 = x + y + z; + int t3 = x + y + z; + return t1 + t2 + t3; + } + + @Benchmark + public int loadLoad() { + VarHandle.loadLoadFence(); + int t1 = x + y + z; + VarHandle.loadLoadFence(); + int t2 = x + y + z; + VarHandle.loadLoadFence(); + int t3 = x + y + z; + VarHandle.loadLoadFence(); + return t1 + t2 + t3; + } + + @Benchmark + public int storeStore() { + VarHandle.storeStoreFence(); + int t1 = x + y + z; + VarHandle.storeStoreFence(); + int t2 = x + y + z; + VarHandle.storeStoreFence(); + int t3 = x + y + z; + VarHandle.storeStoreFence(); + return t1 + t2 + t3; + } + + @Benchmark + public int acquire() { + VarHandle.acquireFence(); + int t1 = x + y + z; + VarHandle.acquireFence(); + int t2 = x + y + z; + VarHandle.acquireFence(); + int t3 = x + y + z; + VarHandle.acquireFence(); + return t1 + t2 + t3; + } + + @Benchmark + public int release() { + VarHandle.releaseFence(); + int t1 = x + y + z; + VarHandle.releaseFence(); + int t2 = x + y + z; + VarHandle.releaseFence(); + int t3 = x + y + z; + VarHandle.releaseFence(); + return t1 + t2 + t3; + } + + @Benchmark + public int full() { + VarHandle.fullFence(); + int t1 = x + y + z; + VarHandle.fullFence(); + int t2 = x + y + z; + VarHandle.fullFence(); + int t3 = x + y + z; + VarHandle.fullFence(); + return t1 + t2 + t3; + } + +} diff --git a/test/micro/org/openjdk/bench/vm/fences/MultipleWithStores.java b/test/micro/org/openjdk/bench/vm/fences/MultipleWithStores.java new file mode 100644 index 0000000000000..c405b93b178fb --- /dev/null +++ b/test/micro/org/openjdk/bench/vm/fences/MultipleWithStores.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2021, Red Hat, Inc. All rights reserved. + * 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 org.openjdk.bench.vm.fences; + +import org.openjdk.jmh.annotations.*; + +import java.lang.invoke.VarHandle; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(3) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +public class MultipleWithStores { + + int x, y, z; + + @Benchmark + public void plain() { + x = 1; + y = 1; + z = 1; + } + + @Benchmark + public void loadLoad() { + VarHandle.loadLoadFence(); + x = 1; + VarHandle.loadLoadFence(); + y = 1; + VarHandle.loadLoadFence(); + z = 1; + VarHandle.loadLoadFence(); + } + + @Benchmark + public void storeStore() { + VarHandle.storeStoreFence(); + x = 1; + VarHandle.storeStoreFence(); + y = 1; + VarHandle.storeStoreFence(); + z = 1; + VarHandle.storeStoreFence(); + } + + @Benchmark + public void acquire() { + VarHandle.releaseFence(); + x = 1; + VarHandle.releaseFence(); + y = 1; + VarHandle.releaseFence(); + z = 1; + VarHandle.releaseFence(); + } + + @Benchmark + public void release() { + VarHandle.releaseFence(); + x = 1; + VarHandle.releaseFence(); + y = 1; + VarHandle.releaseFence(); + z = 1; + VarHandle.releaseFence(); + } + + @Benchmark + public void full() { + VarHandle.fullFence(); + x = 1; + VarHandle.fullFence(); + y = 1; + VarHandle.fullFence(); + z = 1; + VarHandle.fullFence(); + } + +} diff --git a/test/micro/org/openjdk/bench/vm/fences/SafePublishing.java b/test/micro/org/openjdk/bench/vm/fences/SafePublishing.java new file mode 100644 index 0000000000000..d337c6dd7c918 --- /dev/null +++ b/test/micro/org/openjdk/bench/vm/fences/SafePublishing.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2021, Red Hat, Inc. All rights reserved. + * 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 org.openjdk.bench.vm.fences; + +import org.openjdk.jmh.annotations.*; + +import java.lang.invoke.VarHandle; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(value = 3, jvmArgsAppend = {"-XX:+UseParallelGC", "-Xmx128m"}) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +public class SafePublishing { + + @Benchmark + public Object plain() { + return new Plain(); + } + + @Benchmark + public Object release() { + return new Release(); + } + + @Benchmark + public Object storeStore() { + return new StoreStore(); + } + + static class Plain { + int x; + public Plain() { + x = 1; + VarHandle.releaseFence(); + } + } + + static class Release { + int x; + public Release() { + x = 1; + VarHandle.releaseFence(); + } + } + + static class StoreStore { + int x; + public StoreStore() { + x = 1; + VarHandle.storeStoreFence(); + } + } + +} diff --git a/test/micro/org/openjdk/bench/vm/fences/Single.java b/test/micro/org/openjdk/bench/vm/fences/Single.java new file mode 100644 index 0000000000000..ff74339cc621b --- /dev/null +++ b/test/micro/org/openjdk/bench/vm/fences/Single.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021, Red Hat, Inc. All rights reserved. + * 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 org.openjdk.bench.vm.fences; + +import org.openjdk.jmh.annotations.*; + +import java.lang.invoke.VarHandle; +import java.util.concurrent.TimeUnit; + +@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) +@Fork(3) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +public class Single { + + @Benchmark + public void plain() { + // Do nothing + } + + @Benchmark + public void loadLoad() { + VarHandle.loadLoadFence(); + } + + @Benchmark + public void storeStore() { + VarHandle.storeStoreFence(); + } + + @Benchmark + public void acquire() { + VarHandle.acquireFence(); + } + + @Benchmark + public void release() { + VarHandle.releaseFence(); + } + + @Benchmark + public void full() { + VarHandle.fullFence(); + } + +} From 0ce7d860972603708783d7798b39759657461c2e Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Thu, 28 Sep 2023 09:20:04 +0000 Subject: [PATCH 162/341] 8289745: JfrStructCopyFailed uses heap words instead of bytes for object sizes Backport-of: 7f0e9bd632198c7fd34d27b85ca51ea0e2442e4d --- src/hotspot/share/gc/g1/g1Trace.cpp | 6 +++--- src/hotspot/share/gc/shared/gcTraceSend.cpp | 6 +++--- .../jdk/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java | 4 ++++ .../jfr/event/gc/detailed/TestEvacuationFailedEvent.java | 4 ++++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1Trace.cpp b/src/hotspot/share/gc/g1/g1Trace.cpp index 7bc3cce6c5c7f..a89754751641d 100644 --- a/src/hotspot/share/gc/g1/g1Trace.cpp +++ b/src/hotspot/share/gc/g1/g1Trace.cpp @@ -163,9 +163,9 @@ void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_in // Create JFR structured failure data JfrStructCopyFailed evac_failed; evac_failed.set_objectCount(ef_info.failed_count()); - evac_failed.set_firstSize(ef_info.first_size()); - evac_failed.set_smallestSize(ef_info.smallest_size()); - evac_failed.set_totalSize(ef_info.total_size()); + evac_failed.set_firstSize(ef_info.first_size() * HeapWordSize); + evac_failed.set_smallestSize(ef_info.smallest_size() * HeapWordSize); + evac_failed.set_totalSize(ef_info.total_size() * HeapWordSize); // Add to the event e.set_gcId(GCId::current()); e.set_evacuationFailed(evac_failed); diff --git a/src/hotspot/share/gc/shared/gcTraceSend.cpp b/src/hotspot/share/gc/shared/gcTraceSend.cpp index b33c73cb22df4..d57af7ceaf127 100644 --- a/src/hotspot/share/gc/shared/gcTraceSend.cpp +++ b/src/hotspot/share/gc/shared/gcTraceSend.cpp @@ -157,9 +157,9 @@ void OldGCTracer::send_old_gc_event() const { static JfrStructCopyFailed to_struct(const CopyFailedInfo& cf_info) { JfrStructCopyFailed failed_info; failed_info.set_objectCount(cf_info.failed_count()); - failed_info.set_firstSize(cf_info.first_size()); - failed_info.set_smallestSize(cf_info.smallest_size()); - failed_info.set_totalSize(cf_info.total_size()); + failed_info.set_firstSize(cf_info.first_size() * HeapWordSize); + failed_info.set_smallestSize(cf_info.smallest_size() * HeapWordSize); + failed_info.set_totalSize(cf_info.total_size() * HeapWordSize); return failed_info; } diff --git a/test/jdk/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java index d639ad23b2444..d5b85dd4681fd 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java @@ -49,12 +49,16 @@ public static void test(String testName, String[] vmFlags) throws Throwable { // This test can not always trigger the expected event. // Test is ok even if no events found. List events = RecordingFile.readAllEvents(Paths.get(jfr_file)); + int minObjectAlignment = 8; for (RecordedEvent event : events) { System.out.println("Event: " + event); long smallestSize = Events.assertField(event, "promotionFailed.smallestSize").atLeast(1L).getValue(); + Asserts.assertTrue((smallestSize % minObjectAlignment) == 0, "smallestSize " + smallestSize + " is not a valid size."); long firstSize = Events.assertField(event, "promotionFailed.firstSize").atLeast(smallestSize).getValue(); + Asserts.assertTrue((firstSize % minObjectAlignment) == 0, "firstSize " + firstSize + " is not a valid size."); long totalSize = Events.assertField(event, "promotionFailed.totalSize").atLeast(firstSize).getValue(); long objectCount = Events.assertField(event, "promotionFailed.objectCount").atLeast(1L).getValue(); + Asserts.assertTrue((totalSize % minObjectAlignment) == 0, "totalSize " + totalSize + " is not a valid size."); Asserts.assertLessThanOrEqual(smallestSize * objectCount, totalSize, "smallestSize * objectCount <= totalSize"); } } diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java index bf0a31c9c3993..fb34249c1dc93 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java @@ -76,13 +76,17 @@ public static void main(String[] args) throws Exception { // Verify recording List events = Events.fromRecording(recording); + int minObjectAlignment = 8; Events.hasEvents(events); for (RecordedEvent event : events) { long objectCount = Events.assertField(event, "evacuationFailed.objectCount").atLeast(1L).getValue(); long smallestSize = Events.assertField(event, "evacuationFailed.smallestSize").atLeast(1L).getValue(); + Asserts.assertTrue((smallestSize % minObjectAlignment) == 0, "smallestSize " + smallestSize + " is not a valid size."); long firstSize = Events.assertField(event, "evacuationFailed.firstSize").atLeast(smallestSize).getValue(); + Asserts.assertTrue((firstSize % minObjectAlignment) == 0, "firstSize " + firstSize + " is not a valid size."); long totalSize = Events.assertField(event, "evacuationFailed.totalSize").atLeast(firstSize).getValue(); + Asserts.assertTrue((totalSize % minObjectAlignment) == 0, "totalSize " + totalSize + " is not a valid size."); Asserts.assertLessThanOrEqual(smallestSize * objectCount, totalSize, "smallestSize * objectCount <= totalSize"); } recording.close(); From 486a468a19c0544ab961f4f52e45b834d271c667 Mon Sep 17 00:00:00 2001 From: Johannes Bechberger Date: Thu, 28 Sep 2023 10:06:02 +0000 Subject: [PATCH 163/341] 8307732: build-test-lib is broken 8274345: make build-test-lib is broken 8303922: build-test-lib target is broken Reviewed-by: shade Backport-of: 0da48f19cbebe0730d689cb966b886f6f73fb3f1 --- make/test/BuildTestLib.gmk | 15 ++++++++++++--- test/lib/jdk/test/lib/hexdump/ASN1Formatter.java | 4 ++-- test/lib/jdk/test/lib/net/HttpHeaderParser.java | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/make/test/BuildTestLib.gmk b/make/test/BuildTestLib.gmk index dff446eed3b3c..f1574988b6fee 100644 --- a/make/test/BuildTestLib.gmk +++ b/make/test/BuildTestLib.gmk @@ -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 @@ -36,9 +36,11 @@ TEST_LIB_SUPPORT := $(SUPPORT_OUTPUTDIR)/test/lib $(eval $(call SetupJavaCompilation, BUILD_WB_JAR, \ TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \ - SRC := $(TEST_LIB_SOURCE_DIR)/sun, \ + SRC := $(TEST_LIB_SOURCE_DIR)/jdk/test/whitebox/, \ BIN := $(TEST_LIB_SUPPORT)/wb_classes, \ JAR := $(TEST_LIB_SUPPORT)/wb.jar, \ + DISABLED_WARNINGS := deprecation removal preview, \ + JAVAC_FLAGS := --enable-preview, \ )) TARGETS += $(BUILD_WB_JAR) @@ -50,7 +52,14 @@ $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \ BIN := $(TEST_LIB_SUPPORT)/test-lib_classes, \ HEADERS := $(TEST_LIB_SUPPORT)/test-lib_headers, \ JAR := $(TEST_LIB_SUPPORT)/test-lib.jar, \ - DISABLED_WARNINGS := try deprecation rawtypes unchecked serial cast, \ + DISABLED_WARNINGS := try deprecation rawtypes unchecked serial cast removal preview, \ + JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.classfile.constantpool=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.classfile.java.lang.constant=ALL-UNNAMED \ + --add-exports java.base/jdk.internal.module=ALL-UNNAMED \ + --enable-preview, \ )) TARGETS += $(BUILD_TEST_LIB_JAR) diff --git a/test/lib/jdk/test/lib/hexdump/ASN1Formatter.java b/test/lib/jdk/test/lib/hexdump/ASN1Formatter.java index 5001978b8603c..844b54da7c84d 100644 --- a/test/lib/jdk/test/lib/hexdump/ASN1Formatter.java +++ b/test/lib/jdk/test/lib/hexdump/ASN1Formatter.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 @@ -303,7 +303,7 @@ private int annotate(DataInputStream in, Appendable out, int available, String p case TAG_BitString: out.append(String.format("%s [%d]", tagName(tag), len)); do { - var skipped = in.skip(len); + var skipped = (int) in.skip(len); len -= skipped; available -= skipped; } while (len > 0); diff --git a/test/lib/jdk/test/lib/net/HttpHeaderParser.java b/test/lib/jdk/test/lib/net/HttpHeaderParser.java index 71b3a84fdaa6f..86e45fcd4debc 100644 --- a/test/lib/jdk/test/lib/net/HttpHeaderParser.java +++ b/test/lib/jdk/test/lib/net/HttpHeaderParser.java @@ -34,7 +34,7 @@ import static java.util.Objects.requireNonNull; -public class HttpHeaderParser { +public final class HttpHeaderParser { private static final char CR = '\r'; private static final char LF = '\n'; private static final char HT = '\t'; From 9404b2b16beaaa536a3698a7641cd9fd2e22d9f1 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 28 Sep 2023 11:43:45 +0000 Subject: [PATCH 164/341] 8314121: test tools/jpackage/share/RuntimePackageTest.java#id0 fails on RHEL8 Backport-of: 8107eab3c09b3f9fcf1348c3bf1deb7c4ac2fdf3 --- .../classes/jdk/jpackage/internal/resources/template.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.spec b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.spec index 3538d2776f85a..e42f2e6f44113 100644 --- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.spec +++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/template.spec @@ -30,6 +30,9 @@ Requires: PACKAGE_DEFAULT_DEPENDENCIES PACKAGE_CUSTOM_DEPENDENCIES #build time will substantially increase and it may require unpack200/system java to install %define __jar_repack %{nil} +# on RHEL we got unwanted improved debugging enhancements +%define _build_id_links none + %define package_filelist %{_builddir}/%{name}.files %define app_filelist %{_builddir}/%{name}.app.files %define filesystem_filelist %{_builddir}/%{name}.filesystem.files From 7e58a4246443b2428de675a945d42f64f0eaca24 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 28 Sep 2023 13:58:36 +0000 Subject: [PATCH 165/341] 8283670: gtest os.release_multi_mappings_vm is still racy Backport-of: 2e9fd56524f739dc4023b81061cb2587d6325fac --- test/hotspot/gtest/runtime/test_os.cpp | 58 +++++++++++++++----------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/test/hotspot/gtest/runtime/test_os.cpp b/test/hotspot/gtest/runtime/test_os.cpp index c5591242bc6d7..017f4c10875b6 100644 --- a/test/hotspot/gtest/runtime/test_os.cpp +++ b/test/hotspot/gtest/runtime/test_os.cpp @@ -373,6 +373,15 @@ static inline bool can_reserve_executable_memory(void) { #define PRINT_MAPPINGS(s) { tty->print_cr("%s", s); os::print_memory_mappings((char*)p, total_range_len, tty); } //#define PRINT_MAPPINGS +// Release a range allocated with reserve_multiple carefully, to not trip mapping +// asserts on Windows in os::release_memory() +static void carefully_release_multiple(address start, int num_stripes, size_t stripe_len) { + for (int stripe = 0; stripe < num_stripes; stripe++) { + address q = start + (stripe * stripe_len); + EXPECT_TRUE(os::release_memory((char*)q, stripe_len)); + } +} + #ifndef _AIX // JDK-8257041 // Reserve an area consisting of multiple mappings // (from multiple calls to os::reserve_memory) @@ -385,25 +394,34 @@ static address reserve_multiple(int num_stripes, size_t stripe_len) { const bool exec_supported = can_reserve_executable_memory(); #endif - size_t total_range_len = num_stripes * stripe_len; - // Reserve a large contiguous area to get the address space... - address p = (address)os::reserve_memory(total_range_len); - EXPECT_NE(p, (address)NULL); - // .. release it... - EXPECT_TRUE(os::release_memory((char*)p, total_range_len)); - // ... re-reserve in the same spot multiple areas... - for (int stripe = 0; stripe < num_stripes; stripe++) { - address q = p + (stripe * stripe_len); - // Commit, alternatingly with or without exec permission, - // to prevent kernel from folding these mappings. + address p = NULL; + for (int tries = 0; tries < 256 && p == NULL; tries ++) { + size_t total_range_len = num_stripes * stripe_len; + // Reserve a large contiguous area to get the address space... + p = (address)os::reserve_memory(total_range_len); + EXPECT_NE(p, (address)NULL); + // .. release it... + EXPECT_TRUE(os::release_memory((char*)p, total_range_len)); + // ... re-reserve in the same spot multiple areas... + for (int stripe = 0; stripe < num_stripes; stripe++) { + address q = p + (stripe * stripe_len); + // Commit, alternatingly with or without exec permission, + // to prevent kernel from folding these mappings. #ifdef __APPLE__ - const bool executable = exec_supported ? (stripe % 2 == 0) : false; + const bool executable = exec_supported ? (stripe % 2 == 0) : false; #else - const bool executable = stripe % 2 == 0; + const bool executable = stripe % 2 == 0; #endif - q = (address)os::attempt_reserve_memory_at((char*)q, stripe_len, executable); - EXPECT_NE(q, (address)NULL); - EXPECT_TRUE(os::commit_memory((char*)q, stripe_len, executable)); + q = (address)os::attempt_reserve_memory_at((char*)q, stripe_len, executable); + if (q == NULL) { + // Someone grabbed that area concurrently. Cleanup, then retry. + tty->print_cr("reserve_multiple: retry (%d)...", stripe); + carefully_release_multiple(p, stripe, stripe_len); + p = NULL; + } else { + EXPECT_TRUE(os::commit_memory((char*)q, stripe_len, executable)); + } + } } return p; } @@ -426,14 +444,6 @@ static address reserve_one_commit_multiple(int num_stripes, size_t stripe_len) { } #ifdef _WIN32 -// Release a range allocated with reserve_multiple carefully, to not trip mapping -// asserts on Windows in os::release_memory() -static void carefully_release_multiple(address start, int num_stripes, size_t stripe_len) { - for (int stripe = 0; stripe < num_stripes; stripe++) { - address q = start + (stripe * stripe_len); - EXPECT_TRUE(os::release_memory((char*)q, stripe_len)); - } -} struct NUMASwitcher { const bool _b; NUMASwitcher(bool v): _b(UseNUMAInterleaving) { UseNUMAInterleaving = v; } From 1ce8f3ebcd1df36d195568aa7a486607d3e7b7b3 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 28 Sep 2023 14:00:46 +0000 Subject: [PATCH 166/341] 8293156: Dcmd VM.classloaders fails to print the full hierarchy Backport-of: c6be2cd347fc07dcc0da56acf40fc7a005119f09 --- .../classfile/classLoaderHierarchyDCmd.cpp | 98 ++++++++++++------- .../dcmd/vm/ClassLoaderHierarchyTest.java | 92 +++++++++++++---- 2 files changed, 136 insertions(+), 54 deletions(-) diff --git a/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp b/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp index d9081dc13ffed..ec22f548a48b2 100644 --- a/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp +++ b/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp @@ -123,7 +123,7 @@ struct LoadedClassInfo : public ResourceObj { const ClassLoaderData* const _cld; LoadedClassInfo(Klass* klass, const ClassLoaderData* cld) - : _klass(klass), _cld(cld) {} + : _next(NULL), _klass(klass), _cld(cld) {} }; @@ -138,7 +138,7 @@ class LoaderTreeNode : public ResourceObj { // this parent loader, we fill in all the other details. const oop _loader_oop; - const ClassLoaderData* _cld; + const ClassLoaderData* _cld; // May be NULL if loader never loaded anything LoaderTreeNode* _child; LoaderTreeNode* _next; @@ -155,33 +155,59 @@ class LoaderTreeNode : public ResourceObj { // one. int _num_folded; - void print_with_childs(outputStream* st, BranchTracker& branchtracker, - bool print_classes, bool verbose) const { + // Returns Klass of loader; NULL for bootstrap loader + const Klass* loader_klass() const { + return (_loader_oop != NULL) ? _loader_oop->klass() : NULL; + } - ResourceMark rm; + // Returns ResourceArea-allocated class name of loader class; "" if there is no klass (bootstrap loader) + const char* loader_class_name() const { + const Klass* klass = loader_klass(); + return klass != NULL ? klass->external_name() : ""; + } - if (_cld == NULL) { - // Not sure how this could happen: we added a preliminary node for a parent but then never encountered - // its CLD? - return; + // Returns oop of loader name; NULL for bootstrap; NULL if no name was set + oop loader_name_oop() const { + return (_loader_oop != NULL) ? java_lang_ClassLoader::name(_loader_oop) : NULL; + } + + // Returns ResourceArea-allocated name of loader, "" if none is set + const char* loader_name() const { + oop name_oop = loader_name_oop(); + return name_oop != NULL ? java_lang_String::as_utf8_string(name_oop) : ""; + } + + bool is_bootstrap() const { + if (_loader_oop == NULL) { + assert(_cld != NULL && _cld->is_boot_class_loader_data(), "bootstrap loader must have CLD"); + return true; } + return false; + } + + void print_with_child_nodes(outputStream* st, BranchTracker& branchtracker, + bool print_classes, bool verbose) const { + + assert(SafepointSynchronize::is_at_safepoint(), "invariant"); + + ResourceMark rm; // Retrieve information. - const Klass* const loader_klass = _cld->class_loader_klass(); - const Symbol* const loader_name = _cld->name(); + const Klass* const the_loader_klass = loader_klass(); + const char* const the_loader_class_name = loader_class_name(); + const char* const the_loader_name = loader_name(); branchtracker.print(st); // e.g. "+--- jdk.internal.reflect.DelegatingClassLoader" st->print("+%.*s", BranchTracker::twig_len, "----------"); - if (_cld->is_the_null_class_loader_data()) { + if (is_bootstrap()) { st->print(" "); } else { - assert(!_cld->has_class_mirror_holder(), "_cld must be the primary cld"); - if (loader_name != NULL) { - st->print(" \"%s\",", loader_name->as_C_string()); + if (the_loader_name[0] != '\0') { + st->print(" \"%s\",", the_loader_name); } - st->print(" %s", loader_klass != NULL ? loader_klass->external_name() : "??"); + st->print(" %s", the_loader_class_name); if (_num_folded > 0) { st->print(" (+ %d more)", _num_folded); } @@ -211,7 +237,7 @@ class LoaderTreeNode : public ResourceObj { branchtracker.print(st); st->print_cr("%*s " PTR_FORMAT, indentation, "Loader Data:", p2i(_cld)); branchtracker.print(st); - st->print_cr("%*s " PTR_FORMAT, indentation, "Loader Klass:", p2i(loader_klass)); + st->print_cr("%*s " PTR_FORMAT, indentation, "Loader Klass:", p2i(the_loader_klass)); // Empty line branchtracker.print(st); @@ -220,6 +246,7 @@ class LoaderTreeNode : public ResourceObj { if (print_classes) { if (_classes != NULL) { + assert(_cld != NULL, "we have classes, we should have a CLD"); for (LoadedClassInfo* lci = _classes; lci; lci = lci->_next) { // non-strong hidden classes should not live in // the primary CLD of their loaders. @@ -252,6 +279,7 @@ class LoaderTreeNode : public ResourceObj { } if (_hidden_classes != NULL) { + assert(_cld != NULL, "we have classes, we should have a CLD"); for (LoadedClassInfo* lci = _hidden_classes; lci; lci = lci->_next) { branchtracker.print(st); if (lci == _hidden_classes) { // first iteration @@ -285,7 +313,7 @@ class LoaderTreeNode : public ResourceObj { // Print children, recursively LoaderTreeNode* c = _child; while (c != NULL) { - c->print_with_childs(st, branchtracker, print_classes, verbose); + c->print_with_child_nodes(st, branchtracker, print_classes, verbose); c = c->_next; } @@ -294,10 +322,21 @@ class LoaderTreeNode : public ResourceObj { // Helper: Attempt to fold this node into the target node. If success, returns true. // Folding can be done if both nodes are leaf nodes and they refer to the same loader class // and they have the same name or no name (note: leaf check is done by caller). - bool can_fold_into(LoaderTreeNode* target_node) const { + bool can_fold_into(const LoaderTreeNode* target_node) const { assert(is_leaf() && target_node->is_leaf(), "must be leaf"); - return _cld->class_loader_klass() == target_node->_cld->class_loader_klass() && - _cld->name() == target_node->_cld->name(); + + // Must have the same non-null klass + const Klass* k = loader_klass(); + if (k == NULL || k != target_node->loader_klass()) { + return false; + } + + // Must have the same loader name, or none + if (::strcmp(loader_name(), target_node->loader_name()) != 0) { + return false; + } + + return true; } public: @@ -309,6 +348,7 @@ class LoaderTreeNode : public ResourceObj { {} void set_cld(const ClassLoaderData* cld) { + assert(_cld == NULL, "there should be only one primary CLD per loader"); _cld = cld; } @@ -343,14 +383,6 @@ class LoaderTreeNode : public ResourceObj { } } - const ClassLoaderData* cld() const { - return _cld; - } - - const oop loader_oop() const { - return _loader_oop; - } - LoaderTreeNode* find(const oop loader_oop) { LoaderTreeNode* result = NULL; if (_loader_oop == loader_oop) { @@ -373,6 +405,7 @@ class LoaderTreeNode : public ResourceObj { void fold_children() { LoaderTreeNode* node = _child; LoaderTreeNode* prev = NULL; + ResourceMark rm; while (node != NULL) { LoaderTreeNode* matching_node = NULL; if (node->is_leaf()) { @@ -398,9 +431,9 @@ class LoaderTreeNode : public ResourceObj { } } - void print_with_childs(outputStream* st, bool print_classes, bool print_add_info) const { + void print_with_child_nodes(outputStream* st, bool print_classes, bool print_add_info) const { BranchTracker bwt; - print_with_childs(st, bwt, print_classes, print_add_info); + print_with_child_nodes(st, bwt, print_classes, print_add_info); } }; @@ -475,7 +508,7 @@ class LoaderInfoScanClosure : public CLDClosure { } void print_results(outputStream* st) const { - _root->print_with_childs(st, _print_classes, _verbose); + _root->print_with_child_nodes(st, _print_classes, _verbose); } void do_cld (ClassLoaderData* cld) { @@ -492,7 +525,6 @@ class LoaderInfoScanClosure : public CLDClosure { // Update CLD in node, but only if this is the primary CLD for this loader. if (cld->has_class_mirror_holder() == false) { - assert(info->cld() == NULL, "there should be only one primary CLD per loader"); info->set_cld(cld); } diff --git a/test/hotspot/jtreg/serviceability/dcmd/vm/ClassLoaderHierarchyTest.java b/test/hotspot/jtreg/serviceability/dcmd/vm/ClassLoaderHierarchyTest.java index e3f1a8d915085..48ec48bf8ccd1 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/vm/ClassLoaderHierarchyTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/vm/ClassLoaderHierarchyTest.java @@ -47,6 +47,19 @@ public class ClassLoaderHierarchyTest { + class EmptyDelegatingLoader extends ClassLoader { + EmptyDelegatingLoader(String name, ClassLoader parent) { + super(name, parent); + } + } + + static void loadTestClassInLoaderAndCheck(String classname, ClassLoader loader) throws ClassNotFoundException { + Class c = Class.forName(classname, true, loader); + if (c.getClassLoader() != loader) { + Assert.fail(classname + " defined by wrong classloader: " + c.getClassLoader()); + } + } + //+-- // | // +-- "platform", jdk.internal.loader.ClassLoaders$PlatformClassLoader @@ -63,39 +76,76 @@ public class ClassLoaderHierarchyTest { public void run(CommandExecutor executor) throws ClassNotFoundException { + // A) one unnamed, two named loaders ClassLoader unnamed_cl = new TestClassLoader(null, null); - Class c1 = Class.forName("TestClass2", true, unnamed_cl); - if (c1.getClassLoader() != unnamed_cl) { - Assert.fail("TestClass defined by wrong classloader: " + c1.getClassLoader()); - } - ClassLoader named_cl = new TestClassLoader("Kevin", null); - Class c2 = Class.forName("TestClass2", true, named_cl); - if (c2.getClassLoader() != named_cl) { - Assert.fail("TestClass defined by wrong classloader: " + c2.getClassLoader()); - } - ClassLoader named_child_cl = new TestClassLoader("Bill", unnamed_cl); - Class c3 = Class.forName("TestClass2", true, named_child_cl); - if (c3.getClassLoader() != named_child_cl) { - Assert.fail("TestClass defined by wrong classloader: " + c3.getClassLoader()); - } + loadTestClassInLoaderAndCheck("TestClass2", unnamed_cl); + loadTestClassInLoaderAndCheck("TestClass2", named_cl); + loadTestClassInLoaderAndCheck("TestClass2", named_child_cl); + + // B) A named CL with empty loaders as parents (JDK-8293156) + EmptyDelegatingLoader emptyLoader1 = new EmptyDelegatingLoader("EmptyLoader1", null); + EmptyDelegatingLoader emptyLoader2 = new EmptyDelegatingLoader("EmptyLoader2", emptyLoader1); + ClassLoader named_child_2_cl = new TestClassLoader("Child2", emptyLoader2); + loadTestClassInLoaderAndCheck("TestClass2", named_child_2_cl); + + // C) Test output for several class loaders, same class, same name, empty parents, + // and all these should be folded by default. + EmptyDelegatingLoader emptyLoader3 = new EmptyDelegatingLoader("EmptyLoader3", null); + EmptyDelegatingLoader emptyLoader4 = new EmptyDelegatingLoader("EmptyLoader4", emptyLoader3); + ClassLoader named_child_3_cl = new TestClassLoader("ChildX", emptyLoader4); // Same names + ClassLoader named_child_4_cl = new TestClassLoader("ChildX", emptyLoader4); + ClassLoader named_child_5_cl = new TestClassLoader("ChildX", emptyLoader4); + ClassLoader named_child_6_cl = new TestClassLoader("ChildX", emptyLoader4); + loadTestClassInLoaderAndCheck("TestClass2", named_child_3_cl); + loadTestClassInLoaderAndCheck("TestClass2", named_child_4_cl); + loadTestClassInLoaderAndCheck("TestClass2", named_child_5_cl); + loadTestClassInLoaderAndCheck("TestClass2", named_child_6_cl); + + // D) Test output for several *unnamed* class loaders, same class, same parents, + // and all these should be folded by default too. + EmptyDelegatingLoader emptyLoader5 = new EmptyDelegatingLoader(null, null); + EmptyDelegatingLoader emptyLoader6 = new EmptyDelegatingLoader(null, emptyLoader5); + ClassLoader named_child_7_cl = new TestClassLoader(null, emptyLoader6); // Same names + ClassLoader named_child_8_cl = new TestClassLoader(null, emptyLoader6); + ClassLoader named_child_9_cl = new TestClassLoader(null, emptyLoader6); + ClassLoader named_child_10_cl = new TestClassLoader(null, emptyLoader6); + loadTestClassInLoaderAndCheck("TestClass2", named_child_7_cl); + loadTestClassInLoaderAndCheck("TestClass2", named_child_8_cl); + loadTestClassInLoaderAndCheck("TestClass2", named_child_9_cl); + loadTestClassInLoaderAndCheck("TestClass2", named_child_10_cl); // First test: simple output, no classes displayed OutputAnalyzer output = executor.execute("VM.classloaders"); - output.shouldContain(""); - output.shouldMatch(".*TestClassLoader"); - output.shouldMatch("Kevin.*TestClassLoader"); - output.shouldMatch("Bill.*TestClassLoader"); + // (A) + output.shouldContain("+-- "); + output.shouldContain(" +-- \"platform\", jdk.internal.loader.ClassLoaders$PlatformClassLoader"); + output.shouldContain(" | +-- \"app\", jdk.internal.loader.ClassLoaders$AppClassLoader"); + output.shouldContain(" +-- \"Kevin\", ClassLoaderHierarchyTest$TestClassLoader"); + output.shouldContain(" +-- ClassLoaderHierarchyTest$TestClassLoader"); + output.shouldContain(" | +-- \"Bill\", ClassLoaderHierarchyTest$TestClassLoader"); + // (B) + output.shouldContain(" +-- \"EmptyLoader1\", ClassLoaderHierarchyTest$EmptyDelegatingLoader"); + output.shouldContain(" | +-- \"EmptyLoader2\", ClassLoaderHierarchyTest$EmptyDelegatingLoader"); + output.shouldContain(" | +-- \"Child2\", ClassLoaderHierarchyTest$TestClassLoader"); + // (C) + output.shouldContain(" +-- \"EmptyLoader3\", ClassLoaderHierarchyTest$EmptyDelegatingLoader"); + output.shouldContain(" | +-- \"EmptyLoader4\", ClassLoaderHierarchyTest$EmptyDelegatingLoader"); + output.shouldContain(" | +-- \"ChildX\", ClassLoaderHierarchyTest$TestClassLoader (+ 3 more)"); + // (D) + output.shouldContain(" +-- ClassLoaderHierarchyTest$EmptyDelegatingLoader"); + output.shouldContain(" +-- ClassLoaderHierarchyTest$EmptyDelegatingLoader"); + output.shouldContain(" +-- ClassLoaderHierarchyTest$TestClassLoader (+ 3 more)"); // Second test: print with classes. output = executor.execute("VM.classloaders show-classes"); output.shouldContain(""); output.shouldContain("java.lang.Object"); - output.shouldMatch(".*TestClassLoader"); - output.shouldMatch("Kevin.*TestClassLoader"); - output.shouldMatch("Bill.*TestClassLoader"); + output.shouldContain("java.lang.Enum"); + output.shouldContain("java.lang.NullPointerException"); output.shouldContain("TestClass2"); + output.shouldContain("Hidden Classes:"); } From 9fce30a719bd9e177b14576d11490d981725c7ae Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 28 Sep 2023 14:03:09 +0000 Subject: [PATCH 167/341] 8298867: Basics.java fails with SSL handshake exception Backport-of: 06f9374e0c59fa666e6f120749d9170f65fadc4f --- test/jdk/ProblemList.txt | 1 - test/jdk/javax/net/ssl/SSLEngine/Basics.java | 156 +++++++++++-------- 2 files changed, 92 insertions(+), 65 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 5d866ccb9bddd..7bc846c8ab985 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -640,7 +640,6 @@ javax/net/ssl/SSLEngine/IllegalRecordVersion.java 8298873 generic- javax/net/ssl/SSLEngine/EngineCloseOnAlert.java 8298868 generic-all javax/net/ssl/SSLEngine/ConnectionTest.java 8298869 generic-all javax/net/ssl/SSLEngine/CheckStatus.java 8298872 generic-all -javax/net/ssl/SSLEngine/Basics.java 8298867 generic-all sun/security/smartcardio/TestChannel.java 8039280 generic-all sun/security/smartcardio/TestConnect.java 8039280 generic-all diff --git a/test/jdk/javax/net/ssl/SSLEngine/Basics.java b/test/jdk/javax/net/ssl/SSLEngine/Basics.java index 177422cb489c3..3239bfd4ce99d 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/Basics.java +++ b/test/jdk/javax/net/ssl/SSLEngine/Basics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * 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,41 +26,53 @@ * @bug 4495742 * @summary Add non-blocking SSL/TLS functionality, usable with any * I/O abstraction - * * This is intended to test many of the basic API calls to the SSLEngine * interface. This doesn't really exercise much of the SSL code. * + * @library /test/lib * @author Brad Wetmore + * @run main/othervm Basics */ import java.security.*; import java.io.*; import java.nio.*; +import java.util.Arrays; import javax.net.ssl.*; import javax.net.ssl.SSLEngineResult.*; +import jdk.test.lib.security.SecurityUtils; + public class Basics { - private static String pathToStores = "../etc"; - private static String keyStoreFile = "keystore"; - private static String trustStoreFile = "truststore"; - private static String passwd = "passphrase"; + private static final String PATH_TO_STORES = "../etc"; + private static final String KEY_STORE_FILE = "keystore"; + private static final String TRUSTSTORE_FILE = "truststore"; + + private static final String KEYSTORE_PATH = + System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + + "/" + KEY_STORE_FILE; + private static final String TRUSTSTORE_PATH = + System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + + "/" + TRUSTSTORE_FILE; - private static String keyFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + keyStoreFile; - private static String trustFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + trustStoreFile; + public static void main(String[] args) throws Exception { + SecurityUtils.removeFromDisabledTlsAlgs("TLSv1.1"); + + runTest("TLSv1.3", "TLS_AES_256_GCM_SHA384"); + runTest("TLSv1.2", "TLS_RSA_WITH_AES_256_GCM_SHA384"); + runTest("TLSv1.1", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA"); + } - public static void main(String args[]) throws Exception { + private static void runTest(String protocol, String cipherSuite) throws Exception { + System.out.printf("Testing %s with %s%n", protocol, cipherSuite); KeyStore ks = KeyStore.getInstance("JKS"); KeyStore ts = KeyStore.getInstance("JKS"); char[] passphrase = "passphrase".toCharArray(); - ks.load(new FileInputStream(keyFilename), passphrase); - ts.load(new FileInputStream(trustFilename), passphrase); + ks.load(new FileInputStream(KEYSTORE_PATH), passphrase); + ts.load(new FileInputStream(TRUSTSTORE_PATH), passphrase); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, passphrase); @@ -77,75 +89,85 @@ public static void main(String args[]) throws Exception { System.out.println(ssle); String [] suites = ssle.getSupportedCipherSuites(); - String secondSuite = suites[1]; - String [] oneSuites = new String [] { secondSuite }; + // sanity check that the ciphersuite we want to use is still supported + Arrays.stream(suites) + .filter(s -> s.equals(cipherSuite)) + .findFirst() + .orElseThrow((() -> + new RuntimeException(cipherSuite + + " is not a supported ciphersuite."))); printStrings("Supported Ciphersuites", suites); printStrings("Enabled Ciphersuites", ssle.getEnabledCipherSuites()); - ssle.setEnabledCipherSuites(oneSuites); + ssle.setEnabledCipherSuites(new String [] { cipherSuite }); printStrings("Set Ciphersuites", ssle.getEnabledCipherSuites()); suites = ssle.getEnabledCipherSuites(); if ((ssle.getEnabledCipherSuites().length != 1) || - !(suites[0].equals(secondSuite))) { - throw new Exception("set ciphers not what was expected"); + !(suites[0].equals(cipherSuite))) { + throw new RuntimeException("set ciphers not what was expected"); } System.out.println(); String [] protocols = ssle.getSupportedProtocols(); - String secondProtocol = protocols[1]; - String [] oneProtocols = new String [] { protocols[1] }; + // sanity check that the protocol we want is still supported + Arrays.stream(protocols) + .filter(p -> p.equals(protocol)) + .findFirst() + .orElseThrow(() -> + new RuntimeException(protocol + + " is not a supported TLS protocol.")); printStrings("Supported Protocols", protocols); printStrings("Enabled Protocols", ssle.getEnabledProtocols()); - ssle.setEnabledProtocols(oneProtocols); + ssle.setEnabledProtocols(new String[]{ protocol }); printStrings("Set Protocols", ssle.getEnabledProtocols()); protocols = ssle.getEnabledProtocols(); if ((ssle.getEnabledProtocols().length != 1) || - !(protocols[0].equals(secondProtocol))) { - throw new Exception("set protocols not what was expected"); + !(protocols[0].equals(protocol))) { + throw new RuntimeException("set protocols not what was expected"); } System.out.println("Checking get/setUseClientMode"); ssle.setUseClientMode(true); - if (ssle.getUseClientMode() != true) { - throw new Exception("set/getUseClientMode false"); + if (!ssle.getUseClientMode()) { + throw new RuntimeException("set/getUseClientMode false"); } ssle.setUseClientMode(false); - if (ssle.getUseClientMode() != false) { - throw new Exception("set/getUseClientMode true"); + if (ssle.getUseClientMode()) { + throw new RuntimeException("set/getUseClientMode true"); } System.out.println("Checking get/setClientAuth"); ssle.setNeedClientAuth(false); - if (ssle.getNeedClientAuth() != false) { - throw new Exception("set/getNeedClientAuth true"); + if (ssle.getNeedClientAuth()) { + throw new RuntimeException("set/getNeedClientAuth true"); } ssle.setNeedClientAuth(true); - if (ssle.getNeedClientAuth() != true) { - throw new Exception("set/getNeedClientAuth false"); + if (!ssle.getNeedClientAuth()) { + throw new RuntimeException("set/getNeedClientAuth false"); } ssle.setWantClientAuth(true); - if (ssle.getNeedClientAuth() == true) { - throw new Exception("set/getWantClientAuth need = true"); + if (ssle.getNeedClientAuth()) { + throw new RuntimeException("set/getWantClientAuth need = true"); } - if (ssle.getWantClientAuth() != true) { - throw new Exception("set/getNeedClientAuth false"); + if (!ssle.getWantClientAuth()) { + throw new RuntimeException("set/getNeedClientAuth false"); } ssle.setWantClientAuth(false); - if (ssle.getWantClientAuth() != false) { - throw new Exception("set/getNeedClientAuth true"); + if (ssle.getWantClientAuth()) { + throw new RuntimeException("set/getNeedClientAuth true"); } /* @@ -156,13 +178,13 @@ public static void main(String args[]) throws Exception { System.out.println("checking session creation"); ssle.setEnableSessionCreation(false); - if (ssle.getEnableSessionCreation() != false) { - throw new Exception("set/getSessionCreation true"); + if (ssle.getEnableSessionCreation()) { + throw new RuntimeException("set/getSessionCreation true"); } ssle.setEnableSessionCreation(true); - if (ssle.getEnableSessionCreation() != true) { - throw new Exception("set/getSessionCreation false"); + if (!ssle.getEnableSessionCreation()) { + throw new RuntimeException("set/getSessionCreation false"); } /* Checking for overflow wrap/unwrap() */ @@ -170,18 +192,13 @@ public static void main(String args[]) throws Exception { if (ssle.wrap(smallBB, smallBB).getStatus() != Status.BUFFER_OVERFLOW) { - throw new Exception("wrap should have overflowed"); + throw new RuntimeException("wrap should have overflowed"); } // For unwrap(), the BUFFER_OVERFLOW will not be generated // until received SSL/TLS application data. // Test test/jdk/javax/net/ssl/SSLEngine/LargePacket.java will check // BUFFER_OVERFLOW/UNDERFLOW for both wrap() and unwrap(). - // - //if (ssle.unwrap(smallBB, smallBB).getStatus() != - // Status.BUFFER_OVERFLOW) { - // throw new Exception("unwrap should have overflowed"); - //} SSLSession ssls = ssle.getSession(); @@ -196,14 +213,18 @@ public static void main(String args[]) throws Exception { */ if (ssle.wrap(appBB, netBB).getHandshakeStatus() != HandshakeStatus.NEED_UNWRAP) { - throw new Exception("initial client hello needs unwrap"); + throw new RuntimeException("initial client hello needs unwrap"); } - /* Checking for overflow wrap/unwrap() */ - - if (ssle.wrap(appBB, netBB).getStatus() != - Status.BUFFER_OVERFLOW) { - throw new Exception("unwrap should have overflowed"); + /* + * After the first call to wrap(), the handshake status is + * NEED_UNWRAP and we need to receive data before doing anymore + * handshaking. + */ + SSLEngineResult result = ssle.wrap(appBB, netBB); + if (result.getStatus() != Status.OK + && result.bytesConsumed() != 0 && result.bytesProduced() != 0) { + throw new RuntimeException("wrap should have returned without doing anything"); } ByteBuffer ro = appBB.asReadOnlyBuffer(); @@ -218,7 +239,7 @@ public static void main(String args[]) throws Exception { try { ssle.unwrap(netBB, ro); - throw new Exception("unwrap wasn't ReadOnlyBufferException"); + throw new RuntimeException("unwrap wasn't ReadOnlyBufferException"); } catch (ReadOnlyBufferException e) { System.out.println("Caught the ReadOnlyBuffer: " + e); } @@ -233,7 +254,7 @@ public static void main(String args[]) throws Exception { appBB)).getStatus() != Status.BUFFER_UNDERFLOW) { System.out.println(sslER); - throw new Exception("unwrap should underflow"); + throw new RuntimeException("unwrap should underflow"); } if ((sslER = @@ -241,7 +262,7 @@ public static void main(String args[]) throws Exception { appBB)).getStatus() != Status.BUFFER_UNDERFLOW) { System.out.println(sslER); - throw new Exception("unwrap should underflow"); + throw new RuntimeException("unwrap should underflow"); } if ((sslER = @@ -249,15 +270,22 @@ public static void main(String args[]) throws Exception { appBB)).getStatus() != Status.BUFFER_UNDERFLOW) { System.out.println(sslER); - throw new Exception("unwrap should underflow"); + throw new RuntimeException("unwrap should underflow"); } // junk inbound message try { + /* + * Exceptions are thrown when: + * - the length field is correct but the data can't be decoded. + * - the length field is larger than max allowed. + */ ssle.unwrap(ByteBuffer.wrap(gobblydegook), appBB); - throw new Exception("Didn't catch the nasty SSLException"); - } catch (SSLException e) { - System.out.println("caught the nasty SSLException: " + e); + throw new RuntimeException("Expected SSLProtocolException was not thrown " + + "for bad input"); + } catch (SSLProtocolException e) { + System.out.println("caught the SSLProtocolException for bad decoding: " + + e); } System.out.println("Test PASSED"); @@ -278,8 +306,8 @@ public static void main(String args[]) throws Exception { (byte) 0x00 }; static byte [] gobblydegook = new byte [] { - // "HELLO HELLO" - (byte) 0x48, (byte) 0x45, (byte) 0x4C, (byte) 0x4C, (byte) 0x20, + // bad data but correct record length to cause decryption error + (byte) 0x48, (byte) 0x45, (byte) 0x4C, (byte) 0x00, (byte) 0x04, (byte) 0x48, (byte) 0x45, (byte) 0x4C, (byte) 0x4C }; static void printStrings(String label, String [] strs) { From cb535e2d52221bfc23e4c26a730399bceb573547 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Thu, 28 Sep 2023 16:15:31 +0000 Subject: [PATCH 168/341] 8308592: Framework for CA interoperability testing Backport-of: da57d2a1eb409ddc64117865c7d24ed518421cab --- .../certification/ActalisCA.java | 217 ------ .../certification/AmazonCA.java | 613 ----------------- .../certification/BuypassCA.java | 330 --------- .../certification/CAInterop.java | 561 +++++++++++++++ .../{CertignaRoots.java => CertignaCA.java} | 95 +-- .../certification/ComodoCA.java | 643 ------------------ .../certification/EntrustCA.java | 319 --------- .../certification/GlobalSignR6CA.java | 212 ------ .../certification/GoDaddyCA.java | 346 ---------- .../certification/GoogleCA.java | 621 ----------------- .../certification/LetsEncryptCA.java | 180 ----- .../certification/MicrosoftTLS.java | 348 ---------- .../certification/QuoVadisCA.java | 495 -------------- .../certification/SSLCA.java | 490 ------------- .../certification/TWCAGlobalCA.java | 206 ------ .../certification/TeliaSoneraCA.java | 195 ------ .../certification/ValidatePathWithURL.java | 229 +++++++ 17 files changed, 801 insertions(+), 5299 deletions(-) delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/BuypassCA.java create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java rename test/jdk/security/infra/java/security/cert/CertPathValidator/certification/{CertignaRoots.java => CertignaCA.java} (74%) delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ComodoCA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/EntrustCA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GlobalSignR6CA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GoDaddyCA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GoogleCA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/MicrosoftTLS.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/QuoVadisCA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/SSLCA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/TWCAGlobalCA.java delete mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/TeliaSoneraCA.java create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ValidatePathWithURL.java diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java deleted file mode 100644 index cd1db71c418ef..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * 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 - * 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 8189131 - * @summary Interoperability tests with Actalis CA - * @build ValidatePathWithParams - * @run main/othervm/timeout=180 -Djava.security.debug=certpath ActalisCA OCSP - * @run main/othervm/timeout=180 -Djava.security.debug=certpath ActalisCA CRL - */ - - /* - * Obtain test artifacts for Actalis CA from: - * - * Test website with *active* TLS Server certificate: - * https://ssltest-active.actalis.it/ - * - * Test website with *revoked* TLS Server certificate: - * https://ssltest-revoked.actalis.it/ - * - * Test website with *expired* TLS Server certificate: - * https://ssltest-expired.actalis.it/ - */ -public class ActalisCA { - - // Owner: CN=Actalis Organization Validated Server CA G3, O=Actalis S.p.A., - // L=Ponte San Pietro, ST=Bergamo, C=IT - // Issuer: CN=Actalis Authentication Root CA, O=Actalis S.p.A ./03358520967, - // L=Milan, C=IT - // Serial number: 5c3b3f37adfc28fe0fcfd3abf83f8551 - // Valid from: Mon Jul 06 00:20:55 PDT 2020 until: Sun Sep 22 04:22:02 PDT 2030 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIHdTCCBV2gAwIBAgIQXDs/N638KP4Pz9Or+D+FUTANBgkqhkiG9w0BAQsFADBr\n" + - "MQswCQYDVQQGEwJJVDEOMAwGA1UEBwwFTWlsYW4xIzAhBgNVBAoMGkFjdGFsaXMg\n" + - "Uy5wLkEuLzAzMzU4NTIwOTY3MScwJQYDVQQDDB5BY3RhbGlzIEF1dGhlbnRpY2F0\n" + - "aW9uIFJvb3QgQ0EwHhcNMjAwNzA2MDcyMDU1WhcNMzAwOTIyMTEyMjAyWjCBiTEL\n" + - "MAkGA1UEBhMCSVQxEDAOBgNVBAgMB0JlcmdhbW8xGTAXBgNVBAcMEFBvbnRlIFNh\n" + - "biBQaWV0cm8xFzAVBgNVBAoMDkFjdGFsaXMgUy5wLkEuMTQwMgYDVQQDDCtBY3Rh\n" + - "bGlzIE9yZ2FuaXphdGlvbiBWYWxpZGF0ZWQgU2VydmVyIENBIEczMIICIjANBgkq\n" + - "hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAs73Ch+t2owm3ayTkyqy0OPuCTiybxTyS\n" + - "4cU4y0t2RGSwCNjLh/rcutO0yoriZxVtPrNMcIRQ544BQhHFt/ypW7e+t8wWKrHa\n" + - "r3BkKwSUbqNwpDWP1bXs7IJTVhHXWGAm7Ak1FhrrBmtXk8QtdzTzDDuxfFBK7sCL\n" + - "N0Jdqoqb1V1z3wsWqAvr4KlSCFW05Nh4baWm/kXOmb8U+XR6kUmuoVvia3iBhotR\n" + - "TzAHTO9SWWkgjTcir/nhBvyL2Roq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h0dHA6Ly9jcmwwNS5hY3Rh\n" + - "bGlzLml0L1JlcG9zaXRvcnkvQVVUSC1ST09UL2dldExhc3RDUkwwHQYDVR0OBBYE\n" + - "FJ+KsbXxsd6C9Cd8vojN3qlDgaNLMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0B\n" + - "AQsFAAOCAgEAJbygMnKJ5M6byr5Ectq05ODqwNMtky8TEF3O55g6RHhxblf6OegZ\n" + - "4ui4+ElHNOIXjycbeuUGuFA4LScCC9fnI1Rnn8TI2Q7OP5YWifEfnrdp99t/tJzQ\n" + - "hfdi7ZTdRRZZGV9x+grfR/RtjT2C3Lt9X4lcbuSxTea3PHAwwi0A3bYRR1L5ciPm\n" + - "eAnYtG9kpat8/RuC22oxiZZ5FdjU6wrRWkASRLiIwNcFIYfvpUbMWElaCUhqaB2y\n" + - "YvWF8o02pnaYb4bvTCg4cVabVnojUuuXH81LeQhhsSXLwcdwSdew0NL4zCiNCn2Q\n" + - "iDZpz2biCWDggibmWxsUUF6AbqMHnwsdS8vsKXiFQJHeAdNAhA+kwpqYAdhUiCdj\n" + - "RTUdtRNUucLvZEN1OAvVYyog9xYCfhtkqgXQROMANP+Z/+yaZahaP/Vgak/V00se\n" + - "Hdh7F+B6h5HVdwdh+17E2jl+aMTfyvBFcg2H/9Qjyl4TY8NW/6v0DPK52sVt8a35\n" + - "I+7xLGLPohAl4z6pEf2OxgjMNfXXCXS33smRgz1dLQFo8UpAb3rf84zkXaqEI6Qi\n" + - "2P+5pibVFQigRbn4RcE+K2a/nm2M/o+WZTSio+E+YXacnNk71VcO82biOof+jBKT\n" + - "iC3Xi7rAlypmme+QFBw9F1J89ig3smV/HaN8tO0lfTpvm7Zvzd5TkMs=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=ssltest-active.actalis.it, O=Actalis S.p.A., L=Ponte San Pietro, - // ST=Bergamo, C=IT - // Issuer: CN=Actalis Organization Validated Server CA G3, O=Actalis S.p A., - // L=Ponte San Pietro, ST=Bergamo, C=IT - // Serial number: 4a49e2afcd448af3b7f5f14e1cd5954 - // Valid from: Tue Mar 08 08:00:57 PST 2022 until: Wed Mar 08 08:00:57 PST 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIH0jCCBbqgAwIBAgIQBKSeKvzUSK87f18U4c1ZVDANBgkqhkiG9w0BAQsFADCB\n" + - "iTELMAkGA1UEBhMCSVQxEDAOBgNVBAgMB0JlcmdhbW8xGTAXBgNVBAcMEFBvbnRl\n" + - "IFNhbiBQaWV0cm8xFzAVBgNVBAoMDkFjdGFsaXMgUy5wLkEuMTQwMgYDVQQDDCtB\n" + - "Y3RhbGlzIE9yZ2FuaXphdGlvbiBWYWxpZGF0ZWQgU2VydmVyIENBIEczMB4XDTIy\n" + - "MDMwODE2MDA1N1oXDTIzMDMwODE2MDA1N1owdzELMAkGA1UEBhMCSVQxEDAOBgNV\n" + - "BAgMB0JlcmdhbW8xGTAXBgNVBAcMEFBvbnRlIFNhbiBQaWV0cm8xFzAVBgNVBAoM\n" + - "DkFjdGFsaXMgUy5wLkEuMSIwIAYDVQQDDBlzc2x0ZXN0LWFjdGl2ZS5hY3RhbGlz\n" + - "Lml0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsJnlOatNNth7gfqZ\n" + - "WN8HMfp9qlkDf/YW8ReNXyTtqFEy2xZrVVmAV2XIqL1lJDYJz86mdVsz3AqIMTzo\n" + - "GxPlmn/oEnF0YeRYQ1coKRdwP7hWSwqyMMhh+C7r5zMA9gQQVXV5wWR5U+bgvt23\n" + - "Y/55DOqk3Fp5Odt6Lyu6xA45MwHrj2Gr/nMKe8L7f8UYPWT98MJa1+TXB24yllOw\n" + - "rZE8gZByLBCVzDkVwRwTgu+HgY6zm5sJTvBT4tyJy4QD8u2xLWoZ5sXodrU0Z3Nf\n" + - "xU9keMFp6CIh1t+akqFgpW81b/HWkfUO0+L6PH4hgaSPtiwp2dVFsF9v5p4on9qA\n" + - "2j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qwx8DEZ2JkApFEV/3cVHBHZAsEAKQaNsgiaN9kTAAAB\n" + - "f2pMUYEAAAQDAEcwRQIgdCNjaV7nQcCiVefX28u1vtQMy+rqT4F4i9EVJ2xbqbQC\n" + - "IQCrpcYqt53tX/rSMoGnjFhDGnMhnYyc2AqzpokfhmdcVTANBgkqhkiG9w0BAQsF\n" + - "AAOCAgEAfXISBKP1dZQv1kkWZVDXiVY/fv+068DKq2e8hgBcsN6b9a2rlVfBU2iq\n" + - "W9KqFNET5GDWf1wjM71Itjau8b1A3+apcNdEGQk3eqIOymK5kVtVvAI2ahp4926x\n" + - "Kkt/sexmi1pJGA+eLfTixkCoaESh5P8U7HDW/vUFXm2AtLQih+oT5OVoYt5e9pXr\n" + - "hr8oadm/ZDJxiyDL1vcTIsl2TM4/Fpo2IWxYzUC+YshnuLiRwWI840maJmWFx/lJ\n" + - "Pzdik3P51Uef7VsCSBhTxER09/B4IrEUMDAhVgG5QNbcFSHvnmpV8JLrNuBKUROU\n" + - "xnDsWieKlb5YO6S6PjGOncOrd+k4RCIYRaekSnx52WBKkpqxMEv/rjY1Glx4Cota\n" + - "mpNiYDvZHGzrRQtY2eH17XhFatBxEEbJMA+0QPbFksHcKxAxJgMDncqag4TDq5fT\n" + - "I2NUxqiB51F5w0x+++lyLnUZ+z4BJFZ73VdtfoJ2fsuRhemOoZjHPi/V2exXpAfb\n" + - "pomha3KCrTcuFv1lj8mPx5L4ciNPxuDFgjeXEaTGjS8IvdNoJIrgdHdahMwkwS/y\n" + - "wei7FJ1Ey0maqRUpUlAY6sIQPQ/KDltTuKX/C94C5pYLI0JXCScr5xg6C+r2ckbA\n" + - "rjhpn3C/NptVyZgT8bL4XT5ITrAjwPciBj0yxYzUkrLZO1wKQSQ=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=ssltest-revoked.actalis.it, O=Actalis S.p.A., L=Ponte San Pietro, ST=Bergamo, C=IT - // Issuer: CN=Actalis Organization Validated Server CA G3, O=Actalis S.p.A., - // L=Ponte San Pietro, ST=Bergamo, C=IT - // Serial number: 320955171b78d49507508910da2c5bc4 - // Valid from: Tue Sep 27 03:40:43 PDT 2022 until: Wed Sep 27 03:40:43 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIH1TCCBb2gAwIBAgIQMglVFxt41JUHUIkQ2ixbxDANBgkqhkiG9w0BAQsFADCB\n" + - "iTELMAkGA1UEBhMCSVQxEDAOBgNVBAgMB0JlcmdhbW8xGTAXBgNVBAcMEFBvbnRl\n" + - "IFNhbiBQaWV0cm8xFzAVBgNVBAoMDkFjdGFsaXMgUy5wLkEuMTQwMgYDVQQDDCtB\n" + - "Y3RhbGlzIE9yZ2FuaXphdGlvbiBWYWxpZGF0ZWQgU2VydmVyIENBIEczMB4XDTIy\n" + - "MDkyNzEwNDA0M1oXDTIzMDkyNzEwNDA0M1oweDELMAkGA1UEBhMCSVQxEDAOBgNV\n" + - "BAgMB0JlcmdhbW8xGTAXBgNVBAcMEFBvbnRlIFNhbiBQaWV0cm8xFzAVBgNVBAoM\n" + - "DkFjdGFsaXMgUy5wLkEuMSMwIQYDVQQDDBpzc2x0ZXN0LXJldm9rZWQuYWN0YWxp\n" + - "cy5pdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKdBnbeFtw/Ejp1U\n" + - "gr86BQ5rqgGXWWXb7fsOhPb5On9RXTojg6oaeIV4GxHsMZhEDKQdcZ6JWAo2dbtp\n" + - "/7ereFEDWG/YJahLHFZ/ihXG4AmfObYEhoGbKitW75fOs/aWC7Veck/sXsw7cjLW\n" + - "GY623ybcF9DBExg3S4uLRaSkv5hXUDu/CzphUgwiEd5YNBZjcryOiS8+Y5EQ+2q+\n" + - "g+tdRG9m5G5YxeHWgQz2HDDwLDsJhWkb8/RsUurU/I+avHPhYk13K5Ysf311gww8\n" + - "bAsplfdJ2gdn8Is+EAEH4GJHqMybC95YDh1w5dY7dk/lIoNX4hYUIQimirIr3OW8\n" + - "Svkj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tdqwx8DEZ2JkApFEV/3cVHBHZAsEAKQaNsgiaN9kT\n" + - "AAABg36SGU0AAAQDAEcwRQIhAOCD/dOs4HjyC+GQaQRh4U+/mUwWyu+CnlHdebmD\n" + - "hAvFAiAvBE0rbxgm8TpZLG2TaMk3dqZj7Q6FFdLlqTsvwhKa3jANBgkqhkiG9w0B\n" + - "AQsFAAOCAgEAEnPALMVp1pySJgHhugLWAUgiD6stpDWCKfaBxPr+jf34A5wS+m5r\n" + - "2VhYyNQpOwIQB76K2RSJQrdpg7Dg2L6EiUnbbClSTrOkZ4XX5ggBIjldDEx4ZxhI\n" + - "zwSw4KB6+DDAVMwsCL0q0E7AAPOMaZ0RDLteusqQYIYm08TXfJPWD8LjQPt/8Uie\n" + - "LOqm1eLUuwJc+eHFWV+Xr8Uea6SFwqNEj7qPHb2MElctET/MhSIIUKI1ObmrFwyB\n" + - "ElKEPaUh9L0HXpnuD8IWc7tw2mdvnWJhuGG8G6JkasTGvtZ4gKIDBdTrJcuj7MCS\n" + - "amz3ZBCY47tP1ohgImjqwg4ITYjX6UQXgj/nBVDdu+nXkEhx16uPJkTYWaun9Nio\n" + - "8RjYIOxXmDD39QbGUElP0Epsr2wcVT9tIFYMGzUpIO51mCk3Aq1AmiQZwZZhqOIN\n" + - "RDx7lGESPj3IgdVfJi9Ing/OUNtS46Ug9DSuDcGqdY7KnTYEUdWGsUJNtnpjd4lS\n" + - "U6oIAeW1aKuOve6iNg1vsFAN57aJNh1ih3BOup58J9ve42bNlAYWN8wiNxM+Aeba\n" + - "ArUSTnH/QEYCyMRD0XqIREVR9VhNODgSZbL3XedYBAW9wImi1whp+u+8aReXd7lC\n" + - "Q3kD9KRyfZ9Kk05Glf3DsZMWvp1N2ZZWaU2Ms5U3ijUheCiBrqrs8a8=\n" + - "-----END CERTIFICATE-----"; - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - } - - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Tue Sep 27 03:52:40 PDT 2022", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.java deleted file mode 100644 index dec0ff8872a08..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.java +++ /dev/null @@ -1,613 +0,0 @@ -/* - * 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 - * 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 8233223 - * @summary Interoperability tests with Amazon's CA1, CA2, CA3, and CA4 - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath AmazonCA OCSP - * @run main/othervm -Djava.security.debug=certpath AmazonCA CRL - */ - -/* - * Obtain TLS test artifacts for Amazon CAs from: - * - * Amazon Root CA 1 - * Valid - https://good.sca1a.amazontrust.com/ - * Revoked - https://revoked.sca1a.amazontrust.com/ - * Amazon Root CA 2 - * Valid - https://good.sca2a.amazontrust.com/ - * Revoked - https://revoked.sca2a.amazontrust.com/ - * Amazon Root CA 3 - * Valid - https://good.sca3a.amazontrust.com/ - * Revoked - https://revoked.sca3a.amazontrust.com/ - * Amazon Root CA 4 - * Valid - https://good.sca4a.amazontrust.com/ - * Revoked - https://revoked.sca4a.amazontrust.com/ - */ -public class AmazonCA { - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - } - - new AmazonCA_1().runTest(pathValidator); - new AmazonCA_2().runTest(pathValidator); - new AmazonCA_3().runTest(pathValidator); - new AmazonCA_4().runTest(pathValidator); - } -} - -class AmazonCA_1 { - - // Owner: CN=Amazon RSA 2048 M02, O=Amazon, C=US - // Issuer: CN=Amazon Root CA 1, O=Amazon, C=US - // Serial number: 773124a4bcbd44ec7b53beaf194842d3a0fa1 - // Valid from: Tue Aug 23 15:25:30 PDT 2022 until: Fri Aug 23 15:25:30 PDT 2030 - private static final String INT_VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIEXjCCA0agAwIBAgITB3MSSkvL1E7HtTvq8ZSELToPoTANBgkqhkiG9w0BAQsF\n" + - "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + - "b24gUm9vdCBDQSAxMB4XDTIyMDgyMzIyMjUzMFoXDTMwMDgyMzIyMjUzMFowPDEL\n" + - "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEcMBoGA1UEAxMTQW1hem9uIFJT\n" + - "QSAyMDQ4IE0wMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALtDGMZa\n" + - "qHneKei1by6+pUPPLljTB143Si6VpEWPc6mSkFhZb/6qrkZyoHlQLbDYnI2D7hD0\n" + - "s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UwFIb7UIspogZSKxPIWJpxiPo3TcBambbVtQOcNRWz5qCQdD\n" + - "slI2yayq0n2TXoHyNCLEH8rpsJRVILFsg0jc7BaFrMnF462+ajSehgj12IidNeRN\n" + - "4zl+EoNaWdpnWndvSpAEkq2P\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=Amazon RSA 2048 M01, O=Amazon, C=US - // Issuer: CN=Amazon Root CA 1, O=Amazon, C=US - // Serial number: 77312380b9d6688a33b1ed9bf9ccda68e0e0f - // Valid from: Tue Aug 23 15:21:28 PDT 2022 until: Fri Aug 23 15:21:28 PDT 2030 - private static final String INT_REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIEXjCCA0agAwIBAgITB3MSOAudZoijOx7Zv5zNpo4ODzANBgkqhkiG9w0BAQsF\n" + - "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + - "b24gUm9vdCBDQSAxMB4XDTIyMDgyMzIyMjEyOFoXDTMwMDgyMzIyMjEyOFowPDEL\n" + - "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEcMBoGA1UEAxMTQW1hem9uIFJT\n" + - "QSAyMDQ4IE0wMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOtxLKnL\n" + - "H4gokjIwr4pXD3i3NyWVVYesZ1yX0yLI2qIUZ2t88Gfa4gMqs1YSXca1R/lnCKeT\n" + - "epWSGA+0+fkQNpp/L4C2T7oTTsddUx7g3ZYzByDTlrwS5HRQQqEFE3O1T5tEJP4t\n" + - "f+28IoXsNiEzl3UGzicYgtzj2cWCB41eJgEmJmcf2T8TzzK6a614ZPyq/w4CPAff\n" + - "nAV4coz96nW3AyiE2uhuB4zQUIXvgVSycW7sbWLvj5TDXunEpNCRwC4kkZjK7rol\n" + - "jtT2cbb7W2s4Bkg3R42G3PLqBvt2N32e/0JOTViCk8/iccJ4sXqrS1uUN4iB5Nmv\n" + - "JK74csVl+0u0UecCAwEAAaOCAVowggFWMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYD\n" + - "VR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNV\n" + - "HQ4EFgQUgbgOY4qJEhjl+js7UJWf5uWQE4UwHwYDVR0jBBgwFoAUhBjMhTTsvAyU\n" + - "lC4IWZzHshBOCggwewYIKwYBBQUHAQEEbzBtMC8GCCsGAQUFBzABhiNodHRwOi8v\n" + - "b2NzcC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbTA6BggrBgEFBQcwAoYuaHR0cDov\n" + - "L2NydC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbS9yb290Y2ExLmNlcjA/BgNVHR8E\n" + - "ODA2MDSgMqAwhi5odHRwOi8vY3JsLnJvb3RjYTEuYW1hem9udHJ1c3QuY29tL3Jv\n" + - "b3RjYTEuY3JsMBMGA1UdIAQMMAowCAYGZ4EMAQIBMA0GCSqGSIb3DQEBCwUAA4IB\n" + - "AQCtAN4CBSMuBjJitGuxlBbkEUDeK/pZwTXv4KqPK0G50fOHOQAd8j21p0cMBgbG\n" + - "kfMHVwLU7b0XwZCav0h1ogdPMN1KakK1DT0VwA/+hFvGPJnMV1Kx2G4S1ZaSk0uU\n" + - "5QfoiYIIano01J5k4T2HapKQmmOhS/iPtuo00wW+IMLeBuKMn3OLn005hcrOGTad\n" + - "hcmeyfhQP7Z+iKHvyoQGi1C0ClymHETx/chhQGDyYSWqB/THwnN15AwLQo0E5V9E\n" + - "SJlbe4mBlqeInUsNYugExNf+tOiybcrswBy8OFsd34XOW3rjSUtsuafd9AWySa3h\n" + - "xRRrwszrzX/WWGm6wyB+f7C4\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=valid.rootca1.demo.amazontrust.com - // Issuer: CN=Amazon RSA 2048 M02, O=Amazon, C=US - // Serial number: 60c6e837b2e7586d8464eb34f4a85fe - // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIGKDCCBRCgAwIBAgIQBgxug3sudYbYRk6zT0qF/jANBgkqhkiG9w0BAQsFADA8\n" + - "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRwwGgYDVQQDExNBbWF6b24g\n" + - "UlNBIDIwNDggTTAyMB4XDTIzMDUxMDAwMDAwMFoXDTI0MDYwNzIzNTk1OVowLTEr\n" + - "MCkGA1UEAxMidmFsaWQucm9vdGNhMS5kZW1vLmFtYXpvbnRydXN0LmNvbTCCASIw\n" + - "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3hA+omhUcO8nYO8/+dkpbYz8WI\n" + - "1ms7Y7JA2pPFfp2N/aWcf6m5ORm1BkyGLOttjTu318Qpa9eahQ1Pi3RNe3BtqjD9\n" + - "jcHncpwAFMsXy1beZA7sZ7AA4vKltA3t6yrU5ruTLUGQwUndeIBBSTW5QpdT9I/p\n" + - "EM7d+Miwre63kofbJ1lVPAJvN/udMVqGWNF8V5qscklUUHoSKA3FWWsiCyIgnthg\n" + - "G3u6R1KH66Qionp0ho/ttvrBCI0C/bdrdH+wybFv8oFFvAW2U9xn2Azt47/2kHHm\n" + - "tTRjrgufhDbcz/MLR6hwBXAJuwVvJZmSqe7B4IILFexu6wjxZfyqVm2FMr8CAwEA\n" + - "AaOCAzMwggMvMB8GA1UdIwQYMBaAFMAxUs1aUMOCfHRxzsvpnPl664LiMB0GA1Ud\n" + - "DgQWBBSkrnsTnjwYhDRAeLy/9FXm/7hApDBlBgNVHREEXjBcgiJ2YWxpZC5yb290\n" + - "Y2ExLmRlbW8uYW1hem9udHJ1c3QuY29tghpnb29kLnNjYTBhLmFtYXpvbnRydXN0\n" + - "LmNvbYIaZ29vZC5zY2ExYS5hbWF6b250cnVzdC5jb20wDgYDVR0PAQH/BAQDAgWg\n" + - "MB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQ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prwLul4\n" + - "8wp3gnC3Hjb8NykydCo6vw0AJ2UzjpjiTyVZ93jITzLOiboOUa1gQGnojzWlYaet\n" + - "sXe+RDylBp/Wuj1ZS7v/etltzYm5GanPi4y/p7Ta3Uky6std/GM6XbPRdBEFboFR\n" + - "B2IP0divd9c74Q+tLgpsAz5yXm9LtYPMcEPC2YRN2PgBg67c5+A7eIOluuw=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.rootca1.demo.amazontrust.com - // Issuer: CN=Amazon RSA 2048 M01, O=Amazon, C=US - // Serial number: e1023665b1268d788cc25bf69a9d05e - // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIGMjCCBRqgAwIBAgIQDhAjZlsSaNeIzCW/aanQXjANBgkqhkiG9w0BAQsFADA8\n" + - "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRwwGgYDVQQDExNBbWF6b24g\n" + - "UlNBIDIwNDggTTAxMB4XDTIzMDUxMDAwMDAwMFoXDTI0MDYwNzIzNTk1OVowLzEt\n" + - "MCsGA1UEAxMkcmV2b2tlZC5yb290Y2ExLmRlbW8uYW1hem9udHJ1c3QuY29tMIIB\n" + - "IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxSPd1PWACxZohFCAJT1JWuXK\n" + - "GY29wZZ9yY0zoiq6+qYiUIU0crktytUNNI1ZpW/3qXpEw2ZQkM6WF1LshXtwGwrA\n" + - "zJwSeX1L9T5rOKhoBvoFeqfX7xu4VBM1/fDGt5X+NRFfD9Op9UfK5OsnL05TYach\n" + - "rdnfOA5wKGvMgFiN5CeOD0AtumXSuAnTZC85ojJTHjPF+hqV893WvrrUxLyyxtvh\n" + - "lq/WttFOjhfQu2IkfyDAFiH939uzUi0WSTAdsbsHuko5mDTDnOfMRbaaWZu0At01\n" + - "EgaIPeK+kGdi7EYwVndIwTKLeQ4mjIM8aj8Heg/y2hZ0kOmfCUZdUmJFlNoCIQID\n" + - "AQABo4IDOzCCAzcwHwYDVR0jBBgwFoAUgbgOY4qJEhjl+js7UJWf5uWQE4UwHQYD\n" + - "VR0OBBYEFMeBhIOkuWUY4DYqFrfgbD2eUeFtMG0GA1UdEQRmMGSCJHJldm9rZWQu\n" + - "cm9vdGNhMS5kZW1vLmFtYXpvbnRydXN0LmNvbYIdcmV2b2tlZC5zY2EwYS5hbWF6\n" + - "b250cnVzdC5jb22CHXJldm9rZWQuc2NhMWEuYW1hem9udHJ1c3QuY29tMA4GA1Ud\n" + - "DwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwOwYDVR0f\n" + - "BDQwMjAwoC6gLIYqaHR0cDovL2NybC5yMm0wMS5hbWF6b250cnVzdC5jb20vcjJt\n" + - "MDEuY3JsMBMGA1UdIAQMMAowCAYGZ4EMAQIBMHUGCCsGAQUFBwEBBGkwZzAtBggr\n" + - "BgEFBQcwAYYhaHR0cDovL29jc3AucjJtMDEuYW1hem9udHJ1c3QuY29tMDYGCCsG\n" + - "AQUFBzAChipodHRwOi8vY3J0LnIybTAxLmFtYXpvbnRydXN0LmNvbS9yMm0wMS5j\n" + - "ZXIwDAYDVR0TAQH/BAIwADCCAX4GCisGAQQB1nkCBAIEggFuBIIBagFoAHYA7s3Q\n" + - "ZNXbGs7FXLedtM0TojKHRny87N7DUUhZRnEftZsAAAGIB72TggAABAMARzBFAiAZ\n" + - "naLbRHRuaRrE304GSuWX/79MU/e+SSlr0cNJ0kNNaAIhAPnz9HayL4txhkTEZiMs\n" + - "nttNnNqD17I0J17JLVOF4i/4AHYASLDja9qmRzQP5WoC+p0w6xxSActW3SyB2bu/\n" + - "qznYhHMAAAGIB72TmwAABAMARzBFAiEAgEqT7CYGQ/u36/3YcxBH78QfknI9kgcY\n" + - "sgJLkurUF6cCIFZZ/b803+ek6o+bmdV/uVx2UlskAyyolZ2okBAb6IscAHYA2ra/\n" + - "az+1tiKfm8K7XGvocJFxbLtRhIU0vaQ9MEjX+6sAAAGIB72TbQAABAMARzBFAiEA\n" + - "6z2RSoK263hvYF71rj1d0TpC70/6zagSRR4glHOT6IACICYvaMAnrCNSTSiZ20Wz\n" + - "Ju5roTippO3BWKhQYrTKZuu4MA0GCSqGSIb3DQEBCwUAA4IBAQB4S1JGulFpMIaP\n" + - "NtLUJmjWz8eexQdWLDVF+H8dd6xpZgpiYtig/Ynphzuk1IIF8DkT3CeK/9vrezgI\n" + - "igNjneN9B4eIuzi/rJzIKeUwpZ2k5D+36Ab4esseoc+TopmNerw8hidt2g818jER\n" + - "D71ppSMakeQFPGe/Hs2/cVa/G1DNVcU2XAut45yRZ/+xsZ0/mcBDVsG9P5uGCN5O\n" + - "7SAp4J959WnKDqgVuU9WowPE5IjmS9BAv2gjniFYdDV2yksyf7+8edHd1KfSVX06\n" + - "pLx6CuCVZGJFG4Q2Aa1YAh1Wvt9hqWeXXpNRO2/wChL5rhT4GajsrGepsk4bjxYX\n" + - "Wf2iZ8mX\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - - // Validate valid - pathValidator.validate(new String[]{VALID, INT_VALID}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT_REVOKED}, - ValidatePathWithParams.Status.REVOKED, - "Mon May 15 13:36:57 PDT 2023", System.out); - } -} - -class AmazonCA_2 { - - // Owner: CN=Amazon RSA 4096 M02, O=Amazon, C=US - // Issuer: CN=Amazon Root CA 2, O=Amazon, C=US - // Serial number: 773125b0c34c3c940299a9f04a39e5a52ccd9 - // Valid from: Tue Aug 23 15:29:13 PDT 2022 until: Fri Aug 23 15:29:13 PDT 2030 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIGXjCCBEagAwIBAgITB3MSWww0w8lAKZqfBKOeWlLM2TANBgkqhkiG9w0BAQwF\n" + - "ADA5MQswCQYD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+ - "lKvDTDxZvPF4dbEXICNPd51EMGPgETxwboOV+bzWFVI0IWQ8PhZ2VuMPDk2taOMp\n" + - "NsuLtlYc2twPb9r/Hvgv7G6+ItpBHZwOVt1oI3pHbjMp7P3pOZSPr6G1WkNy9mX8\n" + - "rVc=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=valid.rootca2.demo.amazontrust.com - // Issuer: CN=Amazon RSA 4096 M02, O=Amazon, C=US - // Serial number: 662f7646d76193cbb76946d111e49fa - // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIICzCCBfOgAwIBAgIQBmL3ZG12GTy7dpRtER5J+jANBgkqhkiG9w0BAQwFADA8\n" + - "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRwwGgYDVQQDExNBbWF6b24g\n" + - "UlNBIDQwOTYgTTAyMB4XDTIzMDUxMDAwMDAwMFoXDTI0MDYwNzIzNTk1OVowLTEr\n" + - "MCkGA1UEAxMidmFsaWQucm9vdGNhMi5kZW1vLmFtYXpvbnRydXN0LmNvbTCCAiIw\n" + - "DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAON5EbEKoBiujI7Ja8mLZLJbaY7f\n" + - "RtoWIjU/F0l9ueWFogXmEaA1jWsl97F3WTHTyGKz6ChCjPMSyoXXpY+yoE90QUyX\n" + - "w35uWEhNrc40drMJkyN+QXitSrH346GCOKvpYVvu18UD4W8hDhg8vvbOQYhtmSf7\n" + - "Rfrs7/qUdXpzpvR9VjWktbQAzJT8fB/jFNjNQJTknynjGiYO5GF51+peOCLK6qw8\n" + - "9kKYEigR4K8/aWL283rC4xRxZqVioy433VG02l/Fwdv8o/vL9YYIqkyspCB9fpFw\n" + - "Q50yYrwEomxuOz7rXhmdfeNaFYuyTtOUSKff6p2oqO0S7pcLujUVMlO4dYBDELQF\n" + - "cabByNjwblviCtGKJMIzD6Thkgamp3iXQgc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n" + - "+rTcuke2feOvQ4EnVviM0k85JZNiqPDH2iafAWyqZFUYTnb7XK3HhJflAniv/SLq\n" + - "DQfbJmtQtNHdJYgVmC1u2RT9gbJDIAj0ZI4vU2WVB5Hmd9F31un6jundEuG4+S4=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.rootca2.demo.amazontrust.com - // Issuer: CN=Amazon RSA 4096 M02, O=Amazon, C=US - // Serial number: 788baa8f47bc5b1c624424216240fd3 - // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIIEjCCBfqgAwIBAgIQB4i6qPR7xbHGJEJCFiQP0zANBgkqhkiG9w0BAQwFADA8\n" + - "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRwwGgYDVQQDExNBbWF6b24g\n" + - "UlNBIDQwOTYgTTAyMB4XDTIzMDUxMDAwMDAwMFoXDTI0MDYwNzIzNTk1OVowLzEt\n" + - "MCsGA1UEAxMkcmV2b2tlZC5yb290Y2EyLmRlbW8uYW1hem9udHJ1c3QuY29tMIIC\n" + - "IjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzJfddWdrWhA9dSJdmy23veN9\n" + - "oLvSqpM4YaXGZmPtKUmbFMLs2I3vCKrzflRKeOpl3MCc2hh6TH/3z+Q/fGugXLsY\n" + - "H8QcjSbiIOd15n+3dUFTLKaoWMyseMcWiOIVaN5rCDVXiAHdt1pc147wyFQIzqNK\n" + - "J/xiV1u9eT2MFue+4bd7kUNAcmI8M+SXruhto4jtAV8ugpTEChTDlyO/l8xmaM1Q\n" + - "HkijsHX7Aq72Q/3PH/U+wbJ9pmpTp4x2AEJoo45IGfB/NKDTrv5otLBuiP8Y0M7b\n" + - "K7irRPDFBqMNZw7S7p39SnC+V/WibJQk5Bo/8vcwDJX+WnDkw1QD/uXu3ugDzSDD\n" + - "iBDViMOdN+3K47s4x2kdssoh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ynPaZHq/c0\n" + - "GGvyT6MpvFGMW0s0woLRT28CIEFbZbFSCnKugaqw9QDNi7vYmIF3Gyi3s6G2cCxY\n" + - "4RJXAHYASLDja9qmRzQP5WoC+p0w6xxSActW3SyB2bu/qznYhHMAAAGIB72DDgAA\n" + - "BAMARzBFAiAvfNcgtFEwk5C9dvMUYANbIAv0IOdF1new8Umn3cM+JwIhALbs/3L9\n" + - "0ndF7sRKDZmfronNruptFlrI528P5Qi2P528AHUA2ra/az+1tiKfm8K7XGvocJFx\n" + - "bLtRhIU0vaQ9MEjX+6sAAAGIB72CxQAABAMARjBEAiBKUns2FPbs0cThb6e7SnyL\n" + - "y4/qP3V1Q/ASt/ZDRTeEQQIgWSQO4Gsz32srtqYuTM9AsFd92WA44kJHincdcGVX\n" + - "XbIwDQYJKoZIhvcNAQEMBQADggIBAAnaNbn2wXylTCS7dtgB3rWdUf6hja1UDuvB\n" + - "uZEL2dUOvyXfVFLNxKdeWBPzqpwEBNNwPQXhoI97TXlyu2x60jLzQamoGoRQ3s0P\n" + - "NLhasLGEIQH/oYdMV/yp8EI8fUuRVE3xyw39FRqOrmsUFAnxNQmBO/09JM7sLcvS\n" + - "wwh14p9dFTTolJHgnL4ZEtmZxSddFG+GBSTJ/A7dVSmwIudwzd+goA6173BI6yeT\n" + - "hhQumLctQiOM7y1MzFeV8rL+oIpd2xuzyhKKT1EgvU6/wyt0Ib8QqsFsrXPnUOKk\n" + - "HAq3SeZyq35QUaTKoaH9L1iZMbSCG9Jm6FMb12SdAz53653tYvAiUS76oD8Jot13\n" + - "RZu5NUlWAVLLq0OaEtuGp0bh+cVtzVnCC9m1qa46YpY0SojpvSbakgQMMGIgDlT3\n" + - "wFE7tST4WlsDC1f/m+H9V5qz/j0U8D3eNNdowxPqx/JZq/sk9ZK5KyMFARrvM+fh\n" + - "YrVYjKt91mu7JaS4pPOyZmJ8OQ14EvrN7BXc7IkNrI1reeaRFe49k5DAETB8VmP5\n" + - "2F0SWou2KkgtJvU4Z7YjlZ2HNHnpjTK5KdPNpRSt7EUy2zn9NCNoyQhnws70FyXv\n" + - "oPFyG92lnUQOKaAUhVRwTr9fvnkdMOzSKg/spxi2Ogdzym5Jw68eguwi0dVqX2+9\n" + - "3zViP2aH\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Mon May 15 13:38:54 PDT 2023", System.out); - } -} - -class AmazonCA_3 { - - // Owner: CN=Amazon ECDSA 256 M02, O=Amazon, C=US - // Issuer: CN=Amazon Root CA 3, O=Amazon, C=US - // Serial number: 773126de2c2fafd2c47ad88b1566e0182046d - // Valid from: Tue Aug 23 15:33:24 PDT 2022 until: Fri Aug 23 15:33:24 PDT 2030 - private static final String INT_VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIC1DCCAnmgAwIBAgITB3MSbeLC+v0sR62IsVZuAYIEbTAKBggqhkjOPQQDAjA5\n" + - "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + - "Um9vdCBDQSAzMB4XDTIyMDgyMzIyMzMyNFoXDTMwMDgyMzIyMzMyNFowPTELMAkG\n" + - "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEdMBsGA1UEAxMUQW1hem9uIEVDRFNB\n" + - "IDI1NiBNMDIwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAS9vQLD4W/Kg4AnFRl8\n" + - "x/FUbLqtd5ICYjUijGsytF9hmgb/Dyk+Ebt4cw6rAlGbaiOLapSJKZiZr+UQdh3I\n" + - "QOr+o4IBWjCCAVYwEgYDVR0TAQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYw\n" + - "HQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMB0GA1UdDgQWBBS7eJrXaDMy\n" + - "nRq7bP2xNEwB3svQdTAfBgNVHSMEGDAWgBSrttvXBp43rDCGB5Fwx5zEGbF4wDB7\n" + - "BggrBgEFBQcBAQRvMG0wLwYIKwYBBQUHMAGGI2h0dHA6Ly9vY3NwLnJvb3RjYTMu\n" + - "YW1hem9udHJ1c3QuY29tMDoGCCsGAQUFBzAChi5odHRwOi8vY3J0LnJvb3RjYTMu\n" + - "YW1hem9udHJ1c3QuY29tL3Jvb3RjYTMuY2VyMD8GA1UdHwQ4MDYwNKAyoDCGLmh0\n" + - "dHA6Ly9jcmwucm9vdGNhMy5hbWF6b250cnVzdC5jb20vcm9vdGNhMy5jcmwwEwYD\n" + - "VR0gBAwwCjAIBgZngQwBAgEwCgYIKoZIzj0EAwIDSQAwRgIhAKSYEcDcp3kcPMzh\n" + - "OIYDWZOLu4InPod4fQhRTmc2zBAgAiEAmwdGE4AuNWhw9N8REhf82rJLNm7h9Myg\n" + - "TsR9Wu0bQYU=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=Amazon ECDSA 256 M01, O=Amazon, C=US - // Issuer: CN=Amazon Root CA 3, O=Amazon, C=US - // Serial number: 773126684d577c0fcf8d3a342bea86f94fc8f - // Valid from: Tue Aug 23 15:31:46 PDT 2022 until: Fri Aug 23 15:31:46 PDT 2030 - private static final String INT_REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIC0zCCAnmgAwIBAgITB3MSZoTVd8D8+NOjQr6ob5T8jzAKBggqhkjOPQQDAjA5\n" + - "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + - "Um9vdCBDQSAzMB4XDTIyMDgyMzIyMzE0NloXDTMwMDgyMzIyMzE0NlowPTELMAkG\n" + - "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEdMBsGA1UEAxMUQW1hem9uIEVDRFNB\n" + - "IDI1NiBNMDEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAT80w+2RwNHzyXmVUM/\n" + - "OUKBZpJkTzHyCKDl4sBrUfjzVjot/lNba9kYzMKSHYv95CUDoMaF2h2KAqx65uLQ\n" + - "Y8ago4IBWjCCAVYwEgYDVR0TAQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYw\n" + - "HQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMB0GA1UdDgQWBBRPWfy8BhYo\n" + - "v6LI2wj7zxMkumlCXDAfBgNVHSMEGDAWgBSrttvXBp43rDCGB5Fwx5zEGbF4wDB7\n" + - "BggrBgEFBQcBAQRvMG0wLwYIKwYBBQUHMAGGI2h0dHA6Ly9vY3NwLnJvb3RjYTMu\n" + - "YW1hem9udHJ1c3QuY29tMDoGCCsGAQUFBzAChi5odHRwOi8vY3J0LnJvb3RjYTMu\n" + - "YW1hem9udHJ1c3QuY29tL3Jvb3RjYTMuY2VyMD8GA1UdHwQ4MDYwNKAyoDCGLmh0\n" + - "dHA6Ly9jcmwucm9vdGNhMy5hbWF6b250cnVzdC5jb20vcm9vdGNhMy5jcmwwEwYD\n" + - "VR0gBAwwCjAIBgZngQwBAgEwCgYIKoZIzj0EAwIDSAAwRQIhALRfxq3SQIhj5xA4\n" + - "S5UAY/KlKqayZDpnbBdCDH8Kqmf/AiAUVZddALefnqRe+ifxN2FUp461LL6/cgVM\n" + - "EH3Ty27f1Q==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=valid.rootca3.demo.amazontrust.com - // Issuer: CN=Amazon ECDSA 256 M02, O=Amazon, C=US - // Serial number: 8e2f14864fb28e4a1da0f15a5118cc8 - // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIEfjCCBCWgAwIBAgIQCOLxSGT7KOSh2g8VpRGMyDAKBggqhkjOPQQDAjA9MQsw\n" + - "CQYDVQQGEwJ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IgdAlMjqeoihi1arnJpzN8Bqxy\n" + - "5ULMUO7GK3JEgcogJHMAdgBIsONr2qZHNA/lagL6nTDrHFIBy1bdLIHZu7+rOdiE\n" + - "cwAAAYgHvXLkAAAEAwBHMEUCIF7wDDmWxTHwBZM7Me8eOCM1aQ/g1c1rJg/I+NJa\n" + - "HkZYAiEA8p+IviuY5piHBELjUtVlZLiS9XSSMxpQNhUerqC/YFoAdQDatr9rP7W2\n" + - "Ip+bwrtca+hwkXFsu1GEhTS9pD0wSNf7qwAAAYgHvXKvAAAEAwBGMEQCIFLskZDs\n" + - "UG4+/88D/5/QbD9zT6ZmZlwXiPZ6H2YR/KiJAiBvi4vvNsb9KNAhJMgI2T2iCg9U\n" + - "CIru+US6y3ua7dKKDTAKBggqhkjOPQQDAgNHADBEAiAzvgzKV/kvBbKWCT1NNUBD\n" + - "AF9okIEcJx/ukFgzmYMwUQIgXeJeVf3izkxsgiEUSknwHsErLFs/cEme2PSRj2AW\n" + - "dYA=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.rootca3.demo.amazontrust.com - // Issuer: CN=Amazon ECDSA 256 M01, O=Amazon, C=US - // Serial number: c458bfaeedae16a5e61fe64773fc898 - // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIEhzCCBC2gAwIBAgIQDEWL+u7a4WpeYf5kdz/ImDAKBggqhkjOPQQDAjA9MQsw\n" + - "CQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMR0wGwYDVQQDExRBbWF6b24gRUNE\n" + - "U0EgMjU2IE0wMTAeFw0yMzA1MTAwMDAwMDBaFw0yNDA2MDcyMzU5NTlaMC8xLTAr\n" + - "BgNVBAMTJHJldm9rZWQucm9vdGNhMy5kZW1vLmFtYXpvbnRydXN0LmNvbTBZMBMG\n" + - "ByqGSM49AgEGCCqGSM49AwEHA0IABAsSs5kW5TZlS0SDrMb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N4q4NnMgB1\n" + - "ANq2v2s/tbYin5vCu1xr6HCRcWy7UYSFNL2kPTBI1/urAAABiAe9lN4AAAQDAEYw\n" + - "RAIgL0qoVbKLFD+Y3f/V6Rw+euZrPO6d1HEVPQGo7wLzkl8CIGHp3PQmmrEofl76\n" + - "4da7bY0L+csFW0sB8clN0KziMfe6MAoGCCqGSM49BAMCA0gAMEUCIQC+6VdX9X5g\n" + - "x3NSUmJ7py01Zxf26TNBv1ildxqesvZ/7wIgIrefriRzPiIFDHCUbdjk0VlmMwZR\n" + - "VzXXHINsGCiCKOs=\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - - // Validate valid - pathValidator.validate(new String[]{VALID, INT_VALID}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT_REVOKED}, - ValidatePathWithParams.Status.REVOKED, - "Mon May 15 13:41:22 PDT 2023", System.out); - } -} - -class AmazonCA_4 { - - // Owner: CN=Amazon ECDSA 384 M02, O=Amazon, C=US - // Issuer: CN=Amazon Root CA 4, O=Amazon, C=US - // Serial number: 773127dfaa6b9e2b95538aa76dde4307f17c4 - // Valid from: Tue Aug 23 15:36:58 PDT 2022 until: Fri Aug 23 15:36:58 PDT 2030 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIDETCCApagAwIBAgITB3MSffqmueK5VTiqdt3kMH8XxDAKBggqhkjOPQQDAzA5\n" + - "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + - "Um9vdCBDQSA0MB4XDTIyMDgyMzIyMzY1OFoXDTMwMDgyMzIyMzY1OFowPTELMAkG\n" + - "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEdMBsGA1UEAxMUQW1hem9uIEVDRFNB\n" + - "IDM4NCBNMDIwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATNYzWQDXV0NoNmR0hJPwJq\n" + - "hjYOOS9z0B2Z7MQudxg5x3Vsib6N+tJkq8dljRq5o6K0bbh/kRVfoi9wfKhB03Yz\n" + - "gkerrwRCH7Z9gU5nbBY+Y5+EtImq4yOB0n7JQgQxWemjggFaMIIBVjASBgNVHRMB\n" + - "Af8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBhjAdBgNVHSUEFjAUBggrBgEFBQcD\n" + - "AQYIKwYBBQUHAwIwHQYDVR0OBBYEFKbZqzuHmTP/6Gj4i2GDbNCyuq+9MB8GA1Ud\n" + - "IwQYMBaAFNPsxzplbszh2naaVvuc84ZtV+WBMHsGCCsGAQUFBwEBBG8wbTAvBggr\n" + - "BgEFBQcwAYYjaHR0cDovL29jc3Aucm9vdGNhNC5hbWF6b250cnVzdC5jb20wOgYI\n" + - "KwYBBQUHMAKGLmh0dHA6Ly9jcnQucm9vdGNhNC5hbWF6b250cnVzdC5jb20vcm9v\n" + - "dGNhNC5jZXIwPwYDVR0fBDgwNjA0oDKgMIYuaHR0cDovL2NybC5yb290Y2E0LmFt\n" + - "YXpvbnRydXN0LmNvbS9yb290Y2E0LmNybDATBgNVHSAEDDAKMAgGBmeBDAECATAK\n" + - "BggqhkjOPQQDAwNpADBmAjEA2zCG6x0xMlgSXWEGLN8+1XN+OCYF5vj0Z1jtVy+A\n" + - "pdLlzuxNt9HBWn3hvqvO2W8KAjEApNdsZOCmk5uZBYiuCSBnDH3jyKhN6dWyuuHW\n" + - "9Wj7SxKnOU5+wYWZA0BQAv1KT62i\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=valid.rootca4.demo.amazontrust.com - // Issuer: CN=Amazon ECDSA 384 M02, O=Amazon, C=US - // Serial number: f579bed3369f1a147ea5d0e8e6532d3 - // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIEvjCCBESgAwIBAgIQD1eb7TNp8aFH6l0OjmUy0zAKBgg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sNR\n" + - "SFlGcR+1mwAAAYgHvZA9AAAEAwBHMEUCIQCmzmQOzunsuAg1GpIcNx0isG6ylbhP\n" + - "y9JP4UFclL2hdwIgBtTM89mE7QJDj7h7xr2eRPio1ehgmeYH1PHXxCqHIGYAdgBI\n" + - "sONr2qZHNA/lagL6nTDrHFIBy1bdLIHZu7+rOdiEcwAAAYgHvZB1AAAEAwBHMEUC\n" + - "IF9hbi82CLU5umfRze4NpX6u4jlT+N8KSaBe6UbhqjBZAiEAi2Y6PTt2+107LxtM\n" + - "oBpHprph7hQvGfjPE+p+rfM/X+EAdgDatr9rP7W2Ip+bwrtca+hwkXFsu1GEhTS9\n" + - "pD0wSNf7qwAAAYgHvZBeAAAEAwBHMEUCIAI+m4mVE3HtZOEMC5VI7m0nEPdPPJUq\n" + - "fxUKPpeIVmk5AiEA0scVJy7g3Fv+2nTVhbcwWCwn/Gvc+0txQrc529juflcwCgYI\n" + - "KoZIzj0EAwMDaAAwZQIxAKV837BpqlNHg35EsCCtrJPoQ6RuY9UoHm1O2CdsCXGR\n" + - "Z3kAnlgIV8A/waI6wQqfsQIwdCqaC+qN60JCnX09YKRD15eQjq1rN3w+llI+lEbS\n" + - "FSMsnoHJcqMZLo9s+4Rf0zS3\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.rootca4.demo.amazontrust.com - // Issuer: CN=Amazon ECDSA 384 M02, O=Amazon, C=US - // Serial number: 4a5d392936b4decb818b7fb106ebbd8 - // Valid from: Tue May 09 17:00:00 PDT 2023 until: Fri Jun 07 16:59:59 PDT 2024 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIExjCCBEygAwIBAgIQBKXTkpNrTey4GLf7EG672DAKBggqhkjOPQQDAzA9MQsw\n" + - "CQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMR0wGwYDVQQDExRBbWF6b24gRUNE\n" + - "U0EgMzg0IE0wMjAeFw0yMzA1MTAwMDAwMDBaFw0yNDA2MDcyMzU5N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scIAHcASLDja9qmRzQP5WoC+p0w6xxSActW3SyB2bu/qznYhHMAAAGIB72QJgAA\n" + - "BAMASDBGAiEAg+x7JBT3oIaZdnfgGN1G6SAiNUL7zR/tBhbWIG9tz94CIQDGwBiV\n" + - "Tslt11+W3ZaNsS7UtUIiB45YHUc4qKm5ry2fTAB2ANq2v2s/tbYin5vCu1xr6HCR\n" + - "cWy7UYSFNL2kPTBI1/urAAABiAe9kAgAAAQDAEcwRQIgPvKfSpMJKRocGk9+GNr3\n" + - "hUj8x8WySB//0X116TNgA0gCIQDhGRqxnEZmEFGEfj5GY9vjEfm0kKwcL0lCuwBu\n" + - "NZG4dzAKBggqhkjOPQQDAwNoADBlAjEA1PLdsrko3tDs50aAeEU9Gn+0CG8QKy7R\n" + - "fQaXBTjGETDgGJk/7zGNpGelKPr/UYV9AjASwdA32S8jIADxA8HrqiMsVYDFMnbU\n" + - "jLLwR6CTLtAcWtwVmoQ2x0usvTvN8YJBPoA=\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Mon May 15 13:42:48 PDT 2023", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/BuypassCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/BuypassCA.java deleted file mode 100644 index 9ad20271bec41..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/BuypassCA.java +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. - * 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 8189131 - * @summary Interoperability tests with Buypass Class 2 and Class 3 CA - * @build ValidatePathWithParams - * @run main/othervm/timeout=180 -Djava.security.debug=certpath BuypassCA OCSP - * @run main/othervm/timeout=180 -Djava.security.debug=certpath BuypassCA CRL - */ - - /* - * Obtain test artifacts for Buypass Class 2 and Class 3 CAs from: - * Buypass Class 3 CA 2 - * https://valid.qcevident.ca23.ssl.buypass.no/ - * https://revoked.qcevident.ca23.ssl.buypass.no/ - * https://expired.qcevident.ca23.ssl.buypass.no/ - * https://valid.evident.ca23.ssl.buypass.no/ - * https://revoked.evident.ca23.ssl.buypass.no/ - * https://expired.evident.ca23.ssl.buypass.no/ - * https://valid.businessplus.ca23.ssl.buypass.no - * https://revoked.businessplus.ca23.ssl.buypass.no - * https://expired.businessplus.ca23.ssl.buypass.no - - * Buypass Class 2 CA 2 - * https://valid.business.ca22.ssl.buypass.no - * https://revoked.business.ca22.ssl.buypass.no - * https://expired.business.ca22.ssl.buypass.no - * https://valid.domain.ca22.ssl.buypass.no - * https://revoked.domain.ca22.ssl.buypass.no - * https://expired.domain.ca22.ssl.buypass.no/ - */ -public class BuypassCA { - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - } - - new BuypassClass2().runTest(pathValidator); - new BuypassClass3().runTest(pathValidator); - } -} - -class BuypassClass2 { - - // Owner: CN=Buypass Class 2 CA 2, O=Buypass AS-983163327, C=NO - // Issuer: CN=Buypass Class 2 Root CA, O=Buypass AS-983163327, C=NO - // Serial number: 1b781c6d5e34ce1f77 - // Valid from: Mon Mar 25 05:17:10 PDT 2019 until: Sat Oct 26 02:16:17 PDT 2030 - private static final String INT_CLASS_2 = "-----BEGIN CERTIFICATE-----\n" + - "MIIFKTCCAxGgAwIBAgIJG3gcbV40zh93MA0GCSqGSIb3DQEBCwUAME4xCzAJBgNV\n" + - "BAYTAk5PMR0wGwYDVQQKDBRCdXlwYXNzIEFTLTk4MzE2MzMyNzEgMB4GA1UEAwwX\n" + - "QnV5cGFzcyBDbGFzcyAyIFJvb3QgQ0EwHhcNMTkwMzI1MTIxNzEwWhcNMzAxMDI2\n" + - "MDkxNjE3WjBLMQswCQYDVQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMx\n" + - "NjMzMjcxHTAbBgNVBAMMFEJ1eXBhc3MgQ2xhc3MgMiBDQSAyMIIBIjANBgkqhkiG\n" + - "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnKtnxpZLDQ+R0uzKzDMr83L8Dn+5ToSpD31z\n" + - "qiYMykj7I2geNQ7javKsBOzhgeVr7GP4yJ5bK/P0dhoKesYvQITihfwztbMP6DyH\n" + - "q1QJLQBqQnF0Lk8GhxSSNAZnlkCgX3aazoL32p9BeEfHuUE/8BlPywJY/RyE5/39\n" + - "w3EKmWylhUkeRCMo3dUZr4khJq8JwGp/feKFs9n5FouM5PGhpFpZO+WQXEeqxpnc\n" + - "CxbvWpInBoTnmX3+ofjm+fmY+sdAnyHkuOBBw3koGbFQygDaJP9VItOGByCX4iSV\n" + - "ty/2uzppowIkf7Mpu5v5HJGKObLMP1gGv5lNqjAe8mz0bn25kwIDAQABo4IBCzCC\n" + - "AQcwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBTJgHfg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J9U\n" + - "15T5+EGHs8ccHQWyYQ6gqYk8o4JgP4rSJqO1sMI=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=valid.domain.ca22.ssl.buypass.no - // Issuer: CN=Buypass Class 2 CA 2, O=Buypass AS-983163327, C=NO - // Serial number: 34e2bff8063debd18d79 - // Valid from: Mon Sep 23 04:12:34 PDT 2019 until: Mon Oct 11 14:59:00 PDT 2021 - private static final String VALID_CLASS_2 = "-----BEGIN CERTIFICATE-----\n" + - "MIIF8jCCBNqgAwIBAgIKNOK/+AY969GNeTANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + - "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + - "FEJ1eXBhc3MgQ2xhc3MgMiBDQSAyMB4XDTE5MDkyMzExMTIzNFoXDTIxMTAxMTIx\n" + - "NTkwMFowKzEpMCcGA1UEAwwgdmFsaWQuZG9tYWluLmNhMjIuc3NsLmJ1eXBhc3Mu\n" + - "bm8wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCeu/8j7y55R3OucDek\n" + - "gtdoVOEJQb2XaCR4OwiRzn74hLYhKGdFmFwSp+bPCT62NzjdK1urVeKrCQdC1Gkm\n" + - "e7iSOsHHO5aC8oxkgdv8mwEwwvH7xHCcpEVLDlE5Oc0d4cS4QIwFAhNIC77slixL\n" + - "fEdupc5e8FfQf3MlnhX+8gpgRzTx3iw8sb3gUwi3+7PRommHOhC7Ll+iI9LiLODJ\n" + - "qrkHnCbM2HJMK+SGTOQ/whiQwMCnkLaEG0WO1rYc4BGRGfFb8qmQWw/tDKkEey7X\n" + - "nLIFHSC33OiexQshAwRIAE7r1h9gMY1aAAB2Uxwi9/3l6fsd/VPmK7s7lYTBsrpK\n" + - "r4bTAgMBAAGjggL2MIIC8jAJBgNVHRMEAjAAMB8GA1UdIwQYMBaAFJKtZYmyAA/L\n" + - "UQ3BI+yUTo/BBD93MB0G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QADggEBAJH1RhTuMbhEOYlw+Efbx7PP7EEC/GQ1ijET\n" + - "vZS45jFQyTKhFUcdP2QPAtEVo1nS8PBs0txQJBf0xceWUjer9ruxiAS+JlW21AOi\n" + - "Uq9Kahpj5k63Z7tN8KTeOUE8wZGmHyvVcPP6mkC94RbjYIb4gd13eYxd2Vv1a7YX\n" + - "dNI+J3g7sX5ijssfJxzDd0hORj2584YY2WiKKvIGxwDnLkxk09i3IvjEKsAi4Cgn\n" + - "5798X5sSL1Q9C6gHEWt+cB5UtfILCfbLNRczS9zGku6gjh1c8dB7zc63mn7oCf1C\n" + - "gnQ2xqwbZb3Wau8CPwcMqJWgQZLQFPbZd+4Xo5SDDqYppV4oN2A=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.domain.ca22.ssl.buypass.no - // Issuer: CN=Buypass Class 2 CA 2, O=Buypass AS-983163327, C=NO - // Serial number: 34e4b97261795f98c495 - // Valid from: Mon Sep 23 04:52:42 PDT 2019 until: Thu Sep 23 14:59:00 PDT 2021 - private static final String REVOKED_CLASS_2 = "-----BEGIN CERTIFICATE-----\n" + - "MIIF9zCCBN+gAwIBAgIKNOS5cmF5X5jElTANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + - "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + - "FEJ1eXBhc3MgQ2xhc3MgMiBDQSAyMB4XDTE5MDkyMzExNTI0MloXDTIxMDkyMzIx\n" + - "NTkwMFowLTErMCkGA1UEAwwicmV2b2tlZC5kb21haW4uY2EyMi5zc2wuYnV5cGFz\n" + - "cy5ubzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOiChajGbQktGjbl\n" + - "k/i5PtqfMN6cMyjJdOirxzXdUG8dT+QErC5zcElCwuyy5MH7DQJRbSYsPxQmr6z5\n" + - "OSheBxX0lPPLjJFfEafBZ+Fw1xmCVy3Xjt3GEl85iqv5y0/E/UlQ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" + - "eQAABAMARzBFAiBCXKlCGkqa85QVqMR5dYDDz3F5aQgLXPubrQLX7cAZ0wIhALRr\n" + - "p8F6OfIdccSUhzEcNdtensQ/7zxgn81bUzn1ar9EAHcAb1N2rDHwMRnYmQCkURX/\n" + - "dxUcEdkCwQApBo2yCJo32RMAAAFtXfeBSQAABAMASDBGAiEAyrR31T85HGekHZdD\n" + - "r/m6flxqQaUIGcAJ5WcrBuIBuYkCIQD0rDdm+vM5/lNXIfjjrPLhATFEvrxpXJvu\n" + - "+sW4Ntm94jANBgkqhkiG9w0BAQsFAAOCAQEAjbMEFeNXFy3YQSr8O0+fY7qwaAzk\n" + - "vq65Ef/B2zvqO375+JI21grUikmFUnDiAaM8Y+8PJkOXDiuxR2/XCLsXpxCcPqQh\n" + - "V0MZlqXtjKZjBACILBX7aqGibojJTIlo0Dkd+LfPwswfXscTbb1CUXpUPn7CiUj5\n" + - "0WwfvjjQXny0NAB6WEkBMEBx6/Q75dvltoV9N1BZVer9hov6UTDuSad86faX2QF2\n" + - "aIEjrTJY3m2HqnIYf/lQxuDUDW0h7ddGGsIEBDM8z7M/rvT068ssRqJ8uecGjMaz\n" + - "JElX8VDgMux2kyjTAiAFD5QO+KTfySri9QXptik3wo66zDOmkVES1snvVQ==\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID_CLASS_2, INT_CLASS_2}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED_CLASS_2, INT_CLASS_2}, - ValidatePathWithParams.Status.REVOKED, - "Mon Sep 23 04:53:18 PDT 2019", System.out); - } -} - -class BuypassClass3 { - - // Owner: CN=Buypass Class 3 CA 2, O=Buypass AS-983163327, C=NO - // Issuer: CN=Buypass Class 3 Root CA, O=Buypass AS-983163327, C=NO - // Serial number: 1be0dc6a3e7f220475 - // Valid from: Mon Mar 25 05:12:16 PDT 2019 until: Sat Oct 26 01:16:17 PDT 2030 - private static final String INT_CLASS_3 = "-----BEGIN CERTIFICATE-----\n" + - "MIIFKTCCAxGgAwIBAgIJG+Dcaj5/IgR1MA0GCSqGSIb3DQEBCwUAME4xCzAJBgNV\n" + - "BAYTAk5PMR0wGwYDVQQKDBRCdXlwYXNzIEFTLTk4MzE2MzMyNzEgMB4GA1UEAwwX\n" + - "QnV5cGFzcyBDbGFzcyAzIFJvb3QgQ0EwHhcNMTkwMzI1MTIxMjE2WhcNMzAxMDI2\n" + - "MDgxNjE3WjBLMQswCQYDVQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMx\n" + - "NjMzMjcxHTAbBgNVBAMMFEJ1eXBhc3MgQ2xhc3MgMyBDQSAyMIIBIjANBgkqhkiG\n" + - "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvU4V2hRFFe4K7BMEmm4IoMTwS7NyDQB4JEar\n" + - "dV1qBsKHIIQJDm9hbCakcLIWXVv6vYrJZ1AEF0b6awBwhhlqXlyNnOtNa9uR+IAP\n" + - "86d4yOGpgHSlNAhdtOOk9Qw6MUzzBo1lyoYmoL0f5n02SMrlMcArSg458o08eDUx\n" + - "4iZs4dXDR9Hjxac2s+mdAO35Js8VK/D50AIMDJvHVeCMw+rumZkNZuRqM7PjIK+u\n" + - "BmbqO8A95PeqQEWHvM5nchlV1+ZGNVqHHSJenlMnVKytGv+4KJp7U741H/9cMbd2\n" + - "X2PXsewWWFhGXoS8R9VXQ5xb3hF6324FQXvcA1mXRv6DAJedXQIDAQABo4IBCzCC\n" + - "AQcwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBRHuM3/5W/u+LLsL04O+SWw\n" + - "jjxrwzAdBgNVHQ4EFgQUIjAu0vv2S8rAuDvSBMTpcuaXmwwwDgYDVR0PAQH/BAQD\n" + - "AgEGMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjARBgNVHSAECjAIMAYG\n" + - "BFUdIAAwPQYDVR0fBDYwNDAyoDCgLoYsaHR0cDovL2NybC5idXlwYXNzLm5vL2Ny\n" + - "bC9CUENsYXNzM1Jvb3RDQS5jcmwwMwYIKwYBBQUHAQEEJzAlMCMGCCsGAQUFBzAB\n" + - "hhdodHRwOi8vb2NzcC5idXlwYXNzLmNvbTANBgkqhkiG9w0BAQsFAAOCAgEAo42Y\n" + - "fp96nUiZbZsqvYBID3Sqtx3jJfU8gNHFeXgkS0pxYHHYUwsVSVRjw+BGVEGUswpF\n" + - "MaYMCZD37ZL0JpvvXWrCDaMb/GqDJAQHLLTyVKPGGGIWCZH/FrhnNvcpt2XXA8lU\n" + - "Ujzp5nZPuqvenzQ/aXHI4sH5sN/QjyKVMSa/6RbWBeQmvIdgyM+0jIR5/r6UGiKM\n" + - "ar55trZgnlIbvQJ/w8QTmI/NwvA5CtRaOslQBxeKoAR0BuA/lRWnocXa/BM5uO6P\n" + - "ULL7ct/uI1bS+YThHXHmFybI6kDf+RhRzWY9165ZP96PBph6smQkxPDAz2b8v+mh\n" + - "LThH+5hkqnoetYfK2MdBYinceGPP3gZ+uBSDDI2o6vdVvdg7G96GP1OEtgTEqZa3\n" + - "glVafckpn/8F5CisypdQuZ5zyy/6SXZCKkPcikR87ysSKnjtteXbxMWVtwkeBALT\n" + - "K7DbJA+5aOCYRNj6CJGULQKiGlC01/ipORKewf5J3yus81lLHzBmgQMA5l9RL8rV\n" + - "6dI246mPpQ+8WDLsDrK3ydSDv5izgdVHzhL0tT2u4vwSq2WUqCgi4xLIA1N/fA2H\n" + - "xEW7zh0X/3YVz++g/6bd7iqRD9nRRZxACekRbza7AqU5xN1UjvVtCJQ9VC74K9KP\n" + - "pBoLWE2Bz5ksL9VUc4kS+WGORvZrSE1EpBq6cHc=\n" + - "-----END CERTIFICATE-----"; - - // Owner: SERIALNUMBER=983163327, CN=valid.businessplus.ca23.ssl.buypass.no, O=BUYPASS AS, - // L=OSLO, OID.2.5.4.17=0484, C=NO - // Issuer: CN=Buypass Class 3 CA 2, O=Buypass AS-983163327, C=NO - // Serial number: 267b7a9f0c3da9b94b39 - // Valid from: Mon Sep 23 04:17:42 PDT 2019 until: Mon Oct 11 14:59:00 PDT 2021 - private static final String VALID_CLASS_3 = "-----BEGIN CERTIFICATE-----\n" + - "MIIGUTCCBTmgAwIBAgIKJnt6nww9qblLOTANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + - "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + - "FEJ1eXBhc3MgQ2xhc3MgMyBDQSAyMB4XDTE5MDkyMzExMTc0MloXDTIxMTAxMTIx\n" + - "NTkwMFowgYUxCzAJBgNVBAYTAk5PMQ0wCwYDVQQRDAQwNDg0MQ0wCwYDVQQHDARP\n" + - "U0xPMRMwEQYDVQQKDApCVVlQQVNTIEFTMS8wLQYDVQQDDCZ2YWxpZC5idXNpbmVz\n" + - "c3BsdXMuY2EyMy5zc2wuYnV5cGFzcy5ubzESMBAGA1UEBRMJOTgzMTYzMzI3MIIB\n" + - "IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArqj6dPVIQUULBV/S+u2/Rfko\n" + - "3BljX/KMEAclJHPu6AbJ2Dw5oLqCynOfTwLmGl3IRBQuDUAuoLdaptIhaXR2VTsF\n" + - "8SWdHNXkykC2eD0XkAUdTuKgRm/3U4f0T3XQsjwKOEQGECwGEWJekBL73retSRWe\n" + - "Ccc19NpSKZ5rmRnQSlKLfqUyihmw2xXmIWwEmBq0OOyG8ic3C11Zxh6yUOtlZJqB\n" + - "lWqbAAOK5SXTNV0qozwgkSvtAtJvUo2++rng35Oj8MvjKQjLi92NnSpjbj3rUivW\n" + - "++44X94IgoF9dITkSMnubXhaTLnciM08R8jmCFj877NRrVJRmcJhPfP1yHnR3wID\n" + - "AQABo4IC+jCCAvYwCQYDVR0TBAIwADAfBgNVHSMEGDAWgBQiMC7S+/ZLysC4O9IE\n" + - "xOly5pebD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BAQsFAAOCAQEAsmQAOn1f1CbvnOpggS2efmy1pQXvvw+YeCYP\n" + - "bElO578h7scn8al4N7huQZ/z14BELe0chGWNA/ReW5nAu3SUOiv+E8/kv9i9Y8ul\n" + - "MJPL62nXW6Z/mkyystuBNtON420iWL/gS/vduxSZE/iBB4znctDpXS917/XWf31Y\n" + - "ZonemF3MSfi/s9V0Ic82ZY/+HZ4NLTDyKRd4kFF58OoH9RZNb6g8MbTp+gPadiUG\n" + - "UcfPGV3yGiugQa7WHTl7QJ9ishyafiZ4hpeKem6TMDEztgGyLIZ4MSxQvoeI2jJP\n" + - "KjHd5fW/HClbEcrN+w0a0MUNMaAOaZfMS7jS6sDpaVL8D0EX5A==\n" + - "-----END CERTIFICATE-----"; - - // Owner: SERIALNUMBER=983163327, CN=revoked.businessplus.ca23.ssl.buypass.no, O=BUYPASS AS, - // L=OSLO, OID.2.5.4.17=0484, C=NO - // Issuer: CN=Buypass Class 3 CA 2, O=Buypass AS-983163327, C=NO - // Serial number: 267cee3fab06c615fb27 - // Valid from: Mon Sep 23 04:56:56 PDT 2019 until: Thu Sep 23 14:59:00 PDT 2021 - private static final String REVOKED_CLASS_3 = "-----BEGIN CERTIFICATE-----\n" + - "MIIGWDCCBUCgAwIBAgIKJnzuP6sGxhX7JzANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + - "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + - "FEJ1eXBhc3MgQ2xhc3MgMyBDQSAyMB4XDTE5MDkyMzExNTY1NloXDTIxMDkyMzIx\n" + - "NTkwMFowgYcxCzAJBgNVBAYTAk5PMQ0wCwYDVQQRDAQwNDg0MQ0wCwYDVQQHDARP\n" + - "U0xPMRMwEQYDVQQKDApCVVlQQVNTIEFTMTEwLwYDVQQDDChyZXZva2VkLmJ1c2lu\n" + - "ZXNzcGx1cy5jYTIzLnNzbC5idXlwYXNzLm5vMRIwEAYDVQQFEwk5OD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0c4V5UKq1LoGpCWZDaOHtGFAAABbV37Y7oAAAQDAEcwRQIgYbaNSR3R5x9p9sYJ\n" + - "UzRDdd/lbELb05u9GqlLtl4M61YCIQCTBecXTbMs4zuG/wu722HZy/XgD6fiQySp\n" + - "FhHDO3CYagB2AKS5CZC0GFgUh7sTosxncAo8NZgE+RvfuON3zQ7IDdwQAAABbV37\n" + - "Y7wAAAQDAEcwRQIgD8j40M03oLMCg5WmFBN7VL6169F7rKatE12btLQRYtYCIQC0\n" + - "rDhQiZP7j14Y4JqEFQx6UHl3dvxLxZTDW34Z54IUWQB3AG9Tdqwx8DEZ2JkApFEV\n" + - "/3cVHBHZAsEAKQaNsgiaN9kTAAABbV37YOUAAAQDAEgwRgIhANTGHD1g2pbsTtoN\n" + - "CJ2m6nfxm9jB3huftKGDjeo7EyxHAiEA3EYNUc6hr+4Q9lMAphUgpW6oyaNCsIzl\n" + - "izbNhq8dBRYwDQYJKoZIhvcNAQELBQADggEBADUuO4MmYjPkmkik5tjUPiiDDXEQ\n" + - "A41jr72qmdleYdkhnaKAJa8Enn6j/ySRV0enA7yqJeNp1qgPQFvlOh3TqFB3Ae5b\n" + - "XAfL2B7vKbegpjKm8dVH5RurqVm9xZcXb1nbwfu2k3lqqsp/uwqvLBItJDvA8pfi\n" + - "2R46sEtj2gFpAlKFDwepuaklqhrvEoIjIaAL0RrGfKY0oRQw1YMbPNIebsVaWr04\n" + - "rt6tlxrq7PyW1w9Mt3445WA1NzSWc7pAjFLfY6u87QaPHI4ES31H9xxRDsxmr6Y3\n" + - "BJmiWd5uUxev0nVw0saqvlo4yAEBq4rI/DieKcQI4qEI8myzoS0R0azMfLM=\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID_CLASS_3, INT_CLASS_3}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED_CLASS_3, INT_CLASS_3}, - ValidatePathWithParams.Status.REVOKED, - "Mon Sep 23 04:57:31 PDT 2019", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java new file mode 100644 index 0000000000000..2cf9ae88397ab --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java @@ -0,0 +1,561 @@ +/* + * 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 id=actalisauthenticationrootca + * @bug 8189131 + * @summary Interoperability tests with Actalis CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp + * CAInterop actalisauthenticationrootca OCSP + * @run main/othervm/timeout=180 -Djava.security.debug=certpath,ocsp + * CAInterop actalisauthenticationrootca CRL + */ + +/* + * @test id=amazonrootca1 + * @bug 8233223 + * @summary Interoperability tests with Amazon's CA1 + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop amazonrootca1 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop amazonrootca1 CRL + */ + +/* + * @test id=amazonrootca2 + * @bug 8233223 + * @summary Interoperability tests with Amazon's CA2 + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop amazonrootca2 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop amazonrootca2 CRL + */ + +/* + * @test id=amazonrootca3 + * @bug 8233223 + * @summary Interoperability tests with Amazon's CA3 + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop amazonrootca3 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop amazonrootca3 CRL + */ + +/* + * @test id=amazonrootca4 + * @bug 8233223 + * @summary Interoperability tests with Amazon's CA4 + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop amazonrootca4 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop amazonrootca4 CRL + */ + +/* + * @test id=buypassclass2ca + * @bug 8189131 + * @summary Interoperability tests with Buypass Class 2 CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop buypassclass2ca OCSP + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop buypassclass2ca CRL + */ + +/* + * @test id=buypassclass3ca + * @bug 8189131 + * @summary Interoperability tests with Buypass Class 3 CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop buypassclass3ca OCSP + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop buypassclass3ca CRL + */ + +/* + * @test id=comodorsaca + * @bug 8189131 + * @summary Interoperability tests with Comodo RSA CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop comodorsaca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop comodorsaca CRL + */ + +/* + * @test id=comodoeccca + * @bug 8189131 + * @summary Interoperability tests with Comodo ECC CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop comodoeccca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop comodoeccca CRL + */ + +/* + * @test id=usertrustrsaca + * @bug 8189131 + * @summary Interoperability tests with Comodo userTrust RSA CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop usertrustrsaca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop usertrustrsaca CRL + */ + +/* + * @test id=usertrusteccca + * @bug 8189131 + * @summary Interoperability tests with Comodo userTrust ECC CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop usertrusteccca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop usertrusteccca CRL + */ + +/* + * @test id=letsencryptisrgx1 + * @bug 8189131 + * @summary Interoperability tests with Let's Encrypt CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop letsencryptisrgx1 DEFAULT + */ + +/* + * @test id=globalsignrootcar6 + * @bug 8216577 + * @summary Interoperability tests with GlobalSign R6 CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop globalsignrootcar6 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop globalsignrootcar6 CRL + */ + +/* + * @test id=entrustrootcaec1 + * @bug 8195774 + * @summary Interoperability tests with Entrust CAs + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop entrustrootcaec1 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop entrustrootcaec1 CRL + */ + +/* + * @test id=entrustrootcag4 + * @bug 8243321 + * @summary Interoperability tests with Entrust CAs + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop entrustrootcag4 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop entrustrootcag4 CRL + */ + +/* + * @test id=godaddyrootg2ca + * @bug 8196141 + * @summary Interoperability tests with GoDaddy CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop godaddyrootg2ca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop godaddyrootg2ca CRL + */ + +/* + * @test id=starfieldrootg2ca + * @bug 8196141 + * @summary Interoperability tests with Starfield CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop starfieldrootg2ca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop starfieldrootg2ca CRL + */ + +/* + * @test id=globalsigneccrootcar4 + * @bug 8307134 + * @summary Interoperability tests with Google's GlobalSign R4 and GTS Root certificates + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop globalsigneccrootcar4 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop globalsigneccrootcar4 CRL + */ + +/* + * @test id=gtsrootcar1 + * @bug 8307134 + * @summary Interoperability tests with Google's GlobalSign R4 and GTS Root certificates + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop gtsrootcar1 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop gtsrootcar1 CRL + */ + +/* + * @test id=gtsrootcar2 + * @bug 8307134 + * @summary Interoperability tests with Google's GlobalSign R4 and GTS Root certificates + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop gtsrootcar2 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop gtsrootcar2 CRL + */ + +/* + * @test id=gtsrootecccar3 + * @bug 8307134 + * @summary Interoperability tests with Google's GlobalSign R4 and GTS Root certificates + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop gtsrootecccar3 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop gtsrootecccar3 CRL + */ + +/* + * @test id=gtsrootecccar4 + * @bug 8307134 + * @summary Interoperability tests with Google's GlobalSign R4 and GTS Root certificates + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop gtsrootecccar4 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop gtsrootecccar4 CRL + */ + +/* + * @test id=microsoftecc2017 + * @bug 8304760 + * @summary Interoperability tests with Microsoft TLS root CAs + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop microsoftecc2017 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop microsoftecc2017 CRL + */ + +/* + * @test id=microsoftrsa2017 + * @bug 8304760 + * @summary Interoperability tests with Microsoft TLS root CAs + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop microsoftrsa2017 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop microsoftrsa2017 CRL + */ + +/* + * @test id=quovadisrootca1g3 + * @bug 8189131 + * @summary Interoperability tests with QuoVadis Root CA1 G3 CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop quovadisrootca1g3 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop quovadisrootca1g3 CRL + */ + +/* + * @test id=quovadisrootca2g3 + * @bug 8189131 + * @summary Interoperability tests with QuoVadis Root CA2 G3 CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop quovadisrootca2g3 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop quovadisrootca2g3 CRL + */ + +/* + * @test id=quovadisrootca3g3 + * @bug 8189131 + * @summary Interoperability tests with QuoVadis Root CA3 G3 CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop quovadisrootca3g3 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop quovadisrootca3g3 CRL + */ + +/* + * @test id=sslrootrsaca + * @bug 8243320 + * @summary Interoperability tests with SSL.com's RSA CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop sslrootrsaca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop sslrootrsaca CRL + */ + +/* + * @test id=sslrootevrsaca + * @bug 8243320 + * @summary Interoperability tests with SSL.com's EV RSA CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop sslrootevrsaca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop sslrootevrsaca CRL + */ + +/* + * @test id=sslrooteccca + * @bug 8243320 + * @summary Interoperability tests with SSL.com's ECC CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop sslrooteccca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop sslrooteccca CRL + */ + +/* + * @test id=teliasonerarootcav1 + * @bug 8210432 + * @summary Interoperability tests with TeliaSonera Root CA v1 + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop teliasonerarootcav1 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop teliasonerarootcav1 CRL + */ + +/* + * @test id=twcaglobalrootca + * @bug 8305975 + * @summary Interoperability tests with TWCA Global Root CA from TAIWAN-CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop twcaglobalrootca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop twcaglobalrootca CRL + */ + +/* + * @test id=certignarootca + * @bug 8314960 + * @summary Interoperability tests with Certigna Root CAs from Dhimyotis + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop certignarootca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop certignarootca CRL + */ + +/** + * Collection of certificate validation tests for interoperability with external CAs + */ +public class CAInterop { + + /** + * Returns the test configuration for CA + * + * @param alias from the cacerts file without [jdk] + * @return CATestURLs + */ + private CATestURLs getTestURLs(String alias) { + return switch (alias) { + case "actalisauthenticationrootca" -> + new CATestURLs("https://ssltest-active.actalis.it", + "https://ssltest-revoked.actalis.it"); + + case "amazonrootca1" -> + new CATestURLs("https://valid.rootca1.demo.amazontrust.com", + "https://revoked.rootca1.demo.amazontrust.com"); + case "amazonrootca2" -> + new CATestURLs("https://valid.rootca2.demo.amazontrust.com", + "https://revoked.rootca2.demo.amazontrust.com"); + case "amazonrootca3" -> + new CATestURLs("https://valid.rootca3.demo.amazontrust.com", + "https://revoked.rootca3.demo.amazontrust.com"); + case "amazonrootca4" -> + new CATestURLs("https://valid.rootca4.demo.amazontrust.com", + "https://revoked.rootca4.demo.amazontrust.com"); + + case "buypassclass2ca" -> + new CATestURLs("https://valid.business.ca22.ssl.buypass.no", + "https://revoked.business.ca22.ssl.buypass.no"); + case "buypassclass3ca" -> + new CATestURLs("https://valid.qcevident.ca23.ssl.buypass.no", + "https://revoked.qcevident.ca23.ssl.buypass.no"); + + case "comodorsaca" -> + new CATestURLs("https://comodorsacertificationauthority-ev.comodoca.com", + "https://comodorsacertificationauthority-ev.comodoca.com:444"); + case "comodoeccca" -> + new CATestURLs("https://comodoecccertificationauthority-ev.comodoca.com", + "https://comodoecccertificationauthority-ev.comodoca.com:444"); + case "usertrustrsaca" -> + new CATestURLs("https://usertrustrsacertificationauthority-ev.comodoca.com", + "https://usertrustrsacertificationauthority-ev.comodoca.com:444"); + case "usertrusteccca" -> + new CATestURLs("https://usertrustecccertificationauthority-ev.comodoca.com", + "https://usertrustecccertificationauthority-ev.comodoca.com:444"); + + case "letsencryptisrgx1" -> + new CATestURLs("https://valid-isrgrootx1.letsencrypt.org", + "https://revoked-isrgrootx1.letsencrypt.org"); + + case "globalsignrootcar6" -> + new CATestURLs("https://valid.r6.roots.globalsign.com", + "https://revoked.r6.roots.globalsign.com"); + + case "entrustrootcaec1" -> + new CATestURLs("https://validec.entrust.net", + "https://revokedec.entrust.net"); + case "entrustrootcag4" -> + new CATestURLs("https://validg4.entrust.net", + "https://revokedg4.entrust.net"); + + case "godaddyrootg2ca" -> + new CATestURLs("https://valid.gdig2.catest.godaddy.com", + "https://revoked.gdig2.catest.godaddy.com"); + case "starfieldrootg2ca" -> + new CATestURLs("https://valid.sfig2.catest.starfieldtech.com", + "https://revoked.sfig2.catest.starfieldtech.com"); + + case "globalsigneccrootcar4" -> + new CATestURLs("https://good.gsr4.demo.pki.goog", + "https://revoked.gsr4.demo.pki.goog"); + case "gtsrootcar1" -> + new CATestURLs("https://good.gtsr1.demo.pki.goog", + "https://revoked.gtsr1.demo.pki.goog"); + case "gtsrootcar2" -> + new CATestURLs("https://good.gtsr2.demo.pki.goog", + "https://revoked.gtsr2.demo.pki.goog"); + case "gtsrootecccar3" -> + new CATestURLs("https://good.gtsr3.demo.pki.goog", + "https://revoked.gtsr3.demo.pki.goog"); + case "gtsrootecccar4" -> + new CATestURLs("https://good.gtsr4.demo.pki.goog", + "https://revoked.gtsr4.demo.pki.goog"); + + case "microsoftecc2017" -> + new CATestURLs("https://acteccroot2017.pki.microsoft.com", + "https://rvkeccroot2017.pki.microsoft.com"); + case "microsoftrsa2017" -> + new CATestURLs("https://actrsaroot2017.pki.microsoft.com", + "https://rvkrsaroot2017.pki.microsoft.com"); + + case "quovadisrootca1g3" -> + new CATestURLs("https://quovadis-root-ca-1-g3.chain-demos.digicert.com", + "https://quovadis-root-ca-1-g3-revoked.chain-demos.digicert.com"); + case "quovadisrootca2g3" -> + new CATestURLs("https://quovadis-root-ca-2-g3.chain-demos.digicert.com", + "https://quovadis-root-ca-2-g3-revoked.chain-demos.digicert.com"); + case "quovadisrootca3g3" -> + new CATestURLs("https://quovadis-root-ca-3-g3.chain-demos.digicert.com", + "https://quovadis-root-ca-3-g3-revoked.chain-demos.digicert.com"); + + case "sslrootrsaca" -> + new CATestURLs("https://test-dv-rsa.ssl.com", + "https://revoked-rsa-dv.ssl.com"); + case "sslrootevrsaca" -> + new CATestURLs("https://test-ev-rsa.ssl.com", + "https://revoked-rsa-ev.ssl.com"); + case "sslrooteccca" -> + new CATestURLs("https://test-dv-ecc.ssl.com", + "https://revoked-ecc-dv.ssl.com"); + + case "teliasonerarootcav1" -> + new CATestURLs("https://juolukka.cover.sonera.net:10443", + "https://juolukka.cover.sonera.net:10444"); + + case "twcaglobalrootca" -> + new CATestURLs("https://evssldemo6.twca.com.tw", + "https://evssldemo7.twca.com.tw"); + + case "certignarootca" -> + new CATestURLs("https://valid.servicesca.dhimyotis.com", + "https://revoked.servicesca.dhimyotis.com"); + + default -> throw new RuntimeException("No test setup found for: " + alias); + }; + } + + public static void main(String[] args) throws Exception { + if (args.length < 2) { + throw new RuntimeException("Run as: CAInterop "); + } + + String caAlias = args[0]; + + CAInterop caInterop = new CAInterop(args[1]); + CATestURLs caTestURLs = caInterop.getTestURLs(caAlias); + + caInterop.validate(caAlias + " [jdk]", + caTestURLs.getVALID_URL(), + caTestURLs.getREVOKED_URL()); + } + + static class CATestURLs { + final String VALID_URL; + final String REVOKED_URL; + + public CATestURLs(String validURL, + String revokedURL) { + VALID_URL = validURL; + REVOKED_URL = revokedURL; + } + + public String getVALID_URL() { + return VALID_URL; + } + + public String getREVOKED_URL() { + return REVOKED_URL; + } + } + + /** + * Constructor for interoperability test with third party CA. + * + * @param revocationMode revocation checking mode to use + */ + public CAInterop(String revocationMode) { + if ("CRL".equalsIgnoreCase(revocationMode)) { + ValidatePathWithURL.enableCRLOnly(); + } else if ("OCSP".equalsIgnoreCase(revocationMode)) { + ValidatePathWithURL.enableOCSPOnly(); + } else { + // OCSP and CRL check by default + ValidatePathWithURL.enableOCSPAndCRL(); + } + + ValidatePathWithURL.logRevocationSettings(); + } + + /** + * Validates provided URLs using HttpsURLConnection making sure they + * anchor to the root CA found in cacerts using provided alias. + * + * @param caAlias CA alis from cacerts file + * @param validCertURL valid test URL + * @param revokedCertURL revoked test URL + * @throws Exception thrown when certificate can't be validated as valid or revoked + */ + public void validate(String caAlias, + String validCertURL, + String revokedCertURL) throws Exception { + + ValidatePathWithURL validatePathWithURL = new ValidatePathWithURL(caAlias); + + if (validCertURL != null) { + validatePathWithURL.validateDomain(validCertURL, false); + } + + if (revokedCertURL != null) { + validatePathWithURL.validateDomain(revokedCertURL, true); + } + } +} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaRoots.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaCA.java similarity index 74% rename from test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaRoots.java rename to test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaCA.java index 92744eac3d066..f1dd2d6229a47 100644 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaRoots.java +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CertignaCA.java @@ -23,70 +23,13 @@ /* * @test - * @bug 8245654 8314960 + * @bug 8245654 8256895 * @summary Interoperability tests with Certigna Root CAs from Dhimyotis * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath CertignaRoots OCSP - * @run main/othervm -Djava.security.debug=certpath CertignaRoots CRL + * @run main/othervm -Djava.security.debug=certpath CertignaCA OCSP + * @run main/othervm -Djava.security.debug=certpath CertignaCA CRL */ - -/* - * Obtain TLS test artifacts for Certigna Root CAs from: - * - * Valid TLS Certificates: - * https://valid.servicesca.dhimyotis.com/ - * - * Revoked TLS Certificates: - * https://revoked.servicesca.dhimyotis.com/ - */ -public class CertignaRoots { - - // Owner: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036, - // OU=0002 48146308100036, O=DHIMYOTIS, C=FR - // Issuer: CN=Certigna Root CA, OU=0002 48146308100036, O=Dhimyotis, C=FR - // Serial number: fd30cf04344fc38dd90c4e70753d0623 - // Valid from: Wed Nov 25 03:37:21 PST 2015 until: Fri Jun 03 04:37:21 PDT 2033 - private static final String INT_CERTIGNA_ROOT_CA = "-----BEGIN CERTIFICATE-----\n" + - "MIIHETCCBPmgAwIBAgIRAP0wzwQ0T8ON2QxOcHU9BiMwDQYJKoZIhvcNAQELBQAw\n" + - "WjELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAw\n" + - "MiA0ODE0NjMwODEwMDAzNjEZMBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0x\n" + - "NTExMjUxMTM3MjFaFw0zMzA2MDMxMTM3MjFaMH0xCzAJBgNVBAYTAkZSMRIwEAYD\n" + - "VQQKDAlESElNWU9USVMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgxMDAwMzYxHTAb\n" + - "BgNVBGEMFE5UUkZSLTQ4MTQ2MzA4MTAwMDM2MR0wGwYDVQQDDBRDZXJ0aWduYSBT\n" + - "ZXJ2aWNlcyBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALPM+7Lp\n" + - "WBz9wFcPaTc3xnB+5g0XrnptB0EPPfrR04vO52Ykm4ky1d4ZLd10tbM1fa1RqNSO\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lcjA8BggrBgEFBQcwAoYwaHR0cDovL2F1dG9yaXRlLmRoaW15b3Rpcy5jb20v\n" + - "Y2VydGlnbmFyb290Y2EuZGVyMG0GA1UdHwRmMGQwL6AtoCuGKWh0dHA6Ly9jcmwu\n" + - "Y2VydGlnbmEuZnIvY2VydGlnbmFyb290Y2EuY3JsMDGgL6AthitodHRwOi8vY3Js\n" + - "LmRoaW15b3Rpcy5jb20vY2VydGlnbmFyb290Y2EuY3JsMA0GCSqGSIb3DQEBCwUA\n" + - "A4ICAQCI5QbprXJ93L+JWHYpUTinXAMSvXMx2dmNm4mIiJRAbGnBOoEYx7M61fbL\n" + - "L5EJIYZhw8jLmeYVFuMao5OJLwda+RMmVzE7lyTGsY64IDKdwogByNCqbKzrlhnU\n" + - "8myyMNB0BDs2jgwQe2Dj9v+MddeHr7sDqvs7R1tSS5hoASLtdQhO7oxUzr3m7M8q\n" + - "+lh4jszli+cjfiPUVS2ADFu4ccQIh4OsIX6SWdU+8R+c/fn0FV6ip4SAVbNyCToz\n" + - "0ZbZKO8YTJgORxRmvrop9dPyuLWjaRrZ0LMx4a3EM3sQDPDqmsG0lHtfFj2PiJvq\n" + - "4lEYA+gDiLKODI+3DJMqo559m3QSS52DsShomHX/Txd0lJoZwepCE6X4KkG9FHjV\n" + - "WXyLgYFwCOcn+hkLhdpblms0wtjeSPITGOioSkefzhleJnDgJ9X4M3svd0HLTpJi\n" + - "lC1DmDZgdrXWITVdOoCogr2LFKNiGd0tbpKG533eKpfBALlm+afc6j73p1KhJEAn\n" + - "AfydDZqBRqv6+HHYplNDn/K2I1CZdkwaGrx3HOR/voGUi1sUI+hYbsPAFu8ZxrhD\n" + - "9UiysmLCfEUhqkbojony+L2mKsoLqyd24emQzn7GgMa7emlWX2jQUTwrD4SliZ2u\n" + - "OetVaZX5RLyqJWs4Igo/xye0xtMQN8INJ4hSZvnMQ1qFtuSRcQ==\n" + - "-----END CERTIFICATE-----"; - +public class CertignaCA { // Owner: CN=Certigna Services CA, OID.2.5.4.97=NTRFR-48146308100036, // OU=0002 48146308100036, O=DHIMYOTIS, C=FR // Issuer: CN=Certigna, O=Dhimyotis, C=FR @@ -239,28 +182,12 @@ public class CertignaRoots { "-----END CERTIFICATE-----"; public static void main(String[] args) throws Exception { - // OCSP check by default - boolean ocspEnabled = args.length < 1 || !"CRL".equalsIgnoreCase(args[0]); - - // CN=Certigna - new CertignaCAs().runTest(ocspEnabled, - VALID, - REVOKED, - INT_CERTIGNA); - // CN=Certigna Root CA - new CertignaCAs().runTest(ocspEnabled, - VALID, - REVOKED, - INT_CERTIGNA_ROOT_CA); - } -} + // Added to test for JDK-8256895 + System.setProperty("jdk.security.certpath.ocspNonce", "true"); -class CertignaCAs { - public void runTest(boolean ocspEnabled, - final String VALID, - final String REVOKED, - final String INT_CERT) throws Exception { + // OCSP check by default + boolean ocspEnabled = args.length < 1 || !"CRL".equalsIgnoreCase(args[0]); ValidatePathWithParams pathValidator; String[] validChainToValidate; @@ -270,11 +197,11 @@ public void runTest(boolean ocspEnabled, pathValidator = new ValidatePathWithParams(null); pathValidator.enableCRLCheck(); - validChainToValidate = new String[]{VALID, INT_CERT}; - revChainToValidate = new String[]{REVOKED, INT_CERT}; + validChainToValidate = new String[]{VALID, INT_CERTIGNA}; + revChainToValidate = new String[]{REVOKED, INT_CERTIGNA}; } else { // int certificate doesn't specify OCSP responder - pathValidator = new ValidatePathWithParams(new String[]{INT_CERT}); + pathValidator = new ValidatePathWithParams(new String[]{INT_CERTIGNA}); pathValidator.enableOCSPCheck(); validChainToValidate = new String[]{VALID}; diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ComodoCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ComodoCA.java deleted file mode 100644 index 73d7171b906ac..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ComodoCA.java +++ /dev/null @@ -1,643 +0,0 @@ -/* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. - * 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 8189131 8231887 - * @summary Interoperability tests with Comodo RSA, ECC, userTrust RSA, and - * userTrust ECC CAs - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath ComodoCA OCSP - * @run main/othervm -Djava.security.debug=certpath ComodoCA CRL - */ - - /* - * Obtain TLS test artifacts for Comodo CAs from: - * - * Valid TLS Certificates: - * https://comodorsacertificationauthority-ev.comodoca.com - * https://comodoecccertificationauthority-ev.comodoca.com - * https://usertrustrsacertificationauthority-ev.comodoca.com - * https://usertrustecccertificationauthority-ev.comodoca.com - * - * Revoked TLS Certificates: - * https://comodorsacertificationauthority-ev.comodoca.com:444 - * https://comodoecccertificationauthority-ev.comodoca.com:444 - * https://usertrustrsacertificationauthority-ev.comodoca.com:444 - * https://usertrustecccertificationauthority-ev.comodoca.com:444 - */ -public class ComodoCA { - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - } - - new ComodoRSA().runTest(pathValidator); - new ComodoECC().runTest(pathValidator); - new ComodoUserTrustRSA().runTest(pathValidator); - new ComodoUserTrustECC().runTest(pathValidator); - } -} - -class ComodoRSA { - - // Owner: CN=COMODO RSA Extended Validation Secure Server CA, - // O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB - // Issuer: CN=COMODO RSA Certification Authority, O=COMODO CA Limited, - // L=Salford, ST=Greater Manchester, C=GB - // Serial number: 6a74380d4ebfed435b5a3f7e16abdd8 - // Valid from: Sat Feb 11 16:00:00 PST 2012 until: Thu Feb 11 15:59:59 PST 2027 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" - + "MIIGDjCCA/agAwIBAgIQBqdDgNTr/tQ1taP34Wq92DANBgkqhkiG9w0BAQwFADCB\n" - + "hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" - + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV\n" - + "BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTIwMjEy\n" - + "MDAwMDAwWhcNMjcwMjExMjM1OTU5WjCBkjELMAkGA1UEBhMCR0IxGzAZBgNVBAgT\n" - + "EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR\n" - + "Q09NT0RPIENBIExpbWl0ZWQxODA2BgNVBAMTL0NPTU9ETyBSU0EgRXh0ZW5kZWQg\n" - + "VmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC\n" - + "AQ8AMIIBCgKCAQEAlVbeVLTf1QJJe9FbXKKyHo+cK2JMK40SKPMalaPGEP0p3uGf\n" - + "CzhAk9HvbpUQ/OGQF3cs7nU+e2PsYZJuTzurgElr3wDqAwB/L3XVKC/sVmePgIOj\n" - + "vdwDmZOLlJFWW6G4ajo/Br0OksxgnP214J9mMF/b5pTwlWqvyIqvgNnmiDkBfBzA\n" - + "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ucNgBfIXOBhYsvss2B5JdoaZXOcOBCgJjqwyBZ9kzEi7nQLiMBciUEA\n" - + "KKlHMd99SUWa9eanRRrSjhMQ34Ovmw2tfn6dNVA0BM7pINae253UqNpktNEvWS5e\n" - + "ojZh1CSggjMziqHRbO9haKPl0latxf1eYusVqHQSTC8xjOnB3xBLAer2VBvNfzu9\n" - + "XJ/B288ByvK6YBIhMe2pZLiySVgXbVrXzYxtvp5/4gJYp9vDLVj2dAZqmvZh+fYA\n" - + "tmnYOosxWd2R5nwnI4fdAw+PKowegwFOAWEMUnNt/AiiuSpm5HZNMaBWm9lTjaK2\n" - + "jwLI5jqmBNFI+8NKAnb9L9K8E7bobTQk+p0pisehKxTxlgBzuRPpwLk6R1YCcYAn\n" - + "pLwltum95OmYdBbxN4SBB7SC\n" - + "-----END CERTIFICATE-----"; - - // Owner: CN=comodorsacertificationauthority-ev.comodoca.com, - // O=Sectigo Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, STREET=Trafford Road, - // L=Salford, ST=Manchester, OID.2.5.4.17=M5 3EQ, C=GB, OID.2.5.4.15=Private Organization, - // OID.1.3.6.1.4.1.311.60.2.1.3=GB, SERIALNUMBER=04058690 - // Issuer: CN=COMODO RSA Extended Validation Secure Server CA, O=COMODO CA Limited, L=Salford, - // ST=Greater Manchester, C=GB - // Serial number: 9eb246629030e0b527ca2f93e5ebf25a - // Valid from: Mon Mar 01 16:00:00 PST 2021 until: Sat Apr 02 16:59:59 PDT 2022 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIHSzCCBjOgAwIBAgIRAJ6yRmKQMOC1J8ovk+Xr8lowDQYJKoZIhvcNAQELBQAw\n" + - "gZIxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO\n" + - "BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMTgwNgYD\n" + - "VQQDEy9DT01PRE8gU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ADggEBADRFnOFgb3mzCUpXxiU5/mM5\n" + - "ECRj3NzXKXjcYlSMhVcWA7Eqa5rhJuh11vbPoDQzQcGxntS/zhRwJFRF3hnyFa3m\n" + - "4t+7ZnUaJN+GOMTABh4kYiOSpE9id12URdJzWv2IHg4CU3OLnsBHGh7H9eWfbPvn\n" + - "OW4owV1ChpiEHh40i/NQkTn9JzjlZepI9+EsSdhn2tpis7tko6PX/plgw8bRgm7f\n" + - "ong2QaX/DE6z4VIdomW8TQhB9turhKxwjzPTbtYDQIgZfRP/H1S5jYutqbE5yL5B\n" + - "r+VOiSuB8234P4xWg1IBL2EFbxPdgOSMTWRJutUcj44kJKmwp5GUQtySSccw4gk=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=comodorsacertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, - // O=Sectigo Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, STREET=Trafford Road, - // L=Salford, OID.2.5.4.17=M5 3EQ, C=GB, OID.2.5.4.15=Private Organization, - // OID.1.3.6.1.4.1.311.60.2.1.3=GB, SERIALNUMBER=04058690 - // Issuer: CN=COMODO RSA Extended Validation Secure Server CA, O=COMODO CA Limited, L=Salford, - // ST=Greater Manchester, C=GB - // Serial number: a0c7cabcc25ed9358ded02cc1d485545 - // Valid from: Sun Sep 29 17:00:00 PDT 2019 until: Tue Dec 28 15:59:59 PST 2021 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIH0TCCBrmgAwIBAgIRAKDHyrzCXtk1je0CzB1IVUUwDQYJKoZIhvcNAQELBQAw\n" + - "gZIxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO\n" + - "BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMTgwNgYD\n" + - "VQQDEy9DT01PRE8gUlNBIEV4dGVuZGVkIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZ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FAAABbYMBd1oAAAQDAEcwRQIgXbG32dagMeLhuZb+LSpJO1vI\n" + - "BmxmRnNdiz5FbG9cCbwCIQCr1X9f+ebT5fhlDUNBURUorTtM8QQciBiueBqvHk7+\n" + - "1DANBgkqhkiG9w0BAQsFAAOCAQEAM/A/1dgoc5NP1n+w3SX9qWcN7QT7ExdrnZSl\n" + - "Ygn0PF2fx4gz7cvNKucbpQJNA4C9awGydyYK8/o5KDUXt3K7eb1OAZ/NZBjygsJs\n" + - "ikXvxlBh8oEoqBOfOtr24l0NGUWnP8Qeu/VPcIMER4V8qX+in0pCXkSd67nkp6Bs\n" + - "EcqhDPgmzdSC1gQHsZuBdotG14OfdH1cG1bRK6GadISLG1h8BFukVem42B149v8F\n" + - "MCIUQAYprAVv2WlTZKBx9XzuK6IK3+klHZ07Jfvjvt7PPG5HKSMWBMnMaTHKcyQI\n" + - "G3t91yw7BnNNInZlBSsFtqjbHhDcr7uruZdbi0rerSsi2qDr0w==\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Tue Mar 02 02:51:39 PST 2021", System.out); - } -} - -class ComodoECC { - - // Owner: CN=COMODO ECC Extended Validation Secure Server CA, - // O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB - // Issuer: CN=COMODO ECC Certification Authority, O=COMODO CA Limited, - // L=Salford, ST=Greater Manchester, C=GB - // Serial number: 61d4643b412b5d8d715499d8553aa03 - // Valid from: Sun Apr 14 17:00:00 PDT 2013 until: Fri Apr 14 16:59:59 PDT 2028 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" - + "MIIDojCCAyigAwIBAgIQBh1GQ7QStdjXFUmdhVOqAzAKBggqhkjOPQQDAzCBhTEL\n" - + "MAkGA1UEBhMCR0I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NydDAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29t\n" - + "MAoGCCqGSM49BAMDA2gAMGUCMQDmPWS98nREWdt4xB83r9MVvgG5INpKHi6V1dUY\n" - + "lCqvSvXXjK0QvZSrOB7cj9RavGgCMG2xJNG+SvlTWEYpmK7eXSgmRUgoBDeQ0yDK\n" - + "lnxmeeOBnnCaDIxAcA3aCj2Gtdt3sA==\n" - + "-----END CERTIFICATE-----"; - - // Owner: CN=comodoecccertificationauthority-ev.comodoca.com, O=Sectigo Limited, STREET="3rd Floor, - // 26 Office Village", STREET=Exchange Quay, STREET=Trafford Road, L=Salford, ST=Manchester, OID.2.5.4.17=M5 3EQ, - // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, SERIALNUMBER=04058690 - // Issuer: CN=COMODO ECC Extended Validation Secure Server CA, O=COMODO CA Limited, L=Salford, - // ST=Greater Manchester, C=GB - // Serial number: db437a31e5be29a62443e3caa1479001 - // Valid from: Mon Mar 01 16:00:00 PST 2021 until: Sat Apr 02 16:59:59 PDT 2022 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIFvzCCBWWgAwIBAgIRANtDejHlvimmJEPjyqFHkAEwCgYIKoZIzj0EAwIwgZIx\n" + - "CzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNV\n" + - "BAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMTgwNgYDVQQD\n" + - "Ey9DT01PRE8gRUNDIEV4dGVuZGVkIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBD\n" + - "QTAeFw0yMTAzMDIwMDAwMDBaFw0yMjA0MDIyMzU5NTlaMIIBNzERMA8GA1UEBRMI\n" + - "MDQwNTg2OTAxEzARBgsrBgEEAYI3PAIBAxMCR0IxHTAbBgNVBA8TFFByaXZhdGUg\n" + - "T3JnYW5p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+ - "blNlY3VyZVNlcnZlckNBLmNydDAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuY29t\n" + - "b2RvY2EuY29tMDoGA1UdEQQzMDGCL2NvbW9kb2VjY2NlcnRpZmljYXRpb25hdXRo\n" + - "b3JpdHktZXYuY29tb2RvY2EuY29tMIIBBAYKKwYBBAHWeQIEAgSB9QSB8gDwAHYA\n" + - "RqVV63X6kSAwtaKJafTzfREsQXS+/Um4havy/HD+bUcAAAF38qtH4AAABAMARzBF\n" + - "AiBsKoB1TTfoUYUNqF160/vlOENHyK1zzARcnfGKYURHTwIhANKYWg1CO7jyCPk+\n" + - "IrrLaR+461snNK4LJZXJm4o/9GeeAHYAb1N2rDHwMRnYmQCkURX/dxUcEdkCwQAp\n" + - "Bo2yCJo32RMAAAF38qtJIAAABAMARzBFAiEA1hgxkYZb5Tc9+vQsDnsfXVewClN2\n" + - "7gzwd4hZdqAsOSYCID9CWcBvkKrL44mfe9ky1Z6BnAWHUBMCxTjt8MO/IMZ8MAoG\n" + - "CCqGSM49BAMCA0gAMEUCIBa3sfOiVb0q4LcXU9umKjzVw3Ib8VdiPTtXSnyl0oLb\n" + - "AiEAnpRB53UtLAF7xw98ELmK/LEk1b5KSlqoO8sFHgwQ8vI=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=comodoecccertificationauthority-ev.comodoca.com, OU=COMODO EV SSL, O=Sectigo Limited, - // STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, STREET=Trafford Road, L=Salford, OID.2.5.4.17=M5 3EQ, - // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, SERIALNUMBER=04058690 - // Issuer: CN=COMODO ECC Extended Validation Secure Server CA, O=COMODO CA Limited, L=Salford, - // ST=Greater Manchester, C=GB - // Serial number: 7972d9d8472a2d52ad1ee6edfb16cbe1 - // Valid from: Sun Sep 29 17:00:00 PDT 2019 until: Tue Dec 28 15:59:59 PST 2021 - private static final String REVOKED = "-----BE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BHMEUCIQDjKN3h86ofR94+JxLFoYuoA+DRtxEY8XGg+NQXlZfUrgIgEoO2\n" + - "ZzKbGfohdwj/WtDwJDRX5pjXF4M0nECiwtYXDIwwCgYIKoZIzj0EAwIDSAAwRQIg\n" + - "AkIRVQBwrElFjrnqk5XPvnlnwkIm1A70ayqOf1FexoQCIQC8tBTn//RCfrhcgTjd\n" + - "ER4wRjFfFoc6lC68OHGVg9CZZg==\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Tue Mar 02 02:53:40 PST 2021", System.out); - } -} - -class ComodoUserTrustRSA { - - // Owner: CN=Sectigo RSA Extended Validation Secure Server CA, O=Sectigo Limited, L=Salford, - // ST=Greater Manchester, C=GB - // Issuer: CN=USERTrust RSA Certification Authority, O=The USERTRUST Network, L=Jersey City, ST=New Jersey, C=US - // Serial number: 284e39c14b386d889c7299e58cd05a57 - // Valid from: Thu Nov 01 17:00:00 PDT 2018 until: Tue Dec 31 15:59:59 PST 2030 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIGNDCCBBygAwIBAgIQKE45wUs4bYiccpnljNBaVzANBgkqhkiG9w0BAQwFADCB\n" + - "iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + - "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV\n" + - "BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTgx\n" + - "MTAyMDAwMDAwWhcNMzAxMjMxMjM1OTU5WjCBkTELMAkGA1UEBhMCR0IxGzAZBgNV\n" + - "BAgTEkdyZWF0ZXIgTW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Ly9jcnQudXNlcnRydXN0LmNvbS9VU0VSVHJ1c3RSU0FB\n" + - "ZGRUcnVzdENBLmNydDAlBggrBgEFBQcwAYYZaHR0cDovL29jc3AudXNlcnRydXN0\n" + - "LmNvbTANBgkqhkiG9w0BAQwFAAOCAgEAQ4AzPxVypLyy3IjUUmVl7FaxrHsXQq2z\n" + - "Zt2gKnHQShuA+5xpRPNndjvhHk4D08PZXUe6Im7E5knqxtyl5aYdldb+HI/7f+zd\n" + - "W/1ub2N4Vq4ZYUjcZ1ECOFK7Z2zoNicDmU+Fe/TreXPuPsDicTG/tMcWEVM558OQ\n" + - "TJkB2LK3ZhGukWM/RTMRcRdXaXOX8Lh0ylzRO1O0ObXytvOFpkkkD92HGsfS06i7\n" + - "NLDPJEeZXqzHE5Tqj7VSAj+2luwfaXaPLD8lQEVci8xmsPGOn0mXE1ZzsChEPhVq\n" + - "FYQUsbiRJRhidKauhd+G2CkRTcR5fpsuz+iStB9s5Fks9lKoXnn0hv78VYjvR78C\n" + - "Cvj5FW/ounHjWTWMb3il9S5ngbFGcelB1l/MQkR63+1ybdi2OpjNWJCftxOWUpkC\n" + - "xaRdnOnSj7GQY0NLn8Gtq9FcSZydtkVgXpouSFZkXNS/MYwbcCCcRKBbrk8ss0SI\n" + - "Xg1gTURjh9VP1OHm0OktYcUw9e90wHIDn7h0qA+bWOsZquSRzT4s2crF3ZSA3tuV\n" + - "/UJ33mjdVO8wBD8aI5y10QreSPJvZHHNDyCmoyjXvNhR+u3arXUoHWxO+MZBeXbi\n" + - "iF7Nwn/IEmQvWBW8l6D26CXIavcY1kAJcfyzHkrPbLo+fAOa/KFl3lIU+0biEVNk\n" + - "Q9zXE6hC6X4=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=usertrustrsacertificationauthority-ev.comodoca.com, O=Sectigo Limited, STREET="3rd Floor, - // 26 Office Village", STREET=Exchange Quay, STREET=Trafford Road, L=Salford, ST=Manchester, OID.2.5.4.17=M5 3EQ, - // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, SERIALNUMBER=04058690 - // Issuer: CN=Sectigo RSA Extended Validation Secure Server CA, O=Sectigo Limited, L=Salford, - // ST=Greater Manchester, C=GB - // Serial number: 4e484426dbfed0c222b2ed152465614a - // Valid from: Mon Mar 01 16:00:00 PST 2021 until: Sat Apr 02 16:59:59 PDT 2022 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIHTzCCBjegAwIBAgIQTkhEJtv+0MIisu0VJGVhSjANBgkqhkiG9w0BAQsFADCB\n" + - "kTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + - "A1UEBxMHU2FsZm9yZDEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTkwNwYDVQQD\n" + - "EzBTZWN0aWdvIFJTQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFNlY3VyZSBTZXJ2ZXIg\n" + - "Q0EwHhcNMjEwMzAyMDAwMDAwWhcNMjIwNDAyMjM1OTU5WjCCAToxETAPBgNVBAUT\n" + - "CDA0MDU4NjkwMRMwEQYLKwYBBAGCNzwCAQMTAkdCMR0wGwYDVQQPExRQcml2YXRl\n" + - "IE9yZ2FuaXphdGlvbjELMAkGA1UEBhMCR0IxDzANBgNVBBETBk01IDNFUTETMBEG\n" + - "A1UECBMKTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEWMBQGA1UECRMNVHJh\n" + - "ZmZvcmQgUm9hZDEWMBQGA1UECRMNRXhjaGFuZ2UgUXVheTElMCMGA1UECRMcM3Jk\n" + - "IEZsb29yLCAyNiBPZmZpY2UgVmlsbGFnZTEYMBYGA1UEChMPU2VjdGlnbyBMaW1p\n" + - "dGVkMTswOQYDVQQDEzJ1c2VydHJ1c3Ryc2FjZXJ0aWZpY2F0aW9uYXV0aG9yaXR5\n" + - "LWV2LmNvbW9kb2NhLmNvbTCCASIwDQYJKo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VR0RBDYwNIIydXNlcnRydXN0cnNh\n" + - "Y2VydGlmaWNhdGlvbmF1dGhvcml0eS1ldi5jb21vZG9jYS5jb20wggEFBgorBgEE\n" + - "AdZ5AgQCBIH2BIHzAPEAdwBGpVXrdfqRIDC1oolp9PN9ESxBdL79SbiFq/L8cP5t\n" + - "RwAAAXfyrRCwAAAEAwBIMEYCIQCeOHfnABa6cl0EHTzyMj2t2qBqORBAC16hJIIl\n" + - "Y52W4QIhAKHDk1m9lW0kmcZJWEko3eA9QKJSDLNLpdUoBPzNNc76AHYAb1N2rDHw\n" + - "MRnYmQCkURX/dxUcEdkCwQApBo2yCJo32RMAAAF38q0R6wAABAMARzBFAiEAywsh\n" + - "8Ki6fFOExwR6de0qzTmf7bJMuQcY0Ry463/9R44CIDeAcX7Z9S1vlRB9gzVomNIN\n" + - "vkcnUazq7dowPnr5rYMOMA0GCSqGSIb3DQEBCwUAA4IBAQA3a+PBgH1SBVEDpgAN\n" + - "mWaqIQzJzMRfSgvopQ6nC8iD95SfYD/rvic7aOeBLh/5aEs/CknJsg6o0qB3wz1v\n" + - "T5JXd5JldRWw3nP80jkIaYgq97RUIkjcHhuw4hTyQP6wk7XVlPVLvBo9ePWxJjmn\n" + - "whxlSyxQ5A5NdrTqZOJmu9nFr2HXpX75kGwCkUKZI050FAZZydsK3LfMBTqe1Xwi\n" + - "PKyjXDWd40LjOEg31sA43ofO8n2pySP5LG5XAsvoAyPCy3zXhx5cdtmQFLIkntus\n" + - "DCfN+n51HPUo8r4PUhQtOiRUB3K871LTdwyv4/CRXS2fIhtO1pxYNKFOw0yrUf6j\n" + - "ECgk\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=usertrustrsacertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, O=Sectigo Limited, - // STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, STREET=Trafford Road, L=Salford, ST=Manchester, - // OID.2.5.4.17=M5 3EQ, C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, SERIALNUMBER=04058690 - // Issuer: CN=Sectigo RSA Extended Validation Secure Server CA, O=Sectigo Limited, L=Salford, - // ST=Greater Manchester, C=GB - // Serial number: b07fd164b5790c9d5d1fddff5819cdb2 - // Valid from: Sun Sep 29 17:00:00 PDT 2019 until: Tue Dec 28 15:59:59 PST 2021 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIH5TCCBs2gAwIBAgIRALB/0WS1eQydXR/d/1gZzbIwDQYJKoZIhvcNAQELBQAw\n" + - "gZExCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO\n" + - "BgNVBAcTB1NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE5MDcGA1UE\n" + - "AxMwU2VjdGlnbyBSU0EgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVy\n" + - "IENBMB4XDTE5MDkzMDAwMDAwMFoXDTIxMTIyODIzNTk1OVowggFWMREwDwYDVQQF\n" + - "EwgwNDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJpdmF0\n" + - "ZSBPcmdhbml6YXRpb24xCzAJBgNVBAYTAkdCMQ8wDQYDVQQREwZNNSAzRVExEzAR\n" + - "BgNVBAgTCk1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxFjAUBgNVBAkTDVRy\n" + - "YWZmb3JkIFJvYWQxFjAUBgNVBAkTDUV4Y2hhbmdlIFF1YXkxJTAjBgNVBAkTHDNy\n" + - "ZCBGbG9vciwgMjYgT2ZmaWNlIFZpbGxhZ2UxGDAWBgNVBAoTD1NlY3RpZ28gTGlt\n" + - "aXRlZDEaMBgGA1UECxMRQ09NT0RPIEVWIFNHQyBTU0wxOzA5BgNVBAMTMnVzZXJ0\n" + - "cnVzdHJzYWNlcnRpZmljYXRpb25hdXRob3JpdHktZXYuY29tb2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6udaD\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Tue Mar 02 02:55:42 PST 2021", System.out); - } -} - -class ComodoUserTrustECC { - - // Owner: CN=Sectigo ECC Extended Validation Secure Server CA, O=Sectigo Limited, L=Salford, - // ST=Greater Manchester, C=GB - // Issuer: CN=USERTrust ECC Certification Authority, O=The USERTRUST Network, L=Jersey City, ST=New Jersey, C=US - // Serial number: 80f5606d3a162b143adc12fbe8c2066f - // Valid from: Thu Nov 01 17:00:00 PDT 2018 until: Tue Dec 31 15:59:59 PST 2030 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIDyTCCA0+gAwIBAgIRAID1YG06FisUOtwS++jCBm8wCgYIKoZIzj0EAwMwgYgx\n" + - "CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5MRQwEgYDVQQHEwtKZXJz\n" + - "ZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMS4wLAYDVQQD\n" + - "EyVVU0VSVHJ1c3QgRUNDIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTE4MTEw\n" + - "MjAwMDAwMFoXDTMwMTIzMTIzNTk1OVowgZExCzAJBgNVBAYTAkdCMRswGQYDVQQI\n" + - "ExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxGDAWBgNVBAoT\n" + - "D1NlY3RpZ28gTGltaXRlZDE5MDcGA1UEAxMwU2VjdGlnbyBFQ0MgRXh0ZW5kZWQg\n" + - "VmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMFkwEwYHKoZIzj0CAQYIKoZIzj0D\n" + - "AQcDQgAEAyJ5Ca9JyXq8bO+krLVWysbtm7fdMSJ54uFD23t0x6JAC4IjxevfQJzW\n" + - "z4T6yY+FybTBqtOa++ijJFnkB5wKy6OCAY0wggGJMB8GA1UdIwQYMBaAFDrhCYbU\n" + - "zxnClnZ0SXbc4DXGY2OaMB0GA1UdDgQWBBTvwSqVDDLa+3Mw3IoT2BVL9xPo+DAO\n" + - "BgNVHQ8BAf8EBAMCAYYwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHSUEFjAUBggr\n" + - "BgEFBQcDAQYIKwYBBQUHAwIwOgYDVR0gBDMwMTAvBgRVHSAAMCcwJQYIKwYBBQUH\n" + - "AgEWGWh0dHBzOi8vY3BzLnVzZXJ0cnVzdC5jb20wUAYDVR0fBEkwRzBFoEOgQYY/\n" + - "aHR0cDovL2NybC51c2VydHJ1c3QuY29tL1VTRVJUcnVzdEVDQ0NlcnRpZmljYXRp\n" + - "b25BdXRob3JpdHkuY3JsMHYGCCsGAQUFBwEBBGowaDA/BggrBgEFBQcwAoYzaHR0\n" + - "cDovL2NydC51c2VydHJ1c3QuY29tL1VTRVJUcnVzdEVDQ0FkZFRydXN0Q0EuY3J0\n" + - "MCUGCCsGAQUFBzABhhlodHRwOi8vb2NzcC51c2VydHJ1c3QuY29tMAoGCCqGSM49\n" + - "BAMDA2gAMGUCMQCjHztBDL90GCRXHlGqm0H7kzP04hd0MxwakKjWzOmstXNFLONj\n" + - "RFa0JqI/iKUJMFcCMCbLgyzcFW7DihtY5XE0XCLCw+git0NjxiFB6FaOFIlyDdqT\n" + - "j+Th+DJ92JLvICVD/g==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=usertrustecccertificationauthority-ev.comodoca.com, O=Sectigo Limited, - // STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, STREET=Trafford Road, L=Salford, - // ST=Manchester, OID.2.5.4.17=M5 3EQ, - // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, SERIALNUMBER=04058690 - // Issuer: CN=Sectigo ECC Extended Validation Secure Server CA, O=Sectigo Limited, L=Salford, - // ST=Greater Manchester, C=GB - // Serial number: 9aa5da67480446fd7bf408fd5fdaa1d8 - // Valid from: Mon Mar 01 16:00:00 PST 2021 until: Sat Apr 02 16:59:59 PDT 2022 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIFwTCCBWigAwIBAgIRAJql2mdIBEb9e/QI/V/aodgwCgYIKoZIzj0EAwIwgZEx\n" + - "CzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNV\n" + - "BAcTB1NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE5MDcGA1UEAxMw\n" + - "U2VjdGlnbyBFQ0MgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENB\n" + - "MB4XDTIxMDMwMjAwMDAwMFoXDTIyMDQwMjIzNTk1OVowggE6MREwDwYDVQQFEwgw\n" + - "NDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJpdmF0ZSBP\n" + - "cmdhbml6YXRpb24xCzAJBgNVBAYTAkdCMQ8wDQYDVQQREwZNNSAzRVExEzARBgNV\n" + - "BAgTCk1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxFjAUBgNVBAkTDVRyYWZm\n" + - "b3JkIFJvYWQxFjAUBgNVBAkTDUV4Y2hhbmdlIFF1YXkxJTAjBgNVBAkTHDNyZCBG\n" + - "bG9vciwgMjYgT2ZmaWNlIFZpbGxhZ2UxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRl\n" + - "ZDE7MDkGA1UEAxMydXNlcnRydXN0ZWNjY2VydGlmaWNhdGlvbmF1dGhvcml0eS1l\n" + - "di5jb21vZG9jYS5jb20wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQtMl8R33Za\n" + - "WD6H8BW0+wybBf0+6+L5YYK/eyAVG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AIgS+r3C10ua38DPJKvUJvW5bvL\n" + - "SCQ949n3sBJvhV6aXq4CIH/oEGgvJmKtMEjVKUQg8TrZO6LwQ+0sYfL79Qvm8wL3\n" + - "MAoGCCqGSM49BAMCA0cAMEQCID4Q9cc8OQ9tmKnnKZyplPsPipI5apVGkBqFRUSt\n" + - "zzM3AiAw5tw3cv/oabDsYdU+lmp5kZ/S3Z97ANAAaHE0AfXe/Q==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=usertrustecccertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, - // O=Sectigo Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, STREET=Trafford Road, - // L=Salford, OID.2.5.4.17=M5 3EQ, - // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, SERIALNUMBER=04058690 - // Issuer: CN=Sectigo ECC Extended Validation Secure Server CA, O=Sectigo Limited, L=Salford, - // ST=Greater Manchester, C=GB - // Serial number: 8b72489b7f505a55e2a22659c90ed2ab - // Valid from: Sun Sep 29 17:00:00 PDT 2019 until: Tue Dec 28 15:59:59 PST 2021 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIGRTCCBeugAwIBAgIRAItySJt/UFpV4qImWckO0qswCgYIKoZIzj0EAwIwgZEx\n" + - "CzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNV\n" + - "BAcTB1NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE5MDcGA1UEAxMw\n" + - "U2VjdGlnbyBFQ0MgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENB\n" + - "MB4XDTE5MDkzMDAwMDAwMFoXDTIxMTIyODIzNTk1OVowggFBMREwDwYDVQQFEwgw\n" + - "NDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJpdmF0ZSBP\n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V4dGVuZGVk\n" + - "VmFsaWRhdGlvblNlY3VyZVNlcnZlckNBLmNydDAjBggrBgEFBQcwAYYXaHR0cDov\n" + - "L29jc3Auc2VjdGlnby5jb20wPQYDVR0RBDYwNIIydXNlcnRydXN0ZWNjY2VydGlm\n" + - "aWNhdGlvbmF1dGhvcml0eS1ldi5jb21vZG9jYS5jb20wggF/BgorBgEEAdZ5AgQC\n" + - "BIIBbwSCAWsBaQB2AO5Lvbd1zmC64UJpH6vhnmajD35fsHLYgwDEe4l6qP3LAAAB\n" + - "bYL/SJoAAAQDAEcwRQIhAL7EJt/Rgz6NBnx2v8Hevux3Gpcxy64kaeyLVgFeNqFk\n" + - "AiBRf+OWLOtZzEav/oERljrk8hgZB4CR1nj/Tn98cmRrwwB2AFWB1MIWkDYBSuoL\n" + - "m1c8U/DA5Dh4cCUIFy+jqh0HE9MMAAABbYL/SIgAAAQDAEcwRQIgVtZZaiBMC2lu\n" + - "atBzUHQmOq4qrUQP7nS83cd3VzPhToECIQDnlpOCdaxJwr8C0MtkvYpKSabwBPFL\n" + - "ASEkwmOpjuQErAB3ALvZ37wfinG1k5Qjl6qSe0c4V5UKq1LoGpCWZDaOHtGFAAAB\n" + - "bYL/SJoAAAQDAEgwRgIhAI8OgzP/kzF1bOJRHU2S/ewij/6HpGPy7Mbm7Hyuv3IU\n" + - "AiEAxDmX2FmORlgeerQmQ+ar3D9/TwA9RQckVDu5IrgweREwCgYIKoZIzj0EAwID\n" + - "SAAwRQIhAPwQWGWd3oR7YJ7ngCDQ9TAbdPgND51SiR34WfEgaTQtAiAxD4umKm02\n" + - "59GEMj5NpyF2ZQEq5mEGcjJNojrn+PC4zg==\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Tue Mar 02 02:59:25 PST 2021", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/EntrustCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/EntrustCA.java deleted file mode 100644 index 40b01309ccb42..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/EntrustCA.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. - * 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 8195774 8243321 - * @summary Interoperability tests with Entrust CAs - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath EntrustCA OCSP - * @run main/othervm -Djava.security.debug=certpath EntrustCA CRL - */ - -/* - * Obtain test artifacts for Entrust CA from: - * - * EC CA: - * Valid: https://validec.entrust.net - * Revoked https://revokedec.entrust.net - * - * G4 CA: - * Valid: https://validg4.entrust.net - * Revoked: https://revokedg4.entrust.net - */ -public class EntrustCA { - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - boolean ocspEnabled = false; - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - ocspEnabled = true; - } - - new Entrust_ECCA().runTest(pathValidator, ocspEnabled); - new Entrust_G4().runTest(pathValidator, ocspEnabled); - } -} - -class Entrust_ECCA { - - // Owner: CN=Entrust Certification Authority - L1J, OU="(c) 2016 Entrust, Inc. - for authorized use only", - // OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US - // Issuer: CN=Entrust Root Certification Authority - EC1, OU="(c) 2012 Entrust, Inc. - for authorized use only", - // OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIID5zCCA2ygAwIBAgIQCoPUgD5+n1EAAAAAUdTB9zAKBggqhkjOPQQDAzCBvzEL\n" + - "MAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1Nl\n" + - "ZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEy\n" + - "IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEzMDEGA1UE\n" + - "AxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRUMxMB4X\n" + - "DTE2MDQwNTIwMTk1NFoXDTM3MTAwNTIwNDk1NFowgboxCzAJBgNVBAYTAlVTMRYw\n" + - "FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu\n" + - "bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNiBFbnRydXN0LCBJbmMu\n" + - "IC0gZm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxLjAsBgNVBAMTJUVudHJ1c3QgQ2Vy\n" + - "dGlmaWNhdGlvbiBBdXRob3JpdHkgLSBMMUowdjAQBgcqhkjOPQIBBgUrgQQAIgNi\n" + - "AAT14eFXmpQX/dEf7NAxrMH13n0btz1KKvH2S1rROGPAKex2CY8yxznbffK/MbCk\n" + - "F7ByYXGs1+8kL5xmTysU/c+YmjOZx2mMSAk2DPw30fijJ3tRrwChZ+TBpgtB6+A5\n" + - "MsCjggEuMIIBKjAOBgNVHQ8BAf8EBAMCAQYwEgYDVR0TAQH/BAgwBgEB/wIBADAz\n" + - "BggrBgEFBQcBAQQnMCUwIwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLmVudHJ1c3Qu\n" + - "bmV0MDMGA1UdHwQsMCowKKAmoCSGImh0dHA6Ly9jcmwuZW50cnVzdC5uZXQvZWMx\n" + - "cm9vdC5jcmwwOwYDVR0gBDQwMjAwBgRVHSAAMCgwJgYIKwYBBQUHAgEWGmh0dHA6\n" + - "Ly93d3cuZW50cnVzdC5uZXQvcnBhMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEF\n" + - "BQcDAjAdBgNVHQ4EFgQUw/lFA77I+Qs8RTXz63Ls5+jrlJswHwYDVR0jBBgwFoAU\n" + - "t2PnGt2N6QimVYOk4GpQQWURQkkwCgYIKoZIzj0EAwMDaQAwZgIxAPnVAOqxKDd7\n" + - "v37EBmpPqWCCWBFPKW6HpRx3GUWc9caeQIw8rO2HXYgf92pb/TsJYAIxAJhI0MpR\n" + - "z5L42xF1R9UIPfQxCMwgsnWBqIqcfMrMO+2DxQy6GIP3cFFj9gRyxguKWw==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=validec.entrust.net, SERIALNUMBER=D15576572, OID.2.5.4.15=Private Organization, O="Entrust, Inc.", - // OID.1.3.6.1.4.1.311.60.2.1.2=Maryland, OID.1.3.6.1.4.1.311.60.2.1.3=US, L=Kanata, ST=Ontario, C=CA - // Issuer: CN=Entrust Certification Authority - L1J, OU="(c) 2016 Entrust, Inc. - for authorized use only", - // OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIFrTCCBTKgAwIBAgIQYtgW4DLwh74AAAAAVqBXkTAKBggqh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GtgWhwfi6OnQHV\n" + - "XIiNPRHEzbbsvswAAAFkNzGkvgAABAMASDBGAiEAlxy/kxB9waIifYn+EV550pvA\n" + - "C3jUfS/bjsKbcsBH9cQCIQDSHTJORz6fZu8uLFhpV525pw7iHVh2dSn3gpcteObh\n" + - "DQB3ALvZ37wfinG1k5Qjl6qSe0c4V5UKq1LoGpCWZDaOHtGFAAABZDcxpTsAAAQD\n" + - "AEgwRgIhAPCBqVqSvAEIXMPloV0tfBEEdjRrAhiG407cPqYwt9AFAiEAuQf4R5os\n" + - "MLkD3XhxvrTDvnD+PUOf8PzPevsWkuxNqcQwDgYDVR0PAQH/BAQDAgeAMB0GA1Ud\n" + - "JQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBjBggrBgEFBQcBAQRXMFUwIwYIKwYB\n" + - "BQUHMAGGF2h0dHA6Ly9vY3NwLmVudHJ1c3QubmV0MC4GCCsGAQUFBzAChiJodHRw\n" + - "Oi8vYWlhLmVudHJ1c3QubmV0L2wxai1lYzEuY2VyMDMGA1UdHwQsMCowKKAmoCSG\n" + - "Imh0dHA6Ly9jcmwuZW50cnVzdC5uZXQvbGV2ZWwxai5jcmwwSgYDVR0gBEMwQTA2\n" + - "BgpghkgBhvpsCgECMCgwJgYIKwYBBQUHAgEWGmh0dHA6Ly93d3cuZW50cnVzdC5u\n" + - "ZXQvcnBhMAcGBWeBDAEBMB8GA1UdIwQYMBaAFMP5RQO+yPkLPEU18+ty7Ofo65Sb\n" + - "MB0GA1UdDgQWBBT+J7OhS6gskCanmOGnx10DPSF8ATAJBgNVHRMEAjAAMAoGCCqG\n" + - "SM49BAMCA2kAMGYCMQCQLUQABT74TmdHzAtB97uNF5+Zy15wzkmlKeRSOXCIf2C5\n" + - "YKjsgdkR1OdzZXcpjNgCMQDfWcdPhodNXZC4l1lLPOPaTzPPw6uVqqoITQlc6r1t\n" + - "dRkkD6K9ii/X8EtwoFp7s80=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revokedec.entrust.net, SERIALNUMBER=115868500, OID.2.5.4.15=Private Organization, O="Entrust, Inc.", - // OID.1.3.6.1.4.1.311.60.2.1.2=Texas, OID.1.3.6.1.4.1.311.60.2.1.3=US, L=Kanata, ST=Ontario, C=CA - // Issuer: CN=Entrust Certification Authority - L1J, OU="(c) 2016 Entrust, Inc. - for authorized use only", - // OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIGJzCCBaygAwIBAgIRAM0WDfag1taIAAAAAFagJ5gwCgYIKoZIzj0EAwIwgbox\n" + - "CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9T\n" + - "ZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAx\n" + - "NiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxLjAsBgNV\n" + - "BAMTJUVudHJ1c3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBMMUowHhcNMTcw\n" + - "NTI0MTcwNzA4WhcNMTkwNTI0MTczNjU1WjCByDELMAkGA1UEBhMCQ0ExEDAOBgNV\n" + - "BAgTB09udGFyaW8xDzANBgNVBAcTBkthbmF0YTETMBEGCysGAQQBgjc8AgEDEwJV\n" + - "UzEWMBQGCysGAQQBgjc8AgECEwVUZXhhczEWMBQGA1UEChMNRW50cnVzdCwgSW5j\n" + - "LjEdMBsGA1UEDxMUUHJpdmF0ZSBPcmdhbml6YXRpb24xEjAQBgNVBAUTCTExNTg2\n" + - "ODUwMDEeMBwGA1UEAxMVcmV2b2tlZGVjLmVudHJ1c3QubmV0MFkwEwYHKoZIzj0C\n" + - "AQYIKoZIzj0DAQcDQgAEN5MP/59yrs9uwVM/Mrc8IuHonMChAZgN2twwvh8KTnR2\n" + - "3stfem/R+NtLccq+4ds1+8ktnXgP7u1x0as6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N0Lm5l\n" + - "dC9sZXZlbDFqLmNybDBKBgNVHSAEQzBBMDYGCmCGSAGG+mwKAQIwKDAmBggrBgEF\n" + - "BQcCARYaaHR0cDovL3d3dy5lbnRydXN0Lm5ldC9ycGEwBwYFZ4EMAQEwHwYDVR0j\n" + - "BBgwFoAUw/lFA77I+Qs8RTXz63Ls5+jrlJswHQYDVR0OBBYEFIj28ytR8ulo1p2t\n" + - "ZnBQOLK0rlLUMAkGA1UdEwQCMAAwCgYIKoZIzj0EAwIDaQAwZgIxANzqGRI0en5P\n" + - "gSUDcdwoQSNKrBPBfGz2AQVLHAXsxvIlGhKZAQtM49zxA8AdFy/agwIxAMEjJH6A\n" + - "4UbcGZc40eYu6wUbAxiUDD3gwSElNQ8Z6IhNLPCCdMM6KZORyaagAcXn4A==\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Wed May 24 10:39:28 PDT 2017", System.out); - } -} - -class Entrust_G4 { - - // Owner: CN=Entrust Certification Authority - L1N, OU="(c) 2014 Entrust, Inc. - for authorized use only", - // OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US - // Issuer: CN=Entrust Root Certification Authority - G4, OU="(c) 2015 Entrust, Inc. - for authorized use only", - // OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIGMjCCBBqgAwIBAgIRAKvsd/8bQQwHAAAAAFVl2AUwDQYJKoZIhvcNAQELBQAw\n" + - "gb4xCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQL\n" + - "Ex9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2FsLXRlcm1zMTkwNw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XRas\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=validg4.entrust.net, SERIALNUMBER=1913605, OID.2.5.4.15=Private Organization, - // O=Entrust Datacard Limited, OID.1.3.6.1.4.1.311.60.2.1.2=Ontario, OID.1.3.6.1.4.1.311.60.2.1.3=CA, - // L=Ottawa, ST=Ontario, C=CA - // Issuer: CN=Entrust Certification Authority - L1N, OU="(c) 2014 Entrust, Inc. - for authorized use only", - // OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US - // Serial number: 83790beb78eeb966007ad3dbf11d570 - // Valid from: Fri May 29 13:29:00 PDT 2020 until: Sun Aug 28 13:34:23 PDT 2022 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIFpjCCBI6gAwIBAgIQCDeQvreO65ZgB609vxHVcDANBgkqhkiG9w0BAQsFADCB\n" + - "ujELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsT\n" + - "H1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAy\n" + - "MDE0IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEuMCwG\n" + - "A1UEAxMlRW50cnVzdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEwxTjAeFw0y\n" + - "MDA1MjkyMDI5MDBaFw0yMjA4MjgyMDM0MjNaMIHRMQswCQYDVQQGEwJDQTEQMA4G\n" + - "A1UECBMHT250YXJpbzEPMA0GA1UEBxMGT3R0YXdhMRMwEQYLKwYBBAGCNzwCAQMT\n" + - "AkNBMRgwFgYLKwYBBAGCNzwCAQITB09udGFyaW8xITAfBgNVBAoTGEVudHJ1c3Qg\n" + - "RGF0YWNhcmQgTGltaXRlZDEdMBsGA1UEDxMUUHJpdmF0ZSBPcmdhbml6YXRpb24x\n" + - "EDAOBgNVBAUTBzE5MTM2MDUxHDAaBgNVBAMTE3ZhbGlkZz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k\n" + - "iAZZ4RJSWwI/CBQYAlUmd2wb/SBk9eYNAu/UL0XiAbwbOjH2dV6JHwAdwn0eoPR1\n" + - "KK/E1/OVoVibVBdxLMISPqdodRgHps6kGCOJxS8Zz8d3AEvx27EQ/Hg/EwIJZsUK\n" + - "dyb48V6a3XzExqLiwGu9oI9Ozm3/mo11ixmhvSFXH+FZf93qvvCSO+XTGGrLv5ja\n" + - "Tkazn/HgnwUBHd1TiO0jLhAdc+rZyd/SDjXMAXsa99zVfc2MY0Mb8+MohNHOwqYg\n" + - "tuYuirvtt9P0oteauL+iEBCRcqsmJaHGeaEyJH2QMxC5W22KpW245eHisW7rMoGQ\n" + - "9nbGmfe97p7bHQ==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revokedg4.entrust.net, SERIALNUMBER=1913605, OID.2.5.4.15=Private Organization, - // O=Entrust Datacard Limited, OID.1.3.6.1.4.1.311.60.2.1.2=Ontario, OID.1.3.6.1.4.1.311.60.2.1.3=CA, - // L=Ottawa, ST=Ontario, C=CA - // Issuer: CN=Entrust Certification Authority - L1N, OU="(c) 2014 Entrust, Inc. - for authorized use only", - // OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US - // Serial number: 24c5f46412b9dcc242a93017176979d6 - // Valid from: Fri May 29 13:36:00 PDT 2020 until: Sun Aug 28 13:40:43 PDT 2022 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIFqjCCBJKgAwIBAgIQJMX0ZBK53MJCqTAXF2l51jANBgkqhkiG9w0BAQsFADCB\n" + - "ujELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsT\n" + - "H1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAy\n" + - "MDE0IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEuMCwG\n" + - "A1UEAxMlRW50cnVzdCBDZXJ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2NzcC5lbnRydXN0Lm5l\n" + - "dDAzBggrBgEFBQcwAoYnaHR0cDovL2FpYS5lbnRydXN0Lm5ldC9sMW4tY2hhaW4y\n" + - "NTYuY2VyMDMGA1UdHwQsMCowKKAmoCSGImh0dHA6Ly9jcmwuZW50cnVzdC5uZXQv\n" + - "bGV2ZWwxbi5jcmwwIAYDVR0RBBkwF4IVcmV2b2tlZGc0LmVudHJ1c3QubmV0MEsG\n" + - "A1UdIAREMEIwNwYKYIZIAYb6bAoBAjApMCcGCCsGAQUFBwIBFhtodHRwczovL3d3\n" + - "dy5lbnRydXN0Lm5ldC9ycGEwBwYFZ4EMAQEwDQYJKoZIhvcNAQELBQADggEBAGab\n" + - "wtgpooQW3YL2Cqk9RDJFbNct5BSbzgY9qN1TOe4L7gbjV0BJBCcsHOCjvbgEuzME\n" + - "FC/kAmBu7eMnKVAqCCsWaI8XV7xB7P/BqHpvf9LI/GyHg4wCYdxgFGBXHOjlSy+8\n" + - "YWRM5UnFUknqbj1B4u2/U+U3X66QXi+MWrmBdjpcMahpY5zP1Bh90OmIc8DY4arf\n" + - "widObgJe2H/VFScudLf5JMpBso2v772GYTRr5Tqqq3ouS9WvDf0NBvoStt1oiUMP\n" + - "oowesfNiaYa/rZzWRlhYNs089KUeLhjOZswtIY5LCyy+Wt3CHgXljGEQFgi7p59s\n" + - "gk0aMRYM9Gri26VbD5A=\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Fri May 29 13:42:13 PDT 2020", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GlobalSignR6CA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GlobalSignR6CA.java deleted file mode 100644 index 244ef26c2ca85..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GlobalSignR6CA.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. - * 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 8216577 8249176 - * @summary Interoperability tests with GlobalSign R6 CA - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath GlobalSignR6CA OCSP - * @run main/othervm -Djava.security.debug=certpath GlobalSignR6CA CRL - */ - - /* - * - * Obtain TLS test artifacts for GlobalSign R6 CA from: - * - * Valid TLS Certificates: - * https://valid.r6.roots.globalsign.com/ - * - * Revoked TLS Certificates: - * https://revoked.r6.roots.globalsign.com/ - */ -public class GlobalSignR6CA { - - // Owner: CN=GlobalSign Atlas R6 EV TLS CA 2020, O=GlobalSign nv-sa, C=BE - // Issuer: CN=GlobalSign, O=GlobalSign, OU=GlobalSign Root CA - R6 - // Serial number: 7803182afbecd89eb19309bb4a25bdaa - // Valid from: Mon Jul 27 17:00:00 PDT 2020 until: Sat Jul 27 17:00:00 PDT 2030 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIGwDCCBKigAwIBAgIQeAMYKvvs2J6xkwm7SiW9qjANBgkqhkiG9w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" + - "0ZMTWGh8wCz6v3XBaXR0rxDAz9GImpU+xPx2XjuHac7OnYbN+i8p7cJPUxABjHiA\n" + - "LWXIZtCn5ziCfvYC6+SCp8x9TPJzAIfJ4NKv/8SpvvzuchVkAQqlQaGFBEdkX84R\n" + - "I/WYYG+2BliFIpbQnfljYWCURbfsYz7+Zxb94+4yzva49p8T6lALoK3s2kqIVLKN\n" + - "s6qAnk/qX6JihkaR3W+iViHMC5tqQX/pd8QIXccF3PA2OdeNGU4iUNZqUbYB4VZd\n" + - "AaOaeaUl0LwAta6DB5w344eUIqDgaitSwQZBnxppmwL3tGzP1ero2e2RvBmphbxI\n" + - "atIdxA==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=valid.r6.roots.globalsign.com, - // O=GMO GlobalSign LTD, STREET="Springfield House, Sandling Road", OID.2.5.4.17=ME14 2LP, L=Maidstone, ST=Kent, - // C=GB, SERIALNUMBER=04705639, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB - // Issuer: CN=GlobalSign Atlas R6 EV TLS CA 2020, O=GlobalSign nv-sa, C=BE - // Serial number: 1aff2829dd8bf07aa65a7b3c920ca4b - // Valid from: Thu Aug 27 00:20:06 PDT 2020 until: Tue Sep 28 00:20:06 PDT 2021 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIHyjCCBbKgAwIBAgIQAa/ygp3YvweqZaezySDKSzANBgkqhkiG9w0BAQsFADBV\n" + - "MQswCQYDVQQGEwJCRTEZMBcGA1UEChMQR2xvYmFsU2lnbiBudi1zYTErMCkGA1UE\n" + - "AxMiR2xvYmFsU2lnbiBBdGxhcyBSNiBFViBUTFMgQ0EgMjAyMDAeFw0yMDA4Mjcw\n" + - "NzIwMDZaFw0yMTA5MjgwNzIwMDZaMIH6MRMwEQYLKwYBBAGCNzwCAQMTAkdCMR0w\n" + - "GwYDVQQPDBRQcml2YXRlIE9yZ2FuaXphdGlvbjERMA8GA1UEBRMIMDQ3MDU2M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PRGIgCUDiiwnENVsQB/D24y3IapPkojujrvsVsmQN42GIgOY5tLK/8cCziD\n" + - "vf0GzZnmL1D2ezi3TaBj+XBWFcAyF2Y9AnVRmC9CrVcp6EX0KhD4g9ZgbpJZpVlk\n" + - "G3xfOiZWTeqLnQhCMXcdcutWIwXAX5gueyF1t545vECCE4PeGZNAeWqdbrj7xaS8\n" + - "3rKQdgwF9r6p7F5HHwEVCckhovEYU4DNFzYb9n/YmC3hmskFB1keTYqydKUYEGZ5\n" + - "fvLvsjRj9xwOCqIs5j1vuKw2CaqmHxrfYaDMMSZPq/iYrOWrf72wZIvtnAHePt3X\n" + - "atQMqNbDMQrjul31ljDP9CIbbtuZSkSACyMxiC10l4uTTLQiTxtZPkwIazOjnbBe\n" + - "A4fruOEQ2k1gu5oFgqmo+xuclOKNjwd/RkK4FXnD\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.r6.roots.globalsign.com, - // O=GMO GlobalSign LTD, STREET="Springfield House, Sandling Road", OID.2.5.4.17=ME14 2LP, L=Maidstone, ST=Kent, - // C=GB, SERIALNUMBER=04705639, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB - // Issuer: CN=GlobalSign Atlas R6 EV TLS CA 2020, O=GlobalSign nv-sa, C=BE - // Serial number: 1df30d84796ac20c47da63b8e681e8f - // Valid from: Thu Aug 27 00:37:53 PDT 2020 until: Tue Sep 28 00:37:53 PDT 2021 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIHzzCCBbegAwIBAgIQAd8w2EeWrCDEfaY7jmgejzANBgkqhkiG9w0BAQsFADBV\n" + - "MQswCQYDVQQGEwJCRTEZMBcGA1UEChMQR2xvYmFsU2lnbiBudi1zYTErMCkGA1UE\n" + - "AxMiR2xvYmFsU2lnbiBBdGxhcyBSNiBFViBUTFMgQ0EgMjAyMDAeFw0yMDA4Mjcw\n" + - "NzM3NTNaFw0yMTA5MjgwNzM3NTNaMIH8MRMwEQYL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6eo1BFKxQ3\n" + - "lDKYVXgg0OvMG/C2rvH/EIq5r+st49rNGWfcWRoHsDUruChZOHwJ9PrXKBLB/QVd\n" + - "4uw2V/0ipOETDudly7yLodXP8quhet4bCEO9gweXppL/MikLrE5xt46HW1/6w+jF\n" + - "wKCHWlq4ViswlaQ8q0oY/97o2udnuDQaNdrLgW3VofMeBIMNPBgkLDicOH6bLwNf\n" + - "lV68qi1ZBxBuOdoOqQyZ9RU9d3EL50XEJ4MtUvjJRAT5EWdFaB8SGGZbD5fyza8c\n" + - "KmeO5tkZWYecLd8CKqwKcW7umPflEwOzw60Cxg6eyBYA8Jfagpbdb/kXsF6Ov8IW\n" + - "vxNdHCnXnR3oBWm2uHddESO2zGF1ZfOb0O3cHHG5nCgVkWW68VpgX/LaN90u6Dzw\n" + - "diJX7esZV5ZaniqD+flWldgAdcfeXlJ5b7I7GnFr61ycmZT/qupagUS1WDq/zfct\n" + - "QcB4QmnAzGe6kcqiDOSyIYWpiw09jha63KpJtJDWRemrlQI=\n" + - "-----END CERTIFICATE-----"; - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - } - - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Thu Aug 27 00:38:11 PDT 2020", System.out); - } -} - diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GoDaddyCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GoDaddyCA.java deleted file mode 100644 index e8971b987ca32..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GoDaddyCA.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * @test - * @bug 8196141 - * @summary Interoperability tests with GoDaddy/Starfield CA - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath GoDaddyCA OCSP - * @run main/othervm -Djava.security.debug=certpath GoDaddyCA CRL - */ - -/* - * Obtain test artifacts for GoDaddy/Starfield CAs from: - * - * Go Daddy Root Certificate Authority - G2: - * valid: https://valid.gdig2.catest.godaddy.com/ - * expired: https://expired.gdig2.catest.godaddy.com/ - * revoked: https://revoked.gdig2.catest.godaddy.com/ - * - * Starfield Root Certificate Authority - G2: - * valid: https://valid.sfig2.catest.starfieldtech.com/ - * expired: https://expired.sfig2.catest.starfieldtech.com/ - * revoked: https://revoked.sfig2.catest.starfieldtech.com/ - */ -public class GoDaddyCA { - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - // CRL check - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - } - - new GoDaddyGdig2().runTest(pathValidator); - new GoDaddySfig2().runTest(pathValidator); - } -} - -class GoDaddyGdig2 { - - // Owner: CN=Go Daddy Secure Certificate Authority - G2, - // OU=http://certs.godaddy.com/repository/, O="GoDaddy.com, Inc.", - // L=Scottsdale, ST=Arizona, C=US - // Issuer: CN=Go Daddy Root Certificate Authority - G2, O="GoDaddy.com, Inc.", - // L=Scottsdale, ST=Arizona, C=US - private static final String INT = "-----BEGIN CERTIFICATE-----\n" - + "MIIE0DCCA7igAwIBAgIBBzANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx\n" - + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT\n" - + "EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp\n" - + "ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTExMDUwMzA3MDAwMFoXDTMxMDUwMzA3\n" - + "MDAwMFowgbQxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH\n" - + "EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjEtMCsGA1UE\n" - + "CxMkaHR0cDovL2NlcnRzLmdvZGFkZHkuY29tL3JlcG9zaXRvcnkvMTMwMQYDVQQD\n" - + "EypHbyBEYWRkeSBTZWN1cmUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IC0gRzIwggEi\n" - + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC54MsQ1K92vdSTYuswZLiBCGzD\n" - + "BNliF44v/z5lz4/OYuY8UhzaFkVLVat4a2ODYpDOD2lsmcgaFItMzEUz6ojcnqOv\n" - + "K/6AYZ15V8TPLvQ/MDxdR/yaFrzDN5ZBUY4RS1T4KL7QjL7wMDge87Am+GZHY23e\n" - + "cSZHjzhHU9FGHbTj3ADqRay9vHHZqm8A29vNMDp5T19MR/gd71vCxJ1gO7GyQ5HY\n" - + "pDNO6rPWJ0+tJYqlxvTV0KaudAVkV4i1RFXULSo6Pvi4vekyCgKUZMQWOlDxSq7n\n" - + "eTOvDCAHf+jfBDnCaQJsY1L6d8EbyHSHyLmTGFBUNUtpTrw700kuH9zB0lL7AgMB\n" - + "AAGjggEaMIIBFjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV\n" - + "HQ4EFgQUQMK9J47MNIMwojPX+2yz8LQsgM4wHwYDVR0jBBgwFoAUOpqFBxBnKLbv\n" - + "9r0FQW4gwZTaD94wNAYIKwYBBQUHAQEEKDAmMCQGCCsGAQUFBzABhhhodHRwOi8v\n" - + "b2NzcC5nb2RhZGR5LmNvbS8wNQYDVR0fBC4wLDAqoCigJoYkaHR0cDovL2NybC5n\n" - + "b2RhZGR5LmNvbS9nZHJvb3QtZzIuY3JsMEYGA1UdIAQ/MD0wOwYEVR0gADAzMDEG\n" - + "CCsGAQUFBwIBFiVodHRwczovL2NlcnRzLmdvZGFkZHkuY29tL3JlcG9zaXRvcnkv\n" - + "MA0GCSqGSIb3DQEBCwUAA4IBAQAIfmyTEMg4uJapkEv/oV9PBO9sPpyIBslQj6Zz\n" - + "91cxG7685C/b+LrTW+C05+Z5Yg4MotdqY3MxtfWoSKQ7CC2iXZDXtHwlTxFWMMS2\n" - + "RJ17LJ3lXubvDGGqv+QqG+6EnriDfcFDzkSnE3ANkR/0yBOtg2DZ2HKocyQetawi\n" - + "DsoXiWJYRBuriSUBAA/NxBti21G00w9RKpv0vHP8ds42pM3Z2Czqrpv1KrKQ0U11\n" - + "GIo/ikGQI31bS/6kA1ibRrLDYGCD+H1QQc7CoZDDu+8CL9IVVO5EFdkKrqeKM+2x\n" - + "LXY2JtwE65/3YR8V3Idv7kaWKK2hJn0KCacuBKONvPi8BDAB\n" - + "-----END CERTIFICATE-----"; - - // 1.3.6.1.4.1.311.60.2.1.3=US/1.3.6.1.4.1.311.60.2.1.2=Delaware/businessCategory=Private - // Organization/serialNumber=5510922, C=US, ST=Arizona, L=Scottsdale, O=GoDaddy INC., CN=valid.gdig2.catest.godaddy.com - private static final String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\n" + - "MEUCIQCFowkRXyR8gkX8cL7RbPSwiKCHy/1I1WVzpinmrHlZFQIgE5nShGeK7cqT\n" + - "j2C9FfrPc/Axe3/pzAFxD/BNQD1RO5sAdgCkuQmQtBhYFIe7E6LMZ3AKPDWYBPkb\n" + - "37jjd80OyA3cEAAAAV6H25GdAAAEAwBHMEUCIBQrE+FqILUhI0wdp2X+lf/e3UG1\n" + - "gyxHmSVeN2+CkrXPAiEA1mIIVmLNURGyI8wnZ5KRnBPOKYM2MC54RJ8CFrEHIz4w\n" + - "DQYJKoZIhvcNAQELBQADggEBADInvf3eS6SgQ1qxPx4RT2hPeU5frlWJWcOWUdZB\n" + - "6mVNcmUQMkYnjkg8+PQ782HGP0DvAfcIRDhSfXdIqzEk8MPUq1XHEOfwRzLpTiCN\n" + - "FQDQIt1LXnzESCUurJS8r4mxgaVLAwHFytOTDrQn0Xfs93dm0tnRGAg7iBg+N33V\n" + - "zOR4aqojdDUWa1Rr4WFqZMkZIxzREQCYC8HXSYqLA1oPuoMMog8dId7XSalBmGJ4\n" + - "KQVsZ0/Hpi0y9k/Zw5obGcEYJWMbuU1iaEkvdtXOiXEQfJ1WS+Yy55J4GSjpIiop\n" + - "qDZD88xA9r7ttzM/khao7jfIpVWG2HuX0JlHWdh3y9aegiw=\n" + - "-----END CERTIFICATE-----"; - - // 1.3.6.1.4.1.311.60.2.1.3=US/1.3.6.1.4.1.311.60.2.1.2=Delaware/businessCategory=Private - // Organization/serialNumber=5510922, C=US, ST=Arizona, L=Scottsdale, O=GoDaddy INC., CN=revoked.gdig2.catest.godaddy.com - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIHdDCCBlygAwIBAgIIEBJV3vmogM8wDQYJKoZIhvcNAQELBQAwgbQxCzAJBgNV\n" + - "BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRow\n" + - "GAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjEtMCsGA1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GHiH5L3yXE7BsH\n" + - "v75ja2RtuuYbMADAlDK/ZDoCIQDwuCq3x+egpB/GISxTnwkrDwhNhhIJNyk5F4j1\n" + - "/J8A0DANBgkqhkiG9w0BAQsFAAOCAQEAMGot6gBZ77HIDMb1n/HPrKdSHN0ngq7Z\n" + - "rhrkgbp+mH1Cs1lZA3qldMDxKXgNiodFqU/e4VewasQ9tJMmDXrTZIHualJGmIvq\n" + - "ISvV0ZUfSW/sJmo0ZDw8iBM993LDkA4wSc6SunhjOwu3LBfl9aKkeq6IhUEAG8X7\n" + - "54oO4iApt+APLMyeV9lZ/T7MGVbAjwdm+T1RMa/Ca99BahaRWN7hiM+zS3Ly+l6G\n" + - "7kqAkBFuJWbbZImADZ2RPldY6hBzTk6MT2hLCV40UD8JqwJo+qq7nGfJdTaFyZI6\n" + - "nJvrVATO7jL64YFP3xlVi8EQaCeKdZdn+BCCNA/ja0mWMj8EU9Islg==\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, null, System.out); - } -} - -class GoDaddySfig2 { - - // Owner: CN=Starfield Secure Certificate Authority - G2, - // OU=http://certs.starfieldtech.com/repository/, O="Starfield Technologies, Inc.", - // L=Scottsdale, ST=Arizona, C=US - // Issuer: CN=Starfield Root Certificate Authority - G2, - // O="Starfield Technologies, Inc.", L=Scottsdale, ST=Arizona, C=US - private static final String INT = "-----BEGIN CERTIFICATE-----\n" - + "MIIFADCCA+igAwIBAgIBBzANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx\n" - + "EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT\n" - + "HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjA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WNo\n" - + "LmNvbS8wOwYDVR0fBDQwMjAwoC6gLIYqaHR0cDovL2NybC5zdGFyZmllbGR0ZWNo\n" - + "LmNvbS9zZnJvb3QtZzIuY3JsMEwGA1UdIARFMEMwQQYEVR0gADA5MDcGCCsGAQUF\n" - + "BwIBFitodHRwczovL2NlcnRzLnN0YXJmaWVsZHRlY2guY29tL3JlcG9zaXRvcnkv\n" - + "MA0GCSqGSIb3DQEBCwUAA4IBAQBWZcr+8z8KqJOLGMfeQ2kTNCC+Tl94qGuc22pN\n" - + "QdvBE+zcMQAiXvcAngzgNGU0+bE6TkjIEoGIXFs+CFN69xpk37hQYcxTUUApS8L0\n" - + "rjpf5MqtJsxOYUPl/VemN3DOQyuwlMOS6eFfqhBJt2nk4NAfZKQrzR9voPiEJBjO\n" - + "eT2pkb9UGBOJmVQRDVXFJgt5T1ocbvlj2xSApAer+rKluYjdkf5lO6Sjeb6JTeHQ\n" - + "sPTIFwwKlhR8Cbds4cLYVdQYoKpBaXAko7nv6VrcPuuUSvC33l8Odvr7+2kDRUBQ\n" - + "7nIMpBKGgc0T0U7EPMpODdIm8QC3tKai4W56gf0wrHofx1l7\n" - + "-----END CERTIFICATE-----"; - - // 1.3.6.1.4.1.311.60.2.1.3=US/1.3.6.1.4.1.311.60.2.1.2=Arizona/businessCategory=Private - // Organization/serialNumber=R17247416, C=US, ST=Arizona, L=Scottsdale, O=Starfield Technologies, LLC, - // CN=valid.sfig2.catest.starfieldtech.com - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIHuzCCBqOgAwIBAgIIaZoUcUIjkGwwDQYJKoZIhvcNAQELBQAwgcYxCzAJBgNV\n" + - "BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUw\n" + - "IwYDVQQKExxTdGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTMwMQYDVQQLEypo\n" + - "dHRwOi8vY2VydHMuc3RhcmZpZWxkdGVjaC5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wQAAABXo30gFsA\n" + - "AAQDAEYwRAIgb8Xc54M+QD4wfSWLj5Ae/wrSEgRp7Kbf4Lf4vT4W0usCIGAShkJI\n" + - "CRxoudQDRxooNJhfXgsTB8QhwFC9PUPo3ZV+MA0GCSqGSIb3DQEBCwUAA4IBAQBt\n" + - "TqvwxqrkPYm/ssbN9cpVWlrQPw3DblsAEV6gnrrTJMd7HB042H3HLUiitddRjO40\n" + - "0EJM/tUOSGcWfqnJHWFDKoWzdrF5lHAzSRkMjdXgY9TTN5K5tUMEpfRjtink/zoY\n" + - "pNyc5ua4SXn94KfMZcOYGRvUM+0q6vLRBBMH541E3M6q6JbEBqZJFY8gBWwYqHH0\n" + - "xNGahm5++v4trFFCJzSfvfV1v+rnqy8tRivi7ZFLXWCcSyAqMH+T9Q36lKeFtaw4\n" + - "Sapf+dh2yrd2IBLW5eaAD13nCAjO/W0GuC7zw4+4mhW5+DTVJXrCkK5XddkVLhML\n" + - "k5pMoIv5EsFIm0Cs+DfF\n" + - "-----END CERTIFICATE-----"; - - // 1.3.6.1.4.1.311.60.2.1.3=US/1.3.6.1.4.1.311.60.2.1.2=Arizona/businessCategory=Private - // Organization/serialNumber=R17247416, C=US, ST=Arizona, L=Scottsdale, O=Starfield Technologies, LLC, - // CN=revoked.sfig2.catest.starfieldtech.com - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIHwTCCBqmgAwIBAgIJAPc1qVz+WDxpMA0GCSqGSIb3DQEBCwUAMIHGMQswCQYD\n" + - "VQQGEwJVUzEQMA4GA1UECBMHQXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTEl\n" + - "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEzMDEGA1UECxMq\n" + - "aHR0cDovL2NlcnRzLnN0YXJmaWVsZHRlY2guY29tL3JlcG9zaXRvcnkvMTQwMgYD\n" + - "VQQDEytTdGFyZmllbGQgU2VjdXJlIENlcnRpZmljYXRlIEF1dG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VuNaAIh\n" + - "AObDQwpDYh/bNp6k547gDxnR73LeU3kvl1Y76GjgxLAhMA0GCSqGSIb3DQEBCwUA\n" + - "A4IBAQDJ5vlagzOH8/ORUMgT33muSDFXCe5el/sQzVg8dridw9qjnxOpkGibdCiT\n" + - "b9Il1bdi7UnG8MlA3XpDjGgp6J/mUTijD9WcFx4lp5JnPaIbShHWCyIlRVZJzrZc\n" + - "UYhR56xXOKDYKYOIvM6qTqegXyEynJrIVTArMk7jQf0oNQLLHzXE1fVS1zut0H5l\n" + - "GE+TBgjasMEa1o1e/H/heSytb2zFNsZr8oxojzGBmlKyfCoIIcCv3PxX2ur57zJE\n" + - "9ADWoYK/7gYVba0JmLV4nQltDPp06nOYT9imxBWTrFahgPx1jOQDLgIpitkjyCy4\n" + - "xpmxUk8L6yc3O3aSD9OU/fzk/t/d\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, null, System.out); - } -} - diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GoogleCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GoogleCA.java deleted file mode 100644 index 95ac059de03dd..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/GoogleCA.java +++ /dev/null @@ -1,621 +0,0 @@ -/* - * 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 8307134 - * @summary Interoperability tests with Google's GlobalSign R4 and GTS Root certificates - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath GoogleCA OCSP - * @run main/othervm -Djava.security.debug=certpath GoogleCA CRL - */ - -/* - * Obtain TLS test artifacts for Google CAs from: - * - * https://pki.goog/repository/ - */ -public class GoogleCA { - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - boolean ocspEnabled = false; - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - ocspEnabled = true; - } - - new GoogleGSR4().runTest(pathValidator); - new GoogleGTSR1().runTest(pathValidator); - new GoogleGTSR2().runTest(pathValidator); - new GoogleGTSR3().runTest(pathValidator); - new GoogleGTSR4().runTest(pathValidator); - } -} - -class GoogleGSR4 { - - // Owner: CN=GTS CA 2D4, O=Google Trust Services LLC, C=US - // Issuer: CN=GlobalSign, O=GlobalSign, OU=GlobalSign ECC Root CA - R4 - // Serial number: 21668f1cd0a2a8f847d8aad34 - // Valid from: Tue Oct 04 17:00:42 PDT 2022 until: Wed Sep 29 17:00:42 PDT 2027 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIDBDCCAqugAwIBAgINAhZo8c0KKo+EfYqtNDAKBggqhkjOPQQDAjBQMSQwIgYD\n" + - "VQQLExtHbG9iYWxTaWduIEVDQyBSb290IENBIC0gUjQxEzARBgNVBAoTCkdsb2Jh\n" + - "bFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMjIxMDA1MDAwMDQyWhcNMjcw\n" + - "OTMwMDAwMDQyWjBGMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0\n" + - "IFNlcnZpY2VzIExMQzETMBEGA1UEAxMKR1RTIENBIDJENDBZMBMGByqGSM49AgEG\n" + - "CCqGSM49AwEHA0IABPQdCdV61990MPueGTVpXAjRmp2JIxt0Yuy59RZYT/XKg1lN\n" + - "gpRc0eh/bHtpehigtqe+llKTiVEkMhSMURoQQsOjggFyMIIBbjAOBgNVHQ8BAf8E\n" + - "BAMCAYYwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMBIGA1UdEwEB/wQI\n" + - "MAYBAf8CAQAwHQYDVR0OBBYEFKiI2Yo5rGXVgks3qJVsZUPNRAHgMB8GA1UdIwQY\n" + - "MBaAFFSwe61FuOJAf/sKbvu+M8k8o4TVMGYGCCsGAQUFBwEBBFowWDAlBggrBgEF\n" + - "BQcwAYYZaHR0cDovL29jc3AucGtpLmdvb2cvZ3NyNDAvBggrBgEFBQcwAoYjaHR0\n" + - "cDovL3BraS5nb29nL3JlcG8vY2VydHMvZ3NyNC5kZXIwMgYDVR0fBCswKTAnoCWg\n" + - "I4YhaHR0cDovL2NybC5wa2kuZ29vZy9nc3I0L2dzcjQuY3JsME0GA1UdIARGMEQw\n" + - "CAYGZ4EMAQIBMDgGCisGAQQB1nkCBQMwKjAoBggrBgEFBQcCARYcaHR0cHM6Ly9w\n" + - "a2kuZ29vZy9yZXBvc2l0b3J5LzAKBggqhkjOPQQDAgNHADBEAiBi+ikli1YBHQGs\n" + - "b5mnyBo5mydw04o386BPgaPpiBzgagIgbcpwQJCalLIekv8XRMoWFr3nV5XJfWRU\n" + - "5QPpOX0rXbg=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=good.gsr4.demo.pki.goog - // Issuer: CN=GTS CA 2D4, O=Google Trust Services LLC, C=US - // Serial number: 4c435754ee6e013c10efaff908a58cbb - // Valid from: Mon Mar 27 12:41:45 PDT 2023 until: Sun Jun 25 12:41:44 PDT 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIEsTCCBFegAwIBAgIQTENXVO5uATwQ76/5CKWMuzAKBggqhkjOPQQDAjBGMQsw\n" + - "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzET\n" + - "MBEGA1UEAxMKR1RTIENBIDJENDAeFw0yMzAzMjcxOTQxNDVaFw0yMzA2MjUxOTQx\n" + - "NDRaMCIxIDAeBgNVBAMTF2dvb2QuZ3NyNC5kZW1vLnBraS5nb29nMIIBIjANBgkq\n" + - "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAymtcnnxJ8pSF4YJUKTWKcHbRw28ShLzo\n" + - "KVTRPUsRrZZDqyDx296k3e0D04kBhcvEduxtEabCe89m06SH7L+bGVi25j35AXwn\n" + - "6aziLs/EV4BRy9ACfYipeT5PnQbaMmVe65q/RYKmWqD/z0SEh2uMFxRVl1CBmS/J\n" + - "owbNUlrEEDiYkE/nGfCmacpW0QZ7kxGjSR34mCSDugIYE/HME3ZVcZOVf2LT0lBA\n" + - "DhQtZI6cXy2lO8Ro/dUtcZKjo8iu0xW1pQeiJq9+CGp62MJFmpl+EfzP/B8aXQiF\n" + - "+m44LJJgAjiShAwVo9HbJUYv0dqCS9G22FL43xXqAdDlWZeuZyg7bQIDAQABo4IC\n" + - "fjCCAnowDgYDVR0PAQH/BAQDAgWgMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAwGA1Ud\n" + - "EwEB/wQCMAAwHQYDVR0OBBYEFKMuYkTnbWyrTBfBqbNNe91z3GPjMB8GA1UdIwQY\n" + - "MBaAFKiI2Yo5rGXVgks3qJVsZUPNRAHgMHgGCCsGAQUFBwEBBGwwajA1BggrBgEF\n" + - "BQcwAYYpaHR0cDovL29jc3AucGtpLmdvb2cvcy9ndHMyZDQvS2tnczU5VFFIelkw\n" + - "MQYIKwYBBQUHMAKGJWh0dHA6Ly9wa2kuZ29vZy9yZXBvL2NlcnRzL2d0czJkNC5k\n" + - "ZXIwIgYDVR0RBBswGYIXZ29vZC5nc3I0LmRlbW8ucGtpLmdvb2cwIQYDVR0gBBow\n" + - "GDAIBgZngQwBAgEwDAYKKwYBBAHWeQIFAzA8BgNVHR8ENTAzMDGgL6AthitodHRw\n" + - "Oi8vY3Jscy5wa2kuZ29vZy9ndHMyZDQvSUlXMzNMVUVwV3cuY3JsMIIBBAYKKwYB\n" + - "BAHWeQIEAgSB9QSB8gDwAHcA6D7Q2j71BjUy51covIlryQPTy9ERa+zraeF3fW0G\n" + - "vW4AAAGHJM62ygAABAMASDBGAiEAkeiqmfYYCVEmGA12/RJUZPdmxRP2ZXF0Xm30\n" + - "Oz+q2tgCIQCgSYqT/6RH+PCOauOVW4uaoshT+HfqurghVCzwGgBFvwB1ALc++yTf\n" + - "nE26dfI5xbpY9Gxd/ELPep81xJ4dCYEl7bSZAAABhyTOttoAAAQDAEYwRAIgBXao\n" + - "3Pry1nCHu3bngW3q3CHSLzmNHmO4cXMSdN2sAOkCIDE5DUyok3TRsOIHu1QTB0R2\n" + - "UxPeFm9KS73TBT8JEZykMAoGCCqGSM49BAMCA0gAMEUCIG1m91VOq3tghyLPA6YR\n" + - "/Pkq+gQylyM8wGJgnRMRE0lhAiEAxBgYXImtVqbfymq2MYwhV9KmG9gPIfqN6qWi\n" + - "lzblUM0=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.gsr4.demo.pki.goog - // Issuer: CN=GTS CA 2D4, O=Google Trust Services LLC, C=US - // Serial number: 1f9bd55e26716b3710b2614cec6fff02 - // Valid from: Mon Mar 27 12:48:37 PDT 2023 until: Sun Jun 25 12:48:36 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIEtzCCBFygAwIBAgIQH5vVXiZxazcQsmFM7G//AjAKBggqhkjOPQQDAjBGMQsw\n" + - "CQYDVQQGEwJVUzEiMCA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KKwYBBAHWeQIFAzA8BgNVHR8ENTAzMDGgL6At\n" + - "hitodHRwOi8vY3Jscy5wa2kuZ29vZy9ndHMyZDQvSUlXMzNMVUVwV3cuY3JsMIIB\n" + - "AwYKKwYBBAHWeQIEAgSB9ASB8QDvAHYAejKMVNi3LbYg6jjgUh7phBZwMhOFTTvS\n" + - "K8E6V6NS61IAAAGHJNUx1gAABAMARzBFAiEAj/RgXx1ScnsOf9R9N3eyPMJtH33C\n" + - "mOrRCOodG8QXmE0CIHwNJC5E53BVmfMzZwJH9f2BiUx31SGHWFvG283zVtX/AHUA\n" + - "6D7Q2j71BjUy51covIlryQPTy9ERa+zraeF3fW0GvW4AAAGHJNUxnAAABAMARjBE\n" + - "AiAI7pcrKatsz0G4QYPKmS74VQVEgnHqgKSoqv0ghTJXTgIgPyoYubz4MEHYirBu\n" + - "69BLC2jioXr8+wS7MK1IPqjdH44wCgYIKoZIzj0EAwIDSQAwRgIhAI4NdZ5JwTuW\n" + - "P+RH2bsAc5xrb804G9mOc3WMRVxTUKesAiEA/jHMJ2YdPv0WXKjKY7nUyFjUPdin\n" + - "BHRHfBeltynaFzU=\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Mon Mar 27 13:49:33 PDT 2023", System.out); - } -} - -class GoogleGTSR1 { - - // Owner: CN=GTS CA 1D4, O=Google Trust Services LLC, C=US - // Issuer: CN=GTS Root R1, O=Google Trust Services LLC, C=US - // Serial number: 2008eb2023336658b64cddb9b - // Valid from: Wed Aug 12 17:00:42 PDT 2020 until: Wed Sep 29 17:00:42 PDT 2027 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIFjDCCA3SgAwIBAgINAgCOsgIzNmWLZM3bmzANBgkqhkiG9w0B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+ - "MCswKaAnoCWGI2h0dHA6Ly9jcmwucGtpLmdvb2cvZ3RzcjEvZ3RzcjEuY3JsME0G\n" + - "A1UdIARGMEQwCAYGZ4EMAQIBMDgGCisGAQQB1nkCBQMwKjAoBggrBgEFBQcCARYc\n" + - "aHR0cHM6Ly9wa2kuZ29vZy9yZXBvc2l0b3J5LzANBgkqhkiG9w0BAQsFAAOCAgEA\n" + - "IVToy24jwXUr0rAPc924vuSVbKQuYw3nLflLfLh5AYWEeVl/Du18QAWUMdcJ6o/q\n" + - "FZbhXkBH0PNcw97thaf2BeoDYY9Ck/b+UGluhx06zd4EBf7H9P84nnrwpR+4GBDZ\n" + - "K+Xh3I0tqJy2rgOqNDflr5IMQ8ZTWA3yltakzSBKZ6XpF0PpqyCRvp/NCGv2KX2T\n" + - "uPCJvscp1/m2pVTtyBjYPRQ+QuCQGAJKjtN7R5DFrfTqMWvYgVlpCJBkwlu7+7KY\n" + - "3cTIfzE7cmALskMKNLuDz+RzCcsYTsVaU7Vp3xL60OYhqFkuAOOxDZ6pHOj9+OJm\n" + - "YgPmOT4X3+7L51fXJyRH9KfLRP6nT31D5nmsGAOgZ26/8T9hsBW1uo9ju5fZLZXV\n" + - "VS5H0HyIBMEKyGMIPhFWrlt/hFS28N1zaKI0ZBGD3gYgDLbiDT9fGXstpk+Fmc4o\n" + - "lVlWPzXe81vdoEnFbr5M272HdgJWo+WhT9BYM0Ji+wdVmnRffXgloEoluTNcWzc4\n" + - "1dFpgJu8fF3LG0gl2ibSYiCi9a6hvU0TppjJyIWXhkJTcMJlPrWx1VytEUGrX2l0\n" + - "JDwRjW/656r0KVB02xHRKvm2ZKI03TglLIpmVCK3kBKkKNpBNkFt8rhafcCKOb9J\n" + - "x/9tpNFlQTl7B39rJlJWkR17QnZqVptFePFORoZmFzM=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=good.gtsr1.demo.pki.goog - // Issuer: CN=GTS CA 1D4, O=Google Trust Services LLC, C=US - // Serial number: 19c08d5cde41fc84108f54c8d2a1aeca - // Valid from: Mon Mar 27 12:33:43 PDT 2023 until: Sun Jun 25 12:33:42 PDT 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIFcjCCBFqgAwIBAgIQGcCNXN5B/IQQj1TI0qGuyjANBgkqhkiG9w0BAQsFADBG\n" + - "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + - "QzETMBEGA1UEAxMKR1RTIENBIDFENDAeFw0yMzAzMjcxOTMzNDNaFw0yMzA2MjUx\n" + - "OTMzNDJaMCMxITAfBgNVBAMTGGdvb2QuZ3RzcjEuZGVtby5wa2kuZ29vZzCCASIw\n" + - "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMkOYhMM6kQMlep+l2/l5KTC1ow8\n" + - "nXHwXQzugR2Js302pM3p2UCfnfhlK0a9UUSVtAZa8ydVUyVRF9LzW1rOIK8UdlEj\n" + - "O6qAvPnPw8laY7rCPWRPibxu0OqL/5sYD+a4hQ7GhVsYDXXxnWQvLV5mppRlYF/8\n" + - "80ugGggRb+U3y6V84f1JnwSMvZFULe19BOeV5qWAHHFfgy0zePzcDMy8AqxaVBOb\n" + - "FVSsbdql2gnRyC4WZ9D5lc8vwS84KrJbce2+VtrpcKVALtyVA0Zzor2lr2wOVc4i\n" + - "OOwMNk9948eStAjOV8N4B1h9D/pd+cFSWfgXufr5ZClwijLr3zLvZxDGI6ECAwEA\n" + - "AaOCAn0wggJ5MA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATAM\n" + - "BgNVHRMBAf8EAjAAMB0GA1UdDgQWBBSTKR+0ebWnH3uGz5qju5/LpkCjYzAfBgNV\n" + - "HSMEGDAWgBQl4hgOsleRlCrl1F2GkIPeU7O4kjB4BggrBgEFBQcBAQRsMGowNQYI\n" + - "KwYBBQUHMAGGKWh0dHA6Ly9vY3NwLnBraS5nb29nL3MvZ3RzMWQ0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\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.gtsr1.demo.pki.goog - // Issuer: CN=GTS CA 1D4, O=Google Trust Services LLC, C=US - // Serial number: c414c34e6c2cc66c102b8d3502be3bb4 - // Valid from: Mon Mar 27 12:42:39 PDT 2023 until: Sun Jun 25 12:42:38 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIFfDCCBGSgAwIBAgIRAMQUw05sLMZsECuNNQK+O7QwDQYJKoZIhvcNAQELBQAw\n" + - "RjELMAkGA1UEBhMCVVMxIjAgBgNVBAoTGUdvb2dsZSBUcnVzdCBTZXJ2aWNlcyBM\n" + - "TEMxEzARBgNVBAMTCkdUUyBDQSAxRDQwHhcNMjMwMzI3MTk0MjM5WhcNMjMwNjI1\n" + - "MTk0MjM4WjAmMSQwIgYDVQQDExtyZXZva2VkLmd0c3IxLmRlbW8ucGtpLmdvb2cw\n" + - "ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCOeL80aphh8K8Cz41Sl2Cv\n" + - "cI3Elrrm/2sQH5Q0nxNuoZcxTGk3hD75Ntf6eqgclUQXJDEGbfoo3q7kYIQPXEIy\n" + - "+AuiMTd80ZRHuPBp8ci/wkh6N7B9mE/rjzJz77QgJluykoXRx9SiDyE4Yn9sRbBH\n" + - "jNm/KBv8wMV6hzJZYaALyDpGVNuAx9cHE91LaSvamPiccJn4wb9zDtyFduS3yYbz\n" + - "FREt960j420TeHjeWFkuXXVQMnPeRAWugclhJKzLz1U1gm5PWGxThMgVIy0v8v63\n" + - "3qFT09I4avi0AzBaRtINCaS39Mo2AoX1jZNjFDNLzRO1fSSJpzJmWyXJ2jRI7MwF\n" + - "AgMBAAGjggKDMIICfzAOBgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUH\n" + - "AwEwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUCuJDEKGIdbWqxyVFZmIZoyQZ4T4w\n" + - "HwYDVR0jBBgwFoAUJeIYDrJXkZQq5dRdhpCD3lOzuJIweAYIKwYBBQUHAQEEbDBq\n" + - "MDUGCCsGAQUFBzABhilodHRwOi8vb2NzcC5wa2kuZ29vZy9zL2d0czFkNC9rb2Zm\n" + - "cmFBODZBdzAxBggrBgEFBQcwAoYlaHR0cDovL3BraS5nb29nL3JlcG8vY2VydHMv\n" + - "Z3RzMWQ0LmRlcjAmBgNVHREEHzAdghtyZXZva2VkLmd0c3IxLmRlbW8ucGtpLmdv\n" + - "b2cwIQYDVR0gBBowGDAIBgZngQwBAgEwDAYKKwYBBAHWeQIFAzA8BgNVHR8ENTAz\n" + - "MDGgL6AthitodHRwOi8vY3Jscy5wa2kuZ29vZy9ndHMxZDQvODJFckFFQVVsR1ku\n" + - "Y3JsMIIBBQYKKwYBBAHWeQIEAgSB9gSB8wDxAHYArfe++nz/EMiLnT2cHj4YarRn\n" + - "KV3PsQwkyoWGNOvcgooAAAGHJM+cawAABAMARzBFAiB568monxGD3NiHsqNmsy+t\n" + - "IL4kCc71UNCCJthgnlL7HgIhAKSYf7P7CFO2wWdAt8LBMrsLoip9lytrinj0JR8R\n" + - "CYK9AHcAtz77JN+cTbp18jnFulj0bF38Qs96nzXEnh0JgSXttJkAAAGHJM+cZAAA\n" + - "BAMASDBGAiEAj8nBf1ihput8Gb8qCqVgvqAxPv9t4xLVhWg3tqv8gGMCIQDPiNbu\n" + - "vsyOi9nE6pDm86nggExXRa13wwCtr2wjAn5IpDANBgkqhkiG9w0BAQsFAAOCAQEA\n" + - "ezldM/NCUH58eXPZnbPaMMKrT5oNBxv+hypDy96+PyAqKtbC2bK+7sobGMZkfpG5\n" + - "8dW0mFmfazzjgbZUj54ZVHG4KaHeit8Nq1s07wh2Jo1c2JQdKxEXAOItax/IOfEd\n" + - "tqSg8AwSmhogQeiA7EXRspw4dYXL5uP/8jPPqByMI3PRmm3y7wyQLKNlNAfSgn7m\n" + - "wkrZxMRAENML4JND5UKxg7zo9e/Wvf4UPtEVVZaEj6ZxOe4JljvErCtayaw03t5p\n" + - "I18IAhXRpqm8JG1UGWjn49O8vkjB0bf/7iVXXI4rg6gGVia+HFuxKVGk5OQzo4Qd\n" + - "wBl6yOc8tpUH3phFPYbiMg==\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Mon Mar 27 13:43:25 PDT 2023", System.out); - } -} - -class GoogleGTSR2 { - - // Owner: CN=GTS CA 1D8, O=Google Trust Services LLC, C=US - // Issuer: CN=GTS Root R2, O=Google Trust Services LLC, C=US - // Serial number: 219c15ac025a1b0a5c1d9d501 - // Valid from: Tue Oct 04 17:00:42 PDT 2022 until: Wed Sep 29 17:00:42 PDT 2027 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIFjDCCA3SgAwIBAgINAhnBWsAlobClwdnVATANBgkqhkiG9w0BAQsFADBHMQsw\n" + - "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU\n" + - "MBIGA1UEAxMLR1RTIFJvb3QgUjIwHhcNMjIxMDA1MDAwMDQyWhcNMjcwOTMwMDAw\n" + - "MDQyWjBGMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp\n" + - "Y2VzIExMQzETMBEGA1UEAxMKR1RTIENBIDFEODCCASIwDQYJKoZIhvcNAQEBBQAD\n" + - "ggEPADCCAQoCggEBAKgpBAgi9bhOp5nCIELI/W+1rMoxNH3isu2LuDI3pPEPYJ0o\n" + - "YDxXB1zKHvUqn1VWDlF+K4vLPzjTRv2MUw8fHH9IAd/Rx+mrUHUxffTPU5O41tPj\n" + - "OdzFRO+FOr5RqZfbtXWbEUNyv7wyyCYr9gaDvDeQgDn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0AwX55SSu\n" + - "KvehoYs1ItHdEV1J2XfATZpCn6jMTEB/JYERbXW0VWLUhdaZORtaayQoU5YXbgvg\n" + - "bsPgqdIsPaxs/Chrp6zIKvs503YYcvs0GQSUQ1MFAWc+Loc39669T7WnL8Uu2yCO\n" + - "RxjFp3+fhTVA5UYwL1vy4wPnNUoa4+CA6JypT6ODUWcXZa8pWOdyHpbg0IeL389D\n" + - "s67kirG8/eKQxFzckbhL5AD8BJS3wkF7O7A8Gd+2VvSWhmEQzzOBHcvT/lqrCSe0\n" + - "7R7CV/Pw4E9C2GBLGfw8opxGXrdfJRjU6nHf5c+tC4xIjH/i3PQjaIFLG3D60mav\n" + - "0nkS92iorZl2dCiHTKxaD/J4B6VV03lpEcUdVg4WeGAmTClsXUnMOjCnlVYMLg9v\n" + - "URq0LbylxbGBelBrCNyqBS5UO6+9F4/Yi4vzoIvvbJ0=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=good.gtsr2.demo.pki.goog - // Issuer: CN=GTS CA 1D8, O=Google Trust Services LLC, C=US - // Serial number: 428fe99edb0df46e1008e4452f6cbfd2 - // Valid from: Mon Mar 27 12:52:12 PDT 2023 until: Sun Jun 25 12:52:11 PDT 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIFdDCCBFygAwIBAgIQQo/pntsN9G4QCORFL2y/0jANBgkqhkiG9w0BAQsFADBG\n" + - "MQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExM\n" + - "QzETMBEGA1UEAxMKR1RTIENBIDFEODAeFw0yMzAzMjcxOTUyMTJaFw0yMzA2MjUx\n" + - "OTUyMTFaMCMxITAfBgNVBAMTGGdvb2QuZ3RzcjIuZGVtby5wa2kuZ29vZzCCASIw\n" + - "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMaC0h20vohsggOQ0XGL5ca3Gqyf\n" + - "2n44PhYBrhzPpbq9/Mk9BKYYFy9osH0HwTFk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aKL512/S8AdgDo\n" + - "PtDaPvUGNTLnVyi8iWvJA9PL0RFr7Otp4Xd9bQa9bgAAAYck2PoBAAAEAwBHMEUC\n" + - "IHWqRE57W1pJJJAXrxFNMrjEO3f0YejAfi47mdyS1zJYAiEA4ye+achvGTYIMRnl\n" + - "jwBlTsYQQYt7KAVt2VAGMRB4H8kwDQYJKoZIhvcNAQELBQADggEBAGf9hz7NJRow\n" + - "veCSrfeVav2tDkx8s9VU7VD+lApip1mdqOGsqkCkeaA5hsGfhqleQFwsOAjduBFA\n" + - "nSV6KgiqFsgHSuS9zuSp2aVe8xhxq6mpr4LngkeUDc32mB9tW9AMaiYp8UeYyFGq\n" + - "hvjUb7/H2wFlT6qO+Qp/+hmfulKqNnrSzpZLIl+x2EBn3L6CFe5xaKzNaANgbShI\n" + - "cQsyKdaUrSAzNJZWnHwaAyQ1msqqXXoVzKmjAGMgZrXZNxv8Lh9V1v+F9WHDIjeQ\n" + - "TtahntIgq38eGtZAnyjdrUtfQwBlQI3zaE0n7n6Fq8ocglJE5woRlL/eTmSKiZr9\n" + - "rrEY0sJ0fCw=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.gtsr2.demo.pki.goog - // Issuer: CN=GTS CA 1D8, O=Google Trust Services LLC, C=US - // Serial number: df9af5c19e9dbdf6107cb03548ffbd06 - // Valid from: Mon Mar 27 12:45:09 PDT 2023 until: Sun Jun 25 12:45:08 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIFejCCBGKgAwIBAgIRAN+a9cGenb32EHywNUj/vQYwDQYJKoZIhvcNAQELBQAw\n" + - "RjELMAkGA1UEBhMCVVMxIjAgBgNVBAoTGUdvb2dsZSBUcnVzdCBTZXJ2aWNlcyBM\n" + - "TEMxEzARBgNVBAMTCkdUUyBDQSAxRDgwHhcNMjMwMzI3MTk0NTA5WhcNMjMwNjI1\n" + - "MTk0NTA4WjAmMSQwIgYDVQQDExtyZXZva2VkLmd0c3IyLmRl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7phBZw\n" + - "MhOFTTvSK8E6V6NS61IAAAGHJNGpywAABAMARzBFAiEApXndD34BJ3oOCLvGoa5f\n" + - "Xu0P6t4yf1pdCQONuLTSrX4CIDMp1N5/VKjClXqE/t2xux3mvJH2ceVECID4B69v\n" + - "WfOhAHUA6D7Q2j71BjUy51covIlryQPTy9ERa+zraeF3fW0GvW4AAAGHJNGphwAA\n" + - "BAMARjBEAiBa5aSnTCc2ceQj/asKFYRRGbwzXTnaDbvNMMeB4ogEXAIgZykyJVPh\n" + - "4Sfkroi8tvV6dwxexp0dT2EXHAmr+/GzZU0wDQYJKoZIhvcNAQELBQADggEBAHVn\n" + - "uWbk/OaljXKeyhlDCgdvnzJGCFQXwGyIJzNDkCs8k3iA1iwJKArvpkczxnCBxCPE\n" + - "imW2MHWCayT9JXKuO4ppU0oTh6GYvRV6DV1OkuWXsna7+dGf3+tkm9k0wauI6J8X\n" + - "H1T8Dq3W0+S+8UNSftduYSR1wTcN15OxIzlZ/FrV3LLRDxH2RKSsXfXBLgP1befh\n" + - "m+8SPQTpZ5NdMl7my0gmVgNF5ZIbFiHYzJkF2vS4iXJCI6fTWyoA1u/7jQyHdLOy\n" + - "pY0s6gKWEwwtpYC1lWI6ek/wLfuNrJbiRRiRs8e3HHQymn8K3T1PM+7n8huDy95b\n" + - "f1EgLMjvEtx6xpIqrqg=\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Mon Mar 27 13:45:40 PDT 2023", System.out); - } -} - -class GoogleGTSR3 { - - // Owner: CN=GTS CA 2D3, O=Google Trust Services LLC, C=US - // Issuer: CN=GTS Root R3, O=Google Trust Services LLC, C=US - // Serial number: 21668d8d65bc4320e5b8e5e76 - // Valid from: Tue Oct 04 17:00:42 PDT 2022 until: Wed Sep 29 17:00:42 PDT 2027 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIDIDCCAqagAwIBAgINAhZo2NZbxDIOW45edjAKBggqhkjOPQQDAzBHMQswCQYD\n" + - "VQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIG\n" + - "A1UEAxMLR1RTIFJvb3QgUjMwHhcNMjIxMDA1MDAwMDQyWhcNMjcwOTMwMDAwMDQy\n" + - "WjBGMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2Vz\n" + - "IExMQzETMBEGA1UEAxMKR1RTIENBIDJEMzBZMBMGByqGSM49AgEGCCqGSM49AwEH\n" + - "A0IABGQQXn8LoR0OtyBn+KkEav3utA7WFBgWEb/8bXVlW6xJLTZJIC04lsNmNKWJ\n" + - "P/fwHYfrZcx1o4vvOUTO9OD/7pijggF2MIIBcjAOBgNVHQ8BAf8EBAMCAYYwHQYD\n" + - "VR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMBIGA1UdEwEB/wQIMAYBAf8CAQAw\n" + - "HQYDVR0OBBYEFL+pU78badiFKTSaaUPL1nrUmf9tMB8GA1UdIwQYMBaAFMHxJrqg\n" + - "La6Fgc/T8SoSvbgKZ/28MGgGCCsGAQUFBwEBBFwwWjAmBggrBgEFBQcwAYYaaHR0\n" + - "cDovL29jc3AucGtpLmdvb2cvZ3RzcjMwMAYIKwYBBQUHMAKGJGh0dHA6Ly9wa2ku\n" + - "Z29vZy9yZXBvL2NlcnRzL2d0c3IzLmRlcjA0BgNVHR8ELTArMCmgJ6AlhiNodHRw\n" + - "Oi8vY3JsLnBraS5nb29nL2d0c3IzL2d0c3IzLmNybDBNBgNVHSAERjBEMAgGBmeB\n" + - "DAECATA4BgorBgEEAdZ5AgUDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vcGtpLmdv\n" + - "b2cvcmVwb3NpdG9yeS8wCgYIKoZIzj0EAwMDaAAwZQIxAO3wG4U11INX3hl2UyCn\n" + - "0A/upBaO+BBzX1OiQx7UfmMXc65kqkdIcNzZc6G6EWnNVAIwBG0LuIKWXfYc+Wbk\n" + - "STfMvwatUvd6QjdIKsYF0e8Hiaav+hLI0DzOuJcDPFtfYIyY\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=good.gtsr3.demo.pki.goog - // Issuer: CN=GTS CA 2D3, O=Google Trust Services LLC, C=US - // Serial number: 7d08ad6716e51d1210bfc149e3d0af19 - // Valid from: Mon Mar 27 12:37:41 PDT 2023 until: Sun Jun 25 12:37:40 PDT 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIEszCCBFmgAwIBAgIQfQitZxblHRIQv8FJ49CvGTAKBggqhkjOPQQDAjBGMQsw\n" + - "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzET\n" + - "MBEGA1UEAxMKR1RTIENBIDJEMzAeFw0yMzAzMjcxOTM3NDFaFw0yMzA2MjUxOTM3\n" + - "NDBaMCMxITAfBgNVBAMTGGdvb2QuZ3RzcjMuZGVtby5wa2kuZ29vZzCCASIwDQYJ\n" + - "KoZIhvcNAQEBBQADggEPADCCAQoCggEBAL7R40feuILVPC65FhoVh3kZ8mJuEKpJ\n" + - "SiSB9gbKRkaKBr4kHOm7+sa0RkAm3Zgbomd2JGiJbYYcQ4lY8MMlXruFLLY+0AMf\n" + - "Pf5mQbn6i+oSyfaNwV0Hk1q1MhZL5WSKLywXS0NVw50JGQw/SiIRhmR22DdOtxuh\n" + - "VC7ZOebYTbHzTBSYTxvoyJZ0bGUQMWQ0rI2lzOp+2kqSTDMmRejXUNm14ZrsdXUb\n" + - "F8nOunZpT5ppESFvsK7TFrWJlAFHNVxJjPkNaRyfIaR7G+hORoV5tHGaNeTzmFkO\n" + - "3ySGcRlvL41IWqBN4LwLiS6QN+Je7nIBDojEPTBVhPCzP++1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WftpYt\n" + - "e8CkUXnIxA==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.gtsr3.demo.pki.goog - // Issuer: CN=GTS CA 2D3, O=Google Trust Services LLC, C=US - // Serial number: 7ffa6a827df64c6010ebc47b5ca3eda7 - // Valid from: Mon Mar 27 12:45:58 PDT 2023 until: Sun Jun 25 12:45:57 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIEuTCCBF+gAwIBAgIQf/pqgn32TGAQ68R7XKPtpzAKBggqhkjOPQQDAjBGMQsw\n" + - "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzET\n" + - "MBEGA1UEAxMKR1RTIENBIDJEMzAeFw0yMzAzMjcxOTQ1NThaFw0yMzA2MjUxOTQ1\n" + - "NTdaMCYxJDAiBgNVBAMTG3Jldm9rZWQuZ3RzcjMuZGVtby5wa2kuZ29vZzCCASIw\n" + - "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKpn78KglifqiS3f5hPLH64og4aH\n" + - "7a1tDBza2ebTLYB74i1u65EIENCyzvz6OYvh8kKzhqZMPFbORd8OCESzebjv/Dc2\n" + - "BJJV498N3BfSZYWN+baVxKuOZ4HWXV5NyP85rEvbcaAWcmqvh++G88FOCTQvYd4D\n" + - "/RKgAMptDjM+4X6V2NIRXcmOZJWZ2iItao76FARvbKH0D2UJLG4ENdOznRonnItP\n" + - "74UEVfNCb/i7I+NMJYTuDA4/rr+AS6pttvsVM9pqWkIJqOloEVNcCyyr1buflfJO\n" + - "j4A8Nz9fTUffpfApQnPi394iUcdCVyCrcjB2ta2eMR/3AyhiSXOmxcGjUcECAwEA\n" + - "AaOCAoIwggJ+MA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATAM\n" + - "BgNVHRMBAf8EAjAAMB0GA1UdDgQWBBSg57WFIkW4b1eTcWX+qZsN+JEewTAfBgNV\n" + - "HSMEGDAWgBS/qVO/G2nYhSk0mmlDy9Z61Jn/bTB4BggrBgEFBQcBAQRsMGowNQYI\n" + - "KwYBBQUHMAGGKWh0dHA6Ly9vY3NwLnBraS5nb29nL3MvZ3RzMmQzL1pEZWExWTdT\n" + - "SlBZMDEGCCsGAQUFBzAChiVodHRwOi8vcGtpLmdvb2cvcmVwby9jZXJ0cy9ndHMy\n" + - "ZDMuZGVyMCYGA1UdEQQfMB2CG3Jldm9rZWQuZ3RzcjMuZGVtby5wa2kuZ29vZzAh\n" + - "BgNVHSAEGjAYMAgGBmeBDAECATAMBgorBgEEAdZ5AgUDMDwGA1UdHwQ1MDMwMaAv\n" + - "oC2GK2h0dHA6Ly9jcmxzLnBraS5nb29nL2d0czJkMy9WREItNVdJSTVRSS5jcmww\n" + - "ggEEBgorBgEEAdZ5AgQCBIH1BIHyAPAAdQDoPtDaPvUGNTLnVyi8iWvJA9PL0RFr\n" + - "7Otp4Xd9bQa9bgAAAYck00MJAAAEAwBGMEQCIALwbMReWy/zrvUwV1G5XOxN8koN\n" + - "VJ1pp7s1d7ClE9ebAiBYWwJeccnfHLIh9AJTdeuN+R/pDzEudVBSC2rIdo3HhgB3\n" + - "ALc++yTfnE26dfI5xbpY9Gxd/ELPep81xJ4dCYEl7bSZAAABhyTTQzMAAAQDAEgw\n" + - "RgIhAOEO0oyiRgMNDdWvRTobr7sex2SUFsjpKmwenYAULrRiAiEA6uKFK1sbnJ1J\n" + - "lW8Tw2G4jGpEFIc4C9duRbU6DIbGnckwCgYIKoZIzj0EAwIDSAAwRQIgN3byD4lu\n" + - "a8A0hzUR1OnPoXSyfus6HOhmBozH6coY9MICIQDsT5jj5GKVtxtlcki5iE08K70Z\n" + - "gt/tkcE1Fkk4RsZORA==\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Mon Mar 27 13:47:24 PDT 2023", System.out); - } -} - -class GoogleGTSR4 { - - // Owner: CN=GTS CA 2P2, O=Google Trust Services LLC, C=US - // Issuer: CN=GTS Root R4, O=Google Trust Services LLC, C=US - // Serial number: 2166825e1700440612491f540 - // Valid from: Tue Oct 04 17:00:42 PDT 2022 until: Wed Sep 29 17:00:42 PDT 2027 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIDITCCAqagAwIBAgINAhZoJeFwBEBhJJH1QDAKBggqhkjOPQQDAzBHMQswCQYD\n" + - "VQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIG\n" + - "A1UEAxMLR1RTIFJvb3QgUjQwHhcNMjIxMDA1MDAwMDQyWhcNMjcwOTMwMDAwMDQy\n" + - "WjBGMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2Vz\n" + - "IExMQzETMBEGA1UEAxMKR1RTIENBIDJQMjBZMBMGByqGSM49AgEGCCqGSM49AwEH\n" + - "A0IABKdQkzjAHqOUsb/TkH7cz5lRtD374tNZ8rYrCUb1mxypE+VmCb1Jgzq+93tR\n" + - "dE78GRzPI4+q6raha1TEyWgoniOjggF2MIIBcjAOBgNVHQ8BAf8EBAMCAYYwHQYD\n" + - "VR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMBIGA1UdEwEB/wQIMAYBAf8CAQAw\n" + - "HQYDVR0OBBYEFIcjqVBIDgeJVApxMPYz0gpH9p2sMB8GA1UdIwQYMBaAFIBM1ut0\n" + - "/0k2o9XY/LU+xWrwlB2MMGgGCCsGAQUFBwEBBFwwWjAmBggrBgEFBQcwAYYaaHR0\n" + - "cDovL29jc3AucGtpLmdvb2cvZ3RzcjQwMAYIKwYBBQUHMAKGJGh0dHA6Ly9wa2ku\n" + - "Z29vZy9yZXBvL2NlcnRzL2d0c3I0LmRlcjA0BgNVHR8ELTArMCmgJ6AlhiNodHRw\n" + - "Oi8vY3JsLnBraS5nb29nL2d0c3I0L2d0c3I0LmNybDBNBgNVHSAERjBEMAgGBmeB\n" + - "DAECATA4BgorBgEEAdZ5AgUDMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vcGtpLmdv\n" + - "b2cvcmVwb3NpdG9yeS8wCgYIKoZIzj0EAwMDaQAwZgIxAMnbIiQb5fsdexUuVGoB\n" + - "MVwsDPGd7VC13Y0OBezt7FqFHDwqm8nnVdV/FkNyXNv9/AIxAN51NGqMcbexMOYK\n" + - "pLC0zXfjNwvqBsZhmzCCQIM6MVyBID0rjjxPu7laIaHqAu6T5Q==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=good.gtsr4.demo.pki.goog - // Issuer: CN=GTS CA 2P2, O=Google Trust Services LLC, C=US - // Serial number: 743c4f78750e30f0d407a19254ba96a - // Valid from: Mon Mar 27 12:40:42 PDT 2023 until: Sun Jun 25 12:40:41 PDT 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIEsTCCBFegAwIBAgIQB0PE94dQ4w8NQHoZJUupajAKBggqhkjOPQQDAjBGMQsw\n" + - "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzET\n" + - "MBEGA1UEAxMKR1RTIENBIDJQMjAeFw0yMzAzMjcxOTQwNDJaFw0yMzA2MjUxOTQw\n" + - "NDFaMCMxITAfBgNVBAMTGGdvb2QuZ3RzcjQuZGVtby5wa2kuZ29vZzCCASIwDQYJ\n" + - "KoZIhvcNAQEBBQADggEPADCCAQoCggEBAOdkWBg3i5CxzH1dvlBoWHtIUyk78OAA\n" + - "bZdq7pKWB8i8C9Rf089uQ+7jQWOmqCNxU+OXdjumPfk/4MQvvtkmaqKi7HCN1bvQ\n" + - "0CrW7Zhi5jx11QuzEEZVdvXcchzmodp9GSl9t6zK/ItNiIYVisH9dqRWrZ/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zW/pzVtRn8oz1L/PBzw2NYRPFdDkRUCIG1uIaGUA7uqiILD6vvp/1VD\n" + - "XriEIH8/qz/3qWqxsZanMAoGCCqGSM49BAMCA0gAMEUCIQCnpyh5H9Hn+f8nOFZp\n" + - "wz7p+x5pmMVvPzah1g+EmoFO/wIgStidgVhudT/vpM2OH/oN30Na+EJJDqWxousN\n" + - "6t9L8FQ=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked.gtsr4.demo.pki.goog - // Issuer: CN=GTS CA 2P2, O=Google Trust Services LLC, C=US - // Serial number: 6b2d650d4bc3bd3f11a595bf05187915 - // Valid from: Mon Mar 27 12:47:43 PDT 2023 until: Sun Jun 25 12:47:42 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIEuDCCBF6gAwIBAgIQay1lDUvDvT8RpZW/BRh5FTAKBggqhkjOPQQDAjBGMQsw\n" + - "CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzET\n" + - "MBEGA1UEAxMKR1RTIENBIDJQMjAeFw0yMzAzMjcxOTQ3NDNaFw0yMzA2MjUxOTQ3\n" + - "NDJaMCYxJDAiBgNVBAMTG3Jldm9rZWQuZ3RzcjQuZGVtby5wa2kuZ29vZzCCASIw\n" + - "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOEKoC1Zv/m2G8DrGkOgLq5TPSeC\n" + - "X3cClcI6s4JS5Cld2DKX7m4P8rXAxJyVHvlmkxZQoD6Y7JxsavlJ/Yw0qdqkNLTv\n" + - "kviEiLNYEn8Qu0SoRLNanzoFUINZkAZ4/0Lfvsrl9tTigLsCJ4jQauemGmGcmKUy\n" + - "qsKisfrMC0ZG9EP9WRjc9WF13Jqe55+gZ7LqaAAoPVR/7J6T1VAKteaYaXrORtVF\n" + - "uMeinE4c9YuxRCLa+3X1qqc3HAsvZEBOdb35fC0cN/ILktCQpq1Fj+QD4jfR6bVQ\n" + - "E8e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tfQo4MDpBnd2RI6wIhAOdlQythGgU+nOENodsB+wUOQXOb\n" + - "akcBOxrDWfyhxmpk\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Mon Mar 27 13:48:18 PDT 2023", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java deleted file mode 100644 index d97342ae8d230..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. - * 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 8189131 - * @summary Interoperability tests with Let's Encrypt CA - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath LetsEncryptCA OCSP - * @run main/othervm -Djava.security.debug=certpath LetsEncryptCA CRL - */ - - /* - * Obtain TLS test artifacts for Let's Encrypt CA from: - * - * Valid TLS Certificates: - * https://valid-isrgrootx1.letsencrypt.org/ - * - * Revoked TLS Certificates: - * https://revoked-isrgrootx1.letsencrypt.org/ - * - * Test artifacts don't have CRLs listed and intermediate cert doesn't have OCSP. - */ -public class LetsEncryptCA { - - // Owner: CN=R3, O=Let's Encrypt, C=US - // Issuer: CN=ISRG Root X1, O=Internet Security Research Group, C=US - // Serial number: 912b084acf0c18a753f6d62e25a75f5a - // Valid from: Thu Sep 03 17:00:00 PDT 2020 until: Mon Sep 15 09:00:00 PDT 2025 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIFFjCCAv6gAwIBAgIRAJErCErPDBinU/bWLiWnX1owDQYJKoZIhvcNAQELBQAw\n" + - "TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n" + - "cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMjAwOTA0MDAwMDAw\n" + - "WhcNMjUwOTE1MTYwMDAwWjAyMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNTGV0J3Mg\n" + - "RW5jcnlwdDELMAkGA1UEAxMCUjMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK\n" + - "AoIBAQC7AhUozPaglNMPEuyNVZLD+ILxmaZ6QoinXSaqtSu5xUyxr45r+XXIo9cP\n" + - "R5QUVTVXjJ6oojkZ9YI8QqlObvU7wy7bjcCwXPNZOOftz2nwWgsbvsCUJCWH+jdx\n" + - "sxPnHKzhm+/b5DtFUkWWqcFTzjTIUu61ru2P3mBw4qVUq7ZtDpelQDRrK9O8Zutm\n" + - "NHz6a4uPVymZ+DAXXbpyb/uBxa3Shlg9F8fnCbvxK/eG3MHacV3URuPMrSXBiLxg\n" + - "Z3Vms/EY96Jc5lP/Ooi2R6X/ExjqmAl3P51T+c8B5fWmcBcUr2Ok/5mzk53cU6cG\n" + - "/kiFHaFpriV1uxPMUgP17VGhi9sVAgMBAAGj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j1nYsvC9JSQ6Zv\n" + - "MldlTTKB3zhThV1+XWYp6rjd5JW1zbVWEkLNxE7GJThEUG3szgBVGP7pSWTUTsqX\n" + - "nLRbwHOoq7hHwg==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=valid-isrgrootx1.letsencrypt.org - // Issuer: CN=R3, O=Let's Encrypt, C=US - // Serial number: 46326744d1c2f3feeca7148ed59353144a6 - // Valid from: Wed Jun 02 08:00:18 PDT 2021 until: Tue Aug 31 08:00:18 PDT 2021 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIFSDCCBDCgAwIBAgISBGMmdE0cLz/uynFI7Vk1MUSmMA0GCSqGSIb3DQEBCwUA\n" + - "MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD\n" + - "EwJSMzAeFw0yMTA2MDIxNTAwMThaFw0yMTA4MzExNTAwMThaMCsxKTAnBgNVBAMT\n" + - "IHZhbGlkLWlzcmdyb290eDEubGV0c2VuY3J5cHQub3JnMIIBIjANBgkqhkiG9w0B\n" + - "AQEFAAOCAQ8AMIIBCgKCAQEAmdx7jlaUZ0MgEvqzYWXItAFxVAOmR3KF+79vU195\n" + - "O5X54Go1+GU+eyFAeTqr6W1gC/MIrSA9LO4neJUx5AWCYaLq7IE7/YnmXTT6BB0x\n" + - "WFN3V1OJg9bAqpcEclQp6fbQS6DjdQvUUaEvVIwPzaen6Hmtw6LuHOYOdLk4fUSm\n" + - "zadWiyNlMm0/ts+MLHY5iQd9ypGhJED7KBDQ4d4wvyMYo/MYKOUQ+dTXcIegh7p4\n" + - "0OVtbrkdCuGJL+cEw1IUtSNQD+MnvUIu1je7Yb6iZ6Qd3iopNLykHYZb8YemakGX\n" + - "SDdC54yi35NU+Y+l23vycbVmRd8vK1sizhjRSE+ufmEqXQIDAQABo4ICXTCCAlkw\n" + - "DgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrB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"31rsKzpSbMJpnQ7WcgkUPdpoDo4JElGCyf7VZHNicumipAiCmKu0Q6TRCPOXxlKE\n" + - "/BIyDey3rXVw3wzOlxmVF6t/V3vGtbgVvN/feUe/ytyv4vLfRR4udi2XxWt3x1la\n" + - "7R3zuWdRQhh21p1H\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked-isrgrootx1.letsencrypt.org - // Issuer: CN=R3, O=Let's Encrypt, C=US - // Serial number: 4f1333011635d76d6356c5f1fb8a7273617 - // Valid from: Fri Jun 25 08:18:10 PDT 2021 until: Thu Sep 23 08:18:09 PDT 2021 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIFSTCCBDGgAwIBAgISBPEzMBFjXXbWNWxfH7inJzYXMA0GCSqGSIb3DQEBCwUA\n" + - "MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD\n" + - "EwJSMzAeFw0yMTA2MjUxNTE4MTBaFw0yMTA5MjMxNTE4MDlaMC0xKzApBgNVBAMT\n" + - "InJldm9rZWQtaXNyZ3Jvb3R4MS5sZXRzZW5jcnlwdC5vcmcwggEiMA0GCSqGSIb3\n" + - "DQEBAQUAA4IBDwAwggEKAoIBAQCkCp4fq7FnN5lfAWX0vhCcyC5WO9TuU6ckuYYj\n" + - "8/wQ8GQ/FIl+vXCAmHIfIX14irQN8TISeVdMOP0C7sa73d3GSawX7qMaRhddXn7V\n" + - "EL+4CbHQ6qit5YkakwhHz9tKbYX16wPj+inn22kJVwi8iLbhYB9WWSvv7OyiNSHv\n" + - "nmlYUkMv8+9UhgPT4yCKF1OEI5ajUOuecjOKc+EzsT/JqPRErvBOIKn3PRn4h8UM\n" + - "0BJDrDtZMpkvD4/lyRs3g/BLsf3DQjlEgKit0hvc72yyhiDbKd41EmBoQC5rNF7o\n" + - "B0CnBXhDLHbC/YRunVrYGsF0h2J9hw4055BdaXbS2BJnPEFnAgMBAAGjggJcMIIC\n" + - "WD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XXKj1KdfJGzgeoXqBv5PPCiP3hmBQixoJnSKImnUIXWh4O8\n" + - "kBtmgII5ug0q+jI3LvpJuv7xQsaNYFBcmFiQQ7YRt4W99GMdbYGjhzT8iBDEH7nG\n" + - "MsqWuwB5TN5vIuw2aWxcfaqKayq7UPA4rJePWdD/5RzKlQKLQx0BA3AL+3Nnj1fT\n" + - "NEKwCWWylIND6z/9Xw==\n" + - "-----END CERTIFICATE-----"; - - public static void main(String[] args) throws Exception { - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - pathValidator.enableCRLCheck(); - - // Validate int, EE certs don't have CRLs - pathValidator.validate(new String[]{INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - return; - } - - // OCSP check by default - // intermediate cert R3 doesn't specify OCSP responder - ValidatePathWithParams pathValidator = new ValidatePathWithParams(new String[]{INT}); - pathValidator.enableOCSPCheck(); - - // Validate valid - pathValidator.validate(new String[]{VALID}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED}, - ValidatePathWithParams.Status.REVOKED, - "Fri Jun 25 09:18:12 PDT 2021", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/MicrosoftTLS.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/MicrosoftTLS.java deleted file mode 100644 index e21aad61b8364..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/MicrosoftTLS.java +++ /dev/null @@ -1,348 +0,0 @@ -/* - * 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 8304760 - * @summary Interoperability tests with Microsoft TLS root CAs - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath MicrosoftTLS OCSP - * @run main/othervm -Djava.security.debug=certpath MicrosoftTLS CRL - */ - -/* - * Microsoft ECC Root Certificate Authority 2017: - * Valid: http://acteccroot2017.pki.microsoft.com/ - * Revoked: http://rvkeccroot2017.pki.microsoft.com/ - * Expired: http://expeccroot2017.pki.microsoft.com/ - * - * Microsoft RSA Root Certificate Authority 2017: - * Valid: http://actrsaroot2017.pki.microsoft.com/ - * Revoked: http://rvkrsaroot2017.pki.microsoft.com/ - * Expired: http://exprsaroot2017.pki.microsoft.com/ - */ -public class MicrosoftTLS { - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - } - - new MicrosoftECCTLS().runTest(pathValidator); - new MicrosoftRSATLS().runTest(pathValidator); - } -} - -class MicrosoftECCTLS { - - // Owner: CN=Microsoft ECC TLS Issuing AOC CA 01, O=Microsoft Corporation, C=US - // Issuer: CN=Microsoft ECC Root Certificate Authority 2017, O=Microsoft - // Corporation, C=US - // Serial number: 33000000282bfd23e7d1add707000000000028 - // Valid from: Thu Jun 24 12:58:36 PDT 2021 until: Wed Jun 24 12:58:36 PDT 2026 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIESTCCA8+gAwIBAgITMwAAACgr/SPn0a3XBwAAAA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cGtpb3BzL2NlcnRzL01pY3Jv\n" + - "c29mdCUyMEVDQyUyMFJvb3QlMjBDZXJ0aWZpY2F0ZSUyMEF1dGhvcml0eSUyMDIw\n" + - "MTcuY3J0MC0GCCsGAQUFBzABhiFodHRwOi8vb25lb2NzcC5taWNyb3NvZnQuY29t\n" + - "L29jc3AwcAYDVR0gBGkwZzAIBgZngQwBAgEwCAYGZ4EMAQICMFEGDCsGAQQBgjdM\n" + - "g30BATBBMD8GCCsGAQUFBwIBFjNodHRwOi8vd3d3Lm1pY3Jvc29mdC5jb20vcGtp\n" + - "b3BzL0RvY3MvUmVwb3NpdG9yeS5odG0wCgYIKoZIzj0EAwMDaAAwZQIxANmPydUj\n" + - "lgj/2K77UnMeMkSGIgXzOhcTsixzZL+NmTR1Bq2hSPeA6Y3mn3lMlwxZmAIwIio6\n" + - "KrgItH4YmLWKd8QClIrE9QjbDlR7oFqaU3J34bWbMlAEjRARdZhhQlNwdORe\n" + - "-----END CERTIFICATE-----"; - - // Owner: O=Microsoft Corporation, L=Redmond, ST=Washington, C=US - // Issuer: CN=Microsoft ECC TLS Issuing AOC CA 01, O=Microsoft Corporation, C=US - // Serial number: 3300000154e1c6007ee3d5c903000000000154 - // Valid from: Fri Oct 14 13:44:52 PDT 2022 until: Mon Oct 09 13:44:52 PDT 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIF3zCCBWSgAwIBAgITMwAAAVThxgB+49XJAwAAAAABVDAKBggqhkjOPQQDAzBb\n" + - "MQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSww\n" + - "KgYDVQQDEyNNaWNyb3NvZnQgRUNDIFRMUyBJc3N1aW5nIEFPQyBDQSAwMTAeFw0y\n" + - "MjEwMTQyMDQ0NTJaFw0yMzEwMDkyMDQ0NTJaMFQxCzAJBgNVBAYTAlVTMRMwEQYD\n" + - "VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy\n" + - "b3NvZnQgQ29ycG9yYXRpb24wdjAQBgcqhkjOPQIBBgUrgQQAIgNiAARk86yqvyiv\n" + - "jH2Frg2l6bmh1f0CqiKAEHdA2S2vTQhR4CtvFArkrPdqcKrhAAfQSgnC8KJQ08gl\n" + - "QvjK55202ib55YX3h+96IW6fQOkE18cvPwqkD3DVQuROouLaL1r70NWjggPvMIID\n" + - "6zCCAX8GCisGAQQB1nkCBAIEggFvBIIBawFpAHYA6D7Q2j71BjUy51covIlryQPT\n" + - "y9ERa+zraeF3fW0GvW4AAAGD2EdUigAABAMARzBFAiEA6rbt+9QhpuqX36PnuckO\n" + - "fR0Wu/8z3Yry9fdFKvJDCEUCIGBz901b4ZGEjCaSJdlZVr29v2td4crPa9I6S97i\n" + - "nShAAHYAs3N3B+GEUPhjhtYFqdwRCUp5LbFnDAuH3PADDnk2pZoAAAGD2EdU/wAA\n" + - "BAMARzBFAiBIvnSKGeCIWOlZowi7s7ZdwmyGhv2waJWSdewUSS6UOAIhALJhPQ19\n" + - "nmjjTwWB9sgCIF7RZbd2xwBd1hno06MQMSqTAHcAejKMVNi3LbYg6jjgUh7phBZw\n" + - "MhOFTTvSK8E6V6NS61IAAAGD2EdUxwAABAMASDBGAiEArrc6Fu74KTj/z4lGCK9A\n" + - "O6UkhLpKnXdxEHilY7ghcZICIQCUjkvK4wehX1qEonjQoBkBJxLCus6y8WbkoxCe\n" + - "jHu2HTAbBgkrBgEEAYI3FQoEDjAMMAoGCCsGAQUFBwMBMDwGCSsGAQQBgjcVBwQv\n" + - "MC0GJSsGAQQBgjcVCIe91xuB5+tGgoGdLo7QDIfw2h1dgbXdUIWf/XUCAWQCAR0w\n" + - "gaYGCCsGAQUFBwEBBIGZMIGWMGUGCCsGAQUFBzAChllodHRwOi8vd3d3Lm1pY3Jv\n" + - "c29mdC5jb20vcGtpb3BzL2NlcnRzL01pY3Jvc29mdCUyMEVDQyUyMFRMUyUyMElz\n" + - "c3VpbmclMjBBT0MlMjBDQSUyMDAxLmNydDAtBggrBgEFBQcwAYYhaHR0cDovL29u\n" + - "ZW9jc3AubWljcm9zb2Z0LmNvbS9vY3NwMB0GA1UdDgQWBBTVpTA+3jWCa1okX5Ri\n" + - "HnuY2/b+IzAOBgNVHQ8BAf8EBAMCB4AwKwYDVR0RBCQwIoIgYWN0ZWNjcm9vdDIw\n" + - "MTcucGtpLm1pY3Jvc29mdC5jb20waAYDVR0fBGEwXzBdoFugWYZXaHR0cDovL3d3\n" + - "dy5taWNyb3NvZnQuY29tL3BraW9wcy9jcmwvTWljcm9zb2Z0JTIwRUNDJTIwVExT\n" + - "JTIwSXNzdWluZyUyMEFPQyUyMENBJTIwMDEuY3JsMGYGA1UdIARfMF0wUQYMKwYB\n" + - "BAGCN0yDfQEBMEEwPwYIKwYBBQUHAgEWM2h0dHA6Ly93d3cubWljcm9zb2Z0LmNv\n" + - "bS9wa2lvcHMvRG9jcy9SZXBvc2l0b3J5Lmh0bTAIBgZngQwBAgIwHwYDVR0jBBgw\n" + - "FoAUMVu5zlEbfNGqA8Dr7TZdwp3TieEwEwYDVR0lBAwwCgYIKwYBBQUHAwEwCgYI\n" + - "KoZIzj0EAwMDaQAwZgIxAOKV8s3SpXVd6zho8zQa4uGXkxPVocYo410FdTwu0lw7\n" + - "G/MQPhLmj4DNsQJ/nYzDcwIxAMw7iZExsY9Is66/EaAty4rA+yuliwCag88VnDRH\n" + - "9cjiongZgpddIYS8xf76B2pi/Q==\n" + - "-----END CERTIFICATE-----"; - - // Owner: O=Microsoft Corporation, L=Redmond, ST=Washington, C=US - // Issuer: CN=Microsoft ECC TLS Issuing AOC CA 01, O=Microsoft Corporation, C=US - // Serial number: 3300000155ea28117be8708034000000000155 - // Valid from: Fri Oct 14 13:50:39 PDT 2022 until: Mon Oct 09 13:50:39 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIF3TCCBWOgAwIBAgITMwAAAVXqKBF76HCANAAAAAAB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gPIscuNH/BK20=\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Fri Oct 14 15:46:18 PDT 2022", System.out); - } -} - -class MicrosoftRSATLS { - - // Owner: CN=Microsoft RSA TLS Issuing AOC CA 01, O=Microsoft Corporation, C=US - // Issuer: CN=Microsoft RSA Root Certificate Authority 2017, O=Microsoft - // Corporation, C=US - // Serial number: 330000002ffaf06f6697e2469c00000000002f - // Valid from: Thu Jun 24 13:57:35 PDT 2021 until: Wed Jun 24 13:57:35 PDT 2026 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIHmDCCBYCgAwIBAgITMwAAAC/68G9ml+JGnAAAAAAALzANBgkqhkiG9w0BAQwF\n" + - "ADBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u\n" + - "MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9y\n" + - "aXR5IDIwMTcwHhcNMjEwNjI0MjA1NzM1WhcNMjYwNjI0MjA1NzM1WjBbMQswCQYD\n" + - "VQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSwwKgYDVQQD\n" + - "EyNNaWNyb3NvZnQgUlNBIFRMUyBJc3N1aW5nIEFPQyBDQSAwMTCCAiIwDQYJKoZI\n" + - "hvcNAQEBBQADggIPADCCAgoCggIBAKAYz8zB6I+LeiWYURf1QUaISydvRgxWfcc6\n" + - "UvEiwvryj2UsRfFuREo2ErLTvP9qQ9E0YBTyWEqI2TXn4jo2uZ2cpGODiQQWlixe\n" + - "aAFcYgSqLzidFXj401vzQsz4E0zylD/ZeY+xkQ6xrdg5312x2u2Ap7A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Ls59MMCxhy6Erb7kFQgu1oUWXGFhbMQkeLN4TXGi6X3loXYfING9om\n" + - "nWa/udxvPRwAZmcHU2l2W8cwVXiy6uucsh3kPQ==\n" + - "-----END CERTIFICATE-----"; - - // Owner: O=Microsoft Corporation, L=Redmond, ST=Washington, C=US - // Issuer: CN=Microsoft RSA TLS Issuing AOC CA 01, O=Microsoft Corporation, C=US - // Serial number: 330000014a3b44c12636e54b9f00000000014a - // Valid from: Fri Oct 14 13:55:34 PDT 2022 until: Mon Oct 09 13:55:34 PDT 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIILDCCBhSgAwIBAgITMwAAAUo7RMEmNuVLnwAAAAABSjANBgkqhkiG9w0BAQwF\n" + - "ADBbMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u\n" + - "MSwwKgYDVQQDEyNNaWNyb3NvZnQgUlNBIFRMUyBJc3N1aW5nIEFPQyBDQSAwMTAe\n" + - "Fw0yMjEwMTQyMDU1MzRaFw0yMzEwMDkyMDU1MzRaMFQxCzAJBgNVBAYTAlVTMRMw\n" + - "EQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVN\n" + - "aWNyb3NvZnQgQ29ycG9yYXRpb24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK\n" + - "AoIBAQDTo/3ysrrKP2eOLQ8JUFhQT09HJM1lUr0nH7RiP4VAKFrGFMIQSCsq17y7\n" + - "PuTHxW53Fvxb5s/EKZobzhlgv4rHQxvoMuGWRBgJN6KfspQAuFnUVG+3y70fHy/O\n" + - "PiVUJdfTupsys/fjzERqzx6FZoU1RzQ08na36SicSOQmj5svtHHxL8ZibDD48Xzp\n" + - "oIEBh2uUDhevkZedBmqlIdAhNgKXqf2lieLjWXZQLzUyXHikQJxNFOHFVjBqH3pu\n" + - "pYt2XD78bS/xeKRbGLw52+o3/u4eaPyiJoG0GaV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+ - "ougVo16GCOdcOG9+c6dBjbHseaQY0a95ZirtNLbutIvmvMIysvAHMC3NkunnD0cQ\n" + - "BxF47+meDc80QJGCaNlJ8E1SlUbEtRfVNsbcw1skO3hAsYAIA8M//BW7XcKRDvLn\n" + - "nPrC+5fWtDzmXgUE/Sve3rCr/AfBiBrLERcJHxYy41U=\n" + - "-----END CERTIFICATE-----"; - - // Owner: O=Microsoft Corporation, L=Redmond, ST=Washington, C=US - // Issuer: CN=Microsoft RSA TLS Issuing AOC CA 01, O=Microsoft Corporation, C=US - // Serial number: 330000014b4c2b0b9955688feb00000000014b - // Valid from: Fri Oct 14 13:56:58 PDT 2022 until: Mon Oct 09 13:56:58 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIIKjCCBhKgAwIBAgITMwAAAUtMKwuZVWiP6wAAAAABSzANBgkqhkiG9w0BAQwF\n" + - "ADBbMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u\n" + - "MSwwKgYDVQQDEyNNaWNyb3NvZnQgUlNBIFRMUyBJc3N1aW5nIEFPQyBDQSAwMTAe\n" + - "Fw0yMjEwMTQyMDU2NThaFw0yMzEwMDkyMDU2NThaMFQxCzAJBgNVBAYTAlVTMRMw\n" + - "EQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVN\n" + - "aWNyb3NvZnQgQ29ycG9yYXRpb24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK\n" + - "AoIBAQD2UxPzrv61IqG8jCFPWM3KeQpBeBlxh3mzvWVFmo340r0J1C3uLaUTPYLo\n" + - "P+Xndq2GqYLlm/5FEY7ynU1as57SH0tHbKCIYYJezn/ZJHUYcOY80uGKpP3bdbRq\n" + - "W51Xo7/gzTrXFJ2Nrn05d9mKBq+Oxs71+Nj7QuzjHYAF0n8OWNwZCBOBdAX3EDVQ\n" + - "4HBMSkIzriodM0F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n" + - "ApIjebH4RlOGiRRRJ5/Wz9Wk850mEvF16UlB1MUpLiKU63/nJvuR1TvOisAUl+5L\n" + - "oAfBFVkX4IGJU+9tc4VXYvTpd24xLHk/o6Fnl23D6zWlsZKldNxYPhiriXN9Duvb\n" + - "6xmaQX4gua6jmTFUhKDyyVJpW1A4GjuenPYsCmabzydiAeMIQirCCLSTqXrSw1YL\n" + - "2+608l1nqYy1JOrSq/zFp3c5buSFbjj7jVJB5LEh\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Fri Oct 14 15:46:18 PDT 2022", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/QuoVadisCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/QuoVadisCA.java deleted file mode 100644 index e171bafe1ada2..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/QuoVadisCA.java +++ /dev/null @@ -1,495 +0,0 @@ -/* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. - * 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 8189131 8207059 - * @key intermittent - * @summary Interoperability tests with QuoVadis Root CA1, CA2, and CA3 G3 CAs - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath QuoVadisCA OCSP - * @run main/othervm -Djava.security.debug=certpath QuoVadisCA CRL - */ - -/* - * Obtain TLS test artifacts for QuoVadis CAs from: - * - * https://www.quovadisglobal.com/download-roots-crl/ - * - */ -public class QuoVadisCA { - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - } - - new RootCA1G3().runTest(pathValidator); - new RootCA2G3().runTest(pathValidator); - new RootCA3G3().runTest(pathValidator); - } -} - -class RootCA1G3 { - - // Owner: CN=DigiCert QuoVadis TLS ICA QV Root CA 1 G3, O="DigiCert, Inc", C=US - // Issuer: CN=QuoVadis Root CA 1 G3, O=QuoVadis Limited, C=BM - // Serial number: 2837d5c3c2b57294becf99afe8bbdcd1bb0b20f1 - // Valid from: Wed Jan 06 12:50:51 PST 2021 until: Sat Jan 04 12:50:51 PST 2031 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIFgDCCA2igAwIBAgIUKDfVw8K1cpS+z5mv6Lvc0bsLIPEwDQYJKoZIhvcNAQEL\n" + - "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + - "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMSBHMzAeFw0yMTAxMDYyMDUwNTFaFw0z\n" + - "MTAxMDQyMDUwNTFaMFkxCzAJBgNVBAYTAlVTMRYwFAYDVQQKDA1EaWdpQ2VydCwg\n" + - "SW5jMTIwMAYDVQQDDClEaWdpQ2VydCBRdW9WYWRpcyBUTFMgSUNBIFFWIFJvb3Qg\n"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4/edX6Yesq6C1G8Pza1LwStXD/jCQHFvWbPud86V0ikS4rS\n" + - "qlmu3fzUrGZ2/Q+n5jrnRqM5IS8TXYcnzLD3azH1+aZjkwQt9HP4IuvAe/Bg9aWE\n" + - "XeDmksbg0SqQInrWn+BVYtD+hCZNz8K0GnKKpx3Q9VxzRv+BMbO5e9iqK1Hcj5Wv\n" + - "ZXvU45j2r5y9WML4fc8CvphzbF6ezr1e51i+yabNmfld33gRX48V5oNk16wX32ed\n" + - "kQ83sKNomQm1dXURWK8aSDcZFAvJQ8vKTLIE9wiQmtjfSGoJzQhKLaN+egrp4L9y\n" + - "fjpFIeK4zgAH39P4s4kaPWTdfXe2n6P5o7Xolp4R22SVkI76d8d+5Iv7Rtqd+mqI\n" + - "y1hkwyTBbOBLtyF7yMtJQewkkZ0MWxkPvWg193RbYVRx8w1EycnxMgNwy2sJw7MR\n" + - "XM6Mihkw910BkvlbsFUXw4uSvRkkRWSBWVrkM5hvZGtbIJkqrdnj55RSk4DLOOT/\n" + - "LUyji/KpgD7YCi7emFA4tH6OpkNrjUJ3gdRnD4GwQj/87tYeoQWZ6uCl0MHDUCmw\n" + - "73bpxSkjPrYbmKo9mGEAMhW1ZxY=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=quovadis-root-ca-1-g3.chain-demos.digicert.com, O="DigiCert, Inc.", - // L=Lehi, ST=Utah, C=US - // Issuer: CN=DigiCert QuoVadis TLS ICA QV Root CA 1 G3, O="DigiCert, Inc", C=US - // Serial number: a94cc08600f5fe5d3f0659bfcfec6f0 - // Valid from: Fri Mar 04 16:00:00 PST 2022 until: Wed Apr 05 16:59:59 PDT 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIG/DCCBeSgAwIBAgIQCpTMCGAPX+XT8GWb/P7G8DANBgkqhkiG9w0BAQsFADBZ\n" + - "MQswCQYDVQQGEwJVUzEWMBQGA1UECgwNRGlnaUNlcnQsIEluYzEyMDAGA1UEAwwp\n" + - "RGlna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kXv7/vWJXOxR1xl2d/WYDLsfp3BbqW\n" + - "YuKQwB5tTH1hEoNhQIyGnuE1Y1ZgtX24rSVfTCkU/3dnTZaIhaZgFHyftAum7xSI\n" + - "Qzu7pwih+PXrGNXupsnZ+VUE7a7zHyRDajixhSp7dZS4zLoDTxeyKX0MDmo4e8Mi\n" + - "HNYVASYcrdld90jVJaeI/V3EkJAX7/Eyo9JqzivEwGM0e0JhCLekcVSzhjGoAlbQ\n" + - "tIzCIaeVUlWKKiNXSKr1WD4oCD3ky4Y5VekTGzyUf/0LYzV+Y7p8epc5vTWKwYx/\n" + - "vQwJ4RsgFit+c84mSg4qug==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=quovadis-root-ca-1-g3-revoked.chain-demos.digicert.com, - // O="DigiCert, Inc.", L=Lehi, ST=Utah, C=US - // Issuer: CN=DigiCert QuoVadis TLS ICA QV Root CA 1 G3, O="DigiCert, Inc", C=US - // Serial number: e7eff4cdd14ebed1daa7bb7e07300ed - // Valid from: Fri Mar 04 16:00:00 PST 2022 until: Wed Apr 05 16:59:59 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIHDjCCBfagAwIBAgIQDn7/TN0U6+0dqnu34HMA7TANBgkqhkiG9w0BAQsFADBZ\n" + - "MQswCQYDVQQGEwJVUzEWMBQGA1UECgwNRGlnaUNlcnQsIEluYzEyMDAGA1UEAwwp\n" + - "RGlnaUNlcnQgUXVvVmFkaXMgVExTIElDQSBRViBSb290IENBIDEgRzMwHhcNMjIw\n" + - "MzA1MDAwMDAwWhcNMjMwNDA1MjM1OTU5WjCBhTELMAkGA1UEBhMCVVMxDTALBgNV\n" + - "BAgTBFV0YWgxDTALBgNVBAcTBExlaGkxFzAVBgNVBAoTDkRpZ2lDZXJ0LCBJbmMu\n" + - "MT8wPQYDVQQDEzZxdW92YWRpcy1yb290LWNhLTEtZzMtcmV2b2tlZC5jaGFpbi1k\n" + - "ZW1vcy5kaWdpY2VydC5jb20w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TFyRJ63sK65M+W0d55bHvleUAHRCOiGhhgqE/cby\n" + - "z50hDzJMLnjskMSpkxMoeSeutAS2e7oIvA//7C37LrQccQ==\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) - throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Tue Mar 08 11:22:28 PST 2022", System.out); - } -} - -class RootCA2G3 { - - // Owner: CN=DigiCert QV EV TLS ICA G1, O="DigiCert, Inc.", C=US - // Issuer: CN=QuoVadis Root CA 2 G3, O=QuoVadis Limited, C=BM - // Serial number: 65e9bcd53e791df22dffeb5ecc2bc7a5588d0883 - // Valid from: Mon Mar 16 12:39:42 PDT 2020 until: Thu Mar 14 12:39:42 PDT 2030 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIFbzCCA1egAwIBAgIUZem81T55HfIt/+tezCvHpViNCIMwDQYJKoZIhvcNAQEL\n" + - "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + - "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMiBHMzAeFw0yMDAzMTYxOTM5NDJaFw0z\n" + - "MDAzMTQxOTM5NDJaMEoxCzAJBgNVBAYTAlVTMRcwFQYDVQQKDA5EaWdpQ2VydCwg\n" + - "SW5jLjEiMCAGA1UEAwwZRGlnaUNlcnQgUVYgRVYgVExTIElDQSBHMTCCASIwDQYJ\n" + - "KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMhwn6I+pGrJsnisnzP7EU5cFN9UT5XF\n" + - "auA13F3jHeUUZmBOcMSOJEhx/e7oeVScTnmKpe7t7uey7lIIC9DWFmP8klbtLBgL\n" + - "0jY4MPlCkVyxUIhZ73EHCPqDCX9bo+rMB6C758/tKZOPcoWRixQypP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d9WXhyDCV5W2O8QIbrd42CK5k1rlM6gXwOyDmYY5CVAl1QeXEeRfDk/zNjU/1\n" + - "+LnH/Dv88VcZhODYq+VGbyM8bpNr0v95PY3yaH4kzpWGqWAN5i9LosfcaqRPmyL4\n" + - "PcKTQwcA9AVTjITExFua/QtGrXLPvMVxR248G9IQpJMxP3JEGkjlKCenmc29r2u1\n" + - "KE4TeCs2xxjR1PusTfX91bBW3YAoAPDTRQKZjolegLUY44j3uKSzAdhMEbZQhovH\n" + - "Lraqx1WjTayTuq1Vuakcia5shmgFVSNcE+NVgLEIe32oTOm/G6Kd1lcm9C4Ph1Cg\n" + - "nfDuqohZrk76kJTk8poAY5aFCQHhVzbpSw3zooMGjjvWnkG+/DC6SZM8rKoOdKiB\n" + - "cy+N\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=quovadis-root-ca-2-g3.chain-demos.digicert.com, O="DigiCert, - // Inc.", L=Lehi, ST=Utah, C=US, SERIALNUMBER=5299537-0142, OID.1.3.6.1.4 - // 1.311.60.2.1.2=Utah, OID.1.3.6.1.4.1.311.60.2.1.3=US, - // OID.2.5.4 .15=Private Organization - // Issuer: CN=DigiCert QV EV TLS ICA G1, O="DigiCert, Inc.", C=US - // Serial number: 9c5e9d5f169d3a59e64db208d3e849d - // Valid from: Wed Feb 02 16:00:00 PST 2022 until: Mon Mar 06 15:59:59 PST 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIHNDCCBhygAwIBAgIQCcXp1fFp06WeZNsgjT6EnTANBgkqhkiG9w0BAQsFADBK\n" + - "MQswCQYDVQQGEwJVUzEXMBUGA1UECgwORGlnaUNlcnQsIEluYy4xIjAgBgNVBAMM\n" + - "GURpZ2lDZXJ0IFFWIEVWIFRMUyBJQ0EgRzEwHhcNMjIwMjAzMDAwMDAwWhcNMjMw\n" + - "MzA2MjM1OTU5WjCB3zEdMBsGA1UEDwwUUHJpdmF0ZSBPcmdhbml6YXRpb24xEzAR\n" + - "BgsrBgEE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JxXzftBau5LbDWlvQ6EF+22fnaVDsKIwNgYwbhJb+6zr8t\n" + - "LOFS6Y51YSlRrDUvy94S3PE7N8D3wyKq18IhXOI1WUeR0bKHLlXtl+ZjKMIMkd/l\n" + - "YtLnnskRCQa0P/HLwQYLUpgiNGVZJQbjrWsVzcw12mR/gza1KjR02STJRGZad7L0\n" + - "Oz48CRhm94iaEjFcVKT3vcDUrtCKpkmhBACcdA3NNqDq10i/SLspOeDLSESkkJKF\n" + - "w8w3YCqXjZn5JyV3sVHYNezNKtLdCxn4\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=quovadis-root-ca-2-g3-revoked.chain-demos.digicert.com, - // O="DigiCert, Inc.", L=Lehi, ST=Utah, C=US, SERIALNUMBER=5299537-0142, - // OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.2=Utah, - // OID.1.3.6.1.4.1.311.60.2.1.3=US - // Issuer: CN=DigiCert QV EV TLS ICA G1, O="DigiCert, Inc.", C=US - // Serial number: 3f84605850df3ac98fcc15adec269f8 - // Valid from: Sun Apr 17 17:00:00 PDT 2022 until: Fri May 19 16:59:59 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIHQDCCBiigAwIBAgIQA/hGBYUN86yY/MFa3sJp+DANBgkqhkiG9w0BAQsFADBK\n" + - "MQswCQYDVQQGEwJVUzEXMBUGA1UECgwORGlnaUNlcnQsIEluYy4xIjAgBgNVBAMM\n" + - "GURpZ2lDZXJ0IFFWIEVWIFRMUyBJQ0EgRzEwHhcNMjIwNDE4MDAwMDAwWhcNMjMw\n" + - "NTE5MjM1OTU5WjCB5zETMBEGCysGAQQBgjc8AgEDEwJVUzEVMBMGCysGAQQBgjc8\n" + - "AgECEwRVdGFoMR0wGwYDVQQPDBRQcml2YXRlIE9yZ2FuaXphdGlvbjEVMBMGA1UE\n" + - "BRMMNTI5OTUzNy0wMTQyMQswCQYDVQQGEwJVUzENMAsGA1UECBMEVXRhaDENMAsG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mTWhex+e02z95n6RPYCiazuZNZ\n" + - "xiarN83pRNu/fIjVXw2jENg7+kaC1wwLqET0x6/EJa6YI3Xa7Aumb8Pp2r2UZ5Tr\n" + - "7BUhmiRLkvw/9SI8ceXNSwuTTGK2fKHm2/CWqI0cS3zWk3dC\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) - throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Mon Apr 18 14:07:46 PDT 2022", System.out); - } -} - -class RootCA3G3 { - - // Owner: CN=DigiCert QuoVadis TLS ICA QV Root CA 3 G3, O="DigiCert, Inc", C=US - // Issuer: CN=QuoVadis Root CA 3 G3, O=QuoVadis Limited, C=BM - // Serial number: 427dd33a8ff51d8152e813c7dec93ba76312a7d8 - // Valid from: Wed Jan 06 12:55:40 PST 2021 until: Sat Jan 04 12:55:40 PST 2031 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIFgDCCA2igAwIBAgIUQn3TOo/1HYFS6BPH3sk7p2MSp9gwDQYJKoZIhvcNAQEL\n" + - "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + - "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMyBHMzAeFw0yMTAxMDYyMDU1NDBaFw0z\n" + - "MTAxMDQyMDU1NDBaMFkxCzAJBgNVBAYTAlVTMRYwFAYDVQQKDA1EaWdpQ2VydCwg\n" + - "SW5jMTIwMAYDVQQDDClEaWdpQ2VydCBRdW9WYWRpcyBUTFMgSUNBIFFWIFJvb3Qg\n" + - "Q0EgMyBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALxNTdqnFD+A\n" + - "MhketYfVfVUWQKPkVEuyYj7Y2uwXBMRP4RStO4Co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EnAL9QROh0X9jFi\n" + - "SlsHPrxWC3adOdAW+B+kVG0cM2nurd0Ic2YkiLKOOaSd5hbCQY/fCZwohtest+ZU\n" + - "Ajyd+FVzSNvEFrwPzZwKfcdemvD4kew8lx5sG6BUL4GkFWnotxSr+F9Huwgj4pC+\n" + - "cxE2841a/9r/gliuwDM/8jkt16epFAdw0fXemyM8FdHJDnB++3d8SyjOOQ8j+VHW\n" + - "31NWx27sORa5CgRchlldXWDzIIEwbc82a1OAfGUmNAsdEHjMl1HMcZHbjCmdSdsw\n" + - "fmyldZrj2YmvOI5ZlE9z4vzi35KyqlxWCtu9O/SJq/rBvYS0TPmm8HbhJQbeMe6p\n" + - "vJGrxcb1muSBANn9T9wvukjiNNw32ciSDCjZ0h4N+CGxbzoZtgIAQ29IunYdnJix\n" + - "ZiP+ED6xvwgVRBkDSgWD2W/hex/+z4fNmGQJDcri51/tZCqHHv2Y7XReuf4Fk+nP\n" + - "l8Sd/Kpqwde/sJkoqwDcBSJygh0=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=quovadis-root-ca-3-g3.chain-demos.digicert.com, O="DigiCert, Inc.", - // L=Lehi, ST=Utah, C=US - // Issuer: CN=DigiCert QuoVadis TLS ICA QV Root CA 3 G3, O="DigiCert, Inc", C=US - // Serial number: f27ee3fad1d754ae78d7866da0a4f6f - // Valid from: Fri Mar 04 16:00:00 PST 2022 until: Wed Apr 05 16:59:59 PDT 2023 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIG/jCCBeagAwIBAgIQDyfuP60ddUrnjXhm2gpPbzANBgkqhkiG9w0BAQsFADBZ\n" + - "MQswCQYDVQQGEwJVUzEWMBQGA1UECgwNRGlnaUNlcnQsIEluYzEyMDAGA1UEAwwp\n" + - "RGlnaUNlcnQgUXVvVmFkaXMgVExTIElDQSBRViBSb290IENBIDMgRzMwHhcNMjIw\n" + - "MzA1MDAwMDAwWhcNMjMwNDA1MjM1OTU5WjB9MQswCQYDVQQGEwJVUz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oIuJwREjzv54SK7xsQ4whco0nw8DvLt+/5us4t96u8r1EuBKkF45ngz\n" + - "t77MTqpa0nvWUT7q9POT7xwQNui7P0j5t7prVX/fBKm5EfK1Jdi1Toj9+VxTIWYk\n" + - "splUCXw7zxaA3nlrncAmnHxZEY8sQjpGY1OGY0udd+m5bldJNbRTA1Q+VoPVMiU6\n" + - "osdBQGUbbWrqm1fnoFW1VvUt\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=quovadis-root-ca-3-g3-revoked.chain-demos.digicert.com, - // O="DigiCert, Inc.", L=Lehi, ST=Utah, C=US - // Issuer: CN=DigiCert QuoVadis TLS ICA QV Root CA 3 G3, O="DigiCert, Inc", C=US - // Serial number: aafa7cafda91796626f5fc8bcb38702 - // Valid from: Fri Mar 04 16:00:00 PST 2022 until: Wed Apr 05 16:59:59 PDT 2023 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIHDTCCBfWgAwIBAgIQCq+nyv2pF5Zib1/IvLOHAjANBgkqhkiG9w0BAQsFADBZ\n" + - "MQswCQYDVQQGEwJVUzEWMBQGA1UECgwNRGlnaUNlcnQsIEluYzEyMDAGA1UEAwwp\n" + - "RGlnaUNlcnQgUXVvVmFkaXMgVExTIElDQSBRViBSb290IENBIDMgRzMwHhcNMjIw\n" + - "MzA1MDAwMDAwWhcNMjMwNDA1MjM1OTU5WjCBhTELMAkGA1UEBhMCVVMxDTALBgNV\n" + - "BAgTBFV0YWgxDTALBgNVBAcTBExlaGkxFzAVBgNVBAoTDkRpZ2lDZXJ0LCBJbmMu\n" + - "MT8wPQYDVQQDEzZxdW92YWRpcy1yb290LWNhLTMtZzMtcmV2b2tlZC5jaGFpbi1k\n" + - "ZW1vcy5kaWdpY2VydC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n" + - "AQDofDJ1xHHWMhbWwU7e4cY3u2NjvE4ur/A0Y13UK53zoH8qDunV6ORAXQ+zSpev\n" + - "kPlnIbdjYO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2VydFF1b1ZhZGlzVExTSUNBUVZSb290Q0EzRzMuY3J0MAkGA1UdEwQCMAAwggF9\n" + - "BgorBgEEAdZ5AgQCBIIBbQSCAWkBZwB1AOg+0No+9QY1MudXKLyJa8kD08vREWvs\n" + - "62nhd31tBr1uAAABf1wc0LIAAAQDAEYwRAIgdmF6UFe2jgbM3FjYRMmcNaXfpleT\n" + - "E8hmYfmAVy5lSoUCIDPCV27IP9wpdGoxnnCMBwuekg6E4SB0lj49+o9OHHjDAHUA\n" + - "Nc8ZG7+xbFe/D61MbULLu7YnICZR6j/hKu+oA8M71kwAAAF/XBzQ0QAABAMARjBE\n" + - "AiBO6vYHFci7OWvqDHRlgTn+Q6zNG/LysZEOlrO4W8ZZ2gIgDY5+qjlar3esPN0b\n" + - "JUR5vfITl7UiZoqINJSm1gZ4Nm4AdwCzc3cH4YRQ+GOG1gWp3BEJSnktsWcMC4fc\n" + - "8AMOeTalmgAAAX9cHNDdAAAEAwBIMEYCIQCB52OPhdnYybsWzmkdSGSbgQVmS0V7\n" + - "ZumbThJSJwpuiwIhAP+JRx+Eu3MYRp5iyLb+xlWqghMnDnF9aCfm1VuW4aDuMA0G\n" + - "CSqGSIb3DQEBCwUAA4IBAQBO/4LljBpMGYYxBang12UIQ+FIjxAfKqqIklSa+du2\n" + - "ea0VHqaRrdfh/aTxzb0WaU++bgQN+MeHmQdvwYSgAyU/lY7mIvDTNxFOO6IG2vfR\n" + - "+JAUnS9iVUQ1rXHU72cxUsne5aRyLQ0W/2Zayx85O6/C9gIUJgJVRuk0dTPZ6tnq\n" + - "FoW1S4GwqEpzTuJU8rP5IvMYoYo8jItpjzS0W90gtDvev/XBRs1ig28Ky7ZS5AtQ\n" + - "S2Q6Ikg9YzegE9YNj2wqdZnEneoce0G1InysM/geY1BZ57G9RAUZkzWVTJRLJgbg\n" + - "2nWSqpQJ765gg9JdsRo+zqj1kUBbUYoTSlaAJG6ucrlB\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator) - throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Tue Mar 08 11:23:06 PST 2022", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/SSLCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/SSLCA.java deleted file mode 100644 index dd0b982f58bdf..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/SSLCA.java +++ /dev/null @@ -1,490 +0,0 @@ -/* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. - * 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 8243320 8256895 - * @summary Interoperability tests with SSL.com's RSA, EV RSA, and ECC CA - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath SSLCA OCSP - * @run main/othervm -Djava.security.debug=certpath SSLCA CRL - */ - -/* - * Obtain TLS test artifacts for SSL.com CAs from: - * - * SSL.com RSA CA - * Valid - https://test-dv-rsa.ssl.com - * Revoked - https://revoked-rsa-dv.ssl.com/ - * SSL.com EV RSA CA - * Valid - https://test-ev-rsa.ssl.com - * Revoked - https://revoked-rsa-ev.ssl.com/ - * SSL.com ECC CA - * Valid - https://test-dv-ecc.ssl.com - * Revoked - https://revoked-ecc-dv.ssl.com/ - */ -public class SSLCA { - - public static void main(String[] args) throws Exception { - - System.setProperty("jdk.security.certpath.ocspNonce", "true"); - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - boolean ocspEnabled = false; - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - ocspEnabled = true; - } - - new SSLCA_RSA().runTest(pathValidator, ocspEnabled); - new SSLCA_EV_RSA().runTest(pathValidator, ocspEnabled); - new SSLCA_ECC().runTest(pathValidator, ocspEnabled); - } -} - -class SSLCA_RSA { - - // Owner: CN=SSL.com RSA SSL subCA, O=SSL Corporation, L=Houston, ST=Texas, C=US - // Issuer: CN=SSL.com Root Certification Authority RSA, O=SSL Corporation, L=Houston, ST=Texas, C=US - // Serial number: 997ed109d1f07fc - // Valid from: Fri Feb 12 10:48:52 PST 2016 until: Wed Feb 12 10:48:52 PST 2031 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIGbzCCBFegAwIBAgIICZftEJ0fB/wwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UE\n" + - "BhMCVVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQK\n" + - "DA9TU0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZp\n" + - "Y2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYwMjEyMTg0ODUyWhcNMzEwMjEyMTg0\n" + - "ODUyWjBpMQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv\n" + - "dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjEeMBwGA1UEAwwVU1NMLmNv\n" + - "bSBSU0EgU1N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uoCyGKmh0dHA6Ly9jcmxzLnNzbC5jb20vc3NsLmNv\n" + - "bS1yc2EtUm9vdENBLmNybDAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0lBBYwFAYIKwYB\n" + - "BQUHAwEGCCsGAQUFBwMCMA0GCSqGSIb3DQEBCwUAA4ICAQAi6e/iSV5DEqDO6XjQ\n" + - "SIIzXgc255yv6Oc2sqZnvRyVBHtHvo62jMoHY3Xunc/EofbeS4aHdYBvgkn6CNTj\n" + - "VkCU+psWwcT3Pg83uP4k4Thu7bXvrClfS+XBlbJiCF/PSJxLrKnxRn+XIGiYl62H\n" + - "glBhq9K8/fZrI2Qh1mZJmWE0FlxEDCb4i8SBNi8lmDogaFi8/yl32Z9ahmhxcLit\n" + - "DU/XyKA0yOqvIrOGKH95v+/l8fQkzE1VEFvj+iyv4TXd7mRZDOsfqfIDZhrpou02\n" + - "kXH/hcXlrR++t8kjj9wt8HHQ+FkryWI6bU3KPRJR6N8EH2EHi23Rp8/kyMs+gwaz\n" + - "zMqnkNPbMME723rXk6/85sjOUaZCmhmRIx9rgqIWQesU962J0FruGOOasLT7WbZi\n" + - "FsmSblmpjUAo49sIRi7X493qegyCEAa412ynybhQ7LVsTLEPxVbdmGVih3jVTif/\n" + - "Nztr2Isaaz4LpMEo4mGCiGxec5mKr1w8AE9n6D91CvxR5/zL1VU1JCVC7sAtkdki\n" + - "vnN1/6jEKFJvlUr5/FX04JXeomIjXTI8ciruZ6HIkbtJup1n9Zxvmr9JQcFTsP2c\n" + - "bRbjaT7JD6MBidAWRCJWClR/5etTZwWwWrRCrzvIHC7WO6rCzwu69a+l7ofCKlWs\n" + - "y702dmPTKEdEfwhgLx0LxJr/Aw==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=test-dv-rsa.ssl.com - // Issuer: CN=SSL.com RSA SSL subCA, O=SSL Corporation, L=Houston, ST=Texas, C=US - // Serial number: 4ceada4ade82a6ccd0b2ae32c0dbfd62 - // Valid from: Fri Jun 28 07:06:50 PDT 2019 until: Sun Jun 27 07:06:50 PDT 2021 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIHTjCCBTagAwIBAgIQTOraSt6CpszQsq4ywNv9YjANBgkqhkiG9w0BAQsFADBp\n" + - "MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0b24x\n" + - "GDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjEeMBwGA1UEAwwVU1NMLmNvbSBSU0Eg\n" + - "U1NMIHN1YkNBMB4XDTE5MDYyODE0MDY1MFoXDTIxMDYyNzE0MDY1MFowHjEcMBoG\n" + - "A1UEAwwTdGVzdC1kdi1yc2Euc3NsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEP\n" + - "ADCCAQoCggEBAKlOrYr8fnHN8REfJDwgsBhJvnsU4beQIYYaOAzR8pmo8eq1U/K0\n" + - "uwRrgJ5K61V78zBO5qmZNiivBobViftObWrq2H6QhQsYdMYXld3SEnEotIIriRHY\n" + - "2PcqlgnFYXkqI0ZKs4kNs+j3GS0IwncJJwKtypmtLTCLK5J/kG7qB2MNfXZTIzKI\n" + - "iZza4RUM1j67Hv3fPJzNEJ9urfjaI4xcRh5airlzBWOBU9pW87P7BgQN7cNzJQji\n" + - "4DSvb1pSXv8sBbZk5fmG+81PyUxcfqj7Dbih0J1Aoq0YysHugsrK/kLz+CvqL9B2\n" + - "a1JMZfob9jzcA7XPjpggLc3az2Wvv3XKqokCAwEAAaOCAzswggM3MB8GA1UdIwQY\n" + - "MBaAFCYUfuDc16b34tQEJ99h8cLs5zLKMHwGCCsGAQUFBwEBBHAwbjBKBggrBgEF\n" + - "BQcwAoY+aHR0cDovL3d3dy5zc2wuY29tL3JlcG9zaXRvcnkvU1NMY29tLVN1YkNB\n" + - "LVNTTC1SU0EtNDA5Ni1SMS5jcnQwIAYIKwYBBQUHMAGGFGh0dHA6Ly9vY3Nwcy5z\n" + - "c2wuY29tMDcGA1UdE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EOUfq7tmQCJHMODVgz3iHrdxRB1E58nXHlZ6vUdrCo\n" + - "pD9d6Cp+AwvrOdv6MndVJgel9tVOAqAUblwdLzPNQHEcXoKnFEVv2SVQCmAYLlkP\n" + - "xX2RS73gseiit4QnVZOWi/wDhqMm7/iq8n7rL/f7+ly2+7e3LVjxd24HZkgxNgbn\n" + - "JDjYvIla+EvyrY8514Ru3Pf1UICY03VpYjE8R7SxrqcvOLtwvOVew6TuCUl6RNpl\n" + - "xeC9Oa1dgf+QRXN7LvmBXUP2nOCnwJE1ENvThPLw9BXLatVJgkA/v/mYWE5VjzIL\n" + - "hboPH2fNWemUv5QMzxUkqhgHgrhr8wnhI6xYIYciGDbmmfnItHex7bxktT7axoCD\n" + - "3dTQQe01YfK/LlkHtnBmJf/t0F33m8KXcQ51fic/TR2U5Tampxp2kdFdTyvRRqMl\n" + - "igqo3EhiPmB9bKsnXDA2AnvdjZT9uFwbUu5lNxjiMQcSZikjQAjJPgjCZ9BQOGbL\n" + - "eqgZcw2CxWMxFSTLL3TIBlNL/0GpRlTvr3IGyvHEr7EESXKD+Ar8XW+4VlMc1s8F\n" + - "cdtnus71s7wm+JUSXcM0WJUkRUvWqHlPi3Ucfe7k6x6BG9Mb42ECjorefPXvFu7v\n" + - "OT4=\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked-rsa-dv.ssl.com - // Issuer: CN=SSL.com RSA SSL subCA, O=SSL Corporation, L=Houston, ST=Texas, C=US - // Serial number: 3f527e677d00558272ac90d1620b67f4 - // Valid from: Fri Jun 28 07:13:48 PDT 2019 until: Sun Jun 27 07:13:48 PDT 2021 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIHVzCCBT+gAwIBAgIQP1J+Z30AVYJyrJDRYgtn9DANBgkqhkiG9w0BAQsFADBp\n" + - "MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0b24x\n" + - "GDAWBgNVBAoMD1NTTCBD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aPFQgu99/zAlerPUThz4O2CskOgKt77y6KOgCbBp\n" + - "7fQF6vh/aOm0Xba2Z0CtB+uVN2g4+LwyuovOy+JyjGKv7GxRKEQmGZsRLDVpxOs5\n" + - "W47K+iuOEhTRWRkStfuk2LcCLwTrgxHv2/Wo+80ME/7wxGKs1IzlkcFtFLhaeN4p\n" + - "QsmADpcyBfeWmvTdKgaVBOE2F/nenIiKpo+0jcoMAW6JgMD+otn8gofBq+Za1N4X\n" + - "xckvLWbMDAj4lELBHXu7gLHHLJCL9GGPD5HKjH/RyLtKKaRgT/AV6jl/woKTAzGF\n" + - "SPqgNQsu+sCdUbO0nDONkXDxhfan8XNrd32KMPGucJySiyjpHkurobMuGbs/LQzd\n" + - "JLTSTIIIPpEHBk7PHRGPSFewIhi0aDhupgZLU9UGrLRw/xV/KlGqTcGFWBvvOC+I\n" + - "CSZFRr0hWBv/dfw=\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Fri Jun 28 07:25:02 PDT 2019", System.out); - } -} - -class SSLCA_EV_RSA { - - // Owner: CN=SSL.com EV SSL Intermediate CA RSA R3, O=SSL Corp, L=Houston, ST=Texas, C=US - // Issuer: CN=SSL.com EV Root Certification Authority RSA R2, O=SSL Corporation, L=Houston, ST=Texas, C=US - // Serial number: 56b629cd34bc78f6 - // Valid from: Wed May 31 11:14:37 PDT 2017 until: Fri May 30 11:14:37 PDT 2042 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIG4DCCBMigAwIBAgIQA6P00GAwUqM3zjgKiDAxjDANBgkqhkiG9w0BAQsFADCB\n" + - "gjELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9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GOTh33eMzwWoRxvk6o7y73Sy6XBfycN+8LhXUZT0X8STmWtBtLSMp\n" + - "blWMjuuFyUVQvIj05N7hORY/LhdQhEx8kVwS5RkLVSpRnohdk+nI69yIA7EwZKlw\n" + - "kKEsDqlVOeDYWVWQANDC55kJ7nOyJbqtGJqImwWXdQcf37fi80cf+mKOYs5vNmkx\n" + - "D9bwFWsKnP71x0liSlv8z79vRAo8FJwTgXRNO1c0ACf0rXEJy3GRAXRWiTvuGahR\n" + - "JVM3Jnn0G6o3+vTfwa7CKR/9Jc4t25iRU3xmSgiusg4u8i5x\n" + - "-----END CERTIFICATE-----"; - - // Owner: OID.1.3.6.1.4.1.311.60.2.1.3=US, OID.1.3.6.1.4.1.311.60.2.1.2=Nevada, STREET=3100 Richmond Ave, - // OID.2.5.4.15=Private Organization, OID.2.5.4.17=77098, CN=test-ev-rsa.ssl.com, SERIALNUMBER=NV20081614243, - // O=SSL Corp, L=Houston, ST=Texas, C=US - // Issuer: CN=SSL.com EV SSL Intermediate CA RSA R3, O=SSL Corp, L=Houston, ST=Texas, C=US - // Serial number: 558089b221d7cd9c7a4bc4a7fd7e2969 - // Valid from: Mon Jul 01 13:28:01 PDT 2019 until: Wed Jun 30 13:28:01 PDT 2021 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIISTCCBjGgAwIBAgIQVYCJsiHXzZx6S8Sn/X4paTANBgkqhkiG9w0BAQsFADBy\n" + - "MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0b24x\n" + - "ETAPBgNVBAoMCFNTTCBDb3JwMS4wLAYDVQQDDCVTU0wuY29tIEVWIFNTTCBJbnRl\n" + - "cm1lZGlhdGUgQ0EgUlNBIFIzMB4XDTE5MDcwMTIwMjgwMVoXDTIxMDYzMDIwMjgw\n" + - "MVowgfExCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91\n" + - "c3RvbjERMA8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DB623Y4ccxYN5LZxjVx668/\n" + - "xj3JffaY5185qPjAqkjLUzj9TeeAJk/ws1YXbQJvO4CZV2QXrishC+dEoqvfOe/u\n" + - "sMHcMJy+cFrPhe4cC7s9fHeYTpF36yvfWrgjGwDki/9zgRhOvDuM72dIMkrcHkZi\n" + - "OvZMgyoXz/Nw3D514K9BSt6xRB2qGzI8fx0EOGzEEjX1Zdie2uVDy9aC8k8TjQAM\n" + - "v/YT7Bggpv300hWvBGw0QT8l7Nk1PZFBagAhqRCKRsR1pUZ8CyZzwNkNyUSYV4Or\n" + - "n0vYwVEgpMeSMu/ObWwWPM7QKSNcSSIV5lxmsZX+wS76OpDMHm27P94RTEePF4sG\n" + - "QmvY6hgHSlREJUL0vyGGY2Rbm3cL3zaM4qTquN18v61uUVKakELYIcRZwVTyBj5M\n" + - "KxOkjGXnLYpDOLFHD4WB1q7J+SorG43V+nbmTEN5fshGUjjWoz5ykfErnyJa1+Py\n" + - "FXWoPFb425DelhuDe94btROuJELRfzhqDXoKrhDgSQGV2qM3sk6uIPOaoH4N31ko\n" + - "C41bezSdJ5r4mif8iA==\n" + - "-----END CERTIFICATE-----"; - - // Owner: OID.1.3.6.1.4.1.311.60.2.1.3=US, OID.1.3.6.1.4.1.311.60.2.1.2=Nevada, STREET=3100 Richmond Ave, - // OID.2.5.4.15=Private Organization, OID.2.5.4.17=77098, CN=revoked-rsa-ev.ssl.com, SERIALNUMBER=NV20081614243, - // O=SSL Corp, L=Houston, ST=Texas, C=US - // Issuer: CN=SSL.com EV SSL Intermediate CA RSA R3, O=SSL Corp, L=Houston, ST=Texas, C=US - // Serial number: 1ea7f53492bded2d425135bdf525889f - // Valid from: Mon Jul 01 13:29:02 PDT 2019 until: Wed Jun 30 13:29:02 PDT 2021 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIIUzCCBjugAwIBAgIQHqf1NJK97S1CUTW99SWInzANBgkqhkiG9w0BAQsFADBy\n" + - "MQswCQYDVQQGEwJVUzE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S6BqQlmQ2jh7RhQAAAWuvQy4MAAAEAwBGMEQC\n" + - "IGFiEQ8fMrjm1bV/mbT35bvJWf4mUbb92/NkHkQvHcaQAiBcS4CclZmzQLj4w6CV\n" + - "JsLf1P6+OhCDtvxWZdndGwJRczANBgkqhkiG9w0BAQsFAAOCAgEAFwE/RMAk871D\n" + - "acLlB0Jb29+WBmCgIu1pA+bh5/lMxn5KoPxkbHPFVHlfenDgZHUNU6DKH4HdCUG7\n" + - "GSAyajLiYRkcrDtBfp5MtNUAqnOJbh2NWiJ3FgSdAjfeSXPhhGfQ3U+0YCWarBfO\n" + - "xZ49eyhTzhHMoW+caJV3jC442Ebzh2X243MwcxqIkjgzWs6duiHnpHfT9gZBl3ou\n" + - "eu85LVFwzxNdrrAx1yG9PA05wCsYYlzwx7fC8ycfbvs+2ORIztiEScyr9VCg5sho\n" + - "YGuBFuP38sWRwiV5K7+EqpGjY+4R3BLWol7lzWsqWJC1J4zkd6Df5reSGBt0wlbx\n" + - "7MdUTXzHMtP8NDIYpdMBrPbkzOKIDzO6bDMsBWWFz7rWCmxUI6sSf0yknPtmBgCd\n" + - "rJAq25V/DqSRGrkaY4Dx1CPGtwYN34fCDLxKeN69rG5mkR2w7HRR5eMXek6oi3Pr\n" + - "hQrKt5NgrYjO6HJ6ABI5xoDM9doXy9BYbz5RX43RTU399aIqyXZh0d3W0rr7wggt\n" + - "+PFRU1OJqhpPQgKsB5zFT3G2HgVBD0hawHS+0Hu+CHpngiDziH+eyvTk3tdhIq2x\n" + - "oDZXs7SSZK6hf/im+7OFSkROy6CwhAn3nxRI9lpag1tTgF4kVSctBv+301ev0twX\n" + - "0w6RymKcvEbcuSDHkzOYWxc1cqwOxjA=\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Mon Jul 01 20:53:13 PDT 2019", System.out); - } -} - -class SSLCA_ECC { - - // Owner: CN=SSL.com SSL Intermediate CA ECC R2, O=SSL Corp, L=Houston, ST=Texas, C=US - // Issuer: CN=SSL.com Root Certification Authority ECC, O=SSL Corporation, L=Houston, ST=Texas, C=US - // Serial number: 75e6dfcbc1685ba8 - // Valid from: Fri Feb 12 10:14:03 PST 2016 until: Tue Feb 12 10:14:03 PST 2041 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIDejCCAv+gAwIBAgIQHNcSEt4VENkSgtozEEoQLzAKBggqhkjOPQQDAzB8MQsw\n" + - "CQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0b24xGDAW\n" + - "BgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNvbSBSb290IENl\n" + - "cnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzAeFw0xOTAzMDcxOTQyNDJaFw0zNDAz\n" + - "MDMxOTQyNDJaMG8xCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UE\n" + - "BwwHSG91c3RvbjERMA8GA1UECgwIU1NMIENvcnAxKzApBgNVBAMMIlNTTC5jb20g\n" + - "U1NMIEludGVybWVkaWF0ZSBDQSBFQ0MgUjIwdjAQBgcqhkjOPQIBBgUrgQQAIgNi\n" + - "AASEOWn30uEYKDLFu4sCjFQ1VupFaeMtQjqVWyWSA7+KFljnsVaFQ2hgs4cQk1f/\n" + - "RQ2INSwdVCYU0i5qsbom20rigUhDh9dM/r6bEZ75eFE899kSCI14xqThYVLPdLEl\n" + - "+dyjggFRMIIBTTASBgNVHRMBAf8ECDAGAQH/AgEAMB8GA1UdIwQYMBaAFILRhXMw\n" + - "5zUE044CkvvlpNHEIejNMHgGCCsGAQUFBwEBBGwwajBGBggrBgEFBQcwAoY6aHR0\n" + - "cDovL3d3dy5zc2wuY29tL3JlcG9zaXRvcnkvU1NMY29tLVJvb3RDQS1FQ0MtMzg0\n" + - "LVIxLmNydDAgBggrBgEFBQcwAYYUaHR0cDovL29jc3BzLnNzbC5jb20wEQYDVR0g\n" + - "BAowCDAGBgRVHSAAMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATA7BgNV\n" + - "HR8ENDAyMDCgLqAshipodHRwOi8vY3Jscy5zc2wuY29tL3NzbC5jb20tZWNjLVJv\n" + - "b3RDQS5jcmwwHQYDVR0OBBYEFA10Zgpen+Is7NXCXSUEf3Uyuv99MA4GA1UdDwEB\n" + - "/wQEAwIBhjAKBggqhkjOPQQDAwNpADBmAjEAxYt6Ylk/N8Fch/3fgKYKwI5A011Q\n" + - "MKW0h3F9JW/NX/F7oYtWrxljheH8n2BrkDybAjEAlCxkLE0vQTYcFzrR24oogyw6\n" + - "VkgTm92+jiqJTO5SSA9QUa092S5cTKiHkH2cOM6m\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=test-dv-ecc.ssl.com - // Issuer: CN=SSL.com SSL Intermediate CA ECC R2, O=SSL Corp, L=Houston, ST=Texas, C=US - // Serial number: 1bfbd8e4bea894f3d1887c50e7d366d7 - // Valid from: Fri Jun 28 06:58:27 PDT 2019 until: Sun Jun 27 06:58:27 PDT 2021 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIE9TCCBHqgAwIBAgIQG/vY5L6olPPRiHxQ59Nm1zAKBggqhkjOPQQDAzBvMQsw\n" + - "CQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0b24xETAP\n" + - "BgNVBAoMCFNTTCBDb3JwMSswKQYDVQQDDCJTU0wuY29tIFNTTCBJbnRlcm1lZGlh\n" + - "dGUgQ0EgRUNDIFIyMB4XDTE5MDYyODEzNTgyN1oXDTIxMDYyNzEzNTgyN1owHjEc\n" + - "MBoGA1UEAwwTdGVzdC1kdi1lY2Muc3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lQqrUugakJZkNo4e0YUAAAFrnmqArQAABAMA\n" + - "SDBGAiEAs2yfi9e1h6dTQbe4WPd7+5qf7kvP7Vr2k0nAtBS1IgECIQCQYL9he9J4\n" + - "Bh5cpQezTVPgLAOGcf5xIcCrBs1QJe66/AB3AFWB1MIWkDYBSuoLm1c8U/DA5Dh4\n" + - "cCUIFy+jqh0HE9MMAAABa55qgaEAAAQDAEgwRgIhAI/27txsvzpbBXkMICi/UOzE\n" + - "t8uZidbF9KSwmGRPT/6gAiEAhm/VeWHDeWK8gFMU+f0/x4jK7UbzySGBvPzbPpNd\n" + - "EDwwCgYIKoZIzj0EAwMDaQAwZgIxAJKn8Hr68Z/2rA+VHfZo8eeIFaZ3nvSvQO92\n" + - "1Byl6cPAm8DsdCnYT16uNSL8Zb5IQAIxAOFLsqPDCSAYkpgutAnVgwI+c549SIRU\n" + - "k8ol+wUx6zgMmt8VHYagyj6IO0GRDjm/eA==\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=revoked-ecc-dv.ssl.com - // Issuer: CN=SSL.com SSL Intermediate CA ECC R2, O=SSL Corp, L=Houston, ST=Texas, C=US - // Serial number: 423c2b57dfa379d0c45ffceb6284ed99 - // Valid from: Fri Jun 28 07:09:30 PDT 2019 until: Sun Jun 27 07:09:30 PDT 2021 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIE+TCCBH+gAwIBAgIQQjwrV9+jedDEX/zrYoTtmTAKBggqhkjOPQQDAzBvMQsw\n" + - "CQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0b24xETAP\n" + - "BgNVBAoMCFNTTCBDb3JwMSswKQYDVQQDDCJTU0wuY29tIFNTTCBJbnRlcm1lZGlh\n" + - "dGUgQ0EgRUNDIFIyMB4XDTE5MDYyODE0MDkzMFoXDTIxMDYyNzE0MDkzMFowITEf\n" + - "MB0GA1UEAwwWcmV2b2tlZC1lY2MtZHYuc3NsLmNvbTBZMBMGBy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QaNsgiaN9kTAAABa550\n" + - "oQEAAAQDAEcwRQIhAJ3nwLI7kLP2SKicFKuJoqRYKE/FR2Ff65WL+iWxm/6nAiAJ\n" + - "cd9EKnBETwM9qQfKoSSs2oTQL4QjSKJZi/sPfKQaagB2ALvZ37wfinG1k5Qjl6qS\n" + - "e0c4V5UKq1LoGpCWZDaOHtGFAAABa550oH4AAAQDAEcwRQIhAIo6k5BMSFN3FnD4\n" + - "UFbyJJG/Bujh+OFTYzVM8vuIBoU0AiAhBe+air4wHvd68ykK6xOPv9Qshje9F6LC\n" + - "gxTqbMOEkDAKBggqhkjOPQQDAwNoADBlAjEAyayBtbcCQB0fE+cCc7OHLuNvb9tl\n" + - "uiHWy/Ika6IA72WJLLmED971ik08OMa2mGt4AjAklxdElQ5Z/nSeJ2CNEwD7pcYz\n" + - "468kkrMoGU2lk3QmwcXZscPIoh4Pwew6QteY4J0=\n" + - "-----END CERTIFICATE-----"; - - public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) throws Exception { - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Fri Jun 28 07:59:20 PDT 2019", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/TWCAGlobalCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/TWCAGlobalCA.java deleted file mode 100644 index 48c4d77a6ba24..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/TWCAGlobalCA.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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 8305975 - * @summary Interoperability tests with TWCA Global Root CA from TAIWAN-CA - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath TWCAGlobalCA OCSP - * @run main/othervm -Djava.security.debug=certpath TWCAGlobalCA CRL - */ - -/* - * Obtain TLS test artifacts for TWCA Global Root CA from: - * - * Valid TLS Certificates: - * https://evssldemo6.twca.com.tw - * - * Revoked TLS Certificates: - * https://evssldemo7.twca.com.tw - */ -public class TWCAGlobalCA { - - // Owner: CN=TWCA Global EVSSL Certification Authority, OU=Global EVSSL Sub-CA, O=TAIWAN-CA, C=TW - // Issuer: CN=TWCA Global Root CA, OU=Root CA, O=TAIWAN-CA, C=TW - // Serial number: 40013304f70000000000000cc042cd6d - // Valid from: Thu Aug 23 02:53:30 PDT 2012 until: Fri Aug 23 08:59:59 PDT 2030 - private static final String INT = "-----BEGIN CERTIFICATE-----\n" + - "MIIFdzCCA1+gAwIBAgIQQAEzBPcAAAAAAAAMwELNbTANBgkqhkiG9w0BAQsFADBR\n" + - "MQswCQYDVQQGEwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRAwDgYDVQQLEwdSb290\n" + - "IENBMRwwGgYDVQQDExNUV0NBIEdsb2JhbCBSb290IENBMB4XDTEyMDgyMzA5NTMz\n" + - "MFoXDTMwMDgyMzE1NTk1OVowczELMAkGA1UEBhMCVFcxEjAQBgNVBAoTCVRBSVdB\n" + - "Ti1DQTEcMBoGA1UECxMTR2xvYmFsIEVWU1NMI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VlWHN0zJAX232fdoZmnajl8gtj\n" + - "u0AOOyDDJ7Vlh38rDMRlX/u+MS2DFcsq5Vd3EMwJsWWFR9D3Dcey+Tu9uEmEdqeB\n" + - "+Erd4YjCeV9PyOW3SzPQ47RdW6XYmHArPh65/LcmSxTn/lxQy/NEBGGWqhm6s6n1\n" + - "49mPq4MtQcMLo/NBI+8jv7BVjnThbbEh2edHHxMNiAd5kLZFDCyJuFkoezjWL4AH\n" + - "ratXdoHtqvqtPoy97LyGrLrJeh+0hkO9u8QOt2gF7BEhNfid7o5dnsPRk+8l77Hn\n" + - "T1dvBs++M0r0QG4AWMSMj9uUn6rhl4FGTvAsyB1fA8p/xCLoIEetIpKRP3BD+ve2\n" + - "eYjWPorR/0W77iMTeoQEeuxDIxi2J/U9QLKKvzzqBy1TYrqqPe5YxqHLNAcfHZvo\n" + - "BTPPbtP0WAiXrJiELTYcqFXETvQcGw0XjoUZNvJE8RD7vssSNT17RKU8iBRX7CbL\n" + - "AB3T8gYykPMJTUqQSmdgEdVRBcqRMMdU+XRAEoU/Mz5oHAkm3ZNTDNwsEp2Dg1/b\n" + - "qzfPMhg4/3/YyWzGrzNeCSWZkjYImAzLCvN0D5rbdVHEmFIrEJt+igocGozroq5x\n" + - "DT5KhixlrqexzWE=\n" + - "-----END CERTIFICATE-----"; - - // Owner: OID.2.5.4.17=100, STREET="10F.,NO.85,Yanping S. Rd.,Taipei City 100,Taiwan (R.O.C)", - // SERIALNUMBER=70759028, OID.1.3.6.1.4.1.311.60.2.1.3=TW, OID.1.3.6.1.4.1.311.60.2.1.2=Taiwan, - // OID.1.3.6.1.4.1.311.60.2.1.1=Taipei, OID.2.5.4.15=Private Organization, - // CN=evssldemo6.twca.com.tw, O=TAIWAN-CA INC., L=Taipei, ST=Taiwan, C=TW - // Issuer: CN=TWCA Global EVSSL Certification Authority, OU=Global EVSSL Sub-CA, - // O=TAIWAN-CA, C=TW - // Serial number: 47e70000001258ff71d89af7f0353fef - // Valid from: Thu Mar 02 00:49:56 PST 2023 until: Sun Mar 31 08:59:59 PDT 2024 - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIH7zCCBtegAwIBAgIQR+cAAAASWP9x2Jr38DU/7zANBgkqhkiG9w0BAQsFADBz\n" + - "MQswCQYDVQQGEwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRwwGgYDVQQLExNHbG9i\n" + - "YWwgRVZTU0wgU3ViLUNBMTIwMAYDVQQDEylUV0NBIEdsb2JhbCBFVlNTTCBDZXJ0\n" + - "aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0yMzAzMDIwODQ5NTZaFw0yNDAzMzExNTU5\n" + - "NTlaMIIBMzELMAkGA1UEBhMCVFcxDzANBgNVBAgTBlRhaXdhbjEPMA0GA1UEBxMG\n" + - "VGFpcGVpMRcwFQYDVQQKEw5UQUlXQU4tQ0EgSU5DLjEfMB0GA1UEAxMWZXZzc2xk\n" + - "ZW1vNi50d2NhLmNvbS50dzEdMBsGA1UEDxMUUHJpdmF0ZSBPcmdhbml6YXRpb24x\n" + - "FzAVBgsrBgEEAYI3PAIBARMGVGFpcGVpMRcwFQYLKwYBBAGCNzwCAQITBlRhaXdh\n" + - "bjETMBEGCysGAQQBgjc8AgEDEwJUVzERMA8GA1UEBRMINzA3NTkwMjgxQTA/BgNV\n" + - "BAkTODEwRi4sTk8uODUsWWFucGluZyBTLiBSZC4sVGFpcGVpIENpdHkgMTAwLFRh\n" + - "aXdhbiAoUi5PLkMpMQwwCgYDVQQREwMxMDAwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n" + - "DwAwggEKAoIBAQDEgj/jtcAtGPkiBilLajzHIqfiAxpwwnKhdHwyOnqfcqur1p2R\n" + - "Cxl0Q8jYGmY8ZUq7716XnIGN3bn3Wu10BvmHi07h8f54/G/K7xBKjkasAh44zW1P\n" + - "hgdaxH0huRvoQOoSRCitew8YpMN4B++uOQ8yu2pWDGDdQHW4VaWt/e+QtZbQtp/b\n" + - "7vUWgcuhxD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AFWB1MIWkDYBSuoLm1c8U/DA5Dh4cCUIFy+jqh0HE9MMAAABhqGD\n" + - "iJYAAAQDAEcwRQIgIHKa+XeYyDURUq9AVYEntGS5oJitKyWZjSOlpD+udZgCIQC/\n" + - "oVPtjJpcXP4OScYFsNWMPKUtZOO5mY5y7V65S84DrQB2ADtTd3U+LbmAToswWwb+\n" + - "QDtn2E/D9Me9AA0tcm/h+tQXAAABhqGDh8YAAAQDAEcwRQIgYT7aPr9YCtF5TCTp\n" + - "NICK9c5eiL6Ku/y9wM6ARgG2k1UCIQDomqlwGur+AMI4YIc1SNqyNVCyxgP1DxXP\n" + - "FYkX6BX17gB2AO7N0GTV2xrOxVy3nbTNE6Iyh0Z8vOzew1FIWUZxH7WbAAABhqGD\n" + - "iKkAAAQDAEcwRQIhAKTMliyTn48vvP9hN8jucD6rGZwRCqQI6suE6ADpN7bNAiB3\n" + - "zFZFdH8eJRn3RXjD/mzbmF201sNLitp9SOYAazubljANBgkqhkiG9w0BAQsFAAOC\n" + - "AQEAOOtzqtRFvxlJro61O0dEkDottToFh88vib3N3AofS5uW0nDpoS0L27XR8IDd\n" + - "2NfN+2XKAQXdz2BqHnjW1nAMXUx4TAMi4jG8XpOkvpSDXbjghD5EB10FyAzCuGmv\n" + - "mKxkVOU1DzL0kSLLQjLaJ57WUYsoE97f5O6rY9jlJpid32o1WgM1oZsBjPhO8Kiy\n" + - "KJ5zZHppolGPtuFYMUcatiqv//pH/5piwtlYSkbwMj5nYidSrSBciBzO53HFk1pE\n" + - "TABXFcoK3gmhWM04lysmJMwAzRUbNQVizpGDICbRjCOVnwCbutnSnka8pDHkq4Zy\n" + - "BrUeZe2xJe8jWvukwqvNzIIvwg==\n" + - "-----END CERTIFICATE-----"; - - // Owner: OID.2.5.4.17=100, STREET="10F.,NO.85,Yanping S. Rd.,Taipei City 100,Taiwan (R.O.C)", - // SERIALNUMBER=70759028, OID.1.3.6.1.4.1.311.60.2.1.3=TW, OID.1.3.6.1.4.1.311.60.2.1.2=Taiwan, - // OID.1.3.6.1.4.1.311.60.2.1.1=Taipei, OID.2.5.4.15=Private Organization, - // CN=evssldemo7.twca.com.tw, O=TAIWAN-CA INC., L=Taipei, ST=Taiwan, C=TW - // Issuer: CN=TWCA Global EVSSL Certification Authority, OU=Global EVSSL Sub-CA, - // O=TAIWAN-CA, C=TW - // Serial number: 47e70000001258f036a5b513091ccb2e - // Valid from: Tue Feb 07 02:03:08 PST 2023 until: Thu Mar 07 07:59:59 PST 2024 - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIHdjCCBl6gAwIBAgIQR+cAAAASWPA2pbUTCRzLLjANBgkqhkiG9w0BAQsFADBz\n" + - "MQswCQYDVQQGEwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRwwGgYDVQQLExNHbG9i\n" + - "YWwgRVZTU0wgU3ViLUNBMTIwMAYDVQQDEylUV0NBIEdsb2JhbCBFVlNTTCBDZXJ0\n" + - "aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0yMzAyMDcxMDAzMDhaFw0yNDAzMDcxNTU5\n" + - "NTlaMIIBMzELMAkGA1UEBhMCVFcxDzANBgNVBAgTBlRhaXdhbjEPMA0GA1UEBxMG\n" + - "VGFpcGVpMRcwFQYDVQQKEw5UQUlXQU4tQ0EgSU5DLjEfMB0GA1UEAxMWZXZzc2xk\n" + - "ZW1vNy50d2NhLmNvbS50dzEdMBsGA1UEDxMUUHJpdmF0ZSBPcmdhbml6YXRpb24x\n" + - "FzAVBgsrBgEEAYI3PAIBARMGVGFpcGVpMRcwFQYLKwYBBAGCNzwCAQITBlRhaXdh\n" + - "bjETMBEGCysGAQQBgjc8AgEDEwJUVzERMA8GA1UEBRMINzA3NTkwMjgxQTA/BgNV\n" + - "BAkTODEwRi4sTk8uODUsWWFucGluZyBTLiBSZC4sVGFpcGVpIENpdHkgMTAwLFRh\n" + - "aXdhbiAoUi5PLkMpMQwwCgYDVQQREwMxMDAwggEiMA0GCSqGSIb3DQEBAQU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HAwIwggF9BgorBgEEAdZ5AgQCBIIBbQSCAWkBZwB2AFWB1MIWkDYBSuoLm1c8\n" + - "U/DA5Dh4cCUIFy+jqh0HE9MMAAABhitUR1YAAAQDAEcwRQIhANv7DhQm67R1Ilmg\n" + - "k5StrFQ1dqyELzZTAT3on84g0G/vAiAttP+EWWmztK2luQ7SxvQsmExDh/qGiZHq\n" + - "NAd2a8dUIgB1AO7N0GTV2xrOxVy3nbTNE6Iyh0Z8vOzew1FIWUZxH7WbAAABhitU\n" + - "RycAAAQDAEYwRAIgcU5n4DJaGWvTr3wZug59ItynMgCZ5z0ZVrZr2KwV70wCIHEv\n" + - "DAwNBLGsdj5IX/4E5hnzJvS7WroSLnRB6OW931JbAHYAdv+IPwq2+5VRwmHM9Ye6\n" + - "NLSkzbsp3GhCCp/mZ0xaOnQAAAGGK1RKDwAABAMARzBFAiBvlIvOnE8PhYJQueMh\n" + - "AOCwgREvnAsk3Edt59lcuqPrrQIhAOSRb3UmBYkHQ6k5pUJva0Mgk0GmnLR0de0s\n" + - "VxW3TTASMA0GCSqGSIb3DQEBCwUAA4IBAQAQB7oaouXBI6VpLzL+kzOZXSTbSClv\n" + - "LS33DTEBI3A8LTXHbFq6c4/ZdqieUzy42Kd0i9e3hI1hwQYPgEwxpROOcldX72r0\n" + - "EUTh0L+XrxN3YEgod6aCsjIiJlWYy6J2ZXVURnk/iWYAwYLa0JmmBGuWFjEnq4lO\n" + - "xL1C3M2mYAEC+Beb7Xyq1rcu97p4P8igJYM+VfwXNwYYRCXUr9f4ESD7t5vXlYoE\n" + - "c4m5KiBQD9XtZS77QRon9JCQklxTvMkxuLwWvSdzicEUzWeFp+kN/fcXL2SVsb17\n" + - "xDPMMsMMh7L/f+uMWDYZ+wH17LYQxOLi7VXT3fv8nl2X2iD3d4CCh0Tu\n" + - "-----END CERTIFICATE-----"; - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - } - - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Thu Mar 23 17:30:19 PDT 2023", System.out); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/TeliaSoneraCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/TeliaSoneraCA.java deleted file mode 100644 index 3dc0c94abc266..0000000000000 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/TeliaSoneraCA.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8210432 - * @summary Interoperability tests with TeliaSonera Root CA v1 - * @build ValidatePathWithParams - * @run main/othervm -Djava.security.debug=certpath TeliaSoneraCA OCSP - * @run main/othervm -Djava.security.debug=certpath TeliaSoneraCA CRL - */ - -/* - * Obtain TLS test artifacts for TeliaSonera Root CA v1 from: - * - * Valid TLS Certificates: - * https://juolukka.cover.sonera.net:10443/ - * - * Revoked TLS Certificates: - * https://juolukka.cover.sonera.net:10444/ - */ -public class TeliaSoneraCA { - - // Owner: CN=TeliaSonera Server CA v2, O=TeliaSonera, C=FI - // Issuer: CN=TeliaSonera Root CA v1, O=TeliaSonera - private static final String INT = "-----BEGIN CERTIFICATE-----\n" - + "MIIHHjCCBQagAwIBAgIQTEYq9tv794BPhMF8/qlytjANBgkqhkiG9w0BAQsFADA3\n" - + "MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwWVGVsaWFTb25lcmEgUm9v\n" - + "dCBDQSB2MTAeFw0xNDEwMTYwODA5NTdaFw0zMjEwMTYwNTA0MDBaMEYxCzAJBgNV\n" - + "BAYTAkZJMRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEhMB8GA1UEAwwYVGVsaWFTb25l\n" - + "cmEgU2VydmVyIENBIHYyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA\n" - + "rwQN5rfRLbVAiYWLJF9SI4YLm8oqrtf8OjGybgoLyiMIo8nhY/atuGRFWCQNOnUK\n" - + "caZn29C360PlC5yYrsrSHuouROisqHSJcgA7HvV+37Rcry7daeDj6rfyx4yI5dmj\n" - + "LwHkK0j1NzhX1JxFDgPeLNuebgzv/j8OfRhYK/BttpystC4Zgm3gZheKDjYsDS5D\n" - + "gjffuOysP3vewrcuw0EIZFx+HawuwNBLq4tMf4VSitYDHJSLIM2TeXZGGY5slTbT\n" - + "yLnrU5mIzG9WKqxyy7qHuFw1JtlAXkCLmUEVaF9M+dRPiGIjlDrpBgbDD9mT2CSk\n" - + "V/XG1696/voY5xB8KNIC1cOSmSO7kdJyR5tWiDIJiwMXrTwG+kZiqlbcKDsZeJ9p\n" - + "5bZxXO0pEpde3wgEYRvFr5Cx4vcz4h5pom9coJOCW9tqXU43KcueTrt4Ks9f92q1\n" - + "ehjyEnCh0BCdrjUOXsUtFosm9qxJnDwVlThYhS9EHuCTNBgj1Yxj6A+8fwwJP9DN\n" - + "C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CbUdyVzumfQnU24Sce92oMtEfyuxIOmhvoXU7LpnYlH3Q29UGP5dL0D3edGz\n" - + "HeU6Tf8bkcOEHtnTrkd+y+rfFSDWYl9r1y993NAcrBHhroQCE53mlrO7TjXa3zDq\n" - + "6LGR8T8VgvGw0IBz6mzAks0wMYB0b4uREPmWXi+m+RqG3lnpl+eBzz6YVLkxIYMq\n" - + "QIXJIBsu4/ybmadsfdql6E8Lo3dKVD4UG10mtd+iPbJiBiW/a9VbEe3NVKIv4H2y\n" - + "HqYcxDXAeUI66E3K2cjCmKoQaa0Ywt02ikZFd0v1OWNPS7YWbEJWkVR1PcPMESK9\n" - + "6HKI4xhG2tJesmXjQ8q8aSx2u79Zts3ewjKqTmurf6FXW3u9TpSCUe6Drr/3X7Ve\n" - + "nBy4M0sLwCecD/L9gjTa+EItQTYzCkpxiMO49tQdX/BpwgWju4Kg3qkaBNTzvSlk\n" - + "gdnRJqCUkVuzwK4yBqUoyRz3prlhvvRGdZJKf6IXRDhncpey5pm0PQYQ4cArx7Go\n" - + "AaAKz0ZTHOKjnM2KIdUhBJQybL7oPklSfkeMWoUoYED6R4YMTt/JXX4ixEb5DgDJ\n" - + "0F+bNcF7qGrJTkTx0Ccy4BuuY05hJckd72E7WdmjN7DDeosghgWZNV/6D7N5tfxo\n" - + "nlU=\n" - + "-----END CERTIFICATE-----"; - - // Owner: CN=juolukka.cover.sonera.net, OU=security, O=Telia Finland Oyj, L=helsinki, C=FI - // Issuer: CN=TeliaSonera Server CA v2, O=TeliaSonera, C=FI - private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + - "MIIHiDCCBXCgAwIBAgIPAWOq14hk136UDQY3WSjLMA0GCSqGSIb3DQEBCwUAMEYx\n" + - "CzAJBgNVBAYTAkZJMRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEhMB8GA1UEAwwYVGVs\n" + - "aWFTb25lcmEgU2VydmVyIENBIHYyMB4XDTE4MDUyOTA3NDA0MVoXDTE5MDUyOTA3\n" + - "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1VocQXKkWMHQ7AfWNnOGzb7B1qg7gsw0n\n" + - "axqinyCjkhMpHpcVtmD9Pi15HLFDIy9yI2S+FHJQfhUSmM/LdCWzQpnee6/Wo+uw\n" + - "p0Jg2v6v9GGaqfpuiVJPFN9dOv3OjMU7DL5lgMRWFRo2T8+wBHXDyBhT0W0y5kRJ\n" + - "eWA7t6CnkziHuaOihZAHUH3nn5exjqUFVS0ThbF6hxN7HAlq/xIbTKlZjkLlc14W\n" + - "fB8vkxJyy/tgBZ4dCj9Y1Y32d4eFT5JZJgqgkN59SmX56BswNXncGrk/vWZFFx+g\n" + - "9dgb8QSe8KseD1iSLc7SsqVDv8NPYdaI3eZ90W8Wv0/CDls321O6UbAmURzQwFGB\n" + - "w8WnteoVBi6Wf6M1TxIfJsXBYeIN0BB6AYc8cmZIOtx2C8aH4JJT45MyFnBv3ac5\n" + - "Ahs9pGn/+K+5yb2e\n" + - "-----END CERTIFICATE-----"; - - // Owner: CN=juolukka.cover.sonera.net, OU=Security, O=TeliaSonera Finland, L=Helsinki, C=FI - // Issuer: CN=TeliaSonera Server CA v2, O=TeliaSonera, C=FI - private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + - "MIIGEDCCA/igAwIBAgIRAKWJTjs6v04ZTyb2wJxfnJswDQYJKoZIhvcNAQELBQAw\n" + - "RjELMAkGA1UEBhMCRkkxFDASBgNVBAoMC1RlbGlhU29uZXJhMSEwHwYDVQQDDBhU\n" + - "ZWxpYVNvbmVyYSBTZXJ2ZXIgQ0EgdjIwHhcNMTYxMjIzMDcwMTQ2WhcNMTkxMjIz\n" + - "MDcwMTQ2WjB1MQswCQYDVQQGEwJGSTERMA8GA1UEBwwISGVsc2lua2kxHDAaBgNV\n" + - "BAoME1RlbGlhU29uZXJhIEZpbmxhbmQxETAPBgNVBAsMCFNlY3VyaXR5MSIwIAYD\n" + - "VQQDDBlqdW9sdWtrYS5jb3Zlci5zb25lcmEubmV0MIIBIjANBgkqhkiG9w0BAQEF\n" + - "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JezANBgkqhkiG9w0BAQsFAAOCAgEASRK1l1MZb/IRlyi+\n" + - "XjfZcxJdFuNzW2kpZstW6Ni2XiD3p7aROBfDFtu7GajzZHb6p76auDb4NwJgeE/3\n" + - "6gnXoIK00HwpF2RAhxDpkF8r3q0jSqGhSv/xz9Nx7JBzgqfSw3Ha4ohioIed3uc+\n" + - "nMDyvVenio4GYgtxIIubSybCxMv/lBA/S4daIVCYK3VOoBbM2F36ecAKvRU5vIWM\n" + - "urXsfANL3u4qgJpaM0DclzFsOkVsRPffzToko/Nr6pGXYjt47IzTRlwLMnLehoZW\n" + - "ZZMGMVVOlR7XGf81UjWB6OsKeoQ4FWgcb/rIJcZusm+LqvnsCHuC3gtuC2nGA7lr\n" + - "fseUlG7QZN9/QfUIyvL69wAzeVj1cUcd7GHcAH9DyZJfI8orv4PyUvitDdgISkFu\n" + - "GZ562O7cGmCv00/6I4t0z9wZal8a5lRDoKXAYy+u/adrO1JjLwi11y/DTw9LQ7sJ\n" + - "gVP/v2GsI0ajF9A6z33UHN9uxXZVmQNvOiMkcJiGLovFgu5zxoAg2W3pHjbBbeL8\n" + - "v5MPqgsKafgzaSRtXBBvaISHi9hhRR8v/qSwO3NyLm8uAhQD4x+OPHrmQ/s16j45\n" + - "Ib53UHj1k6byXGUqDgzFBsmEPV6Shf2C4/HcRHpAX8wQx3xVwDtRzDpNUR6vnNfi\n" + - "PwzRU1xsQKd8llmgl4l+fYV0tBA=\n" + - "-----END CERTIFICATE-----"; - - public static void main(String[] args) throws Exception { - - ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); - - if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { - pathValidator.enableCRLCheck(); - } else { - // OCSP check by default - pathValidator.enableOCSPCheck(); - } - - // Validate valid - pathValidator.validate(new String[]{VALID, INT}, - ValidatePathWithParams.Status.GOOD, null, System.out); - - // Validate Revoked - pathValidator.validate(new String[]{REVOKED, INT}, - ValidatePathWithParams.Status.REVOKED, - "Thu Dec 22 23:14:55 PST 2016", System.out); - - // reset validation date back to current date - pathValidator.resetValidationDate(); - } -} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ValidatePathWithURL.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ValidatePathWithURL.java new file mode 100644 index 0000000000000..5d18b599c6510 --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ValidatePathWithURL.java @@ -0,0 +1,229 @@ +/* + * 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 jtreg.SkippedException; + +import javax.net.ssl.*; +import javax.security.auth.x500.X500Principal; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URL; +import java.security.*; +import java.security.cert.*; +import java.security.cert.Certificate; + +public class ValidatePathWithURL { + + private final X509Certificate rootCertificate; + private final X500Principal rootPrincipal; + + /** + * Enables the certificate revocation checking and loads the certificate from + * cacerts file for give caAlias + * + * @param caAlias CA alias for CA certificate in cacerts file + * @throws Exception when fails to get CA certificate from cacerts file + */ + public ValidatePathWithURL(String caAlias) throws Exception { + System.setProperty("com.sun.net.ssl.checkRevocation", "true"); + Security.setProperty("ssl.TrustManagerFactory.algorithm", "SunPKIX"); + + // some test sites don't have correct hostname specified in test certificate + HttpsURLConnection.setDefaultHostnameVerifier(new CustomHostnameVerifier()); + + String FS = System.getProperty("file.separator"); + String CACERTS_STORE = + System.getProperty("test.jdk") + FS + "lib" + FS + "security" + FS + "cacerts"; + + KeyStore cacerts = KeyStore.getInstance("PKCS12"); + try (FileInputStream fis = new FileInputStream(CACERTS_STORE)) { + cacerts.load(fis, null); + } + + rootCertificate = (X509Certificate) cacerts.getCertificate(caAlias); + rootPrincipal = rootCertificate.getSubjectX500Principal(); + } + + /** + * Enable revocation checking using OCSP and disables CRL check + */ + public static void enableOCSPOnly() { + System.setProperty("com.sun.security.enableCRLDP", "false"); + Security.setProperty("ocsp.enable", "true"); + } + + /** + * Enable revocation checking using CRL + */ + public static void enableCRLOnly() { + System.setProperty("com.sun.security.enableCRLDP", "true"); + Security.setProperty("ocsp.enable", "false"); + } + + /** + * Enable revocation checking using OCSP or CRL + */ + public static void enableOCSPAndCRL() { + System.setProperty("com.sun.security.enableCRLDP", "true"); + Security.setProperty("ocsp.enable", "true"); + } + + /** + * Logs revocation settings + */ + public static void logRevocationSettings() { + System.out.println("====================================================="); + System.out.println("CONFIGURATION"); + System.out.println("====================================================="); + System.out.println("http.proxyHost :" + System.getProperty("http.proxyHost")); + System.out.println("http.proxyPort :" + System.getProperty("http.proxyPort")); + System.out.println("https.proxyHost :" + System.getProperty("https.proxyHost")); + System.out.println("https.proxyPort :" + System.getProperty("https.proxyPort")); + System.out.println("https.socksProxyHost :" + + System.getProperty("https.socksProxyHost")); + System.out.println("https.socksProxyPort :" + + System.getProperty("https.socksProxyPort")); + System.out.println("jdk.certpath.disabledAlgorithms :" + + Security.getProperty("jdk.certpath.disabledAlgorithms")); + System.out.println("com.sun.security.enableCRLDP :" + + System.getProperty("com.sun.security.enableCRLDP")); + System.out.println("ocsp.enable :" + Security.getProperty("ocsp.enable")); + System.out.println("====================================================="); + } + + /** + * Validates end entity certificate used in provided test URL using + * HttpsURLConnection. Validation is skipped on network error or if + * the certificate is expired. + * + * @param testURL URL to validate + * @param revokedCert if true then validate is REVOKED certificate + * @throws Exception on failure to validate certificate + */ + public void validateDomain(final String testURL, + final boolean revokedCert) + throws Exception { + System.out.println(); + System.out.println("===== Validate " + testURL + "====="); + if (!validateDomainCertChain(testURL, revokedCert)) { + throw new RuntimeException("Failed to validate " + testURL); + } + System.out.println("======> SUCCESS"); + } + + private boolean validateDomainCertChain(final String testURL, + final boolean revokedCert) + throws Exception { + HttpsURLConnection httpsURLConnection = null; + try { + URL url = new URL(testURL); + httpsURLConnection = (HttpsURLConnection) url.openConnection(); + httpsURLConnection.setInstanceFollowRedirects(false); + httpsURLConnection.connect(); + + // certain that test certificate anchors to trusted CA for VALID certificate + // if the connection is successful + Certificate[] chain = httpsURLConnection.getServerCertificates(); + httpsURLConnection.disconnect(); + validateAnchor(chain); + } catch (SSLHandshakeException e) { + System.out.println("SSLHandshakeException: " + e.getMessage()); + Throwable cause = e.getCause(); + + while (cause != null) { + if (cause instanceof CertPathValidatorException cpve) { + if (cpve.getReason() == CertPathValidatorException.BasicReason.REVOKED + || cpve.getCause() instanceof CertificateRevokedException) { + System.out.println("Certificate is revoked"); + + // We can validate anchor for revoked certificates as well + Certificate[] chain = cpve.getCertPath().getCertificates().toArray(new Certificate[0]); + validateAnchor(chain); + + if (revokedCert) { + return true; + } + } else if (cpve.getReason() == CertPathValidatorException.BasicReason.EXPIRED + || cpve.getCause() instanceof CertificateExpiredException) { + System.out.println("Certificate is expired"); + throw new SkippedException("Certificate is expired, skip the test"); + } + break; + } + cause = cause.getCause(); + } + + throw new RuntimeException("Unhandled exception", e); + } catch (SSLException e) { + // thrown if root CA is not included in cacerts + throw new RuntimeException(e); + } catch (IOException e) { + throw new SkippedException("Network setup issue, skip this test", e); + } finally { + if (httpsURLConnection != null) { + httpsURLConnection.disconnect(); + } + } + + return !revokedCert; + } + + private void validateAnchor(Certificate[] chain) throws Exception { + X509Certificate interCert = null; + + // fail if there is no intermediate CA or self-signed + if (chain.length < 2) { + throw new RuntimeException("Cert chain too short " + chain.length); + } else { + System.out.println("Finding intermediate certificate issued by CA"); + for (Certificate cert : chain) { + if (cert instanceof X509Certificate certificate) { + System.out.println("Checking: " + certificate.getSubjectX500Principal()); + System.out.println("Issuer: " + certificate.getIssuerX500Principal()); + if (certificate.getIssuerX500Principal().equals(rootPrincipal)) { + interCert = certificate; + break; + } + } + } + } + + if (interCert == null) { + throw new RuntimeException("Intermediate Root CA not found in the chain"); + } + + // validate intermediate CA signed by root CA under test + System.out.println("Found intermediate root CA: " + interCert.getSubjectX500Principal()); + System.out.println("intermediate CA Issuer: " + interCert.getIssuerX500Principal()); + interCert.verify(rootCertificate.getPublicKey()); + System.out.println("Verified: Intermediate CA signed by test root CA"); + } + + private static class CustomHostnameVerifier implements HostnameVerifier { + @Override + public boolean verify(String hostname, SSLSession session) { + // Allow any hostname + return true; + } + } +} From 174c32911d3ca563e98f0303b5eee45d66f97ece Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 29 Sep 2023 09:54:35 +0000 Subject: [PATCH 169/341] 8296437: NMT incurs costs if disabled Backport-of: 9f8b6d2aa6733efb69d2d4f7e5f9e09dc5df9800 --- src/hotspot/share/services/memTracker.hpp | 4 +-- .../share/utilities/nativeCallStack.cpp | 1 + .../share/utilities/nativeCallStack.hpp | 28 ++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/services/memTracker.hpp b/src/hotspot/share/services/memTracker.hpp index 1c81c3f7928bc..41d93dd294ea7 100644 --- a/src/hotspot/share/services/memTracker.hpp +++ b/src/hotspot/share/services/memTracker.hpp @@ -88,9 +88,9 @@ class MemTracker : AllStatic { #include "services/virtualMemoryTracker.hpp" #define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail) ? \ - NativeCallStack(0) : NativeCallStack::empty_stack()) + NativeCallStack(0) : FAKE_CALLSTACK) #define CALLER_PC ((MemTracker::tracking_level() == NMT_detail) ? \ - NativeCallStack(1) : NativeCallStack::empty_stack()) + NativeCallStack(1) : FAKE_CALLSTACK) class MemBaseline; diff --git a/src/hotspot/share/utilities/nativeCallStack.cpp b/src/hotspot/share/utilities/nativeCallStack.cpp index 2dff574bfe797..4beae375953ab 100644 --- a/src/hotspot/share/utilities/nativeCallStack.cpp +++ b/src/hotspot/share/utilities/nativeCallStack.cpp @@ -77,6 +77,7 @@ void NativeCallStack::print_on(outputStream* out) const { // Decode and print this call path void NativeCallStack::print_on(outputStream* out, int indent) const { + DEBUG_ONLY(assert_not_fake();) address pc; char buf[1024]; int offset; diff --git a/src/hotspot/share/utilities/nativeCallStack.hpp b/src/hotspot/share/utilities/nativeCallStack.hpp index 8387a1ce25977..9c6957e5ec942 100644 --- a/src/hotspot/share/utilities/nativeCallStack.hpp +++ b/src/hotspot/share/utilities/nativeCallStack.hpp @@ -57,7 +57,29 @@ class NativeCallStack : public StackObj { private: address _stack[NMT_TrackingStackDepth]; static const NativeCallStack _empty_stack; + public: + + enum class FakeMarker { its_fake }; +#ifdef ASSERT + static constexpr uintptr_t _fake_address = -2; // 0xFF...FE + inline void assert_not_fake() const { + assert(_stack[0] != (address)_fake_address, "Must not be a fake stack"); + } +#endif + + // This "fake" constructor is only used in the CALLER_PC and CURRENT_PC macros + // when NMT is off or in summary mode. In these cases, it does not need a + // callstack, and we can leave the constructed object uninitialized. That will + // cause the constructor call to be optimized away (see JDK-8296437). + explicit NativeCallStack(FakeMarker dummy) { +#ifdef ASSERT + for (int i = 0; i < NMT_TrackingStackDepth; i++) { + _stack[i] = (address)_fake_address; + } +#endif + } + // Default ctor creates an empty stack. // (it may make sense to remove this altogether but its used in a few places). NativeCallStack() { @@ -65,12 +87,13 @@ class NativeCallStack : public StackObj { } explicit NativeCallStack(int toSkip); - NativeCallStack(address* pc, int frameCount); + explicit NativeCallStack(address* pc, int frameCount); static inline const NativeCallStack& empty_stack() { return _empty_stack; } // if it is an empty stack inline bool is_empty() const { + DEBUG_ONLY(assert_not_fake();) return _stack[0] == NULL; } @@ -92,6 +115,7 @@ class NativeCallStack : public StackObj { // Helper; calculates a hash value over the stack frames in this stack unsigned int calculate_hash() const { + DEBUG_ONLY(assert_not_fake();) uintptr_t hash = 0; for (int i = 0; i < NMT_TrackingStackDepth; i++) { hash += (uintptr_t)_stack[i]; @@ -103,4 +127,6 @@ class NativeCallStack : public StackObj { void print_on(outputStream* out, int indent) const; }; +#define FAKE_CALLSTACK NativeCallStack(NativeCallStack::FakeMarker::its_fake) + #endif // SHARE_UTILITIES_NATIVECALLSTACK_HPP From 003f4f4f25e53405a3ba1f0c20ff695202230f79 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 3 Oct 2023 19:54:35 +0000 Subject: [PATCH 170/341] 8271829: mark hotspot runtime/Throwable tests which ignore external VM flags Backport-of: 659498a07f5be0feae26c1772a6b4e8ad2dec103 --- test/hotspot/jtreg/runtime/Throwable/StackTraceLogging.java | 3 ++- .../hotspot/jtreg/runtime/Throwable/TestCatchThrowableOOM.java | 1 + .../jtreg/runtime/Throwable/TestMaxJavaStackTraceDepth.java | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/Throwable/StackTraceLogging.java b/test/hotspot/jtreg/runtime/Throwable/StackTraceLogging.java index c86da3a2c29d8..1482037b28f29 100644 --- a/test/hotspot/jtreg/runtime/Throwable/StackTraceLogging.java +++ b/test/hotspot/jtreg/runtime/Throwable/StackTraceLogging.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8150778 * @summary check stacktrace logging + * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/Throwable/TestCatchThrowableOOM.java b/test/hotspot/jtreg/runtime/Throwable/TestCatchThrowableOOM.java index 3aabb37323eec..36fedc0bd2dda 100644 --- a/test/hotspot/jtreg/runtime/Throwable/TestCatchThrowableOOM.java +++ b/test/hotspot/jtreg/runtime/Throwable/TestCatchThrowableOOM.java @@ -25,6 +25,7 @@ * @test * @bug 8267118 * @summary Test catching Throwable doesn't trigger OOME + * @requires vm.flagless * @library /test/lib * @run driver TestCatchThrowableOOM */ diff --git a/test/hotspot/jtreg/runtime/Throwable/TestMaxJavaStackTraceDepth.java b/test/hotspot/jtreg/runtime/Throwable/TestMaxJavaStackTraceDepth.java index 7862b4df6e4a7..92e5771860889 100644 --- a/test/hotspot/jtreg/runtime/Throwable/TestMaxJavaStackTraceDepth.java +++ b/test/hotspot/jtreg/runtime/Throwable/TestMaxJavaStackTraceDepth.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 7179701 * @summary MaxJavaStackTraceDepth of zero is not handled correctly/consistently in the VM + * @requires vm.flagless * @modules java.base/jdk.internal.misc:open * @modules java.base/java.lang:open * @library /test/lib From 644e410269d7b494ab0d6c0fbc7a0fd2d99cfdc6 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 3 Oct 2023 20:06:10 +0000 Subject: [PATCH 171/341] 8271828: mark hotspot runtime/classFileParserBug tests which ignore external VM flags Backport-of: e49b7d958c1db70c452cb6c47c885b7e6264b822 --- .../jtreg/runtime/classFileParserBug/ClassFileParserBug.java | 3 ++- .../classFileParserBug/TestBadPackageWithInterface.java | 3 ++- .../classFileParserBug/TestEmptyBootstrapMethodsAttr.java | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/classFileParserBug/ClassFileParserBug.java b/test/hotspot/jtreg/runtime/classFileParserBug/ClassFileParserBug.java index a43043f55688e..31dde4d3adf6c 100644 --- a/test/hotspot/jtreg/runtime/classFileParserBug/ClassFileParserBug.java +++ b/test/hotspot/jtreg/runtime/classFileParserBug/ClassFileParserBug.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @bug 8040018 * @library /test/lib * @summary Check for exception instead of assert. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * java.management * @compile LambdaMath.jcod diff --git a/test/hotspot/jtreg/runtime/classFileParserBug/TestBadPackageWithInterface.java b/test/hotspot/jtreg/runtime/classFileParserBug/TestBadPackageWithInterface.java index 5e64195c1af0b..f7028990b0547 100644 --- a/test/hotspot/jtreg/runtime/classFileParserBug/TestBadPackageWithInterface.java +++ b/test/hotspot/jtreg/runtime/classFileParserBug/TestBadPackageWithInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @bug 8245487 * @summary Check that if the VM rejects classes from packages starting with "java/", it will exit * cleanly after InstanceKlass::verify_on(), and not leave freed memory in _local_interfaces. + * @requires vm.flagless * @library /test/lib * @compile BadClassPackage.jasm * @run driver TestBadPackageWithInterface diff --git a/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java b/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java index f997400e42a75..ea91f54da83c2 100644 --- a/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java +++ b/test/hotspot/jtreg/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java @@ -26,6 +26,7 @@ * @bug 8041918 * @library /test/lib * @summary Test empty bootstrap_methods table within BootstrapMethods attribute + * @requires vm.flagless * @modules java.base/jdk.internal.misc * java.management * @compile emptynumbootstrapmethods1.jcod emptynumbootstrapmethods2.jcod From 54533e5f69e6b2663b01c7c7fd85bc5665851e61 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 3 Oct 2023 20:15:47 +0000 Subject: [PATCH 172/341] 8271887: mark hotspot runtime/CDSCompressedKPtrs tests which ignore external VM flags Backport-of: a3b01439701c1e01f9095a51b4f1048282956623 --- .../jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java | 3 ++- test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java index 3daf28d5c30f1..be97d1cf056eb 100644 --- a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java +++ b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @requires vm.cds * @requires vm.bits == 64 + * @requires vm.flagless * @bug 8003424 * @summary Testing UseCompressedClassPointers with CDS * @library /test/lib diff --git a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java index 7fce01009e848..19c4128f46009 100644 --- a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java +++ b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/XShareAuto.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. * 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 * @requires vm.cds + * @requires vm.flagless * @bug 8005933 * @summary -Xshare:auto is the default when -Xshare is not specified * @library /test/lib From fca27925a850355213a8df15a289419a0bfeaaa6 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 3 Oct 2023 20:19:33 +0000 Subject: [PATCH 173/341] 8198668: MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001/TestDescription.java still failing Backport-of: d1249aa5cbf3a3a3a24e85bcec30aecbc3e09bc0 --- test/hotspot/jtreg/ProblemList.txt | 5 - .../isexceeded001.java | 94 ++++++++++++------- 2 files changed, 61 insertions(+), 38 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index df1d07cb7cdf3..d3b3d81d6571c 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -138,11 +138,6 @@ serviceability/sa/TestJmapCoreMetaspace.java 8294316,8267433 macosx-x64 ############################################################################# -vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001/TestDescription.java 8198668 generic-all -vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded002/TestDescription.java 8153598 generic-all -vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded003/TestDescription.java 8198668 generic-all -vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded004/TestDescription.java 8153598 generic-all -vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded005/TestDescription.java 8153598 generic-all vmTestbase/nsk/monitoring/ThreadMXBean/ThreadInfo/Deadlock/JavaDeadlock001/TestDescription.java 8060733 generic-all vmTestbase/nsk/jdi/HiddenClass/events/events001.java 8257705 generic-all diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java index ebdcbe6b5b8a1..436c42f819dd1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. * 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,21 +47,22 @@ public static void main(String[] argv) { public static int run(String[] argv, PrintStream out) { ArgumentHandler argHandler = new ArgumentHandler(argv); Log log = new Log(out, argHandler); + log.enableVerbose(true); // show log output + MemoryMonitor monitor = Monitor.getMemoryMonitor(log, argHandler); List pools = monitor.getMemoryPoolMBeans(); for (int i = 0; i < pools.size(); i++) { Object pool = pools.get(i); - log.display(i + " pool " + monitor.getName(pool)); - + log.display(i + " pool " + monitor.getName(pool) + " of type: " + monitor.getType(pool)); if (!monitor.isUsageThresholdSupported(pool)) { - log.display(" does not support usage thresholds"); + log.display(" does not support usage thresholds: skip"); continue; - } else - log.display(" supports usage thresholds"); + } // Set a threshold that is greater than used value MemoryUsage usage = monitor.getUsage(pool); + boolean isExceeded = monitor.isUsageThresholdExceeded(pool); long used = usage.getUsed(); long max = usage.getMax(); long threshold = used + 1; @@ -69,49 +70,76 @@ public static int run(String[] argv, PrintStream out) { if ( (max > -1) && (threshold > max) ) { // we can't test threshold - not enough memory log.display("not enough memory for testing threshold:" + - " used=" + used + - ", max = " + max ); + " used=" + used + ", max=" + max + ": skip"); + continue; } monitor.setUsageThreshold(pool, threshold); - log.display(" threshold " + threshold + " is set, used = " + used ); + log.display(" used value is " + used + " max is " + max + " isExceeded = " + isExceeded); + log.display(" threshold set to " + threshold); + log.display(" threshold count " + monitor.getUsageThresholdCount(pool)); + // Reset peak usage so we can use it: monitor.resetPeakUsage(pool); - log.display(" resetting peak usage"); - log.display(" peak usage = " + monitor.getPeakUsage(pool).getUsed()); + isExceeded = monitor.isUsageThresholdExceeded(pool); + log.display(" reset peak usage. peak usage = " + monitor.getPeakUsage(pool).getUsed() + + " isExceeded = " + isExceeded); - // Eat some memory - provoke usage of the pool to cross the - // threshold value - b = new byte[INCREMENT]; // Eat 100K + // Eat some memory - _may_ cause usage of the pool to cross threshold, + // but cannot assume this affects the pool we are testing. + b = new byte[INCREMENT]; - boolean isExceeded = monitor.isUsageThresholdExceeded(pool); - usage = monitor.getPeakUsage(pool); - used = usage.getUsed(); + isExceeded = monitor.isUsageThresholdExceeded(pool); + log.display(" Allocated heap. isExceeded = " + isExceeded); - log.display(" used value is " + used); + // Fetch usage information: use peak usage in comparisons below, in case usage went up and then down. + // Log used and peak used in case of failure. + usage = monitor.getUsage(pool); + MemoryUsage peakUsage = monitor.getPeakUsage(pool); + used = usage.getUsed(); + max = usage.getMax(); + long peakUsed = usage.getUsed(); + long peakMax = usage.getMax(); + + log.display(" used value is " + used + " max is " + max + " isExceeded = " + isExceeded); + log.display("peak used value is " + peakUsed + " peak max is " + peakMax); + log.display(" threshold set to " + threshold); + long thresholdCount = monitor.getUsageThresholdCount(pool); + log.display(" threshold count " + thresholdCount); + + // Test can be imprecise, particularly with CodeHeap: usage changes outside our control. + if (thresholdCount > 0 && monitor.getType(pool) != MemoryType.HEAP) { + log.display(" thresholdCount increasing outside our control for non-heap Pool: skip"); + continue; + } - if (used < threshold && isExceeded) { - // There're problems with isUsageThresholdExceeded() + // If peak used value is less than threshold, then isUsageThresholdExceeded() + // is expected to return false. + if (peakUsed < threshold && isExceeded) { + // used is commonly less than threshold, but isExceeded should not be true: log.complain("isUsageThresholdExceeded() returned " + "true, while threshold = " + threshold - + " and used peak = " + used); + + " and used peak = " + peakUsed); + isExceeded = monitor.isUsageThresholdExceeded(pool); + if (isExceeded) { testFailed = true; + } else { + log.complain("isUsageThresholdExceeded() now says false."); + } } else - if (used >= threshold && !isExceeded) { - // we can introduce some imprecision during pooling memory usage - // value at the Code Cache memory pool. Amount of used memory - // was changed after we'd calculated isExceeded value - - if (monitor.isUsageThresholdExceeded(pool)) { - // that's mean such imprecision - log.display("isUsageThresholdExceeded() returned false," + // If peak used value is greater or equal than threshold, then + // isUsageThresholdExceeded() is expected to return true. + if (peakUsed >= threshold && !isExceeded) { + isExceeded = monitor.isUsageThresholdExceeded(pool); + if (isExceeded) { + log.display("isUsageThresholdExceeded() returned false, then true," + " while threshold = " + threshold + " and " - + "used peak = " + used); + + "used peak = " + peakUsed); } else { - // some other problems with isUsageThresholdExceeded() - log.complain("isUsageThresholdExceeded() returned false," + // Failure: + log.complain("isUsageThresholdExceeded() returned false, and is still false," + " while threshold = " + threshold + " and " - + "used peak = " + used); + + "used peak = " + peakUsed); testFailed = true; } } From 28adafcb524a043eca0fc6e7f9a1bb2a5490d723 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 3 Oct 2023 20:25:34 +0000 Subject: [PATCH 174/341] 8298873: Update IllegalRecordVersion.java for changes to TLS implementation 8301189: validate-source fails after JDK-8298873 Backport-of: fc26d3e5770ca3440105d3904a6e4af9af4860fa --- test/jdk/ProblemList.txt | 1 - .../HandshakeWithInvalidRecordVersion.java | 236 ++++++++++++++++++ .../ssl/SSLEngine/IllegalRecordVersion.java | 77 ------ 3 files changed, 236 insertions(+), 78 deletions(-) create mode 100644 test/jdk/javax/net/ssl/SSLEngine/HandshakeWithInvalidRecordVersion.java delete mode 100644 test/jdk/javax/net/ssl/SSLEngine/IllegalRecordVersion.java diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 7bc846c8ab985..c75a6602c0a46 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -636,7 +636,6 @@ sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic- javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x64 javax/net/ssl/SSLEngine/TestAllSuites.java 8298874 generic-all -javax/net/ssl/SSLEngine/IllegalRecordVersion.java 8298873 generic-all javax/net/ssl/SSLEngine/EngineCloseOnAlert.java 8298868 generic-all javax/net/ssl/SSLEngine/ConnectionTest.java 8298869 generic-all javax/net/ssl/SSLEngine/CheckStatus.java 8298872 generic-all diff --git a/test/jdk/javax/net/ssl/SSLEngine/HandshakeWithInvalidRecordVersion.java b/test/jdk/javax/net/ssl/SSLEngine/HandshakeWithInvalidRecordVersion.java new file mode 100644 index 0000000000000..71119489b85f1 --- /dev/null +++ b/test/jdk/javax/net/ssl/SSLEngine/HandshakeWithInvalidRecordVersion.java @@ -0,0 +1,236 @@ +/* + * 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 + * 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 8042449 8299870 + * @library /javax/net/ssl/templates + * @summary Verify successful handshake ignores invalid record version + * + * @run main/timeout=300 HandshakeWithInvalidRecordVersion + */ + +import javax.net.ssl.*; +import javax.net.ssl.SSLEngineResult.*; +import java.io.*; +import java.security.*; +import java.nio.*; +import java.util.Arrays; + +public class HandshakeWithInvalidRecordVersion implements SSLContextTemplate { + private static final boolean DEBUG = Boolean.getBoolean("test.debug"); + + private static final String PATH_TO_STORES = "../etc"; + private static final String KEYSTORE_FILE = "keystore"; + private static final String TRUSTSTORE_FILE = "truststore"; + + private static final String KEYSTORE_PATH = + System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + + "/" + KEYSTORE_FILE; + private static final String TRUSTSTORE_PATH = + System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + + "/" + TRUSTSTORE_FILE; + + public static void main(String [] args) throws Exception { + var runner = new HandshakeWithInvalidRecordVersion(); + runner.executeTest("TLSv1.2", + new String[]{"TLSv1.2"}, new String[]{"TLSv1.3", "TLSv1.2"}); + + runner.executeTest("TLSv1.2", + new String[]{"TLSv1.3", "TLSv1.2"}, new String[]{"TLSv1.2"}); + + runner.executeTest("TLSv1.3", + new String[]{"TLSv1.2", "TLSv1.3"}, new String[]{"TLSv1.3"}); + + runner.executeTest("TLSv1.3", + new String[]{"TLSv1.3"}, new String[]{"TLSv1.2", "TLSv1.3"}); + } + + + private void executeTest(String expectedProtocol, String[] clientProtocols, + String[] serverProtocols) throws Exception { + System.out.printf("Executing test%n" + + "Client protocols: %s%nServer protocols: %s%nExpected negotiated: %s%n", + Arrays.toString(clientProtocols), Arrays.toString(serverProtocols), + expectedProtocol); + + SSLEngine cliEngine = createClientSSLContext().createSSLEngine(); + cliEngine.setUseClientMode(true); + cliEngine.setEnabledProtocols(clientProtocols); + SSLEngine srvEngine = createServerSSLContext().createSSLEngine(); + srvEngine.setUseClientMode(false); + srvEngine.setEnabledProtocols(serverProtocols); + + SSLSession session = cliEngine.getSession(); + int netBufferMax = session.getPacketBufferSize(); + int appBufferMax = session.getApplicationBufferSize(); + + ByteBuffer cliToSrv = ByteBuffer.allocateDirect(netBufferMax); + ByteBuffer srvIBuff = ByteBuffer.allocateDirect(appBufferMax + 50); + ByteBuffer cliOBuff = ByteBuffer.wrap("I'm client".getBytes()); + + + System.out.println("Generating ClientHello"); + SSLEngineResult cliRes = cliEngine.wrap(cliOBuff, cliToSrv); + checkResult(cliRes, HandshakeStatus.NEED_UNWRAP); + log("Client wrap result: " + cliRes); + cliToSrv.flip(); + if (cliToSrv.limit() > 5) { + System.out.println("Setting record version to (0xa9, 0xa2)"); + cliToSrv.put(1, (byte)0xa9); + cliToSrv.put(2, (byte)0xa2); + } else { + throw new RuntimeException("ClientHello message is only " + + cliToSrv.limit() + "bytes. Expecting at least 6 bytes. "); + } + + System.out.println("Processing ClientHello"); + SSLEngineResult srv = srvEngine.unwrap(cliToSrv, srvIBuff); + checkResult(srv, HandshakeStatus.NEED_TASK); + runDelegatedTasks(srvEngine); + + finishHandshake(cliEngine, srvEngine); + + if (!cliEngine.getSession().getProtocol() + .equals(srvEngine.getSession().getProtocol()) + || !cliEngine.getSession().getProtocol().equals(expectedProtocol)) { + throw new RuntimeException("Client and server did not negotiate protocol. " + + "Expected: " + expectedProtocol + ". Negotiated: " + + cliEngine.getSession().getProtocol()); + } + } + private boolean isHandshaking(SSLEngine e) { + return (e.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING); + } + + private void finishHandshake(SSLEngine client, SSLEngine server) throws Exception { + boolean clientDone = false; + boolean serverDone = false; + SSLEngineResult serverResult; + SSLEngineResult clientResult; + int capacity = client.getSession().getPacketBufferSize(); + ByteBuffer emptyBuffer = ByteBuffer.allocate(capacity); + ByteBuffer serverToClient = ByteBuffer.allocate(capacity); + ByteBuffer clientToServer = ByteBuffer.allocate(capacity); + + System.out.println("Finishing handshake..."); + while (isHandshaking(client) || + isHandshaking(server)) { + + log("================"); + + clientResult = client.wrap(emptyBuffer, clientToServer); + serverResult = server.wrap(emptyBuffer, serverToClient); + + if (clientResult.getHandshakeStatus() == HandshakeStatus.FINISHED) { + clientDone = true; + } + + if (serverResult.getHandshakeStatus() == HandshakeStatus.FINISHED) { + serverDone = true; + } + + log("wrap1 = " + clientResult); + log("wrap2 = " + serverResult); + + if (clientResult.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { + Runnable runnable; + while ((runnable = client.getDelegatedTask()) != null) { + runnable.run(); + } + } + + if (serverResult.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { + Runnable runnable; + while ((runnable = server.getDelegatedTask()) != null) { + runnable.run(); + } + } + + clientToServer.flip(); + serverToClient.flip(); + + log("----"); + + clientResult = client.unwrap(serverToClient, emptyBuffer); + serverResult = server.unwrap(clientToServer, emptyBuffer); + + if (clientResult.getHandshakeStatus() == HandshakeStatus.FINISHED) { + clientDone = true; + } + + if (serverResult.getHandshakeStatus() == HandshakeStatus.FINISHED) { + serverDone = true; + } + + log("unwrap1 = " + clientResult); + log("unwrap2 = " + serverResult); + + if (clientResult.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { + Runnable runnable; + while ((runnable = client.getDelegatedTask()) != null) { + runnable.run(); + } + } + + if (serverResult.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { + Runnable runnable; + while ((runnable = server.getDelegatedTask()) != null) { + runnable.run(); + } + } + + clientToServer.clear(); + serverToClient.clear(); + } + + System.out.println("Handshake complete"); + + if (!clientDone || !serverDone) { + throw new RuntimeException("Both should be true:\n" + + " clientDone = " + clientDone + " serverDone = " + serverDone); + } + } + + private static void runDelegatedTasks(SSLEngine engine) { + Runnable runnable; + while ((runnable = engine.getDelegatedTask()) != null) { + log("\trunning delegated task..."); + runnable.run(); + } + } + + private static void checkResult(SSLEngineResult result, HandshakeStatus expectedStatus) { + if(result.getHandshakeStatus() != expectedStatus) { + throw new RuntimeException(String.format( + "Handshake status %s does not match expected status of %s", + result.getHandshakeStatus(), expectedStatus)); + } + } + + private static void log(Object msg) { + if (DEBUG) { + System.out.println(msg); + } + } +} diff --git a/test/jdk/javax/net/ssl/SSLEngine/IllegalRecordVersion.java b/test/jdk/javax/net/ssl/SSLEngine/IllegalRecordVersion.java deleted file mode 100644 index cab265287909f..0000000000000 --- a/test/jdk/javax/net/ssl/SSLEngine/IllegalRecordVersion.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * 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. - */ - -// This test case relies on updated static security property, no way to re-use -// security property in samevm/agentvm mode. - -/* - * @test - * @bug 8042449 - * @summary Issue for negative byte major record version - * - * @run main/othervm IllegalRecordVersion - */ - -import javax.net.ssl.*; -import javax.net.ssl.SSLEngineResult.*; -import java.io.*; -import java.security.*; -import java.nio.*; - -public class IllegalRecordVersion { - - public static void main(String args[]) throws Exception { - SSLContext context = SSLContext.getDefault(); - - SSLEngine cliEngine = context.createSSLEngine(); - cliEngine.setUseClientMode(true); - SSLEngine srvEngine = context.createSSLEngine(); - srvEngine.setUseClientMode(false); - - SSLSession session = cliEngine.getSession(); - int netBufferMax = session.getPacketBufferSize(); - int appBufferMax = session.getApplicationBufferSize(); - - ByteBuffer cliToSrv = ByteBuffer.allocateDirect(netBufferMax); - ByteBuffer srvIBuff = ByteBuffer.allocateDirect(appBufferMax + 50); - ByteBuffer cliOBuff = ByteBuffer.wrap("I'm client".getBytes()); - - - System.out.println("client hello (record version(0xa9, 0xa2))"); - SSLEngineResult cliRes = cliEngine.wrap(cliOBuff, cliToSrv); - System.out.println("Client wrap result: " + cliRes); - cliToSrv.flip(); - if (cliToSrv.limit() > 5) { - cliToSrv.put(1, (byte)0xa9); - cliToSrv.put(2, (byte)0xa2); - } - - try { - srvEngine.unwrap(cliToSrv, srvIBuff); - throw new Exception( - "Cannot catch the unsupported record version issue"); - } catch (SSLException e) { - // get the expected exception - } - } -} From 91332e2a7708c521a59bb2bce68b4c5924311942 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 3 Oct 2023 20:28:32 +0000 Subject: [PATCH 175/341] 8298869: Update ConnectionTest.java for changes to TLS implementation Backport-of: d6007a356f8081290cc745481af160a4cad8a9bb --- test/jdk/ProblemList.txt | 1 - .../net/ssl/SSLEngine/ConnectionTest.java | 758 ++++++++---------- 2 files changed, 340 insertions(+), 419 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index c75a6602c0a46..e703884e5bedc 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -637,7 +637,6 @@ javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x javax/net/ssl/SSLEngine/TestAllSuites.java 8298874 generic-all javax/net/ssl/SSLEngine/EngineCloseOnAlert.java 8298868 generic-all -javax/net/ssl/SSLEngine/ConnectionTest.java 8298869 generic-all javax/net/ssl/SSLEngine/CheckStatus.java 8298872 generic-all sun/security/smartcardio/TestChannel.java 8039280 generic-all diff --git a/test/jdk/javax/net/ssl/SSLEngine/ConnectionTest.java b/test/jdk/javax/net/ssl/SSLEngine/ConnectionTest.java index a18444ccc7ac5..e1ed18e9fdee6 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/ConnectionTest.java +++ b/test/jdk/javax/net/ssl/SSLEngine/ConnectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, 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 @@ -28,7 +28,8 @@ * I/O abstraction * @author Brad Wetmore * - * @run main/othervm ConnectionTest + * @run main/othervm ConnectionTest TLSv1.2 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * @run main/othervm ConnectionTest TLSv1.3 TLS_AES_256_GCM_SHA384 */ /* @@ -45,44 +46,46 @@ public class ConnectionTest { - private SSLContext sslc; - private SSLEngine ssle1; - private SSLEngine ssle2; - - private static String pathToStores = "../etc"; - private static String keyStoreFile = "keystore"; - private static String trustStoreFile = "truststore"; - private static String passwd = "passphrase"; - - private static String keyFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + keyStoreFile; - private static String trustFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + trustStoreFile; - - private ByteBuffer appIn1, appOut1; - private ByteBuffer appIn2, appOut2; - private ByteBuffer oneToTwo, twoToOne; + private final SSLEngine clientEngine; + private final SSLEngine serverEngine; + + private static final String PATH_TO_STORES = "../etc"; + private static final String KEYSTORE_FILE = "keystore"; + private static final String TRUSTSTORE_FILE = "truststore"; + + private static final String KEYSTORE_PATH = + System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + + "/" + KEYSTORE_FILE; + private static final String TRUSTSTORE_PATH = + System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + + "/" + TRUSTSTORE_FILE; + + private ByteBuffer clientIn, clientOut; + private ByteBuffer serverIn, serverOut; + private ByteBuffer clientToServer, serverToClient; private ByteBuffer emptyBuffer; - private ByteBuffer oneToTwoShifter, twoToOneShifter; + private ByteBuffer clientToServerShifter, serverToClientShifter; - private String hostname = "hostname"; - private int portNumber = 77; + private final String HOSTNAME = "hostname"; - public ConnectionTest() + private final int PORT_NUMBER = 77; + + public ConnectionTest(String enabledProtocol, String enabledCipherSuite) throws Exception { - sslc = getSSLContext(); - ssle1 = sslc.createSSLEngine(hostname, portNumber); - ssle2 = sslc.createSSLEngine(); + SSLContext sslContext = getSSLContext(); + clientEngine = sslContext.createSSLEngine(HOSTNAME, PORT_NUMBER); + serverEngine = sslContext.createSSLEngine(); + + clientEngine.setEnabledCipherSuites(new String [] { + enabledCipherSuite}); + clientEngine.setEnabledProtocols(new String[]{enabledProtocol}); - ssle1.setEnabledCipherSuites(new String [] { - "SSL_RSA_WITH_RC4_128_MD5"}); + serverEngine.setEnabledCipherSuites(new String [] { + enabledCipherSuite}); + serverEngine.setEnabledProtocols(new String[]{enabledProtocol}); - ssle2.setEnabledCipherSuites(new String [] { - "SSL_RSA_WITH_RC4_128_MD5"}); createBuffers(); } @@ -92,8 +95,8 @@ private SSLContext getSSLContext() throws Exception { KeyStore ts = KeyStore.getInstance("JKS"); char[] passphrase = "passphrase".toCharArray(); - ks.load(new FileInputStream(keyFilename), passphrase); - ts.load(new FileInputStream(trustFilename), passphrase); + ks.load(new FileInputStream(KEYSTORE_PATH), passphrase); + ts.load(new FileInputStream(TRUSTSTORE_PATH), passphrase); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, passphrase); @@ -110,62 +113,62 @@ private SSLContext getSSLContext() throws Exception { private void createBuffers() { // Size the buffers as appropriate. - SSLSession session = ssle1.getSession(); + SSLSession session = clientEngine.getSession(); int appBufferMax = session.getApplicationBufferSize(); int netBufferMax = session.getPacketBufferSize(); - appIn1 = ByteBuffer.allocateDirect(appBufferMax + 10); - appIn2 = ByteBuffer.allocateDirect(appBufferMax + 10); + clientIn = ByteBuffer.allocateDirect(appBufferMax + 10); + serverIn = ByteBuffer.allocateDirect(appBufferMax + 10); - appIn1.position(10); - appIn2.position(10); + clientIn.position(10); + serverIn.position(10); - oneToTwo = ByteBuffer.allocateDirect(netBufferMax + 10); - twoToOne = ByteBuffer.allocateDirect(netBufferMax + 10); + clientToServer = ByteBuffer.allocateDirect(netBufferMax + 10); + serverToClient = ByteBuffer.allocateDirect(netBufferMax + 10); - oneToTwo.position(10); - twoToOne.position(10); - oneToTwoShifter = oneToTwo.slice(); - twoToOneShifter = twoToOne.slice(); + clientToServer.position(10); + serverToClient.position(10); + clientToServerShifter = clientToServer.slice(); + serverToClientShifter = serverToClient.slice(); - appOut1 = ByteBuffer.wrap("Hi Engine2, I'm SSLEngine1".getBytes()); - appOut2 = ByteBuffer.wrap("Hello Engine1, I'm SSLEngine2".getBytes()); + clientOut = ByteBuffer.wrap("Hi Engine2, I'm SSLEngine1".getBytes()); + serverOut = ByteBuffer.wrap("Hello Engine1, I'm SSLEngine2".getBytes()); emptyBuffer = ByteBuffer.allocate(10); emptyBuffer.limit(5); emptyBuffer.position(emptyBuffer.limit()); - System.out.println("AppOut1 = " + appOut1); - System.out.println("AppOut2 = " + appOut2); - System.out.println(); + log("clientOut = " + clientOut); + log("serverOut = " + serverOut); + log(""); } private void checkResult(SSLEngineResult result, Status status, HandshakeStatus hsStatus, int consumed, int produced, - boolean done) throws Exception { + boolean done) { if ((status != null) && (result.getStatus() != status)) { - throw new Exception("Unexpected Status: need = " + status + + throw new RuntimeException("Unexpected Status: need = " + status + " got = " + result.getStatus()); } if ((hsStatus != null) && (result.getHandshakeStatus() != hsStatus)) { - throw new Exception("Unexpected hsStatus: need = " + hsStatus + + throw new RuntimeException("Unexpected hsStatus: need = " + hsStatus + " got = " + result.getHandshakeStatus()); } if ((consumed != -1) && (consumed != result.bytesConsumed())) { - throw new Exception("Unexpected consumed: need = " + consumed + + throw new RuntimeException("Unexpected consumed: need = " + consumed + " got = " + result.bytesConsumed()); } if ((produced != -1) && (produced != result.bytesProduced())) { - throw new Exception("Unexpected produced: need = " + produced + + throw new RuntimeException("Unexpected produced: need = " + produced + " got = " + result.bytesProduced()); } if (done && (hsStatus == HandshakeStatus.FINISHED)) { - throw new Exception( + throw new RuntimeException( "Handshake already reported finished"); } @@ -176,13 +179,13 @@ private boolean isHandshaking(SSLEngine e) { } private void test() throws Exception { - ssle1.setUseClientMode(true); - ssle2.setUseClientMode(false); - ssle2.setNeedClientAuth(true); + clientEngine.setUseClientMode(true); + serverEngine.setUseClientMode(false); + serverEngine.setNeedClientAuth(true); - System.out.println("Testing for early unwrap/wrap"); - SSLEngineResult result1 = ssle1.unwrap(twoToOne, appIn1); - SSLEngineResult result2 = ssle2.wrap(appOut2, oneToTwo); + log("Testing for early unwrap/wrap"); + SSLEngineResult result1 = clientEngine.unwrap(serverToClient, clientIn); + SSLEngineResult result2 = serverEngine.wrap(serverOut, clientToServer); /* * These should not consume/produce data, because they @@ -194,483 +197,401 @@ private void test() throws Exception { checkResult(result2, Status.OK, HandshakeStatus.NEED_UNWRAP, 0, 0, false); - System.out.println("Doing Initial Handshake"); - - boolean done1 = false; - boolean done2 = false; + log("Doing Initial Handshake"); /* * Do initial handshaking */ - while (isHandshaking(ssle1) || - isHandshaking(ssle2)) { + handshake(); - System.out.println("================"); + checkEngineAndSession(); - result1 = ssle1.wrap(emptyBuffer, oneToTwo); - checkResult(result1, null, null, 0, -1, done1); - result2 = ssle2.wrap(emptyBuffer, twoToOne); - checkResult(result2, null, null, 0, -1, done2); + SSLSession clientSession1 = clientEngine.getSession(); + SSLSession serverSession1 = serverEngine.getSession(); - if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) { - done1 = true; - } + /* + * Should be able to write/read a small buffer like this. + */ + int appOut1Len = clientOut.remaining(); + int appOut2Len = serverOut.remaining(); + int net1Len; + int net2Len; - if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) { - done2 = true; - } + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(result1, Status.OK, HandshakeStatus.NOT_HANDSHAKING, + appOut1Len, -1, false); + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(result2, Status.OK, HandshakeStatus.NOT_HANDSHAKING, + appOut2Len, -1, false); + net1Len = result1.bytesProduced(); + net2Len = result2.bytesProduced(); - System.out.println("wrap1 = " + result1); - System.out.println("wrap2 = " + result2); + log("wrap1 = " + result1); + log("wrap2 = " + result2); - if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { - Runnable runnable; - while ((runnable = ssle1.getDelegatedTask()) != null) { - runnable.run(); - } - } + clientToServer.flip(); + serverToClient.flip(); - if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { - Runnable runnable; - while ((runnable = ssle2.getDelegatedTask()) != null) { - runnable.run(); - } - } + clientToServer.position(10); + serverToClient.position(10); - oneToTwo.flip(); - twoToOne.flip(); + log("----"); - oneToTwo.position(10); - twoToOne.position(10); + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(result1, Status.OK, HandshakeStatus.NOT_HANDSHAKING, + net2Len, appOut2Len, false); + result2 = serverEngine.unwrap(clientToServer, serverIn); + checkResult(result2, Status.OK, HandshakeStatus.NOT_HANDSHAKING, + net1Len, appOut1Len, false); - System.out.println("----"); + log("unwrap1 = " + result1); + log("unwrap2 = " + result2); - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(result1, null, null, -1, 0, done1); - result2 = ssle2.unwrap(oneToTwo, appIn2); - checkResult(result2, null, null, -1, 0, done2); + updateByteBuffers(); - if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) { - done1 = true; - } + serverSession1.invalidate(); + serverEngine.beginHandshake(); - if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) { - done2 = true; - } + log("\nRENEGOTIATING"); + log("============="); - if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { - Runnable runnable; - while ((runnable = ssle1.getDelegatedTask()) != null) { - runnable.run(); - } - } - - if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { - Runnable runnable; - while ((runnable = ssle2.getDelegatedTask()) != null) { - runnable.run(); - } - } + clientIn.clear(); + serverIn.clear(); - System.out.println("unwrap1 = " + result1); - System.out.println("unwrap2 = " + result2); - - oneToTwoShifter.position(oneToTwo.position() - 10); - oneToTwoShifter.limit(oneToTwo.limit() - 10); - twoToOneShifter.position(twoToOne.position() - 10); - twoToOneShifter.limit(twoToOne.limit() - 10); - oneToTwoShifter.compact(); - twoToOneShifter.compact(); - oneToTwo.position(oneToTwoShifter.position() + 10); - oneToTwo.limit(oneToTwoShifter.limit() + 10); - twoToOne.position(twoToOneShifter.position() + 10); - twoToOne.limit(twoToOneShifter.limit() + 10); + /* + * Do a quick test to see if this can do a switch + * into client mode, at this point, you shouldn't be able + * to switch back. + */ + try { + log("Try to change client mode"); + serverEngine.setUseClientMode(true); + throw new RuntimeException("Should have thrown IllegalArgumentException"); + } catch (IllegalArgumentException e) { + log("Caught correct IllegalArgumentException"); } - System.out.println("\nDONE HANDSHAKING"); - System.out.println("================"); + handshake(); - if (!done1 || !done2) { - throw new Exception("Both should be true:\n" + - " done1 = " + done1 + " done2 = " + done2); - } + SSLSession clientSession2 = clientEngine.getSession(); + SSLSession serverSession2 = serverEngine.getSession(); - String host = ssle1.getPeerHost(); - int port = ssle1.getPeerPort(); - if (!host.equals(hostname) || (port != portNumber)) { - throw new Exception("unexpected host/port " + host + ":" + port); - } - host = ssle2.getPeerHost(); - port = ssle2.getPeerPort(); - if ((host != null) || (port != -1)) { - throw new Exception("unexpected host/port " + host + ":" + port); - } + log("\nDoing close"); + log("==========="); - SSLSession ssls1 = ssle1.getSession(); + clientEngine.closeOutbound(); + serverEngine.closeOutbound(); - host = ssls1.getPeerHost(); - port = ssls1.getPeerPort(); - if (!host.equals(hostname) || (port != portNumber)) { - throw new Exception("unexpected host/port " + host + ":" + port); - } + clientToServer.flip(); + serverToClient.flip(); + clientToServer.position(10); + serverToClient.position(10); - SSLSession ssls2 = ssle2.getSession(); + clientIn.clear(); + serverIn.clear(); - host = ssls2.getPeerHost(); - port = ssls2.getPeerPort(); - if ((host != null) || (port != -1)) { - throw new Exception("unexpected host/port " + host + ":" + port); - } + log("LAST UNWRAP"); + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(result1, Status.BUFFER_UNDERFLOW, + HandshakeStatus.NEED_WRAP, 0, 0, false); + result2 = serverEngine.unwrap(clientToServer, serverIn); + checkResult(result2, Status.BUFFER_UNDERFLOW, + HandshakeStatus.NEED_WRAP, 0, 0, false); - /* - * Should be able to write/read a small buffer like this. - */ - int appOut1Len = appOut1.remaining(); - int appOut2Len = appOut2.remaining(); - int net1Len; - int net2Len; + log("unwrap1 = " + result1); + log("unwrap2 = " + result2); + + updateByteBuffers(); + + log("LAST WRAP"); + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, + 0, -1, false); + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, + 0, -1, false); + + log("wrap1 = " + result1); + log("wrap2 = " + result2); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(result1, Status.OK, HandshakeStatus.NOT_HANDSHAKING, - appOut1Len, -1, false); - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(result2, Status.OK, HandshakeStatus.NOT_HANDSHAKING, - appOut2Len, -1, false); net1Len = result1.bytesProduced(); net2Len = result2.bytesProduced(); - System.out.println("wrap1 = " + result1); - System.out.println("wrap2 = " + result2); + clientToServer.flip(); + serverToClient.flip(); - oneToTwo.flip(); - twoToOne.flip(); + clientToServer.position(10); + serverToClient.position(10); - oneToTwo.position(10); - twoToOne.position(10); - - System.out.println("----"); + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, + net1Len, 0, false); + result2 = serverEngine.unwrap(clientToServer, serverIn); + checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, + net2Len, 0, false); - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(result1, Status.OK, HandshakeStatus.NOT_HANDSHAKING, - net2Len, appOut2Len, false); - result2 = ssle2.unwrap(oneToTwo, appIn2); - checkResult(result2, Status.OK, HandshakeStatus.NOT_HANDSHAKING, - net1Len, appOut1Len, false); + log("unwrap1 = " + result1); + log("unwrap2 = " + result2); - System.out.println("unwrap1 = " + result1); - System.out.println("unwrap2 = " + result2); + updateByteBuffers(); - oneToTwoShifter.position(oneToTwo.position() - 10); - oneToTwoShifter.limit(oneToTwo.limit() - 10); - twoToOneShifter.position(twoToOne.position() - 10); - twoToOneShifter.limit(twoToOne.limit() - 10); - oneToTwoShifter.compact(); - twoToOneShifter.compact(); - oneToTwo.position(oneToTwoShifter.position() + 10); - oneToTwo.limit(oneToTwoShifter.limit() + 10); - twoToOne.position(twoToOneShifter.position() + 10); - twoToOne.limit(twoToOneShifter.limit() + 10); + log("EXTRA WRAP"); + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, + 0, 0, false); + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, + 0, 0, false); - ssls2.invalidate(); - ssle2.beginHandshake(); + log("wrap1 = " + result1); + log("wrap2 = " + result2); - System.out.println("\nRENEGOTIATING"); - System.out.println("============="); + clientToServer.flip(); + serverToClient.flip(); + clientToServer.position(10); + serverToClient.position(10); - done1 = false; - done2 = false; + log("EXTRA UNWRAP"); + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, + 0, 0, false); + result2 = serverEngine.unwrap(clientToServer, serverIn); + checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, + 0, 0, false); - appIn1.clear(); - appIn2.clear(); + log("unwrap1 = " + result1); + log("unwrap2 = " + result2); - /* - * Do a quick test to see if this can do a switch - * into client mode, at this point, you shouldn't be able - * to switch back. - */ - try { - System.out.println("Try to change client mode"); - ssle2.setUseClientMode(true); - throw new Exception("Should have thrown IllegalArgumentException"); - } catch (IllegalArgumentException e) { - System.out.println("Caught correct IllegalArgumentException"); - } + checkSession(clientSession1, serverSession1, clientSession2, serverSession2); + log(clientEngine); + log(serverEngine); + } - while (isHandshaking(ssle1) || - isHandshaking(ssle2)) { + private void handshake() throws Exception { + boolean clientDone = false; + boolean serverDone = false; + SSLEngineResult result2; + SSLEngineResult result1; + while (isHandshaking(clientEngine) || + isHandshaking(serverEngine)) { - System.out.println("================"); + log("================"); - result1 = ssle1.wrap(emptyBuffer, oneToTwo); - checkResult(result1, null, null, 0, -1, done1); - result2 = ssle2.wrap(emptyBuffer, twoToOne); - checkResult(result2, null, null, 0, -1, done2); + result1 = clientEngine.wrap(emptyBuffer, clientToServer); + checkResult(result1, null, null, 0, -1, clientDone); + result2 = serverEngine.wrap(emptyBuffer, serverToClient); + checkResult(result2, null, null, 0, -1, serverDone); if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) { - done1 = true; + clientDone = true; } if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) { - done2 = true; + serverDone = true; } - System.out.println("wrap1 = " + result1); - System.out.println("wrap2 = " + result2); + log("wrap1 = " + result1); + log("wrap2 = " + result2); if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { Runnable runnable; - while ((runnable = ssle1.getDelegatedTask()) != null) { + while ((runnable = clientEngine.getDelegatedTask()) != null) { runnable.run(); } } if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { Runnable runnable; - while ((runnable = ssle2.getDelegatedTask()) != null) { + while ((runnable = serverEngine.getDelegatedTask()) != null) { runnable.run(); } } - oneToTwo.flip(); - twoToOne.flip(); + clientToServer.flip(); + serverToClient.flip(); - oneToTwo.position(10); - twoToOne.position(10); + clientToServer.position(10); + serverToClient.position(10); - System.out.println("----"); + log("----"); - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(result1, null, null, -1, 0, done1); - result2 = ssle2.unwrap(oneToTwo, appIn2); - checkResult(result2, null, null, -1, 0, done2); + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(result1, null, null, -1, 0, clientDone); + result2 = serverEngine.unwrap(clientToServer, serverIn); + checkResult(result2, null, null, -1, 0, serverDone); if (result1.getHandshakeStatus() == HandshakeStatus.FINISHED) { - done1 = true; + clientDone = true; } if (result2.getHandshakeStatus() == HandshakeStatus.FINISHED) { - done2 = true; + serverDone = true; } - System.out.println("unwrap1 = " + result1); - System.out.println("unwrap2 = " + result2); + log("unwrap1 = " + result1); + log("unwrap2 = " + result2); if (result1.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { Runnable runnable; - while ((runnable = ssle1.getDelegatedTask()) != null) { + while ((runnable = clientEngine.getDelegatedTask()) != null) { runnable.run(); } } if (result2.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { Runnable runnable; - while ((runnable = ssle2.getDelegatedTask()) != null) { + while ((runnable = serverEngine.getDelegatedTask()) != null) { runnable.run(); } } - oneToTwoShifter.position(oneToTwo.position() - 10); - oneToTwoShifter.limit(oneToTwo.limit() - 10); - twoToOneShifter.position(twoToOne.position() - 10); - twoToOneShifter.limit(twoToOne.limit() - 10); - oneToTwoShifter.compact(); - twoToOneShifter.compact(); - oneToTwo.position(oneToTwoShifter.position() + 10); - oneToTwo.limit(oneToTwoShifter.limit() + 10); - twoToOne.position(twoToOneShifter.position() + 10); - twoToOne.limit(twoToOneShifter.limit() + 10); - } - - host = ssle1.getPeerHost(); - port = ssle1.getPeerPort(); - if (!host.equals(hostname) || (port != portNumber)) { - throw new Exception("unexpected host/port " + host + ":" + port); + updateByteBuffers(); } - host = ssle2.getPeerHost(); - port = ssle2.getPeerPort(); - if ((host != null) || (port != -1)) { - throw new Exception("unexpected host/port " + host + ":" + port); - } - SSLSession ssls3 = ssle2.getSession(); + log("\nDONE HANDSHAKING"); + log("================"); - host = ssls1.getPeerHost(); - port = ssls1.getPeerPort(); - if (!host.equals(hostname) || (port != portNumber)) { - throw new Exception("unexpected host/port " + host + ":" + port); + if (!clientDone || !serverDone) { + throw new RuntimeException("Both should be true:\n" + + " clientDone = " + clientDone + " serverDone = " + serverDone); } + } - SSLSession ssls4 = ssle2.getSession(); - - host = ssls2.getPeerHost(); - port = ssls2.getPeerPort(); - if ((host != null) || (port != -1)) { - throw new Exception("unexpected host/port " + host + ":" + port); - } + private void updateByteBuffers() { + clientToServerShifter.position(clientToServer.position() - 10); + clientToServerShifter.limit(clientToServer.limit() - 10); + serverToClientShifter.position(serverToClient.position() - 10); + serverToClientShifter.limit(serverToClient.limit() - 10); + clientToServerShifter.compact(); + serverToClientShifter.compact(); + clientToServer.position(clientToServerShifter.position() + 10); + clientToServer.limit(clientToServerShifter.limit() + 10); + serverToClient.position(serverToClientShifter.position() + 10); + serverToClient.limit(serverToClientShifter.limit() + 10); + } - System.out.println("\nDoing close"); - System.out.println("==========="); + private static void checkSession(SSLSession clientSession1, SSLSession serverSession1, + SSLSession clientSession2, SSLSession serverSession2) { + log("\nSession Info for client SSLEngine 1"); + log(clientSession1); + log(clientSession1.getCreationTime()); - ssle1.closeOutbound(); - ssle2.closeOutbound(); + String peer1 = clientSession1.getPeerHost(); + log(peer1); - oneToTwo.flip(); - twoToOne.flip(); - oneToTwo.position(10); - twoToOne.position(10); + String protocol1 = clientSession1.getProtocol(); + log(protocol1); - appIn1.clear(); - appIn2.clear(); + String ciphersuite1 = clientSession1.getCipherSuite(); + log(ciphersuite1); + log(""); - System.out.println("LAST UNWRAP"); - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(result1, Status.BUFFER_UNDERFLOW, - HandshakeStatus.NEED_WRAP, 0, 0, false); - result2 = ssle2.unwrap(oneToTwo, appIn2); - checkResult(result2, Status.BUFFER_UNDERFLOW, - HandshakeStatus.NEED_WRAP, 0, 0, false); + log("\nSession Info for server SSLEngine 1"); + log(serverSession1); + log(serverSession1.getCreationTime()); - System.out.println("unwrap1 = " + result1); - System.out.println("unwrap2 = " + result2); - - oneToTwoShifter.position(oneToTwo.position() - 10); - oneToTwoShifter.limit(oneToTwo.limit() - 10); - twoToOneShifter.position(twoToOne.position() - 10); - twoToOneShifter.limit(twoToOne.limit() - 10); - oneToTwoShifter.compact(); - twoToOneShifter.compact(); - oneToTwo.position(oneToTwoShifter.position() + 10); - oneToTwo.limit(oneToTwoShifter.limit() + 10); - twoToOne.position(twoToOneShifter.position() + 10); - twoToOne.limit(twoToOneShifter.limit() + 10); - - System.out.println("LAST WRAP"); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(result1, Status.CLOSED, HandshakeStatus.NEED_UNWRAP, - 0, -1, false); - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(result2, Status.CLOSED, HandshakeStatus.NEED_UNWRAP, - 0, -1, false); + String peer2 = serverSession1.getPeerHost(); + log(peer2); - System.out.println("wrap1 = " + result1); - System.out.println("wrap2 = " + result2); + String protocol2 = serverSession1.getProtocol(); + log(protocol2); - net1Len = result1.bytesProduced(); - net2Len = result2.bytesProduced(); + String ciphersuite2 = serverSession1.getCipherSuite(); + log(ciphersuite2); + log(""); - oneToTwo.flip(); - twoToOne.flip(); + if (peer1.equals(peer2)) { + throw new RuntimeException("peer hostnames not equal"); + } - oneToTwo.position(10); - twoToOne.position(10); + if (!protocol1.equals(protocol2)) { + throw new RuntimeException("protocols not equal"); + } - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, - net1Len, 0, false); - result2 = ssle2.unwrap(oneToTwo, appIn2); - checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, - net2Len, 0, false); + compareCertificates(clientSession1, serverSession1); + compareCertificates(clientSession2, serverSession2); - System.out.println("unwrap1 = " + result1); - System.out.println("unwrap2 = " + result2); - - oneToTwoShifter.position(oneToTwo.position() - 10); - oneToTwoShifter.limit(oneToTwo.limit() - 10); - twoToOneShifter.position(twoToOne.position() - 10); - twoToOneShifter.limit(twoToOne.limit() - 10); - oneToTwoShifter.compact(); - twoToOneShifter.compact(); - oneToTwo.position(oneToTwoShifter.position() + 10); - oneToTwo.limit(oneToTwoShifter.limit() + 10); - twoToOne.position(twoToOneShifter.position() + 10); - twoToOne.limit(twoToOneShifter.limit() + 10); - - System.out.println("EXTRA WRAP"); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, - 0, 0, false); - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, - 0, 0, false); + if (!ciphersuite1.equals(ciphersuite2)) { + throw new RuntimeException("ciphersuites not equal"); + } - System.out.println("wrap1 = " + result1); - System.out.println("wrap2 = " + result2); + log("\nSession Info for client SSLEngine 2"); + log(clientSession2); + log("\nSession Info for server SSLEngine 2"); + log(serverSession2); + } - oneToTwo.flip(); - twoToOne.flip(); - oneToTwo.position(10); - twoToOne.position(10); - System.out.println("EXTRA UNWRAP"); - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(result1, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, - 0, 0, false); - result2 = ssle2.unwrap(oneToTwo, appIn2); - checkResult(result2, Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, - 0, 0, false); + private static void compareCertificates(SSLSession client, SSLSession server) { + try { + java.security.cert.Certificate clientLocal = client.getLocalCertificates()[0]; + java.security.cert.Certificate clientPeer = client.getPeerCertificates()[0]; + java.security.cert.Certificate serverLocal = server.getLocalCertificates()[0]; + java.security.cert.Certificate serverPeer = server.getPeerCertificates()[0]; + + log(String.format("Client local cert: %s%nClient peer cert: %s%n" + + "Server local cert: %s%nServer peer cert: %s%n", + clientLocal, clientPeer, serverLocal, serverPeer)); + + if (!clientLocal.equals(serverPeer)) { + throw new RuntimeException("Client's local certificate does " + + "not match server's peer certificate"); + } - System.out.println("unwrap1 = " + result1); - System.out.println("unwrap2 = " + result2); + if (!clientPeer.equals(serverLocal)) { + throw new RuntimeException("Client's peer certificate does " + + "not match server's local certificate"); + } - checkSession(ssls1, ssls2, ssls3, ssls4); - System.out.println(ssle1); - System.out.println(ssle2); + } catch (SSLPeerUnverifiedException e) { + throw new RuntimeException("Could not get peer certificate!", e); + } } - private static void checkSession(SSLSession ssls1, SSLSession ssls2, - SSLSession ssls3, SSLSession ssls4) throws Exception { - System.out.println("\nSession Info for SSLEngine1"); - System.out.println(ssls1); - System.out.println(ssls1.getCreationTime()); - String peer1 = ssls1.getPeerHost(); - System.out.println(peer1); - String protocol1 = ssls1.getProtocol(); - System.out.println(protocol1); - java.security.cert.Certificate cert1 = ssls1.getPeerCertificates()[0]; - System.out.println(cert1); - String ciphersuite1 = ssls1.getCipherSuite(); - System.out.println(ciphersuite1); - System.out.println(); - - System.out.println("\nSession Info for SSLEngine2"); - System.out.println(ssls2); - System.out.println(ssls2.getCreationTime()); - String peer2 = ssls2.getPeerHost(); - System.out.println(peer2); - String protocol2 = ssls2.getProtocol(); - System.out.println(protocol2); - java.security.cert.Certificate cert2 = ssls2.getPeerCertificates()[0]; - System.out.println(cert2); - String ciphersuite2 = ssls2.getCipherSuite(); - System.out.println(ciphersuite2); - System.out.println(); - - if (peer1.equals(peer2)) { - throw new Exception("peer hostnames not equal"); + private void checkEngineAndSession() + throws Exception { + String host = clientEngine.getPeerHost(); + int port = clientEngine.getPeerPort(); + if (!host.equals(HOSTNAME) || (port != PORT_NUMBER)) { + throw new Exception("Unexpected host/port from client engine." + + " Expected " + HOSTNAME + ":" + PORT_NUMBER + + " Received " +host + ":" + port); } - if (!protocol1.equals(protocol2)) { - throw new Exception("protocols not equal"); + host = serverEngine.getPeerHost(); + port = serverEngine.getPeerPort(); + if ((host != null) || (port != -1)) { + throw new Exception("Unexpected host/port from server engine." + + " Expected null:-1" + + " Received " + host + ":" + port); } - if (!cert1.equals(cert2)) { - throw new Exception("certs not equal"); - } + SSLSession clientSession = clientEngine.getSession(); - if (!ciphersuite1.equals(ciphersuite2)) { - throw new Exception("ciphersuites not equal"); + host = clientSession.getPeerHost(); + port = clientSession.getPeerPort(); + if (!host.equals(HOSTNAME) || (port != PORT_NUMBER)) { + throw new Exception("Unexpected host/port from client session." + + " Expected " + HOSTNAME + ":" + PORT_NUMBER + + " Received " + host + ":" + port); } - System.out.println("\nSession Info for SSLEngine3"); - System.out.println(ssls3); - System.out.println("\nSession Info for SSLEngine4"); - System.out.println(ssls4); + SSLSession serverSession = serverEngine.getSession(); - if (ssls3.equals(ssls1) || ssls4.equals(ssls2)) { - throw new Exception("sessions should not be equals"); + host = serverSession.getPeerHost(); + port = serverSession.getPeerPort(); + if ((host != null) || (port != -1)) { + throw new Exception("Unexpected host/port from server session." + + " Expected null:-1" + + " Received " + host + ":" + port); } + + } + + private static void log(Object msg) { + System.out.println(msg); } public static void main(String args[]) throws Exception { @@ -678,7 +599,8 @@ public static void main(String args[]) throws Exception { // and keys used in this test are not disabled. Security.setProperty("jdk.tls.disabledAlgorithms", ""); - ConnectionTest ct = new ConnectionTest(); + log(String.format("Running with %s and %s%n", args[0], args[1])); + ConnectionTest ct = new ConnectionTest(args[0], args[1]); ct.test(); } -} +} \ No newline at end of file From 26fb0f87897e7d7b193e08c1d69e6c0fa12c976c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 3 Oct 2023 20:31:34 +0000 Subject: [PATCH 176/341] 8299748: java/util/zip/Deinflate.java failing on s390x Backport-of: fee02f066879e77e55e217660daa46607778b6e8 --- test/jdk/java/util/zip/DeInflate.java | 71 +++++++++++++++++++-------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/test/jdk/java/util/zip/DeInflate.java b/test/jdk/java/util/zip/DeInflate.java index ff2cb63c6e7c5..7e7458bbb3790 100644 --- a/test/jdk/java/util/zip/DeInflate.java +++ b/test/jdk/java/util/zip/DeInflate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, 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 @@ -47,11 +47,12 @@ static void checkStream(Deflater def, byte[] in, int len, Arrays.fill(out1, (byte)0); Arrays.fill(out2, (byte)0); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (DeflaterOutputStream defos = new DeflaterOutputStream(baos, def)) { - defos.write(in, 0, len); + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + try (DeflaterOutputStream defos = new DeflaterOutputStream(baos, def)) { + defos.write(in, 0, len); + } + out1 = baos.toByteArray(); } - out1 = baos.toByteArray(); int m = out1.length; Inflater inf = new Inflater(nowrap); @@ -118,27 +119,55 @@ static void checkByteBufferReadonly(Deflater def, Inflater inf, } catch (ReadOnlyBufferException robe) {} } - static void check(Deflater def, byte[] in, int len, - byte[] out1, byte[] out2, boolean nowrap) + /** + * Uses the {@code def} deflater to deflate the input data {@code in} of length {@code len}. + * A new {@link Inflater} is then created within this method to inflate the deflated data. The + * inflated data is then compared with the {@code in} to assert that it matches the original + * input data. + * This method repeats these checks for the different overloaded methods of + * {@code Deflater.deflate(...)} and {@code Inflater.inflate(...)} + * + * @param def the deflater to use for deflating the contents in {@code in} + * @param in the input content + * @param len the length of the input content to use + * @param nowrap will be passed to the constructor of the {@code Inflater} used in this + * method + * @throws Throwable if any error occurs during the check + */ + static void check(Deflater def, byte[] in, int len, boolean nowrap) throws Throwable { - Arrays.fill(out1, (byte)0); - Arrays.fill(out2, (byte)0); - + byte[] tempBuffer = new byte[len]; + byte[] out1, out2; + int m = 0, n = 0; + Inflater inf = new Inflater(nowrap); def.setInput(in, 0, len); def.finish(); - int m = def.deflate(out1); - Inflater inf = new Inflater(nowrap); - inf.setInput(out1, 0, m); - int n = inf.inflate(out2); + try (ByteArrayOutputStream baos = new ByteArrayOutputStream(len)) { + while (!def.finished()) { + int temp_counter = def.deflate(tempBuffer); + m += temp_counter; + baos.write(tempBuffer, 0, temp_counter); + } + out1 = baos.toByteArray(); + baos.reset(); - if (n != len || - !Arrays.equals(Arrays.copyOf(in, len), Arrays.copyOf(out2, len)) || - inf.inflate(out2) != 0) { - System.out.printf("m=%d, n=%d, len=%d, eq=%b%n", - m, n, len, Arrays.equals(in, out2)); - throw new RuntimeException("De/inflater failed:" + def); + inf.setInput(out1, 0, m); + + while (!inf.finished()) { + int temp_counter = inf.inflate(tempBuffer); + n += temp_counter; + baos.write(tempBuffer, 0, temp_counter); + } + out2 = baos.toByteArray(); + if (n != len || + !Arrays.equals(in, 0, len, out2, 0, len) || + inf.inflate(out2) != 0) { + System.out.printf("m=%d, n=%d, len=%d, eq=%b%n", + m, n, len, Arrays.equals(in, out2)); + throw new RuntimeException("De/inflater failed:" + def); + } } // readable @@ -287,7 +316,7 @@ public static void main(String[] args) throws Throwable { : new Random().nextInt(dataIn.length); // use a new deflater Deflater def = newDeflater(level, strategy, dowrap, dataOut2); - check(def, dataIn, len, dataOut1, dataOut2, dowrap); + check(def, dataIn, len, dowrap); def.end(); // reuse the deflater (with reset) and test on stream, which From ceafbb759e515e4ca42de18a0d6423e35d176059 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 3 Oct 2023 20:43:58 +0000 Subject: [PATCH 177/341] 8295424: adjust timeout for another JLI GetObjectSizeIntrinsicsTest.java subtest 8297367: disable TestRedirectLinks.java in slowdebug mode Backport-of: 6e5470525d5236901c219146f363d4860e6b8008 --- .../lang/instrument/GetObjectSizeIntrinsicsTest.java | 2 +- .../javadoc/doclet/testLinkOption/TestRedirectLinks.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java b/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java index 369f1fc34a244..b8a8dbf93b511 100644 --- a/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java +++ b/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java @@ -288,7 +288,7 @@ * -Xbatch -XX:TieredStopAtLevel=1 * -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest large * - * @run main/othervm -Xmx8g + * @run main/othervm/timeout=180 -Xmx8g * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:. * -Xbatch -XX:-TieredCompilation * -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest large diff --git a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestRedirectLinks.java b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestRedirectLinks.java index ce7192cced9a8..d123fd2734ea4 100644 --- a/test/langtools/jdk/javadoc/doclet/testLinkOption/TestRedirectLinks.java +++ b/test/langtools/jdk/javadoc/doclet/testLinkOption/TestRedirectLinks.java @@ -26,11 +26,14 @@ * @bug 8190312 * @summary test redirected URLs for -link * @library /tools/lib ../../lib + * @library /test/lib * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.javadoc/jdk.javadoc.internal.api * jdk.javadoc/jdk.javadoc.internal.tool * @build toolbox.ToolBox toolbox.JavacTask javadoc.tester.* + * @build jtreg.SkippedException + * @build jdk.test.lib.Platform * @run main TestRedirectLinks */ @@ -66,12 +69,18 @@ import toolbox.JavacTask; import toolbox.ToolBox; +import jdk.test.lib.Platform; +import jtreg.SkippedException; + public class TestRedirectLinks extends JavadocTester { /** * The entry point of the test. * @param args the array of command line arguments. */ public static void main(String... args) throws Exception { + if (Platform.isSlowDebugBuild()) { + throw new SkippedException("Test is unstable with slowdebug bits"); + } TestRedirectLinks tester = new TestRedirectLinks(); tester.runTests(); } From cde511da4c98f6fd788acb4f79d58312826857ea Mon Sep 17 00:00:00 2001 From: Fei Yang Date: Wed, 4 Oct 2023 12:32:01 +0000 Subject: [PATCH 178/341] 8316743: RISC-V: Change UseVectorizedMismatchIntrinsic option result to warning Backport-of: 750da0012931656cfd55f3e67c3f49ad7363ab8e --- src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp | 2 +- src/hotspot/cpu/riscv/vm_version_riscv.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp index 55a309f24ba07..5a44d8f59a8af 100644 --- a/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRGenerator_riscv.cpp @@ -804,7 +804,7 @@ void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) { } void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) { - fatal("vectorizedMismatch intrinsic is not implemented on this platform"); + ShouldNotReachHere(); } // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index 1f66b29816a4f..1ce789dcc47f2 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -111,6 +111,11 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseCRC32CIntrinsics, false); } + if (UseVectorizedMismatchIntrinsic) { + warning("VectorizedMismatch intrinsic is not available on this CPU."); + FLAG_SET_DEFAULT(UseVectorizedMismatchIntrinsic, false); + } + if (FLAG_IS_DEFAULT(UseMD5Intrinsics)) { FLAG_SET_DEFAULT(UseMD5Intrinsics, true); } From 2589bf35e6a478ab762e559f97906b01a3d80448 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 4 Oct 2023 12:37:28 +0000 Subject: [PATCH 179/341] 8316514: Better diagnostic header for VtableStub Backport-of: 6c61bc195090abf73683b811e214810a1226d299 --- src/hotspot/share/code/vtableStubs.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/code/vtableStubs.cpp b/src/hotspot/share/code/vtableStubs.cpp index d490adb3eeff9..7ea2d19fcd3af 100644 --- a/src/hotspot/share/code/vtableStubs.cpp +++ b/src/hotspot/share/code/vtableStubs.cpp @@ -230,8 +230,9 @@ address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) { enter(is_vtable_stub, vtable_index, s); if (PrintAdapterHandlers) { - tty->print_cr("Decoding VtableStub %s[%d]@" INTX_FORMAT, - is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location())); + tty->print_cr("Decoding VtableStub %s[%d]@" PTR_FORMAT " [" PTR_FORMAT ", " PTR_FORMAT "] (" SIZE_FORMAT " bytes)", + is_vtable_stub? "vtbl": "itbl", vtable_index, p2i(VtableStub::receiver_location()), + p2i(s->code_begin()), p2i(s->code_end()), pointer_delta(s->code_end(), s->code_begin(), 1)); Disassembler::decode(s->code_begin(), s->code_end()); } // Notify JVMTI about this stub. The event will be recorded by the enclosing From fa40b5f0248525743f65a2b871394a9be29d9868 Mon Sep 17 00:00:00 2001 From: Soumadipta Roy Date: Wed, 4 Oct 2023 17:59:14 +0000 Subject: [PATCH 180/341] 8315766: Parallelize gc/stress/TestStressIHOPMultiThread.java test Backport-of: edd454b502b9bacde55492820e52655bbac63b89 --- .../gc/stress/TestStressIHOPMultiThread.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/gc/stress/TestStressIHOPMultiThread.java b/test/hotspot/jtreg/gc/stress/TestStressIHOPMultiThread.java index fc630e3fdb60b..4c288e7b48630 100644 --- a/test/hotspot/jtreg/gc/stress/TestStressIHOPMultiThread.java +++ b/test/hotspot/jtreg/gc/stress/TestStressIHOPMultiThread.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 @@ -24,7 +24,7 @@ package gc.stress; /* - * @test TestStressIHOPMultiThread + * @test * @bug 8148397 * @key stress * @summary Stress test for IHOP @@ -34,21 +34,41 @@ * -Xlog:gc+ihop=debug,gc+ihop+ergo=debug,gc+ergo=debug:TestStressIHOPMultiThread1.log * -Dtimeout=2 -DheapUsageMinBound=30 -DheapUsageMaxBound=80 * -Dthreads=2 gc.stress.TestStressIHOPMultiThread + */ + +/* + * @test + * @requires vm.gc.G1 * @run main/othervm/timeout=200 -Xmx256m -XX:G1HeapWastePercent=0 -XX:G1MixedGCCountTarget=1 * -XX:+UseG1GC -XX:G1HeapRegionSize=2m -XX:+G1UseAdaptiveIHOP * -Xlog:gc+ihop=debug,gc+ihop+ergo=debug,gc+ergo=debug:TestStressIHOPMultiThread2.log * -Dtimeout=2 -DheapUsageMinBound=60 -DheapUsageMaxBound=90 * -Dthreads=3 gc.stress.TestStressIHOPMultiThread + */ + +/* + * @test + * @requires vm.gc.G1 * @run main/othervm/timeout=200 -Xmx256m -XX:G1HeapWastePercent=0 -XX:G1MixedGCCountTarget=1 * -XX:+UseG1GC -XX:G1HeapRegionSize=4m -XX:-G1UseAdaptiveIHOP * -Xlog:gc+ihop=debug,gc+ihop+ergo=debug,gc+ergo=debug:TestStressIHOPMultiThread3.log * -Dtimeout=2 -DheapUsageMinBound=40 -DheapUsageMaxBound=90 * -Dthreads=5 gc.stress.TestStressIHOPMultiThread + */ + +/* + * @test + * @requires vm.gc.G1 * @run main/othervm/timeout=200 -Xmx128m -XX:G1HeapWastePercent=0 -XX:G1MixedGCCountTarget=1 * -XX:+UseG1GC -XX:G1HeapRegionSize=8m -XX:+G1UseAdaptiveIHOP * -Xlog:gc+ihop=debug,gc+ihop+ergo=debug,gc+ergo=debug:TestStressIHOPMultiThread4.log * -Dtimeout=2 -DheapUsageMinBound=20 -DheapUsageMaxBound=90 * -Dthreads=10 gc.stress.TestStressIHOPMultiThread + */ + +/* + * @test + * @requires vm.gc.G1 * @run main/othervm/timeout=200 -Xmx512m -XX:G1HeapWastePercent=0 -XX:G1MixedGCCountTarget=1 * -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:+G1UseAdaptiveIHOP * -Xlog:gc+ihop=debug,gc+ihop+ergo=debug,gc+ergo=debug:TestStressIHOPMultiThread5.log From aa5475013e522fe1383a7ab77fd8bf3553ccf70b Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 4 Oct 2023 19:07:41 +0000 Subject: [PATCH 181/341] 8281015: Further simplify NMT backend Reviewed-by: lucy Backport-of: b96b743727a628c1b33cc9b3374f010c2ea30b78 --- src/hotspot/share/runtime/os.cpp | 29 +++--- .../share/services/mallocSiteTable.cpp | 22 +++-- .../share/services/mallocSiteTable.hpp | 39 +++++--- src/hotspot/share/services/mallocTracker.cpp | 71 +++++++------ src/hotspot/share/services/mallocTracker.hpp | 99 +++++-------------- .../share/services/mallocTracker.inline.hpp | 36 ------- src/hotspot/share/services/memTracker.cpp | 6 +- src/hotspot/share/services/memTracker.hpp | 38 +++---- src/hotspot/share/services/nmtCommon.hpp | 4 +- src/hotspot/share/utilities/debug.cpp | 4 + 10 files changed, 129 insertions(+), 219 deletions(-) delete mode 100644 src/hotspot/share/services/mallocTracker.inline.hpp diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index 369e5c4f5fabd..3b80b7f34deeb 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -669,23 +669,19 @@ void* os::malloc(size_t size, MEMFLAGS memflags, const NativeCallStack& stack) { return NULL; } - const NMT_TrackingLevel level = MemTracker::tracking_level(); - const size_t nmt_overhead = - MemTracker::malloc_header_size(level) + MemTracker::malloc_footer_size(level); - - const size_t outer_size = size + nmt_overhead; + const size_t outer_size = size + MemTracker::overhead_per_malloc(); // Check for overflow. if (outer_size < size) { return NULL; } - void* const outer_ptr = (u_char*)::malloc(outer_size); + void* const outer_ptr = ::malloc(outer_size); if (outer_ptr == NULL) { return NULL; } - void* inner_ptr = MemTracker::record_malloc((address)outer_ptr, size, memflags, stack, level); + void* const inner_ptr = MemTracker::record_malloc((address)outer_ptr, size, memflags, stack); DEBUG_ONLY(::memset(inner_ptr, uninitBlockPad, size);) DEBUG_ONLY(break_if_ptr_caught(inner_ptr);) @@ -724,19 +720,17 @@ void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCa return NULL; } - const NMT_TrackingLevel level = MemTracker::tracking_level(); - const size_t nmt_overhead = - MemTracker::malloc_header_size(level) + MemTracker::malloc_footer_size(level); - - const size_t new_outer_size = size + nmt_overhead; + const size_t new_outer_size = size + MemTracker::overhead_per_malloc(); // If NMT is enabled, this checks for heap overwrites, then de-accounts the old block. - void* const old_outer_ptr = MemTracker::record_free(memblock, level); + void* const old_outer_ptr = MemTracker::record_free(memblock); void* const new_outer_ptr = ::realloc(old_outer_ptr, new_outer_size); + if (new_outer_ptr == NULL) { + return NULL; + } - // If NMT is enabled, this checks for heap overwrites, then de-accounts the old block. - void* const new_inner_ptr = MemTracker::record_malloc(new_outer_ptr, size, memflags, stack, level); + void* const new_inner_ptr = MemTracker::record_malloc(new_outer_ptr, size, memflags, stack); DEBUG_ONLY(break_if_ptr_caught(new_inner_ptr);) @@ -757,10 +751,9 @@ void os::free(void *memblock) { DEBUG_ONLY(break_if_ptr_caught(memblock);) - const NMT_TrackingLevel level = MemTracker::tracking_level(); - // If NMT is enabled, this checks for heap overwrites, then de-accounts the old block. - void* const old_outer_ptr = MemTracker::record_free(memblock, level); + void* const old_outer_ptr = MemTracker::record_free(memblock); + ::free(old_outer_ptr); } diff --git a/src/hotspot/share/services/mallocSiteTable.cpp b/src/hotspot/share/services/mallocSiteTable.cpp index 2670c138daa15..f8d30e1dca918 100644 --- a/src/hotspot/share/services/mallocSiteTable.cpp +++ b/src/hotspot/share/services/mallocSiteTable.cpp @@ -106,13 +106,11 @@ bool MallocSiteTable::walk(MallocSiteWalker* walker) { * 2. Overflow hash bucket. * Under any of above circumstances, caller should handle the situation. */ -MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, size_t* bucket_idx, - size_t* pos_idx, MEMFLAGS flags) { +MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, uint32_t* marker, MEMFLAGS flags) { assert(flags != mtNone, "Should have a real memory type"); const unsigned int hash = key.calculate_hash(); const unsigned int index = hash_to_index(hash); - *bucket_idx = (size_t)index; - *pos_idx = 0; + *marker = 0; // First entry for this hash bucket if (_table[index] == NULL) { @@ -122,41 +120,47 @@ MallocSite* MallocSiteTable::lookup_or_add(const NativeCallStack& key, size_t* b // swap in the head if (Atomic::replace_if_null(&_table[index], entry)) { + *marker = build_marker(index, 0); return entry->data(); } delete entry; } + unsigned pos_idx = 0; MallocSiteHashtableEntry* head = _table[index]; - while (head != NULL && (*pos_idx) <= MAX_BUCKET_LENGTH) { + while (head != NULL && pos_idx < MAX_BUCKET_LENGTH) { if (head->hash() == hash) { MallocSite* site = head->data(); if (site->flag() == flags && site->equals(key)) { + *marker = build_marker(index, pos_idx); return head->data(); } } - if (head->next() == NULL && (*pos_idx) < MAX_BUCKET_LENGTH) { + if (head->next() == NULL && pos_idx < (MAX_BUCKET_LENGTH - 1)) { MallocSiteHashtableEntry* entry = new_entry(key, flags); // OOM check if (entry == NULL) return NULL; if (head->atomic_insert(entry)) { - (*pos_idx) ++; + pos_idx ++; + *marker = build_marker(index, pos_idx); return entry->data(); } // contended, other thread won delete entry; } head = (MallocSiteHashtableEntry*)head->next(); - (*pos_idx) ++; + pos_idx ++; } return NULL; } // Access malloc site -MallocSite* MallocSiteTable::malloc_site(size_t bucket_idx, size_t pos_idx) { +MallocSite* MallocSiteTable::malloc_site(uint32_t marker) { + uint16_t bucket_idx = bucket_idx_from_marker(marker); assert(bucket_idx < table_size, "Invalid bucket index"); + const uint16_t pos_idx = pos_idx_from_marker(marker); MallocSiteHashtableEntry* head = _table[bucket_idx]; for (size_t index = 0; index < pos_idx && head != NULL; diff --git a/src/hotspot/share/services/mallocSiteTable.hpp b/src/hotspot/share/services/mallocSiteTable.hpp index 6e026f9704c86..6f18145157f86 100644 --- a/src/hotspot/share/services/mallocSiteTable.hpp +++ b/src/hotspot/share/services/mallocSiteTable.hpp @@ -114,11 +114,22 @@ class MallocSiteTable : AllStatic { table_size = (table_base_size * NMT_TrackingStackDepth - 1) }; - // The table must not be wider than the maximum value the bucket_idx field - // in the malloc header can hold. + // Table cannot be wider than a 16bit bucket idx can hold +#define MAX_MALLOCSITE_TABLE_SIZE (USHRT_MAX - 1) + // Each bucket chain cannot be longer than what a 16 bit pos idx can hold (hopefully way shorter) +#define MAX_BUCKET_LENGTH (USHRT_MAX - 1) + STATIC_ASSERT(table_size <= MAX_MALLOCSITE_TABLE_SIZE); + static uint32_t build_marker(unsigned bucket_idx, unsigned pos_idx) { + assert(bucket_idx <= MAX_MALLOCSITE_TABLE_SIZE && pos_idx < MAX_BUCKET_LENGTH, "overflow"); + return (uint32_t)bucket_idx << 16 | pos_idx; + } + static uint16_t bucket_idx_from_marker(uint32_t marker) { return marker >> 16; } + static uint16_t pos_idx_from_marker(uint32_t marker) { return marker & 0xFFFF; } + public: + static bool initialize(); // Number of hash buckets @@ -126,9 +137,8 @@ class MallocSiteTable : AllStatic { // Access and copy a call stack from this table. Shared lock should be // acquired before access the entry. - static inline bool access_stack(NativeCallStack& stack, size_t bucket_idx, - size_t pos_idx) { - MallocSite* site = malloc_site(bucket_idx, pos_idx); + static inline bool access_stack(NativeCallStack& stack, uint32_t marker) { + MallocSite* site = malloc_site(marker); if (site != NULL) { stack = *site->call_stack(); return true; @@ -137,23 +147,22 @@ class MallocSiteTable : AllStatic { } // Record a new allocation from specified call path. - // Return true if the allocation is recorded successfully, bucket_idx - // and pos_idx are also updated to indicate the entry where the allocation - // information was recorded. + // Return true if the allocation is recorded successfully and updates marker + // to indicate the entry where the allocation information was recorded. // Return false only occurs under rare scenarios: // 1. out of memory // 2. overflow hash bucket static inline bool allocation_at(const NativeCallStack& stack, size_t size, - size_t* bucket_idx, size_t* pos_idx, MEMFLAGS flags) { - MallocSite* site = lookup_or_add(stack, bucket_idx, pos_idx, flags); + uint32_t* marker, MEMFLAGS flags) { + MallocSite* site = lookup_or_add(stack, marker, flags); if (site != NULL) site->allocate(size); return site != NULL; } - // Record memory deallocation. bucket_idx and pos_idx indicate where the allocation + // Record memory deallocation. marker indicates where the allocation // information was recorded. - static inline bool deallocation_at(size_t size, size_t bucket_idx, size_t pos_idx) { - MallocSite* site = malloc_site(bucket_idx, pos_idx); + static inline bool deallocation_at(size_t size, uint32_t marker) { + MallocSite* site = malloc_site(marker); if (site != NULL) { site->deallocate(size); return true; @@ -173,8 +182,8 @@ class MallocSiteTable : AllStatic { // Delete a bucket linked list static void delete_linked_list(MallocSiteHashtableEntry* head); - static MallocSite* lookup_or_add(const NativeCallStack& key, size_t* bucket_idx, size_t* pos_idx, MEMFLAGS flags); - static MallocSite* malloc_site(size_t bucket_idx, size_t pos_idx); + static MallocSite* lookup_or_add(const NativeCallStack& key, uint32_t* marker, MEMFLAGS flags); + static MallocSite* malloc_site(uint32_t marker); static bool walk(MallocSiteWalker* walker); static inline unsigned int hash_to_index(unsigned int hash) { diff --git a/src/hotspot/share/services/mallocTracker.cpp b/src/hotspot/share/services/mallocTracker.cpp index 285a60d853f95..85ddf37faa4b2 100644 --- a/src/hotspot/share/services/mallocTracker.cpp +++ b/src/hotspot/share/services/mallocTracker.cpp @@ -26,7 +26,6 @@ #include "runtime/os.hpp" #include "services/mallocSiteTable.hpp" #include "services/mallocTracker.hpp" -#include "services/mallocTracker.inline.hpp" #include "services/memTracker.hpp" #include "utilities/debug.hpp" #include "utilities/ostream.hpp" @@ -112,20 +111,6 @@ void MallocHeader::mark_block_as_dead() { set_footer(_footer_canary_dead_mark); } -void MallocHeader::release() { - assert(MemTracker::enabled(), "Sanity"); - - check_block_integrity(); - - MallocMemorySummary::record_free(size(), flags()); - MallocMemorySummary::record_free_malloc_header(sizeof(MallocHeader)); - if (MemTracker::tracking_level() == NMT_detail) { - MallocSiteTable::deallocation_at(size(), _bucket_idx, _pos_idx); - } - - mark_block_as_dead(); -} - void MallocHeader::print_block_on_error(outputStream* st, address bad_address) const { assert(bad_address >= (address)this, "sanity"); @@ -219,13 +204,8 @@ void MallocHeader::check_block_integrity() const { #undef PREFIX } -bool MallocHeader::record_malloc_site(const NativeCallStack& stack, size_t size, - size_t* bucket_idx, size_t* pos_idx, MEMFLAGS flags) const { - return MallocSiteTable::allocation_at(stack, size, bucket_idx, pos_idx, flags); -} - bool MallocHeader::get_stack(NativeCallStack& stack) const { - return MallocSiteTable::access_stack(stack, _bucket_idx, _pos_idx); + return MallocSiteTable::access_stack(stack, _mst_marker); } bool MallocTracker::initialize(NMT_TrackingLevel level) { @@ -241,29 +221,33 @@ bool MallocTracker::initialize(NMT_TrackingLevel level) { // Record a malloc memory allocation void* MallocTracker::record_malloc(void* malloc_base, size_t size, MEMFLAGS flags, - const NativeCallStack& stack, NMT_TrackingLevel level) { - assert(level != NMT_off, "precondition"); - void* memblock; // the address for user data - MallocHeader* header = NULL; - - if (malloc_base == NULL) { - return NULL; + const NativeCallStack& stack) +{ + assert(MemTracker::enabled(), "precondition"); + assert(malloc_base != NULL, "precondition"); + + MallocMemorySummary::record_malloc(size, flags); + MallocMemorySummary::record_new_malloc_header(sizeof(MallocHeader)); + uint32_t mst_marker = 0; + if (MemTracker::tracking_level() == NMT_detail) { + MallocSiteTable::allocation_at(stack, size, &mst_marker, flags); } // Uses placement global new operator to initialize malloc header - - header = ::new (malloc_base)MallocHeader(size, flags, stack, level); - memblock = (void*)((char*)malloc_base + sizeof(MallocHeader)); + MallocHeader* const header = ::new (malloc_base)MallocHeader(size, flags, stack, mst_marker); + void* const memblock = (void*)((char*)malloc_base + sizeof(MallocHeader)); // The alignment check: 8 bytes alignment for 32 bit systems. // 16 bytes alignment for 64-bit systems. assert(((size_t)memblock & (sizeof(size_t) * 2 - 1)) == 0, "Alignment check"); #ifdef ASSERT - if (level > NMT_off) { - // Read back - assert(get_size(memblock) == size, "Wrong size"); - assert(get_flags(memblock) == flags, "Wrong flags"); + // Read back + { + MallocHeader* const header2 = malloc_header(memblock); + assert(header2->size() == size, "Wrong size"); + assert(header2->flags() == flags, "Wrong flags"); + header2->check_block_integrity(); } #endif @@ -271,8 +255,19 @@ void* MallocTracker::record_malloc(void* malloc_base, size_t size, MEMFLAGS flag } void* MallocTracker::record_free(void* memblock) { - assert(MemTracker::tracking_level() != NMT_off && memblock != NULL, "precondition"); - MallocHeader* header = malloc_header(memblock); - header->release(); + assert(MemTracker::enabled(), "Sanity"); + assert(memblock != NULL, "precondition"); + + MallocHeader* const header = malloc_header(memblock); + header->check_block_integrity(); + + MallocMemorySummary::record_free(header->size(), header->flags()); + MallocMemorySummary::record_free_malloc_header(sizeof(MallocHeader)); + if (MemTracker::tracking_level() == NMT_detail) { + MallocSiteTable::deallocation_at(header->size(), header->mst_marker()); + } + + header->mark_block_as_dead(); + return (void*)header; } diff --git a/src/hotspot/share/services/mallocTracker.hpp b/src/hotspot/share/services/mallocTracker.hpp index 6490b3d53ffd2..22296a33e1313 100644 --- a/src/hotspot/share/services/mallocTracker.hpp +++ b/src/hotspot/share/services/mallocTracker.hpp @@ -267,7 +267,7 @@ class MallocMemorySummary : AllStatic { * * 8 9 10 11 12 13 14 15 16 ++ * +--------+--------+--------+--------+--------+--------+--------+--------+ ------------------------ - * ... | bucket idx | pos idx | flags | unused | canary | ... User payload .... + * ... | malloc site table marker | flags | unused | canary | ... User payload .... * +--------+--------+--------+--------+--------+--------+--------+--------+ ------------------------ * * Layout on 32-bit: @@ -279,7 +279,7 @@ class MallocMemorySummary : AllStatic { * * 8 9 10 11 12 13 14 15 16 ++ * +--------+--------+--------+--------+--------+--------+--------+--------+ ------------------------ - * ... | bucket idx | pos idx | flags | unused | canary | ... User payload .... + * ... | malloc site table marker | flags | unused | canary | ... User payload .... * +--------+--------+--------+--------+--------+--------+--------+--------+ ------------------------ * * Notes: @@ -294,16 +294,12 @@ class MallocMemorySummary : AllStatic { class MallocHeader { NOT_LP64(uint32_t _alt_canary); - size_t _size; - uint16_t _bucket_idx; - uint16_t _pos_idx; - uint8_t _flags; - uint8_t _unused; + const size_t _size; + const uint32_t _mst_marker; + const uint8_t _flags; + const uint8_t _unused; uint16_t _canary; -#define MAX_MALLOCSITE_TABLE_SIZE (USHRT_MAX - 1) -#define MAX_BUCKET_LENGTH (USHRT_MAX - 1) - static const uint16_t _header_canary_life_mark = 0xE99E; static const uint16_t _header_canary_dead_mark = 0xD99D; static const uint16_t _footer_canary_life_mark = 0xE88E; @@ -314,12 +310,7 @@ class MallocHeader { // We discount sizes larger than these static const size_t max_reasonable_malloc_size = LP64_ONLY(256 * G) NOT_LP64(3500 * M); - // Check block integrity. If block is broken, print out a report - // to tty (optionally with hex dump surrounding the broken block), - // then trigger a fatal error. - void check_block_integrity() const; void print_block_on_error(outputStream* st, address bad_address) const; - void mark_block_as_dead(); static uint16_t build_footer(uint8_t b1, uint8_t b2) { return ((uint16_t)b1 << 8) | (uint16_t)b2; } @@ -329,46 +320,28 @@ class MallocHeader { public: - MallocHeader(size_t size, MEMFLAGS flags, const NativeCallStack& stack, NMT_TrackingLevel level) { + MallocHeader(size_t size, MEMFLAGS flags, const NativeCallStack& stack, uint32_t mst_marker) + : _size(size), _mst_marker(mst_marker), _flags(NMTUtil::flag_to_index(flags)), + _unused(0), _canary(_header_canary_life_mark) + { assert(size < max_reasonable_malloc_size, "Too large allocation size?"); - - _flags = NMTUtil::flag_to_index(flags); - set_size(size); - if (level == NMT_detail) { - size_t bucket_idx; - size_t pos_idx; - if (record_malloc_site(stack, size, &bucket_idx, &pos_idx, flags)) { - assert(bucket_idx <= MAX_MALLOCSITE_TABLE_SIZE, "Overflow bucket index"); - assert(pos_idx <= MAX_BUCKET_LENGTH, "Overflow bucket position index"); - _bucket_idx = (uint16_t)bucket_idx; - _pos_idx = (uint16_t)pos_idx; - } - } - - _unused = 0; - _canary = _header_canary_life_mark; // On 32-bit we have some bits more, use them for a second canary // guarding the start of the header. NOT_LP64(_alt_canary = _header_alt_canary_life_mark;) set_footer(_footer_canary_life_mark); // set after initializing _size - - MallocMemorySummary::record_malloc(size, flags); - MallocMemorySummary::record_new_malloc_header(sizeof(MallocHeader)); } inline size_t size() const { return _size; } inline MEMFLAGS flags() const { return (MEMFLAGS)_flags; } + inline uint32_t mst_marker() const { return _mst_marker; } bool get_stack(NativeCallStack& stack) const; - // Cleanup tracking information and mark block as dead before the memory is released. - void release(); + void mark_block_as_dead(); - private: - inline void set_size(size_t size) { - _size = size; - } - bool record_malloc_site(const NativeCallStack& stack, size_t size, - size_t* bucket_idx, size_t* pos_idx, MEMFLAGS flags) const; + // Check block integrity. If block is broken, print out a report + // to tty (optionally with hex dump surrounding the broken block), + // then trigger a fatal error. + void check_block_integrity() const; }; // This needs to be true on both 64-bit and 32-bit platforms @@ -381,15 +354,9 @@ class MallocTracker : AllStatic { // Initialize malloc tracker for specific tracking level static bool initialize(NMT_TrackingLevel level); - // malloc tracking header size for specific tracking level - static inline size_t malloc_header_size(NMT_TrackingLevel level) { - return (level == NMT_off) ? 0 : sizeof(MallocHeader); - } - - // malloc tracking footer size for specific tracking level - static inline size_t malloc_footer_size(NMT_TrackingLevel level) { - return (level == NMT_off) ? 0 : sizeof(uint16_t); - } + // The overhead that is incurred by switching on NMT (we need, per malloc allocation, + // space for header and 16-bit footer) + static const size_t overhead_per_malloc = sizeof(MallocHeader) + sizeof(uint16_t); // Parameter name convention: // memblock : the beginning address for user data @@ -401,30 +368,11 @@ class MallocTracker : AllStatic { // Record malloc on specified memory block static void* record_malloc(void* malloc_base, size_t size, MEMFLAGS flags, - const NativeCallStack& stack, NMT_TrackingLevel level); + const NativeCallStack& stack); // Record free on specified memory block static void* record_free(void* memblock); - // Offset memory address to header address - static inline void* get_base(void* memblock); - static inline void* get_base(void* memblock, NMT_TrackingLevel level) { - if (memblock == NULL || level == NMT_off) return memblock; - return (char*)memblock - malloc_header_size(level); - } - - // Get memory size - static inline size_t get_size(void* memblock) { - MallocHeader* header = malloc_header(memblock); - return header->size(); - } - - // Get memory type - static inline MEMFLAGS get_flags(void* memblock) { - MallocHeader* header = malloc_header(memblock); - return header->flags(); - } - static inline void record_new_arena(MEMFLAGS flags) { MallocMemorySummary::record_new_arena(flags); } @@ -439,8 +387,11 @@ class MallocTracker : AllStatic { private: static inline MallocHeader* malloc_header(void *memblock) { assert(memblock != NULL, "NULL pointer"); - MallocHeader* header = (MallocHeader*)((char*)memblock - sizeof(MallocHeader)); - return header; + return (MallocHeader*)((char*)memblock - sizeof(MallocHeader)); + } + static inline const MallocHeader* malloc_header(const void *memblock) { + assert(memblock != NULL, "NULL pointer"); + return (const MallocHeader*)((const char*)memblock - sizeof(MallocHeader)); } }; diff --git a/src/hotspot/share/services/mallocTracker.inline.hpp b/src/hotspot/share/services/mallocTracker.inline.hpp deleted file mode 100644 index b73e1d42adb24..0000000000000 --- a/src/hotspot/share/services/mallocTracker.inline.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_SERVICES_MALLOCTRACKER_INLINE_HPP -#define SHARE_SERVICES_MALLOCTRACKER_INLINE_HPP - -#include "services/mallocTracker.hpp" - -#include "services/memTracker.hpp" - -inline void* MallocTracker::get_base(void* memblock){ - return get_base(memblock, MemTracker::tracking_level()); -} - -#endif // SHARE_SERVICES_MALLOCTRACKER_INLINE_HPP diff --git a/src/hotspot/share/services/memTracker.cpp b/src/hotspot/share/services/memTracker.cpp index 1037ec27418b9..343703213ad6a 100644 --- a/src/hotspot/share/services/memTracker.cpp +++ b/src/hotspot/share/services/memTracker.cpp @@ -33,7 +33,7 @@ #include "runtime/vmOperations.hpp" #include "services/memBaseline.hpp" #include "services/memReporter.hpp" -#include "services/mallocTracker.inline.hpp" +#include "services/mallocTracker.hpp" #include "services/memTracker.hpp" #include "services/nmtCommon.hpp" #include "services/nmtPreInit.hpp" @@ -90,10 +90,6 @@ void MemTracker::initialize() { } } -void* MemTracker::malloc_base(void* memblock) { - return MallocTracker::get_base(memblock); -} - void Tracker::record(address addr, size_t size) { if (MemTracker::tracking_level() < NMT_summary) return; switch(_type) { diff --git a/src/hotspot/share/services/memTracker.hpp b/src/hotspot/share/services/memTracker.hpp index 41d93dd294ea7..b6788391ee681 100644 --- a/src/hotspot/share/services/memTracker.hpp +++ b/src/hotspot/share/services/memTracker.hpp @@ -26,6 +26,7 @@ #define SHARE_SERVICES_MEMTRACKER_HPP #include "services/nmtCommon.hpp" +#include "utilities/debug.hpp" #include "utilities/nativeCallStack.hpp" @@ -50,17 +51,18 @@ class MemTracker : AllStatic { public: static inline NMT_TrackingLevel tracking_level() { return NMT_off; } static inline bool enabled() { return false; } + static size_t overhead_per_malloc() { return 0; } static inline void init() { } static bool check_launcher_nmt_support(const char* value) { return true; } static bool verify_nmt_option() { return true; } static inline void* record_malloc(void* mem_base, size_t size, MEMFLAGS flag, - const NativeCallStack& stack, NMT_TrackingLevel level) { return mem_base; } + const NativeCallStack& stack) { return mem_base; } static inline size_t malloc_header_size(NMT_TrackingLevel level) { return 0; } static inline size_t malloc_header_size(void* memblock) { return 0; } static inline size_t malloc_footer_size(NMT_TrackingLevel level) { return 0; } static inline void* malloc_base(void* memblock) { return memblock; } - static inline void* record_free(void* memblock, NMT_TrackingLevel level) { return memblock; } + static inline void* record_free(void* memblock) { return memblock; } static inline void record_new_arena(MEMFLAGS flag) { } static inline void record_arena_free(MEMFLAGS flag) { } @@ -141,38 +143,30 @@ class MemTracker : AllStatic { return _tracking_level > NMT_off; } + // Per-malloc overhead incurred by NMT, depending on the current NMT level + static size_t overhead_per_malloc() { + return enabled() ? MallocTracker::overhead_per_malloc : 0; + } + static inline void* record_malloc(void* mem_base, size_t size, MEMFLAGS flag, - const NativeCallStack& stack, NMT_TrackingLevel level) { - if (level != NMT_off) { - return MallocTracker::record_malloc(mem_base, size, flag, stack, level); + const NativeCallStack& stack) { + assert(mem_base != NULL, "caller should handle NULL"); + if (enabled()) { + return MallocTracker::record_malloc(mem_base, size, flag, stack); } return mem_base; } - static inline size_t malloc_header_size(NMT_TrackingLevel level) { - return MallocTracker::malloc_header_size(level); - } - - // malloc tracking footer size for specific tracking level - static inline size_t malloc_footer_size(NMT_TrackingLevel level) { - return MallocTracker::malloc_footer_size(level); - } - - // To malloc base address, which is the starting address - // of malloc tracking header if tracking is enabled. - // Otherwise, it returns the same address. - static void* malloc_base(void* memblock); - // Record malloc free and return malloc base address - static inline void* record_free(void* memblock, NMT_TrackingLevel level) { + static inline void* record_free(void* memblock) { // Never turned on - if (level == NMT_off || memblock == NULL) { + assert(memblock != NULL, "caller should handle NULL"); + if (!enabled()) { return memblock; } return MallocTracker::record_free(memblock); } - // Record creation of an arena static inline void record_new_arena(MEMFLAGS flag) { if (!enabled()) return; diff --git a/src/hotspot/share/services/nmtCommon.hpp b/src/hotspot/share/services/nmtCommon.hpp index b573fb6b7dfa7..88b84c9461374 100644 --- a/src/hotspot/share/services/nmtCommon.hpp +++ b/src/hotspot/share/services/nmtCommon.hpp @@ -87,7 +87,7 @@ class NMTUtil : AllStatic { // Map memory type to index static inline int flag_to_index(MEMFLAGS flag) { - assert(flag_is_valid(flag), "Invalid flag"); + assert(flag_is_valid(flag), "Invalid flag (%u)", (unsigned)flag); return static_cast(flag); } @@ -98,7 +98,7 @@ class NMTUtil : AllStatic { // Map an index to memory type static MEMFLAGS index_to_flag(int index) { - assert(flag_index_is_valid(index), "Invalid flag"); + assert(flag_index_is_valid(index), "Invalid flag index (%d)", index); return static_cast(index); } diff --git a/src/hotspot/share/utilities/debug.cpp b/src/hotspot/share/utilities/debug.cpp index 809e8d97f8099..ddb551dd0048e 100644 --- a/src/hotspot/share/utilities/debug.cpp +++ b/src/hotspot/share/utilities/debug.cpp @@ -476,6 +476,10 @@ extern "C" JNIEXPORT void verify() { extern "C" JNIEXPORT void pp(void* p) { Command c("pp"); FlagSetting fl(DisplayVMOutput, true); + if (p == NULL) { + tty->print_cr("NULL"); + return; + } if (Universe::heap()->is_in(p)) { oop obj = cast_to_oop(p); obj->print(); From 76fd18e1288ee0ac604b58aaa3eeb0cff4016e18 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 4 Oct 2023 19:22:04 +0000 Subject: [PATCH 182/341] 8292072: NMT: repurpose Tracking overhead counter as global malloc counter Reviewed-by: lucy Backport-of: 1c1c4410b20f598c7e81fae044b6cb298ed12bab --- src/hotspot/share/services/mallocTracker.cpp | 22 +----------- src/hotspot/share/services/mallocTracker.hpp | 35 ++++++++++---------- src/hotspot/share/services/memBaseline.hpp | 2 +- src/hotspot/share/services/memReporter.cpp | 8 ++--- 4 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/hotspot/share/services/mallocTracker.cpp b/src/hotspot/share/services/mallocTracker.cpp index 85ddf37faa4b2..5b5baad0b9666 100644 --- a/src/hotspot/share/services/mallocTracker.cpp +++ b/src/hotspot/share/services/mallocTracker.cpp @@ -62,25 +62,6 @@ size_t MemoryCounter::peak_size() const { } #endif -// Total malloc invocation count -size_t MallocMemorySnapshot::total_count() const { - size_t amount = 0; - for (int index = 0; index < mt_number_of_types; index ++) { - amount += _malloc[index].malloc_count(); - } - return amount; -} - -// Total malloc'd memory amount -size_t MallocMemorySnapshot::total() const { - size_t amount = 0; - for (int index = 0; index < mt_number_of_types; index ++) { - amount += _malloc[index].malloc_size(); - } - amount += _tracking_header.size() + total_arena(); - return amount; -} - // Total malloc'd memory used by arenas size_t MallocMemorySnapshot::total_arena() const { size_t amount = 0; @@ -96,6 +77,7 @@ void MallocMemorySnapshot::make_adjustment() { size_t arena_size = total_arena(); int chunk_idx = NMTUtil::flag_to_index(mtChunk); _malloc[chunk_idx].record_free(arena_size); + _all_mallocs.deallocate(arena_size); } @@ -227,7 +209,6 @@ void* MallocTracker::record_malloc(void* malloc_base, size_t size, MEMFLAGS flag assert(malloc_base != NULL, "precondition"); MallocMemorySummary::record_malloc(size, flags); - MallocMemorySummary::record_new_malloc_header(sizeof(MallocHeader)); uint32_t mst_marker = 0; if (MemTracker::tracking_level() == NMT_detail) { MallocSiteTable::allocation_at(stack, size, &mst_marker, flags); @@ -262,7 +243,6 @@ void* MallocTracker::record_free(void* memblock) { header->check_block_integrity(); MallocMemorySummary::record_free(header->size(), header->flags()); - MallocMemorySummary::record_free_malloc_header(sizeof(MallocHeader)); if (MemTracker::tracking_level() == NMT_detail) { MallocSiteTable::deallocation_at(header->size(), header->mst_marker()); } diff --git a/src/hotspot/share/services/mallocTracker.hpp b/src/hotspot/share/services/mallocTracker.hpp index 22296a33e1313..b905cb63f6bf9 100644 --- a/src/hotspot/share/services/mallocTracker.hpp +++ b/src/hotspot/share/services/mallocTracker.hpp @@ -140,7 +140,7 @@ class MallocMemorySnapshot : public ResourceObj { private: MallocMemory _malloc[mt_number_of_types]; - MemoryCounter _tracking_header; + MemoryCounter _all_mallocs; public: @@ -149,14 +149,18 @@ class MallocMemorySnapshot : public ResourceObj { return &_malloc[index]; } - inline MemoryCounter* malloc_overhead() { - return &_tracking_header; - } + inline size_t malloc_overhead() const; // Total malloc invocation count - size_t total_count() const; + size_t total_count() const { + return _all_mallocs.count(); + } + // Total malloc'd memory amount - size_t total() const; + size_t total() const { + return _all_mallocs.size() + malloc_overhead() + total_arena(); + } + // Total malloc'd memory used by arenas size_t total_arena() const; @@ -170,7 +174,7 @@ class MallocMemorySnapshot : public ResourceObj { // copy is going on, because their size is adjusted using this // buffer in make_adjustment(). ThreadCritical tc; - s->_tracking_header = _tracking_header; + s->_all_mallocs = _all_mallocs; for (int index = 0; index < mt_number_of_types; index ++) { s->_malloc[index] = _malloc[index]; } @@ -194,10 +198,12 @@ class MallocMemorySummary : AllStatic { static inline void record_malloc(size_t size, MEMFLAGS flag) { as_snapshot()->by_type(flag)->record_malloc(size); + as_snapshot()->_all_mallocs.allocate(size); } static inline void record_free(size_t size, MEMFLAGS flag) { as_snapshot()->by_type(flag)->record_free(size); + as_snapshot()->_all_mallocs.deallocate(size); } static inline void record_new_arena(MEMFLAGS flag) { @@ -217,18 +223,9 @@ class MallocMemorySummary : AllStatic { s->make_adjustment(); } - // Record memory used by malloc tracking header - static inline void record_new_malloc_header(size_t sz) { - as_snapshot()->malloc_overhead()->allocate(sz); - } - - static inline void record_free_malloc_header(size_t sz) { - as_snapshot()->malloc_overhead()->deallocate(sz); - } - // The memory used by malloc tracking headers static inline size_t tracking_overhead() { - return as_snapshot()->malloc_overhead()->size(); + return as_snapshot()->malloc_overhead(); } static MallocMemorySnapshot* as_snapshot() { @@ -344,6 +341,10 @@ class MallocHeader { void check_block_integrity() const; }; +size_t MallocMemorySnapshot::malloc_overhead() const { + return _all_mallocs.count() * sizeof(MallocHeader); +} + // This needs to be true on both 64-bit and 32-bit platforms STATIC_ASSERT(sizeof(MallocHeader) == (sizeof(uint64_t) * 2)); diff --git a/src/hotspot/share/services/memBaseline.hpp b/src/hotspot/share/services/memBaseline.hpp index c43c937abb107..45b3774f27d3e 100644 --- a/src/hotspot/share/services/memBaseline.hpp +++ b/src/hotspot/share/services/memBaseline.hpp @@ -142,7 +142,7 @@ class MemBaseline { size_t malloc_tracking_overhead() const { assert(baseline_type() != Not_baselined, "Not yet baselined"); MemBaseline* bl = const_cast(this); - return bl->_malloc_memory_snapshot.malloc_overhead()->size(); + return bl->_malloc_memory_snapshot.malloc_overhead(); } MallocMemory* malloc_memory(MEMFLAGS flag) { diff --git a/src/hotspot/share/services/memReporter.cpp b/src/hotspot/share/services/memReporter.cpp index f783560c4ce8c..5f9d2f3c1404a 100644 --- a/src/hotspot/share/services/memReporter.cpp +++ b/src/hotspot/share/services/memReporter.cpp @@ -157,8 +157,8 @@ void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, } } else if (flag == mtNMT) { // Count malloc headers in "NMT" category - reserved_amount += _malloc_snapshot->malloc_overhead()->size(); - committed_amount += _malloc_snapshot->malloc_overhead()->size(); + reserved_amount += _malloc_snapshot->malloc_overhead(); + committed_amount += _malloc_snapshot->malloc_overhead(); } if (amount_in_current_scale(reserved_amount) > 0) { @@ -210,9 +210,9 @@ void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, } if (flag == mtNMT && - amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) { + amount_in_current_scale(_malloc_snapshot->malloc_overhead()) > 0) { out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ", - amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale); + amount_in_current_scale(_malloc_snapshot->malloc_overhead()), scale); } else if (flag == mtClass) { // Metadata information report_metadata(Metaspace::NonClassType); From 20d41b94787371fe8f260dac05138b554f305ea1 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 4 Oct 2023 19:39:45 +0000 Subject: [PATCH 183/341] 8297958: NMT: Display peak values Backport-of: 336d230a39e41eeed8b9d2ce3fec42e9de1d11fe --- .../share/services/mallocSiteTable.hpp | 4 ++ src/hotspot/share/services/mallocTracker.cpp | 33 +++------- src/hotspot/share/services/mallocTracker.hpp | 33 ++++++---- src/hotspot/share/services/memReporter.cpp | 62 +++++++++++++------ src/hotspot/share/services/memReporter.hpp | 6 +- 5 files changed, 81 insertions(+), 57 deletions(-) diff --git a/src/hotspot/share/services/mallocSiteTable.hpp b/src/hotspot/share/services/mallocSiteTable.hpp index 6f18145157f86..80a9741aeacde 100644 --- a/src/hotspot/share/services/mallocSiteTable.hpp +++ b/src/hotspot/share/services/mallocSiteTable.hpp @@ -49,8 +49,12 @@ class MallocSite : public AllocationSite { // Memory allocated from this code path size_t size() const { return _c.size(); } + // Peak memory ever allocated from this code path + size_t peak_size() const { return _c.peak_size(); } // The number of calls were made size_t count() const { return _c.count(); } + + const MemoryCounter* counter() const { return &_c; } }; // Malloc site hashtable entry diff --git a/src/hotspot/share/services/mallocTracker.cpp b/src/hotspot/share/services/mallocTracker.cpp index 5b5baad0b9666..494527ec4500a 100644 --- a/src/hotspot/share/services/mallocTracker.cpp +++ b/src/hotspot/share/services/mallocTracker.cpp @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "runtime/atomic.hpp" #include "runtime/os.hpp" #include "services/mallocSiteTable.hpp" #include "services/mallocTracker.hpp" @@ -33,34 +34,20 @@ size_t MallocMemorySummary::_snapshot[CALC_OBJ_SIZE_IN_TYPE(MallocMemorySnapshot, size_t)]; #ifdef ASSERT -void MemoryCounter::update_peak_count(size_t count) { - size_t peak_cnt = peak_count(); - while (peak_cnt < count) { - size_t old_cnt = Atomic::cmpxchg(&_peak_count, peak_cnt, count, memory_order_relaxed); - if (old_cnt != peak_cnt) { - peak_cnt = old_cnt; - } - } -} - -void MemoryCounter::update_peak_size(size_t sz) { +void MemoryCounter::update_peak(size_t size, size_t cnt) { size_t peak_sz = peak_size(); - while (peak_sz < sz) { - size_t old_sz = Atomic::cmpxchg(&_peak_size, peak_sz, sz, memory_order_relaxed); - if (old_sz != peak_sz) { + while (peak_sz < size) { + size_t old_sz = Atomic::cmpxchg(&_peak_size, peak_sz, size, memory_order_relaxed); + if (old_sz == peak_sz) { + // I won + _peak_count = cnt; + break; + } else { peak_sz = old_sz; } } } - -size_t MemoryCounter::peak_count() const { - return Atomic::load(&_peak_count); -} - -size_t MemoryCounter::peak_size() const { - return Atomic::load(&_peak_size); -} -#endif +#endif // ASSERT // Total malloc'd memory used by arenas size_t MallocMemorySnapshot::total_arena() const { diff --git a/src/hotspot/share/services/mallocTracker.hpp b/src/hotspot/share/services/mallocTracker.hpp index b905cb63f6bf9..c458d35500342 100644 --- a/src/hotspot/share/services/mallocTracker.hpp +++ b/src/hotspot/share/services/mallocTracker.hpp @@ -43,8 +43,13 @@ class MemoryCounter { volatile size_t _count; volatile size_t _size; - DEBUG_ONLY(volatile size_t _peak_count;) - DEBUG_ONLY(volatile size_t _peak_size; ) +#ifdef ASSERT + // Peak size and count. Note: Peak count is the count at the point + // peak size was reached, not the absolute highest peak count. + volatile size_t _peak_count; + volatile size_t _peak_size; + void update_peak(size_t size, size_t cnt); +#endif // ASSERT public: MemoryCounter() : _count(0), _size(0) { @@ -56,9 +61,8 @@ class MemoryCounter { size_t cnt = Atomic::add(&_count, size_t(1), memory_order_relaxed); if (sz > 0) { size_t sum = Atomic::add(&_size, sz, memory_order_relaxed); - DEBUG_ONLY(update_peak_size(sum);) + DEBUG_ONLY(update_peak(sum, cnt);) } - DEBUG_ONLY(update_peak_count(cnt);) } inline void deallocate(size_t sz) { @@ -74,19 +78,20 @@ class MemoryCounter { if (sz != 0) { assert(sz >= 0 || size() >= size_t(-sz), "Must be"); size_t sum = Atomic::add(&_size, size_t(sz), memory_order_relaxed); - DEBUG_ONLY(update_peak_size(sum);) + DEBUG_ONLY(update_peak(sum, _count);) } } inline size_t count() const { return Atomic::load(&_count); } inline size_t size() const { return Atomic::load(&_size); } -#ifdef ASSERT - void update_peak_count(size_t cnt); - void update_peak_size(size_t sz); - size_t peak_count() const; - size_t peak_size() const; -#endif // ASSERT + inline size_t peak_count() const { + return DEBUG_ONLY(Atomic::load(&_peak_count)) NOT_DEBUG(0); + } + + inline size_t peak_size() const { + return DEBUG_ONLY(Atomic::load(&_peak_size)) NOT_DEBUG(0); + } }; /* @@ -123,12 +128,14 @@ class MallocMemory { } inline size_t malloc_size() const { return _malloc.size(); } + inline size_t malloc_peak_size() const { return _malloc.peak_size(); } inline size_t malloc_count() const { return _malloc.count();} inline size_t arena_size() const { return _arena.size(); } + inline size_t arena_peak_size() const { return _arena.peak_size(); } inline size_t arena_count() const { return _arena.count(); } - DEBUG_ONLY(inline const MemoryCounter& malloc_counter() const { return _malloc; }) - DEBUG_ONLY(inline const MemoryCounter& arena_counter() const { return _arena; }) + const MemoryCounter* malloc_counter() const { return &_malloc; } + const MemoryCounter* arena_counter() const { return &_arena; } }; class MallocMemorySummary; diff --git a/src/hotspot/share/services/memReporter.cpp b/src/hotspot/share/services/memReporter.cpp index 5f9d2f3c1404a..ee0d0b871f991 100644 --- a/src/hotspot/share/services/memReporter.cpp +++ b/src/hotspot/share/services/memReporter.cpp @@ -45,11 +45,14 @@ void MemReporterBase::print_total(size_t reserved, size_t committed) const { amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale); } -void MemReporterBase::print_malloc(size_t amount, size_t count, MEMFLAGS flag) const { +void MemReporterBase::print_malloc(const MemoryCounter* c, MEMFLAGS flag) const { const char* scale = current_scale(); outputStream* out = output(); const char* alloc_type = (flag == mtThreadStack) ? "" : "malloc="; + const size_t amount = c->size(); + const size_t count = c->count(); + if (flag != mtNone) { out->print("(%s" SIZE_FORMAT "%s type=%s", alloc_type, amount_in_current_scale(amount), scale, NMTUtil::flag_to_name(flag)); @@ -58,11 +61,21 @@ void MemReporterBase::print_malloc(size_t amount, size_t count, MEMFLAGS flag) c amount_in_current_scale(amount), scale); } + // blends out mtChunk count number if (count > 0) { out->print(" #" SIZE_FORMAT "", count); } out->print(")"); + + size_t pk_amount = c->peak_size(); + if (pk_amount == amount) { + out->print_raw(" (at peak)"); + } else if (pk_amount > amount) { + size_t pk_count = c->peak_count(); + out->print(" (peak=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", + amount_in_current_scale(pk_amount), scale, pk_count); + } } void MemReporterBase::print_virtual_memory(size_t reserved, size_t committed) const { @@ -71,9 +84,9 @@ void MemReporterBase::print_virtual_memory(size_t reserved, size_t committed) co amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale); } -void MemReporterBase::print_malloc_line(size_t amount, size_t count) const { +void MemReporterBase::print_malloc_line(const MemoryCounter* c) const { output()->print("%28s", " "); - print_malloc(amount, count); + print_malloc(c); output()->print_cr(" "); } @@ -83,10 +96,26 @@ void MemReporterBase::print_virtual_memory_line(size_t reserved, size_t committe output()->print_cr(" "); } -void MemReporterBase::print_arena_line(size_t amount, size_t count) const { +void MemReporterBase::print_arena_line(const MemoryCounter* c) const { const char* scale = current_scale(); - output()->print_cr("%27s (arena=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", " ", + outputStream* out = output(); + + const size_t amount = c->size(); + const size_t count = c->count(); + + out->print("%27s (arena=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", "", amount_in_current_scale(amount), scale, count); + + size_t pk_amount = c->peak_size(); + if (pk_amount == amount) { + out->print_raw(" (at peak)"); + } else if (pk_amount > amount) { + size_t pk_count = c->peak_count(); + out->print(" (peak=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", + amount_in_current_scale(pk_amount), scale, pk_count); + } + + out->cr(); } void MemReporterBase::print_virtual_memory_region(const char* type, address base, size_t size) const { @@ -195,18 +224,18 @@ void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, } // report malloc'd memory - if (amount_in_current_scale(malloc_memory->malloc_size()) > 0) { - // We don't know how many arena chunks are in used, so don't report the count - size_t count = (flag == mtChunk) ? 0 : malloc_memory->malloc_count(); - print_malloc_line(malloc_memory->malloc_size(), count); + if (amount_in_current_scale(malloc_memory->malloc_size()) > 0 + DEBUG_ONLY(|| amount_in_current_scale(malloc_memory->malloc_peak_size()) > 0)) { + print_malloc_line(malloc_memory->malloc_counter()); } if (amount_in_current_scale(virtual_memory->reserved()) > 0) { print_virtual_memory_line(virtual_memory->reserved(), virtual_memory->committed()); } - if (amount_in_current_scale(malloc_memory->arena_size()) > 0) { - print_arena_line(malloc_memory->arena_size(), malloc_memory->arena_count()); + if (amount_in_current_scale(malloc_memory->arena_size()) > 0 + DEBUG_ONLY(|| amount_in_current_scale(malloc_memory->arena_peak_size()) > 0)) { + print_arena_line(malloc_memory->arena_counter()); } if (flag == mtNMT && @@ -271,12 +300,9 @@ int MemDetailReporter::report_malloc_sites() { const MallocSite* malloc_site; int num_omitted = 0; while ((malloc_site = malloc_itr.next()) != NULL) { - // Don't report free sites; does not count toward omitted count. - if (malloc_site->size() == 0) { - continue; - } - // Don't report if site has allocated less than one unit of whatever our scale is - if (scale() > 1 && amount_in_current_scale(malloc_site->size()) == 0) { + // Don't report if site has never allocated less than one unit of whatever our scale is + if (scale() > 1 && amount_in_current_scale(malloc_site->size()) == 0 + DEBUG_ONLY(&& amount_in_current_scale(malloc_site->peak_size()) == 0)) { num_omitted ++; continue; } @@ -286,7 +312,7 @@ int MemDetailReporter::report_malloc_sites() { MEMFLAGS flag = malloc_site->flag(); assert(NMTUtil::flag_is_valid(flag) && flag != mtNone, "Must have a valid memory type"); - print_malloc(malloc_site->size(), malloc_site->count(),flag); + print_malloc(malloc_site->counter(), flag); out->print_cr("\n"); } return num_omitted; diff --git a/src/hotspot/share/services/memReporter.hpp b/src/hotspot/share/services/memReporter.hpp index 77fb1d70a00a8..214ad5e7c5cf6 100644 --- a/src/hotspot/share/services/memReporter.hpp +++ b/src/hotspot/share/services/memReporter.hpp @@ -82,12 +82,12 @@ class MemReporterBase : public StackObj { // Print summary total, malloc and virtual memory void print_total(size_t reserved, size_t committed) const; - void print_malloc(size_t amount, size_t count, MEMFLAGS flag = mtNone) const; + void print_malloc(const MemoryCounter* c, MEMFLAGS flag = mtNone) const; void print_virtual_memory(size_t reserved, size_t committed) const; - void print_malloc_line(size_t amount, size_t count) const; + void print_malloc_line(const MemoryCounter* c) const; void print_virtual_memory_line(size_t reserved, size_t committed) const; - void print_arena_line(size_t amount, size_t count) const; + void print_arena_line(const MemoryCounter* c) const; void print_virtual_memory_region(const char* type, address base, size_t size) const; }; From f1c55d2e7ce16223801c55eb872ef7fa055faabf Mon Sep 17 00:00:00 2001 From: Soumadipta Roy Date: Wed, 4 Oct 2023 21:07:18 +0000 Subject: [PATCH 184/341] 8315937: Enable parallelism in vmTestbase/nsk/stress/numeric tests Backport-of: eb1f67b160c4d2b8feb7330786ecd8e53ed53946 --- .../nsk/stress/numeric/TEST.properties | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/TEST.properties diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/TEST.properties b/test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/TEST.properties deleted file mode 100644 index 8b51b2a911560..0000000000000 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/numeric/TEST.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -exclusiveAccess.dirs=. From 31422d70d09277d604446a9bccad859c1ae9f3c2 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 5 Oct 2023 13:02:29 +0000 Subject: [PATCH 185/341] 8316710: Exclude java/awt/font/Rotate/RotatedTextTest.java Backport-of: f4550497eae71bf08cd5f591c2877ca28b7fea81 --- test/jdk/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index e703884e5bedc..1b8e738ba7b86 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -457,6 +457,7 @@ java/awt/Modal/OnTop/OnTopTKModal6Test.java 8198666 macosx-all java/awt/List/SingleModeDeselect/SingleModeDeselect.java 8196367 windows-all java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java 8061235 macosx-all javax/print/PrintSEUmlauts/PrintSEUmlauts.java 8135174 generic-all +java/awt/font/Rotate/RotatedTextTest.java 8219641 linux-all java/awt/font/TextLayout/LigatureCaretTest.java 8266312 generic-all java/awt/image/VolatileImage/CustomCompositeTest.java 8199002 windows-all,linux-all java/awt/image/VolatileImage/GradientPaints.java 8199003 linux-all From 8ef142e3a5987761d734aa907bb0fba6d786eed8 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 5 Oct 2023 18:24:51 +0000 Subject: [PATCH 186/341] 8298874: Update TestAllSuites.java for TLS v1.2 and 1.3 Backport-of: 3361a26df4dafa134181263cc5c81bda6ba8d21e --- test/jdk/ProblemList.txt | 1 - .../net/ssl/SSLEngine/TestAllSuites.java | 252 ++++++++---------- .../jdk/test/lib/security/SecurityUtils.java | 23 +- 3 files changed, 140 insertions(+), 136 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 1b8e738ba7b86..f032485da08cc 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -636,7 +636,6 @@ sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic- javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x64 -javax/net/ssl/SSLEngine/TestAllSuites.java 8298874 generic-all javax/net/ssl/SSLEngine/EngineCloseOnAlert.java 8298868 generic-all javax/net/ssl/SSLEngine/CheckStatus.java 8298872 generic-all diff --git a/test/jdk/javax/net/ssl/SSLEngine/TestAllSuites.java b/test/jdk/javax/net/ssl/SSLEngine/TestAllSuites.java index 3285479a86ca9..67387bd1661b0 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/TestAllSuites.java +++ b/test/jdk/javax/net/ssl/SSLEngine/TestAllSuites.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, 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 @@ -24,202 +24,180 @@ /* * @test * @bug 4495742 + * @library /test/lib + * + * @run main/othervm/timeout=180 TestAllSuites TLSv1.1 + * @run main/othervm/timeout=180 TestAllSuites TLSv1.2 + * @run main/othervm/timeout=180 TestAllSuites TLSv1.3 * - * @run main/timeout=180 TestAllSuites * @summary Add non-blocking SSL/TLS functionality, usable with any * I/O abstraction * - * Iterate through all the suites using both TLS and SSLv3, and turn - * SSLv2Hello off and on. Exchange some bytes and shutdown. + * Iterate through all the suites, exchange some bytes and shutdown. * * @author Brad Wetmore */ +import jdk.test.lib.security.SecurityUtils; + import javax.net.ssl.*; import javax.net.ssl.SSLEngineResult.*; import java.io.*; import java.security.*; import java.nio.*; import java.util.*; +import java.util.Arrays; public class TestAllSuites { - private static boolean debug = false; + private static final boolean DEBUG = Boolean.getBoolean("test.debug"); - private SSLContext sslc; - private SSLEngine ssle1; // client - private SSLEngine ssle2; // server + private final SSLContext SSL_CONTEXT; + private final String PROTOCOL; + private SSLEngine clientEngine; + private SSLEngine serverEngine; - private static String pathToStores = "../etc"; - private static String keyStoreFile = "keystore"; - private static String trustStoreFile = "truststore"; - private static String passwd = "passphrase"; + private static final String PATH_TO_STORES = "../etc"; + private static final String KEYSTORE_FILENAME = "keystore"; + private static final String TRUSTSTORE_FILENAME = "truststore"; - private static String keyFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + keyStoreFile; - private static String trustFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + trustStoreFile; + private static final String KEYSTORE_PATH = + System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + + "/" + KEYSTORE_FILENAME; + private static final String TRUSTSTORE_PATH = + System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + + "/" + TRUSTSTORE_FILENAME; - private ByteBuffer appOut1; // write side of ssle1 - private ByteBuffer appIn1; // read side of ssle1 - private ByteBuffer appOut2; // write side of ssle2 - private ByteBuffer appIn2; // read side of ssle2 + private ByteBuffer clientOut; + private ByteBuffer clientIn; + private ByteBuffer serverOut; + private ByteBuffer serverIn; - private ByteBuffer oneToTwo; // "reliable" transport ssle1->ssle2 - private ByteBuffer twoToOne; // "reliable" transport ssle2->ssle1 + private ByteBuffer clientToServer; + private ByteBuffer serverToClient; - String [][] protocols = new String [][] { - { "SSLv3" }, - { "TLSv1" }, - { "SSLv3", "SSLv2Hello"}, - { "TLSv1", "SSLv2Hello"} - }; - /* - * Majority of the test case is here, setup is done below. - */ + private void createSSLEngines() { + clientEngine = SSL_CONTEXT.createSSLEngine("client", 1); + clientEngine.setUseClientMode(true); - private void createSSLEngines() throws Exception { - ssle1 = sslc.createSSLEngine("client", 1); - ssle1.setUseClientMode(true); + serverEngine = SSL_CONTEXT.createSSLEngine("server", 2); + serverEngine.setUseClientMode(false); - ssle2 = sslc.createSSLEngine("server", 2); - ssle2.setUseClientMode(false); + clientEngine.setEnabledProtocols(new String[]{PROTOCOL}); + serverEngine.setEnabledProtocols(new String[]{PROTOCOL}); } private void test() throws Exception { - - createSSLEngines(); - String [] suites = ssle1.getSupportedCipherSuites(); - - for (int i = 0; i < suites.length; i++) { - for (int j = 0; j < protocols.length; j++) { - createSSLEngines(); - runTest(suites[i], protocols[j]); - } + String [] suites = clientEngine.getEnabledCipherSuites(); + System.out.println("Enabled cipher suites for protocol " + PROTOCOL + + ": " + Arrays.toString(suites)); + for (String suite: suites){ + // Need to recreate engines to override enabled ciphers + createSSLEngines(); + runTest(suite); } } - private void runTest(String suite, String [] protocols) throws Exception { + private void runTest(String suite) throws Exception { boolean dataDone = false; System.out.println("======================================"); - System.out.println("Testing: " + suite); - for (int i = 0; i < protocols.length; i++) { - System.out.print(protocols[i] + " "); - } + System.out.printf("Testing: %s with %s%n", PROTOCOL, suite); - /* - * Don't run the Kerberized suites for now. - */ - if (suite.startsWith("TLS_KRB5")) { - System.out.println("Ignoring Kerberized suite"); - return; - } + String [] suites = new String [] { suite }; - /* - * Don't run the SCSV suite - */ - if (suite.equals("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) { + if(suite.equals("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) { System.out.println("Ignoring SCSV suite"); return; } - - if (!suite.contains("DH_anon")) { - ssle2.setNeedClientAuth(true); - } - - String [] suites = new String [] { suite }; - - ssle1.setEnabledCipherSuites(suites); - ssle2.setEnabledCipherSuites(suites); - - ssle1.setEnabledProtocols(protocols); - ssle2.setEnabledProtocols(protocols); + clientEngine.setEnabledCipherSuites(suites); + serverEngine.setEnabledCipherSuites(suites); createBuffers(); - SSLEngineResult result1; // ssle1's results from last operation - SSLEngineResult result2; // ssle2's results from last operation + SSLEngineResult clientResult; // clientEngine's results from last operation + SSLEngineResult serverResult; // serverEngine's results from last operation Date start = new Date(); - while (!isEngineClosed(ssle1) || !isEngineClosed(ssle2)) { + while (!isEngineClosed(clientEngine) || !isEngineClosed(serverEngine)) { log("----------------"); - result1 = ssle1.wrap(appOut1, oneToTwo); - result2 = ssle2.wrap(appOut2, twoToOne); + clientResult = clientEngine.wrap(clientOut, clientToServer); + serverResult = serverEngine.wrap(serverOut, serverToClient); - log("wrap1: " + result1); - log("oneToTwo = " + oneToTwo); + log("Client engine wrap result: " + clientResult); + log("clientToServer = " + clientToServer); log(""); - log("wrap2: " + result2); - log("twoToOne = " + twoToOne); + log("Server engine wrap result: " + serverResult); + log("serverToClient = " + serverToClient); - runDelegatedTasks(result1, ssle1); - runDelegatedTasks(result2, ssle2); + runDelegatedTasks(clientResult, clientEngine); + runDelegatedTasks(serverResult, serverEngine); - oneToTwo.flip(); - twoToOne.flip(); + clientToServer.flip(); + serverToClient.flip(); log("----"); - result1 = ssle1.unwrap(twoToOne, appIn1); - result2 = ssle2.unwrap(oneToTwo, appIn2); + clientResult = clientEngine.unwrap(serverToClient, clientIn); + serverResult = serverEngine.unwrap(clientToServer, serverIn); - log("unwrap1: " + result1); - log("twoToOne = " + twoToOne); + log("Client engine unrap result: " + clientResult); + log("serverToClient = " + serverToClient); log(""); - log("unwrap2: " + result2); - log("oneToTwo = " + oneToTwo); + log("Server engine unwrap result: " + serverResult); + log("clientToServer = " + clientToServer); - runDelegatedTasks(result1, ssle1); - runDelegatedTasks(result2, ssle2); + runDelegatedTasks(clientResult, clientEngine); + runDelegatedTasks(serverResult, serverEngine); - oneToTwo.compact(); - twoToOne.compact(); + clientToServer.compact(); + serverToClient.compact(); /* - * If we've transfered all the data between app1 and app2, + * If we've transferred all the data between client and server * we try to close and see what that gets us. */ - if (!dataDone && (appOut1.limit() == appIn2.position()) && - (appOut2.limit() == appIn1.position())) { + if (!dataDone && (clientOut.limit() == serverIn.position()) && + (serverOut.limit() == clientIn.position())) { - checkTransfer(appOut1, appIn2); - checkTransfer(appOut2, appIn1); + checkTransfer(clientOut, serverIn); + checkTransfer(serverOut, clientIn); - log("Closing ssle1's *OUTBOUND*..."); - ssle1.closeOutbound(); + clientEngine.closeOutbound(); + serverEngine.closeOutbound(); dataDone = true; } } + System.out.println("Negotiated protocol: " + clientEngine.getSession().getProtocol()); + System.out.println("Negotiated cipher: " + clientEngine.getSession().getCipherSuite()); + /* * Just for grins, try closing again, make sure nothing * strange is happening after we're closed. */ - ssle1.closeInbound(); - ssle1.closeOutbound(); + clientEngine.closeInbound(); + clientEngine.closeOutbound(); - ssle2.closeInbound(); - ssle2.closeOutbound(); + serverEngine.closeInbound(); + serverEngine.closeOutbound(); - appOut1.rewind(); - appIn1.clear(); - oneToTwo.clear(); + clientOut.rewind(); + clientIn.clear(); + clientToServer.clear(); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(result1); + clientResult = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientResult); - result1 = ssle1.unwrap(oneToTwo, appIn1); - checkResult(result1); + clientResult = clientEngine.unwrap(clientToServer, clientIn); + checkResult(clientResult); System.out.println("Test Passed."); System.out.println("\n======================================"); @@ -243,13 +221,18 @@ private static void checkResult(SSLEngineResult result) throws Exception { public static void main(String args[]) throws Exception { - TestAllSuites tas; - - tas = new TestAllSuites(); + if (args.length < 1) { + throw new RuntimeException("Missing TLS protocol parameter."); + } - tas.createSSLEngines(); + switch(args[0]) { + case "TLSv1.1" -> SecurityUtils.removeFromDisabledTlsAlgs("TLSv1.1"); + case "TLSv1.3" -> SecurityUtils.addToDisabledTlsAlgs("TLSv1.2"); + } - tas.test(); + TestAllSuites testAllSuites = new TestAllSuites(args[0]); + testAllSuites.createSSLEngines(); + testAllSuites.test(); System.out.println("All Tests Passed."); System.out.println("Elapsed time: " + elapsed / 1000.0); @@ -261,8 +244,9 @@ public static void main(String args[]) throws Exception { * ********************************************************** */ - public TestAllSuites() throws Exception { - sslc = getSSLContext(keyFilename, trustFilename); + public TestAllSuites(String protocol) throws Exception { + PROTOCOL = protocol; + SSL_CONTEXT = getSSLContext(KEYSTORE_PATH, TRUSTSTORE_PATH); } /* @@ -285,7 +269,7 @@ private SSLContext getSSLContext(String keyFile, String trustFile) TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(ts); - SSLContext sslCtx = SSLContext.getInstance("TLS"); + SSLContext sslCtx = SSLContext.getInstance(PROTOCOL); sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); @@ -295,21 +279,21 @@ private SSLContext getSSLContext(String keyFile, String trustFile) private void createBuffers() { // Size the buffers as appropriate. - SSLSession session = ssle1.getSession(); + SSLSession session = clientEngine.getSession(); int appBufferMax = session.getApplicationBufferSize(); int netBufferMax = session.getPacketBufferSize(); - appIn1 = ByteBuffer.allocateDirect(appBufferMax + 50); - appIn2 = ByteBuffer.allocateDirect(appBufferMax + 50); + clientIn = ByteBuffer.allocateDirect(appBufferMax + 50); + serverIn = ByteBuffer.allocateDirect(appBufferMax + 50); - oneToTwo = ByteBuffer.allocateDirect(netBufferMax); - twoToOne = ByteBuffer.allocateDirect(netBufferMax); + clientToServer = ByteBuffer.allocateDirect(netBufferMax); + serverToClient = ByteBuffer.allocateDirect(netBufferMax); - appOut1 = ByteBuffer.wrap("Hi Engine2, I'm SSLEngine1".getBytes()); - appOut2 = ByteBuffer.wrap("Hello Engine1, I'm SSLEngine2".getBytes()); + clientOut = ByteBuffer.wrap("Hi Server, I'm Client".getBytes()); + serverOut = ByteBuffer.wrap("Hello Client, I'm Server".getBytes()); - log("AppOut1 = " + appOut1); - log("AppOut2 = " + appOut2); + log("ClientOut = " + clientOut); + log("ServerOut = " + serverOut); log(""); } @@ -347,7 +331,7 @@ private static void checkTransfer(ByteBuffer a, ByteBuffer b) } private static void log(String str) { - if (debug) { + if (DEBUG) { System.out.println(str); } } diff --git a/test/lib/jdk/test/lib/security/SecurityUtils.java b/test/lib/jdk/test/lib/security/SecurityUtils.java index c0818d7662a20..319416a466c22 100644 --- a/test/lib/jdk/test/lib/security/SecurityUtils.java +++ b/test/lib/jdk/test/lib/security/SecurityUtils.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 @@ -29,6 +29,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Common library for various security test helper functions. @@ -52,6 +53,26 @@ public static KeyStore getCacertsKeyStore() throws Exception { return KeyStore.getInstance(file, (char[])null); } + /** + * Adds the specified protocols to the jdk.tls.disabledAlgorithms + * security property + */ + public static void addToDisabledTlsAlgs(String... protocols) { + addToDisabledArgs("jdk.tls.disabledAlgorithms", List.of(protocols)); + } + + /** + * Adds constraints to the specified security property. + */ + public static void addToDisabledArgs(String prop, List constraints) { + String value = Security.getProperty(prop); + value = Stream.concat(Arrays.stream(value.split(",")), + constraints.stream()) + .map(String::trim) + .collect(Collectors.joining(",")); + Security.setProperty(prop, value); + } + /** * Removes the specified protocols from the jdk.tls.disabledAlgorithms * security property. From 60ae78aeaf7f7cc424663f81ba77489bd74b5fdb Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 5 Oct 2023 18:26:36 +0000 Subject: [PATCH 187/341] 8298872: Update CheckStatus.java for changes to TLS implementation Backport-of: e7247b10ccd2bf1ad6809395a1b63aa5046d5b1d --- test/jdk/ProblemList.txt | 1 - .../javax/net/ssl/SSLEngine/CheckStatus.java | 714 ------------------ .../ssl/SSLEngine/CheckTlsEngineResults.java | 709 +++++++++++++++++ 3 files changed, 709 insertions(+), 715 deletions(-) delete mode 100644 test/jdk/javax/net/ssl/SSLEngine/CheckStatus.java create mode 100644 test/jdk/javax/net/ssl/SSLEngine/CheckTlsEngineResults.java diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index f032485da08cc..c538816b34fc5 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -637,7 +637,6 @@ sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic- javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x64 javax/net/ssl/SSLEngine/EngineCloseOnAlert.java 8298868 generic-all -javax/net/ssl/SSLEngine/CheckStatus.java 8298872 generic-all sun/security/smartcardio/TestChannel.java 8039280 generic-all sun/security/smartcardio/TestConnect.java 8039280 generic-all diff --git a/test/jdk/javax/net/ssl/SSLEngine/CheckStatus.java b/test/jdk/javax/net/ssl/SSLEngine/CheckStatus.java deleted file mode 100644 index 69d1e07621f87..0000000000000 --- a/test/jdk/javax/net/ssl/SSLEngine/CheckStatus.java +++ /dev/null @@ -1,714 +0,0 @@ -/* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. - * 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 4948079 - * @summary SSLEngineResult needs updating [none yet] - * - * @run main/othervm -Djsse.enableCBCProtection=false CheckStatus - * - * @author Brad Wetmore - */ - -/* - * This is a simple hack to test a bunch of conditions and check - * their return codes. - */ -import javax.net.ssl.*; -import javax.net.ssl.SSLEngineResult.*; -import java.io.*; -import java.security.*; -import java.nio.*; - -public class CheckStatus { - - private static boolean debug = true; - - private SSLContext sslc; - private SSLEngine ssle1; // client - private SSLEngine ssle2; // server - - private static String pathToStores = "../etc"; - private static String keyStoreFile = "keystore"; - private static String trustStoreFile = "truststore"; - private static String passwd = "passphrase"; - - private static String keyFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + keyStoreFile; - private static String trustFilename = - System.getProperty("test.src", "./") + "/" + pathToStores + - "/" + trustStoreFile; - - private ByteBuffer appOut1; // write side of ssle1 - private ByteBuffer appIn1; // read side of ssle1 - private ByteBuffer appOut2; // write side of ssle2 - private ByteBuffer appIn2; // read side of ssle2 - - private ByteBuffer oneToTwo; // "reliable" transport ssle1->ssle2 - private ByteBuffer twoToOne; // "reliable" transport ssle2->ssle1 - - /* - * Majority of the test case is here, setup is done below. - */ - - private void createSSLEngines() throws Exception { - ssle1 = sslc.createSSLEngine("client", 1); - ssle1.setUseClientMode(true); - - ssle2 = sslc.createSSLEngine("server", 2); - ssle2.setUseClientMode(false); - } - - private boolean isHandshaking(SSLEngine e) { - return (e.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING); - } - - private void checkResult(ByteBuffer bbIn, ByteBuffer bbOut, - SSLEngineResult result, - Status status, HandshakeStatus hsStatus, - int consumed, int produced) - throws Exception { - - if ((status != null) && (result.getStatus() != status)) { - throw new Exception("Unexpected Status: need = " + status + - " got = " + result.getStatus()); - } - - if ((hsStatus != null) && (result.getHandshakeStatus() != hsStatus)) { - throw new Exception("Unexpected hsStatus: need = " + hsStatus + - " got = " + result.getHandshakeStatus()); - } - - if ((consumed != -1) && (consumed != result.bytesConsumed())) { - throw new Exception("Unexpected consumed: need = " + consumed + - " got = " + result.bytesConsumed()); - } - - if ((produced != -1) && (produced != result.bytesProduced())) { - throw new Exception("Unexpected produced: need = " + produced + - " got = " + result.bytesProduced()); - } - - if ((consumed != -1) && (bbIn.position() != result.bytesConsumed())) { - throw new Exception("Consumed " + bbIn.position() + - " != " + consumed); - } - - if ((produced != -1) && (bbOut.position() != result.bytesProduced())) { - throw new Exception("produced " + bbOut.position() + - " != " + produced); - } - } - - private void test() throws Exception { - createSSLEngines(); - createBuffers(); - - SSLEngineResult result1; // ssle1's results from last operation - SSLEngineResult result2; // ssle2's results from last operation - - String [] suite1 = new String [] { - "SSL_RSA_WITH_RC4_128_MD5" }; - String [] suite2 = new String [] { - "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA" }; - - ssle1.setEnabledCipherSuites(suite1); - ssle2.setEnabledCipherSuites(suite1); - - log("================"); - - log("unexpected empty unwrap"); - twoToOne.limit(0); - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result1, - Status.OK, HandshakeStatus.NEED_WRAP, 0, 0); - twoToOne.limit(twoToOne.capacity()); - - log("======================================"); - log("client hello"); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); - - oneToTwo.flip(); - result2 = ssle2.unwrap(oneToTwo, appIn2); - - checkResult(oneToTwo, appIn2, result2, - Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0); - runDelegatedTasks(ssle2); - - oneToTwo.compact(); - - log("Check for unwrap when wrap needed"); - result2 = ssle2.unwrap(oneToTwo, appIn2); - checkResult(oneToTwo, appIn2, result2, - Status.OK, HandshakeStatus.NEED_WRAP, 0, 0); - - log("======================================"); - log("ServerHello"); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); - twoToOne.flip(); - - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result1, - Status.OK, HandshakeStatus.NEED_TASK, result2.bytesProduced(), 0); - twoToOne.compact(); - - runDelegatedTasks(ssle1); - - log("======================================"); - log("Key Exchange"); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); - - oneToTwo.flip(); - result2 = ssle2.unwrap(oneToTwo, appIn2); - - checkResult(oneToTwo, appIn2, result2, - Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0); - runDelegatedTasks(ssle2); - - oneToTwo.compact(); - - log("======================================"); - log("CCS"); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); - - oneToTwo.flip(); - result2 = ssle2.unwrap(oneToTwo, appIn2); - - checkResult(oneToTwo, appIn2, result2, - Status.OK, HandshakeStatus.NEED_UNWRAP, - result1.bytesProduced(), 0); - - oneToTwo.compact(); - - log("======================================"); - log("Finished"); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); - - oneToTwo.flip(); - result2 = ssle2.unwrap(oneToTwo, appIn2); - - checkResult(oneToTwo, appIn2, result2, - Status.OK, HandshakeStatus.NEED_WRAP, result1.bytesProduced(), 0); - - oneToTwo.compact(); - - log("======================================"); - log("CCS"); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); - twoToOne.flip(); - - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result1, - Status.OK, HandshakeStatus.NEED_UNWRAP, result2.bytesProduced(), 0); - twoToOne.compact(); - - log("======================================"); - log("FINISHED"); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.OK, HandshakeStatus.FINISHED, 0, -1); - twoToOne.flip(); - - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result1, - Status.OK, HandshakeStatus.FINISHED, result2.bytesProduced(), 0); - twoToOne.compact(); - - log("======================================"); - log("Check Session/Ciphers"); - - String suite = ssle1.getSession().getCipherSuite(); - if (!suite.equals(suite1[0])) { - throw new Exception("suites not equal: " + suite + "/" + - suite1[0]); - } - - suite = ssle2.getSession().getCipherSuite(); - if (!suite.equals(suite1[0])) { - throw new Exception("suites not equal: " + suite + "/" + - suite1[0]); - } - - log("======================================"); - log("DATA"); - - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NOT_HANDSHAKING, - appOut1.capacity(), -1); - oneToTwo.flip(); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.OK, HandshakeStatus.NOT_HANDSHAKING, - appOut2.capacity(), -1); - twoToOne.flip(); - - SSLEngineResult result3 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result3, - Status.OK, HandshakeStatus.NOT_HANDSHAKING, - result2.bytesProduced(), result2.bytesConsumed()); - twoToOne.compact(); - - SSLEngineResult result4 = ssle2.unwrap(oneToTwo, appIn2); - checkResult(oneToTwo, appIn2, result4, - Status.OK, HandshakeStatus.NOT_HANDSHAKING, - result1.bytesProduced(), result1.bytesConsumed()); - oneToTwo.compact(); - - appIn1.clear(); - appIn2.clear(); - appOut1.rewind(); - appOut2.rewind(); - - log("======================================"); - log("RENEGOTIATE"); - - ssle2.getSession().invalidate(); - ssle2.setNeedClientAuth(true); - - ssle1.setEnabledCipherSuites(suite2); - ssle2.setEnabledCipherSuites(suite2); - - ssle2.beginHandshake(); - - log("======================================"); - log("HelloRequest"); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); - twoToOne.flip(); - - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result1, - Status.OK, HandshakeStatus.NEED_TASK, result2.bytesProduced(), 0); - twoToOne.compact(); - - runDelegatedTasks(ssle1); - - log("======================================"); - log("ClientHello"); - - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); - - oneToTwo.flip(); - result2 = ssle2.unwrap(oneToTwo, appIn2); - - checkResult(oneToTwo, appIn2, result2, - Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0); - runDelegatedTasks(ssle2); - - oneToTwo.compact(); - - log("======================================"); - log("CLIENT->SERVER DATA IN MIDDLE OF HANDSHAKE"); - - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NEED_UNWRAP, - appOut1.capacity(), -1); - oneToTwo.flip(); - - result4 = ssle2.unwrap(oneToTwo, appIn2); - checkResult(oneToTwo, appIn2, result4, - Status.OK, HandshakeStatus.NEED_WRAP, - result1.bytesProduced(), result1.bytesConsumed()); - oneToTwo.compact(); - - appIn2.clear(); - appOut1.rewind(); - - log("======================================"); - log("ServerHello"); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); - twoToOne.flip(); - - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result1, - Status.OK, HandshakeStatus.NEED_TASK, result2.bytesProduced(), 0); - twoToOne.compact(); - - runDelegatedTasks(ssle1); - - log("======================================"); - log("SERVER->CLIENT DATA IN MIDDLE OF HANDSHAKE"); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.OK, HandshakeStatus.NEED_UNWRAP, - appOut2.capacity(), -1); - twoToOne.flip(); - - result3 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result3, - Status.OK, HandshakeStatus.NEED_WRAP, - result2.bytesProduced(), result2.bytesConsumed()); - twoToOne.compact(); - - appIn1.clear(); - appOut2.rewind(); - - log("======================================"); - log("Client Cert and Key Exchange"); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); - - oneToTwo.flip(); - result2 = ssle2.unwrap(oneToTwo, appIn2); - - checkResult(oneToTwo, appIn2, result2, - Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0); - runDelegatedTasks(ssle2); - - oneToTwo.compact(); - - log("======================================"); - log("CCS"); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); - - oneToTwo.flip(); - result2 = ssle2.unwrap(oneToTwo, appIn2); - - checkResult(oneToTwo, appIn2, result2, - Status.OK, HandshakeStatus.NEED_UNWRAP, - result1.bytesProduced(), 0); - - oneToTwo.compact(); - - log("======================================"); - log("Finished"); - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); - - oneToTwo.flip(); - result2 = ssle2.unwrap(oneToTwo, appIn2); - - checkResult(oneToTwo, appIn2, result2, - Status.OK, HandshakeStatus.NEED_WRAP, result1.bytesProduced(), 0); - - oneToTwo.compact(); - - log("======================================"); - log("CCS"); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); - twoToOne.flip(); - - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result1, - Status.OK, HandshakeStatus.NEED_UNWRAP, result2.bytesProduced(), 0); - twoToOne.compact(); - - log("======================================"); - log("FINISHED"); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.OK, HandshakeStatus.FINISHED, 0, -1); - twoToOne.flip(); - - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result1, - Status.OK, HandshakeStatus.FINISHED, result2.bytesProduced(), 0); - twoToOne.compact(); - - log("======================================"); - log("Check Session/Ciphers"); - - suite = ssle1.getSession().getCipherSuite(); - if (!suite.equals(suite2[0])) { - throw new Exception("suites not equal: " + suite + "/" + - suite2[0]); - } - - suite = ssle2.getSession().getCipherSuite(); - if (!suite.equals(suite2[0])) { - throw new Exception("suites not equal: " + suite + "/" + - suite2[0]); - } - - log("======================================"); - log("DATA USING NEW SESSION"); - - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.OK, HandshakeStatus.NOT_HANDSHAKING, - appOut1.capacity(), -1); - oneToTwo.flip(); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.OK, HandshakeStatus.NOT_HANDSHAKING, - appOut2.capacity(), -1); - twoToOne.flip(); - - result3 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result3, - Status.OK, HandshakeStatus.NOT_HANDSHAKING, - result2.bytesProduced(), result2.bytesConsumed()); - twoToOne.compact(); - - result4 = ssle2.unwrap(oneToTwo, appIn2); - checkResult(oneToTwo, appIn2, result4, - Status.OK, HandshakeStatus.NOT_HANDSHAKING, - result1.bytesProduced(), result1.bytesConsumed()); - oneToTwo.compact(); - - appIn1.clear(); - appIn2.clear(); - appOut1.rewind(); - appOut2.rewind(); - - log("======================================"); - log("CN"); - - if (isHandshaking(ssle1)) { - throw new Exception("ssle1 IS handshaking"); - } - - if (isHandshaking(ssle2)) { - throw new Exception("ssle2 IS handshaking"); - } - - ssle2.closeOutbound(); - - if (!isHandshaking(ssle2)) { - throw new Exception("ssle1 IS NOT handshaking"); - } - - appOut1.rewind(); - appOut2.rewind(); - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.CLOSED, HandshakeStatus.NEED_UNWRAP, 0, -1); - twoToOne.flip(); - - if (ssle1.isInboundDone()) { - throw new Exception("ssle1 inboundDone"); - } - - result1 = ssle1.unwrap(twoToOne, appIn1); - checkResult(twoToOne, appIn1, result1, - Status.CLOSED, HandshakeStatus.NEED_WRAP, - result2.bytesProduced(), 0); - twoToOne.compact(); - - if (!ssle1.isInboundDone()) { - throw new Exception("ssle1 inboundDone"); - } - - if (!isHandshaking(ssle1)) { - throw new Exception("ssle1 IS NOT handshaking"); - } - - result2 = ssle2.wrap(appOut2, twoToOne); - checkResult(appOut2, twoToOne, result2, - Status.CLOSED, HandshakeStatus.NEED_UNWRAP, 0, 0); - twoToOne.flip(); - - log("======================================"); - log("CN response"); - - if (ssle1.isOutboundDone()) { - throw new Exception("ssle1 outboundDone"); - } - - result1 = ssle1.wrap(appOut1, oneToTwo); - checkResult(appOut1, oneToTwo, result1, - Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, 0, -1); - - if (!ssle1.isOutboundDone()) { - throw new Exception("ssle1 outboundDone is NOT done"); - } - - if (isHandshaking(ssle1)) { - throw new Exception("ssle1 IS handshaking"); - } - - oneToTwo.flip(); - - if (!ssle2.isOutboundDone()) { - throw new Exception("ssle1 outboundDone"); - } - - if (ssle2.isInboundDone()) { - throw new Exception("ssle1 inboundDone"); - } - - result2 = ssle2.unwrap(oneToTwo, appIn2); - - checkResult(oneToTwo, appIn2, result2, - Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, - result1.bytesProduced(), 0); - - if (!ssle2.isOutboundDone()) { - throw new Exception("ssle1 outboundDone is NOT done"); - } - - if (!ssle2.isInboundDone()) { - throw new Exception("ssle1 inboundDone is NOT done"); - } - - if (isHandshaking(ssle2)) { - throw new Exception("ssle1 IS handshaking"); - } - - oneToTwo.compact(); - } - - public static void main(String args[]) throws Exception { - // reset the security property to make sure that the algorithms - // and keys used in this test are not disabled. - Security.setProperty("jdk.tls.disabledAlgorithms", ""); - - CheckStatus cs; - - cs = new CheckStatus(); - - cs.createSSLEngines(); - - cs.test(); - - System.out.println("Test Passed."); - } - - /* - * ********************************************************** - * Majority of the test case is above, below is just setup stuff - * ********************************************************** - */ - - public CheckStatus() throws Exception { - sslc = getSSLContext(keyFilename, trustFilename); - } - - /* - * Create an initialized SSLContext to use for this test. - */ - private SSLContext getSSLContext(String keyFile, String trustFile) - throws Exception { - - KeyStore ks = KeyStore.getInstance("JKS"); - KeyStore ts = KeyStore.getInstance("JKS"); - - char[] passphrase = "passphrase".toCharArray(); - - ks.load(new FileInputStream(keyFile), passphrase); - ts.load(new FileInputStream(trustFile), passphrase); - - KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(ks, passphrase); - - TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); - tmf.init(ts); - - SSLContext sslCtx = SSLContext.getInstance("TLS"); - - sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - - return sslCtx; - } - - private void createBuffers() { - // Size the buffers as appropriate. - - SSLSession session = ssle1.getSession(); - int appBufferMax = session.getApplicationBufferSize(); - int netBufferMax = session.getPacketBufferSize(); - - appIn1 = ByteBuffer.allocateDirect(appBufferMax + 50); - appIn2 = ByteBuffer.allocateDirect(appBufferMax + 50); - - oneToTwo = ByteBuffer.allocateDirect(netBufferMax); - twoToOne = ByteBuffer.allocateDirect(netBufferMax); - - appOut1 = ByteBuffer.wrap("Hi Engine2, I'm SSLEngine1".getBytes()); - appOut2 = ByteBuffer.wrap("Hello Engine1, I'm SSLEngine2".getBytes()); - - log("AppOut1 = " + appOut1); - log("AppOut2 = " + appOut2); - log(""); - } - - private static void runDelegatedTasks(SSLEngine engine) throws Exception { - - Runnable runnable; - while ((runnable = engine.getDelegatedTask()) != null) { - log("running delegated task..."); - runnable.run(); - } - } - - private static void checkTransfer(ByteBuffer a, ByteBuffer b) - throws Exception { - a.flip(); - b.flip(); - - if (!a.equals(b)) { - throw new Exception("Data didn't transfer cleanly"); - } else { - log("Data transferred cleanly"); - } - - a.position(a.limit()); - b.position(b.limit()); - a.limit(a.capacity()); - b.limit(b.capacity()); - } - - private static void log(String str) { - if (debug) { - System.out.println(str); - } - } -} diff --git a/test/jdk/javax/net/ssl/SSLEngine/CheckTlsEngineResults.java b/test/jdk/javax/net/ssl/SSLEngine/CheckTlsEngineResults.java new file mode 100644 index 0000000000000..7a7ecdffa5d45 --- /dev/null +++ b/test/jdk/javax/net/ssl/SSLEngine/CheckTlsEngineResults.java @@ -0,0 +1,709 @@ +/* + * 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 + * 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 4948079 + * @summary Verify return values from SSLEngine wrap/unwrap (TLSv1.2) operations + * + * @run main CheckTlsEngineResults + * + * @author Brad Wetmore + */ + +/* + * This is a simple hack to test a bunch of conditions and check + * their return codes. + */ +import javax.net.ssl.*; +import javax.net.ssl.SSLEngineResult.*; +import java.io.*; +import java.security.*; +import java.nio.*; + +public class CheckTlsEngineResults { + + private final SSLContext SSL_CONTEXT; + private SSLEngine clientEngine; // client + private SSLEngine serverEngine; // server + + private static final String PATH_TO_STORES = "../etc"; + + private static final String KEYSTORE_FILE = "keystore"; + private static final String TRUSTSTORE_FILE = "truststore"; + + private static final String keyFilename = + System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + + "/" + KEYSTORE_FILE; + private static final String trustFilename = + System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + + "/" + TRUSTSTORE_FILE; + + private ByteBuffer clientOut; // write side of clientEngine + private ByteBuffer clientIn; // read side of clientEngine + private ByteBuffer serverOut; // write side of serverEngine + private ByteBuffer serverIn; // read side of serverEngine + + private ByteBuffer clientToServer; // "reliable" transport clientEngine->serverEngine + private ByteBuffer serverToClient; // "reliable" transport serverEngine->clientEngine + + /* + * Majority of the test case is here, setup is done below. + */ + + private void createSSLEngines() throws Exception { + clientEngine = SSL_CONTEXT.createSSLEngine("client", 1); + clientEngine.setUseClientMode(true); + + serverEngine = SSL_CONTEXT.createSSLEngine("server", 2); + serverEngine.setUseClientMode(false); + } + + private boolean isHandshaking(SSLEngine e) { + return (e.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING); + } + + private void checkResult(ByteBuffer bbIn, ByteBuffer bbOut, + SSLEngineResult result, + Status status, HandshakeStatus hsStatus, + int consumed, int produced) + throws Exception { + + if ((status != null) && (result.getStatus() != status)) { + throw new Exception("Unexpected Status: need = " + status + + " got = " + result.getStatus()); + } + + if ((hsStatus != null) && (result.getHandshakeStatus() != hsStatus)) { + throw new Exception("Unexpected hsStatus: need = " + hsStatus + + " got = " + result.getHandshakeStatus()); + } + + if ((consumed != -1) && (consumed != result.bytesConsumed())) { + throw new Exception("Unexpected consumed: need = " + consumed + + " got = " + result.bytesConsumed()); + } + + if ((produced != -1) && (produced != result.bytesProduced())) { + throw new Exception("Unexpected produced: need = " + produced + + " got = " + result.bytesProduced()); + } + + if ((consumed != -1) && (bbIn.position() != result.bytesConsumed())) { + throw new Exception("Consumed " + bbIn.position() + + " != " + consumed); + } + + if ((produced != -1) && (bbOut.position() != result.bytesProduced())) { + throw new Exception("produced " + bbOut.position() + + " != " + produced); + } + } + + private void test() throws Exception { + createSSLEngines(); + createBuffers(); + + SSLEngineResult result1; // clientEngine's results from last operation + SSLEngineResult result2; // serverEngine's results from last operation + String [] suite1 = new String [] { + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" }; + String [] suite2 = new String [] { + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" }; + + clientEngine.setEnabledCipherSuites(suite1); + serverEngine.setEnabledCipherSuites(suite1); + + log("================"); + + log("unexpected empty unwrap"); + serverToClient.limit(0); + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.OK, HandshakeStatus.NEED_WRAP, 0, 0); + serverToClient.limit(serverToClient.capacity()); + + log("======================================"); + log("Client -> Server [ClientHello]"); + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); + + clientToServer.flip(); + result2 = serverEngine.unwrap(clientToServer, serverIn); + + checkResult(clientToServer, serverIn, result2, + Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0); + runDelegatedTasks(serverEngine); + + clientToServer.compact(); + + log("Check for unwrap when wrap needed"); + result2 = serverEngine.unwrap(clientToServer, serverIn); + checkResult(clientToServer, serverIn, result2, + Status.OK, HandshakeStatus.NEED_WRAP, 0, 0); + + log("======================================"); + log("Server -> Client [ServerHello]"); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); + serverToClient.flip(); + + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.OK, HandshakeStatus.NEED_TASK, result2.bytesProduced(), 0); + serverToClient.compact(); + + runDelegatedTasks(clientEngine); + + log("======================================"); + log("Client -> Server [ClientKeyExchange]"); + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); + + clientToServer.flip(); + result2 = serverEngine.unwrap(clientToServer, serverIn); + + checkResult(clientToServer, serverIn, result2, + Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0); + runDelegatedTasks(serverEngine); + + clientToServer.compact(); + + log("======================================"); + log("Client -> Server [ChangeCipherSpec]"); + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); + + clientToServer.flip(); + result2 = serverEngine.unwrap(clientToServer, serverIn); + + checkResult(clientToServer, serverIn, result2, + Status.OK, HandshakeStatus.NEED_UNWRAP, + result1.bytesProduced(), 0); + + clientToServer.compact(); + + log("======================================"); + log("Client -> Server [Finished]"); + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); + + clientToServer.flip(); + result2 = serverEngine.unwrap(clientToServer, serverIn); + + checkResult(clientToServer, serverIn, result2, + Status.OK, HandshakeStatus.NEED_WRAP, result1.bytesProduced(), 0); + + clientToServer.compact(); + + log("======================================"); + log("Server -> Client [NewSessionTicket]"); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); + serverToClient.flip(); + + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.OK, HandshakeStatus.NEED_UNWRAP, result2.bytesProduced(), 0); + serverToClient.compact(); + + log("======================================"); + log("Server -> Client [ChangeCipherSpec]"); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); + serverToClient.flip(); + + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.OK, HandshakeStatus.NEED_UNWRAP, result2.bytesProduced(), 0); + serverToClient.compact(); + + log("======================================"); + log("Server -> Client [Finished]"); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.FINISHED, 0, -1); + serverToClient.flip(); + + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.OK, HandshakeStatus.FINISHED, result2.bytesProduced(), 0); + serverToClient.compact(); + + + log("======================================"); + log("Check Session/Ciphers"); + + String suite = clientEngine.getSession().getCipherSuite(); + if (!suite.equals(suite1[0])) { + throw new Exception("suites not equal: " + suite + "/" + + suite1[0]); + } + + suite = serverEngine.getSession().getCipherSuite(); + if (!suite.equals(suite1[0])) { + throw new Exception("suites not equal: " + suite + "/" + + suite1[0]); + } + + log("======================================"); + log("DATA"); + + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NOT_HANDSHAKING, + clientOut.capacity(), -1); + clientToServer.flip(); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.NOT_HANDSHAKING, + serverOut.capacity(), -1); + serverToClient.flip(); + + SSLEngineResult result3 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result3, + Status.OK, HandshakeStatus.NOT_HANDSHAKING, + result2.bytesProduced(), result2.bytesConsumed()); + serverToClient.compact(); + + SSLEngineResult result4 = serverEngine.unwrap(clientToServer, serverIn); + checkResult(clientToServer, serverIn, result4, + Status.OK, HandshakeStatus.NOT_HANDSHAKING, + result1.bytesProduced(), result1.bytesConsumed()); + clientToServer.compact(); + + clientIn.clear(); + serverIn.clear(); + clientOut.rewind(); + serverOut.rewind(); + + log("======================================"); + log("RENEGOTIATE"); + + serverEngine.getSession().invalidate(); + serverEngine.setNeedClientAuth(true); + + clientEngine.setEnabledCipherSuites(suite2); + serverEngine.setEnabledCipherSuites(suite2); + + serverEngine.beginHandshake(); + + log("======================================"); + log("Server -> Client [HelloRequest]"); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); + serverToClient.flip(); + + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.OK, HandshakeStatus.NEED_TASK, result2.bytesProduced(), 0); + serverToClient.compact(); + + runDelegatedTasks(clientEngine); + + log("======================================"); + log("CLient -> Server [ClientHello]"); + + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); + + clientToServer.flip(); + result2 = serverEngine.unwrap(clientToServer, serverIn); + + checkResult(clientToServer, serverIn, result2, + Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0); + runDelegatedTasks(serverEngine); + + clientToServer.compact(); + + log("======================================"); + log("CLIENT->SERVER DATA IN MIDDLE OF HANDSHAKE"); + + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NEED_UNWRAP, + clientOut.capacity(), -1); + clientToServer.flip(); + + result4 = serverEngine.unwrap(clientToServer, serverIn); + checkResult(clientToServer, serverIn, result4, + Status.OK, HandshakeStatus.NEED_WRAP, + result1.bytesProduced(), result1.bytesConsumed()); + clientToServer.compact(); + + serverIn.clear(); + clientOut.rewind(); + + log("======================================"); + log("Server -> Client [ServerHello]"); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); + serverToClient.flip(); + + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.OK, HandshakeStatus.NEED_TASK, result2.bytesProduced(), 0); + serverToClient.compact(); + + runDelegatedTasks(clientEngine); + + log("======================================"); + log("SERVER->CLIENT DATA IN MIDDLE OF HANDSHAKE"); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.NEED_UNWRAP, + serverOut.capacity(), -1); + serverToClient.flip(); + + result3 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result3, + Status.OK, HandshakeStatus.NEED_WRAP, + result2.bytesProduced(), result2.bytesConsumed()); + serverToClient.compact(); + + clientIn.clear(); + serverOut.rewind(); + + log("======================================"); + log("Client -> Server [Certificate] and [ClientKeyExchange]"); + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); + + clientToServer.flip(); + result2 = serverEngine.unwrap(clientToServer, serverIn); + + checkResult(clientToServer, serverIn, result2, + Status.OK, HandshakeStatus.NEED_TASK, result1.bytesProduced(), 0); + runDelegatedTasks(serverEngine); + + clientToServer.compact(); + + log("======================================"); + log("Client -> Server [ChangeCipherSpec]"); + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); + + clientToServer.flip(); + result2 = serverEngine.unwrap(clientToServer, serverIn); + + checkResult(clientToServer, serverIn, result2, + Status.OK, HandshakeStatus.NEED_UNWRAP, + result1.bytesProduced(), 0); + + clientToServer.compact(); + + log("======================================"); + log("Client -> Server [Finished]"); + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NEED_UNWRAP, 0, -1); + + clientToServer.flip(); + result2 = serverEngine.unwrap(clientToServer, serverIn); + + checkResult(clientToServer, serverIn, result2, + Status.OK, HandshakeStatus.NEED_WRAP, result1.bytesProduced(), 0); + + clientToServer.compact(); + + log("======================================"); + log("Server -> Client [NewSessionTicket]"); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); + serverToClient.flip(); + + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.OK, HandshakeStatus.NEED_UNWRAP, result2.bytesProduced(), 0); + serverToClient.compact(); + + log("======================================"); + log("Server -> Client [ChangeCipherSpec]"); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.NEED_WRAP, 0, -1); + serverToClient.flip(); + + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.OK, HandshakeStatus.NEED_UNWRAP, result2.bytesProduced(), 0); + serverToClient.compact(); + + log("======================================"); + log("Server -> Client [Finished]"); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.FINISHED, 0, -1); + serverToClient.flip(); + + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.OK, HandshakeStatus.FINISHED, result2.bytesProduced(), 0); + serverToClient.compact(); + + log("======================================"); + log("Check Session/Ciphers"); + + suite = clientEngine.getSession().getCipherSuite(); + if (!suite.equals(suite2[0])) { + throw new Exception("suites not equal: " + suite + "/" + + suite2[0]); + } + + suite = serverEngine.getSession().getCipherSuite(); + if (!suite.equals(suite2[0])) { + throw new Exception("suites not equal: " + suite + "/" + + suite2[0]); + } + + log("======================================"); + log("DATA USING NEW SESSION"); + + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.OK, HandshakeStatus.NOT_HANDSHAKING, + clientOut.capacity(), -1); + clientToServer.flip(); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.OK, HandshakeStatus.NOT_HANDSHAKING, + serverOut.capacity(), -1); + serverToClient.flip(); + + result3 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result3, + Status.OK, HandshakeStatus.NOT_HANDSHAKING, + result2.bytesProduced(), result2.bytesConsumed()); + serverToClient.compact(); + + result4 = serverEngine.unwrap(clientToServer, serverIn); + checkResult(clientToServer, serverIn, result4, + Status.OK, HandshakeStatus.NOT_HANDSHAKING, + result1.bytesProduced(), result1.bytesConsumed()); + clientToServer.compact(); + + clientIn.clear(); + serverIn.clear(); + clientOut.rewind(); + serverOut.rewind(); + + log("======================================"); + log("Server -> Client [CloseNotify]"); + + if (isHandshaking(clientEngine)) { + throw new Exception("clientEngine IS handshaking"); + } + + if (isHandshaking(serverEngine)) { + throw new Exception("serverEngine IS handshaking"); + } + + serverEngine.closeOutbound(); + + if (!isHandshaking(serverEngine)) { + throw new Exception("serverEngine IS NOT handshaking"); + } + + clientOut.rewind(); + serverOut.rewind(); + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, 0, -1); + serverToClient.flip(); + + if (clientEngine.isInboundDone()) { + throw new Exception("clientEngine inboundDone"); + } + + result1 = clientEngine.unwrap(serverToClient, clientIn); + checkResult(serverToClient, clientIn, result1, + Status.CLOSED, HandshakeStatus.NEED_WRAP, + result2.bytesProduced(), 0); + serverToClient.compact(); + + if (!clientEngine.isInboundDone()) { + throw new Exception("clientEngine inboundDone"); + } + + if (!isHandshaking(clientEngine)) { + throw new Exception("clientEngine IS NOT handshaking"); + } + + result2 = serverEngine.wrap(serverOut, serverToClient); + checkResult(serverOut, serverToClient, result2, + Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, 0, 0); + serverToClient.flip(); + + log("======================================"); + log("CloseNotify response"); + + if (clientEngine.isOutboundDone()) { + throw new Exception("clientEngine outboundDone"); + } + + result1 = clientEngine.wrap(clientOut, clientToServer); + checkResult(clientOut, clientToServer, result1, + Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, 0, -1); + + if (!clientEngine.isOutboundDone()) { + throw new Exception("clientEngine outboundDone is NOT done"); + } + + if (isHandshaking(clientEngine)) { + throw new Exception("clientEngine IS handshaking"); + } + + clientToServer.flip(); + + if (!serverEngine.isOutboundDone()) { + throw new Exception("clientEngine outboundDone"); + } + + if (serverEngine.isInboundDone()) { + throw new Exception("clientEngine inboundDone"); + } + + result2 = serverEngine.unwrap(clientToServer, serverIn); + + checkResult(clientToServer, serverIn, result2, + Status.CLOSED, HandshakeStatus.NOT_HANDSHAKING, + result1.bytesProduced(), 0); + + if (!serverEngine.isOutboundDone()) { + throw new Exception("clientEngine outboundDone is NOT done"); + } + + if (!serverEngine.isInboundDone()) { + throw new Exception("clientEngine inboundDone is NOT done"); + } + + if (isHandshaking(serverEngine)) { + throw new Exception("clientEngine IS handshaking"); + } + + clientToServer.compact(); + } + + public static void main(String args[]) throws Exception { + CheckTlsEngineResults cs = new CheckTlsEngineResults(); + cs.test(); + System.out.println("Test Passed."); + } + + /* + * ********************************************************** + * Majority of the test case is above, below is just setup stuff + * ********************************************************** + */ + + public CheckTlsEngineResults() throws Exception { + SSL_CONTEXT = getSSLContext(keyFilename, trustFilename); + } + + /* + * Create an initialized SSLContext to use for this test. + */ + private SSLContext getSSLContext(String keyFile, String trustFile) + throws Exception { + + KeyStore ks = KeyStore.getInstance("JKS"); + KeyStore ts = KeyStore.getInstance("JKS"); + + char[] passphrase = "passphrase".toCharArray(); + + ks.load(new FileInputStream(keyFile), passphrase); + ts.load(new FileInputStream(trustFile), passphrase); + + KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(ks, passphrase); + + TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); + tmf.init(ts); + + SSLContext sslCtx = SSLContext.getInstance("TLSv1.2"); + + sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + + return sslCtx; + } + + private void createBuffers() { + // Size the buffers as appropriate. + + SSLSession session = clientEngine.getSession(); + int appBufferMax = session.getApplicationBufferSize(); + int netBufferMax = session.getPacketBufferSize(); + + clientIn = ByteBuffer.allocateDirect(appBufferMax + 50); + serverIn = ByteBuffer.allocateDirect(appBufferMax + 50); + + clientToServer = ByteBuffer.allocateDirect(netBufferMax); + serverToClient = ByteBuffer.allocateDirect(netBufferMax); + + clientOut = ByteBuffer.wrap("Hi Server, I'm Client".getBytes()); + serverOut = ByteBuffer.wrap("Hello Client, I'm Server".getBytes()); + + log("Client out = " + clientOut); + log("Server out = " + serverOut); + log(""); + } + + private static void runDelegatedTasks(SSLEngine engine) { + + Runnable runnable; + while ((runnable = engine.getDelegatedTask()) != null) { + log("Running delegated task..."); + runnable.run(); + } + } + + private static void log(String str) { + System.out.println(str); + } +} From bf2d133f4a8c99249763a614401c9f08dd865535 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 5 Oct 2023 18:30:56 +0000 Subject: [PATCH 188/341] 8301377: adjust timeout for JLI GetObjectSizeIntrinsicsTest.java subtest again 8302607: increase timeout for ContinuousCallSiteTargetChange.java 8305502: adjust timeouts in three more M&M tests Backport-of: 4b23bef51df9c1a5bc8f43748a8d6c8d99995656 --- .../jtreg/compiler/jsr292/ContinuousCallSiteTargetChange.java | 4 ++-- .../monitoring/stress/classload/load007/TestDescription.java | 4 ++-- .../monitoring/stress/classload/load011/TestDescription.java | 4 ++-- .../monitoring/stress/classload/load012/TestDescription.java | 4 ++-- .../jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/hotspot/jtreg/compiler/jsr292/ContinuousCallSiteTargetChange.java b/test/hotspot/jtreg/compiler/jsr292/ContinuousCallSiteTargetChange.java index e877e9aa3d954..b0c05f8a371c7 100644 --- a/test/hotspot/jtreg/compiler/jsr292/ContinuousCallSiteTargetChange.java +++ b/test/hotspot/jtreg/compiler/jsr292/ContinuousCallSiteTargetChange.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 @@ -28,7 +28,7 @@ * * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run driver compiler.jsr292.ContinuousCallSiteTargetChange + * @run driver/timeout=180 compiler.jsr292.ContinuousCallSiteTargetChange */ package compiler.jsr292; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load007/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load007/TestDescription.java index 5080c8cb2233b..93bfe9f2c276a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load007/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load007/TestDescription.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 @@ -47,7 +47,7 @@ * /test/lib * @comment generate and compile LoadableClassXXX classes * @run driver nsk.monitoring.stress.classload.GenClassesBuilder - * @run main/othervm + * @run main/othervm/timeout=180 * -XX:-UseGCOverheadLimit * nsk.monitoring.stress.classload.load001 * classes diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load011/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load011/TestDescription.java index 6b188c7e99fef..97615b682906f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load011/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load011/TestDescription.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 @@ * /test/lib * @comment generate and compile LoadableClassXXX classes * @run driver nsk.monitoring.stress.classload.GenClassesBuilder - * @run main/othervm + * @run main/othervm/timeout=180 * -XX:-UseGCOverheadLimit * nsk.monitoring.stress.classload.load001 * classes diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load012/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load012/TestDescription.java index 4f314677adb18..e56cfe387e21e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load012/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/load012/TestDescription.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 @@ * /test/lib * @comment generate and compile LoadableClassXXX classes * @run driver nsk.monitoring.stress.classload.GenClassesBuilder - * @run main/othervm + * @run main/othervm/timeout=180 * -XX:-UseGCOverheadLimit * nsk.monitoring.stress.classload.load001 * classes diff --git a/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java b/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java index b8a8dbf93b511..759851a57d46b 100644 --- a/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java +++ b/test/jdk/java/lang/instrument/GetObjectSizeIntrinsicsTest.java @@ -278,7 +278,7 @@ * * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * - * @run main/othervm/timeout=240 -Xmx8g + * @run main/othervm/timeout=300 -Xmx8g * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -XX:+WhiteBoxAPI -Xbootclasspath/a:. * -Xint * -javaagent:basicAgent.jar GetObjectSizeIntrinsicsTest GetObjectSizeIntrinsicsTest large From 1cbcea2fdc852cdf019a51c71d03cdc7065a0a31 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 06:41:16 +0000 Subject: [PATCH 189/341] 8298298: NMT: count deltas are printed with 32-bit signed size Reviewed-by: lucy, stuefe Backport-of: f729f5b6d01b0d3a0ee21f50199ca30935c8237a --- src/hotspot/share/services/memReporter.cpp | 45 ++++++++++++------- .../share/utilities/globalDefinitions.hpp | 1 + .../utilities/globalDefinitions_visCPP.hpp | 10 +++++ .../utilities/test_globalDefinitions.cpp | 22 +++++++++ 4 files changed, 63 insertions(+), 15 deletions(-) diff --git a/src/hotspot/share/services/memReporter.cpp b/src/hotspot/share/services/memReporter.cpp index ee0d0b871f991..538b2d50b7452 100644 --- a/src/hotspot/share/services/memReporter.cpp +++ b/src/hotspot/share/services/memReporter.cpp @@ -31,6 +31,16 @@ #include "services/virtualMemoryTracker.hpp" #include "utilities/globalDefinitions.hpp" +// Diff two counters, express them as signed, with range checks +static ssize_t counter_diff(size_t c1, size_t c2) { + assert(c1 <= SSIZE_MAX, "counter out of range: " SIZE_FORMAT ".", c1); + assert(c2 <= SSIZE_MAX, "counter out of range: " SIZE_FORMAT ".", c2); + if (c1 > SSIZE_MAX || c2 > SSIZE_MAX) { + return 0; + } + return c1 - c2; +} + size_t MemReporterBase::reserved_total(const MallocMemory* malloc, const VirtualMemory* vm) const { return malloc->malloc_size() + malloc->arena_size() + vm->reserved(); } @@ -462,8 +472,9 @@ void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t cur } if (current_count > 0) { out->print(" #" SIZE_FORMAT "", current_count); - if (current_count != early_count) { - out->print(" %+d", (int)(current_count - early_count)); + const ssize_t delta_count = counter_diff(current_count, early_count); + if (delta_count != 0) { + out->print(" " SSIZE_PLUS_FORMAT, delta_count); } } } @@ -478,8 +489,9 @@ void MemSummaryDiffReporter::print_arena_diff(size_t current_amount, size_t curr } out->print(" #" SIZE_FORMAT "", current_count); - if (current_count != early_count) { - out->print(" %+d", (int)(current_count - early_count)); + const ssize_t delta_count = counter_diff(current_count, early_count); + if (delta_count != 0) { + out->print(" " SSIZE_PLUS_FORMAT, delta_count); } } @@ -551,30 +563,33 @@ void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, if (flag == mtClass) { // report class count out->print("%27s (classes #" SIZE_FORMAT "", " ", _current_baseline.class_count()); - int class_count_diff = (int)(_current_baseline.class_count() - - _early_baseline.class_count()); - if (_current_baseline.class_count() != _early_baseline.class_count()) { - out->print(" %+d", (int)(_current_baseline.class_count() - _early_baseline.class_count())); + const ssize_t class_count_diff = + counter_diff(_current_baseline.class_count(), _early_baseline.class_count()); + if (class_count_diff != 0) { + out->print(" " SSIZE_PLUS_FORMAT, class_count_diff); } out->print_cr(")"); out->print("%27s ( instance classes #" SIZE_FORMAT, " ", _current_baseline.instance_class_count()); - if (_current_baseline.instance_class_count() != _early_baseline.instance_class_count()) { - out->print(" %+d", (int)(_current_baseline.instance_class_count() - _early_baseline.instance_class_count())); + const ssize_t instance_class_count_diff = + counter_diff(_current_baseline.instance_class_count(), _early_baseline.instance_class_count()); + if (instance_class_count_diff != 0) { + out->print(" " SSIZE_PLUS_FORMAT, instance_class_count_diff); } out->print(", array classes #" SIZE_FORMAT, _current_baseline.array_class_count()); - if (_current_baseline.array_class_count() != _early_baseline.array_class_count()) { - out->print(" %+d", (int)(_current_baseline.array_class_count() - _early_baseline.array_class_count())); + const ssize_t array_class_count_diff = + counter_diff(_current_baseline.array_class_count(), _early_baseline.array_class_count()); + if (array_class_count_diff != 0) { + out->print(" " SSIZE_PLUS_FORMAT, array_class_count_diff); } out->print_cr(")"); } else if (flag == mtThread) { // report thread count out->print("%27s (thread #" SIZE_FORMAT "", " ", _current_baseline.thread_count()); - int thread_count_diff = (int)(_current_baseline.thread_count() - - _early_baseline.thread_count()); + const ssize_t thread_count_diff = counter_diff(_current_baseline.thread_count(), _early_baseline.thread_count()); if (thread_count_diff != 0) { - out->print(" %+d", thread_count_diff); + out->print(" " SSIZE_PLUS_FORMAT, thread_count_diff); } out->print_cr(")"); diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index eeb19980dbf5c..6480b082c81f1 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -141,6 +141,7 @@ class oopDesc; #define INTPTR_FORMAT_W(width) "%" #width PRIxPTR #define SSIZE_FORMAT "%" PRIdPTR +#define SSIZE_PLUS_FORMAT "%+" PRIdPTR #define SIZE_FORMAT "%" PRIuPTR #define SIZE_FORMAT_HEX "0x%" PRIxPTR #define SSIZE_FORMAT_W(width) "%" #width PRIdPTR diff --git a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp index 0cf4ae5c721b4..c82ef953ae3e2 100644 --- a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp @@ -140,4 +140,14 @@ inline int g_isfinite(jdouble f) { return _finite(f); } #define USE_VECTORED_EXCEPTION_HANDLING #endif +#ifndef SSIZE_MAX +#ifdef _LP64 +#define SSIZE_MIN LLONG_MIN +#define SSIZE_MAX LLONG_MAX +#else +#define SSIZE_MIN INT_MIN +#define SSIZE_MAX INT_MAX +#endif +#endif // SSIZE_MAX missing + #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_VISCPP_HPP diff --git a/test/hotspot/gtest/utilities/test_globalDefinitions.cpp b/test/hotspot/gtest/utilities/test_globalDefinitions.cpp index 503bd2d3eead7..9af19614e09a2 100644 --- a/test/hotspot/gtest/utilities/test_globalDefinitions.cpp +++ b/test/hotspot/gtest/utilities/test_globalDefinitions.cpp @@ -22,6 +22,7 @@ */ #include "precompiled.hpp" +#include "memory/resourceArea.hpp" #include "runtime/os.hpp" #include "utilities/align.hpp" #include "utilities/globalDefinitions.hpp" @@ -216,3 +217,24 @@ TEST(globalDefinitions, array_size) { } } + +#define check_format(format, value, expected) \ + do { \ + ResourceMark rm; \ + stringStream out; \ + out.print((format), (value)); \ + const char* result = out.as_string(); \ + EXPECT_STREQ((result), (expected)) << "Failed with" \ + << " format '" << (format) << "'" \ + << " value '" << (value); \ + } while (false) + +TEST(globalDefinitions, format_specifiers) { + check_format(SSIZE_FORMAT, (ssize_t)-123, "-123"); + check_format(SSIZE_FORMAT, (ssize_t)2147483647, "2147483647"); + check_format(SSIZE_FORMAT, (ssize_t)-2147483647, "-2147483647"); + check_format(SSIZE_PLUS_FORMAT, (ssize_t)123, "+123"); + check_format(SSIZE_PLUS_FORMAT, (ssize_t)-123, "-123"); + check_format(SSIZE_PLUS_FORMAT, (ssize_t)2147483647, "+2147483647"); + check_format(SSIZE_PLUS_FORMAT, (ssize_t)-2147483647, "-2147483647"); +} From 4c0171a662c3272b6c78c313ddb7880a1dbb86ed Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 06:43:12 +0000 Subject: [PATCH 190/341] 8305505: NPE in javazic compiler Backport-of: 544bd260b6eb7bc7cf79a3739cc94bad658d7d15 --- test/jdk/sun/util/calendar/zi/GenDoc.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/jdk/sun/util/calendar/zi/GenDoc.java b/test/jdk/sun/util/calendar/zi/GenDoc.java index 370d27b5835fe..e9e6ebc0cd8fa 100644 --- a/test/jdk/sun/util/calendar/zi/GenDoc.java +++ b/test/jdk/sun/util/calendar/zi/GenDoc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -154,10 +154,10 @@ int processZoneinfo(Timezone tz) { outD.mkdirs(); /* If mapfile is available, add a link to the appropriate map */ - if ((mapList == null) && (Main.getMapFile() != null)) { + if (mapList == null && Main.getMapFile() != null) { + mapList = new HashMap(); FileReader fr = new FileReader(Main.getMapFile()); BufferedReader in = new BufferedReader(fr); - mapList = new HashMap(); String line; while ((line = in.readLine()) != null) { // skip blank and comment lines @@ -180,7 +180,7 @@ int processZoneinfo(Timezone tz) { out.write(header1 + new Date() + header3 + zonename + header4); out.write(body1 + "" + zonename + ""); - LatitudeAndLongitude location = mapList.get(zonename); + LatitudeAndLongitude location = (mapList != null ? mapList.get(zonename) : null); if (location != null) { int deg, min, sec; From 76a402d1f56fd1a3637aad6463cc724a8fe7df22 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 06:43:39 +0000 Subject: [PATCH 191/341] 8301455: comments in TestTypeAnnotations still refer to resolved JDK-8068737 Backport-of: 35e75c131d7c1c2596022955c0f4c53dd3c7e448 --- .../doclet/testTypeAnnotations/TestTypeAnnotations.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java b/test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java index f52c4619aee0a..ac5fc62cc2350 100644 --- a/test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java +++ b/test/langtools/jdk/javadoc/doclet/testTypeAnnotations/TestTypeAnnotations.java @@ -136,7 +136,6 @@ annotation interface in typeannos">@FldA java.lang.String,@FldB [][]&nbs\ p;array2SecondOld""", - // When JDK-8068737, we should change the order """
@FldD java.lang.String @FldB java.lang.String> @MRtnA java.lang.Strin\ g method()
""", - // When JDK-8068737 is fixed, we should change the order """
@MRtnA java.lang.String @MTyParamA java.lang.String, tation interface in typeannos">@ParamB java.lang.String> a)""", - // When JDK-8068737 is fixed, we should change the order """
void array2Deep( Date: Fri, 6 Oct 2023 07:10:01 +0000 Subject: [PATCH 193/341] 8299075: TestStringDeduplicationInterned.java fails because extra deduplication Backport-of: 682359cb4871d779425a9468e8a307169b3651d6 --- .../TestStringDeduplicationTools.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java index b476d0591961c..32147e86d176f 100644 --- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java +++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java @@ -333,9 +333,8 @@ public static void main(String[] args) { // Create duplicate of baseString StringBuilder sb1 = new StringBuilder(baseString); String dupString1 = sb1.toString(); - if (getValue(dupString1) == getValue(baseString)) { - throw new RuntimeException("Values should not match"); - } + + checkNotDeduplicated(getValue(dupString1), getValue(baseString)); // Force baseString to be inspected for deduplication // and be inserted into the deduplication hashtable. @@ -348,9 +347,8 @@ public static void main(String[] args) { // Create a new duplicate of baseString StringBuilder sb2 = new StringBuilder(baseString); String dupString2 = sb2.toString(); - if (getValue(dupString2) == getValue(baseString)) { - throw new RuntimeException("Values should not match"); - } + + checkNotDeduplicated(getValue(dupString2), getValue(baseString)); // Intern the new duplicate Object beforeInternedValue = getValue(dupString2); @@ -369,16 +367,13 @@ public static void main(String[] args) { // Check original value of interned string, to make sure // deduplication happened on the interned string and not // on the base string - if (beforeInternedValue == getValue(baseString)) { - throw new RuntimeException("Values should not match"); - } + checkNotDeduplicated(beforeInternedValue, getValue(baseString)); // Create duplicate of baseString StringBuilder sb3 = new StringBuilder(baseString); String dupString3 = sb3.toString(); - if (getValue(dupString3) == getValue(baseString)) { - throw new RuntimeException("Values should not match"); - } + + checkNotDeduplicated(dupString3, getValue(baseString)); forceDeduplication(ageThreshold, FullGC); @@ -395,6 +390,15 @@ public static void main(String[] args) { System.out.println("End: InternedTest"); } + private static void checkNotDeduplicated(Object value1, Object value2) { + // Note that the following check is invalid since a GC + // can run and actually deduplicate the strings. + // + // if (value1 == value2) { + // throw new RuntimeException("Values should not match"); + // } + } + public static OutputAnalyzer run() throws Exception { return runTest("-Xlog:gc=debug,stringdedup*=debug", "-XX:+UseStringDeduplication", From 273872c78dfc055b596e2f24e31b1b71eea7ea8e Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 07:12:12 +0000 Subject: [PATCH 194/341] 8301489: C1: ShortLoopOptimizer might lift instructions before their inputs Backport-of: 73d7aa1d2cb037fed69263a1990258866333664d --- src/hotspot/share/c1/c1_ValueMap.cpp | 29 ++++- .../jtreg/compiler/c1/Test8301489.java | 116 ++++++++++++++++++ 2 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/compiler/c1/Test8301489.java diff --git a/src/hotspot/share/c1/c1_ValueMap.cpp b/src/hotspot/share/c1/c1_ValueMap.cpp index a0a012ce81386..dfd15015aa538 100644 --- a/src/hotspot/share/c1/c1_ValueMap.cpp +++ b/src/hotspot/share/c1/c1_ValueMap.cpp @@ -359,6 +359,33 @@ LoopInvariantCodeMotion::LoopInvariantCodeMotion(ShortLoopOptimizer *slo, Global } } +class CheckInsertionPoint : public ValueVisitor { + private: + Value _insert; + bool _valid = true; + + void visit(Value* vp) { + assert(*vp != nullptr, "value should not be null"); + if (_insert->dominator_depth() < (*vp)->dominator_depth()) { + _valid = false; + } + } + + public: + bool is_valid() { return _valid; } + CheckInsertionPoint(Value insert) + : _insert(insert) { + assert(insert != nullptr, "insertion point should not be null"); + } +}; + +// Check that insertion point has higher dom depth than all inputs to cur +static bool is_dominated_by_inputs(Instruction* insertion_point, Instruction* cur) { + CheckInsertionPoint v(insertion_point); + cur->input_values_do(&v); + return v.is_valid(); +} + void LoopInvariantCodeMotion::process_block(BlockBegin* block) { TRACE_VALUE_NUMBERING(tty->print_cr("processing block B%d", block->block_id())); @@ -394,7 +421,7 @@ void LoopInvariantCodeMotion::process_block(BlockBegin* block) { cur_invariant = is_invariant(cvt->value()); } - if (cur_invariant) { + if (cur_invariant && is_dominated_by_inputs(_insertion_point, cur)) { // perform value numbering and mark instruction as loop-invariant _gvn->substitute(cur); diff --git a/test/hotspot/jtreg/compiler/c1/Test8301489.java b/test/hotspot/jtreg/compiler/c1/Test8301489.java new file mode 100644 index 0000000000000..3cbbfbc27ac3b --- /dev/null +++ b/test/hotspot/jtreg/compiler/c1/Test8301489.java @@ -0,0 +1,116 @@ +/* + * 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 8301489 + * @summary ShortLoopOptimizer might lift instructions before their inputs + * @requires vm.compiler1.enabled + * @run main/othervm -Xcomp -XX:TieredStopAtLevel=1 + * -XX:CompileOnly=compiler.c1.Test8301489::* + * compiler.c1.Test8301489 + */ + + +package compiler.c1; + +public class Test8301489 { + static int c = 0; + static int[] arr = {}; + + static void op2Test(int a, int b) { + // Implicit edges created during dom calculation to exception handler + if (a < 0) { + b = 0; + } + // Create two branches into next loop header block + try { + int l = arr.length; + for (int i = 0; i < l; i++) { + int d = arr[i] + arr[i]; + } + } + // Exception handler as predecessor of the next loop header block + catch (ArithmeticException e) {} + + // op2(a, b) as candidate for hoisting: operands are loop invariant + while (a + b < b) {} + // op2(a, b) should not be hoisted above 'if (a < 0) {...}' block + } + + static void arrayLengthTest() { + float [] newArr = new float[c]; + + try { + for (float f : newArr) {} + } + catch (ArrayIndexOutOfBoundsException e) {} + + while (54321 < newArr.length) { + newArr[c] = 123.45f; + } + } + + static void negateTest(int a) { + if (a <= 111) { + a = -111; + } + + int f = 0; + try { + int l = arr.length; + f--; + } + catch (NegativeArraySizeException e) {} + + while (-a < f) { + f--; + } + } + + static void convertTest(int a) { + if (c == 0) { + a = 0; + } + + long tgt = 10; + + try { + String s = String.valueOf(c); + } + catch (NumberFormatException e) {} + + while ((long)a != tgt) { + tgt--; + } + } + + public static void main(String[] args) { + for (int i = 0; i < 3; i++) { + op2Test(12, 34); + arrayLengthTest(); + negateTest(-778); + convertTest(4812); + } + } +} From dbbded3027ee36921acb1c29f44b7a9f899f2fc8 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 07:16:15 +0000 Subject: [PATCH 195/341] 8308103: Massive (up to ~30x) increase in C2 compilation time since JDK 17 Backport-of: c6ab9c2905203e1ec897b3404f9179ff975d0054 --- src/hotspot/share/opto/loopopts.cpp | 8 ++- ...TestSinkingNodesCausesLongCompilation.java | 63 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestSinkingNodesCausesLongCompilation.java diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index eb1da11123472..258ceadaaaf26 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -1600,7 +1600,13 @@ void PhaseIdealLoop::try_sink_out_of_loop(Node* n) { cast = ConstraintCastNode::make_cast_for_type(x_ctrl, in, in_t, ConstraintCastNode::UnconditionalDependency); } if (cast != nullptr) { - register_new_node(cast, x_ctrl); + Node* prev = _igvn.hash_find_insert(cast); + if (prev != nullptr) { + cast->destruct(&_igvn); + cast = prev; + } else { + register_new_node(cast, x_ctrl); + } x->replace_edge(in, cast); // Chain of AddP: // 2- A CastPP of the base is only added now that both AddP nodes are sunk diff --git a/test/hotspot/jtreg/compiler/loopopts/TestSinkingNodesCausesLongCompilation.java b/test/hotspot/jtreg/compiler/loopopts/TestSinkingNodesCausesLongCompilation.java new file mode 100644 index 0000000000000..292ffe38fc3bd --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestSinkingNodesCausesLongCompilation.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023, Red Hat, Inc. All rights reserved. + * 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 8308103 + * @summary Massive (up to ~30x) increase in C2 compilation time since JDK 17 + * @run main/othervm -Xcomp -XX:CompileOnly=TestSinkingNodesCausesLongCompilation::mainTest -XX:+UnlockDiagnosticVMOptions + * -XX:RepeatCompilation=30 TestSinkingNodesCausesLongCompilation + */ + +public class TestSinkingNodesCausesLongCompilation { + public static final int N = 400; + public static int iFld=41489; + + public void mainTest(String[] strArr1) { + int i9=-13, i10=-248, i11=-4, i13=33, i15=-171, i18=-58, iArr2[]=new int[N]; + + for (i9 = 7; i9 < 256; i9++) { + i11 = 1; + do { + } while (++i11 < 101); + } + for (int i14 : iArr2) { + for (i15 = 63; 0 < i15; i15 -= 2) { + i10 *= i13; + i10 >>= i14; + } + for (i18 = 2; 63 > i18; i18++) { + i10 = iFld; + iArr2[i18] |= i11; + } + } + System.out.println("i9 = " + i9); + } + + public static void main(String[] strArr) { + TestSinkingNodesCausesLongCompilation _instance = new TestSinkingNodesCausesLongCompilation(); + for (int i = 0; i < 10; i++) { + _instance.mainTest(strArr); + } + } +} From 7f9b92ce5e61323de80d3880007723614b70cdda Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 07:29:20 +0000 Subject: [PATCH 196/341] 8312440: assert(cast != nullptr) failed: must have added a cast to pin the node Backport-of: 01e135c91018a41800c2df534b1d6dbd396adbf4 --- src/hotspot/share/opto/loopopts.cpp | 2 +- .../TestSunkNodeMissingCastAssert.java | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestSunkNodeMissingCastAssert.java diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 258ceadaaaf26..33ba2d9a8c770 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -1601,7 +1601,7 @@ void PhaseIdealLoop::try_sink_out_of_loop(Node* n) { } if (cast != nullptr) { Node* prev = _igvn.hash_find_insert(cast); - if (prev != nullptr) { + if (prev != nullptr && get_ctrl(prev) == x_ctrl) { cast->destruct(&_igvn); cast = prev; } else { diff --git a/test/hotspot/jtreg/compiler/loopopts/TestSunkNodeMissingCastAssert.java b/test/hotspot/jtreg/compiler/loopopts/TestSunkNodeMissingCastAssert.java new file mode 100644 index 0000000000000..72d44e0909cec --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestSunkNodeMissingCastAssert.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023, Red Hat, Inc. All rights reserved. + * 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 8312440 + * @summary assert(cast != nullptr) failed: must have added a cast to pin the node + * @run main/othervm -XX:-BackgroundCompilation TestSunkNodeMissingCastAssert + */ + + +public class TestSunkNodeMissingCastAssert { + private static int N = 500; + private static int ia[] = new int[N]; + private static volatile int ib[] = new int[N]; + + private static void test() { + for (int k = 1; k < 200; k++) + switch (k % 5) { + case 0: + ia[k - 1] -= 15; + case 2: + for (int m = 0; m < 1000; m++); + case 3: + ib[k - 1] <<= 5; + case 4: + ib[k + 1] <<= 3; + } + } + + public static void main(String[] args) { + for (int i = 0; i < 20000; i++) { + test(); + } + } +} + From 98e54902340abfdeb6cf11ce5fe93833d5ef2d70 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 07:32:41 +0000 Subject: [PATCH 197/341] 8315377: C2: assert(u->find_out_with(Op_AddP) == nullptr) failed: more than 2 chained AddP nodes? Backport-of: ba1a46392f0b9c77c64278f82513aaf51f5c9b1b --- src/hotspot/share/opto/loopnode.hpp | 2 + src/hotspot/share/opto/loopopts.cpp | 35 ++++++--- .../TestSinkingMoreThan2AddPNodes.java | 75 +++++++++++++++++++ 3 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestSinkingMoreThan2AddPNodes.java diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index 3d8f8b6c88fc0..bf835a92770ca 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -1644,6 +1644,8 @@ class PhaseIdealLoop : public PhaseTransform { void try_sink_out_of_loop(Node* n); bool safe_for_if_replacement(const Node* dom) const; + + void update_addp_chain_base(Node* x, Node* old_base, Node* new_base); }; diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 33ba2d9a8c770..6cfe2bd245369 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -1581,9 +1581,10 @@ void PhaseIdealLoop::try_sink_out_of_loop(Node* n) { assert(!n_loop->is_member(get_loop(x_ctrl)), "should have moved out of loop"); register_new_node(x, x_ctrl); - // Chain of AddP: (AddP base (AddP base )) must keep the same base after sinking so: - // 1- We don't add a CastPP here when the first one is sunk so if the second one is not, their bases remain - // the same. + // Chain of AddP nodes: (AddP base (AddP base (AddP base ))) + // All AddP nodes must keep the same base after sinking so: + // 1- We don't add a CastPP here until the last one of the chain is sunk: if part of the chain is not sunk, + // their bases remain the same. // (see 2- below) assert(!x->is_AddP() || !x->in(AddPNode::Address)->is_AddP() || x->in(AddPNode::Address)->in(AddPNode::Base) == x->in(AddPNode::Base) || @@ -1608,16 +1609,10 @@ void PhaseIdealLoop::try_sink_out_of_loop(Node* n) { register_new_node(cast, x_ctrl); } x->replace_edge(in, cast); - // Chain of AddP: - // 2- A CastPP of the base is only added now that both AddP nodes are sunk + // Chain of AddP nodes: + // 2- A CastPP of the base is only added now that all AddP nodes are sunk if (x->is_AddP() && k == AddPNode::Base) { - for (DUIterator_Fast imax, i = x->fast_outs(imax); i < imax; i++) { - Node* u = x->fast_out(i); - if (u->is_AddP() && u->in(AddPNode::Base) == n->in(AddPNode::Base)) { - _igvn.replace_input_of(u, AddPNode::Base, cast); - assert(u->find_out_with(Op_AddP) == nullptr, "more than 2 chained AddP nodes?"); - } - } + update_addp_chain_base(x, n->in(AddPNode::Base), cast); } break; } @@ -1632,6 +1627,22 @@ void PhaseIdealLoop::try_sink_out_of_loop(Node* n) { } } +void PhaseIdealLoop::update_addp_chain_base(Node* x, Node* old_base, Node* new_base) { + ResourceMark rm; + Node_List wq; + wq.push(x); + while (wq.size() != 0) { + Node* n = wq.pop(); + for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { + Node* u = n->fast_out(i); + if (u->is_AddP() && u->in(AddPNode::Base) == old_base) { + _igvn.replace_input_of(u, AddPNode::Base, new_base); + wq.push(u); + } + } + } +} + // Compute the early control of a node by following its inputs until we reach // nodes that are pinned. Then compute the LCA of the control of all pinned nodes. Node* PhaseIdealLoop::compute_early_ctrl(Node* n, Node* n_ctrl) { diff --git a/test/hotspot/jtreg/compiler/loopopts/TestSinkingMoreThan2AddPNodes.java b/test/hotspot/jtreg/compiler/loopopts/TestSinkingMoreThan2AddPNodes.java new file mode 100644 index 0000000000000..42cc4c77401f7 --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestSinkingMoreThan2AddPNodes.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2023, Red Hat, Inc. All rights reserved. + * 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 8315377 + * @requires vm.compiler2.enabled + * @summary C2: assert(u->find_out_with(Op_AddP) == nullptr) failed: more than 2 chained AddP nodes? + * @library /test/lib + * @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=TestSinkingMoreThan2AddPNodes::test TestSinkingMoreThan2AddPNodes + * + */ + +import jdk.test.lib.Utils; + +public class TestSinkingMoreThan2AddPNodes { + public static void main(String[] strArr) throws Exception { + Thread t = new Thread(new Runnable() { + public void run() { + test(); + } + }); + t.setDaemon(true); + t.start(); + Thread.sleep(Utils.adjustTimeout(500)); + } + + static void test() { + double dArr[] = new double[10]; + int i4 = 5, i11, i12 = 2, iArr[] = new int[400]; + long l1; + byte by1 = 0; + short s1 = 8; + + for (int i = 0; i < iArr.length; i++) { + iArr[i] = (i % 2 == 0) ? 23 : 34; + } + + for (i11 = 10; i11 > 9; ) { + l1 = 1; + do { + try { + i4 = 6 % i4; + i12 = iArr[(int) l1]; + } catch (ArithmeticException a_e) { + } + by1 += 8; + iArr = iArr; + } while (++l1 < 11); + } + + long meth_res = i12; + } +} + From 8afd87b1f95a1426f55c259b9b43faf25d3617ec Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Fri, 6 Oct 2023 12:03:33 +0000 Subject: [PATCH 198/341] 8316566: RISC-V: Zero extended narrow oop passed to Atomic::cmpxchg Backport-of: 2d154fcd0de0612f58abbc5027f409b9b2eb0dc2 --- src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp b/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp index 2b500376f9b48..a7dc84770f84c 100644 --- a/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp +++ b/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp @@ -37,7 +37,7 @@ inline void OrderAccess::storestore() { release(); } inline void OrderAccess::loadstore() { acquire(); } inline void OrderAccess::storeload() { fence(); } -#define FULL_MEM_BARRIER __sync_synchronize() +#define FULL_MEM_BARRIER __atomic_thread_fence(__ATOMIC_SEQ_CST); #define READ_MEM_BARRIER __atomic_thread_fence(__ATOMIC_ACQUIRE); #define WRITE_MEM_BARRIER __atomic_thread_fence(__ATOMIC_RELEASE); From 6cc99758fc4519aa4aa3c5ab834f2e8a8a69fe6b Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 16:38:26 +0000 Subject: [PATCH 199/341] 8258951: java/net/httpclient/HandshakeFailureTest.java failed with "RuntimeException: Not found expected SSLHandshakeException in java.io.IOException" Backport-of: db9834ff82ce477e5c38c8873d39f54882627746 --- .../jdk/internal/net/http/Http2Connection.java | 11 +++++++---- .../jdk/java/net/httpclient/HandshakeFailureTest.java | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java index c505282ebe6be..59c88e9f09984 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java @@ -468,10 +468,11 @@ private static CompletableFuture checkSSLConfig(AbstractAsyncSSLConnection ac CompletableFuture cf = new MinimalFuture<>(); SSLEngine engine = aconn.getEngine(); String engineAlpn = engine.getApplicationProtocol(); - assert Objects.equals(alpn, engineAlpn) - : "alpn: %s, engine: %s".formatted(alpn, engineAlpn); - - DEBUG_LOGGER.log("checkSSLConfig: alpn: %s", alpn ); + DEBUG_LOGGER.log("checkSSLConfig: alpn: '%s', engine: '%s'", alpn, engineAlpn); + if (alpn == null && engineAlpn != null) { + alpn = engineAlpn; + } + DEBUG_LOGGER.log("checkSSLConfig: alpn: '%s'", alpn ); if (alpn == null || !alpn.equals("h2")) { String msg; @@ -494,6 +495,8 @@ private static CompletableFuture checkSSLConfig(AbstractAsyncSSLConnection ac cf.completeExceptionally(new ALPNException(msg, aconn)); return cf; } + assert Objects.equals(alpn, engineAlpn) + : "alpn: %s, engine: %s".formatted(alpn, engineAlpn); cf.complete(null); return cf; }; diff --git a/test/jdk/java/net/httpclient/HandshakeFailureTest.java b/test/jdk/java/net/httpclient/HandshakeFailureTest.java index d111d1f7dc3f1..a6db6be817a64 100644 --- a/test/jdk/java/net/httpclient/HandshakeFailureTest.java +++ b/test/jdk/java/net/httpclient/HandshakeFailureTest.java @@ -49,7 +49,7 @@ /** * @test - * @bug 8238990 + * @bug 8238990 8258951 * @run main/othervm -Djdk.internal.httpclient.debug=true HandshakeFailureTest TLSv1.2 * @run main/othervm -Djdk.internal.httpclient.debug=true HandshakeFailureTest TLSv1.3 * @summary Verify SSLHandshakeException is received when the handshake fails, From e95369bb1bd5b046728fd12f085b406689bee8c1 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 16:42:44 +0000 Subject: [PATCH 200/341] 8281149: (fs) java/nio/file/FileStore/Basic.java fails with java.lang.RuntimeException: values differ by more than 1GB Backport-of: a5343fa60505764c088dad4a17680d92568509d5 --- test/jdk/java/nio/file/FileStore/Basic.java | 27 +++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test/jdk/java/nio/file/FileStore/Basic.java b/test/jdk/java/nio/file/FileStore/Basic.java index 8c62565c9c4e3..9bba08de71f27 100644 --- a/test/jdk/java/nio/file/FileStore/Basic.java +++ b/test/jdk/java/nio/file/FileStore/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,11 +57,12 @@ static void assertTrue(boolean okay) { throw new RuntimeException("Assertion failed"); } - static void checkWithin1GB(long expected, long actual) { + static void checkWithin1GB(String space, long expected, long actual) { long diff = Math.abs(actual - expected); if (diff > G) { - String msg = String.format("|actual %d - expected %d| = %d (%f G)", - actual, expected, diff, (float)diff/G); + String msg = String.format("%s: |actual %d - expected %d| = %d (%f G)", + space, actual, expected, diff, + (float)diff/G); throw new RuntimeException(msg); } } @@ -110,19 +111,19 @@ static void doTests(Path dir) throws IOException { * Test: Space atributes */ File f = file1.toFile(); - long total = f.getTotalSpace(); - long free = f.getFreeSpace(); - long usable = f.getUsableSpace(); // check values are "close" - checkWithin1GB(total, store1.getTotalSpace()); - checkWithin1GB(free, store1.getUnallocatedSpace()); - checkWithin1GB(usable, store1.getUsableSpace()); + checkWithin1GB("total", f.getTotalSpace(), store1.getTotalSpace()); + checkWithin1GB("free", f.getFreeSpace(), store1.getUnallocatedSpace()); + checkWithin1GB("usable", f.getUsableSpace(), store1.getUsableSpace()); // get values by name - checkWithin1GB(total, (Long)store1.getAttribute("totalSpace")); - checkWithin1GB(free, (Long)store1.getAttribute("unallocatedSpace")); - checkWithin1GB(usable, (Long)store1.getAttribute("usableSpace")); + checkWithin1GB("total", f.getTotalSpace(), + (Long)store1.getAttribute("totalSpace")); + checkWithin1GB("free", f.getFreeSpace(), + (Long)store1.getAttribute("unallocatedSpace")); + checkWithin1GB("usable", f.getUsableSpace(), + (Long)store1.getAttribute("usableSpace")); /** * Test: Enumerate all FileStores From 3506c888268d7995938ac64d0261d96deb89fa14 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 16:47:00 +0000 Subject: [PATCH 201/341] 8309104: [JVMCI] compiler/unsafe/UnsafeGetStableArrayElement test asserts wrong values with Graal Backport-of: 11fb5b2209124bbf1100657e340ba5aebc3820d7 --- .../unsafe/UnsafeGetStableArrayElement.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java b/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java index 09fc32ae62402..931b1a10e0bd7 100644 --- a/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java +++ b/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.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 @@ -224,12 +224,12 @@ static void testMatched(Callable c, Runnable setDefaultAction) throws Excepti } static void testMismatched(Callable c, Runnable setDefaultAction) throws Exception { - testMismatched(c, setDefaultAction, false); + testMismatched(c, setDefaultAction, false, true); } - static void testMismatched(Callable c, Runnable setDefaultAction, boolean objectArray) throws Exception { - if (Compiler.isGraalEnabled() && !objectArray) { - // Graal will constant fold mismatched reads from primitive stable arrays + static void testMismatched(Callable c, Runnable setDefaultAction, boolean objectArray, boolean aligned) throws Exception { + if (Compiler.isGraalEnabled() && !objectArray && aligned) { + // Graal will constant fold mismatched reads from primitive stable arrays, except unaligned ones run(c, setDefaultAction, null); } else { run(c, null, setDefaultAction); @@ -319,15 +319,15 @@ static void testUnsafeAccess() throws Exception { testMatched( Test::testD_D, Test::changeD); // Object[], aligned accesses - testMismatched(Test::testL_J, Test::changeL, true); // long & double are always as large as an OOP - testMismatched(Test::testL_D, Test::changeL, true); + testMismatched(Test::testL_J, Test::changeL, true, true); // long & double are always as large as an OOP + testMismatched(Test::testL_D, Test::changeL, true, true); testMatched( Test::testL_L, Test::changeL); // Unaligned accesses - testMismatched(Test::testS_U, Test::changeS); - testMismatched(Test::testC_U, Test::changeC); - testMismatched(Test::testI_U, Test::changeI); - testMismatched(Test::testJ_U, Test::changeJ); + testMismatched(Test::testS_U, Test::changeS, false, false); + testMismatched(Test::testC_U, Test::changeC, false, false); + testMismatched(Test::testI_U, Test::changeI, false, false); + testMismatched(Test::testJ_U, Test::changeJ, true, false); // No way to reliably check the expected behavior: // (1) OOPs change during GC; From 8314149748aa08692787621ab91e18f116d6c67a Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 Oct 2023 16:50:09 +0000 Subject: [PATCH 202/341] 8315606: Open source few swing text/html tests Backport-of: 4127fbb9ed6ca3c3e82da599dbf9cee54de5da31 --- .../text/html/HTMLEditorKit/bug4357975.java | 103 +++++++++++++++ .../text/html/HTMLWriter/bug4841760.java | 67 ++++++++++ .../swing/text/html/ImageView/bug4329185.java | 118 ++++++++++++++++++ .../text/html/InlineView/bug4623342.java | 110 ++++++++++++++++ 4 files changed, 398 insertions(+) create mode 100644 test/jdk/javax/swing/text/html/HTMLEditorKit/bug4357975.java create mode 100644 test/jdk/javax/swing/text/html/HTMLWriter/bug4841760.java create mode 100644 test/jdk/javax/swing/text/html/ImageView/bug4329185.java create mode 100644 test/jdk/javax/swing/text/html/InlineView/bug4623342.java diff --git a/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4357975.java b/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4357975.java new file mode 100644 index 0000000000000..39a78bcf9c1ff --- /dev/null +++ b/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4357975.java @@ -0,0 +1,103 @@ +/* + * 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 + * 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 4357975 + * @summary Tests if InsertUnorderedListItem generates the proper tag sequence + * @run main bug4357975 + */ + +import java.awt.event.ActionEvent; + +import javax.swing.Action; +import javax.swing.JEditorPane; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.AttributeSet; +import javax.swing.text.Element; +import javax.swing.text.StyleConstants; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLEditorKit; +import javax.swing.text.html.HTMLDocument; + +public class bug4357975 { + + public static void main(String[] args) throws Exception { + JEditorPane jep = new JEditorPane(); + HTMLEditorKit kit = new HTMLEditorKit(); + jep.setEditorKit(kit); + jep.setDocument(kit.createDefaultDocument()); + + HTMLDocument doc = (HTMLDocument) jep.getDocument(); + + DocumentListener l = new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + int offset = e.getOffset(); + HTMLDocument doc = (HTMLDocument)e.getDocument(); + + Element el = doc.getCharacterElement(offset + 1); + AttributeSet attrs = el.getAttributes(); + Object name = attrs.getAttribute(StyleConstants.NameAttribute); + boolean passed = (name == HTML.Tag.CONTENT); + + el = el.getParentElement(); + attrs = el.getAttributes(); + name = attrs.getAttribute(StyleConstants.NameAttribute); + passed = (passed && (name == HTML.Tag.IMPLIED)); + + el = el.getParentElement(); + attrs = el.getAttributes(); + name = attrs.getAttribute(StyleConstants.NameAttribute); + passed = (passed && (name == HTML.Tag.LI)); + + el = el.getParentElement(); + attrs = el.getAttributes(); + name = attrs.getAttribute(StyleConstants.NameAttribute); + passed = (passed && (name == HTML.Tag.UL)); + if (!passed) { + throw new RuntimeException("Test failed"); + } + } + + @Override + public void changedUpdate(DocumentEvent e) {} + @Override + public void removeUpdate(DocumentEvent e) {} + }; + doc.addDocumentListener(l); + + Action[] actions = kit.getActions(); + for (int i = 0; i < actions.length; i++){ + Action a = actions[i]; + if (a.getValue(Action.NAME) == "InsertUnorderedListItem") { + a.actionPerformed(new ActionEvent(jep, + ActionEvent.ACTION_PERFORMED, + (String) a.getValue(Action.ACTION_COMMAND_KEY))); + break; + } + } + + } +} diff --git a/test/jdk/javax/swing/text/html/HTMLWriter/bug4841760.java b/test/jdk/javax/swing/text/html/HTMLWriter/bug4841760.java new file mode 100644 index 0000000000000..5c9b41ce6a17c --- /dev/null +++ b/test/jdk/javax/swing/text/html/HTMLWriter/bug4841760.java @@ -0,0 +1,67 @@ +/* + * 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 + * 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 4841760 + * @summary Tests if HTML tags are correctly shown for + StyleEditorKit.ForegroundAction() in JTextPane output. + * @run main bug4841760 + */ + +import javax.swing.JTextPane; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.html.HTMLEditorKit; + +public class bug4841760 { + + public static void main(String[] args) throws Exception { + JTextPane jep = new JTextPane(); + jep.setEditorKit(new HTMLEditorKit()); + jep.setText("hellojavaworld"); + + SimpleAttributeSet set = new SimpleAttributeSet(); + StyleConstants.setForeground(set, java.awt.Color.BLUE); + jep.getStyledDocument().setCharacterAttributes(3, 5, set, false); + + String gotText = jep.getText(); + System.out.println("gotText: " + gotText); + // there should be color attribute set + // and 3 font tags + int i = gotText.indexOf("color"); + if (i > 0) { + i = gotText.indexOf(" 0) { + i = gotText.indexOf(" 0) { + i = gotText.indexOf(" { + bug4329185 test = new bug4329185(); + test.start(); + }); + robot.waitForIdle(); + robot.delay(1000); + boolean passed = ((views[0].getAlignment(View.Y_AXIS) == 0.0) + && (views[1].getAlignment(View.Y_AXIS) == 0.5) + && (views[2].getAlignment(View.Y_AXIS) == 1.0)); + if (!passed) { + throw new RuntimeException("Test failed."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + public void start() { + String text = "aaa"; + f = new JFrame("bug4329185"); + JEditorPane jep = new JEditorPane(); + jep.setEditorKit(new MyHTMLEditorKit()); + jep.setEditable(false); + + jep.setText(text); + + f.getContentPane().add(jep); + f.setSize(500, 500); + f.setLocationRelativeTo(null); + f.setVisible(true); + } + + + static class MyHTMLEditorKit extends HTMLEditorKit { + + private final ViewFactory defaultFactory = new MyHTMLFactory(); + + @Override + public ViewFactory getViewFactory() { + return defaultFactory; + } + + static class MyHTMLFactory extends HTMLEditorKit.HTMLFactory { + private int i = 0; + + @Override + public View create(Element elem) { + Object o = elem.getAttributes() + .getAttribute(StyleConstants.NameAttribute); + if (o instanceof HTML.Tag kind) { + if (kind == HTML.Tag.IMG) { + View v = super.create(elem); + views[i++] = v; + return v; + } + } + return super.create(elem); + } + } + } + +} diff --git a/test/jdk/javax/swing/text/html/InlineView/bug4623342.java b/test/jdk/javax/swing/text/html/InlineView/bug4623342.java new file mode 100644 index 0000000000000..4f26b79c499ec --- /dev/null +++ b/test/jdk/javax/swing/text/html/InlineView/bug4623342.java @@ -0,0 +1,110 @@ +/* + * 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 + * 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 4623342 + * @summary Tests if InlineView causes extra spacing around images in JTable + * @key headful + * @run main bug4623342 + */ + +import java.awt.Robot; +import java.awt.Shape; + +import javax.swing.JFrame; +import javax.swing.JEditorPane; +import javax.swing.SwingUtilities; +import javax.swing.text.View; +import javax.swing.text.html.HTMLEditorKit; + +public class bug4623342 { + + private static volatile boolean passed; + + private JEditorPane jep; + private static JFrame f; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(100); + try { + bug4623342 test = new bug4623342(); + SwingUtilities.invokeAndWait(test::init); + robot.waitForIdle(); + robot.delay(100); + SwingUtilities.invokeAndWait(test::start); + if (!passed) { + throw new RuntimeException("Test failed."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + public void init() { + + String text = + "" + + "" + + "
" + + "
" + + "
"; + + f = new JFrame(); + jep = new JEditorPane(); + jep.setEditorKit(new HTMLEditorKit()); + jep.setEditable(false); + + jep.setText(text); + + f.getContentPane().add(jep); + f.setSize(500, 500); + f.setLocationRelativeTo(null); + f.setVisible(true); + } + + private void start() { + Shape r = jep.getBounds(); + View v = jep.getUI().getRootView(jep); + int tableHeight = 0; + while (!(v instanceof javax.swing.text.html.ParagraphView)) { + int n = v.getViewCount(); + Shape sh = v.getChildAllocation(n - 1, r); + String viewName = v.getClass().getName(); + if (viewName.endsWith("TableView")) { + tableHeight = r.getBounds().height; + } + v = v.getView(n - 1); + if (sh != null) { + r = sh; + } + } + // tableHeight should be the sum of TD's heights (46) + passed = (tableHeight == 46); + } +} From 9f384e76973922b6aa758ed7dc4363b139b2b03f Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Sat, 7 Oct 2023 08:21:12 +0000 Subject: [PATCH 203/341] 8308047: java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java timed out and also had jcmd pipe errors Backport-of: 8c9d091f19760deece8daf3e57add85482b9f2a7 --- .../ScheduledThreadPoolExecutor/BasicCancelTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java b/test/jdk/java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java index d9da860cb7048..5ca755fc3629c 100644 --- a/test/jdk/java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java +++ b/test/jdk/java/util/concurrent/ScheduledThreadPoolExecutor/BasicCancelTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 6602600 - * @run main/othervm -Xmx8m BasicCancelTest + * @run main/othervm -Xmx64m BasicCancelTest * @summary Check effectiveness of RemoveOnCancelPolicy */ @@ -76,7 +76,7 @@ void test(String[] args) throws Throwable { // Needed to avoid OOME pool.setRemoveOnCancelPolicy(true); - final long moreThanYouCanChew = Runtime.getRuntime().freeMemory() / 4; + final long moreThanYouCanChew = Runtime.getRuntime().maxMemory() / 32; System.out.printf("moreThanYouCanChew=%d%n", moreThanYouCanChew); Runnable noopTask = new Runnable() { public void run() {}}; From adef8e467c0e2f36146627ace77f79d874c26783 Mon Sep 17 00:00:00 2001 From: Olga Mikhaltsova Date: Sun, 8 Oct 2023 13:53:23 +0000 Subject: [PATCH 204/341] 8291550: RISC-V: jdk uses misaligned memory access when AvoidUnalignedAccess enabled Reviewed-by: vkempik Backport-of: 37093441661c26f333aac00d16aea00c3341d314 --- src/hotspot/cpu/riscv/assembler_riscv.hpp | 24 +++- .../cpu/riscv/c2_MacroAssembler_riscv.cpp | 52 ++++---- .../gc/shared/barrierSetNMethod_riscv.cpp | 6 +- src/hotspot/cpu/riscv/interp_masm_riscv.cpp | 31 ++++- src/hotspot/cpu/riscv/interp_masm_riscv.hpp | 2 +- .../cpu/riscv/macroAssembler_riscv.cpp | 118 +++++++++++++++--- .../cpu/riscv/macroAssembler_riscv.hpp | 4 + src/hotspot/cpu/riscv/nativeInst_riscv.cpp | 24 ++-- src/hotspot/cpu/riscv/nativeInst_riscv.hpp | 22 ++-- src/hotspot/cpu/riscv/relocInfo_riscv.cpp | 2 +- .../templateInterpreterGenerator_riscv.cpp | 5 +- src/hotspot/cpu/riscv/templateTable_riscv.cpp | 30 +++-- 12 files changed, 234 insertions(+), 86 deletions(-) diff --git a/src/hotspot/cpu/riscv/assembler_riscv.hpp b/src/hotspot/cpu/riscv/assembler_riscv.hpp index ca7a0a8b1c2f8..c7e9569df0531 100644 --- a/src/hotspot/cpu/riscv/assembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/assembler_riscv.hpp @@ -308,6 +308,22 @@ class Assembler : public AbstractAssembler { rdy = 0b111, // in instruction's rm field, selects dynamic rounding mode.In Rounding Mode register, Invalid. }; + // handle unaligned access + static inline uint16_t ld_c_instr(address addr) { + return Bytes::get_native_u2(addr); + } + static inline void sd_c_instr(address addr, uint16_t c_instr) { + Bytes::put_native_u2(addr, c_instr); + } + + // handle unaligned access + static inline uint32_t ld_instr(address addr) { + return Bytes::get_native_u4(addr); + } + static inline void sd_instr(address addr, uint32_t instr) { + Bytes::put_native_u4(addr, instr); + } + static inline uint32_t extract(uint32_t val, unsigned msb, unsigned lsb) { assert_cond(msb >= lsb && msb <= 31); unsigned nbits = msb - lsb + 1; @@ -332,10 +348,10 @@ class Assembler : public AbstractAssembler { unsigned mask = (1U << nbits) - 1; val <<= lsb; mask <<= lsb; - unsigned target = *(unsigned *)a; + unsigned target = ld_instr(a); target &= ~mask; target |= val; - *(unsigned *)a = target; + sd_instr(a, target); } static void patch(address a, unsigned bit, unsigned val) { @@ -1877,10 +1893,10 @@ enum Nf { uint16_t mask = (1U << nbits) - 1; val <<= lsb; mask <<= lsb; - uint16_t target = *(uint16_t *)a; + uint16_t target = ld_c_instr(a); target &= ~mask; target |= val; - *(uint16_t *)a = target; + sd_c_instr(a, target); } static void c_patch(address a, unsigned bit, uint16_t val) { diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index 0c7b270d4bf1a..e5f1a1f9b31e6 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -1099,8 +1099,10 @@ void C2_MacroAssembler::arrays_equals(Register a1, Register a2, Register tmp3, // and a2 and the length in cnt1. // elem_size is the element size in bytes: either 1 or 2. // There are two implementations. For arrays >= 8 bytes, all -// comparisons (including the final one, which may overlap) are -// performed 8 bytes at a time. For strings < 8 bytes, we compare a +// comparisons (for hw supporting unaligned access: including the final one, +// which may overlap) are performed 8 bytes at a time. +// For strings < 8 bytes (and for tails of long strings when +// AvoidUnalignedAccesses is true), we compare a // halfword, then a short, and then a byte. void C2_MacroAssembler::string_equals(Register a1, Register a2, @@ -1111,10 +1113,11 @@ void C2_MacroAssembler::string_equals(Register a1, Register a2, Register tmp2 = t1; assert(elem_size == 1 || elem_size == 2, "must be 2 or 1 byte"); - assert_different_registers(a1, a2, result, cnt1, t0, t1); + assert_different_registers(a1, a2, result, cnt1, tmp1, tmp2); BLOCK_COMMENT("string_equals {"); + beqz(cnt1, SAME); mv(result, false); // Check for short strings, i.e. smaller than wordSize. @@ -1129,26 +1132,31 @@ void C2_MacroAssembler::string_equals(Register a1, Register a2, add(a2, a2, wordSize); sub(cnt1, cnt1, wordSize); bne(tmp1, tmp2, DONE); - } bgtz(cnt1, NEXT_WORD); - - // Last longword. In the case where length == 4 we compare the - // same longword twice, but that's still faster than another - // conditional branch. - // cnt1 could be 0, -1, -2, -3, -4 for chars; -4 only happens when - // length == 4. - add(tmp1, a1, cnt1); - ld(tmp1, Address(tmp1, 0)); - add(tmp2, a2, cnt1); - ld(tmp2, Address(tmp2, 0)); - bne(tmp1, tmp2, DONE); - j(SAME); + } bgez(cnt1, NEXT_WORD); + + if (!AvoidUnalignedAccesses) { + // Last longword. In the case where length == 4 we compare the + // same longword twice, but that's still faster than another + // conditional branch. + // cnt1 could be 0, -1, -2, -3, -4 for chars; -4 only happens when + // length == 4. + add(tmp1, a1, cnt1); + ld(tmp1, Address(tmp1, 0)); + add(tmp2, a2, cnt1); + ld(tmp2, Address(tmp2, 0)); + bne(tmp1, tmp2, DONE); + j(SAME); + } else { + add(tmp1, cnt1, wordSize); + beqz(tmp1, SAME); + } bind(SHORT); Label TAIL03, TAIL01; // 0-7 bytes left. - test_bit(t0, cnt1, 2); - beqz(t0, TAIL03); + test_bit(tmp1, cnt1, 2); + beqz(tmp1, TAIL03); { lwu(tmp1, Address(a1, 0)); add(a1, a1, 4); @@ -1159,8 +1167,8 @@ void C2_MacroAssembler::string_equals(Register a1, Register a2, bind(TAIL03); // 0-3 bytes left. - test_bit(t0, cnt1, 1); - beqz(t0, TAIL01); + test_bit(tmp1, cnt1, 1); + beqz(tmp1, TAIL01); { lhu(tmp1, Address(a1, 0)); add(a1, a1, 2); @@ -1172,8 +1180,8 @@ void C2_MacroAssembler::string_equals(Register a1, Register a2, bind(TAIL01); if (elem_size == 1) { // Only needed when comparing 1-byte elements // 0-1 bytes left. - test_bit(t0, cnt1, 0); - beqz(t0, SAME); + test_bit(tmp1, cnt1, 0); + beqz(tmp1, SAME); { lbu(tmp1, Address(a1, 0)); lbu(tmp2, Address(a2, 0)); diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp index 39ffbea03e8e4..43150f6699825 100644 --- a/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp @@ -84,11 +84,11 @@ static const struct CheckInsn barrierInsn[] = { // BarrierSetAssembler::nmethod_entry_barrier. The matching ignores the specific // register numbers and immediate values in the encoding. void NativeNMethodBarrier::verify() const { - intptr_t addr = (intptr_t) instruction_address(); + address addr = instruction_address(); for(unsigned int i = 0; i < sizeof(barrierInsn)/sizeof(struct CheckInsn); i++ ) { - uint32_t inst = *((uint32_t*) addr); + uint32_t inst = Assembler::ld_instr(addr); if ((inst & barrierInsn[i].mask) != barrierInsn[i].bits) { - tty->print_cr("Addr: " INTPTR_FORMAT " Code: 0x%x", addr, inst); + tty->print_cr("Addr: " INTPTR_FORMAT " Code: 0x%x", p2i(addr), inst); fatal("not an %s instruction.", barrierInsn[i].name); } addr += 4; diff --git a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp index 92c128fe93a9b..dadf1b7a4529a 100644 --- a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp +++ b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp @@ -176,8 +176,15 @@ void InterpreterMacroAssembler::check_and_handle_earlyret(Register java_thread) void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset) { assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode"); - lhu(reg, Address(xbcp, bcp_offset)); - revb_h(reg, reg); + if (AvoidUnalignedAccesses && (bcp_offset % 2)) { + lbu(t1, Address(xbcp, bcp_offset)); + lbu(reg, Address(xbcp, bcp_offset + 1)); + slli(t1, t1, 8); + add(reg, reg, t1); + } else { + lhu(reg, Address(xbcp, bcp_offset)); + revb_h_h_u(reg, reg); + } } void InterpreterMacroAssembler::get_dispatch() { @@ -190,13 +197,23 @@ void InterpreterMacroAssembler::get_dispatch() { } void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index, + Register tmp, int bcp_offset, size_t index_size) { assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); if (index_size == sizeof(u2)) { - load_unsigned_short(index, Address(xbcp, bcp_offset)); + if (AvoidUnalignedAccesses) { + assert_different_registers(index, tmp); + load_unsigned_byte(index, Address(xbcp, bcp_offset)); + load_unsigned_byte(tmp, Address(xbcp, bcp_offset + 1)); + slli(tmp, tmp, 8); + add(index, index, tmp); + } else { + load_unsigned_short(index, Address(xbcp, bcp_offset)); + } } else if (index_size == sizeof(u4)) { - lwu(index, Address(xbcp, bcp_offset)); + load_int_misaligned(index, Address(xbcp, bcp_offset), tmp, false); + // Check if the secondary index definition is still ~x, otherwise // we have to change the following assembler code to calculate the // plain index. @@ -223,7 +240,8 @@ void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, size_t index_size) { assert_different_registers(cache, index); assert_different_registers(cache, xcpool); - get_cache_index_at_bcp(index, bcp_offset, index_size); + // register "cache" is trashed in next shadd, so lets use it as a temporary register + get_cache_index_at_bcp(index, cache, bcp_offset, index_size); assert(sizeof(ConstantPoolCacheEntry) == 4 * wordSize, "adjust code below"); // Convert from field index to ConstantPoolCacheEntry // riscv already has the cache in xcpool so there is no need to @@ -260,7 +278,8 @@ void InterpreterMacroAssembler::get_cache_entry_pointer_at_bcp(Register cache, int bcp_offset, size_t index_size) { assert_different_registers(cache, tmp); - get_cache_index_at_bcp(tmp, bcp_offset, index_size); + // register "cache" is trashed in next ld, so lets use it as a temporary register + get_cache_index_at_bcp(tmp, cache, bcp_offset, index_size); assert(sizeof(ConstantPoolCacheEntry) == 4 * wordSize, "adjust code below"); // Convert from field index to ConstantPoolCacheEntry index // and from word offset to byte offset diff --git a/src/hotspot/cpu/riscv/interp_masm_riscv.hpp b/src/hotspot/cpu/riscv/interp_masm_riscv.hpp index c820291e5fe07..69c1f94635e2d 100644 --- a/src/hotspot/cpu/riscv/interp_masm_riscv.hpp +++ b/src/hotspot/cpu/riscv/interp_masm_riscv.hpp @@ -113,7 +113,7 @@ class InterpreterMacroAssembler: public MacroAssembler { void get_cache_and_index_at_bcp(Register cache, Register index, int bcp_offset, size_t index_size = sizeof(u2)); void get_cache_and_index_and_bytecode_at_bcp(Register cache, Register index, Register bytecode, int byte_no, int bcp_offset, size_t index_size = sizeof(u2)); void get_cache_entry_pointer_at_bcp(Register cache, Register tmp, int bcp_offset, size_t index_size = sizeof(u2)); - void get_cache_index_at_bcp(Register index, int bcp_offset, size_t index_size = sizeof(u2)); + void get_cache_index_at_bcp(Register index, Register tmp, int bcp_offset, size_t index_size = sizeof(u2)); void get_method_counters(Register method, Register mcs, Label& skip); // Load cpool->resolved_references(index). diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index dc3dfde30d427..58ade498dbcbe 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -1350,7 +1350,7 @@ static int patch_imm_in_li32(address branch, int32_t target) { static long get_offset_of_jal(address insn_addr) { assert_cond(insn_addr != NULL); long offset = 0; - unsigned insn = *(unsigned*)insn_addr; + unsigned insn = Assembler::ld_instr(insn_addr); long val = (long)Assembler::sextract(insn, 31, 12); offset |= ((val >> 19) & 0x1) << 20; offset |= (val & 0xff) << 12; @@ -1363,7 +1363,7 @@ static long get_offset_of_jal(address insn_addr) { static long get_offset_of_conditional_branch(address insn_addr) { long offset = 0; assert_cond(insn_addr != NULL); - unsigned insn = *(unsigned*)insn_addr; + unsigned insn = Assembler::ld_instr(insn_addr); offset = (long)Assembler::sextract(insn, 31, 31); offset = (offset << 12) | (((long)(Assembler::sextract(insn, 7, 7) & 0x1)) << 11); offset = offset | (((long)(Assembler::sextract(insn, 30, 25) & 0x3f)) << 5); @@ -1375,35 +1375,35 @@ static long get_offset_of_conditional_branch(address insn_addr) { static long get_offset_of_pc_relative(address insn_addr) { long offset = 0; assert_cond(insn_addr != NULL); - offset = ((long)(Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12))) << 12; // Auipc. - offset += ((long)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)); // Addi/Jalr/Load. + offset = ((long)(Assembler::sextract(Assembler::ld_instr(insn_addr), 31, 12))) << 12; // Auipc. + offset += ((long)Assembler::sextract(Assembler::ld_instr(insn_addr + 4), 31, 20)); // Addi/Jalr/Load. offset = (offset << 32) >> 32; return offset; } static address get_target_of_movptr(address insn_addr) { assert_cond(insn_addr != NULL); - intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 29; // Lui. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)) << 17; // Addi. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[3], 31, 20)) << 6; // Addi. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[5], 31, 20)); // Addi/Jalr/Load. + intptr_t target_address = (((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr), 31, 12)) & 0xfffff) << 29; // Lui. + target_address += ((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr + 4), 31, 20)) << 17; // Addi. + target_address += ((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr + 12), 31, 20)) << 6; // Addi. + target_address += ((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr + 20), 31, 20)); // Addi/Jalr/Load. return (address) target_address; } static address get_target_of_li64(address insn_addr) { assert_cond(insn_addr != NULL); - intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 44; // Lui. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)) << 32; // Addi. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[3], 31, 20)) << 20; // Addi. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[5], 31, 20)) << 8; // Addi. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[7], 31, 20)); // Addi. + intptr_t target_address = (((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr), 31, 12)) & 0xfffff) << 44; // Lui. + target_address += ((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr + 4), 31, 20)) << 32; // Addi. + target_address += ((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr + 12), 31, 20)) << 20; // Addi. + target_address += ((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr + 20), 31, 20)) << 8; // Addi. + target_address += ((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr + 28), 31, 20)); // Addi. return (address)target_address; } static address get_target_of_li32(address insn_addr) { assert_cond(insn_addr != NULL); - intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 12; // Lui. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)); // Addiw. + intptr_t target_address = (((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr), 31, 12)) & 0xfffff) << 12; // Lui. + target_address += ((int64_t)Assembler::sextract(Assembler::ld_instr(insn_addr + 4), 31, 20)); // Addiw. return (address)target_address; } @@ -1428,7 +1428,7 @@ int MacroAssembler::pd_patch_instruction_size(address branch, address target) { } else { #ifdef ASSERT tty->print_cr("pd_patch_instruction_size: instruction 0x%x at " INTPTR_FORMAT " could not be patched!\n", - *(unsigned*)branch, p2i(branch)); + Assembler::ld_instr(branch), p2i(branch)); Disassembler::decode(branch - 16, branch + 16); #endif ShouldNotReachHere(); @@ -1616,6 +1616,92 @@ void MacroAssembler::store_sized_value(Address dst, Register src, size_t size_in } } +// granularity is 1, 2 bytes per load +void MacroAssembler::load_int_misaligned(Register dst, Address src, Register tmp, bool is_signed, int granularity) { + if (AvoidUnalignedAccesses && (granularity != 4)) { + assert_different_registers(dst, tmp, src.base()); + switch(granularity) { + case 1: + lbu(dst, src); + lbu(tmp, Address(src.base(), src.offset() + 1)); + slli(tmp, tmp, 8); + add(dst, dst, tmp); + lbu(tmp, Address(src.base(), src.offset() + 2)); + slli(tmp, tmp, 16); + add(dst, dst, tmp); + is_signed ? lb(tmp, Address(src.base(), src.offset() + 3)) : lbu(tmp, Address(src.base(), src.offset() + 3)); + slli(tmp, tmp, 24); + add(dst, dst, tmp); + break; + case 2: + lhu(dst, src); + is_signed ? lh(tmp, Address(src.base(), src.offset() + 2)) : lhu(tmp, Address(src.base(), src.offset() + 2)); + slli(tmp, tmp, 16); + add(dst, dst, tmp); + break; + default: + ShouldNotReachHere(); + } + } else { + is_signed ? lw(dst, src) : lwu(dst, src); + } +} + +// granularity is 1, 2 or 4 bytes per load +void MacroAssembler::load_long_misaligned(Register dst, Address src, Register tmp, int granularity) { + if (AvoidUnalignedAccesses && (granularity != 8)) { + assert_different_registers(dst, tmp, src.base()); + switch(granularity){ + case 1: + lbu(dst, src); + lbu(tmp, Address(src.base(), src.offset() + 1)); + slli(tmp, tmp, 8); + add(dst, dst, tmp); + lbu(tmp, Address(src.base(), src.offset() + 2)); + slli(tmp, tmp, 16); + add(dst, dst, tmp); + lbu(tmp, Address(src.base(), src.offset() + 3)); + slli(tmp, tmp, 24); + add(dst, dst, tmp); + lbu(tmp, Address(src.base(), src.offset() + 4)); + slli(tmp, tmp, 32); + add(dst, dst, tmp); + lbu(tmp, Address(src.base(), src.offset() + 5)); + slli(tmp, tmp, 40); + add(dst, dst, tmp); + lbu(tmp, Address(src.base(), src.offset() + 6)); + slli(tmp, tmp, 48); + add(dst, dst, tmp); + lbu(tmp, Address(src.base(), src.offset() + 7)); + slli(tmp, tmp, 56); + add(dst, dst, tmp); + break; + case 2: + lhu(dst, src); + lhu(tmp, Address(src.base(), src.offset() + 2)); + slli(tmp, tmp, 16); + add(dst, dst, tmp); + lhu(tmp, Address(src.base(), src.offset() + 4)); + slli(tmp, tmp, 32); + add(dst, dst, tmp); + lhu(tmp, Address(src.base(), src.offset() + 6)); + slli(tmp, tmp, 48); + add(dst, dst, tmp); + break; + case 4: + lwu(dst, src); + lwu(tmp, Address(src.base(), src.offset() + 4)); + slli(tmp, tmp, 32); + add(dst, dst, tmp); + break; + default: + ShouldNotReachHere(); + } + } else { + ld(dst, src); + } +} + // reverse bytes in halfword in lower 16 bits and sign-extend // Rd[15:0] = Rs[7:0] Rs[15:8] (sign-extend to 64 bits) void MacroAssembler::revb_h_h(Register Rd, Register Rs, Register tmp) { diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 718469db6d9ec..1c39536e327ef 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -407,6 +407,10 @@ class MacroAssembler: public Assembler { void load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed, Register dst2 = noreg); void store_sized_value(Address dst, Register src, size_t size_in_bytes, Register src2 = noreg); + // Misaligned loads, will use the best way, according to the AvoidUnalignedAccess flag + void load_int_misaligned(Register dst, Address src, Register tmp, bool is_signed, int granularity = 1); + void load_long_misaligned(Register dst, Address src, Register tmp, int granularity = 1); + public: // Standard pseudo instructions inline void nop() { diff --git a/src/hotspot/cpu/riscv/nativeInst_riscv.cpp b/src/hotspot/cpu/riscv/nativeInst_riscv.cpp index 675ed5be18992..c1f834799a0ad 100644 --- a/src/hotspot/cpu/riscv/nativeInst_riscv.cpp +++ b/src/hotspot/cpu/riscv/nativeInst_riscv.cpp @@ -42,27 +42,27 @@ Register NativeInstruction::extract_rs1(address instr) { assert_cond(instr != NULL); - return as_Register(Assembler::extract(((unsigned*)instr)[0], 19, 15)); + return as_Register(Assembler::extract(Assembler::ld_instr(instr), 19, 15)); } Register NativeInstruction::extract_rs2(address instr) { assert_cond(instr != NULL); - return as_Register(Assembler::extract(((unsigned*)instr)[0], 24, 20)); + return as_Register(Assembler::extract(Assembler::ld_instr(instr), 24, 20)); } Register NativeInstruction::extract_rd(address instr) { assert_cond(instr != NULL); - return as_Register(Assembler::extract(((unsigned*)instr)[0], 11, 7)); + return as_Register(Assembler::extract(Assembler::ld_instr(instr), 11, 7)); } uint32_t NativeInstruction::extract_opcode(address instr) { assert_cond(instr != NULL); - return Assembler::extract(((unsigned*)instr)[0], 6, 0); + return Assembler::extract(Assembler::ld_instr(instr), 6, 0); } uint32_t NativeInstruction::extract_funct3(address instr) { assert_cond(instr != NULL); - return Assembler::extract(((unsigned*)instr)[0], 14, 12); + return Assembler::extract(Assembler::ld_instr(instr), 14, 12); } bool NativeInstruction::is_pc_relative_at(address instr) { @@ -206,7 +206,7 @@ void NativeMovConstReg::verify() { intptr_t NativeMovConstReg::data() const { address addr = MacroAssembler::target_addr_for_insn(instruction_address()); if (maybe_cpool_ref(instruction_address())) { - return *(intptr_t*)addr; + return Bytes::get_native_u8(addr); } else { return (intptr_t)addr; } @@ -215,7 +215,7 @@ intptr_t NativeMovConstReg::data() const { void NativeMovConstReg::set_data(intptr_t x) { if (maybe_cpool_ref(instruction_address())) { address addr = MacroAssembler::target_addr_for_insn(instruction_address()); - *(intptr_t*)addr = x; + Bytes::put_native_u8(addr, x); } else { // Store x into the instruction stream. MacroAssembler::pd_patch_instruction_size(instruction_address(), (address)x); @@ -231,11 +231,11 @@ void NativeMovConstReg::set_data(intptr_t x) { while (iter.next()) { if (iter.type() == relocInfo::oop_type) { oop* oop_addr = iter.oop_reloc()->oop_addr(); - *oop_addr = cast_to_oop(x); + Bytes::put_native_u8((address)oop_addr, x); break; } else if (iter.type() == relocInfo::metadata_type) { Metadata** metadata_addr = iter.metadata_reloc()->metadata_addr(); - *metadata_addr = (Metadata*)x; + Bytes::put_native_u8((address)metadata_addr, x); break; } } @@ -343,7 +343,7 @@ bool NativeInstruction::is_sigill_zombie_not_entrant() { void NativeIllegalInstruction::insert(address code_pos) { assert_cond(code_pos != NULL); - *(juint*)code_pos = 0xffffffff; // all bits ones is permanently reserved as an illegal instruction + Assembler::sd_instr(code_pos, 0xffffffff); // all bits ones is permanently reserved as an illegal instruction } bool NativeInstruction::is_stop() { @@ -379,7 +379,7 @@ void NativeJump::patch_verified_entry(address entry, address verified_entry, add Assembler::patch(pInsn, 19, 12, (offset >> 12) & 0xff); Assembler::patch(pInsn, 11, 7, 0); // zero, no link jump Assembler::patch(pInsn, 6, 0, 0b1101111); // j, (jal x0 offset) - *(unsigned int*)verified_entry = insn; + Assembler::sd_instr(verified_entry, insn); } else { // We use an illegal instruction for marking a method as // not_entrant or zombie. @@ -437,5 +437,5 @@ void NativeMembar::set_kind(uint32_t order_kind) { Assembler::patch(pInsn, 23, 20, successor); address membar = addr_at(0); - *(unsigned int*) membar = insn; + Assembler::sd_instr(membar, insn); } diff --git a/src/hotspot/cpu/riscv/nativeInst_riscv.hpp b/src/hotspot/cpu/riscv/nativeInst_riscv.hpp index 288ccc08d810c..eee60479b1d0d 100644 --- a/src/hotspot/cpu/riscv/nativeInst_riscv.hpp +++ b/src/hotspot/cpu/riscv/nativeInst_riscv.hpp @@ -80,7 +80,7 @@ class NativeInstruction { assert_cond(instr != NULL); return (extract_opcode(instr) == 0b0010011 && // opcode field extract_funct3(instr) == 0b001 && // funct3 field, select the type of operation - Assembler::extract(((unsigned*)instr)[0], 25, 20) == shift); // shamt field + Assembler::extract(Assembler::ld_instr(instr), 25, 20) == shift); // shamt field } static Register extract_rs1(address instr); @@ -203,18 +203,18 @@ class NativeInstruction { protected: address addr_at(int offset) const { return address(this) + offset; } - jint int_at(int offset) const { return *(jint*) addr_at(offset); } - juint uint_at(int offset) const { return *(juint*) addr_at(offset); } + jint int_at(int offset) const { return (jint)Bytes::get_native_u4(addr_at(offset)); } + juint uint_at(int offset) const { return Bytes::get_native_u4(addr_at(offset)); } - address ptr_at(int offset) const { return *(address*) addr_at(offset); } + address ptr_at(int offset) const { return (address)Bytes::get_native_u8(addr_at(offset)); } - oop oop_at (int offset) const { return *(oop*) addr_at(offset); } + oop oop_at (int offset) const { return cast_to_oop(Bytes::get_native_u8(addr_at(offset))); } - void set_int_at(int offset, jint i) { *(jint*)addr_at(offset) = i; } - void set_uint_at(int offset, jint i) { *(juint*)addr_at(offset) = i; } - void set_ptr_at (int offset, address ptr) { *(address*) addr_at(offset) = ptr; } - void set_oop_at (int offset, oop o) { *(oop*) addr_at(offset) = o; } + void set_int_at(int offset, jint i) { Bytes::put_native_u4(addr_at(offset), i); } + void set_uint_at(int offset, jint i) { Bytes::put_native_u4(addr_at(offset), i); } + void set_ptr_at (int offset, address ptr) { Bytes::put_native_u8(addr_at(offset), (u8)ptr); } + void set_oop_at (int offset, oop o) { Bytes::put_native_u8(addr_at(offset), cast_from_oop(o)); } public: @@ -485,7 +485,7 @@ class NativeIllegalInstruction: public NativeInstruction { }; inline bool NativeInstruction::is_nop() { - uint32_t insn = *(uint32_t*)addr_at(0); + uint32_t insn = Assembler::ld_instr(addr_at(0)); return insn == 0x13; } @@ -527,7 +527,7 @@ inline bool is_NativeCallTrampolineStub_at(address addr) { (NativeInstruction::extract_rd(addr + instr_size) == x5) && (NativeInstruction::extract_rs1(addr + instr_size) == x5) && (NativeInstruction::extract_rs1(addr + 2 * instr_size) == x5) && - (Assembler::extract(((unsigned*)addr)[1], 31, 20) == NativeCallTrampolineStub::data_offset)) { + (Assembler::extract(Assembler::ld_instr(addr + 4), 31, 20) == NativeCallTrampolineStub::data_offset)) { return true; } return false; diff --git a/src/hotspot/cpu/riscv/relocInfo_riscv.cpp b/src/hotspot/cpu/riscv/relocInfo_riscv.cpp index 228a64eae2c64..ff484c662bf22 100644 --- a/src/hotspot/cpu/riscv/relocInfo_riscv.cpp +++ b/src/hotspot/cpu/riscv/relocInfo_riscv.cpp @@ -45,7 +45,7 @@ void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) { if (NativeInstruction::is_load_pc_relative_at(addr())) { address constptr = (address)code()->oop_addr_at(reloc->oop_index()); bytes = MacroAssembler::pd_patch_instruction_size(addr(), constptr); - assert(*(address*)constptr == x, "error in oop relocation"); + assert((address)Bytes::get_native_u8(constptr) == x, "error in oop relocation"); } else { bytes = MacroAssembler::patch_oop(addr(), x); } diff --git a/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp b/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp index 95fc27f9e7105..0471a66422c77 100644 --- a/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp @@ -1060,8 +1060,9 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { Label L; __ ld(x28, Address(xmethod, Method::native_function_offset())); address unsatisfied = (SharedRuntime::native_method_throw_unsatisfied_link_error_entry()); - __ mv(t1, unsatisfied); - __ ld(t1, Address(t1, 0)); + __ mv(t, unsatisfied); + __ load_long_misaligned(t1, Address(t, 0), t0, 2); // 2 bytes aligned, but not 4 or 8 + __ bne(x28, t1, L); __ call_VM(noreg, CAST_FROM_FN_PTR(address, diff --git a/src/hotspot/cpu/riscv/templateTable_riscv.cpp b/src/hotspot/cpu/riscv/templateTable_riscv.cpp index 19b31c969e314..a35eb1ad18269 100644 --- a/src/hotspot/cpu/riscv/templateTable_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateTable_riscv.cpp @@ -288,9 +288,15 @@ void TemplateTable::bipush() void TemplateTable::sipush() { transition(vtos, itos); - __ load_unsigned_short(x10, at_bcp(1)); - __ revb_w_w(x10, x10); - __ sraiw(x10, x10, 16); + if (AvoidUnalignedAccesses) { + __ load_signed_byte(x10, at_bcp(1)); + __ load_unsigned_byte(t1, at_bcp(2)); + __ slli(x10, x10, 8); + __ add(x10, x10, t1); + } else { + __ load_unsigned_short(x10, at_bcp(1)); + __ revb_h_h(x10, x10); // reverse bytes in half-word and sign-extend + } } void TemplateTable::ldc(bool wide) @@ -378,7 +384,8 @@ void TemplateTable::fast_aldc(bool wide) // We are resolved if the resolved reference cache entry contains a // non-null object (String, MethodType, etc.) assert_different_registers(result, tmp); - __ get_cache_index_at_bcp(tmp, 1, index_size); + // register result is trashed by next load, let's use it as temporary register + __ get_cache_index_at_bcp(tmp, result, 1, index_size); __ load_resolved_reference_at_index(result, tmp); __ bnez(result, resolved); @@ -1695,8 +1702,15 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) // load branch displacement if (!is_wide) { - __ lhu(x12, at_bcp(1)); - __ revb_h_h(x12, x12); // reverse bytes in half-word and sign-extend + if (AvoidUnalignedAccesses) { + __ lb(x12, at_bcp(1)); + __ lbu(t1, at_bcp(2)); + __ slli(x12, x12, 8); + __ add(x12, x12, t1); + } else { + __ lhu(x12, at_bcp(1)); + __ revb_h_h(x12, x12); // reverse bytes in half-word and sign-extend + } } else { __ lwu(x12, at_bcp(1)); __ revb_w_w(x12, x12); // reverse bytes in word and sign-extend @@ -2099,7 +2113,7 @@ void TemplateTable::fast_binaryswitch() { // else [i = h] // Convert array[h].match to native byte-ordering before compare __ shadd(temp, h, array, temp, 3); - __ ld(temp, Address(temp, 0)); + __ lwu(temp, Address(temp, 0)); __ revb_w_w(temp, temp); // reverse bytes in word (32bit) and sign-extend Label L_done, L_greater; @@ -2122,7 +2136,7 @@ void TemplateTable::fast_binaryswitch() { Label default_case; // Convert array[i].match to native byte-ordering before compare __ shadd(temp, i, array, temp, 3); - __ ld(temp, Address(temp, 0)); + __ lwu(temp, Address(temp, 0)); __ revb_w_w(temp, temp); // reverse bytes in word (32bit) and sign-extend __ bne(key, temp, default_case); From 18fd988d19e283283493c559325a387a716d6906 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Sun, 8 Oct 2023 15:15:38 +0000 Subject: [PATCH 205/341] 8298868: Update EngineCloseOnAlert.java for changes to TLS implementation Backport-of: 7fd440d97c2bb7b7a6cd7094e7339d65d23e7815 --- test/jdk/ProblemList.txt | 2 - .../net/ssl/SSLEngine/EngineCloseOnAlert.java | 92 ++++++++++--------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index c538816b34fc5..ba2113e797e34 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -636,8 +636,6 @@ sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic- javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x64 -javax/net/ssl/SSLEngine/EngineCloseOnAlert.java 8298868 generic-all - sun/security/smartcardio/TestChannel.java 8039280 generic-all sun/security/smartcardio/TestConnect.java 8039280 generic-all sun/security/smartcardio/TestConnectAgain.java 8039280 generic-all diff --git a/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java b/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java index 1ddd9edfa5954..7a4f71d8171dc 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java +++ b/test/jdk/javax/net/ssl/SSLEngine/EngineCloseOnAlert.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2016, 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 @@ -26,8 +26,7 @@ * @bug 8133632 * @summary javax.net.ssl.SSLEngine does not properly handle received * SSL fatal alerts - * - * @run main/othervm EngineCloseOnAlert + * @run main EngineCloseOnAlert */ import java.io.FileInputStream; @@ -40,23 +39,20 @@ public class EngineCloseOnAlert { - private static final String pathToStores = "../etc"; - private static final String keyStoreFile = "keystore"; - private static final String trustStoreFile = "truststore"; + private static final String PATH_TO_STORES = "../etc"; + private static final String KEYSTORE_FILENAME = "keystore"; + private static final String TRUSTSTORE_FILENAME = "truststore"; private static final String passwd = "passphrase"; - private static final String keyFilename = - System.getProperty("test.src", ".") + "/" + pathToStores + - "/" + keyStoreFile; - private static final String trustFilename = - System.getProperty("test.src", ".") + "/" + pathToStores + - "/" + trustStoreFile; + private static final String KEYSTORE_PATH = + System.getProperty("test.src", ".") + "/" + PATH_TO_STORES + + "/" + KEYSTORE_FILENAME; + private static final String TRUSTSTORE_PATH = + System.getProperty("test.src", ".") + "/" + PATH_TO_STORES + + "/" + TRUSTSTORE_FILENAME; private static KeyManagerFactory KMF; private static TrustManagerFactory TMF; - private static TrustManagerFactory EMPTY_TMF; - private static final String[] TLS10ONLY = { "TLSv1" }; - private static final String[] TLS12ONLY = { "TLSv1.2" }; private static final String[] ONECIPHER = { "TLS_RSA_WITH_AES_128_CBC_SHA" }; @@ -91,6 +87,7 @@ public static void main(String[] args) throws Exception { } } + private static final String TLSv12 = "TLSv1.2"; private static final TestCase clientReceivesAlert = new TestCase() { @Override public void runTest() throws Exception { @@ -104,7 +101,9 @@ public void runTest() throws Exception { // match the requested ciphers offered by the client. This // will generate an alert from the server to the client. - SSLContext context = SSLContext.getDefault(); + SSLContext context = SSLContext.getInstance(TLSv12); + context.init(null, null, null); + SSLEngine client = context.createSSLEngine(); SSLEngine server = context.createSSLEngine(); client.setUseClientMode(true); @@ -136,7 +135,8 @@ public void runTest() throws Exception { serverResult = server.wrap(plain, raw); System.out.println("Server result: " + serverResult); runDelegatedTasks(serverResult, server); - } catch (SSLException e) { + throw new RuntimeException("The expected SSLHandshakeException was not thrown."); + } catch (SSLHandshakeException e) { // This is the expected code path System.out.println("Server throws exception: " + e); System.out.println("Server engine state: " + @@ -147,16 +147,13 @@ public void runTest() throws Exception { } raw.clear(); - // The above should show that isInboundDone returns true, and - // handshake status is NEED_WRAP. That is the correct behavior, - // wrap will put a fatal alert message in the buffer. serverResult = server.wrap(plain, raw); System.out.println("Server result (wrap after exception): " + serverResult); System.out.println("Server engine closure state: isInboundDone=" + server.isInboundDone() + ", isOutboundDone=" + server.isOutboundDone()); - checkEngineState(server, NEED_UNWRAP, true, true); + checkEngineState(server, NOT_HANDSHAKING, true, true); raw.flip(); System.out.println("Server-to-Client:\n-----------------\n" + @@ -167,7 +164,8 @@ public void runTest() throws Exception { clientResult = client.unwrap(raw, plain); System.out.println("Client result (unwrap alert): " + clientResult); - } catch (SSLException e) { + throw new RuntimeException("Client did not throw the expected SSLException."); + } catch (SSLHandshakeException e) { System.out.println("Client throws exception: " + e); System.out.println("Engine closure status: isInboundDone=" + client.isInboundDone() + ", isOutboundDone=" @@ -188,17 +186,16 @@ public void runTest() throws Exception { private static final TestCase serverReceivesAlert = new TestCase() { @Override public void runTest() throws Exception { - SSLContext cliContext = SSLContext.getDefault(); - SSLContext servContext = SSLContext.getInstance("TLS"); + SSLContext cliContext = SSLContext.getInstance(TLSv12); + cliContext.init(null, null, null); + SSLContext servContext = SSLContext.getInstance(TLSv12); servContext.init(KMF.getKeyManagers(), TMF.getTrustManagers(), null); SSLEngine client = cliContext.createSSLEngine(); SSLEngine server = servContext.createSSLEngine(); client.setUseClientMode(true); - client.setEnabledProtocols(TLS12ONLY); client.setEnabledCipherSuites(ONECIPHER); server.setUseClientMode(false); - server.setEnabledProtocols(TLS10ONLY); SSLEngineResult clientResult; SSLEngineResult serverResult; ByteBuffer raw = ByteBuffer.allocate(32768); @@ -232,36 +229,41 @@ public void runTest() throws Exception { System.out.println("Server-to-Client:\n-----------------\n" + dumpHexBytes(raw, 16, "\n", ":")); - // The client should parse this and throw an exception because - // It is unwiling to do TLS 1.0 + // Change the handshake type field to client_hello which will + // cause the client to generate an unexpected_message alert + raw.put(5, (byte)0x1); clientResult = client.unwrap(raw, plain); checkEngineState(client, NEED_TASK, false, false); runDelegatedTasks(clientResult, client); - checkEngineState(client, NEED_UNWRAP, false, false); + checkEngineState(client, NEED_WRAP, true, false); + raw.clear(); + // Now the client should wrap the exception try { - client.unwrap(raw, plain); - } catch (SSLException e) { - System.out.println("Client throws exception: " + e); - System.out.println("Engine closure status: isInboundDone=" - + client.isInboundDone() + ", isOutboundDone=" - + client.isOutboundDone() + ", handshake status=" - + client.getHandshakeStatus()); + client.wrap(plain, raw); + throw new RuntimeException("The expected exception was not " + + "thrown after the client processed an unexpected message."); + } catch (SSLProtocolException exc) { + // this is the expected code path + System.out.println("Client throws expected exception: " + exc); + System.out.println("Client engine state: " + + "isInboundDone = "+ client.isInboundDone() + + ", isOutboundDone = " + client.isOutboundDone() + + ", handshake status = " + client.getHandshakeStatus()); checkEngineState(client, NEED_WRAP, true, false); } raw.clear(); - - // Now the client should wrap the exception client.wrap(plain, raw); - checkEngineState(client, NEED_UNWRAP, true, true); - raw.flip(); + checkEngineState(client, NOT_HANDSHAKING, true, true); System.out.println("Client-to-Server:\n-----------------\n" + dumpHexBytes(raw, 16, "\n", ":")); + raw.flip(); try { server.unwrap(raw, plain); - checkEngineState(server, NEED_UNWRAP, false, false); - } catch (SSLException e) { + throw new RuntimeException("The server did not throw an " + + "SSLProtocolException after parsing an alert message."); + } catch (SSLProtocolException e) { System.out.println("Server throws exception: " + e); System.out.println("Engine closure status: isInboundDone=" + server.isInboundDone() + ", isOutboundDone=" @@ -338,15 +340,15 @@ private static void createManagerFactories() KeyStore empty_ts = KeyStore.getInstance("PKCS12"); char[] passphrase = passwd.toCharArray(); - keystore.load(new FileInputStream(keyFilename), passphrase); - truststore.load(new FileInputStream(trustFilename), passphrase); + keystore.load(new FileInputStream(KEYSTORE_PATH), passphrase); + truststore.load(new FileInputStream(TRUSTSTORE_PATH), passphrase); empty_ts.load(null, "".toCharArray()); KMF = KeyManagerFactory.getInstance("PKIX"); KMF.init(keystore, passphrase); TMF = TrustManagerFactory.getInstance("PKIX"); TMF.init(truststore); - EMPTY_TMF = TrustManagerFactory.getInstance("PKIX"); + TrustManagerFactory EMPTY_TMF = TrustManagerFactory.getInstance("PKIX"); EMPTY_TMF.init(truststore); } From c00d445513aca8dba4dcc1160f7e54dea09ff343 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Sun, 8 Oct 2023 15:17:24 +0000 Subject: [PATCH 206/341] 8317121: vector_masked_load instruction is moved too early after JDK-8286941 Backport-of: cfabcbf85837e97bdd6c9e4e06e875ecbaa70084 --- src/hotspot/share/opto/memnode.cpp | 9 +- .../vectorization/TestMaskedVectors.java | 118 ++++++++++++++++++ 2 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/vectorization/TestMaskedVectors.java diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp index 2ee1e5f52f766..f81e80fec0ea0 100644 --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -579,8 +579,13 @@ Node* LoadNode::find_previous_arraycopy(PhaseTransform* phase, Node* ld_alloc, N Node* dest = ac->in(ArrayCopyNode::Dest); if (dest == ld_base) { - const TypeX *ld_offs_t = phase->type(ld_offs)->isa_intptr_t(); - if (ac->modifies(ld_offs_t->_lo, ld_offs_t->_hi, phase, can_see_stored_value)) { + const TypeX* ld_offs_t = phase->type(ld_offs)->isa_intptr_t(); + assert(!ld_offs_t->empty(), "dead reference should be checked already"); + // Take into account vector or unsafe access size + jlong ld_size_in_bytes = (jlong)memory_size(); + jlong offset_hi = ld_offs_t->_hi + ld_size_in_bytes - 1; + offset_hi = MIN2(offset_hi, (jlong)(TypeX::MAX->_hi)); // Take care for overflow in 32-bit VM + if (ac->modifies(ld_offs_t->_lo, (intptr_t)offset_hi, phase, can_see_stored_value)) { return ac; } if (!can_see_stored_value) { diff --git a/test/hotspot/jtreg/compiler/vectorization/TestMaskedVectors.java b/test/hotspot/jtreg/compiler/vectorization/TestMaskedVectors.java new file mode 100644 index 0000000000000..c106a9bc69cb9 --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorization/TestMaskedVectors.java @@ -0,0 +1,118 @@ +/* + * 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 8317121 + * @summary Test masked vectors and unsafe access to memory modified by arraycopy + * @requires vm.compiler2.enabled + * @modules java.base/jdk.internal.misc + * @library /test/lib / + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation -Xbatch -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,TestMaskedVectors::test* -XX:+StressLCM -XX:+StressGCM -XX:StressSeed=2210259638 TestMaskedVectors + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation -Xbatch -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,TestMaskedVectors::test* -XX:+StressLCM -XX:+StressGCM TestMaskedVectors + */ + +import java.lang.reflect.*; +import java.util.*; + +import jdk.internal.misc.Unsafe; + +public class TestMaskedVectors { + + private static Unsafe UNSAFE = Unsafe.getUnsafe(); + private static final long BASE_OFFSET = UNSAFE.arrayBaseOffset(byte[].class); + + static void testLoadVectorMasked(byte[] src, byte[] dst, int len) { + byte[] tmp = new byte[64]; + + // (3) The LoadVectorMasked is found to be dependent on below arraycopy and + // therefore scheduled just below it. As a result, the LoadVectorMasked misses the + // updated elements at index 16..48 and dst will contain incorrect values. + System.arraycopy(src, 0, tmp, 0, 16); + + // (2) The LoadVectorMasked is incorrectly found to be independent of this arraycopy + // because the LoadVectorMasked has offset 0 whereas the arraycopy writes offset >= 16. + // The problem is that MemNode::find_previous_store() -> LoadNode::find_previous_arraycopy() + // -> ArrayCopyNode::modifies does not account for the size of the load. + System.arraycopy(src, 0, tmp, 16, 48); + + // (1) The following arraycopy is expanded into a LoadVectorMasked and a + // StoreVectorMasked in PhaseMacroExpand::generate_partial_inlining_block(). + System.arraycopy(tmp, 0, dst, 0, len); + } + + static long testUnsafeGetLong(byte[] src) { + byte[] tmp = new byte[16]; + + // (3) The unsafe load is found to be dependent on below arraycopy and + // therefore scheduled just below it. As a result, the unsafe load misses the + // updated elements at index 1..16 and therefore returns an incorrect result. + System.arraycopy(src, 0, tmp, 0, 16); + + // (2) The unsafe load is incorrectly found to be independent of this arraycopy + // because the load has offset 0 in 'tmp' whereas the arraycopy writes offsets >= 1. + // The problem is that MemNode::find_previous_store() -> LoadNode::find_previous_arraycopy() + // -> ArrayCopyNode::modifies does not account for the size of the load. + System.arraycopy(src, 0, tmp, 1, 15); + + // (1) Below unsafe load reads the first 8 (byte) array elements. + return UNSAFE.getLong(tmp, BASE_OFFSET); + } + + public static void main(String[] args) { + // Initialize src array with increasing byte values + byte[] src = new byte[64]; + for (byte i = 0; i < src.length; ++i) { + src[i] = (byte)i; + } + + // Compute expected outputs once + byte[] golden1 = new byte[64]; + testLoadVectorMasked(src, golden1, 64); + + long golden2 = testUnsafeGetLong(src); + + // Trigger compilation of test methods and verify the results + for (int i = 0; i < 50_000; ++i) { + int len = i % 32; + byte[] dst = new byte[len]; + testLoadVectorMasked(src, dst, len); + + boolean error = false; + for (int j = 0; j < dst.length; ++j) { + if (dst[j] != golden1[j]) { + System.out.println("Incorrect value of element " + j + ": Expected " + golden1[j] + " but got " + dst[j]); + error = true; + } + } + if (error) { + throw new RuntimeException("Test LoadVectorMasked failed"); + } + + long res = testUnsafeGetLong(src); + if (res != golden2) { + throw new RuntimeException("Incorrect result in test UnsafeGetLong: Expected " + golden2 + " but got " + res); + } + } + } +} From aaa6962a05a8802cee8473f414c82e6a2ff0bddf Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 9 Oct 2023 13:29:50 +0000 Subject: [PATCH 207/341] 8290909: MemoryPoolMBean/isUsageThresholdExceeded tests failed with "isUsageThresholdExceeded() returned false, and is still false, while threshold = MMMMMMM and used peak = NNNNNNN" Backport-of: 3601e30df794db122d8d04fb3c04868ccbaa0baf --- .../isexceeded001.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java index 436c42f819dd1..390bfdd625188 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isUsageThresholdExceeded/isexceeded001.java @@ -37,7 +37,7 @@ public class isexceeded001 { private static boolean testFailed = false; - private static final int INCREMENT = 100 * 1024; // 100kb + private static final int INCREMENT = 100 * 1024 * 1024 ; // 100MB public static void main(String[] argv) { System.exit(Consts.JCK_STATUS_BASE + run(argv, System.out)); } @@ -54,17 +54,20 @@ public static int run(String[] argv, PrintStream out) { for (int i = 0; i < pools.size(); i++) { Object pool = pools.get(i); - log.display(i + " pool " + monitor.getName(pool) + " of type: " + monitor.getType(pool)); - if (!monitor.isUsageThresholdSupported(pool)) { - log.display(" does not support usage thresholds: skip"); + // Skip non-heap pools, as they have unpredictable behaviour, or if + // usage threshold not supported: + if (monitor.getType(pool) != MemoryType.HEAP || !monitor.isUsageThresholdSupported(pool)) { continue; } + log.display(i + " pool " + monitor.getName(pool) + " of type: " + monitor.getType(pool)); // Set a threshold that is greater than used value MemoryUsage usage = monitor.getUsage(pool); + MemoryUsage peakUsage = monitor.getPeakUsage(pool); boolean isExceeded = monitor.isUsageThresholdExceeded(pool); long used = usage.getUsed(); long max = usage.getMax(); + long peakUsed = peakUsage.getUsed(); long threshold = used + 1; if ( (max > -1) && (threshold > max) ) { @@ -76,6 +79,7 @@ public static int run(String[] argv, PrintStream out) { monitor.setUsageThreshold(pool, threshold); log.display(" used value is " + used + " max is " + max + " isExceeded = " + isExceeded); + log.display("peak used value is " + peakUsed); log.display(" threshold set to " + threshold); log.display(" threshold count " + monitor.getUsageThresholdCount(pool)); @@ -95,24 +99,16 @@ public static int run(String[] argv, PrintStream out) { // Fetch usage information: use peak usage in comparisons below, in case usage went up and then down. // Log used and peak used in case of failure. usage = monitor.getUsage(pool); - MemoryUsage peakUsage = monitor.getPeakUsage(pool); + peakUsage = monitor.getPeakUsage(pool); used = usage.getUsed(); max = usage.getMax(); - long peakUsed = usage.getUsed(); - long peakMax = usage.getMax(); + peakUsed = peakUsage.getUsed(); log.display(" used value is " + used + " max is " + max + " isExceeded = " + isExceeded); - log.display("peak used value is " + peakUsed + " peak max is " + peakMax); - log.display(" threshold set to " + threshold); + log.display("peak used value is " + peakUsed); long thresholdCount = monitor.getUsageThresholdCount(pool); log.display(" threshold count " + thresholdCount); - // Test can be imprecise, particularly with CodeHeap: usage changes outside our control. - if (thresholdCount > 0 && monitor.getType(pool) != MemoryType.HEAP) { - log.display(" thresholdCount increasing outside our control for non-heap Pool: skip"); - continue; - } - // If peak used value is less than threshold, then isUsageThresholdExceeded() // is expected to return false. if (peakUsed < threshold && isExceeded) { From 6a0dfaf59e553e331785a1f98d2093ce94a5bae3 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 9 Oct 2023 13:32:03 +0000 Subject: [PATCH 208/341] 8308223: failure handler missed jcmd.vm.info command Backport-of: 563152f32dd2c8617c0e0955d55c5bbce23627fb --- test/failure_handler/src/share/conf/common.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/failure_handler/src/share/conf/common.properties b/test/failure_handler/src/share/conf/common.properties index c53b122d07838..f02fbb2daae24 100644 --- a/test/failure_handler/src/share/conf/common.properties +++ b/test/failure_handler/src/share/conf/common.properties @@ -33,7 +33,7 @@ onTimeout=\ jcmd.compiler.queue \ jcmd.vm.classloader_stats jcmd.vm.stringtable \ jcmd.vm.symboltable jcmd.vm.uptime jcmd.vm.dynlibs \ - jcmd.vm.system_properties \ + jcmd.vm.system_properties jcmd.vm.info \ jcmd.gc.heap_info jcmd.gc.class_histogram jcmd.gc.finalizer_info \ jstack From 3f29f1e5678955645dd2ec7afcd419b5dba1e6c0 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 9 Oct 2023 13:34:11 +0000 Subject: [PATCH 209/341] 8311585: Add JRadioButtonMenuItem to bug8031573.java Backport-of: 4f90abaf17716493bad740dcef76d49f16d69379 --- .../swing/JMenuItem/8031573/bug8031573.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.java b/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.java index 4d3f1cd61139e..567989e0341a4 100644 --- a/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.java +++ b/test/jdk/javax/swing/JMenuItem/8031573/bug8031573.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 @@ -32,18 +32,18 @@ import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import javax.swing.JPanel; +import javax.swing.JRadioButtonMenuItem; import javax.swing.JTextArea; -import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.text.JTextComponent; /* @test - * @bug 8031573 8040279 8143064 - * @summary [macosx] Checkmarks of JCheckBoxMenuItems aren't rendered + * @bug 8031573 8040279 8143064 8294427 + * @summary Checkmarks of JCheckBoxMenuItems aren't rendered * in high resolution on Retina + * @requires (os.family != "linux") * @run main/manual bug8031573 */ @@ -54,14 +54,21 @@ public class bug8031573 { private static final CountDownLatch latch = new CountDownLatch(1); public static final String INSTRUCTIONS = "INSTRUCTIONS:\n\n" - + "Verify that high resolution system icons are used for JCheckBoxMenuItem on HiDPI displays.\n" - + "If the display does not support HiDPI mode press PASS.\n" - + "1. Run the test on HiDPI Display.\n" - + "2. Open the Menu.\n" - + "3. Check that the icon on the JCheckBoxMenuItem is smooth.\n" - + " If so, press PASS, else press FAIL.\n"; + + "Verify that the check and radio-check icons are rendered smoothly\n" + + "for both JCheckBoxMenuItem and JRadioButtonMenuItem.\n" + + "1. Open the Menu.\n" + + "2. Check that the icon on the JCheckBoxMenuItem is smooth.\n" + + "3. Check that the icon on the JRadioButtonMenuItem is smooth.\n" + + "4. If you're on Windows:\n" + + " Test the markers are still crisp after changing the scale in Windows settings.\n" + + " This could be done on same monitor by changing its scale or\n" + + " by moving the window to a secondary monitor with a different scale.\n" + + " Then go to step 6.\n" + + "5. If you're on Mac OS:\n" + + " If you tested on a Retina display, go to step 6.\n" + + "6. If both icons render smoothly, press PASS, otherwise press FAIL.\n"; - public static void main(String args[]) throws Exception { + public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); try { SwingUtilities.invokeAndWait(() -> createTestGUI()); @@ -88,6 +95,9 @@ private static void createTestGUI() { JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem("JCheckBoxMenuItem"); checkBoxMenuItem.setSelected(true); menu.add(checkBoxMenuItem); + JRadioButtonMenuItem radioButtonMenuItem = new JRadioButtonMenuItem("JRadioButtonMenuItem"); + radioButtonMenuItem.setSelected(true); + menu.add(radioButtonMenuItem); bar.add(menu); frame.setJMenuBar(bar); From 4c28f502c0b1467990a4cb334db333a124dd9148 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 9 Oct 2023 14:30:06 +0000 Subject: [PATCH 210/341] 8317700: [17u] Undo backport 8317674 of 8316566 which was pushed to wrong repo. Reviewed-by: rehn, fyang --- src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp b/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp index a7dc84770f84c..2b500376f9b48 100644 --- a/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp +++ b/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp @@ -37,7 +37,7 @@ inline void OrderAccess::storestore() { release(); } inline void OrderAccess::loadstore() { acquire(); } inline void OrderAccess::storeload() { fence(); } -#define FULL_MEM_BARRIER __atomic_thread_fence(__ATOMIC_SEQ_CST); +#define FULL_MEM_BARRIER __sync_synchronize() #define READ_MEM_BARRIER __atomic_thread_fence(__ATOMIC_ACQUIRE); #define WRITE_MEM_BARRIER __atomic_thread_fence(__ATOMIC_RELEASE); From 056ba2d7d90749d70925e2e1c7d6daa66c6992c5 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Mon, 9 Oct 2023 14:42:14 +0000 Subject: [PATCH 211/341] 8316566: RISC-V: Zero extended narrow oop passed to Atomic::cmpxchg Reviewed-by: goetz Backport-of: 9ffec67a3f2dada329a9887338c570424a79e7f8 --- src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp b/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp index 2b500376f9b48..a7dc84770f84c 100644 --- a/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp +++ b/src/hotspot/os_cpu/linux_riscv/orderAccess_linux_riscv.hpp @@ -37,7 +37,7 @@ inline void OrderAccess::storestore() { release(); } inline void OrderAccess::loadstore() { acquire(); } inline void OrderAccess::storeload() { fence(); } -#define FULL_MEM_BARRIER __sync_synchronize() +#define FULL_MEM_BARRIER __atomic_thread_fence(__ATOMIC_SEQ_CST); #define READ_MEM_BARRIER __atomic_thread_fence(__ATOMIC_ACQUIRE); #define WRITE_MEM_BARRIER __atomic_thread_fence(__ATOMIC_RELEASE); From d7e22e820e2d3e68cac114d302a64a09666515a2 Mon Sep 17 00:00:00 2001 From: Soumadipta Roy Date: Mon, 9 Oct 2023 18:51:13 +0000 Subject: [PATCH 212/341] 8315683: Parallelize java/util/concurrent/tck/JSR166TestCase.java Reviewed-by: phh Backport-of: 4415261688dc258b6d254668bcf8818c61cc65ea --- .../util/concurrent/tck/JSR166TestCase.java | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java index 95a03dae22181..811e32a84c851 100644 --- a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java +++ b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java @@ -35,33 +35,54 @@ */ /* - * @test - * @summary JSR-166 tck tests, in a number of variations. - * The first is the conformance testing variant, - * while others also test implementation details. + * @test id=default + * @summary Conformance testing variant of JSR-166 tck tests. + * @build * + * @modules java.management + * @run junit/othervm/timeout=1000 JSR166TestCase + */ + +/* + * @test id=security-manager + * @summary Conformance testing variant of JSR-166 tck tests + * with java security manager set to allow. * @build * * @modules java.management * @run junit/othervm/timeout=1000 -Djava.security.manager=allow JSR166TestCase + */ + +/* + * @test id=forkjoinpool-common-parallelism + * @summary Test implementation details variant of JSR-166 + * tck tests with ForkJoinPool common parallelism. + * @build * + * @modules java.management * @run junit/othervm/timeout=1000 * --add-opens java.base/java.util.concurrent=ALL-UNNAMED * --add-opens java.base/java.lang=ALL-UNNAMED - * -Djava.security.manager=allow * -Djsr166.testImplementationDetails=true + * -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 * JSR166TestCase * @run junit/othervm/timeout=1000 * --add-opens java.base/java.util.concurrent=ALL-UNNAMED * --add-opens java.base/java.lang=ALL-UNNAMED - * -Djava.security.manager=allow * -Djsr166.testImplementationDetails=true - * -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 + * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 + * -Djava.util.secureRandomSeed=true * JSR166TestCase + */ + +/* + * @test id=others + * @summary Remaining test implementation details variant of + * JSR-166 tck tests apart from ForkJoinPool common + * parallelism. + * @build * + * @modules java.management * @run junit/othervm/timeout=1000 * --add-opens java.base/java.util.concurrent=ALL-UNNAMED * --add-opens java.base/java.lang=ALL-UNNAMED - * -Djava.security.manager=allow * -Djsr166.testImplementationDetails=true - * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 - * -Djava.util.secureRandomSeed=true * JSR166TestCase * @run junit/othervm/timeout=1000/policy=tck.policy * --add-opens java.base/java.util.concurrent=ALL-UNNAMED From a393f2581740f854518a3ef7caccd6d3c2d8e4a0 Mon Sep 17 00:00:00 2001 From: Mat Carter Date: Mon, 9 Oct 2023 23:48:59 +0000 Subject: [PATCH 213/341] 8303607: SunMSCAPI provider leaks memory and keys Backport-of: c51d40cfebe793b2e979db0f2d91ac3b136311bb --- .../windows/native/libsunmscapi/security.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp b/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp index 6c53dabce17b0..7d8b13470fe96 100644 --- a/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp +++ b/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp @@ -523,7 +523,11 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_loadKeysOrCertificateC else { if (bCallerFreeProv == TRUE) { - ::CryptReleaseContext(hCryptProv, NULL); // deprecated + if ((dwKeySpec & CERT_NCRYPT_KEY_SPEC) == CERT_NCRYPT_KEY_SPEC) { + NCryptFreeObject(hCryptProv); + } else { + ::CryptReleaseContext(hCryptProv, NULL); // deprecated + } bCallerFreeProv = FALSE; } From 66baa030fe1fc5f967744934ce40627ed5bbe8c8 Mon Sep 17 00:00:00 2001 From: Jenny Shivayogi Date: Tue, 10 Oct 2023 06:44:41 +0000 Subject: [PATCH 214/341] 8272998: ImageIO.read() throws incorrect exception type Backport-of: 6ad6b1c454cbc41de5a401aecda910d668c71e39 --- .../share/classes/javax/imageio/ImageIO.java | 2 + .../jdk/javax/imageio/ReadImageNoIAETest.java | 156 ++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 test/jdk/javax/imageio/ReadImageNoIAETest.java diff --git a/src/java.desktop/share/classes/javax/imageio/ImageIO.java b/src/java.desktop/share/classes/javax/imageio/ImageIO.java index 04793b6f46498..5ac7c293e798c 100644 --- a/src/java.desktop/share/classes/javax/imageio/ImageIO.java +++ b/src/java.desktop/share/classes/javax/imageio/ImageIO.java @@ -1468,6 +1468,8 @@ public static BufferedImage read(ImageInputStream stream) BufferedImage bi; try { bi = reader.read(0, param); + } catch (RuntimeException e) { + throw new IIOException(e.toString(), e); } finally { reader.dispose(); stream.close(); diff --git a/test/jdk/javax/imageio/ReadImageNoIAETest.java b/test/jdk/javax/imageio/ReadImageNoIAETest.java new file mode 100644 index 0000000000000..ffdcc8c57748e --- /dev/null +++ b/test/jdk/javax/imageio/ReadImageNoIAETest.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * 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 8272998 + * @summary ImageIO.read() should only throw IOException from decoding + */ + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import javax.imageio.ImageIO; + +public class ReadImageNoIAETest { + + static final byte[] data = { + (byte)0xff, (byte)0xd8, (byte)0xff, (byte)0xe0, (byte)0x00, (byte)0x10, + (byte)0x4a, (byte)0x46, (byte)0x49, (byte)0x46, (byte)0x00, (byte)0x01, + (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x01, + (byte)0x00, (byte)0x00, (byte)0xff, (byte)0xdb, (byte)0x00, (byte)0x43, + (byte)0x00, (byte)0x08, (byte)0x06, (byte)0x06, (byte)0x07, (byte)0x06, + (byte)0x05, (byte)0x08, (byte)0x07, (byte)0x07, (byte)0x07, (byte)0x09, + (byte)0x09, (byte)0x08, (byte)0x0a, (byte)0x0c, (byte)0x14, (byte)0x0d, + (byte)0x0c, (byte)0x0b, (byte)0x0b, (byte)0x0c, (byte)0x19, (byte)0x12, + (byte)0x13, (byte)0x0f, (byte)0x14, (byte)0x1d, (byte)0x1a, (byte)0x1f, + (byte)0x1e, (byte)0x1d, (byte)0x1a, (byte)0x1c, (byte)0x1c, (byte)0x20, + (byte)0x24, (byte)0x2e, (byte)0x27, (byte)0x20, (byte)0x22, (byte)0x2c, + (byte)0x23, (byte)0x1c, (byte)0x1c, (byte)0x28, (byte)0x37, (byte)0x29, + (byte)0x2c, (byte)0x30, (byte)0x31, (byte)0x34, (byte)0x34, (byte)0x34, + (byte)0x1f, (byte)0x27, (byte)0x39, (byte)0x3d, (byte)0x38, (byte)0x32, + (byte)0x3c, (byte)0x2e, (byte)0x33, (byte)0x34, (byte)0x32, (byte)0xff, + (byte)0xdb, (byte)0x00, (byte)0x43, (byte)0x01, (byte)0x09, (byte)0x09, + (byte)0x09, (byte)0x0c, (byte)0x0b, (byte)0x0c, (byte)0x18, (byte)0x0d, + (byte)0x0d, (byte)0x18, (byte)0x32, (byte)0x21, (byte)0x1c, (byte)0x21, + (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, + (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, + (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, + (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, + (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, + (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, + (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, + (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, (byte)0x32, + (byte)0x32, (byte)0x32, (byte)0xff, (byte)0xc0, (byte)0x00, (byte)0x11, + (byte)0x08, (byte)0xc0, (byte)0x05, (byte)0x6d, (byte)0x05, (byte)0x03, + (byte)0x01, (byte)0x22, (byte)0x00, (byte)0x02, (byte)0x11, (byte)0x01, + (byte)0x03, (byte)0x11, (byte)0x01, (byte)0xff, (byte)0xc4, (byte)0x00, + (byte)0x1f, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x05, (byte)0x01, + (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, + (byte)0x06, (byte)0x07, (byte)0x08, (byte)0x09, (byte)0x0a, (byte)0x0b, + (byte)0xff, (byte)0xc4, (byte)0x00, (byte)0xb5, (byte)0x10, (byte)0x00, + (byte)0x02, (byte)0x01, (byte)0x03, (byte)0x03, (byte)0x02, (byte)0x04, + (byte)0x03, (byte)0x05, (byte)0x05, (byte)0x04, (byte)0x04, (byte)0x00, + (byte)0x00, (byte)0x01, (byte)0x7d, (byte)0x01, (byte)0x02, (byte)0x03, + (byte)0x00, (byte)0x04, (byte)0x11, (byte)0x05, (byte)0x12, (byte)0x21, + (byte)0x31, (byte)0x41, (byte)0x06, (byte)0x13, (byte)0x51, (byte)0x61, + (byte)0x07, (byte)0x22, (byte)0x71, (byte)0x14, (byte)0x32, (byte)0x81, + (byte)0x91, (byte)0xa1, (byte)0x08, (byte)0x23, (byte)0x42, (byte)0xb1, + (byte)0xc1, (byte)0x15, (byte)0x52, (byte)0xd1, (byte)0xf0, (byte)0x24, + (byte)0x33, (byte)0x62, (byte)0x72, (byte)0x82, (byte)0x09, (byte)0x0a, + (byte)0x16, (byte)0x17, (byte)0x18, (byte)0x19, (byte)0x1a, (byte)0x25, + (byte)0x26, (byte)0x27, (byte)0x28, (byte)0x29, (byte)0x2a, (byte)0x34, + (byte)0x35, (byte)0x36, (byte)0x37, (byte)0x38, (byte)0x39, (byte)0x3a, + (byte)0x43, (byte)0x44, (byte)0x45, (byte)0x46, (byte)0x47, (byte)0x48, + (byte)0x49, (byte)0x4a, (byte)0x53, (byte)0x54, (byte)0x55, (byte)0x56, + (byte)0x57, (byte)0x58, (byte)0x59, (byte)0x5a, (byte)0x63, (byte)0x64, + (byte)0x65, (byte)0x66, (byte)0x67, (byte)0x68, (byte)0x69, (byte)0x6a, + (byte)0x73, (byte)0x74, (byte)0x75, (byte)0x76, (byte)0x77, (byte)0x78, + (byte)0x79, (byte)0x7a, (byte)0x83, (byte)0x84, (byte)0x85, (byte)0x86, + (byte)0x87, (byte)0x88, (byte)0x89, (byte)0x8a, (byte)0x92, (byte)0x93, + (byte)0x94, (byte)0x95, (byte)0x96, (byte)0x97, (byte)0x98, (byte)0x99, + (byte)0x9a, (byte)0xa2, (byte)0xa3, (byte)0xa4, (byte)0xa5, (byte)0xa6, + (byte)0xa7, (byte)0xa8, (byte)0xa9, (byte)0xaa, (byte)0xb2, (byte)0xb3, + (byte)0xb4, (byte)0xb5, (byte)0xb6, (byte)0xb7, (byte)0xb8, (byte)0xb9, + (byte)0xba, (byte)0xc2, (byte)0xc3, (byte)0xc4, (byte)0xc5, (byte)0xc6, + (byte)0xc7, (byte)0xc8, (byte)0xc9, (byte)0xca, (byte)0xd2, (byte)0xd3, + (byte)0xd4, (byte)0xd5, (byte)0xd6, (byte)0xd7, (byte)0xd8, (byte)0xd9, + (byte)0xda, (byte)0xe1, (byte)0xe2, (byte)0xe3, (byte)0xe4, (byte)0xe5, + (byte)0xe6, (byte)0xe7, (byte)0xe8, (byte)0xe9, (byte)0xea, (byte)0xf1, + (byte)0xf2, (byte)0xf3, (byte)0xf4, (byte)0xf5, (byte)0xf6, (byte)0xf7, + (byte)0xf8, (byte)0xf9, (byte)0xfa, (byte)0xff, (byte)0xc4, (byte)0x00, + (byte)0x1f, (byte)0x01, (byte)0x00, (byte)0x03, (byte)0x01, (byte)0x01, + (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x01, + (byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, + (byte)0x06, (byte)0x07, (byte)0x08, (byte)0x09, (byte)0x0a, (byte)0x0b, + (byte)0xff, (byte)0xc4, (byte)0x00, (byte)0xb5, (byte)0x11, (byte)0x00, + (byte)0x02, (byte)0x01, (byte)0x02, (byte)0x04, (byte)0x04, (byte)0x03, + (byte)0x04, (byte)0x07, (byte)0x05, (byte)0x04, (byte)0x04, (byte)0x00, + (byte)0x01, (byte)0x02, (byte)0x77, (byte)0x00, (byte)0x01, (byte)0x02, + (byte)0x03, (byte)0x11, (byte)0x04, (byte)0x05, (byte)0x21, (byte)0x31, + (byte)0x06, (byte)0x12, (byte)0x41, (byte)0x51, (byte)0x07, (byte)0x61, + (byte)0x71, (byte)0x13, (byte)0x22, (byte)0x32, (byte)0x81, (byte)0x08, + (byte)0x14, (byte)0x42, (byte)0x91, (byte)0xa1, (byte)0xb1, (byte)0xc1, + (byte)0x09, (byte)0x23, (byte)0x33, (byte)0x52, (byte)0xf0, (byte)0x15, + (byte)0x62, (byte)0x72, (byte)0xd1, (byte)0x0a, (byte)0x16, (byte)0x24, + (byte)0x34, (byte)0xe1, (byte)0x25, (byte)0xf1, (byte)0x17, (byte)0x18, + (byte)0x19, (byte)0x1a, (byte)0x26, (byte)0x27, (byte)0x28, (byte)0x29, + (byte)0x2a, (byte)0x35, (byte)0x36, (byte)0x37, (byte)0x38, (byte)0x39, + (byte)0x3a, (byte)0x43, (byte)0x44, (byte)0x45, (byte)0x46, (byte)0x47, + (byte)0x48, (byte)0x49, (byte)0x4a, (byte)0x53, (byte)0x54, (byte)0x55, + (byte)0x56, (byte)0x57, (byte)0x58, (byte)0x59, (byte)0x5a, (byte)0x63, + (byte)0x64, (byte)0x65, (byte)0x66, (byte)0x67, (byte)0x68, (byte)0x69, + (byte)0x6a, (byte)0x73, (byte)0x74, (byte)0x75, (byte)0x76, (byte)0x77, + (byte)0x78, (byte)0x79, (byte)0x7a, (byte)0x82, (byte)0x83, (byte)0x84, + (byte)0x85, (byte)0x86, (byte)0x87, (byte)0x88, (byte)0x89, (byte)0x8a, + (byte)0x92, (byte)0x93, (byte)0x94, (byte)0x95, (byte)0x96, (byte)0x97, + (byte)0x98, (byte)0x99, (byte)0x9a, (byte)0xa2, (byte)0xa3, (byte)0xa4, + (byte)0xa5, (byte)0xa6, (byte)0xa7, (byte)0xa8, (byte)0xa9, (byte)0xaa, + (byte)0xb2, (byte)0xb3, (byte)0xb4, (byte)0xb5, (byte)0xb6, (byte)0xb7, + (byte)0xb8, (byte)0xb9, (byte)0xba, (byte)0xc2, (byte)0xc3, (byte)0xc4, + (byte)0xc5, (byte)0xc6, (byte)0xc7, (byte)0xc8, (byte)0xc9, (byte)0xca, + (byte)0xd2, (byte)0xd3, (byte)0xd4, (byte)0xd5, (byte)0xd6, (byte)0xd7, + (byte)0xd8, (byte)0xd9, (byte)0xda, (byte)0xe2, (byte)0xe3, (byte)0xe4, + (byte)0xe5, (byte)0xe6, (byte)0xe7, (byte)0xe8, (byte)0xe9, (byte)0xea, + (byte)0xf2, (byte)0xf3, (byte)0xf4, (byte)0xf5, (byte)0xf6, (byte)0xf7, + (byte)0xf8, (byte)0xf9, (byte)0xfa, (byte)0xff, (byte)0xda, (byte)0x00, + (byte)0x0c, (byte)0x03, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x11, + (byte)0x03, (byte)0x11, (byte)0x00, (byte)0x3f, (byte)0x00, (byte)0xe2, + (byte)0xe8, (byte)0xa2, (byte)0x8a, (byte)0xf9, (byte)0x93, (byte)0xf7, + (byte)0x13, (byte)0xff, (byte)0xd9 + }; + + public static void main(String[] arg) { + boolean io_exception = false; + try { + ImageIO.read(new ByteArrayInputStream(data)); + } catch (IOException e) { + io_exception = true; + } + if (!io_exception) { + throw new RuntimeException("No expected IOException"); + } + } +} From e71a98066992657ffbed58b07e84e632e496878b Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 10 Oct 2023 18:20:03 +0000 Subject: [PATCH 215/341] 8266593: vmTestbase/nsk/jvmti/PopFrame/popframe011 fails with "assert(java_thread == _state->get_thread()) failed: Must be" Backport-of: 32839ba012f0a0a66e249cd8d12b94499d82ec0a --- src/hotspot/share/prims/jvmtiEnvBase.cpp | 27 ++++++++++++++---------- test/hotspot/jtreg/ProblemList.txt | 1 - 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index 4160c2c876502..533594528c39a 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -1397,6 +1397,9 @@ SetForceEarlyReturn::doit(Thread *target, bool self) { Thread* current_thread = Thread::current(); HandleMark hm(current_thread); + if (java_thread->is_exiting()) { + return; /* JVMTI_ERROR_THREAD_NOT_ALIVE (default) */ + } if (!self) { if (!java_thread->is_suspended()) { _result = JVMTI_ERROR_THREAD_NOT_SUSPENDED; @@ -1527,6 +1530,10 @@ UpdateForPopTopFrameClosure::doit(Thread *target, bool self) { Thread* current_thread = Thread::current(); HandleMark hm(current_thread); JavaThread* java_thread = target->as_Java_thread(); + + if (java_thread->is_exiting()) { + return; /* JVMTI_ERROR_THREAD_NOT_ALIVE (default) */ + } assert(java_thread == _state->get_thread(), "Must be"); if (!self && !java_thread->is_suspended()) { @@ -1603,14 +1610,12 @@ UpdateForPopTopFrameClosure::doit(Thread *target, bool self) { // It's fine to update the thread state here because no JVMTI events // shall be posted for this PopFrame. - if (!java_thread->is_exiting() && java_thread->threadObj() != NULL) { - _state->update_for_pop_top_frame(); - java_thread->set_popframe_condition(JavaThread::popframe_pending_bit); - // Set pending step flag for this popframe and it is cleared when next - // step event is posted. - _state->set_pending_step_for_popframe(); - _result = JVMTI_ERROR_NONE; - } + _state->update_for_pop_top_frame(); + java_thread->set_popframe_condition(JavaThread::popframe_pending_bit); + // Set pending step flag for this popframe and it is cleared when next + // step event is posted. + _state->set_pending_step_for_popframe(); + _result = JVMTI_ERROR_NONE; } void @@ -1618,6 +1623,9 @@ SetFramePopClosure::doit(Thread *target, bool self) { ResourceMark rm; JavaThread* java_thread = target->as_Java_thread(); + if (java_thread->is_exiting()) { + return; /* JVMTI_ERROR_THREAD_NOT_ALIVE (default) */ + } assert(_state->get_thread() == java_thread, "Must be"); if (!self && !java_thread->is_suspended()) { @@ -1637,9 +1645,6 @@ SetFramePopClosure::doit(Thread *target, bool self) { } assert(vf->frame_pointer() != NULL, "frame pointer mustn't be NULL"); - if (java_thread->is_exiting() || java_thread->threadObj() == NULL) { - return; /* JVMTI_ERROR_THREAD_NOT_ALIVE (default) */ - } int frame_number = _state->count_frames() - _depth; _state->env_thread_state((JvmtiEnvBase*)_env)->set_frame_pop(frame_number); _result = JVMTI_ERROR_NONE; diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index d3b3d81d6571c..9038d3348e57e 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -152,7 +152,6 @@ vmTestbase/nsk/jvmti/AttachOnDemand/attach045/TestDescription.java 8202971 gener vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/TestDescription.java 8219652 aix-ppc64 vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/TestDescription.java 8219652 aix-ppc64 vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/TestDescription.java 8219652 aix-ppc64 -vmTestbase/nsk/jvmti/PopFrame/popframe011/TestDescription.java 8266593 generic-all vmTestbase/gc/lock/jni/jnilock002/TestDescription.java 8192647 generic-all From 943ee59cf7f99b91c076d025b45a75222819267a Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 10 Oct 2023 18:22:17 +0000 Subject: [PATCH 216/341] 8287671: Adjust ForceGC to invoke System::gc fewer times for negative case 8287867: Bad merge of jdk/test/lib/util/ForceGC.java causing test compilation error Backport-of: 2e332c276052554540da0998316a5a99bc350cd6 --- test/lib/jdk/test/lib/util/ForceGC.java | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/test/lib/jdk/test/lib/util/ForceGC.java b/test/lib/jdk/test/lib/util/ForceGC.java index 888869dc53a3c..1a71dd229d11f 100644 --- a/test/lib/jdk/test/lib/util/ForceGC.java +++ b/test/lib/jdk/test/lib/util/ForceGC.java @@ -32,21 +32,24 @@ * Utility class to invoke System.gc() */ public class ForceGC { - private final CountDownLatch cleanerInvoked = new CountDownLatch(1); - private final Cleaner cleaner = Cleaner.create(); + private final static Cleaner cleaner = Cleaner.create(); + + private final CountDownLatch cleanerInvoked; private Object o; + private int gcCount = 0; public ForceGC() { this.o = new Object(); - cleaner.register(o, () -> cleanerInvoked.countDown()); + this.cleanerInvoked = new CountDownLatch(1); + cleaner.register(o, cleanerInvoked::countDown); } private void doit(int iter) { try { for (int i = 0; i < 10; i++) { System.gc(); - System.out.println("doit() iter: " + iter + ", gc " + i); - if (cleanerInvoked.await(1L, TimeUnit.SECONDS)) { + gcCount++; + if (cleanerInvoked.await(100L, TimeUnit.MILLISECONDS)) { return; } } @@ -68,12 +71,20 @@ public boolean await(BooleanSupplier s) { o = null; // Keep reference to Object until now, to ensure the Cleaner // doesn't count down the latch before await() is called. for (int i = 0; i < 10; i++) { - if (s.getAsBoolean()) return true; + if (s.getAsBoolean()) { + System.out.println("ForceGC condition met after System.gc() " + gcCount + " times"); + return true; + } + doit(i); - try { Thread.sleep(1000); } catch (InterruptedException e) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { throw new AssertionError("unexpected interrupted sleep", e); } } + + System.out.println("ForceGC condition not met after System.gc() " + gcCount + " times"); return false; } } From 8e4f66a6187bca6812e6505b0704a5dcf6a5feeb Mon Sep 17 00:00:00 2001 From: Olga Mikhaltsova Date: Tue, 10 Oct 2023 19:53:39 +0000 Subject: [PATCH 217/341] 8309502: RISC-V: String.indexOf intrinsic may produce misaligned memory loads Reviewed-by: vkempik Backport-of: 6b942893868fa1a64977288bdbdb1bbff8bd9d9c --- .../cpu/riscv/c2_MacroAssembler_riscv.cpp | 59 +++++++++++++++---- .../cpu/riscv/macroAssembler_riscv.cpp | 34 +++++++++-- .../cpu/riscv/macroAssembler_riscv.hpp | 1 + 3 files changed, 78 insertions(+), 16 deletions(-) diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index e5f1a1f9b31e6..50bb9506a8266 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -489,7 +489,9 @@ void C2_MacroAssembler::string_indexof(Register haystack, Register needle, } bne(tmp3, skipch, BMSKIP); // if not equal, skipch is bad char add(result, haystack, isLL ? nlen_tmp : ch2); - ld(ch2, Address(result)); // load 8 bytes from source string + // load 8 bytes from source string + // if isLL is false then read granularity can be 2 + load_long_misaligned(ch2, Address(result), ch1, isLL ? 1 : 2); // can use ch1 as temp register here as it will be trashed by next mv anyway mv(ch1, tmp6); if (isLL) { j(BMLOOPSTR1_AFTER_LOAD); @@ -672,10 +674,30 @@ void C2_MacroAssembler::string_indexof_linearscan(Register haystack, Register ne slli(tmp3, result_tmp, haystack_chr_shift); // result as tmp add(haystack, haystack, tmp3); neg(hlen_neg, tmp3); + if (AvoidUnalignedAccesses) { + // preload first value, then we will read by 1 character per loop, instead of four + // just shifting previous ch2 right by size of character in bits + add(tmp3, haystack, hlen_neg); + (this->*load_4chr)(ch2, Address(tmp3), noreg); + if (isLL) { + // need to erase 1 most significant byte in 32-bit value of ch2 + slli(ch2, ch2, 40); + srli(ch2, ch2, 32); + } else { + slli(ch2, ch2, 16); // 2 most significant bytes will be erased by this operation + } + } bind(CH1_LOOP); - add(ch2, haystack, hlen_neg); - (this->*load_4chr)(ch2, Address(ch2), noreg); + add(tmp3, haystack, hlen_neg); + if (AvoidUnalignedAccesses) { + srli(ch2, ch2, isLL ? 8 : 16); + (this->*haystack_load_1chr)(tmp3, Address(tmp3, isLL ? 3 : 6), noreg); + slli(tmp3, tmp3, isLL ? 24 : 48); + add(ch2, ch2, tmp3); + } else { + (this->*load_4chr)(ch2, Address(tmp3), noreg); + } beq(ch1, ch2, MATCH); add(hlen_neg, hlen_neg, haystack_chr_size); blez(hlen_neg, CH1_LOOP); @@ -693,10 +715,23 @@ void C2_MacroAssembler::string_indexof_linearscan(Register haystack, Register ne slli(tmp3, result_tmp, haystack_chr_shift); add(haystack, haystack, tmp3); neg(hlen_neg, tmp3); - + if (AvoidUnalignedAccesses) { + // preload first value, then we will read by 1 character per loop, instead of two + // just shifting previous ch2 right by size of character in bits + add(tmp3, haystack, hlen_neg); + (this->*haystack_load_1chr)(ch2, Address(tmp3), noreg); + slli(ch2, ch2, isLL ? 8 : 16); + } bind(CH1_LOOP); add(tmp3, haystack, hlen_neg); - (this->*load_2chr)(ch2, Address(tmp3), noreg); + if (AvoidUnalignedAccesses) { + srli(ch2, ch2, isLL ? 8 : 16); + (this->*haystack_load_1chr)(tmp3, Address(tmp3, isLL ? 1 : 2), noreg); + slli(tmp3, tmp3, isLL ? 8 : 16); + add(ch2, ch2, tmp3); + } else { + (this->*load_2chr)(ch2, Address(tmp3), noreg); + } beq(ch1, ch2, MATCH); add(hlen_neg, hlen_neg, haystack_chr_size); blez(hlen_neg, CH1_LOOP); @@ -720,7 +755,14 @@ void C2_MacroAssembler::string_indexof_linearscan(Register haystack, Register ne bind(FIRST_LOOP); add(ch2, haystack, hlen_neg); - (this->*load_2chr)(ch2, Address(ch2), noreg); + if (AvoidUnalignedAccesses) { + (this->*haystack_load_1chr)(tmp2, Address(ch2, isLL ? 1 : 2), noreg); // we need a temp register, we can safely use hlen_tmp here, which is a synonym for tmp2 + (this->*haystack_load_1chr)(ch2, Address(ch2), noreg); + slli(tmp2, tmp2, isLL ? 8 : 16); + add(ch2, ch2, tmp2); + } else { + (this->*load_2chr)(ch2, Address(ch2), noreg); + } beq(first, ch2, STR1_LOOP); bind(STR2_NEXT); @@ -744,10 +786,7 @@ void C2_MacroAssembler::string_indexof_linearscan(Register haystack, Register ne bind(DO1); (this->*needle_load_1chr)(ch1, Address(needle), noreg); sub(result_tmp, haystack_len, 1); - mv(tmp3, result_tmp); - if (haystack_chr_shift) { - slli(tmp3, result_tmp, haystack_chr_shift); - } + slli(tmp3, result_tmp, haystack_chr_shift); add(haystack, haystack, tmp3); neg(hlen_neg, tmp3); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 58ade498dbcbe..a63de2ad5be76 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -1616,12 +1616,29 @@ void MacroAssembler::store_sized_value(Address dst, Register src, size_t size_in } } -// granularity is 1, 2 bytes per load +// granularity is 1 OR 2 bytes per load. dst and src.base() allowed to be the same register +void MacroAssembler::load_short_misaligned(Register dst, Address src, Register tmp, bool is_signed, int granularity) { + if (granularity != 1 && granularity != 2) { + ShouldNotReachHere(); + } + if (AvoidUnalignedAccesses && (granularity != 2)) { + assert_different_registers(dst, tmp); + assert_different_registers(tmp, src.base()); + is_signed ? lb(tmp, Address(src.base(), src.offset() + 1)) : lbu(tmp, Address(src.base(), src.offset() + 1)); + slli(tmp, tmp, 8); + lbu(dst, src); + add(dst, dst, tmp); + } else { + is_signed ? lh(dst, src) : lhu(dst, src); + } +} + +// granularity is 1, 2 OR 4 bytes per load, if granularity 2 or 4 then dst and src.base() allowed to be the same register void MacroAssembler::load_int_misaligned(Register dst, Address src, Register tmp, bool is_signed, int granularity) { if (AvoidUnalignedAccesses && (granularity != 4)) { - assert_different_registers(dst, tmp, src.base()); switch(granularity) { case 1: + assert_different_registers(dst, tmp, src.base()); lbu(dst, src); lbu(tmp, Address(src.base(), src.offset() + 1)); slli(tmp, tmp, 8); @@ -1634,9 +1651,11 @@ void MacroAssembler::load_int_misaligned(Register dst, Address src, Register tmp add(dst, dst, tmp); break; case 2: - lhu(dst, src); + assert_different_registers(dst, tmp); + assert_different_registers(tmp, src.base()); is_signed ? lh(tmp, Address(src.base(), src.offset() + 2)) : lhu(tmp, Address(src.base(), src.offset() + 2)); slli(tmp, tmp, 16); + lhu(dst, src); add(dst, dst, tmp); break; default: @@ -1647,12 +1666,12 @@ void MacroAssembler::load_int_misaligned(Register dst, Address src, Register tmp } } -// granularity is 1, 2 or 4 bytes per load +// granularity is 1, 2, 4 or 8 bytes per load, if granularity 4 or 8 then dst and src.base() allowed to be same register void MacroAssembler::load_long_misaligned(Register dst, Address src, Register tmp, int granularity) { if (AvoidUnalignedAccesses && (granularity != 8)) { - assert_different_registers(dst, tmp, src.base()); switch(granularity){ case 1: + assert_different_registers(dst, tmp, src.base()); lbu(dst, src); lbu(tmp, Address(src.base(), src.offset() + 1)); slli(tmp, tmp, 8); @@ -1677,6 +1696,7 @@ void MacroAssembler::load_long_misaligned(Register dst, Address src, Register tm add(dst, dst, tmp); break; case 2: + assert_different_registers(dst, tmp, src.base()); lhu(dst, src); lhu(tmp, Address(src.base(), src.offset() + 2)); slli(tmp, tmp, 16); @@ -1689,9 +1709,11 @@ void MacroAssembler::load_long_misaligned(Register dst, Address src, Register tm add(dst, dst, tmp); break; case 4: - lwu(dst, src); + assert_different_registers(dst, tmp); + assert_different_registers(tmp, src.base()); lwu(tmp, Address(src.base(), src.offset() + 4)); slli(tmp, tmp, 32); + lwu(dst, src); add(dst, dst, tmp); break; default: diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 1c39536e327ef..2eada49233bfe 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -408,6 +408,7 @@ class MacroAssembler: public Assembler { void store_sized_value(Address dst, Register src, size_t size_in_bytes, Register src2 = noreg); // Misaligned loads, will use the best way, according to the AvoidUnalignedAccess flag + void load_short_misaligned(Register dst, Address src, Register tmp, bool is_signed, int granularity = 1); void load_int_misaligned(Register dst, Address src, Register tmp, bool is_signed, int granularity = 1); void load_long_misaligned(Register dst, Address src, Register tmp, int granularity = 1); From ec6f12921a161aa4b92fe5d02d3dad7faf06ff33 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 11 Oct 2023 07:51:05 +0000 Subject: [PATCH 218/341] 8273921: Refactor NSK/JDI tests to create thread using factory Backport-of: a72c8aa6ad58bad57ddbd65139bcb88b6d8aa5db --- .../jdi/BScenarios/multithrd/tc01x001a.java | 8 +-- .../jdi/BScenarios/multithrd/tc02x001a.java | 8 +-- .../jdi/BScenarios/multithrd/tc02x002a.java | 8 +-- .../jdi/BScenarios/multithrd/tc02x003a.java | 8 +-- .../jdi/BScenarios/multithrd/tc02x004a.java | 10 ++-- .../jdi/BScenarios/multithrd/tc03x001a.java | 8 +-- .../jdi/BScenarios/multithrd/tc04x001a.java | 11 ++-- .../_bounds_/filters001a.java | 6 +-- .../addInstanceFilter/instancefilter001a.java | 21 ++++---- .../addInstanceFilter/instancefilter002a.java | 15 +++--- .../addInstanceFilter/instancefilter003a.java | 13 ++--- .../addInstanceFilter/instancefilter004a.java | 21 ++++---- .../addThreadFilter/threadfilter001a.java | 19 +++---- .../addThreadFilter/threadfilter002a.java | 15 +++--- .../addThreadFilter/threadfilter003a.java | 7 ++- .../addThreadFilter/threadfilter004a.java | 19 +++---- .../location/location001a.java | 15 +++--- .../addClassExclusionFilter/filter001a.java | 16 +++--- .../addClassExclusionFilter/filter002a.java | 16 +++--- .../addClassFilter_rt/filter_rt001a.java | 25 ++++------ .../addClassFilter_rt/filter_rt002a.java | 16 +++--- .../addClassFilter_rt/filter_rt003a.java | 25 ++++------ .../addClassFilter_s/filter_s001a.java | 25 ++++------ .../addClassFilter_s/filter_s002a.java | 17 +++---- .../invokeMethod/invokemethod001a.java | 9 ++-- .../invokeMethod/invokemethod007a.java | 8 +-- .../invokeMethod/invokemethod011t.java | 14 +++--- .../invokeMethod/invokemethod013t.java | 14 +++--- .../ClassType/newInstance/newinstance001.java | 2 +- .../newInstance/newinstance001a.java | 7 ++- .../newInstance/newinstance007a.java | 8 +-- .../nsk/jdi/Event/equals/equals001a.java | 10 ++-- .../nsk/jdi/Event/hashCode/hashcode001a.java | 10 ++-- .../nsk/jdi/Event/request/request001a.java | 19 +++---- .../nextEvent/nextevent001a.java | 21 ++++---- .../addCountFilter/addcountfilter001a.java | 16 +++--- .../jdi/EventRequest/disable/disable001a.java | 16 +++--- .../jdi/EventRequest/disable/disable002a.java | 7 +-- .../jdi/EventRequest/enable/enable001a.java | 7 +-- .../jdi/EventRequest/enable/enable002a.java | 7 +-- .../getProperty/getproperty001a.java | 16 +++--- .../EventRequest/isEnabled/isenabled001a.java | 16 +++--- .../putProperty/putproperty001a.java | 16 +++--- .../setEnabled/setenabled001a.java | 16 +++--- .../setEnabled/setenabled002a.java | 16 +++--- .../setEnabled/setenabled003a.java | 16 +++--- .../setsuspendpolicy001a.java | 16 +++--- .../suspendPolicy/suspendpolicy001a.java | 16 +++--- .../createStepRequest/crstepreq002a.java | 16 +++--- .../createStepRequest/crstepreq003a.java | 10 ++-- .../createStepRequest/crstepreq004a.java | 10 ++-- .../createStepRequest/crstepreq005a.java | 8 +-- .../createStepRequest/crstepreq006a.java | 8 +-- .../createStepRequest/crstepreq007a.java | 8 +-- .../createStepRequest/crstepreq008a.java | 8 +-- .../createStepRequest/crstepreq009a.java | 8 +-- .../createStepRequest/crstepreq010a.java | 8 +-- .../deleteEventRequest/delevtreq002a.java | 16 +++--- .../deleteEventRequests/delevtreqs002a.java | 14 ++---- .../stepRequests/stepreq001t.java | 9 ++-- .../stepRequests/stepreq002a.java | 16 +++--- .../eventIterator/eventiterator003a.java | 6 +-- .../nsk/jdi/EventSet/resume/resume008a.java | 24 ++++----- .../nsk/jdi/EventSet/resume/resume009a.java | 24 ++++----- .../suspendPolicy/suspendpolicy008a.java | 40 +++++++-------- .../suspendPolicy/suspendpolicy009a.java | 40 +++++++-------- .../addClassExclusionFilter/filter001a.java | 30 ++++------- .../addClassFilter_rt/filter_rt001a.java | 25 ++++------ .../addClassFilter_rt/filter_rt002a.java | 16 +++--- .../addClassFilter_rt/filter_rt003a.java | 29 ++++------- .../addClassFilter_s/filter_s001a.java | 29 ++++------- .../addClassFilter_s/filter_s002a.java | 16 +++--- .../addInstanceFilter/instancefilter001a.java | 21 ++++---- .../addInstanceFilter/instancefilter002a.java | 12 ++--- .../addInstanceFilter/instancefilter003a.java | 13 ++--- .../addInstanceFilter/instancefilter004a.java | 19 +++---- .../addThreadFilter/threadfilter001a.java | 19 +++---- .../addThreadFilter/threadfilter002a.java | 15 +++--- .../addThreadFilter/threadfilter004a.java | 19 +++---- .../notifyCaught/notifycaught001a.java | 16 +++--- .../notifyUncaught/notifyuncaught001a.java | 16 +++--- .../isVisible/isvisible001a.java | 9 ++-- .../jdi/Locatable/location/location004a.java | 9 ++-- .../jdi/Locatable/location/location005a.java | 9 ++-- .../jdi/LocatableEvent/thread/thread001a.java | 11 ++-- .../addClassExclusionFilter/filter001a.java | 15 ++---- .../addClassFilter_rt/filter_rt001a.java | 16 +++--- .../addClassFilter_rt/filter_rt002a.java | 12 ++--- .../addClassFilter_rt/filter_rt003a.java | 29 ++++------- .../addClassFilter_s/filter_s001a.java | 29 ++++------- .../addInstanceFilter/instancefilter001a.java | 21 ++++---- .../addInstanceFilter/instancefilter002a.java | 15 +++--- .../addInstanceFilter/instancefilter003a.java | 15 +++--- .../addInstanceFilter/instancefilter004a.java | 21 ++++---- .../addThreadFilter/threadfilter001a.java | 19 +++---- .../addThreadFilter/threadfilter002a.java | 15 +++--- .../addThreadFilter/threadfilter004a.java | 19 +++---- .../addClassExclusionFilter/filter001a.java | 17 +++---- .../addClassFilter_rt/filter_rt001a.java | 17 +++---- .../addClassFilter_rt/filter_rt002a.java | 16 +++--- .../addClassFilter_rt/filter_rt003a.java | 29 ++++------- .../addClassFilter_s/filter_s001a.java | 29 ++++------- .../addInstanceFilter/instancefilter001a.java | 21 ++++---- .../addInstanceFilter/instancefilter002a.java | 16 +++--- .../addInstanceFilter/instancefilter003a.java | 16 +++--- .../addInstanceFilter/instancefilter004a.java | 22 ++++---- .../addThreadFilter/threadfilter001a.java | 20 ++++---- .../addThreadFilter/threadfilter002a.java | 16 +++--- .../addThreadFilter/threadfilter003a.java | 9 ++-- .../addThreadFilter/threadfilter004a.java | 19 +++---- .../getValue/getvalue001a.java | 9 ++-- .../owningThread/owningthread001a.java | 14 ++---- .../owningThread/owningthread002a.java | 9 ++-- .../jdi/StackFrame/getValue/getvalue001a.java | 9 ++-- .../jdi/StackFrame/getValue/getvalue002a.java | 9 ++-- .../StackFrame/getValues/getvalues001a.java | 9 ++-- .../StackFrame/getValues/getvalues002a.java | 9 ++-- .../jdi/StackFrame/location/location001a.java | 9 ++-- .../setValue/setvalue001/setvalue001a.java | 9 ++-- .../setValue/setvalue002/setvalue002a.java | 9 ++-- .../setValue/setvalue003/setvalue003a.java | 9 ++-- .../setValue/setvalue004/setvalue004a.java | 9 ++-- .../StackFrame/thisObject/thisobject002a.java | 9 ++-- .../nsk/jdi/StackFrame/thread/thread001a.java | 9 ++-- .../visiblevarbyname001a.java | 9 ++-- .../visiblevarbyname002a.java | 9 ++-- .../visiblevariables001a.java | 9 ++-- .../visiblevariables002a.java | 9 ++-- .../addClassExclusionFilter/filter001a.java | 28 ++++------- .../addClassFilter_rt/filter_rt001a.java | 37 +++++++------- .../addClassFilter_rt/filter_rt002a.java | 16 +++--- .../addClassFilter_rt/filter_rt003a.java | 34 ++++++------- .../addClassFilter_s/filter_s001a.java | 28 ++++------- .../addClassFilter_s/filter_s002a.java | 15 +++--- .../addInstanceFilter/instancefilter001a.java | 19 +++---- .../addInstanceFilter/instancefilter002a.java | 15 +++--- .../addInstanceFilter/instancefilter003a.java | 15 +++--- .../addInstanceFilter/instancefilter004a.java | 19 +++---- .../nsk/jdi/StepRequest/depth/depth001a.java | 16 +++--- .../nsk/jdi/StepRequest/depth/depth002a.java | 16 +++--- .../nsk/jdi/StepRequest/depth/depth003a.java | 16 +++--- .../nsk/jdi/StepRequest/size/size001a.java | 16 +++--- .../nsk/jdi/StepRequest/size/size002a.java | 16 +++--- .../jdi/StepRequest/thread/thread001a.java | 16 +++--- .../addThreadFilter/addthreadfilter001a.java | 16 +++--- .../addThreadFilter/addthreadfilter003a.java | 15 +++--- .../addThreadFilter/addthreadfilter004a.java | 19 +++---- .../addThreadFilter/addthreadfilter005a.java | 11 ++-- .../currentcm001a.java | 2 +- .../jdi/ThreadReference/frame/frame001a.java | 9 ++-- .../frameCount/framecount001a.java | 9 ++-- .../frames_ii/frames_ii001a.java | 9 ++-- .../isAtBreakpoint/isatbreakpoint001a.java | 9 ++-- .../isSuspended/issuspended001a.java | 9 ++-- .../isSuspended/issuspended002a.java | 9 ++-- .../isSuspended/issuspended003a.java | 9 ++-- .../isSuspended/issuspended004a.java | 9 ++-- .../jdi/ThreadReference/name/name001a.java | 9 ++-- .../popFrames/popframes001a.java | 9 ++-- .../popFrames/popframes002a.java | 15 +++--- .../popFrames/popframes003a.java | 15 +++--- .../popFrames/popframes004a.java | 9 ++-- .../ThreadReference/resume/resume001a.java | 9 ++-- .../jdi/ThreadReference/stop/stop001a.java | 14 ++---- .../ThreadReference/suspend/suspend001a.java | 9 ++-- .../suspendCount/suspendcount001a.java | 9 ++-- .../ThreadStartEvent/thread/thread001a.java | 8 +-- .../addThreadFilter/addthreadfilter001a.java | 16 +++--- .../addThreadFilter/addthreadfilter003a.java | 15 +++--- .../addThreadFilter/addthreadfilter004a.java | 19 +++---- .../addThreadFilter/addthreadfilter005a.java | 11 ++-- .../allThreads/allthreads001a.java | 9 ++-- .../cangccm001a.java | 14 ++---- .../cangetmonitorinfo001a.java | 14 ++---- .../cangetinfo001a.java | 14 ++---- .../VirtualMachine/dispose/dispose002a.java | 9 ++-- .../VirtualMachine/dispose/dispose003a.java | 9 ++-- .../VirtualMachine/dispose/dispose004a.java | 9 ++-- .../VirtualMachine/suspend/suspend001a.java | 9 ++-- .../addClassExclusionFilter/filter001a.java | 29 ++++------- .../addClassExclusionFilter/filter002a.java | 29 ++++------- .../addClassFilter_rt/filter_rt001a.java | 29 ++++------- .../addClassFilter_rt/filter_rt002a.java | 29 ++++------- .../addClassFilter_rt/filter_rt005a.java | 29 ++++------- .../addClassFilter_rt/filter_rt006a.java | 29 ++++------- .../addClassFilter_s/filter_s001a.java | 29 ++++------- .../addClassFilter_s/filter_s002a.java | 29 ++++------- .../addInstanceFilter/instancefilter001a.java | 21 ++++---- .../addInstanceFilter/instancefilter002a.java | 21 ++++---- .../addInstanceFilter/instancefilter003a.java | 15 +++--- .../addInstanceFilter/instancefilter004a.java | 15 +++--- .../addInstanceFilter/instancefilter005a.java | 15 +++--- .../addInstanceFilter/instancefilter006a.java | 15 +++--- .../addInstanceFilter/instancefilter007a.java | 21 ++++---- .../addInstanceFilter/instancefilter008a.java | 21 ++++---- .../addThreadFilter/addthreadfilter001a.java | 19 +++---- .../addThreadFilter/addthreadfilter002a.java | 19 +++---- .../addThreadFilter/addthreadfilter003a.java | 15 +++--- .../addThreadFilter/addthreadfilter004a.java | 15 +++--- .../addThreadFilter/addthreadfilter005a.java | 9 ++-- .../addThreadFilter/addthreadfilter006a.java | 9 ++-- .../addThreadFilter/addthreadfilter007a.java | 19 +++---- .../addThreadFilter/addthreadfilter008a.java | 19 +++---- .../nsk/share/jdi/JDIThreadFactory.java | 50 +++++++++++++++++++ .../vmTestbase/nsk/share/jdi/NamedTask.java | 40 +++++++++++++++ 205 files changed, 1367 insertions(+), 1835 deletions(-) create mode 100644 test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIThreadFactory.java create mode 100644 test/hotspot/jtreg/vmTestbase/nsk/share/jdi/NamedTask.java diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc01x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc01x001a.java index 154656c263e81..68e8576c88922 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc01x001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc01x001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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 tc01x001a { public final static int threadCount = 3; private static Log log; - Thready [] thrds = new Thready [threadCount]; + Thread[] thrds = new Thread[threadCount]; public static void main (String argv[]) { ArgumentHandler argHandler = new ArgumentHandler(argv); @@ -76,7 +76,7 @@ public static void main (String argv[]) { tc01x001a() { for (int i = 0; i < thrds.length; i++ ) { - thrds[i] = new Thready("Thread-" + (i+1)); + thrds[i] = JDIThreadFactory.newThread(new Thready("Thread-" + (i+1))); thrds[i].start(); } } @@ -90,7 +90,7 @@ public static void bar(String caller) { log.display(caller + "::bar_step"); // checkStepLine } - static class Thready extends Thread { + static class Thready extends NamedTask { Thready(String name) { super(name); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001a.java index 91a8cb1f08bce..412c18851a90e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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 tc02x001a { static Log log; public final static int checkClassBrkpLine = 93; - Thready [] thrds = new Thready [threadCount]; + Thread[] thrds = new Thread[threadCount]; public static void main (String argv[]) { ArgumentHandler argHandler = new ArgumentHandler(argv); @@ -72,12 +72,12 @@ public static void main (String argv[]) { tc02x001a() { for (int i = 0; i < thrds.length; i++ ) { - thrds[i] = new Thready("Thread-" + (i+1)); + thrds[i] = JDIThreadFactory.newThread(new Thready("Thread-" + (i+1))); thrds[i].start(); } } - static class Thready extends Thread { + static class Thready extends NamedTask { Thready(String name) { super(name); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002a.java index a0bf559387d1f..fd9501d93a6e7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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 tc02x002a { public final static int checkClassBrkpLine1 = 96; public final static int checkClassBrkpLine2 = 98; - Thready [] thrds = new Thready [threadCount]; + Thread[] thrds = new Thread[threadCount]; public static void main (String argv[]) { ArgumentHandler argHandler = new ArgumentHandler(argv); @@ -74,12 +74,12 @@ public static void main (String argv[]) { tc02x002a() { for (int i = 0; i < thrds.length; i++ ) { - thrds[i] = new Thready("Thread-" + (i+1)); + thrds[i] = JDIThreadFactory.newThread(new Thready("Thread-" + (i+1))); thrds[i].start(); } } - static class Thready extends Thread { + static class Thready extends NamedTask { Thready(String name) { super(name); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003a.java index 2f4957d1fa455..5288cdccb147d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x003a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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 tc02x003a { public final static int checkClassBrkpLine1 = 96; public final static int checkClassBrkpLine2 = 98; - Thready [] thrds = new Thready [threadCount]; + Thread[] thrds = new Thread[threadCount]; public static void main (String argv[]) { ArgumentHandler argHandler = new ArgumentHandler(argv); @@ -74,12 +74,12 @@ public static void main (String argv[]) { tc02x003a() { for (int i = 0; i < thrds.length; i++ ) { - thrds[i] = new Thready("Thread-" + (i+1)); + thrds[i] = JDIThreadFactory.newThread(new Thready("Thread-" + (i+1))); thrds[i].start(); } } - static class Thready extends Thread { + static class Thready extends NamedTask { Thready(String name) { super(name); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004a.java index f41aed7660974..ae9541c742329 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc02x004a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.BScenarios.multithrd; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; // THIS TEST IS LINE NUMBER SENSITIVE @@ -38,7 +37,7 @@ public class tc02x004a { static Log log; public final static int checkClassBrkpLine = 79; - Thready [] thrds = new Thready [threadCount]; + Thread[] thrds = new Thread[threadCount]; public static void main (String argv[]) { ArgumentHandler argHandler = new ArgumentHandler(argv); @@ -58,12 +57,12 @@ public static void main (String argv[]) { tc02x004a() { for (int i = 0; i < thrds.length; i++ ) { - thrds[i] = new Thready("Thread-" + (i+1)); + thrds[i] = JDIThreadFactory.newThread(new Thready("Thread-" + (i+1))); thrds[i].start(); } } - static class Thready extends Thread { + static class Thready extends NamedTask { Thready(String name) { super(name); } @@ -75,6 +74,7 @@ public void run() { } } + class tc02x004aClass1 { public tc02x004aClass1(String thrdName) { // checkClassBrkpLine tc02x004a.log.display("tc02x004aClass1::constructor is called from" diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001a.java index 7fffcb2406425..ae789b372fa53 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc03x001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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 tc03x001a { static Log log; public final static int checkExBrkpLine = 90; - Thready [] thrds = new Thready [threadCount]; + Thread[] thrds = new Thread[threadCount]; public static void main (String argv[]) { ArgumentHandler argHandler = new ArgumentHandler(argv); @@ -74,12 +74,12 @@ public static void main (String argv[]) { tc03x001a() { for (int i = 0; i < thrds.length; i++ ) { - thrds[i] = new Thready("Thread-" + (i+1)); + thrds[i] = JDIThreadFactory.newThread(new Thready("Thread-" + (i+1))); thrds[i].start(); } } - static class Thready extends Thread { + static class Thready extends NamedTask { Thready(String name) { super(name); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001a.java index b7a68c487ee75..a343c6c511682 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BScenarios/multithrd/tc04x001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.BScenarios.multithrd; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; // THIS TEST IS LINE NUMBER SENSITIVE @@ -37,8 +36,8 @@ public class tc04x001a { public final static int threadCount = 3; static Log log; - public final static int checkMethodBrkpLine = 74; - Thready [] thrds = new Thready [threadCount]; + public final static int checkMethodBrkpLine = 73; + Thread[] thrds = new Thread[threadCount]; public static void main (String argv[]) { ArgumentHandler argHandler = new ArgumentHandler(argv); @@ -65,7 +64,7 @@ public static void main (String argv[]) { tc04x001a() { for (int i = 0; i < thrds.length; i++ ) { - thrds[i] = new Thready("Thread-" + (i+1)); + thrds[i] = JDIThreadFactory.newThread(new Thready("Thread-" + (i+1))); thrds[i].start(); } } @@ -78,7 +77,7 @@ public static void bar(String caller) { log.display(caller + "::bar is called"); } - static class Thready extends Thread { + static class Thready extends NamedTask { Thready(String name) { super(name); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/_bounds_/filters001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/_bounds_/filters001a.java index ee4300cfbe78b..c81bc46016e52 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/_bounds_/filters001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/_bounds_/filters001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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,11 +64,11 @@ public static void main (String argv[]) { } } -class filters001b extends Thread { +class filters001b extends NamedTask { static Log log; filters001b(String nameObj) { - setName(nameObj); + super(nameObj); } public void run() { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001a.java index 3569a34578670..b453cf768cf54 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.BreakpointRequest.addInstanceFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,8 +53,8 @@ private static void logErr(String message) { //====================================================== test program - static Threadinstancefilter001a thread1 = null; - static Threadinstancefilter001a thread2 = null; + static Thread thread1 = null; + static Thread thread2 = null; static instancefilter001aTestClass objTC[] = { new instancefilter001aTestClass(), new instancefilter001aTestClass(), new instancefilter001aTestClass() }; @@ -99,8 +98,8 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Threadinstancefilter001a("thread1"); - thread2 = new Threadinstancefilter001a("thread2"); + thread1 = JDIThreadFactory.newThread(new Threadinstancefilter001a("thread1")); + thread2 = JDIThreadFactory.newThread(new Threadinstancefilter001a("thread2")); break; case 1: @@ -149,31 +148,29 @@ static int threadStart(Thread t) { static Object lockingObj[] = new Object[2]; static volatile int number = 0; - static class Threadinstancefilter001a extends Thread { + static class Threadinstancefilter001a extends NamedTask { - String tName = null; int tNumber; public Threadinstancefilter001a(String threadName) { super(threadName); - tName = threadName; tNumber = number; number++; lockingObj[tNumber] = threadName; } public void run() { - log1(" 'run': enter :: threadName == " + tName); + log1(" 'run': enter :: threadName == " + getName()); if (lockingObj[tNumber] == null) log1("lockingObj[tNumber] == null"); synchronized(lockingObj[tNumber]) { synchronized (waitnotifyObj) { waitnotifyObj.notify(); } - log1(" objTC[tNumber].method(); :: threadName == " + tName + " tNumber == " + tNumber); + log1(" objTC[tNumber].method(); :: threadName == " + getName() + " tNumber == " + tNumber); objTC[tNumber].method(); } - log1(" 'run': exit :: threadName == " + tName); + log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002a.java index 4cdd50a131b04..23505ff49e36e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.BreakpointRequest.addInstanceFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Threadinstancefilter002a thread1 = null; + static Thread thread1 = null; static instancefilter002aTestClass objTC[] = { new instancefilter002aTestClass(), new instancefilter002aTestClass() }; @@ -98,7 +97,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Threadinstancefilter002a("thread1"); + thread1 = JDIThreadFactory.newThread(new Threadinstancefilter002a("thread1")); break; //------------------------------------------------- standard end section @@ -137,21 +136,19 @@ static int threadStart(Thread t) { static Object lockingObj[] = new Object[2]; static volatile int number = 0; - static class Threadinstancefilter002a extends Thread { + static class Threadinstancefilter002a extends NamedTask { - String tName = null; int tNumber; public Threadinstancefilter002a(String threadName) { super(threadName); - tName = threadName; tNumber = number; number++; lockingObj[tNumber] = threadName; } public void run() { - log1(" 'run': enter :: threadName == " + tName); + log1(" 'run': enter :: threadName == " + getName()); if (lockingObj[tNumber] == null) log1("lockingObj[tNumber] == null"); synchronized(lockingObj[tNumber]) { @@ -160,7 +157,7 @@ public void run() { } objTC[tNumber].method(); } - log1(" 'run': exit :: threadName == " + tName); + log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003a.java index 9039c7bb08e5a..d000cf129f8b9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003a.java @@ -24,7 +24,6 @@ package nsk.jdi.BreakpointRequest.addInstanceFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Threadinstancefilter003a thread1 = null; + static Thread thread1 = null; static instancefilter003aTestClass objTC[] = { new instancefilter003aTestClass(), new instancefilter003aTestClass() }; @@ -98,7 +97,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Threadinstancefilter003a("thread1"); + thread1 = JDIThreadFactory.newThread(new Threadinstancefilter003a("thread1")); break; //------------------------------------------------- standard end section @@ -137,21 +136,19 @@ static int threadStart(Thread t) { static Object lockingObj[] = new Object[2]; static volatile int number = 0; - static class Threadinstancefilter003a extends Thread { + static class Threadinstancefilter003a extends NamedTask { - String tName = null; int tNumber; public Threadinstancefilter003a(String threadName) { super(threadName); - tName = threadName; tNumber = number; number++; lockingObj[tNumber] = threadName; } public void run() { - log1(" 'run': enter :: threadName == " + tName); + log1(" 'run': enter :: threadName == " + getName()); if (lockingObj[tNumber] == null) log1("lockingObj[tNumber] == null"); synchronized(lockingObj[tNumber]) { @@ -160,7 +157,7 @@ public void run() { } objTC[tNumber].method(); } - log1(" 'run': exit :: threadName == " + tName); + log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004a.java index b30041b0ac182..e875d0ac54519 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter004a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.BreakpointRequest.addInstanceFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,8 +53,8 @@ private static void logErr(String message) { //====================================================== test program - static Threadinstancefilter004a thread1 = null; - static Threadinstancefilter004a thread2 = null; + static Thread thread1 = null; + static Thread thread2 = null; static instancefilter004aTestClass objTC[] = { new instancefilter004aTestClass(), new instancefilter004aTestClass(), new instancefilter004aTestClass() }; @@ -99,8 +98,8 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Threadinstancefilter004a("thread1"); - thread2 = new Threadinstancefilter004a("thread2"); + thread1 = JDIThreadFactory.newThread(new Threadinstancefilter004a("thread1")); + thread2 = JDIThreadFactory.newThread(new Threadinstancefilter004a("thread2")); break; case 1: @@ -149,31 +148,29 @@ static int threadStart(Thread t) { static Object lockingObj[] = new Object[2]; static volatile int number = 0; - static class Threadinstancefilter004a extends Thread { + static class Threadinstancefilter004a extends NamedTask { - String tName = null; int tNumber; public Threadinstancefilter004a(String threadName) { super(threadName); - tName = threadName; tNumber = number; number++; lockingObj[tNumber] = threadName; } public void run() { - log1(" 'run': enter :: threadName == " + tName); + log1(" 'run': enter :: threadName == " + getName()); if (lockingObj[tNumber] == null) log1("lockingObj[tNumber] == null"); synchronized(lockingObj[tNumber]) { synchronized (waitnotifyObj) { waitnotifyObj.notify(); } - log1(" objTC[tNumber].method(); :: threadName == " + tName + " tNumber == " + tNumber); + log1(" objTC[tNumber].method(); :: threadName == " + getName() + " tNumber == " + tNumber); objTC[tNumber].method(); } - log1(" 'run': exit :: threadName == " + tName); + log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001a.java index 81625b6b02f5b..b1ca309616485 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.BreakpointRequest.addThreadFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,8 +53,8 @@ private static void logErr(String message) { //====================================================== test program - static Threadthreadfilter001a thread1 = null; - static Threadthreadfilter001a thread2 = null; + static Thread thread1 = null; + static Thread thread2 = null; static threadfilter001aTestClass objTC = new threadfilter001aTestClass(); @@ -99,8 +98,8 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Threadthreadfilter001a("thread1"); - thread2 = new Threadthreadfilter001a("thread2"); + thread1 = JDIThreadFactory.newThread(new Threadthreadfilter001a("thread1")); + thread2 = JDIThreadFactory.newThread(new Threadthreadfilter001a("thread2")); break; case 1: @@ -149,21 +148,19 @@ static int threadStart(Thread t) { static Object lockingObj[] = new Object[2]; static volatile int number = 0; - static class Threadthreadfilter001a extends Thread { + static class Threadthreadfilter001a extends NamedTask { - String tName = null; int tNumber; public Threadthreadfilter001a(String threadName) { super(threadName); - tName = threadName; tNumber = number; number++; lockingObj[tNumber] = threadName; } public void run() { - log1(" 'run': enter :: threadName == " + tName); + log1(" 'run': enter :: threadName == " + getName()); if (lockingObj[tNumber] == null) log1("lockingObj[tNumber] == null"); synchronized(lockingObj[tNumber]) { @@ -172,7 +169,7 @@ public void run() { } objTC.method(); } - log1(" 'run': exit :: threadName == " + tName); + log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002a.java index ed85733431a64..6d27027c00948 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.BreakpointRequest.addThreadFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Threadthreadfilter002a thread1 = null; + static Thread thread1 = null; static threadfilter002aTestClass objTC = new threadfilter002aTestClass(); @@ -98,7 +97,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Threadthreadfilter002a("thread1"); + thread1 = JDIThreadFactory.newThread(new Threadthreadfilter002a("thread1")); break; //------------------------------------------------- standard end section @@ -137,21 +136,19 @@ static int threadStart(Thread t) { static Object lockingObj[] = new Object[2]; static volatile int number = 0; - static class Threadthreadfilter002a extends Thread { + static class Threadthreadfilter002a extends NamedTask { - String tName = null; int tNumber; public Threadthreadfilter002a(String threadName) { super(threadName); - tName = threadName; tNumber = number; number++; lockingObj[tNumber] = threadName; } public void run() { - log1(" 'run': enter :: threadName == " + tName); + log1(" 'run': enter :: threadName == " + getName()); if (lockingObj[tNumber] == null) log1("lockingObj[tNumber] == null"); synchronized(lockingObj[tNumber]) { @@ -160,7 +157,7 @@ public void run() { } objTC.method(); } - log1(" 'run': exit :: threadName == " + tName); + log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003a.java index 5246ec811222d..9fa778a65ba8b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003a.java @@ -24,7 +24,6 @@ package nsk.jdi.BreakpointRequest.addThreadFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Threadthreadfilter003a thread1 = null; + static Thread thread1 = null; static threadfilter003aTestClass objTC = new threadfilter003aTestClass(); @@ -98,7 +97,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Threadthreadfilter003a("thread1"); + thread1 = JDIThreadFactory.newThread(new Threadthreadfilter003a("thread1")); break; case 1: @@ -149,7 +148,7 @@ static int threadStart(Thread t) { return PASSED; } - static class Threadthreadfilter003a extends Thread { + static class Threadthreadfilter003a extends NamedTask { public Threadthreadfilter003a(String threadName) { super(threadName); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004a.java index eee1d5a5cf4db..e8866d4cfe564 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter004a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.BreakpointRequest.addThreadFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,8 +53,8 @@ private static void logErr(String message) { //====================================================== test program - static Threadthreadfilter004a thread1 = null; - static Threadthreadfilter004a thread2 = null; + static Thread thread1 = null; + static Thread thread2 = null; static threadfilter004aTestClass objTC = new threadfilter004aTestClass(); @@ -99,8 +98,8 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Threadthreadfilter004a("thread1"); - thread2 = new Threadthreadfilter004a("thread2"); + thread1 = JDIThreadFactory.newThread(new Threadthreadfilter004a("thread1")); + thread2 = JDIThreadFactory.newThread(new Threadthreadfilter004a("thread2")); break; case 1: @@ -151,21 +150,19 @@ static int threadStart(Thread t) { static Object lockingObj[] = new Object[2]; static volatile int number = 0; - static class Threadthreadfilter004a extends Thread { + static class Threadthreadfilter004a extends NamedTask { - String tName = null; int tNumber; public Threadthreadfilter004a(String threadName) { super(threadName); - tName = threadName; tNumber = number; number++; lockingObj[tNumber] = threadName; } public void run() { - log1(" 'run': enter :: threadName == " + tName); + log1(" 'run': enter :: threadName == " + getName()); if (lockingObj[tNumber] == null) log1("lockingObj[tNumber] == null"); synchronized(lockingObj[tNumber]) { @@ -174,7 +171,7 @@ public void run() { } objTC.method(); } - log1(" 'run': exit :: threadName == " + tName); + log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001a.java index e65ddad306645..2ebade5945cf7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.BreakpointRequest.location; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Threadlocation001a thread1 = null; + static Thread thread1 = null; static TestClass objTC = new TestClass(); @@ -98,7 +97,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Threadlocation001a("thread1"); + thread1 = JDIThreadFactory.newThread(new Threadlocation001a("thread1")); break; //------------------------------------------------- standard end section @@ -137,21 +136,19 @@ static int threadStart(Thread t) { static Object lockingObj[] = new Object[2]; static volatile int number = 0; - static class Threadlocation001a extends Thread { + static class Threadlocation001a extends NamedTask { - String tName = null; int tNumber; public Threadlocation001a(String threadName) { super(threadName); - tName = threadName; tNumber = number; number++; lockingObj[tNumber] = threadName; } public void run() { - log1(" 'run': enter :: threadName == " + tName); + log1(" 'run': enter :: threadName == " + getName()); if (lockingObj[tNumber] == null) log1("lockingObj[tNumber] == null"); synchronized(lockingObj[tNumber]) { @@ -160,7 +157,7 @@ public void run() { } objTC.method(); } - log1(" 'run': exit :: threadName == " + tName); + log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001a.java index e504ba0131e84..cc3259335b17f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.ClassPrepareRequest.addClassExclusionFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1filter001a thread1 = null; + static Thread thread1 = null; //------------------------------------------------------ common section @@ -101,7 +100,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1filter001a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1filter001a("thread1")); log1("run1(thread1);"); run1(thread1); @@ -143,7 +142,7 @@ static void run1(Thread t) { } -class Thread1filter001a extends Thread { +class Thread1filter001a extends NamedTask { class TestClass10{ int var10 = 0; @@ -152,17 +151,14 @@ class TestClass11 extends TestClass10{ int var11 = 0; } - String tName = null; - public Thread1filter001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - filter001a.log1(" 'run': enter :: threadName == " + tName); + filter001a.log1(" 'run': enter :: threadName == " + getName()); TestClass11 obj1 = new TestClass11(); - filter001a.log1(" 'run': exit :: threadName == " + tName); + filter001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002a.java index b09f2db5490dc..03ad19de54c55 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.ClassPrepareRequest.addClassExclusionFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1filter002a thread1 = null; + static Thread thread1 = null; //------------------------------------------------------ common section @@ -101,7 +100,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1filter002a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1filter002a("thread1")); log1("run1(thread1);"); run1(thread1); @@ -143,7 +142,7 @@ static void run1(Thread t) { } -class Thread1filter002a extends Thread { +class Thread1filter002a extends NamedTask { class TestClass10{ int var10 = 0; @@ -152,17 +151,14 @@ class TestClass11 extends TestClass10{ int var11 = 0; } - String tName = null; - public Thread1filter002a(String threadName) { super(threadName); - tName = threadName; } public void run() { - filter002a.log1(" 'run': enter :: threadName == " + tName); + filter002a.log1(" 'run': enter :: threadName == " + getName()); TestClass11 obj1 = new TestClass11(); - filter002a.log1(" 'run': exit :: threadName == " + tName); + filter002a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001a.java index 80f3c2d6232eb..fb9bf4ffa33a1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.ClassPrepareRequest.addClassFilter_rt; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -98,8 +97,8 @@ public static void main (String argv[]) { case 1: - filter_rt001aThread1 thread1 = new filter_rt001aThread1("thread1"); - filter_rt001aThread2 thread2 = new filter_rt001aThread2("thread2"); + Thread thread1 = JDIThreadFactory.newThread(new filter_rt001aThread1("thread1")); + Thread thread2 = JDIThreadFactory.newThread(new filter_rt001aThread2("thread2")); log1("new filter_rt001a().run1(thread1);"); new filter_rt001a().run1(thread1); @@ -155,19 +154,16 @@ class filter_rt001aTestClass10{ class filter_rt001aTestClass11 extends filter_rt001aTestClass10{ static int var11 = 0; } -class filter_rt001aThread1 extends Thread { - - String tName = null; +class filter_rt001aThread1 extends NamedTask { public filter_rt001aThread1(String threadName) { super(threadName); - tName = threadName; } public void run() { - filter_rt001a.log1(" 'run': enter :: threadName == " + tName); + filter_rt001a.log1(" 'run': enter :: threadName == " + getName()); filter_rt001aTestClass11 obj1 = new filter_rt001aTestClass11(); - filter_rt001a.log1(" 'run': exit :: threadName == " + tName); + filter_rt001a.log1(" 'run': exit :: threadName == " + getName()); return; } } @@ -178,19 +174,16 @@ class filter_rt001aTestClass20 { class filter_rt001aTestClass21 { static int var21 = 0; } -class filter_rt001aThread2 extends Thread { - - String tName = null; +class filter_rt001aThread2 extends NamedTask { public filter_rt001aThread2(String threadName) { super(threadName); - tName = threadName; } public void run() { - filter_rt001a.log1(" 'run': enter :: threadName == " + tName); + filter_rt001a.log1(" 'run': enter :: threadName == " + getName()); filter_rt001aTestClass21 obj2 = new filter_rt001aTestClass21(); - filter_rt001a.log1(" 'run': exit :: threadName == " + tName); + filter_rt001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002a.java index 9641f81ec9575..2c0db7202e1df 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.ClassPrepareRequest.addClassFilter_rt; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static filter_rt002aThread1 thread1 = null; + static Thread thread1 = null; static filter_rt002aTestClass10 obj = new filter_rt002aTestClass10(); @@ -98,7 +97,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new filter_rt002aThread1("thread1"); + thread1 = JDIThreadFactory.newThread(new filter_rt002aThread1("thread1")); break; //------------------------------------------------- standard end section @@ -149,19 +148,16 @@ class filter_rt002aTestClass10{ class filter_rt002aTestClass11 extends filter_rt002aTestClass10{ static int var11 = 0; } -class filter_rt002aThread1 extends Thread { - - String tName = null; +class filter_rt002aThread1 extends NamedTask { public filter_rt002aThread1(String threadName) { super(threadName); - tName = threadName; } public void run() { - filter_rt002a.log1(" 'run': enter :: threadName == " + tName); + filter_rt002a.log1(" 'run': enter :: threadName == " + getName()); filter_rt002aTestClass11 obj1 = new filter_rt002aTestClass11(); - filter_rt002a.log1(" 'run': exit :: threadName == " + tName); + filter_rt002a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003a.java index 291d0a9f0750d..c9edcc5e1c6a0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt003a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.ClassPrepareRequest.addClassFilter_rt; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -99,8 +98,8 @@ public static void main (String argv[]) { case 1: - filter_rt003aThread1 thread1 = new filter_rt003aThread1("thread1"); - filter_rt003aThread2 thread2 = new filter_rt003aThread2("thread2"); + Thread thread1 = JDIThreadFactory.newThread(new filter_rt003aThread1("thread1")); + Thread thread2 = JDIThreadFactory.newThread(new filter_rt003aThread2("thread2")); log1("new filter_rt003a().run1(thread1);"); new filter_rt003a().run1(thread1); @@ -156,19 +155,16 @@ class filter_rt003aTestClass10{ class filter_rt003aTestClass11 extends filter_rt003aTestClass10{ static int var11 = 0; } -class filter_rt003aThread1 extends Thread { - - String tName = null; +class filter_rt003aThread1 extends NamedTask { public filter_rt003aThread1(String threadName) { super(threadName); - tName = threadName; } public void run() { - filter_rt003a.log1(" 'run': enter :: threadName == " + tName); + filter_rt003a.log1(" 'run': enter :: threadName == " + getName()); filter_rt003aTestClass11 obj1 = new filter_rt003aTestClass11(); - filter_rt003a.log1(" 'run': exit :: threadName == " + tName); + filter_rt003a.log1(" 'run': exit :: threadName == " + getName()); return; } } @@ -179,19 +175,16 @@ class filter_rt003aTestClass20 { class filter_rt003aTestClass21 { static int var21 = 0; } -class filter_rt003aThread2 extends Thread { - - String tName = null; +class filter_rt003aThread2 extends NamedTask { public filter_rt003aThread2(String threadName) { super(threadName); - tName = threadName; } public void run() { - filter_rt003a.log1(" 'run': enter :: threadName == " + tName); + filter_rt003a.log1(" 'run': enter :: threadName == " + getName()); filter_rt003aTestClass21 obj2 = new filter_rt003aTestClass21(); - filter_rt003a.log1(" 'run': exit :: threadName == " + tName); + filter_rt003a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001a.java index f96143acfb6dd..804af0308fc3e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.ClassPrepareRequest.addClassFilter_s; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -98,13 +97,13 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - Thread1filter_s001a thread1 = new Thread1filter_s001a("thread1"); + Thread thread1 = JDIThreadFactory.newThread(new Thread1filter_s001a("thread1")); log1("new filter_s001a().run1(thread1);"); new filter_s001a().run1(thread1); break; case 1: - Thread2filter_s001a thread2 = new Thread2filter_s001a("thread2"); + Thread thread2 = JDIThreadFactory.newThread(new Thread2filter_s001a("thread2")); log1("new filter_s001a().run1(thread2);"); new filter_s001a().run1(thread2); @@ -146,7 +145,7 @@ public void run1(Thread t) { } -class Thread1filter_s001a extends Thread { +class Thread1filter_s001a extends NamedTask { class TestClass10{ int var10 = 0; @@ -155,34 +154,28 @@ class TestClass11 extends TestClass10{ int var11 = 0; } - String tName = null; - public Thread1filter_s001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - filter_s001a.log1(" 'run': enter :: threadName == " + tName); + filter_s001a.log1(" 'run': enter :: threadName == " + getName()); TestClass11 obj1 = new TestClass11(); - filter_s001a.log1(" 'run': exit :: threadName == " + tName); + filter_s001a.log1(" 'run': exit :: threadName == " + getName()); return; } } -class Thread2filter_s001a extends Thread { - - String tName = null; +class Thread2filter_s001a extends NamedTask { public Thread2filter_s001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - filter_s001a.log1(" 'run': enter :: threadName == " + tName); + filter_s001a.log1(" 'run': enter :: threadName == " + getName()); filter_s001aTestClass21 obj2 = new filter_s001aTestClass21(); - filter_s001a.log1(" 'run': exit :: threadName == " + tName); + filter_s001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002a.java index 0395c7fc78900..65620556e12ac 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.ClassPrepareRequest.addClassFilter_s; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1filter_s002a thread1 = null; + static Thread thread1 = null; //------------------------------------------------------ common section @@ -96,7 +95,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1filter_s002a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1filter_s002a("thread1")); break; //------------------------------------------------- standard end section @@ -142,7 +141,7 @@ public void run1(Thread t) { } -class Thread1filter_s002a extends Thread { +class Thread1filter_s002a extends NamedTask { class TestClass10{ int var10 = 0; @@ -151,18 +150,14 @@ class TestClass11 extends TestClass10{ int var11 = 0; } - - String tName = null; - public Thread1filter_s002a(String threadName) { super(threadName); - tName = threadName; } public void run() { - filter_s002a.log1(" 'run': enter :: threadName == " + tName); + filter_s002a.log1(" 'run': enter :: threadName == " + getName()); TestClass11 obj1 = new TestClass11(); - filter_s002a.log1(" 'run': exit :: threadName == " + tName); + filter_s002a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod001a.java index ce6c285fa07ac..b843a177d7b73 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,6 @@ package nsk.jdi.ClassType.invokeMethod; -import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -99,8 +98,8 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - Threadinvokemethod001a test_thread = - new Threadinvokemethod001a("testedThread"); + Thread test_thread = + JDIThreadFactory.newThread(new Threadinvokemethod001a("testedThread")); log1(" thread2 is created"); label: @@ -150,7 +149,7 @@ public static void main (String argv[]) { } } -class Threadinvokemethod001a extends Thread { +class Threadinvokemethod001a extends NamedTask { public Threadinvokemethod001a(String threadName) { super(threadName); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod007a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod007a.java index ac5b4f393942b..065f8a5be9f42 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod007a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod007a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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 argv[]) { log = new Log(System.err, argHandler); waitTime = argHandler.getWaitTime() * 60000; pipe = argHandler.createDebugeeIOPipe(log); - im007aThread01 thread = null; + Thread thread = null; pipe.println(invokemethod007.SGNL_READY); String instr = pipe.readln(); @@ -54,7 +54,7 @@ public static void main (String argv[]) { // create new thread and start it if (instr.equals(invokemethod007.SGNL_STRTHRD)) { - thread = new im007aThread01("im007aThread01"); + thread = JDIThreadFactory.newThread(new im007aThread01("im007aThread01")); synchronized(im007aThread01.waitStarting) { thread.start(); try { @@ -117,7 +117,7 @@ public static long invokedMethod() { } } -class im007aThread01 extends Thread { +class im007aThread01 extends NamedTask { public static Object waitInvoking = new Object(); public static Object waitStarting = new Object(); public static Object waitFinishing = new Object(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011t.java index 48651dd30f6fc..7a22d2c9483c4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011t.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011t.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,8 +34,8 @@ */ public class invokemethod011t { static Log log; - private invokemethod011Thr thrs[] = - new invokemethod011Thr[invokemethod011.THRDS_NUM-1]; + private invokemethod011Thr thrs011[] = new invokemethod011Thr[invokemethod011.THRDS_NUM-1]; + private Thread thrs[] = new Thread[invokemethod011.THRDS_NUM-1]; private IOPipe pipe; public static void main(String args[]) { @@ -103,8 +103,8 @@ private void startThreads() { Object readyObj = new Object(); for (int i=0; i * A debugger launchs a debuggee which creates new thread, thread2.
* The tested class TestClass is specified outside of the class
- * Threadnewinstance002a extends Thread
+ * Threadnewinstance002a extends JDITask
* After getting thread2 running but locked at a monitor
* the debugger informs the debugger of the thread2 creation
* and waits for an instruction from it.
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance001a.java index 73f81f2b28522..434918cf86e6f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance001a.java @@ -23,7 +23,6 @@ package nsk.jdi.ClassType.newInstance; -import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -97,8 +96,8 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - Threadnewinstance001a test_thread = - new Threadnewinstance001a("testedThread"); + Thread test_thread = + JDIThreadFactory.newThread(new Threadnewinstance001a("testedThread")); log1(" thread2 is created"); label: @@ -169,7 +168,7 @@ int m () { } -class Threadnewinstance001a extends Thread { +class Threadnewinstance001a extends NamedTask { public Threadnewinstance001a(String threadName) { super(threadName); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance007a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance007a.java index 56b29efa38099..aabb839da7b8b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance007a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/newInstance/newinstance007a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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 argv[]) { log = new Log(System.err, argHandler); waitTime = argHandler.getWaitTime() * 60000; pipe = argHandler.createDebugeeIOPipe(log); - im007aThread01 thread = null; + Thread thread = null; pipe.println(newinstance007.SGNL_READY); String instr = pipe.readln(); @@ -54,7 +54,7 @@ public static void main (String argv[]) { // create new thread and start it if (instr.equals(newinstance007.SGNL_STRTHRD)) { - thread = new im007aThread01("im007aThread01"); + thread = JDIThreadFactory.newThread(new im007aThread01("im007aThread01")); synchronized(im007aThread01.waitStarting) { thread.start(); try { @@ -120,7 +120,7 @@ public static void main (String argv[]) { } } -class im007aThread01 extends Thread { +class im007aThread01 extends NamedTask { public static Object waitInvoking = new Object(); public static Object waitStarting = new Object(); public static Object waitFinishing = new Object(); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/equals/equals001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/equals/equals001a.java index 238137951860f..3ae622235b411 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/equals/equals001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/equals/equals001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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 argv[]) { log = new Log(System.err, argHandler); pipe = argHandler.createDebugeeIOPipe(log); try { - Thread thread1 = new equals001aThread("thread1"); + Thread thread1 = JDIThreadFactory.newThread(new equals001aThread("thread1")); synchronized (lock) { synchronized(wait) { @@ -108,7 +108,7 @@ public static void main (String argv[]) { //--------------------------------------------------------- test specific classes -class equals001aThread extends Thread { +class equals001aThread extends NamedTask { String name; @@ -126,7 +126,7 @@ public void run() { foo(); - equals001aThread1 thread2 = new equals001aThread1(); + Thread thread2 = JDIThreadFactory.newThread(new equals001aThread1()); thread2.start(); try { @@ -147,7 +147,7 @@ void foo () { } } -class equals001aThread1 extends Thread { +class equals001aThread1 implements Runnable { public void run() { } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/hashCode/hashcode001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/hashCode/hashcode001a.java index 4e04d99104842..996ccab0b3c0a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/hashCode/hashcode001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/hashCode/hashcode001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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 argv[]) { log = new Log(System.err, argHandler); pipe = argHandler.createDebugeeIOPipe(log); try { - Thread thread1 = new hashcode001aThread("thread1"); + Thread thread1 = JDIThreadFactory.newThread(new hashcode001aThread("thread1")); synchronized (lock) { synchronized(wait) { @@ -108,7 +108,7 @@ public static void main (String argv[]) { //--------------------------------------------------------- test specific classes -class hashcode001aThread extends Thread { +class hashcode001aThread extends NamedTask { String name; @@ -126,7 +126,7 @@ public void run() { foo(); - hashcode001aThread1 thread2 = new hashcode001aThread1(); + Thread thread2 = JDIThreadFactory.newThread(new hashcode001aThread1()); thread2.start(); try { @@ -147,7 +147,7 @@ void foo () { } } -class hashcode001aThread1 extends Thread { +class hashcode001aThread1 implements Runnable { public void run() { } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001a.java index ee7ebdac4329c..21a89670933eb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001a.java @@ -106,7 +106,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread2 = new Thread3request001a("thread2"); + thread2 = JDIThreadFactory.newThread(new Thread3request001a("thread2")); threadStart(thread2); try { // we should wait here for thread2 completion (see 6671428) @@ -119,9 +119,9 @@ public static void main (String argv[]) { for (int n1 = 0; n1 < threadsN; n1++) { if (n1 < threadsN-1) - threads[n1] = new Thread1request001a(threadNames[n1]); + threads[n1] = JDIThreadFactory.newThread(new Thread1request001a(threadNames[n1])); else - threads[n1] = new Thread2request001a(threadNames[n1]); + threads[n1] = JDIThreadFactory.newThread(new Thread2request001a(threadNames[n1])); } log1(" threads has been created"); @@ -183,7 +183,7 @@ public static void nullMethod() { static volatile int n = 0; - static class Thread1request001a extends Thread { + static class Thread1request001a extends NamedTask { int threadIndex; @@ -214,7 +214,7 @@ public void run() { } - static class Thread2request001a extends Thread { + static class Thread2request001a extends NamedTask { int threadIndex; @@ -249,21 +249,18 @@ private void m1() { } - static class Thread3request001a extends Thread { - - String tName = null; + static class Thread3request001a extends NamedTask { public Thread3request001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - log3(" 'run': enter :: threadName == " + tName); + log3(" 'run': enter :: threadName == " + getName()); synchronized (waitnotifyObj) { waitnotifyObj.notify(); } - log3(" 'run': exit :: threadName == " + tName); + log3(" 'run': exit :: threadName == " + getName()); } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001a.java index a1bab60410122..c65994ee36082 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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[]) { //------------------------------------------------------ section tested case 0: - thread2 = new Thread3nextevent001a("thread2"); + thread2 = JDIThreadFactory.newThread(new Thread3nextevent001a("thread2")); threadStart(thread2); try { // we should wait here for thread2 completion (see 6671428) @@ -118,9 +118,9 @@ public static void main (String argv[]) { for (int n1 = 0; n1 < threadsN; n1++) { if (n1 < threadsN-1) - threads[n1] = new Thread1nextevent001a(threadNames[n1]); + threads[n1] = JDIThreadFactory.newThread(new Thread1nextevent001a(threadNames[n1])); else - threads[n1] = new Thread2nextevent001a(threadNames[n1]); + threads[n1] = JDIThreadFactory.newThread(new Thread2nextevent001a(threadNames[n1])); } log1(" threads has been created"); @@ -182,7 +182,7 @@ public static void nullMethod() { static volatile int n = 0; - static class Thread1nextevent001a extends Thread { + static class Thread1nextevent001a extends NamedTask { int threadIndex; @@ -213,7 +213,7 @@ public void run() { } - static class Thread2nextevent001a extends Thread { + static class Thread2nextevent001a extends NamedTask { int threadIndex; @@ -248,21 +248,18 @@ private void m1() { } - static class Thread3nextevent001a extends Thread { - - String tName = null; + static class Thread3nextevent001a extends NamedTask { public Thread3nextevent001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - log3(" 'run': enter :: threadName == " + tName); + log3(" 'run': enter :: threadName == " + getName()); synchronized (waitnotifyObj) { waitnotifyObj.notify(); } - log3(" 'run': exit :: threadName == " + tName); + log3(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001a.java index ae0ff12fffe07..11b33c37e484b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequest.addCountFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1addcountfilter001a thread1 = null; + static Thread thread1 = null; static TestClass11 obj = new TestClass11(); @@ -100,7 +99,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1addcountfilter001a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1addcountfilter001a("thread1")); synchronized (lockObj) { threadStart(thread1); @@ -202,24 +201,21 @@ static void method11 () { } } -class Thread1addcountfilter001a extends Thread { - - String tName = null; +class Thread1addcountfilter001a extends NamedTask { public Thread1addcountfilter001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - addcountfilter001a.log1(" 'run': enter :: threadName == " + tName); + addcountfilter001a.log1(" 'run': enter :: threadName == " + getName()); synchronized(addcountfilter001a.waitnotifyObj) { addcountfilter001a.waitnotifyObj.notify(); } synchronized(addcountfilter001a.lockObj) { TestClass11.method11(); } - addcountfilter001a.log1(" 'run': exit :: threadName == " + tName); + addcountfilter001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable001a.java index d73f0332b86ff..66784ab03721c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequest.disable; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static disable001aThread1 thread1 = null; + static Thread thread1 = null; static disable001aTestClass11 obj = new disable001aTestClass11(); @@ -100,7 +99,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new disable001aThread1("thread1"); + thread1 = JDIThreadFactory.newThread(new disable001aThread1("thread1")); synchronized (lockObj) { threadStart(thread1); @@ -202,24 +201,21 @@ static void method11 () { } } -class disable001aThread1 extends Thread { - - String tName = null; +class disable001aThread1 extends NamedTask { public disable001aThread1(String threadName) { super(threadName); - tName = threadName; } public void run() { - disable001a.log1(" 'run': enter :: threadName == " + tName); + disable001a.log1(" 'run': enter :: threadName == " + getName()); synchronized(disable001a.waitnotifyObj) { disable001a.waitnotifyObj.notify(); } synchronized(disable001a.lockObj) { disable001aTestClass11.method11(); } - disable001a.log1(" 'run': exit :: threadName == " + tName); + disable001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002a.java index 9f5fa78e44e90..6f7cbef24f021 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002a.java @@ -204,22 +204,19 @@ static void method11 () { class disable002aThread1 extends Thread { - String tName = null; - public disable002aThread1(String threadName) { super(threadName); - tName = threadName; } public void run() { - disable002a.log1(" 'run': enter :: threadName == " + tName); + disable002a.log1(" 'run': enter :: threadName == " + getName()); synchronized(disable002a.waitnotifyObj) { disable002a.waitnotifyObj.notify(); } synchronized(disable002a.lockObj) { disable002aTestClass11.method11(); } - disable002a.log1(" 'run': exit :: threadName == " + tName); + disable002a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001a.java index d979bf28129c4..e4f6923abe5e9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001a.java @@ -204,22 +204,19 @@ static void method11 () { class enable001aThread1 extends Thread { - String tName = null; - public enable001aThread1(String threadName) { super(threadName); - tName = threadName; } public void run() { - enable001a.log1(" 'run': enter :: threadName == " + tName); + enable001a.log1(" 'run': enter :: threadName == " + getName()); synchronized(enable001a.waitnotifyObj) { enable001a.waitnotifyObj.notify(); } synchronized(enable001a.lockObj) { enable001aTestClass11.method11(); } - enable001a.log1(" 'run': exit :: threadName == " + tName); + enable001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002a.java index 1035cad5c5a20..498f6148467f5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002a.java @@ -210,22 +210,19 @@ static void method11 () { class enable002aThread1 extends Thread { - String tName = null; - public enable002aThread1(String threadName) { super(threadName); - tName = threadName; } public void run() { - enable002a.log1(" 'run': enter :: threadName == " + tName); + enable002a.log1(" 'run': enter :: threadName == " + getName()); synchronized(enable002a.waitnotifyObj) { enable002a.waitnotifyObj.notify(); } synchronized(enable002a.lockObj) { enable002aTestClass11.method11(); } - enable002a.log1(" 'run': exit :: threadName == " + tName); + enable002a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001a.java index d8c30f9ba7332..ea03c80b7717e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequest.getProperty; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1getproperty001a thread1 = null; + static Thread thread1 = null; static TestClass11 obj = new TestClass11(); @@ -100,7 +99,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1getproperty001a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1getproperty001a("thread1")); synchronized (lockObj) { threadStart(thread1); @@ -202,24 +201,21 @@ static void method11 () { } } -class Thread1getproperty001a extends Thread { - - String tName = null; +class Thread1getproperty001a extends NamedTask { public Thread1getproperty001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - getproperty001a.log1(" 'run': enter :: threadName == " + tName); + getproperty001a.log1(" 'run': enter :: threadName == " + getName()); synchronized(getproperty001a.waitnotifyObj) { getproperty001a.waitnotifyObj.notify(); } synchronized(getproperty001a.lockObj) { TestClass11.method11(); } - getproperty001a.log1(" 'run': exit :: threadName == " + tName); + getproperty001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001a.java index f366b25140cd8..32f95d8fb357e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequest.isEnabled; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1isenabled001a thread1 = null; + static Thread thread1 = null; static TestClass11 obj = new TestClass11(); @@ -100,7 +99,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1isenabled001a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1isenabled001a("thread1")); synchronized (lockObj) { threadStart(thread1); @@ -202,24 +201,21 @@ static void method11 () { } } -class Thread1isenabled001a extends Thread { - - String tName = null; +class Thread1isenabled001a extends NamedTask { public Thread1isenabled001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - isenabled001a.log1(" 'run': enter :: threadName == " + tName); + isenabled001a.log1(" 'run': enter :: threadName == " + getName()); synchronized(isenabled001a.waitnotifyObj) { isenabled001a.waitnotifyObj.notify(); } synchronized(isenabled001a.lockObj) { TestClass11.method11(); } - isenabled001a.log1(" 'run': exit :: threadName == " + tName); + isenabled001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001a.java index 6e5b815919a4c..f833754de73fe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequest.putProperty; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1putproperty001a thread1 = null; + static Thread thread1 = null; static TestClass11 obj = new TestClass11(); @@ -100,7 +99,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1putproperty001a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1putproperty001a("thread1")); synchronized (lockObj) { threadStart(thread1); @@ -202,24 +201,21 @@ static void method11 () { } } -class Thread1putproperty001a extends Thread { - - String tName = null; +class Thread1putproperty001a extends NamedTask { public Thread1putproperty001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - putproperty001a.log1(" 'run': enter :: threadName == " + tName); + putproperty001a.log1(" 'run': enter :: threadName == " + getName()); synchronized(putproperty001a.waitnotifyObj) { putproperty001a.waitnotifyObj.notify(); } synchronized(putproperty001a.lockObj) { TestClass11.method11(); } - putproperty001a.log1(" 'run': exit :: threadName == " + tName); + putproperty001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001a.java index fb1efae4e4fd8..73f17c506a1b6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequest.setEnabled; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static setenabled001aThread1 thread1 = null; + static Thread thread1 = null; static setenabled001aTestClass11 obj = new setenabled001aTestClass11(); @@ -100,7 +99,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new setenabled001aThread1("thread1"); + thread1 = JDIThreadFactory.newThread(new setenabled001aThread1("thread1")); synchronized (lockObj) { threadStart(thread1); @@ -202,24 +201,21 @@ static void method11 () { } } -class setenabled001aThread1 extends Thread { - - String tName = null; +class setenabled001aThread1 extends NamedTask { public setenabled001aThread1(String threadName) { super(threadName); - tName = threadName; } public void run() { - setenabled001a.log1(" 'run': enter :: threadName == " + tName); + setenabled001a.log1(" 'run': enter :: threadName == " + getName()); synchronized(setenabled001a.waitnotifyObj) { setenabled001a.waitnotifyObj.notify(); } synchronized(setenabled001a.lockObj) { setenabled001aTestClass11.method11(); } - setenabled001a.log1(" 'run': exit :: threadName == " + tName); + setenabled001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002a.java index 73d7954614f1e..74d506a531905 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequest.setEnabled; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static setenabled002aThread1 thread1 = null; + static Thread thread1 = null; static setenabled002aTestClass11 obj = new setenabled002aTestClass11(); @@ -100,7 +99,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new setenabled002aThread1("thread1"); + thread1 = JDIThreadFactory.newThread(new setenabled002aThread1("thread1")); synchronized (lockObj) { threadStart(thread1); @@ -208,24 +207,21 @@ static void method11 () { } } -class setenabled002aThread1 extends Thread { - - String tName = null; +class setenabled002aThread1 extends NamedTask { public setenabled002aThread1(String threadName) { super(threadName); - tName = threadName; } public void run() { - setenabled002a.log1(" 'run': enter :: threadName == " + tName); + setenabled002a.log1(" 'run': enter :: threadName == " + getName()); synchronized(setenabled002a.waitnotifyObj) { setenabled002a.waitnotifyObj.notify(); } synchronized(setenabled002a.lockObj) { setenabled002aTestClass11.method11(); } - setenabled002a.log1(" 'run': exit :: threadName == " + tName); + setenabled002a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003a.java index bc22fdd2846f7..438a5d55e3e0a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequest.setEnabled; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1setenabled003a thread1 = null; + static Thread thread1 = null; //------------------------------------------------------ common section @@ -96,7 +95,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1setenabled003a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1setenabled003a("thread1")); Thread1setenabled003a.method(); break; @@ -152,23 +151,20 @@ static int threadStart(Thread t) { } } -class Thread1setenabled003a extends Thread { - - String tName = null; +class Thread1setenabled003a extends NamedTask { public Thread1setenabled003a(String threadName) { super(threadName); - tName = threadName; } public void run() { - setenabled003a.log1(" 'run': enter :: threadName == " + tName); + setenabled003a.log1(" 'run': enter :: threadName == " + getName()); synchronized(setenabled003a.waitnotifyObj) { setenabled003a.waitnotifyObj.notify(); } synchronized(setenabled003a.lockObj) { - setenabled003a.log1(" 'run': exit :: threadName == " + tName); + setenabled003a.log1(" 'run': exit :: threadName == " + getName()); } return; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001a.java index 56466e106c4b7..7a0b5097fbe6d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequest.setSuspendPolicy; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1setsuspendpolicy001a thread1 = null; + static Thread thread1 = null; static TestClass11 obj = new TestClass11(); @@ -100,7 +99,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1setsuspendpolicy001a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1setsuspendpolicy001a("thread1")); synchronized (lockObj) { threadStart(thread1); @@ -202,24 +201,21 @@ static void method11 () { } } -class Thread1setsuspendpolicy001a extends Thread { - - String tName = null; +class Thread1setsuspendpolicy001a extends NamedTask { public Thread1setsuspendpolicy001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - setsuspendpolicy001a.log1(" 'run': enter :: threadName == " + tName); + setsuspendpolicy001a.log1(" 'run': enter :: threadName == " + getName()); synchronized(setsuspendpolicy001a.waitnotifyObj) { setsuspendpolicy001a.waitnotifyObj.notify(); } synchronized(setsuspendpolicy001a.lockObj) { TestClass11.method11(); } - setsuspendpolicy001a.log1(" 'run': exit :: threadName == " + tName); + setsuspendpolicy001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001a.java index 62735c77ef87c..144d538cf2735 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequest.suspendPolicy; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1suspendpolicy001a thread1 = null; + static Thread thread1 = null; static TestClass11 obj = new TestClass11(); @@ -100,7 +99,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1suspendpolicy001a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1suspendpolicy001a("thread1")); synchronized (lockObj) { threadStart(thread1); @@ -202,24 +201,21 @@ static void method11 () { } } -class Thread1suspendpolicy001a extends Thread { - - String tName = null; +class Thread1suspendpolicy001a extends NamedTask { public Thread1suspendpolicy001a(String threadName) { super(threadName); - tName = threadName; } public void run() { - suspendpolicy001a.log1(" 'run': enter :: threadName == " + tName); + suspendpolicy001a.log1(" 'run': enter :: threadName == " + getName()); synchronized(suspendpolicy001a.waitnotifyObj) { suspendpolicy001a.waitnotifyObj.notify(); } synchronized(suspendpolicy001a.lockObj) { TestClass11.method11(); } - suspendpolicy001a.log1(" 'run': exit :: threadName == " + tName); + suspendpolicy001a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002a.java index 150e41fbd3659..7d1fa87ab5552 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequestManager.createStepRequest; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -54,7 +53,7 @@ private static void logErr(String message) { //====================================================== test program - static Thread1crstepreq002a thread1 = null; + static Thread thread1 = null; static TestClass10 obj = new TestClass10(); @@ -98,7 +97,7 @@ public static void main (String argv[]) { //------------------------------------------------------ section tested case 0: - thread1 = new Thread1crstepreq002a("thread1"); + thread1 = JDIThreadFactory.newThread(new Thread1crstepreq002a("thread1")); synchronized (lockObj) { threadStart(thread1); @@ -149,24 +148,21 @@ static void m11() { } } -class Thread1crstepreq002a extends Thread { - - String tName = null; +class Thread1crstepreq002a extends NamedTask { public Thread1crstepreq002a(String threadName) { super(threadName); - tName = threadName; } public void run() { - crstepreq002a.log1(" 'run': enter :: threadName == " + tName); + crstepreq002a.log1(" 'run': enter :: threadName == " + getName()); synchronized(crstepreq002a.waitnotifyObj) { crstepreq002a.waitnotifyObj.notify(); } synchronized(crstepreq002a.lockObj) { TestClass11.m11(); } - crstepreq002a.log1(" 'run': exit :: threadName == " + tName); + crstepreq002a.log1(" 'run': exit :: threadName == " + getName()); return; } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003a.java index e00752db4fbad..460dc8e92f1ee 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq003a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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,21 +72,21 @@ public static void main (String argv[]) { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test case section case 0: - Thread thread0 = new Thread0crstepreq003a("thread0"); + Thread thread0 = JDIThreadFactory.newThread(new Thread0crstepreq003a("thread0")); threadStart(thread0); threadJoin (thread0, "0"); break; case 1: - Thread thread1 = new Thread0crstepreq003a("thread1"); + Thread thread1 = JDIThreadFactory.newThread(new Thread0crstepreq003a("thread1")); threadStart(thread1); threadJoin (thread1, "1"); break; case 2: - Thread thread2 = new Thread0crstepreq003a("thread2"); + Thread thread2 = JDIThreadFactory.newThread(new Thread0crstepreq003a("thread2")); threadStart(thread2); threadJoin (thread2, "2"); @@ -160,7 +160,7 @@ private static void methodForCommunication() { /** * This thread will be suspended on breakpoint. No locks are used. */ -class Thread0crstepreq003a extends Thread { +class Thread0crstepreq003a extends NamedTask { public Thread0crstepreq003a (String name) { super(name); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004a.java index 2f760c4dad2b1..881d211aa0e96 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq004a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,8 +95,8 @@ public static void main (String argv[]) { private static void runTestCase(int testCaseId) { isFirstThreadReady = false; isSecondThreadReady = false; - Thread thread1 = new Thread1crstepreq004a("thread1"); - Thread thread2 = new Thread2crstepreq004a("thread2"); + Thread thread1 = JDIThreadFactory.newThread(new Thread1crstepreq004a("thread1")); + Thread thread2 = JDIThreadFactory.newThread(new Thread2crstepreq004a("thread2")); synchronized (lockObj) { thread1.start(); while (!isFirstThreadReady) { @@ -167,7 +167,7 @@ static void lockAndNotify2() { /** * First thread which owns and locks the crstepreq004a.lockObj1 monitor . */ -class Thread1crstepreq004a extends Thread { +class Thread1crstepreq004a extends NamedTask { public Thread1crstepreq004a (String name) { super(name); } @@ -182,7 +182,7 @@ public void run() { /** * Second thread which who owns the crstepreq004a.lockObj1 monitor . */ -class Thread2crstepreq004a extends Thread { +class Thread2crstepreq004a extends NamedTask { public Thread2crstepreq004a (String name) { super(name); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq005a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq005a.java index 10edb3d96a873..e3afc7540d2c1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq005a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq005a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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,11 +24,11 @@ package nsk.jdi.EventRequestManager.createStepRequest; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; // THIS TEST IS LINE NUMBER SENSITIVE + /** * The debugged application of the test. */ @@ -83,7 +83,7 @@ public static void main (String argv[]) { label0: for (int testCase = 0; testCase < maxCase && instruction != quit; testCase++) { - thread1 = new Thread0crstepreq005a(testCase); + thread1 = JDIThreadFactory.newThread(new Thread0crstepreq005a(testCase)); threadStart(thread1); threadJoin (thread1, testCase); @@ -125,7 +125,7 @@ static int threadStart (Thread t) { /** * This thread will be suspended on breakpoint. No locks are used. */ -class Thread0crstepreq005a extends Thread { +class Thread0crstepreq005a extends NamedTask { int testCase; public Thread0crstepreq005a (int testCase) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq006a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq006a.java index 26f0681064f3c..429496bbf7627 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq006a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq006a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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,11 +24,11 @@ package nsk.jdi.EventRequestManager.createStepRequest; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; // THIS TEST IS LINE NUMBER SENSITIVE + /** * The debugged application of the test. */ @@ -83,7 +83,7 @@ public static void main (String argv[]) { label0: for (int testCase = 0; testCase < maxCase && instruction != quit; testCase++) { - thread1 = new Thread0crstepreq006a(testCase); + thread1 = JDIThreadFactory.newThread(new Thread0crstepreq006a(testCase)); threadStart(thread1); threadJoin (thread1, testCase); @@ -125,7 +125,7 @@ static int threadStart (Thread t) { /** * This thread will be suspended on breakpoint. No locks are used. */ -class Thread0crstepreq006a extends Thread { +class Thread0crstepreq006a extends NamedTask { int testCase; public Thread0crstepreq006a (int testCase) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq007a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq007a.java index 5000cf0c7e687..d8a9121ec5c73 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq007a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq007a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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,11 +24,11 @@ package nsk.jdi.EventRequestManager.createStepRequest; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; // THIS TEST IS LINE NUMBER SENSITIVE + /** * The debugged application of the test. */ @@ -83,7 +83,7 @@ public static void main (String argv[]) { label0: for (int testCase = 0; testCase < maxCase && instruction != quit; testCase++) { - thread1 = new Thread0crstepreq007a(testCase); + thread1 = JDIThreadFactory.newThread(new Thread0crstepreq007a(testCase)); threadStart(thread1); threadJoin (thread1, testCase); @@ -125,7 +125,7 @@ static int threadStart (Thread t) { /** * This thread will be suspended on breakpoint. No locks are used. */ -class Thread0crstepreq007a extends Thread { +class Thread0crstepreq007a extends NamedTask { int testCase; public Thread0crstepreq007a (int testCase) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq008a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq008a.java index 64f20c1fe2684..62b750f001030 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq008a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq008a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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,11 +24,11 @@ package nsk.jdi.EventRequestManager.createStepRequest; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; // THIS TEST IS LINE NUMBER SENSITIVE + /** * The debugged application of the test. */ @@ -83,7 +83,7 @@ public static void main (String argv[]) { label0: for (int testCase = 0; testCase < maxCase && instruction != quit; testCase++) { - thread1 = new Thread0crstepreq008a(testCase); + thread1 = JDIThreadFactory.newThread(new Thread0crstepreq008a(testCase)); threadStart(thread1); threadJoin (thread1, testCase); @@ -125,7 +125,7 @@ static int threadStart (Thread t) { /** * This thread will be suspended on breakpoint. No locks are used. */ -class Thread0crstepreq008a extends Thread { +class Thread0crstepreq008a extends NamedTask { int testCase; public Thread0crstepreq008a (int testCase) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq009a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq009a.java index 8df51baa8b26f..0de8288ca8222 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq009a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq009a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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,11 +24,11 @@ package nsk.jdi.EventRequestManager.createStepRequest; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; // THIS TEST IS LINE NUMBER SENSITIVE + /** * The debugged application of the test. */ @@ -83,7 +83,7 @@ public static void main (String argv[]) { label0: for (int testCase = 0; testCase < maxCase && instruction != quit; testCase++) { - thread1 = new Thread0crstepreq009a(testCase); + thread1 = JDIThreadFactory.newThread(new Thread0crstepreq009a(testCase)); threadStart(thread1); threadJoin (thread1, testCase); @@ -125,7 +125,7 @@ static int threadStart (Thread t) { /** * This thread will be suspended on breakpoint. No locks are used. */ -class Thread0crstepreq009a extends Thread { +class Thread0crstepreq009a extends NamedTask { int testCase; public Thread0crstepreq009a (int testCase) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq010a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq010a.java index 2b9d71c0d6935..61b87f0d02abe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq010a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq010a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. * 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,11 +24,11 @@ package nsk.jdi.EventRequestManager.createStepRequest; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; // THIS TEST IS LINE NUMBER SENSITIVE + /** * The debugged application of the test. */ @@ -83,7 +83,7 @@ public static void main (String argv[]) { label0: for (int testCase = 0; testCase < maxCase && instruction != quit; testCase++) { - thread1 = new Thread0crstepreq010a(testCase); + thread1 = JDIThreadFactory.newThread(new Thread0crstepreq010a(testCase)); threadStart(thread1); threadJoin (thread1, testCase); @@ -125,7 +125,7 @@ static int threadStart (Thread t) { /** * This thread will be suspended on breakpoint. No locks are used. */ -class Thread0crstepreq010a extends Thread { +class Thread0crstepreq010a extends NamedTask { int testCase; public Thread0crstepreq010a (int testCase) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002a.java index 519654834dfc9..2016d1d9142ee 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,7 +24,6 @@ package nsk.jdi.EventRequestManager.deleteEventRequest; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -56,7 +55,7 @@ private static void logErr(String message) { static int testField1 = 0; static NullPointerException testField2 = new NullPointerException("test"); - static Thread1delevtreq002a testField3 = null; + static Thread testField3 = null; //------------------------------------------------------ common section @@ -99,7 +98,7 @@ public static void main (String argv[]) { case 0: synchronized (lockObj1) { - testField3 = new Thread1delevtreq002a("thread1"); + testField3 = JDIThreadFactory.newThread(new Thread1delevtreq002a("thread1")); threadStart(testField3); methodForCommunication(); } @@ -136,22 +135,19 @@ static int threadStart(Thread t) { } } -class Thread1delevtreq002a extends Thread { - - String tName = null; +class Thread1delevtreq002a extends NamedTask { public Thread1delevtreq002a(String threadName) { super(threadName); - tName = threadName; } public void run() { - delevtreq002a.log1(" 'run': enter :: threadName == " + tName); + delevtreq002a.log1(" 'run': enter :: threadName == " + getName()); synchronized(delevtreq002a.waitnotifyObj) { delevtreq002a.waitnotifyObj.notify(); } synchronized(delevtreq002a.lockObj1) { - delevtreq002a.log1(" 'run': exit :: threadName == " + tName); + delevtreq002a.log1(" 'run': exit :: threadName == " + getName()); } return; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002a.java index 7ade8be26c405..d8f3abf44b4aa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002a.java @@ -24,7 +24,6 @@ package nsk.jdi.EventRequestManager.deleteEventRequests; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; /** @@ -56,7 +55,7 @@ private static void logErr(String message) { static int testField1 = 0; static NullPointerException testField2 = new NullPointerException("test"); - static Thread1delevtreqs002a testField3[] = new Thread1delevtreqs002a[10]; + static Thread testField3[] = new Thread[10]; //------------------------------------------------------ common section @@ -100,7 +99,7 @@ public static void main (String argv[]) { case 0: synchronized (lockObj1) { for (int ii = 0; ii < 10; ii++) { - testField3[ii] = new Thread1delevtreqs002a("thread" + ii); + testField3[ii] = JDIThreadFactory.newThread(new Thread1delevtreqs002a("thread" + ii)); threadStart(testField3[ii]); } methodForCommunication(); @@ -138,22 +137,19 @@ static int threadStart(Thread t) { } -class Thread1delevtreqs002a extends Thread { - - String tName = null; +class Thread1delevtreqs002a extends NamedTask { public Thread1delevtreqs002a(String threadName) { super(threadName); - tName = threadName; } public void run() { - delevtreqs002a.log1(" 'run': enter :: threadName == " + tName); + delevtreqs002a.log1(" 'run': enter :: threadName == " + getName()); synchronized(delevtreqs002a.waitnotifyObj) { delevtreqs002a.waitnotifyObj.notify(); } synchronized(delevtreqs002a.lockObj1) { - delevtreqs002a.log1(" 'run': exit :: threadName == " + tName); + delevtreqs002a.log1(" 'run': exit :: threadName == " + getName()); } return; } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq001t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq001t.java index f24451f14f0d1..cf2191d9dfd32 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq001t.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq001t.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. * 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,6 @@ package nsk.jdi.EventRequestManager.stepRequests; -import nsk.share.*; import nsk.share.jpda.*; import nsk.share.jdi.*; @@ -61,8 +60,8 @@ private int runThis(String args[]) { // Get a monitor in order to prevent the threads from exiting synchronized(lockObj) { for (int i=1; i new Thread(r); + + public static Thread newThread(NamedTask task) { + return newThread(task, task.getName()); + } + + + public static Thread newThread(Runnable task) { + return threadFactory.newThread(task); + } + + public static Thread newThread(Runnable task, String name) { + Thread t = threadFactory.newThread(task); + t.setName(name); + return t; + } +} diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/NamedTask.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/NamedTask.java new file mode 100644 index 0000000000000..466775f2d2dd8 --- /dev/null +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/NamedTask.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package nsk.share.jdi; + +public abstract class NamedTask implements Runnable { + private String name; + + public NamedTask(String name) { + this.name = name; + } + + @Override + public abstract void run(); + + public String getName() { + return name; + } + +} From 0a4c4235626269d37dc697b7de0486b0c5eb87b0 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 11 Oct 2023 07:54:50 +0000 Subject: [PATCH 219/341] 8287596: Reorg jdk.test.lib.util.ForceGC Reviewed-by: lucy Backport-of: 82a8bd7e92a1867b0c82f051361938be8610428d --- .../TestOSCClassLoaderLeak.java | 11 ++- .../nativeLibrary/NativeLibraryTest.java | 5 +- .../defineHiddenClass/UnloadingTest.java | 13 ++- .../ReflectionCallerCacheTest.java | 6 +- .../pkcs11/Provider/MultipleLogins.java | 4 +- test/lib/jdk/test/lib/util/ForceGC.java | 80 ++++++++----------- 6 files changed, 49 insertions(+), 70 deletions(-) diff --git a/test/jdk/java/io/ObjectStreamClass/TestOSCClassLoaderLeak.java b/test/jdk/java/io/ObjectStreamClass/TestOSCClassLoaderLeak.java index 3a99760bb6ebb..1816aa45fe7ef 100644 --- a/test/jdk/java/io/ObjectStreamClass/TestOSCClassLoaderLeak.java +++ b/test/jdk/java/io/ObjectStreamClass/TestOSCClassLoaderLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. * 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,8 +30,8 @@ import java.io.Serializable; import java.util.Arrays; import org.testng.annotations.Test; -import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.assertFalse; import jdk.test.lib.util.ForceGC; @@ -54,15 +54,14 @@ public void testClassLoaderLeak() throws Exception { objectStreamClass_MemoryLeakExample.toString(); WeakReference myOwnClassLoaderWeakReference = new WeakReference<>(myOwnClassLoader); - assertNotNull(myOwnClassLoaderWeakReference.get()); + assertFalse(myOwnClassLoaderWeakReference.refersTo(null)); objectStreamClass_MemoryLeakExample = null; myOwnClassLoader = null; loadClass = null; con = null; - assertNotNull(myOwnClassLoaderWeakReference.get()); + assertFalse(myOwnClassLoaderWeakReference.refersTo(null)); - ForceGC gc = new ForceGC(); - assertTrue(gc.await(() -> myOwnClassLoaderWeakReference.get() == null)); + assertTrue(ForceGC.wait(() -> myOwnClassLoaderWeakReference.refersTo(null))); } } diff --git a/test/jdk/java/lang/ClassLoader/nativeLibrary/NativeLibraryTest.java b/test/jdk/java/lang/ClassLoader/nativeLibrary/NativeLibraryTest.java index ab7194713d5ac..46de24d1bcd42 100644 --- a/test/jdk/java/lang/ClassLoader/nativeLibrary/NativeLibraryTest.java +++ b/test/jdk/java/lang/ClassLoader/nativeLibrary/NativeLibraryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. * 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,9 +66,8 @@ public static void main(String... args) throws Exception { // Unload the class loader and native library, and give the Cleaner // thread a chance to unload the native library. // unloadedCount is incremented when the native library is unloaded. - ForceGC gc = new ForceGC(); final int finalCount = count; - if (!gc.await(() -> finalCount == unloadedCount)) { + if (!ForceGC.wait(() -> finalCount == unloadedCount)) { throw new RuntimeException("Expected unloaded=" + count + " but got=" + unloadedCount); } diff --git a/test/jdk/java/lang/invoke/defineHiddenClass/UnloadingTest.java b/test/jdk/java/lang/invoke/defineHiddenClass/UnloadingTest.java index c3cdb2b709552..2e5c4837282bd 100644 --- a/test/jdk/java/lang/invoke/defineHiddenClass/UnloadingTest.java +++ b/test/jdk/java/lang/invoke/defineHiddenClass/UnloadingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -214,18 +214,15 @@ private HiddenClassUnloader(Class hc) { } void unload() { - // Force garbage collection to trigger unloading of class loader and native library - ForceGC gc = new ForceGC(); - assertTrue(gc.await(() -> weakRef.get() == null)); - - if (weakRef.get() != null) { + // Force garbage collection to trigger unloading of class loader + // and native library. + if (!ForceGC.wait(() -> weakRef.refersTo(null))) { throw new RuntimeException("loader " + " not unloaded!"); } } boolean tryUnload() { - ForceGC gc = new ForceGC(); - return gc.await(() -> weakRef.get() == null); + return ForceGC.wait(() -> weakRef.refersTo(null)); } } diff --git a/test/jdk/java/lang/reflect/callerCache/ReflectionCallerCacheTest.java b/test/jdk/java/lang/reflect/callerCache/ReflectionCallerCacheTest.java index f245fb55f694d..47dfa5a019dc1 100644 --- a/test/jdk/java/lang/reflect/callerCache/ReflectionCallerCacheTest.java +++ b/test/jdk/java/lang/reflect/callerCache/ReflectionCallerCacheTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. * 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,9 +107,7 @@ private void load(String classname) throws Exception { WeakReference weakLoader = loadAndRunClass(classname); // Force garbage collection to trigger unloading of class loader - new ForceGC().await(() -> weakLoader.get() == null); - - if (weakLoader.get() != null) { + if (!ForceGC.wait(() -> weakLoader.refersTo(null))) { throw new RuntimeException("Class " + classname + " not unloaded!"); } } diff --git a/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.java b/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.java index 0a507f0a6334f..5d6fb68aceba3 100644 --- a/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.java +++ b/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.java @@ -89,10 +89,8 @@ public static void main(String[] args) throws Exception { Security.removeProvider(providers[i].getName()); providers[i] = null; - ForceGC gc = new ForceGC(); int finalI = i; - gc.await(() -> weakRef[finalI].get() == null); - if (!weakRef[i].refersTo(null)) { + if (!ForceGC.wait(() -> weakRef[finalI].refersTo(null))) { throw new RuntimeException("Expected SunPKCS11 Provider to be GC'ed.."); } } diff --git a/test/lib/jdk/test/lib/util/ForceGC.java b/test/lib/jdk/test/lib/util/ForceGC.java index 1a71dd229d11f..3c9ebc4d35e1e 100644 --- a/test/lib/jdk/test/lib/util/ForceGC.java +++ b/test/lib/jdk/test/lib/util/ForceGC.java @@ -23,68 +23,56 @@ package jdk.test.lib.util; -import java.lang.ref.Cleaner; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; +import java.lang.ref.PhantomReference; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; import java.util.function.BooleanSupplier; /** * Utility class to invoke System.gc() */ public class ForceGC { - private final static Cleaner cleaner = Cleaner.create(); - - private final CountDownLatch cleanerInvoked; - private Object o; - private int gcCount = 0; - - public ForceGC() { - this.o = new Object(); - this.cleanerInvoked = new CountDownLatch(1); - cleaner.register(o, cleanerInvoked::countDown); - } - - private void doit(int iter) { - try { - for (int i = 0; i < 10; i++) { - System.gc(); - gcCount++; - if (cleanerInvoked.await(100L, TimeUnit.MILLISECONDS)) { - return; - } - } - } catch (InterruptedException unexpected) { - throw new AssertionError("unexpected InterruptedException"); - } - } + // The jtreg testing timeout factor. + private static final double TIMEOUT_FACTOR = Double.valueOf( + System.getProperty("test.timeout.factor", "1.0")); /** - * Causes the current thread to wait until the {@code BooleanSupplier} returns true, - * unless the thread is interrupted or a predefined waiting time elapses. + * Causes the current thread to wait until the {@code booleanSupplier} + * returns true, or a specific waiting time elapses. The waiting time + * is 1 second scaled with the jtreg testing timeout factor. * - * @param s boolean supplier - * @return true if the {@code BooleanSupplier} returns true and false if - * the predefined waiting time elapsed before the count reaches zero. - * @throws InterruptedException if the current thread is interrupted while waiting + * @param booleanSupplier boolean supplier + * @return true if the {@code booleanSupplier} returns true, or false + * if did not complete after the specific waiting time. */ - public boolean await(BooleanSupplier s) { - o = null; // Keep reference to Object until now, to ensure the Cleaner - // doesn't count down the latch before await() is called. - for (int i = 0; i < 10; i++) { - if (s.getAsBoolean()) { - System.out.println("ForceGC condition met after System.gc() " + gcCount + " times"); + public static boolean wait(BooleanSupplier booleanSupplier) { + ReferenceQueue queue = new ReferenceQueue<>(); + Object obj = new Object(); + PhantomReference ref = new PhantomReference<>(obj, queue); + obj = null; + Reference.reachabilityFence(obj); + Reference.reachabilityFence(ref); + + int retries = (int)(Math.round(1000L * TIMEOUT_FACTOR) / 200); + for (; retries >= 0; retries--) { + if (booleanSupplier.getAsBoolean()) { return true; } - doit(i); + System.gc(); + try { - Thread.sleep(100); - } catch (InterruptedException e) { - throw new AssertionError("unexpected interrupted sleep", e); + // The remove() will always block for the specified milliseconds + // if the reference has already been removed from the queue. + // But it is fine. For most cases, the 1st GC is sufficient + // to trigger and complete the cleanup. + queue.remove(200L); + } catch (InterruptedException ie) { + // ignore, the loop will try again } } - System.out.println("ForceGC condition not met after System.gc() " + gcCount + " times"); - return false; + return booleanSupplier.getAsBoolean(); } } + From a3872053b84dc6d74281d5b24c95b60774585cda Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 11 Oct 2023 08:03:10 +0000 Subject: [PATCH 220/341] 8294881: test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003/TestDescription.java fails Backport-of: 216c6f63409e60604beb3c4f0e1e0661b1124f8f --- .../VirtualMachine/dispose/dispose002a.java | 7 +-- .../VirtualMachine/dispose/dispose003a.java | 8 ++-- .../VirtualMachine/dispose/dispose004a.java | 8 ++-- .../VirtualMachine/dispose/dispose005a.java | 8 ++-- .../vmTestbase/nsk/share/jdi/JDIUtils.java | 44 +++++++++++++++++++ 5 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIUtils.java diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java index 07847d35c2416..6d5e08bfde073 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * 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,8 +133,9 @@ public static void main (String argv[]) { } break; } else if (instruction.equals("check_alive")) { - log1("checking on: thread2.isAlive"); - if (test_thread.isAlive()) { + log1("checking if thread2 completed"); + if (!JDIUtils.waitForCompletion(test_thread)) { + log1("thread2 is alive after vm.dispose()."); pipe.println("alive"); test_thread.interrupt(); } else { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java index 0b484c84495b0..a8d1fa6336e48 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -135,9 +135,11 @@ public static void main (String argv[]) { break; } else if (instruction.equals("check_alive")) { log1("checking on: thread2.isAlive"); - if (test_thread.isAlive()) { - test_thread.resume(); + if (!JDIUtils.waitForCompletion(test_thread)) { pipe.println("alive"); + logErr("ERROR thread is alive after vm.dispose()"); + exitCode = FAILED; + break; } else { pipe.println("not_alive"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java index 4d8e29f22e547..ef6412000b910 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * 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,9 +136,11 @@ public static void main (String argv[]) { break; } else if (instruction.equals("check_alive")) { log1("checking on: thread2.isAlive"); - if (test_thread.isAlive()) { - test_thread.resume(); + if (!JDIUtils.waitForCompletion(test_thread)) { pipe.println("alive"); + logErr("ERROR thread is alive after vm.dispose()"); + exitCode = FAILED; + break; } else { pipe.println("not_alive"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose005a.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose005a.java index a6cb14f5fd9f7..31084a9ea384c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose005a.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose005a.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -152,10 +152,12 @@ public static void main (String argv[]) { logErr("ERROR: unexpected instruction: " + instruction); exitCode = FAILED; } else { - log1("checking on: testedThread.isAlive"); + log1("checking on: test_thread.done"); if (!test_thread.done) { - test_thread.resume(); pipe.println("alive"); + logErr("ERROR test_thread.done is false after vm.dispose()"); + exitCode = FAILED; + break; } else { pipe.println("not_alive"); } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIUtils.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIUtils.java new file mode 100644 index 0000000000000..f1f25906fb445 --- /dev/null +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIUtils.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package nsk.share.jdi; + +public class JDIUtils { + + /* + * Wait until thread is no longer alive, but only wait + * for a short period of time since it shouldn't take long. + */ + public static boolean waitForCompletion(Thread thread) { + for (int attempt = 1; attempt <= 5; attempt++) { + if (!thread.isAlive()) { + return true; + } + try { + Thread.sleep(attempt * 1000); + } catch (InterruptedException ie) { + } + } + return false; + } +} From 92398a6d8519b024efc9c2b90c71b64ed0343ec5 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 11 Oct 2023 08:16:39 +0000 Subject: [PATCH 221/341] 8300727: java/awt/List/ListGarbageCollectionTest/AwtListGarbageCollectionTest.java failed with "List wasn't garbage collected" Backport-of: f835aaafc7332d324ca9b08b2a34539fc1c573aa --- .../AwtListGarbageCollectionTest.java | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/test/jdk/java/awt/List/ListGarbageCollectionTest/AwtListGarbageCollectionTest.java b/test/jdk/java/awt/List/ListGarbageCollectionTest/AwtListGarbageCollectionTest.java index 56ab900c93bd1..77fa7538aed5d 100644 --- a/test/jdk/java/awt/List/ListGarbageCollectionTest/AwtListGarbageCollectionTest.java +++ b/test/jdk/java/awt/List/ListGarbageCollectionTest/AwtListGarbageCollectionTest.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 @@ -21,21 +21,28 @@ * questions. */ -/** +import java.awt.Frame; +import java.awt.List; +import java.lang.ref.PhantomReference; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; + +import jdk.test.lib.util.ForceGC; + +/* * @test * @key headful * @bug 8040076 * @summary AwtList not garbage collected - * @run main/othervm -Xmx100m AwtListGarbageCollectionTest + * @library /test/lib/ + * @build jdk.test.lib.util.ForceGC + * @run main/othervm -Xmx100m -Xlog:gc=debug AwtListGarbageCollectionTest */ +public class AwtListGarbageCollectionTest { -import java.awt.*; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.lang.ref.WeakReference; + private static final long ENQUEUE_TIMEOUT = 50; -public class AwtListGarbageCollectionTest { - public static void main(String[] args) { + public static void main(String[] args) throws InterruptedException { Frame frame = new Frame("List leak test"); try { test(frame); @@ -45,29 +52,32 @@ public static void main(String[] args) { } private static void test(Frame frame) { - WeakReference weakListRef = null; - try { - frame.setSize(300, 200); - frame.setVisible(true); + frame.setSize(300, 200); + frame.setVisible(true); - List strongListRef = new List(); - frame.add(strongListRef); - strongListRef.setMultipleMode(true); - frame.remove(strongListRef); - weakListRef = new WeakReference(strongListRef); - strongListRef = null; + List strongListRef = new List(); + frame.add(strongListRef); + strongListRef.setMultipleMode(true); + frame.remove(strongListRef); - //make out of memory to force gc - String veryLongString = new String(new char[100]); - while (true) { - veryLongString += veryLongString; - } - } catch (OutOfMemoryError e) { - if (weakListRef == null) { - throw new RuntimeException("Weak list ref wasn't created"); - } else if (weakListRef.get() != null) { - throw new RuntimeException("List wasn't garbage collected"); - } + final ReferenceQueue referenceQueue = new ReferenceQueue<>(); + final PhantomReference phantomListRef = + new PhantomReference<>(strongListRef, referenceQueue); + System.out.println("phantomListRef: " + phantomListRef); + + strongListRef = null; // Clear the strong reference + + System.out.println("Waiting for the reference to be cleared"); + if (!ForceGC.wait(() -> phantomListRef == remove(referenceQueue))) { + throw new RuntimeException("List wasn't garbage collected"); + } + } + + private static Reference remove(ReferenceQueue queue) { + try { + return queue.remove(ENQUEUE_TIMEOUT); + } catch (InterruptedException e) { + throw new RuntimeException(e); } } } From 5e0be4886b2923309a820d2d6230d9071430ebc7 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 11 Oct 2023 08:18:55 +0000 Subject: [PATCH 222/341] 8284047: Harmonize/Standardize the SSLSocket/SSLEngine/SSLSocketSSLEngine test templates Reviewed-by: lucy Backport-of: 824a5e4c605d4aee55252bce5364fa01de525e1b --- .../ssl/ALPN/MyX509ExtendedKeyManager.java | 138 -- .../javax/net/ssl/ALPN/SSLEngineAlpnTest.java | 5 - .../net/ssl/ALPN/SSLServerSocketAlpnTest.java | 287 +--- .../javax/net/ssl/ALPN/SSLSocketAlpnTest.java | 273 +--- .../HandshakeWithInvalidRecordVersion.java | 12 +- .../net/ssl/TLSv12/DisabledShortRSAKeys.java | 168 +-- .../net/ssl/templates/SSLContextTemplate.java | 1321 +++++++++++------ .../net/ssl/templates/SSLEngineTemplate.java | 2 +- .../templates/SSLSocketSSLEngineTemplate.java | 532 ------- .../net/ssl/templates/SSLSocketTemplate.java | 740 +-------- .../sun/security/ssl/ALPN/AlpnGreaseTest.java | 2 +- .../ssl/CipherSuite/DisabledCurve.java | 20 +- .../CipherSuite/RestrictSignatureScheme.java | 135 +- .../SSLEngineBadBufferArrayAccess.java | 103 +- .../ssl/SSLSessionImpl/InvalidateSession.java | 2 +- .../SSLSocketImpl/ClientSocketCloseHang.java | 2 +- .../SSLSocketBruceForceClose.java | 135 +- .../SSLSocketBruteForceClose.java | 102 ++ .../ssl/SSLSocketImpl/SSLSocketClose.java | 168 +-- .../SocketExceptionForSocketIssues.java | 150 +- .../SigAlgosExtTestWithTLS12.java | 135 +- .../ssl/SignatureScheme/Tls13NamedGroups.java | 137 +- .../ssl/X509TrustManagerImpl/TooManyCAs.java | 165 +- 23 files changed, 1331 insertions(+), 3403 deletions(-) delete mode 100644 test/jdk/javax/net/ssl/ALPN/MyX509ExtendedKeyManager.java delete mode 100644 test/jdk/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java create mode 100644 test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketBruteForceClose.java diff --git a/test/jdk/javax/net/ssl/ALPN/MyX509ExtendedKeyManager.java b/test/jdk/javax/net/ssl/ALPN/MyX509ExtendedKeyManager.java deleted file mode 100644 index ecd7dcfc4ebf4..0000000000000 --- a/test/jdk/javax/net/ssl/ALPN/MyX509ExtendedKeyManager.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.net.Socket; -import java.security.Principal; -import java.security.PrivateKey; -import java.security.cert.X509Certificate; -import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLSocket; -import javax.net.ssl.X509ExtendedKeyManager; - -public class MyX509ExtendedKeyManager extends X509ExtendedKeyManager { - - static final String ERROR = "ERROR"; - X509ExtendedKeyManager akm; - String expectedAP; - boolean doCheck = true; - - MyX509ExtendedKeyManager(X509ExtendedKeyManager akm) { - this.akm = akm; - } - - public MyX509ExtendedKeyManager( - X509ExtendedKeyManager akm, String expectedAP, boolean doCheck) { - this.akm = akm; - this.expectedAP = expectedAP; - this.doCheck = doCheck; - - } - - @Override - public String[] getClientAliases(String keyType, Principal[] issuers) { - return akm.getClientAliases(keyType, issuers); - } - - @Override - public String chooseClientAlias(String[] keyType, Principal[] issuers, - Socket socket) { - String nap = ((SSLSocket) socket).getHandshakeApplicationProtocol(); - checkALPN(nap); - - return akm.chooseClientAlias(keyType, issuers, socket); - } - - @Override - public String[] getServerAliases(String keyType, Principal[] issuers) { - return akm.getServerAliases(keyType, issuers); - } - - @Override - public String chooseServerAlias(String keyType, Principal[] issuers, - Socket socket) { - String nap = ((SSLSocket) socket).getHandshakeApplicationProtocol(); - checkALPN(nap); - - return akm.chooseServerAlias(keyType, issuers, socket); - } - - @Override - public X509Certificate[] getCertificateChain(String alias) { - return akm.getCertificateChain(alias); - } - - @Override - public PrivateKey getPrivateKey(String alias) { - return akm.getPrivateKey(alias); - } - - @Override - public String chooseEngineClientAlias(String[] keyType, Principal[] issuers, - SSLEngine engine) { - String nap = engine.getHandshakeApplicationProtocol(); - checkALPN(nap); - - return akm.chooseEngineClientAlias(keyType, issuers, engine); - } - - @Override - public String chooseEngineServerAlias(String keyType, Principal[] issuers, - SSLEngine engine) { - String nap = engine.getHandshakeApplicationProtocol(); - checkALPN(nap); - - return akm.chooseEngineServerAlias(keyType, issuers, engine); - } - - private void checkALPN(String ap) { - - if (!doCheck) { - System.out.println("Skipping KeyManager checks " + - "because a callback has been registered"); - return; - } - - if (ERROR.equals(expectedAP)) { - throw new RuntimeException("Should not reach here"); - } - - System.out.println("Expected ALPN value: " + expectedAP - + " Got: " + ap); - - if (ap == null) { - throw new RuntimeException( - "ALPN should be negotiated, but null was received"); - } - if (expectedAP.equals("NONE")) { - if (!ap.isEmpty()) { - throw new RuntimeException("Expected no ALPN value"); - } else { - System.out.println("No ALPN value negotiated, as expected"); - } - } else if (!expectedAP.equals(ap)) { - throw new RuntimeException(expectedAP - + " ALPN value not available on negotiated connection"); - } - - } -} diff --git a/test/jdk/javax/net/ssl/ALPN/SSLEngineAlpnTest.java b/test/jdk/javax/net/ssl/ALPN/SSLEngineAlpnTest.java index adeb1a7dfc4c1..ca4af2740a08e 100644 --- a/test/jdk/javax/net/ssl/ALPN/SSLEngineAlpnTest.java +++ b/test/jdk/javax/net/ssl/ALPN/SSLEngineAlpnTest.java @@ -28,7 +28,6 @@ * @test * @bug 8051498 8145849 8170282 * @summary JEP 244: TLS Application-Layer Protocol Negotiation Extension - * @compile MyX509ExtendedKeyManager.java * * @run main/othervm SSLEngineAlpnTest h2 UNUSED h2 h2 * @run main/othervm SSLEngineAlpnTest h2 UNUSED h2,http/1.1 h2 @@ -237,10 +236,6 @@ public SSLEngineAlpnTest(String expectedAP) throws Exception { throw new Exception("kms[0] not X509ExtendedKeyManager"); } - kms = new KeyManager[] { new MyX509ExtendedKeyManager( - (X509ExtendedKeyManager) kms[0], expectedAP, - !hasCallback && hasServerAPs) }; - TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(ts); diff --git a/test/jdk/javax/net/ssl/ALPN/SSLServerSocketAlpnTest.java b/test/jdk/javax/net/ssl/ALPN/SSLServerSocketAlpnTest.java index a9373ed09f9da..2d563284ca804 100644 --- a/test/jdk/javax/net/ssl/ALPN/SSLServerSocketAlpnTest.java +++ b/test/jdk/javax/net/ssl/ALPN/SSLServerSocketAlpnTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ * @test * @bug 8051498 8145849 8158978 8170282 * @summary JEP 244: TLS Application-Layer Protocol Negotiation Extension - * @compile MyX509ExtendedKeyManager.java + * @library /javax/net/ssl/templates * * @run main/othervm SSLServerSocketAlpnTest h2 UNUSED h2 h2 * @run main/othervm SSLServerSocketAlpnTest h2 UNUSED h2,http/1.1 h2 @@ -79,56 +79,18 @@ * This example is based on our standard SSLSocketTemplate. */ import java.io.*; -import java.security.KeyStore; import java.util.Arrays; import javax.net.ssl.*; -public class SSLServerSocketAlpnTest { +public class SSLServerSocketAlpnTest extends SSLSocketTemplate { - /* - * ============================================================= - * Set the various variables needed for the tests, then - * specify what tests to run on each side. - */ - - /* - * Should we run the client or server in a separate thread? - * Both sides can throw exceptions, but do you have a preference - * as to which side should be the main thread. - */ - static boolean separateServerThread = false; - - /* - * Where do we find the keystores? - */ - static String pathToStores = "../etc"; - static String keyStoreFile = "keystore"; - static String trustStoreFile = "truststore"; - static String passwd = "passphrase"; - - static String keyFilename = System.getProperty("test.src", ".") + "/" - + pathToStores + "/" + keyStoreFile; - static String trustFilename = System.getProperty("test.src", ".") + "/" - + pathToStores + "/" + trustStoreFile; - - private static boolean hasServerAPs; // whether server APs are present private static boolean hasCallback; // whether a callback is present - /* - * SSLContext - */ - SSLContext mySSLContext = null; - - /* - * Is the server ready to serve? - */ - volatile static boolean serverReady = false; - /* * Turn on SSL debugging? */ - static boolean debug = false; + static boolean debug = Boolean.getBoolean("test.debug"); static String[] serverAPs; static String callbackAP; @@ -144,16 +106,8 @@ public class SSLServerSocketAlpnTest { * smart about it.... */ - /* - * Define the server side of the test. - * - * If the server prematurely exits, serverReady will be set to true - * to avoid infinite hangs. - */ - void doServerSide() throws Exception { - SSLServerSocketFactory sslssf = mySSLContext.getServerSocketFactory(); - SSLServerSocket sslServerSocket - = (SSLServerSocket) sslssf.createServerSocket(serverPort); + @Override + protected void configureServerSocket(SSLServerSocket sslServerSocket) { sslServerSocket.setNeedClientAuth(true); SSLParameters sslp = sslServerSocket.getSSLParameters(); @@ -178,13 +132,16 @@ void doServerSide() throws Exception { sslServerSocket.setSSLParameters(sslp); serverPort = sslServerSocket.getLocalPort(); + } - /* - * Signal Client, we're ready for his connect. - */ - serverReady = true; - - SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); + /* + * Define the server side of the test. + * + * If the server prematurely exits, serverReady will be set to true + * to avoid infinite hangs. + */ + @Override + protected void runServerApplication(SSLSocket sslSocket) throws Exception { if (sslSocket.getHandshakeApplicationProtocol() != null) { throw new Exception ("getHandshakeApplicationProtocol() should " @@ -245,26 +202,9 @@ void doServerSide() throws Exception { sslSocket.close(); } - /* - * Define the client side of the test. - * - * If the server prematurely exits, serverReady will be set to true - * to avoid infinite hangs. - */ - void doClientSide() throws Exception { - - /* - * Wait for server to get started. - */ - while (!serverReady) { - Thread.sleep(50); - } - - SSLSocketFactory sslsf = mySSLContext.getSocketFactory(); - SSLSocket sslSocket - = (SSLSocket) sslsf.createSocket("localhost", serverPort); - - SSLParameters sslp = sslSocket.getSSLParameters(); + @Override + protected void configureClientSocket(SSLSocket socket) { + SSLParameters sslp = socket.getSSLParameters(); /* * The default ciphersuite ordering from the SSLContext may not @@ -278,7 +218,17 @@ void doClientSide() throws Exception { // Set the ALPN selection. sslp.setApplicationProtocols(clientAPs); - sslSocket.setSSLParameters(sslp); + socket.setSSLParameters(sslp); + } + + /* + * Define the client side of the test. + * + * If the server prematurely exits, serverReady will be set to true + * to avoid infinite hangs. + */ + @Override + protected void runClientApplication(SSLSocket sslSocket) throws Exception { if (sslSocket.getHandshakeApplicationProtocol() != null) { throw new Exception ("getHandshakeApplicationProtocol() should " @@ -332,9 +282,6 @@ void doClientSide() throws Exception { // use any free port by default volatile int serverPort = 0; - volatile Exception serverException = null; - volatile Exception clientException = null; - public static void main(String[] args) throws Exception { if (debug) { @@ -351,14 +298,13 @@ public static void main(String[] args) throws Exception { clientAPs = convert(args[2]); expectedAP = args[3]; - hasServerAPs = !args[0].equals("UNUSED"); // are server APs being used? hasCallback = !callbackAP.equals("UNUSED"); // is callback being used? /* * Start the tests. */ try { - new SSLServerSocketAlpnTest(); + new SSLServerSocketAlpnTest().run(); } catch (SSLHandshakeException she) { if (args[3].equals("ERROR")) { System.out.println("Caught the expected exception: " + she); @@ -370,40 +316,6 @@ public static void main(String[] args) throws Exception { System.out.println("Test Passed."); } - SSLContext getSSLContext(String keyFilename, String trustFilename) - throws Exception { - SSLContext ctx = SSLContext.getInstance("TLS"); - - // Keystores - KeyStore keyKS = KeyStore.getInstance("JKS"); - keyKS.load(new FileInputStream(keyFilename), passwd.toCharArray()); - - KeyStore trustKS = KeyStore.getInstance("JKS"); - trustKS.load(new FileInputStream(trustFilename), passwd.toCharArray()); - - // Generate KeyManager and TrustManager - KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(keyKS, passwd.toCharArray()); - - KeyManager[] kms = kmf.getKeyManagers(); - if (!(kms[0] instanceof X509ExtendedKeyManager)) { - throw new Exception("kms[0] not X509ExtendedKeyManager"); - } - - kms = new KeyManager[] { new MyX509ExtendedKeyManager( - (X509ExtendedKeyManager) kms[0], expectedAP, - !hasCallback && hasServerAPs) }; - - TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); - tmf.init(trustKS); - TrustManager[] tms = tmf.getTrustManagers(); - - // initial SSLContext - ctx.init(kms, tms, null); - - return ctx; - } - /* * Convert a comma-separated list into an array of strings. */ @@ -425,143 +337,4 @@ private static String[] convert(String list) { return strings; } - - Thread clientThread = null; - Thread serverThread = null; - - /* - * Primary constructor, used to drive remainder of the test. - * - * Fork off the other side, then do your work. - */ - SSLServerSocketAlpnTest() throws Exception { - Exception startException = null; - mySSLContext = getSSLContext(keyFilename, trustFilename); - try { - if (separateServerThread) { - startServer(true); - startClient(false); - } else { - startClient(true); - startServer(false); - } - } catch (Exception e) { - startException = e; - } - - /* - * Wait for other side to close down. - */ - if (separateServerThread) { - if (serverThread != null) { - serverThread.join(); - } - } else { - if (clientThread != null) { - clientThread.join(); - } - } - - /* - * When we get here, the test is pretty much over. - * Which side threw the error? - */ - Exception local; - Exception remote; - - if (separateServerThread) { - remote = serverException; - local = clientException; - } else { - remote = clientException; - local = serverException; - } - - Exception exception = null; - - /* - * Check various exception conditions. - */ - if ((local != null) && (remote != null)) { - // If both failed, return the curthread's exception. - local.initCause(remote); - exception = local; - } else if (local != null) { - exception = local; - } else if (remote != null) { - exception = remote; - } else if (startException != null) { - exception = startException; - } - - /* - * If there was an exception *AND* a startException, - * output it. - */ - if (exception != null) { - if (exception != startException && startException != null) { - exception.addSuppressed(startException); - } - throw exception; - } - - // Fall-through: no exception to throw! - } - - void startServer(boolean newThread) throws Exception { - if (newThread) { - serverThread = new Thread() { - @Override - public void run() { - try { - doServerSide(); - } catch (Exception e) { - /* - * Our server thread just died. - * - * Release the client, if not active already... - */ - System.err.println("Server died..."); - serverReady = true; - serverException = e; - } - } - }; - serverThread.start(); - } else { - try { - doServerSide(); - } catch (Exception e) { - serverException = e; - } finally { - serverReady = true; - } - } - } - - void startClient(boolean newThread) throws Exception { - if (newThread) { - clientThread = new Thread() { - @Override - public void run() { - try { - doClientSide(); - } catch (Exception e) { - /* - * Our client thread just died. - */ - System.err.println("Client died..."); - clientException = e; - } - } - }; - clientThread.start(); - } else { - try { - doClientSide(); - } catch (Exception e) { - clientException = e; - } - } - } } diff --git a/test/jdk/javax/net/ssl/ALPN/SSLSocketAlpnTest.java b/test/jdk/javax/net/ssl/ALPN/SSLSocketAlpnTest.java index ef72474f4177e..51625f9c14f6c 100644 --- a/test/jdk/javax/net/ssl/ALPN/SSLSocketAlpnTest.java +++ b/test/jdk/javax/net/ssl/ALPN/SSLSocketAlpnTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ * @test * @bug 8051498 8145849 8170282 * @summary JEP 244: TLS Application-Layer Protocol Negotiation Extension - * @compile MyX509ExtendedKeyManager.java + * @library /javax/net/ssl/templates * * @run main/othervm SSLSocketAlpnTest h2 UNUSED h2 h2 * @run main/othervm SSLSocketAlpnTest h2 UNUSED h2,http/1.1 h2 @@ -78,56 +78,18 @@ * This example is based on our standard SSLSocketTemplate. */ import java.io.*; -import java.security.KeyStore; import java.util.Arrays; import javax.net.ssl.*; -public class SSLSocketAlpnTest { +public class SSLSocketAlpnTest extends SSLSocketTemplate { - /* - * ============================================================= - * Set the various variables needed for the tests, then - * specify what tests to run on each side. - */ - - /* - * Should we run the client or server in a separate thread? - * Both sides can throw exceptions, but do you have a preference - * as to which side should be the main thread. - */ - static boolean separateServerThread = false; - - /* - * Where do we find the keystores? - */ - static String pathToStores = "../etc"; - static String keyStoreFile = "keystore"; - static String trustStoreFile = "truststore"; - static String passwd = "passphrase"; - - static String keyFilename = System.getProperty("test.src", ".") + "/" - + pathToStores + "/" + keyStoreFile; - static String trustFilename = System.getProperty("test.src", ".") + "/" - + pathToStores + "/" + trustStoreFile; - - private static boolean hasServerAPs; // whether server APs are present private static boolean hasCallback; // whether a callback is present - /* - * SSLContext - */ - SSLContext mySSLContext = null; - - /* - * Is the server ready to serve? - */ - volatile static boolean serverReady = false; - /* * Turn on SSL debugging? */ - static boolean debug = false; + static boolean debug = Boolean.getBoolean("test.debug"); static String[] serverAPs; static String callbackAP; @@ -143,28 +105,20 @@ public class SSLSocketAlpnTest { * smart about it.... */ + @Override + protected void configureServerSocket(SSLServerSocket socket) { + socket.setNeedClientAuth(true); + } + /* * Define the server side of the test. * * If the server prematurely exits, serverReady will be set to true * to avoid infinite hangs. */ - void doServerSide() throws Exception { - SSLServerSocketFactory sslssf = mySSLContext.getServerSocketFactory(); - SSLServerSocket sslServerSocket - = (SSLServerSocket) sslssf.createServerSocket(serverPort); - // for both client/server to call into X509KM - sslServerSocket.setNeedClientAuth(true); - - serverPort = sslServerSocket.getLocalPort(); - - /* - * Signal Client, we're ready for his connect. - */ - serverReady = true; - - SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); - + @Override + protected void runServerApplication(SSLSocket sslSocket) throws Exception { + System.out.println("in runServerApplication(SSLSocket)"); SSLParameters sslp = sslSocket.getSSLParameters(); /* @@ -206,6 +160,7 @@ void doServerSide() throws Exception { } } + System.out.println("server starting handshake"); sslSocket.startHandshake(); if (sslSocket.getHandshakeApplicationProtocol() != null) { @@ -247,18 +202,9 @@ void doServerSide() throws Exception { * If the server prematurely exits, serverReady will be set to true * to avoid infinite hangs. */ - void doClientSide() throws Exception { - - /* - * Wait for server to get started. - */ - while (!serverReady) { - Thread.sleep(50); - } - - SSLSocketFactory sslsf = mySSLContext.getSocketFactory(); - SSLSocket sslSocket - = (SSLSocket) sslsf.createSocket("localhost", serverPort); + @Override + protected void runClientApplication(SSLSocket sslSocket) throws Exception { + System.out.println("in runClientApplication(SSLSocket)"); SSLParameters sslp = sslSocket.getSSLParameters(); @@ -281,6 +227,7 @@ void doClientSide() throws Exception { + "return null before the handshake starts"); } + System.out.println("Client starting handshake"); sslSocket.startHandshake(); if (sslSocket.getHandshakeApplicationProtocol() != null) { @@ -321,16 +268,6 @@ void doClientSide() throws Exception { sslSocket.close(); } - /* - * ============================================================= - * The remainder is just support stuff - */ - // use any free port by default - volatile int serverPort = 0; - - volatile Exception serverException = null; - volatile Exception clientException = null; - public static void main(String[] args) throws Exception { if (debug) { @@ -347,14 +284,13 @@ public static void main(String[] args) throws Exception { clientAPs = convert(args[2]); expectedAP = args[3]; - hasServerAPs = !args[0].equals("UNUSED"); // are server APs being used? hasCallback = !callbackAP.equals("UNUSED"); // is callback being used? /* * Start the tests. */ try { - new SSLSocketAlpnTest(); + new SSLSocketAlpnTest().run(); } catch (SSLHandshakeException she) { if (args[3].equals("ERROR")) { System.out.println("Caught the expected exception: " + she); @@ -366,40 +302,6 @@ public static void main(String[] args) throws Exception { System.out.println("Test Passed."); } - SSLContext getSSLContext(String keyFilename, String trustFilename) - throws Exception { - SSLContext ctx = SSLContext.getInstance("TLS"); - - // Keystores - KeyStore keyKS = KeyStore.getInstance("JKS"); - keyKS.load(new FileInputStream(keyFilename), passwd.toCharArray()); - - KeyStore trustKS = KeyStore.getInstance("JKS"); - trustKS.load(new FileInputStream(trustFilename), passwd.toCharArray()); - - // Generate KeyManager and TrustManager - KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(keyKS, passwd.toCharArray()); - - KeyManager[] kms = kmf.getKeyManagers(); - if (!(kms[0] instanceof X509ExtendedKeyManager)) { - throw new Exception("kms[0] not X509ExtendedKeyManager"); - } - - kms = new KeyManager[] { new MyX509ExtendedKeyManager( - (X509ExtendedKeyManager) kms[0], expectedAP, - !hasCallback && hasServerAPs) }; - - TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); - tmf.init(trustKS); - TrustManager[] tms = tmf.getTrustManagers(); - - // initial SSLContext - ctx.init(kms, tms, null); - - return ctx; - } - /* * Convert a comma-separated list into an array of strings. */ @@ -421,143 +323,4 @@ private static String[] convert(String list) { return strings; } - - Thread clientThread = null; - Thread serverThread = null; - - /* - * Primary constructor, used to drive remainder of the test. - * - * Fork off the other side, then do your work. - */ - SSLSocketAlpnTest() throws Exception { - Exception startException = null; - mySSLContext = getSSLContext(keyFilename, trustFilename); - try { - if (separateServerThread) { - startServer(true); - startClient(false); - } else { - startClient(true); - startServer(false); - } - } catch (Exception e) { - startException = e; - } - - /* - * Wait for other side to close down. - */ - if (separateServerThread) { - if (serverThread != null) { - serverThread.join(); - } - } else { - if (clientThread != null) { - clientThread.join(); - } - } - - /* - * When we get here, the test is pretty much over. - * Which side threw the error? - */ - Exception local; - Exception remote; - - if (separateServerThread) { - remote = serverException; - local = clientException; - } else { - remote = clientException; - local = serverException; - } - - Exception exception = null; - - /* - * Check various exception conditions. - */ - if ((local != null) && (remote != null)) { - // If both failed, return the curthread's exception. - local.initCause(remote); - exception = local; - } else if (local != null) { - exception = local; - } else if (remote != null) { - exception = remote; - } else if (startException != null) { - exception = startException; - } - - /* - * If there was an exception *AND* a startException, - * output it. - */ - if (exception != null) { - if (exception != startException && startException != null) { - exception.addSuppressed(startException); - } - throw exception; - } - - // Fall-through: no exception to throw! - } - - void startServer(boolean newThread) throws Exception { - if (newThread) { - serverThread = new Thread() { - @Override - public void run() { - try { - doServerSide(); - } catch (Exception e) { - /* - * Our server thread just died. - * - * Release the client, if not active already... - */ - System.err.println("Server died..."); - serverReady = true; - serverException = e; - } - } - }; - serverThread.start(); - } else { - try { - doServerSide(); - } catch (Exception e) { - serverException = e; - } finally { - serverReady = true; - } - } - } - - void startClient(boolean newThread) throws Exception { - if (newThread) { - clientThread = new Thread() { - @Override - public void run() { - try { - doClientSide(); - } catch (Exception e) { - /* - * Our client thread just died. - */ - System.err.println("Client died..."); - clientException = e; - } - } - }; - clientThread.start(); - } else { - try { - doClientSide(); - } catch (Exception e) { - clientException = e; - } - } - } } diff --git a/test/jdk/javax/net/ssl/SSLEngine/HandshakeWithInvalidRecordVersion.java b/test/jdk/javax/net/ssl/SSLEngine/HandshakeWithInvalidRecordVersion.java index 71119489b85f1..295ad66646cf2 100644 --- a/test/jdk/javax/net/ssl/SSLEngine/HandshakeWithInvalidRecordVersion.java +++ b/test/jdk/javax/net/ssl/SSLEngine/HandshakeWithInvalidRecordVersion.java @@ -37,19 +37,9 @@ import java.nio.*; import java.util.Arrays; -public class HandshakeWithInvalidRecordVersion implements SSLContextTemplate { +public class HandshakeWithInvalidRecordVersion extends SSLContextTemplate { private static final boolean DEBUG = Boolean.getBoolean("test.debug"); - private static final String PATH_TO_STORES = "../etc"; - private static final String KEYSTORE_FILE = "keystore"; - private static final String TRUSTSTORE_FILE = "truststore"; - - private static final String KEYSTORE_PATH = - System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + - "/" + KEYSTORE_FILE; - private static final String TRUSTSTORE_PATH = - System.getProperty("test.src", "./") + "/" + PATH_TO_STORES + - "/" + TRUSTSTORE_FILE; public static void main(String [] args) throws Exception { var runner = new HandshakeWithInvalidRecordVersion(); diff --git a/test/jdk/javax/net/ssl/TLSv12/DisabledShortRSAKeys.java b/test/jdk/javax/net/ssl/TLSv12/DisabledShortRSAKeys.java index 63fb1baa23173..3f275d8a28537 100644 --- a/test/jdk/javax/net/ssl/TLSv12/DisabledShortRSAKeys.java +++ b/test/jdk/javax/net/ssl/TLSv12/DisabledShortRSAKeys.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -42,86 +42,35 @@ * @run main/othervm DisabledShortRSAKeys SunX509 SSLv3 */ -import java.net.*; -import java.util.*; import java.io.*; import javax.net.ssl.*; import java.security.Security; -import java.security.KeyStore; -import java.security.KeyFactory; -import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; -import java.security.spec.*; -import java.security.interfaces.*; -import java.util.Base64; - public class DisabledShortRSAKeys extends SSLSocketTemplate { - /* - * Where do we find the keystores? - */ - // Certificates and key used in the test. - static String trustedCertStr = - "-----BEGIN CERTIFICATE-----\n" + - "MIICkjCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJVUzEN\n" + - "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwHhcN\n" + - "MTEwODE5MDE1MjE5WhcNMzIwNzI5MDE1MjE5WjA7MQswCQYDVQQGEwJVUzENMAsG\n" + - "A1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwgZ8wDQYJ\n" + - "KoZIhvcNAQEBBQADgY0AMIGJAoGBAM8orG08DtF98TMSscjGsidd1ZoN4jiDpi8U\n" + - "ICz+9dMm1qM1d7O2T+KH3/mxyox7Rc2ZVSCaUD0a3CkhPMnlAx8V4u0H+E9sqso6\n" + - "iDW3JpOyzMExvZiRgRG/3nvp55RMIUV4vEHOZ1QbhuqG4ebN0Vz2DkRft7+flthf\n" + - "vDld6f5JAgMBAAGjgaUwgaIwHQYDVR0OBBYEFLl81dnfp0wDrv0OJ1sxlWzH83Xh\n" + - "MGMGA1UdIwRcMFqAFLl81dnfp0wDrv0OJ1sxlWzH83XhoT+kPTA7MQswCQYDVQQG\n" + - "EwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2\n" + - "Y2WCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAQYwDQYJKoZIhvcNAQEE\n" + - "BQADgYEALlgaH1gWtoBZ84EW8Hu6YtGLQ/L9zIFmHonUPZwn3Pr//icR9Sqhc3/l\n" + - "pVTxOINuFHLRz4BBtEylzRIOPzK3tg8XwuLb1zd0db90x3KBCiAL6E6cklGEPwLe\n" + - "XYMHDn9eDsaq861Tzn6ZwzMgw04zotPMoZN0mVd/3Qca8UJFucE=\n" + - "-----END CERTIFICATE-----"; - - static String targetCertStr = - "-----BEGIN CERTIFICATE-----\n" + - "MIICNDCCAZ2gAwIBAgIBDDANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJVUzEN\n" + - "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwHhcN\n" + - "MTExMTA3MTM1NTUyWhcNMzEwNzI1MTM1NTUyWjBPMQswCQYDVQQGEwJVUzENMAsG\n" + - "A1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UxEjAQBgNV\n" + - "BAMTCWxvY2FsaG9zdDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC3Pb49OSPfOD2G\n" + - "HSXFCFx1GJEZfqG9ZUf7xuIi/ra5dLjPGAaoY5QF2QOa8VnOriQCXDfyXHxsuRnE\n" + - "OomxL7EVAgMBAAGjeDB2MAsGA1UdDwQEAwID6DAdBgNVHQ4EFgQUXNCJK3/dtCIc\n" + - "xb+zlA/JINlvs/MwHwYDVR0jBBgwFoAUuXzV2d+nTAOu/Q4nWzGVbMfzdeEwJwYD\n" + - "VR0lBCAwHgYIKwYBBQUHAwEGCCsGAQUFBwMCBggrBgEFBQcDAzANBgkqhkiG9w0B\n" + - "AQQFAAOBgQB2qIDUxA2caMPpGtUACZAPRUtrGssCINIfItETXJZCx/cRuZ5sP4D9\n" + - "N1acoNDn0hCULe3lhXAeTC9NZ97680yJzregQMV5wATjo1FGsKY30Ma+sc/nfzQW\n" + - "+h/7RhYtoG0OTsiaDCvyhI6swkNJzSzrAccPY4+ZgU8HiDLzZTmM3Q==\n" + - "-----END CERTIFICATE-----"; - - // Private key in the format of PKCS#8, key size is 512 bits. - static String targetPrivateKey = - "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAtz2+PTkj3zg9hh0l\n" + - "xQhcdRiRGX6hvWVH+8biIv62uXS4zxgGqGOUBdkDmvFZzq4kAlw38lx8bLkZxDqJ\n" + - "sS+xFQIDAQABAkByx/5Oo2hQ/w2q4L8z+NTRlJ3vdl8iIDtC/4XPnfYfnGptnpG6\n" + - "ZThQRvbMZiai0xHQPQMszvAHjZVme1eDl3EBAiEA3aKJHynPVCEJhpfCLWuMwX5J\n" + - "1LntwJO7NTOyU5m8rPECIQDTpzn5X44r2rzWBDna/Sx7HW9IWCxNgUD2Eyi2nA7W\n" + - "ZQIgJerEorw4aCAuzQPxiGu57PB6GRamAihEAtoRTBQlH0ECIQDN08FgTtnesgCU\n" + - "DFYLLcw1CiHvc7fZw4neBDHCrC8NtQIgA8TOUkGnpCZlQ0KaI8KfKWI+vxFcgFnH\n" + - "3fnqsTgaUs4="; - - static char passphrase[] = "passphrase".toCharArray(); - /* * Turn on SSL debugging? */ static boolean debug = false; + private final String enabledProtocol; + private final String tmAlgorithm; + + public DisabledShortRSAKeys(String tmAlgorithm, String enabledProtocol) { + this.tmAlgorithm = tmAlgorithm; + this.enabledProtocol = enabledProtocol; + } + @Override - protected SSLContext createClientSSLContext() throws Exception { - return generateSSLContext(trustedCertStr, null, null); + public SSLContext createClientSSLContext() throws Exception { + return createSSLContext(new Cert[]{Cert.CA_RSA_512}, null, + new ContextParameters(enabledProtocol, tmAlgorithm, "NewSunX509")); } @Override - protected SSLContext createServerSSLContext() throws Exception { - return generateSSLContext(null, targetCertStr, targetPrivateKey); + public SSLContext createServerSSLContext() throws Exception { + return createSSLContext(null, new Cert[]{Cert.EE_RSA_512}, + new ContextParameters(enabledProtocol, tmAlgorithm, "NewSunX509")); } @Override @@ -159,84 +108,6 @@ protected void runClientApplication(SSLSocket socket) throws Exception { } } - /* - * ============================================================= - * The remainder is just support stuff - */ - private static String tmAlgorithm; // trust manager - private static String enabledProtocol; // the target protocol - - private static void parseArguments(String[] args) { - tmAlgorithm = args[0]; - enabledProtocol = args[1]; - } - - private static SSLContext generateSSLContext(String trustedCertStr, - String keyCertStr, String keySpecStr) throws Exception { - - // generate certificate from cert string - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - // create a key store - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(null, null); - - // import the trused cert - Certificate trusedCert = null; - ByteArrayInputStream is = null; - if (trustedCertStr != null) { - is = new ByteArrayInputStream(trustedCertStr.getBytes()); - trusedCert = cf.generateCertificate(is); - is.close(); - - ks.setCertificateEntry("RSA Export Signer", trusedCert); - } - - if (keyCertStr != null) { - // generate the private key. - PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( - Base64.getMimeDecoder().decode(keySpecStr)); - KeyFactory kf = KeyFactory.getInstance("RSA"); - RSAPrivateKey priKey = - (RSAPrivateKey)kf.generatePrivate(priKeySpec); - - // generate certificate chain - is = new ByteArrayInputStream(keyCertStr.getBytes()); - Certificate keyCert = cf.generateCertificate(is); - is.close(); - - Certificate[] chain = null; - if (trusedCert != null) { - chain = new Certificate[2]; - chain[0] = keyCert; - chain[1] = trusedCert; - } else { - chain = new Certificate[1]; - chain[0] = keyCert; - } - - // import the key entry. - ks.setKeyEntry("Whatever", priKey, passphrase, chain); - } - - // create SSL context - TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmAlgorithm); - tmf.init(ks); - - SSLContext ctx = SSLContext.getInstance("TLS"); - if (keyCertStr != null && !keyCertStr.isEmpty()) { - KeyManagerFactory kmf = KeyManagerFactory.getInstance("NewSunX509"); - kmf.init(ks, passphrase); - - ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - ks = null; - } else { - ctx.init(null, tmf.getTrustManagers(), null); - } - - return ctx; - } - public static void main(String[] args) throws Exception { Security.setProperty("jdk.certpath.disabledAlgorithms", "RSA keySize < 1024"); @@ -247,15 +118,12 @@ public static void main(String[] args) throws Exception { System.setProperty("javax.net.debug", "all"); } - /* - * Get the customized arguments. - */ - parseArguments(args); + String tmAlgorithm = args[0]; + String enabledProtocol = args[1]; /* * Start the tests. */ - new DisabledShortRSAKeys().run(); + new DisabledShortRSAKeys(tmAlgorithm, enabledProtocol).run(); } - } diff --git a/test/jdk/javax/net/ssl/templates/SSLContextTemplate.java b/test/jdk/javax/net/ssl/templates/SSLContextTemplate.java index fd2fcd8099d51..171807c5a1de8 100644 --- a/test/jdk/javax/net/ssl/templates/SSLContextTemplate.java +++ b/test/jdk/javax/net/ssl/templates/SSLContextTemplate.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 @@ -39,534 +39,915 @@ /** * SSLContext template to speed up JSSE tests. */ -public interface SSLContextTemplate { +public abstract class SSLContextTemplate { + + /* + * ======================================= + * Certificates and keys used in the test. + */ + // Trusted certificates. + Cert[] TRUSTED_CERTS = { + Cert.CA_ECDSA_SECP256R1, + Cert.CA_RSA_2048, + Cert.CA_DSA_2048 }; + + // End entity certificate. + Cert[] END_ENTITY_CERTS = { + Cert.EE_ECDSA_SECP256R1, + Cert.EE_RSA_2048, + Cert.EE_EC_RSA_SECP256R1, + Cert.EE_DSA_2048 }; + /* * Create an instance of SSLContext for client use. */ - default SSLContext createClientSSLContext() throws Exception { + protected SSLContext createClientSSLContext() throws Exception { return createSSLContext( - createClientKeyManager(), createClientTrustManager(), + createClientKeyManager(), getClientContextParameters()); } /* * Create an instance of SSLContext for server use. */ - default SSLContext createServerSSLContext() throws Exception { + protected SSLContext createServerSSLContext() throws Exception { return createSSLContext( - createServerKeyManager(), createServerTrustManager(), + createServerKeyManager(), getServerContextParameters()); } - /* - * Create an instance of KeyManager for client use. - */ - default KeyManager createClientKeyManager() throws Exception { - return createKeyManager( - endEntityCertStrs, - endEntityPrivateKeys, - endEntityPrivateKeyAlgs, - endEntityPrivateKeyNames, - getServerContextParameters()); + private SSLContext createSSLContext(TrustManager trustManager, + KeyManager keyManager, + ContextParameters params) throws Exception { + SSLContext context = SSLContext.getInstance(params.contextProtocol); + context.init( + new KeyManager[] {keyManager}, + new TrustManager[] {trustManager}, + null); + return context; } - /* - * Create an instance of TrustManager for client use. - */ - default TrustManager createClientTrustManager() throws Exception { - return createTrustManager( - trustedCertStrs, - getServerContextParameters()); - } - /* - * Create an instance of KeyManager for server use. + /** + * Creates a TrustManager with TRUSTED_CERTS and client context parameters */ - default KeyManager createServerKeyManager() throws Exception { - return createKeyManager( - endEntityCertStrs, - endEntityPrivateKeys, - endEntityPrivateKeyAlgs, - endEntityPrivateKeyNames, - getServerContextParameters()); + protected TrustManager createClientTrustManager() throws Exception { + return createTrustManager(TRUSTED_CERTS, getClientContextParameters()); } - /* - * Create an instance of TrustManager for server use. + /** + * Creates a TrustManager with TRUSTED_CERTS and server context parameters */ - default TrustManager createServerTrustManager() throws Exception { - return createTrustManager( - trustedCertStrs, - getServerContextParameters()); + protected TrustManager createServerTrustManager() throws Exception { + return createTrustManager(TRUSTED_CERTS, getServerContextParameters()); } - /* - * The parameters used to configure SSLContext. + /** + * Creates a TrustManager with the given array of trusted certs and + * context parameters. */ - static final class ContextParameters { - final String contextProtocol; - final String tmAlgorithm; - final String kmAlgorithm; + protected TrustManager createTrustManager(Cert[] trustedCerts, + ContextParameters params) throws Exception { + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + ByteArrayInputStream is; - ContextParameters(String contextProtocol, - String tmAlgorithm, String kmAlgorithm) { + KeyStore ts = KeyStore.getInstance("JKS"); + ts.load(null, null); - this.contextProtocol = contextProtocol; - this.tmAlgorithm = tmAlgorithm; - this.kmAlgorithm = kmAlgorithm; + if (trustedCerts != null && trustedCerts.length != 0) { + Certificate[] trustedCert = new Certificate[trustedCerts.length]; + for (int i = 0; i < trustedCerts.length; i++) { + is = new ByteArrayInputStream(trustedCerts[i].certStr.getBytes()); + try { + trustedCert[i] = cf.generateCertificate(is); + } finally { + is.close(); + } + + ts.setCertificateEntry( + "trusted-cert-" + trustedCerts[i].name(), trustedCert[i]); + } } + + // Create an SSLContext object. + TrustManagerFactory tmf = + TrustManagerFactory.getInstance(params.tmAlgorithm); + tmf.init(ts); + return tmf.getTrustManagers()[0]; } - /* - * Get the client side parameters of SSLContext. + /** + * Create a key manager with Cert.END_ENTITY_CERTS and the client + * context parameters. */ - default ContextParameters getClientContextParameters() { - return new ContextParameters("TLS", "PKIX", "NewSunX509"); + protected KeyManager createClientKeyManager() throws Exception { + return createKeyManager(END_ENTITY_CERTS, getClientContextParameters()); } - /* - * Get the server side parameters of SSLContext. + /** + * Create a key manager with Cert.END_ENTITY_CERTS and the server + * context parameters */ - default ContextParameters getServerContextParameters() { - return new ContextParameters("TLS", "PKIX", "NewSunX509"); + protected KeyManager createServerKeyManager() throws Exception { + return createKeyManager(END_ENTITY_CERTS, getServerContextParameters()); } - /* - * ======================================= - * Certificates and keys used in the test. + /** + * Creates a KeyManager with the given end-entity Cert's and context + * parameters */ - // Trusted certificates. - final static String[] trustedCertStrs = { - // SHA256withECDSA, curve prime256v1 - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Subject Key Identifier: - // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 - "-----BEGIN CERTIFICATE-----\n" + - "MIIBvjCCAWOgAwIBAgIJAIvFG6GbTroCMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMDsxCzAJBgNVBAYTAlVT\n" + - "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTBZ\n" + - "MBMGByqGSM49AgEGCCqGSM49AwEHA0IABBz1WeVb6gM2mh85z3QlvaB/l11b5h0v\n" + - "LIzmkC3DKlVukZT+ltH2Eq1oEkpXuf7QmbM0ibrUgtjsWH3mULfmcWmjUDBOMB0G\n" + - "A1UdDgQWBBRgz71z//oaMNKk7NNJcUbvGjWghjAfBgNVHSMEGDAWgBRgz71z//oa\n" + - "MNKk7NNJcUbvGjWghjAMBgNVHRMEBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQCG\n" + - "6wluh1r2/T6L31mZXRKf9JxeSf9pIzoLj+8xQeUChQIhAJ09wAi1kV8yePLh2FD9\n" + - "2YEHlSQUAbwwqCDEVB5KxaqP\n" + - "-----END CERTIFICATE-----", - // -----BEGIN PRIVATE KEY----- - // MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg/HcHdoLJCdq3haVd - // XZTSKP00YzM3xX97l98vGL/RI1KhRANCAAQc9VnlW+oDNpofOc90Jb2gf5ddW+Yd - // LyyM5pAtwypVbpGU/pbR9hKtaBJKV7n+0JmzNIm61ILY7Fh95lC35nFp - // -----END PRIVATE KEY----- - - // SHA256withRSA, 2048 bits - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Subject Key Identifier: - // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C - "-----BEGIN CERTIFICATE-----\n" + - "MIIDSTCCAjGgAwIBAgIJAI4ZF3iy8zG+MA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + - "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + - "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMDsxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALpMcY7aWieXDEM1/YJf\n" + - "JW27b4nRIFZyEYhEloyGsKTuQiiQjc8cqRZFNXe2vwziDB4IyTEl0Hjl5QF6ZaQE\n" + - "huPzzwvQm1pv64KrRXrmj3FisQK8B5OWLty9xp6xDqsaMRoyObLK+oIb20T5fSlE\n" + - "evmo1vYjnh8CX0Yzx5Gr5ye6YSEHQvYOWEws8ad17OlyToR2KMeC8w4qo6rs59pW\n" + - "g7Mxn9vo22ImDzrtAbTbXbCias3xlE0Bp0h5luyf+5U4UgksoL9B9r2oP4GrLNEV\n" + - "oJk57t8lwaR0upiv3CnS8LcJELpegZub5ggqLY8ZPYFQPjlK6IzLOm6rXPgZiZ3m\n" + - "RL0CAwEAAaNQME4wHQYDVR0OBBYEFA3dk8n+S701t+iZeJD721o92xVMMB8GA1Ud\n" + - "IwQYMBaAFA3dk8n+S701t+iZeJD721o92xVMMAwGA1UdEwQFMAMBAf8wDQYJKoZI\n" + - "hvcNAQELBQADggEBAJTRC3rKUUhVH07/1+stUungSYgpM08dY4utJq0BDk36BbmO\n" + - "0AnLDMbkwFdHEoqF6hQIfpm7SQTmXk0Fss6Eejm8ynYr6+EXiRAsaXOGOBCzF918\n" + - "/RuKOzqABfgSU4UBKECLM5bMfQTL60qx+HdbdVIpnikHZOFfmjCDVxoHsGyXc1LW\n" + - "Jhkht8IGOgc4PMGvyzTtRFjz01kvrVQZ75aN2E0GQv6dCxaEY0i3ypSzjUWAKqDh\n" + - "3e2OLwUSvumcdaxyCdZAOUsN6pDBQ+8VRG7KxnlRlY1SMEk46QgQYLbPDe/+W/yH\n" + - "ca4PejicPeh+9xRAwoTpiE2gulfT7Lm+fVM7Ruc=\n" + - "-----END CERTIFICATE-----", - - // -----BEGIN PRIVATE KEY----- - // MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC6THGO2lonlwxD - // Nf2CXyVtu2+J0SBWchGIRJaMhrCk7kIokI3PHKkWRTV3tr8M4gweCMkxJdB45eUB - // emWkBIbj888L0Jtab+uCq0V65o9xYrECvAeTli7cvcaesQ6rGjEaMjmyyvqCG9tE - // +X0pRHr5qNb2I54fAl9GM8eRq+cnumEhB0L2DlhMLPGndezpck6EdijHgvMOKqOq - // 7OfaVoOzMZ/b6NtiJg867QG0212womrN8ZRNAadIeZbsn/uVOFIJLKC/Qfa9qD+B - // qyzRFaCZOe7fJcGkdLqYr9wp0vC3CRC6XoGbm+YIKi2PGT2BUD45SuiMyzpuq1z4 - // GYmd5kS9AgMBAAECggEAFHSoU2MuWwJ+2jJnb5U66t2V1bAcuOE1g5zkWvG/G5z9 - // rq6Qo5kmB8f5ovdx6tw3MGUOklLwnRXBG3RxDJ1iokz3AvkY1clMNsDPlDsUrQKF - // JSO4QUBQTPSZhnsyfR8XHSU+qJ8Y+ohMfzpVv95BEoCzebtXdVgxVegBlcEmVHo2 - // kMmkRN+bYNsr8eb2r+b0EpyumS39ZgKYh09+cFb78y3T6IFMGcVJTP6nlGBFkmA/ - // 25pYeCF2tSki08qtMJZQAvKfw0Kviibk7ZxRbJqmc7B1yfnOEHP6ftjuvKl2+RP/ - // +5P5f8CfIP6gtA0LwSzAqQX/hfIKrGV5j0pCqrD0kQKBgQDeNR6Xi4sXVq79lihO - // a1bSeV7r8yoQrS8x951uO+ox+UIZ1MsAULadl7zB/P0er92p198I9M/0Jth3KBuS - // zj45mucvpiiGvmQlMKMEfNq4nN7WHOu55kufPswQB2mR4J3xmwI+4fM/nl1zc82h - // De8JSazRldJXNhfx0RGFPmgzbwKBgQDWoVXrXLbCAn41oVnWB8vwY9wjt92ztDqJ - // HMFA/SUohjePep9UDq6ooHyAf/Lz6oE5NgeVpPfTDkgvrCFVKnaWdwALbYoKXT2W - // 9FlyJox6eQzrtHAacj3HJooXWuXlphKSizntfxj3LtMR9BmrmRJOfK+SxNOVJzW2 - // +MowT20EkwKBgHmpB8jdZBgxI7o//m2BI5Y1UZ1KE5vx1kc7VXzHXSBjYqeV9FeF - // 2ZZLP9POWh/1Fh4pzTmwIDODGT2UPhSQy0zq3O0fwkyT7WzXRknsuiwd53u/dejg - // iEL2NPAJvulZ2+AuiHo5Z99LK8tMeidV46xoJDDUIMgTG+UQHNGhK5gNAoGAZn/S - // Cn7SgMC0CWSvBHnguULXZO9wH1wZAFYNLL44OqwuaIUFBh2k578M9kkke7woTmwx - // HxQTjmWpr6qimIuY6q6WBN8hJ2Xz/d1fwhYKzIp20zHuv5KDUlJjbFfqpsuy3u1C - // kts5zwI7pr1ObRbDGVyOdKcu7HI3QtR5qqyjwaUCgYABo7Wq6oHva/9V34+G3Goh - // 63bYGUnRw2l5BD11yhQv8XzGGZFqZVincD8gltNThB0Dc/BI+qu3ky4YdgdZJZ7K - // z51GQGtaHEbrHS5caV79yQ8QGY5mUVH3E+VXSxuIqb6pZq2DH4sTAEFHyncddmOH - // zoXBInYwRG9KE/Bw5elhUw== - // -----END PRIVATE KEY----- - - - // SHA256withDSA, 2048 bits - // Validity - // Not Before: May 22 07:18:18 2018 GMT - // Not After : May 17 07:18:18 2038 GMT - // Subject Key Identifier: - // 76:66:9E:F7:3B:DD:45:E5:3B:D9:72:3C:3F:F0:54:39:86:31:26:53 - "-----BEGIN CERTIFICATE-----\n" + - "MIIErjCCBFSgAwIBAgIJAOktYLNCbr02MAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" + - "EwJVUzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2\n" + - "Y2UwHhcNMTgwNTIyMDcxODE4WhcNMzgwNTE3MDcxODE4WjA7MQswCQYDVQQGEwJV\n" + - "UzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2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/eBBHYNFG5gWPv/Q5KoyCtHS03uqGm4rNc/wZTIEEfd66C+\n" + - "QRaUltjOaHmtwOdDHaNqwhYZSVOip+Mo+TfyzHFREcdHLapo7ZXqbdYkRGxRR3d+\n" + - "3DfHaraJO0OKoYlPkr3JMvM/MSGR9AnZOcejUDBOMB0GA1UdDgQWBBR2Zp73O91F\n" + - "5TvZcjw/8FQ5hjEmUzAfBgNVHSMEGDAWgBR2Zp73O91F5TvZcjw/8FQ5hjEmUzAM\n" + - "BgNVHRMEBTADAQH/MAsGCWCGSAFlAwQDAgNHADBEAiBzriYE41M2y9Hy5ppkL0Qn\n" + - "dIlNc8JhXT/PHW7GDtViagIgMko8Qoj9gDGPK3+O9E8DC3wGiiF9CObM4LN387ok\n" + - "J+g=\n" + - "-----END CERTIFICATE-----" - // -----BEGIN PRIVATE KEY----- - // MIICZQIBADCCAjkGByqGSM44BAEwggIsAoIBAQDuRsj4UptM3ty0rvoInHVCy49O - // Yjn0y1L2UNvbGM+Nc5qqywUG3Soh6oCbtkXvbIE2+bLizYxdOO0ziz51N44T7Vpt - // l/F84lRiHB8pv0PzHmcUrbf/PLHqq6CN1jisyDC9hnK4rIU/pXBq7R9+k39frntk - // p59z0lsscoDaj45ZT+blI2JhS7wH+ECzJXZHfw9lcXMLB4wfMuYlGbF3s3PyxIUW - // Uv9Npor6pUcNwDJKvzlXv2bcRVrD9J7H8RBnWbmlBaaaRn4scRb8pqwd/iedXE7f - // qWQQ6g9stA2H3PvPIgrOI8B033AyKS2+d/BwYwY9qxILUBEkJgdKKA//sLD7AiEA - // tW2HIYBJTbQ2C9xYKS4DUlGKe4CFr/XoWguyzts+24kCggEAYrbxTpw5FI2vDQBe - // 5Q6TlW+YqUPEonAS1t5EGpsYcrssYGcsvz6I2f6D6K5Klv0/wNK4ZxujLLBKQLXY - // sFQfnKwWBqN23MJhMSYXTienWLihaaT1oQsCjB7PZ6SvpagTJfJeY+fMZXBXgu2X - // xn/BmBpIRVtHOOLxEITDG2nOmU0z+JsPtbe8SX5gzJSxMiKU12gAJPLqFS1s0Fp0 - // eNLB4sm70tLtycUJG+/8vLTjmbvKpc/2Dku5UOlMVBl9uwntRNPmoHz6YXraEQJU - // tXHs6lmu6+uBmtJ5I9ZMJHEao4E4icdDcJ1F6+/FQFxYVRfefjt5X6ob3bRBrZIQ - // xj4OzQQjAiEAsceWOM8do4etxp2zgnoNXV8PUUyqWhz1+0srcKV7FR4= - // -----END PRIVATE KEY----- - }; + protected KeyManager createKeyManager(Cert[] endEntityCerts, + ContextParameters params) throws Exception { + KeyStore ks = null; // key store + char[] passphrase = "passphrase".toCharArray(); - // End entity certificate. - final static String[] endEntityCertStrs = { - // SHA256withECDSA, curve prime256v1 - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Authority Key Identifier: - // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 - "-----BEGIN CERTIFICATE-----\n" + - "MIIBqjCCAVCgAwIBAgIJAPLY8qZjgNRAMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMFUxCzAJBgNVBAYTAlVT\n" + - "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTEY\n" + - "MBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD\n" + - "QgAEb+9n05qfXnfHUb0xtQJNS4JeSi6IjOfW5NqchvKnfJey9VkJzR7QHLuOESdf\n" + - "xlR7q8YIWgih3iWLGfB+wxHiOqMjMCEwHwYDVR0jBBgwFoAUYM+9c//6GjDSpOzT\n" + - "SXFG7xo1oIYwCgYIKoZIzj0EAwIDSAAwRQIgWpRegWXMheiD3qFdd8kMdrkLxRbq\n" + - "1zj8nQMEwFTUjjQCIQDRIrAjZX+YXHN9b0SoWWLPUq0HmiFIi8RwMnO//wJIGQ==\n" + - "-----END CERTIFICATE-----", - - // SHA256withRSA, 2048 bits - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Authority Key Identifier: - // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C - "-----BEGIN CERTIFICATE-----\n" + - "MIIDNjCCAh6gAwIBAgIJAO2+yPcFryUTMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + - "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + - "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMFUxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOC\n" + - "AQ8AMIIBCgKCAQEAszfBobWfZIp8AgC6PiWDDavP65mSvgCXUGxACbxVNAfkLhNR\n" + - "QOsHriRB3X1Q3nvO9PetC6wKlvE9jlnDDj7D+1j1r1CHO7ms1fq8rfcQYdkanDtu\n" + - "4AlHo8v+SSWX16MIXFRYDj2VVHmyPtgbltcg4zGAuwT746FdLI94uXjJjq1IOr/v\n" + - "0VIlwE5ORWH5Xc+5Tj+oFWK0E4a4GHDgtKKhn2m72hN56/GkPKGkguP5NRS1qYYV\n" + - "/EFkdyQMOV8J1M7HaicSft4OL6eKjTrgo93+kHk+tv0Dc6cpVBnalX3TorG8QI6B\n" + - "cHj1XQd78oAlAC+/jF4pc0mwi0un49kdK9gRfQIDAQABoyMwITAfBgNVHSMEGDAW\n" + - "gBQN3ZPJ/ku9NbfomXiQ+9taPdsVTDANBgkqhkiG9w0BAQsFAAOCAQEApXS0nKwm\n" + - "Kp8gpmO2yG1rpd1+2wBABiMU4JZaTqmma24DQ3RzyS+V2TeRb29dl5oTUEm98uc0\n" + - "GPZvhK8z5RFr4YE17dc04nI/VaNDCw4y1NALXGs+AHkjoPjLyGbWpi1S+gfq2sNB\n" + - "Ekkjp6COb/cb9yiFXOGVls7UOIjnVZVd0r7KaPFjZhYh82/f4PA/A1SnIKd1+nfH\n" + - "2yk7mSJNC7Z3qIVDL8MM/jBVwiC3uNe5GPB2uwhd7k5LGAVN3j4HQQGB0Sz+VC1h\n" + - "92oi6xDa+YBva2fvHuCd8P50DDjxmp9CemC7rnZ5j8egj88w14X44Xjb/Fd/ApG9\n" + - "e57NnbT7KM+Grw==\n" + - "-----END CERTIFICATE-----", - - // SHA256withRSA, curv prime256v1 - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 21 07:18:16 2028 GMT - // Authority Key Identifier: - // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C - "-----BEGIN CERTIFICATE-----\n" + - "MIICazCCAVOgAwIBAgIJAO2+yPcFryUUMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + - "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + - "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0yODA1MjEwNzE4MTZaMFUxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0D\n" + - "AQcDQgAE59MERNTlVZ1eeps8Z3Oue5ZkgQdPtD+WIE6tj3PbIKpxGPDxvfNP959A\n" + - "yQjEK/ehWQVrCMmNoEkIzY+IIBgB06MjMCEwHwYDVR0jBBgwFoAUDd2Tyf5LvTW3\n" + - "6Jl4kPvbWj3bFUwwDQYJKoZIhvcNAQELBQADggEBAFOTVEqs70ykhZiIdrEsF1Ra\n" + - "I3B2rLvwXZk52uSltk2/bzVvewA577ZCoxQ1pL7ynkisPfBN1uVYtHjM1VA3RC+4\n" + - "+TAK78dnI7otYjWoHp5rvs4l6c/IbOspS290IlNuDUxMErEm5wxIwj+Aukx/1y68\n" + - "hOyCvHBLMY2c1LskH1MMBbDuS1aI+lnGpToi+MoYObxGcV458vxuT8+wwV8Fkpvd\n" + - "ll8IIFmeNPRv+1E+lXbES6CSNCVaZ/lFhPgdgYKleN7sfspiz50DG4dqafuEAaX5\n" + - "xaK1NWXJxTRz0ROH/IUziyuDW6jphrlgit4+3NCzp6vP9hAJQ8Vhcj0n15BKHIQ=\n" + - "-----END CERTIFICATE-----", - - // SHA256withDSA, 2048 bits - // Validity - // Not Before: May 22 07:18:20 2018 GMT - // Not After : May 17 07:18:20 2038 GMT - // Authority Key Identifier: - // 76:66:9E:F7:3B:DD:45:E5:3B:D9:72:3C:3F:F0:54:39:86:31:26:53 - "-----BEGIN CERTIFICATE-----\n" + - "MIIEnDCCBEGgAwIBAgIJAP/jh1qVhNVjMAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" + - "EwJVUzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2\n" + - "Y2UwHhcNMTgwNTIyMDcxODIwWhcNMzgwNTE3MDcxODIwWjBVMQswCQYDVQQGEwJV\n" + - "UzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2Ux\n" + - "GDAWBgNVBAMMD1JlZ3Jlc3Npb24gVGVzdDCCA0cwggI6BgcqhkjOOAQBMIICLQKC\n" + - "AQEAmlavgoJrMcjqWRVcDE2dmWAPREgnzQvneEDef68cprDzjSwvOs5Q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BU9y\n" + - "fuykPkptg9C0rCM9t06bukpOSaEz/2VIQdLE8fHYFA6pHZ6CIc2+5cfvMgTPhcjz\n" + - "W2jCt6MjMCEwHwYDVR0jBBgwFoAUdmae9zvdReU72XI8P/BUOYYxJlMwCwYJYIZI\n" + - "AWUDBAMCA0gAMEUCIQCeI5fN08b9BpOaHdc3zQNGjp24FOL/RxlBLeBAorswJgIg\n" + - "JEZ8DhYxQy1O7mmZ2UIT7op6epWMB4dENjs0qWPmcKo=\n" + - "-----END CERTIFICATE-----" - }; - - // Private key in the format of PKCS#8. - final static String[] endEntityPrivateKeys = { - // - // EC private key related to cert endEntityCertStrs[0]. - // - "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgn5K03bpTLjEtFQRa\n" + - "JUtx22gtmGEvvSUSQdimhGthdtihRANCAARv72fTmp9ed8dRvTG1Ak1Lgl5KLoiM\n" + - "59bk2pyG8qd8l7L1WQnNHtAcu44RJ1/GVHurxghaCKHeJYsZ8H7DEeI6", - - // - // RSA private key related to cert endEntityCertStrs[1]. - // - "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCzN8GhtZ9kinwC\n" + - "ALo+JYMNq8/rmZK+AJdQbEAJvFU0B+QuE1FA6weuJEHdfVDee870960LrAqW8T2O\n" + - "WcMOPsP7WPWvUIc7uazV+ryt9xBh2RqcO27gCUejy/5JJZfXowhcVFgOPZVUebI+\n" + - "2BuW1yDjMYC7BPvjoV0sj3i5eMmOrUg6v+/RUiXATk5FYfldz7lOP6gVYrQThrgY\n" + - "cOC0oqGfabvaE3nr8aQ8oaSC4/k1FLWphhX8QWR3JAw5XwnUzsdqJxJ+3g4vp4qN\n" + - "OuCj3f6QeT62/QNzpylUGdqVfdOisbxAjoFwePVdB3vygCUAL7+MXilzSbCLS6fj\n" + - "2R0r2BF9AgMBAAECggEASIkPkMCuw4WdTT44IwERus3IOIYOs2IP3BgEDyyvm4B6\n" + - "JP/iihDW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K6/+wOiYkCgYEA1tZkI1rD1W9NYZtbI9BE\n" + - "qlJVFi2PBOJMKNuWdouPX3HLQ72GJSQff2BFzLTELjweVVJ0SvY4IipzpQOHQOBy\n" + - "5qh/p6izXJZh3IHtvwVBjHoEVplg1b2+I5e3jDCfqnwcQw82dW5SxOJMg1h/BD0I\n" + - "qAL3go42DYeYhu/WnECMeis=", - - // - // EC private key related to cert endEntityCertStrs[2]. - // - "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGVc7hICpmp91jbYe\n" + - "nrr8nYHD37RZP3VENY+szuA7WjuhRANCAATn0wRE1OVVnV56mzxnc657lmSBB0+0\n" + - "P5YgTq2Pc9sgqnEY8PG980/3n0DJCMQr96FZBWsIyY2gSQjNj4ggGAHT", - - // - // DSA private key related to cert endEntityCertStrs[3]. - // - "MIICZQIBADCCAjoGByqGSM44BAEwggItAoIBAQCaVq+CgmsxyOpZFVwMTZ2ZYA9E\n" + - "SCfNC+d4QN5/rxymsPONLC86zlB4XLHvmJtp2jV7qM7+tbWmsIZYcMPWgD9Ofg+T\n" + - "e+7SdTHO+XWoBNz5olulRTk6nRu+notsKxBCyVX0V5GHsRvts/qClz+QcIHMSALV\n" + - "UIrumtxxdbL63pIw4ds0PeH5RtyR9JpS5pWxUk1MPUPoYSV9GPg2bPUEY99Ji8qi\n" + - "vA1kRTeBfAWC0OgBwbHu1zIKUukMd+pF/D/vKKovJ6I/sPiGXmUw2i4lYOUB0wWn\n" + - "QUyBLez1UMWKchyvpW0FYxMbv7j5zMcAH7d++vCWo3OEGfe4Uet6Q3/Dx83HAiEA\n" + - "mjtJp7XNrsgxbRDqETkHhv6zYH8Voo+gDgSO1m7XcH0CggEBAI5moswp++plZSBP\n" + - "Q9DdCNHt0AV13Toj1jf5M5DNmTX6P6/D/oRfi8Ui1fiCKFv+7lD0J2anCFUaLtu+\n" + - "j7v78gp5OChDp/n49K6DtKtZZRDmw/Bpm6LNdknmdN5kO5wVzbIXHTCCeNs/CJTF\n" + - "mSU5PvEaI4y3M5NraSgLPkq4gEv7/A8orGbKmj1Whj3F9t1Tosxdm/+WkPldMz2t\n" + - "gev+9RM2S6S9XoembRgwRaFVkpQmKoKpOoZcdqV47FLDq5BYH/5POeJ9wLuAHjxQ\n" + - "5CMKo4p/lW7BCd4kuGWFT+OFFXfG2v6EtlqFbXBiFWLxyMsOtkUqWARCqEHhyucl\n" + - "TSYlj60EIgIgLfA75+8KcKxdN8mr6gzGjQe7jPFGG42Ejhd7Q2F4wuw=" - }; - - // Private key algorithm of endEntityPrivateKeys. - final static String[] endEntityPrivateKeyAlgs = { - "EC", - "RSA", - "EC", - "DSA", - }; - - // Private key names of endEntityPrivateKeys. - static final String[] endEntityPrivateKeyNames = { - "ecdsa", - "rsa", - "ec-rsa", - "dsa", - }; + if (endEntityCerts == null || endEntityCerts.length == 0) { + return null; + + } else { + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + ks = KeyStore.getInstance("JKS"); + ks.load(null, null); + + for (Cert endEntityCert : endEntityCerts) { + // generate the private key. + PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( + Base64.getMimeDecoder().decode(endEntityCert.privKeyStr)); + KeyFactory kf = + KeyFactory.getInstance( + endEntityCert.keyAlgo); + PrivateKey priKey = kf.generatePrivate(priKeySpec); + + // generate certificate chain + ByteArrayInputStream is = new ByteArrayInputStream( + endEntityCert.certStr.getBytes()); + Certificate keyCert = null; + try { + keyCert = cf.generateCertificate(is); + } finally { + is.close(); + } + + Certificate[] chain = new Certificate[]{keyCert}; + + // import the key entry. + ks.setKeyEntry("cert-" + endEntityCert.name(), + priKey, passphrase, chain); + } + + KeyManagerFactory kmf = + KeyManagerFactory.getInstance(params.kmAlgorithm); + kmf.init(ks, passphrase); + return kmf.getKeyManagers()[0]; + } + } /* * Create an instance of SSLContext with the specified trust/key materials. */ - private SSLContext createSSLContext( - KeyManager keyManager, - TrustManager trustManager, + protected SSLContext createSSLContext( + Cert[] trustedCerts, + Cert[] endEntityCerts, ContextParameters params) throws Exception { - SSLContext context = SSLContext.getInstance(params.contextProtocol); - context.init( - new KeyManager[] { - keyManager - }, - new TrustManager[] { - trustManager - }, - null); + // Generate certificate from cert string. + TrustManager tm = createTrustManager(trustedCerts, params); - return context; + KeyManager km = createKeyManager(endEntityCerts, params); + + SSLContext context = SSLContext.getInstance(params.contextProtocol); + context.init(km == null ? null : new KeyManager[]{km}, new TrustManager[]{tm}, null); + return context; } /* - * Create an instance of KeyManager with the specified key materials. + * The parameters used to configure SSLContext. */ - static KeyManager createKeyManager( - String[] keyMaterialCerts, - String[] keyMaterialKeys, - String[] keyMaterialKeyAlgs, - String[] keyMaterialKeyNames, - ContextParameters params) throws Exception { - - char[] passphrase = "passphrase".toCharArray(); - - // Generate certificate from cert string. - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - // Import the key materials. - // - // Note that certification paths bigger than one are not supported yet. - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(null, null); - ByteArrayInputStream is; - for (int i = 0; i < keyMaterialCerts.length; i++) { - String keyCertStr = keyMaterialCerts[i]; - - // generate the private key. - PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( - Base64.getMimeDecoder().decode(keyMaterialKeys[i])); - KeyFactory kf = - KeyFactory.getInstance(keyMaterialKeyAlgs[i]); - PrivateKey priKey = kf.generatePrivate(priKeySpec); - - // generate certificate chain - is = new ByteArrayInputStream(keyCertStr.getBytes()); - Certificate keyCert = null; - try { - keyCert = cf.generateCertificate(is); - } finally { - is.close(); - } + static final class ContextParameters { + final String contextProtocol; + final String tmAlgorithm; + final String kmAlgorithm; - Certificate[] chain = new Certificate[] { keyCert }; + ContextParameters(String contextProtocol, + String tmAlgorithm, String kmAlgorithm) { - // import the key entry. - ks.setKeyEntry("cert-" + keyMaterialKeyNames[i], - priKey, passphrase, chain); + this.contextProtocol = contextProtocol; + this.tmAlgorithm = tmAlgorithm; + this.kmAlgorithm = kmAlgorithm; } - - KeyManagerFactory kmf = - KeyManagerFactory.getInstance(params.kmAlgorithm); - kmf.init(ks, passphrase); - - KeyManager[] km = kmf.getKeyManagers(); - - return km[0]; } /* - * Create an instance of TrustManager with the specified trust materials. + * Get the client side parameters of SSLContext. */ - static TrustManager createTrustManager( - String[] trustedMaterials, - ContextParameters params) throws Exception { - - // Generate certificate from cert string. - CertificateFactory cf = CertificateFactory.getInstance("X.509"); + protected ContextParameters getClientContextParameters() { + return new ContextParameters("TLS", "PKIX", "NewSunX509"); + } - // Import the trusted certs. - KeyStore ts = KeyStore.getInstance("PKCS12"); - ts.load(null, null); + /* + * Get the server side parameters of SSLContext. + */ + protected ContextParameters getServerContextParameters() { + return new ContextParameters("TLS", "PKIX", "NewSunX509"); + } - Certificate[] trustedCert = - new Certificate[trustedMaterials.length]; - ByteArrayInputStream is; - for (int i = 0; i < trustedMaterials.length; i++) { - String trustedCertStr = trustedMaterials[i]; - - is = new ByteArrayInputStream(trustedCertStr.getBytes()); - try { - trustedCert[i] = cf.generateCertificate(is); - } finally { - is.close(); - } - ts.setCertificateEntry("trusted-cert-" + i, trustedCert[i]); + enum Cert { + + CA_ECDSA_SECP256R1( + "EC", + // SHA256withECDSA, curve secp256r1 + // Validity + // Not Before: May 22 07:18:16 2018 GMT + // Not After : May 17 07:18:16 2038 GMT + // Subject Key Identifier: + // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 + "-----BEGIN CERTIFICATE-----\n" + + "MIIBvjCCAWOgAwIBAgIJAIvFG6GbTroCMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + + "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + + "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMDsxCzAJBgNVBAYTAlVT\n" + + "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTBZ\n" + + "MBMGByqGSM49AgEGCCqGSM49AwEHA0IABBz1WeVb6gM2mh85z3QlvaB/l11b5h0v\n" + + "LIzmkC3DKlVukZT+ltH2Eq1oEkpXuf7QmbM0ibrUgtjsWH3mULfmcWmjUDBOMB0G\n" + + "A1UdDgQWBBRgz71z//oaMNKk7NNJcUbvGjWghjAfBgNVHSMEGDAWgBRgz71z//oa\n" + + "MNKk7NNJcUbvGjWghjAMBgNVHRMEBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQCG\n" + + "6wluh1r2/T6L31mZXRKf9JxeSf9pIzoLj+8xQeUChQIhAJ09wAi1kV8yePLh2FD9\n" + + "2YEHlSQUAbwwqCDEVB5KxaqP\n" + + "-----END CERTIFICATE-----", + "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg/HcHdoLJCdq3haVd\n" + + "XZTSKP00YzM3xX97l98vGL/RI1KhRANCAAQc9VnlW+oDNpofOc90Jb2gf5ddW+Yd\n" + + "LyyM5pAtwypVbpGU/pbR9hKtaBJKV7n+0JmzNIm61ILY7Fh95lC35nFp"), + + CA_ECDSA_SECP384R1( + "EC", + // SHA384withECDSA, curve secp384r1 + // Validity + // Not Before: Jun 24 08:15:06 2019 GMT + // Not After : Jun 19 08:15:06 2039 GMT + // Subject Key Identifier: + // 0a:93:a9:a0:bf:e7:d5:48:9d:4f:89:15:c6:51:98:80:05:51:4e:4e + "-----BEGIN CERTIFICATE-----\n" + + "MIICCDCCAY6gAwIBAgIUCpOpoL/n1UidT4kVxlGYgAVRTk4wCgYIKoZIzj0EAwMw\n" + + "OzELMAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0Ug\n" + + "VGVzdCBTZXJpdmNlMB4XDTE5MDYyNDA4MTUwNloXDTM5MDYxOTA4MTUwNlowOzEL\n" + + "MAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVz\n" + + "dCBTZXJpdmNlMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAENVQN1wXWFdgC6u/dDdiC\n" + + "y+WtMTF66oL/0BSm+1ZqsogamzCryawOcHgiuXgWzx5CQ3LuOC+tDFyXpGfHuCvb\n" + + "dkzxPrP5n9NrR8/uRPe5l1KOUbchviU8z9cTP+LZxnZDo1MwUTAdBgNVHQ4EFgQU\n" + + "SktSFArR1p/5mXV0kyo0RxIVa/UwHwYDVR0jBBgwFoAUSktSFArR1p/5mXV0kyo0\n" + + "RxIVa/UwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjBZvoNmq3/v\n" + + "RD2gBTyvxjS9h0rsMRLHDnvul/KWngytwGPTOBo0Y8ixQXSjdKoc3rkCMQDkiNgx\n" + + "IDxuHedmrLQKIPnVcthTmwv7//jHiqGoKofwChMo2a1P+DQdhszmeHD/ARQ=\n" + + "-----END CERTIFICATE-----", + "MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDChlbt0NF8oIKODSxn2\n" + + "WXCXuJm3z78LRkzYQS3Nx5NMjei5ytkFZz4qvD4XXMWlTEyhZANiAAQ1VA3XBdYV\n" + + "2ALq790N2ILL5a0xMXrqgv/QFKb7VmqyiBqbMKvJrA5weCK5eBbPHkJDcu44L60M\n" + + "XJekZ8e4K9t2TPE+s/mf02tHz+5E97mXUo5RtyG+JTzP1xM/4tnGdkM="), + + CA_ECDSA_SECP521R1( + "EC", + // SHA512withECDSA, curve secp521r1 + // Validity + // Not Before: Jun 24 08:15:06 2019 GMT + // Not After : Jun 19 08:15:06 2039 GMT + // Subject Key Identifier: + // 25:ca:68:76:6d:29:17:9b:71:78:45:2d:d4:c6:e4:5d:fe:25:ff:90 + "-----BEGIN CERTIFICATE-----\n" + + "MIICUzCCAbSgAwIBAgIUJcpodm0pF5txeEUt1MbkXf4l/5AwCgYIKoZIzj0EAwQw\n" + + "OzELMAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0Ug\n" + + "VGVzdCBTZXJpdmNlMB4XDTE5MDYyNDA4MTUwNloXDTM5MDYxOTA4MTUwNlowOzEL\n" + + "MAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVz\n" + + "dCBTZXJpdmNlMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQAmFD5VmB2MdyJ6k+E\n" + + "eP4JncrE65ySL07gVmFwnr8otOt3NtRAyzmviMNNXXjo5R5NqNjKP4pr92JjT0sO\n" + + "D65yngkBtH151Ev/fiKPLxkXL9GzfKdWHVhDX7Zg6DUydzukzZV2/dIyloAIqwlz\n" + + "QVKJqT7RypDufdng8hnE9YfKo6ypZiujUzBRMB0GA1UdDgQWBBRAIrxa7WqtqUCe\n" + + "HFuKREDC92spvTAfBgNVHSMEGDAWgBRAIrxa7WqtqUCeHFuKREDC92spvTAPBgNV\n" + + "HRMBAf8EBTADAQH/MAoGCCqGSM49BAMEA4GMADCBiAJCAe22iirZnODCmlpxcv57\n" + + "3g5BEE60C+dtYmTqR4DtFyDaTRQ5CFf4ZxvQPIbD+SXi5Cbrl6qtrZG0cjUihPkC\n" + + "Hi1hAkIAiEcO7nMPgQLny+GrciojfN+bZXME/dPz6KHBm/89f8Me+jawVnv6y+df\n" + + "2Sbafh1KV6ntWQtB4bK3MXV8Ym9Eg1I=\n" + + "-----END CERTIFICATE-----", + "MIHuAgEAMBAGByqGSM49AgEGBSuBBAAjBIHWMIHTAgEBBEIAV8dZszV6+nLw3LeA\n" + + "Q+qLJLGaqyjlsQkaopCPcmoRdy1HX6AzB/YnKsPkHp/9DQN6A2JgUhFG5B0XvKSk\n" + + "BqNNuSGhgYkDgYYABACYUPlWYHYx3InqT4R4/gmdysTrnJIvTuBWYXCevyi063c2\n" + + "1EDLOa+Iw01deOjlHk2o2Mo/imv3YmNPSw4PrnKeCQG0fXnUS/9+Io8vGRcv0bN8\n" + + "p1YdWENftmDoNTJ3O6TNlXb90jKWgAirCXNBUompPtHKkO592eDyGcT1h8qjrKlm\n" + + "Kw=="), + + CA_RSA_2048( + "RSA", + // SHA256withRSA, 2048 bits + // Validity + // Not Before: May 22 07:18:16 2018 GMT + // Not After : May 17 07:18:16 2038 GMT + // Subject Key Identifier: + // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C + "-----BEGIN CERTIFICATE-----\n" + + "MIIDSTCCAjGgAwIBAgIJAI4ZF3iy8zG+MA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + + "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + + "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMDsxCzAJBgNVBAYT\n" + + "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + + "ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALpMcY7aWieXDEM1/YJf\n" + + "JW27b4nRIFZyEYhEloyGsKTuQiiQjc8cqRZFNXe2vwziDB4IyTEl0Hjl5QF6ZaQE\n" + + "huPzzwvQm1pv64KrRXrmj3FisQK8B5OWLty9xp6xDqsaMRoyObLK+oIb20T5fSlE\n" + + "evmo1vYjnh8CX0Yzx5Gr5ye6YSEHQvYOWEws8ad17OlyToR2KMeC8w4qo6rs59pW\n" + + "g7Mxn9vo22ImDzrtAbTbXbCias3xlE0Bp0h5luyf+5U4UgksoL9B9r2oP4GrLNEV\n" + + "oJk57t8lwaR0upiv3CnS8LcJELpegZub5ggqLY8ZPYFQPjlK6IzLOm6rXPgZiZ3m\n" + + "RL0CAwEAAaNQME4wHQYDVR0OBBYEFA3dk8n+S701t+iZeJD721o92xVMMB8GA1Ud\n" + + "IwQYMBaAFA3dk8n+S701t+iZeJD721o92xVMMAwGA1UdEwQFMAMBAf8wDQYJKoZI\n" + + "hvcNAQELBQADggEBAJTRC3rKUUhVH07/1+stUungSYgpM08dY4utJq0BDk36BbmO\n" + + "0AnLDMbkwFdHEoqF6hQIfpm7SQTmXk0Fss6Eejm8ynYr6+EXiRAsaXOGOBCzF918\n" + + "/RuKOzqABfgSU4UBKECLM5bMfQTL60qx+HdbdVIpnikHZOFfmjCDVxoHsGyXc1LW\n" + + "Jhkht8IGOgc4PMGvyzTtRFjz01kvrVQZ75aN2E0GQv6dCxaEY0i3ypSzjUWAKqDh\n" + + "3e2OLwUSvumcdaxyCdZAOUsN6pDBQ+8VRG7KxnlRlY1SMEk46QgQYLbPDe/+W/yH\n" + + "ca4PejicPeh+9xRAwoTpiE2gulfT7Lm+fVM7Ruc=\n" + + "-----END CERTIFICATE-----", + "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC6THGO2lonlwxD\n" + + "Nf2CXyVtu2+J0SBWchGIRJaMhrCk7kIokI3PHKkWRTV3tr8M4gweCMkxJdB45eUB\n" + + "emWkBIbj888L0Jtab+uCq0V65o9xYrECvAeTli7cvcaesQ6rGjEaMjmyyvqCG9tE\n" + + "+X0pRHr5qNb2I54fAl9GM8eRq+cnumEhB0L2DlhMLPGndezpck6EdijHgvMOKqOq\n" + + "7OfaVoOzMZ/b6NtiJg867QG0212womrN8ZRNAadIeZbsn/uVOFIJLKC/Qfa9qD+B\n" + + "qyzRFaCZOe7fJcGkdLqYr9wp0vC3CRC6XoGbm+YIKi2PGT2BUD45SuiMyzpuq1z4\n" + + "GYmd5kS9AgMBAAECggEAFHSoU2MuWwJ+2jJnb5U66t2V1bAcuOE1g5zkWvG/G5z9\n" + + "rq6Qo5kmB8f5ovdx6tw3MGUOklLwnRXBG3RxDJ1iokz3AvkY1clMNsDPlDsUrQKF\n" + + "JSO4QUBQTPSZhnsyfR8XHSU+qJ8Y+ohMfzpVv95BEoCzebtXdVgxVegBl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5caV79yQ8QGY5mUVH3E+VXSxuIqb6pZq2DH4sTAEFHyncddmOH\n" + + "zoXBInYwRG9KE/Bw5elhUw=="), + + CA_RSA_512( // for DisabledShortRSAKeys test + "RSA", + // md5WithRSAEncryption, 1024 bits + // Validity + // Not Before: Aug 19 01:52:19 2011 GMT + // Not After : Jul 29 01:52:19 2032 GMT + // X509v3 Authority Key Identifier: + // keyid:B9:7C:D5:D9:DF:A7:4C:03:AE:FD:0E:27:5B:31:95:6C:C7:F3:75:E1 + // DirName:/C=US/O=Java/OU=SunJSSE Test Serivce + // serial:00 + "-----BEGIN CERTIFICATE-----\n" + + "MIICkjCCAfugAwIBAgIBADANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJVUzEN\n" + + "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwHhcN\n" + + "MTEwODE5MDE1MjE5WhcNMzIwNzI5MDE1MjE5WjA7MQswCQYDVQQGEwJVUzENMAsG\n" + + "A1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwgZ8wDQYJ\n" + + "KoZIhvcNAQEBBQADgY0AMIGJAoGBAM8orG08DtF98TMSscjGsidd1ZoN4jiDpi8U\n" + + "ICz+9dMm1qM1d7O2T+KH3/mxyox7Rc2ZVSCaUD0a3CkhPMnlAx8V4u0H+E9sqso6\n" + + "iDW3JpOyzMExvZiRgRG/3nvp55RMIUV4vEHOZ1QbhuqG4ebN0Vz2DkRft7+flthf\n" + + "vDld6f5JAgMBAAGjgaUwgaIwHQYDVR0OBBYEFLl81dnfp0wDrv0OJ1sxlWzH83Xh\n" + + "MGMGA1UdIwRcMFqAFLl81dnfp0wDrv0OJ1sxlWzH83XhoT+kPTA7MQswCQYDVQQG\n" + + "EwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2\n" + + "Y2WCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAQYwDQYJKoZIhvcNAQEE\n" + + "BQADgYEALlgaH1gWtoBZ84EW8Hu6YtGLQ/L9zIFmHonUPZwn3Pr//icR9Sqhc3/l\n" + + "pVTxOINuFHLRz4BBtEylzRIOPzK3tg8XwuLb1zd0db90x3KBCiAL6E6cklGEPwLe\n" + + "XYMHDn9eDsaq861Tzn6ZwzMgw04zotPMoZN0mVd/3Qca8UJFucE=\n" + + "-----END CERTIFICATE-----", + "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAtz2+PTkj3zg9hh0l\n" + + "xQhcdRiRGX6hvWVH+8biIv62uXS4zxgGqGOUBdkDmvFZzq4kAlw38lx8bLkZxDqJ\n" + + "sS+xFQIDAQABAkByx/5Oo2hQ/w2q4L8z+NTRlJ3vdl8iIDtC/4XPnfYfnGptnpG6\n" + + "ZThQRvbMZiai0xHQPQMszvAHjZVme1eDl3EBAiEA3aKJHynPVCEJhpfCLWuMwX5J\n" + + "1LntwJO7NTOyU5m8rPECIQDTpzn5X44r2rzWBDna/Sx7HW9IWCxNgUD2Eyi2nA7W\n" + + "ZQIgJerEorw4aCAuzQPxiGu57PB6GRamAihEAtoRTBQlH0ECIQDN08FgTtnesgCU\n" + + "DFYLLcw1CiHvc7fZw4neBDHCrC8NtQIgA8TOUkGnpCZlQ0KaI8KfKWI+vxFcgFnH\n" + + "3fnqsTgaUs4=" + + ), + + CA_DSA_2048( + "DSA", + // SHA256withDSA, 2048 bits + // Validity + // Not Before: May 22 07:18:18 2018 GMT + // Not After : May 17 07:18:18 2038 GMT + // Subject Key Identifier: + // 76:66:9E:F7:3B:DD:45:E5:3B:D9:72:3C:3F:F0:54:39:86:31:26:53 + "-----BEGIN CERTIFICATE-----\n" + + "MIIErjCCBFSgAwIBAgIJAOktYLNCbr02MAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" + + "EwJVUzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSB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ZOjufVWP7hhEz8xPobb1CS4e3vuQiv5UBfhdPL3f3l9T7JMAKPH6C9Vve\n" + + "OQXE5eGqbjsySbcmseHoYUt1WCSnSda1opX8zchX04e7DhGfE2/L9flpYEoSt8lI\n" + + "vMNjgOwvKdW3yvPt1/eBBHYNFG5gWPv/Q5KoyCtHS03uqGm4rNc/wZTIEEfd66C+\n" + + "QRaUltjOaHmtwOdDHaNqwhYZSVOip+Mo+TfyzHFREcdHLapo7ZXqbdYkRGxRR3d+\n" + + "3DfHaraJO0OKoYlPkr3JMvM/MSGR9AnZOcejUDBOMB0GA1UdDgQWBBR2Zp73O91F\n" + + "5TvZcjw/8FQ5hjEmUzAfBgNVHSMEGDAWgBR2Zp73O91F5TvZcjw/8FQ5hjEmUzAM\n" + + "BgNVHRMEBTADAQH/MAsGCWCGSAFlAwQDAgNHADBEAiBzriYE41M2y9Hy5ppkL0Qn\n" + + "dIlNc8JhXT/PHW7GDtViagIgMko8Qoj9gDGPK3+O9E8DC3wGiiF9CObM4LN387ok\n" + + "J+g=\n" + + "-----END CERTIFICATE-----", + "MIICZQIBADCCAjkGByqGSM44BAEwggIsAoIBAQDuRsj4UptM3ty0rvoInHVCy49O" + + "Yjn0y1L2UNvbGM+Nc5qqywUG3Soh6oCbtkXvbIE2+bLizYxdOO0ziz51N44T7Vpt" + + "l/F84lRiHB8pv0PzHmcUrbf/PLHqq6CN1jisyDC9hnK4rIU/pXBq7R9+k39frntk" + + "p59z0lsscoDaj45ZT+blI2JhS7wH+ECzJXZHfw9lcXMLB4wfMuYlGbF3s3PyxIUW" + + "Uv9Npor6pUcNwDJKvzlXv2bcRVrD9J7H8RBnWbmlBaaaRn4scRb8pqwd/iedXE7f" + + "qWQQ6g9stA2H3PvPIgrOI8B033AyKS2+d/BwYwY9qxILUBEkJgdKKA//sLD7AiEA" + + "tW2HIYBJTbQ2C9xYKS4DUlGKe4CFr/XoWguyzts+24kCggEAYrbxTpw5FI2vDQBe" + + "5Q6TlW+YqUPEonAS1t5EGpsYcrssYGcsvz6I2f6D6K5Klv0/wNK4ZxujLLBKQLXY" + + "sFQfnKwWBqN23MJhMSYXTienWLihaaT1oQsCjB7PZ6SvpagTJfJeY+fMZXBXgu2X" + + "xn/BmBpIRVtHOOLxEITDG2nOmU0z+JsPtbe8SX5gzJSxMiKU12gAJPLqFS1s0Fp0" + + "eNLB4sm70tLtycUJG+/8vLTjmbvKpc/2Dku5UOlMVBl9uwntRNPmoHz6YXraEQJU" + + "tXHs6lmu6+uBmtJ5I9ZMJHEao4E4icdDcJ1F6+/FQFxYVRfefjt5X6ob3bRBrZIQ" + + "xj4OzQQjAiEAsceWOM8do4etxp2zgnoNXV8PUUyqWhz1+0srcKV7FR4="), + + CA_DSA_1024( + "DSA", + // dsaWithSHA1, 1024 bits + // Validity + // Not Before: Apr 24 12:25:43 2020 GMT + // Not After : Apr 22 12:25:43 2030 GMT + // Authority Key Identifier: + // E1:3C:01:52:EB:D1:38:F7:CF:F1:E3:5E:DB:54:75:7F:5E:AB:2D:36 + "-----BEGIN CERTIFICATE-----\n" + + "MIIC9TCCArWgAwIBAgIUd52yKk0OxQuxdaYRAfq5VLuF1ZAwCQYHKoZIzjgEAzAu\n" + + "MQswCQYDVQQGEwJVUzENMAsGA1UECgwESmF2YTEQMA4GA1UECwwHU3VuSlNTRTAe\n" + + "Fw0yMDA0MjQxMjI1NDJaFw0zMDA0MjIxMjI1NDJaMC4xCzAJBgNVBAYTAlVTMQ0w\n" + + "CwYDVQQKDARKYXZhMRAwDgYDVQQLDAdTdW5KU1NFMIIBtjCCASsGByqGSM44BAEw\n" + + "ggEeAoGBAKgyb2XpANq43T8yBf5v0PTBOddLPxd0f0FotASron5rQr86JjBTfgIW\n" + + "oE4u7nYlO6bp/M4Dw6qZr+HaDu9taIDOj6LL51eUShVsOgS7XZcUzLT8vPnkEDDo\n" + + "u326x0B7fuNCbMLm+ipM2d4FhLUTt4Qb5TcY6l7dOGHeWiL7nl43AhUAoGr8DY2m\n" + + "WHZPHk2XbZ5wpaM2lLcCgYBKiFbFFViH/ylHJRPtYtjtJw4ls1scbVP4TRHnKoZc\n" + + "HPAird1fDYgGC2b0GQNAMABhI+L+ogxS7qakySpJCheuN25AjiSyilygQdlXoWRt\n" + + "Mggsh8EQZT7iP4V4e9m3xRHzb5ECvsSTdZB1BQMcC90W2Avq+orqgBnr2in9UEd8\n" + + "qwOBhAACgYAgVWxjYWlWIv7s4BnNMQoPKppi205f3aC6wv6Rqk4BnYYYrFONEmzQ\n" + + "hzj6lSXfxLpTu4lg2zNeIraZggoS0ztkbZNNADEmAHx+OLshiJJxu2/KfoopJOZg\n" + + "8ARmuaKOkWbkW9y4hWhfBlVwZbckG3Eibff0xronIXXy7B7UKaccyqNTMFEwHQYD\n" + + "VR0OBBYEFOE8AVLr0Tj3z/HjXttUdX9eqy02MB8GA1UdIwQYMBaAFOE8AVLr0Tj3\n" + + "z/HjXttUdX9eqy02MA8GA1UdEwEB/wQFMAMBAf8wCQYHKoZIzjgEAwMvADAsAhRC\n" + + "YLduLniBEJ51SfBWIkvNW6OG7QIUSKaTY6rgEFDEMoTqOjFChR22nkk=\n" + + "-----END CERTIFICATE-----", + "MIIBSgIBADCCASsGByqGSM44BAEwggEeAoGBAKgyb2XpANq43T8yBf5v0PTBOddL\n" + + "Pxd0f0FotASron5rQr86JjBTfgIWoE4u7nYlO6bp/M4Dw6qZr+HaDu9taIDOj6LL\n" + + "51eUShVsOgS7XZcUzLT8vPnkEDDou326x0B7fuNCbMLm+ipM2d4FhLUTt4Qb5TcY\n" + + "6l7dOGHeWiL7nl43AhUAoGr8DY2mWHZPHk2XbZ5wpaM2lLcCgYBKiFbFFViH/ylH\n" + + "JRPtYtjtJw4ls1scbVP4TRHnKoZcHPAird1fDYgGC2b0GQNAMABhI+L+ogxS7qak\n" + + "ySpJCheuN25AjiSyilygQdlXoWRtMggsh8EQZT7iP4V4e9m3xRHzb5ECvsSTdZB1\n" + + "BQMcC90W2Avq+orqgBnr2in9UEd8qwQWAhQ7rSn+WvIxeuZ/CK4p04eMe5JzpA=="), + + CA_ED25519( + "EdDSA", + // ED25519 + // Validity + // Not Before: May 24 23:32:35 2020 GMT + // Not After : May 22 23:32:35 2030 GMT + // X509v3 Authority Key Identifier: + // keyid:06:76:DB:88:EB:61:55:4C:C9:63:41:C2:A0:A8:57:3F:D7:F1:B8:EC + "-----BEGIN CERTIFICATE-----\n" + + "MIIByTCCAXugAwIBAgIUCyxKvhErehsygx50JYArsHby9hAwBQYDK2VwMDsxCzAJ\n" + + "BgNVBAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3Qg\n" + + "U2VyaXZjZTAeFw0yMDA1MjQyMzMyMzVaFw0zMDA1MjIyMzMyMzVaMDsxCzAJBgNV\n" + + "BAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + + "aXZjZTAqMAUGAytlcAMhAKdotuYIkH8PYbopSLbaf1BtqUY2d6AbTgK2prMzQ6B3\n" + + "o4GQMIGNMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFAZ224jrYVVMyWNBwqCo\n" + + "Vz/X8bjsMB8GA1UdIwQYMBaAFAZ224jrYVVMyWNBwqCoVz/X8bjsMA4GA1UdDwEB\n" + + "/wQEAwIBhjAqBgNVHSUBAf8EIDAeBggrBgEFBQcDAwYIKwYBBQUHAwgGCCsGAQUF\n" + + "BwMJMAUGAytlcANBADVAArvME8xFigFhCCCOTBoy/4ldGkDZQ/GT3Q6xnAP558FU\n" + + "0G32OprKQZP43D9bmFU0LMgCVM9bHWU+bu/10AU=\n" + + "-----END CERTIFICATE-----", + "MC4CAQAwBQYDK2VwBCIEII/VYp8nu/eqq2L5y7/3IzavBgis4LWP6Rikv0N8SpgL"), + + CA_ED448( + "EdDSA", + // ED448 + // Validity + // Not Before: May 24 23:23:43 2020 GMT + // Not After : May 22 23:23:43 2030 GMT + // X509v3 Authority Key Identifier: + // keyid:F5:D5:9D:FB:6F:B7:50:29:DF:F0:B8:83:10:5F:9B:C4:A8:1C:E9:F4 + "-----BEGIN CERTIFICATE-----\n" + + "MIICFDCCAZSgAwIBAgIUKcmLeKilq0LN40sniBJO7F1gb/owBQYDK2VxMDsxCzAJ\n" + + "BgNVBAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3Qg\n" + + "U2VyaXZjZTAeFw0yMDA1MjQyMzIzNDNaFw0zMDA1MjIyMzIzNDNaMDsxCzAJBgNV\n" + + "BAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + + "aXZjZTBDMAUGAytlcQM6APYP8iSXS8xPVDike5RgCByfTtg4GGtpYfoBtt6G5szA\n" + + "55ExAKjm03wtk29nEPU2mCHF2QgfBzUrgKOBkDCBjTAPBgNVHRMBAf8EBTADAQH/\n" + + "MB0GA1UdDgQWBBT11Z37b7dQKd/wuIMQX5vEqBzp9DAfBgNVHSMEGDAWgBT11Z37\n" + + "b7dQKd/wuIMQX5vEqBzp9DAOBgNVHQ8BAf8EBAMCAYYwKgYDVR0lAQH/BCAwHgYI\n" + + "KwYBBQUHAwMGCCsGAQUFBwMIBggrBgEFBQcDCTAFBgMrZXEDcwAlRXA2gPb52yV3\n" + + "MKJErjmKlYSFExj5w5jafbbd0QgI1yDs+qSaZLjQ8ljwabmLDg+KR+167m0djQDI\n" + + "OOoVuL7bgM0RL836KnuuBzm+gTdPp0gCXy3k9lL0KA0V2YLJHXXzu3suu+7rdgoP\n" + + "plCh2hWdLgA=\n" + + "-----END CERTIFICATE-----", + "MEcCAQAwBQYDK2VxBDsEOd6/hRZqkUyTlJSwdN5gO/HnoWYda1fD83YUm5j6m2Bg\n" + + "hAQi+QadFsQLD7R6PI/4Q0twXqlKnxU5Ug=="), + + EE_ECDSA_SECP256R1( + "EC", + // SHA256withECDSA, curve secp256r1 + // Validity + // Not Before: May 22 07:18:16 2018 GMT + // Not After : May 17 07:18:16 2038 GMT + // Authority Key Identifier: + // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 + "-----BEGIN CERTIFICATE-----\n" + + "MIIBqjCCAVCgAwIBAgIJAPLY8qZjgNRAMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + + "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + + "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMFUxCzAJBgNVBAYTAlVT\n" + + "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTEY\n" + + "MBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD\n" + + "QgAEb+9n05qfXnfHUb0xtQJNS4JeSi6IjOfW5NqchvKnfJey9VkJzR7QHLuOESdf\n" + + "xlR7q8YIWgih3iWLGfB+wxHiOqMjMCEwHwYDVR0jBBgwFoAUYM+9c//6GjDSpOzT\n" + + "SXFG7xo1oIYwCgYIKoZIzj0EAwIDSAAwRQIgWpRegWXMheiD3qFdd8kMdrkLxRbq\n" + + "1zj8nQMEwFTUjjQCIQDRIrAjZX+YXHN9b0SoWWLPUq0HmiFIi8RwMnO//wJIGQ==\n" + + "-----END CERTIFICATE-----", + "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgn5K03bpTLjEtFQRa\n" + + "JUtx22gtmGEvvSUSQdimhGthdtihRANCAARv72fTmp9ed8dRvTG1Ak1Lgl5KLoiM\n" + + "59bk2pyG8qd8l7L1WQnNHtAcu44RJ1/GVHurxghaCKHeJYsZ8H7DEeI6"), + + EE_ECDSA_SECP384R1( + "EC", + // SHA384withECDSA, curve secp384r1 + // Validity + // Not Before: Jun 24 08:15:06 2019 GMT + // Not After : Jun 19 08:15:06 2039 GMT + // Authority Key Identifier: + // 40:2D:AA:EE:66:AA:33:27:AD:9B:5D:52:9B:60:67:6A:2B:AD:52:D2 + "-----BEGIN CERTIFICATE-----\n" + + "MIICEjCCAZegAwIBAgIUS3F0AqAXWRg07CnbknJzxofyBQMwCgYIKoZIzj0EAwMw\n" + + "OzELMAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0Ug\n" + + "VGVzdCBTZXJpdmNlMB4XDTE5MDYyNDA4MTUwNloXDTM5MDYxOTA4MTUwNlowVTEL\n" + + "MAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVz\n" + + "dCBTZXJpdmNlMRgwFgYDVQQDDA9SZWdyZXNzaW9uIFRlc3QwdjAQBgcqhkjOPQIB\n" + + "BgUrgQQAIgNiAARqElz8b6T07eyKomIinhztV3/3XBk9bKGtJ0W+JOltjuhMmP/w\n" + + "G8ASSevpgqgpi6EzpBZaaJxE3zNfkNnxXOZmQi2Ypd1uK0zRdbEOKg0XOcTTZwEj\n" + + "iLjYmt3O0pwpklijQjBAMB0GA1UdDgQWBBRALaruZqozJ62bXVKbYGdqK61S0jAf\n" + + "BgNVHSMEGDAWgBRKS1IUCtHWn/mZdXSTKjRHEhVr9TAKBggqhkjOPQQDAwNpADBm\n" + + "AjEArVDFKf48xijN6huVUJzKCOP0zlWB5Js+DItIkZmLQuhciPLhLIB/rChf3Y4C\n" + + "xuP4AjEAmfLhQRI0O3pifpYzYSVh2G7/jHNG4eO+2dvgAcU+Lh2IIj/cpLaPFSvL\n" + + "J8FXY9Nj\n" + + "-----END CERTIFICATE-----", + "MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDASuI9EtK29APXPipkc\n" + + "qDA+qwlewMjv/OcjUJ77kP1Vz62oVF9iY9SRIyFIUju8wt+hZANiAARqElz8b6T0\n" + + "7eyKomIinhztV3/3XBk9bKGtJ0W+JOltjuhMmP/wG8ASSevpgqgpi6EzpBZaaJxE\n" + + "3zNfkNnxXOZmQi2Ypd1uK0zRdbEOKg0XOcTTZwEjiLjYmt3O0pwpklg="), + + EE_ECDSA_SECP521R1( + "EC", + // SHA512withECDSA, curve secp521r1 + // Validity + // Not Before: Jun 24 08:15:06 2019 GMT + // Not After : Jun 19 08:15:06 2039 GMT + // Authority Key Identifier: + // 7B:AA:79:A4:49:DD:59:34:F0:86:6C:51:C7:30:F4:CE:C5:81:8A:28 + "-----BEGIN CERTIFICATE-----\n" + + "MIICXDCCAb2gAwIBAgIUck4QTsbHNqUfPxfGPJLYbedFPdswCgYIKoZIzj0EAwQw\n" + + "OzELMAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0Ug\n" + + "VGVzdCBTZXJpdmNlMB4XDTE5MDYyNDA4MTUwNloXDTM5MDYxOTA4MTUwNlowVTEL\n" + + "MAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVz\n" + + "dCBTZXJpdmNlMRgwFgYDVQQDDA9SZWdyZXNzaW9uIFRlc3QwgZswEAYHKoZIzj0C\n" + + "AQYFK4EEACMDgYYABAGa2zDLhYQHHCLI3YBqFYJTzrnDIjzwXrxhcRTS8DYkcrjZ\n" + + "+Fih1YyNhix0sdjH+3EqElXAHHuVzn3n3hPOtQCWlQCICkErB34S0cvmtRkeW8Fi\n" + + "hrR5tvJEzEZjPSgwn81kKyhV2L70je6i7Cw884Va8bODckpgw0vTmbQb7T9dupkv\n" + + "1aNCMEAwHQYDVR0OBBYEFHuqeaRJ3Vk08IZsUccw9M7FgYooMB8GA1UdIwQYMBaA\n" + + "FEAivFrtaq2pQJ4cW4pEQML3aym9MAoGCCqGSM49BAMEA4GMADCBiAJCAb33KHdY\n" + + "WDbusORWoY8Euglpd5zsF15hJsk7wtpD5HST1/NWmdCx405w+TV6a9Gr4VPHeaIQ\n" + + "99i/+f237ALL5p6IAkIBbwwFL1vt3c/bx+niyuffQPNjly80rdC9puqAqriSiboS\n" + + "efhxjidJ9HLaIRCMEPyd6vAsC8mO8YvL1uCuEQLsiGM=\n" + + "-----END CERTIFICATE-----", + "MIHuAgEAMBAGByqGSM49AgEGBSuBBAAjBIHWMIHTAgEBBEIB8C/2OX2Dt9vFszzV\n" + + "hcAe0CbkMlvu9uQ/L7Vz88heuIj0rUZIPGshvgIJt1hCMT8HZxYHvDa4lbUvqjFB\n" + + "+zafvPWhgYkDgYYABAGa2zDLhYQHHCLI3YBqFYJTzrnDIjzwXrxhcRTS8DYkcrjZ\n" + + "+Fih1YyNhix0sdjH+3EqElXAHHuVzn3n3hPOtQCWlQCICkErB34S0cvmtRkeW8Fi\n" + + "hrR5tvJEzEZjPSgwn81kKyhV2L70je6i7Cw884Va8bODckpgw0vTmbQb7T9dupkv\n" + + "1Q=="), + + EE_RSA_2048( + "RSA", + // SHA256withRSA, 2048 bits + // Validity + // Not Before: May 22 07:18:16 2018 GMT + // Not After : May 17 07:18:16 2038 GMT + // Authority Key Identifier: + // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C + "-----BEGIN CERTIFICATE-----\n" + + "MIIDNjCCAh6gAwIBAgIJAO2+yPcFryUTMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + + "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + + "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMFUxCzAJBgNVBAYT\n" + + "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + + "ZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOC\n" + + "AQ8AMIIBCgKCAQEAszfBobWfZIp8AgC6PiWDDavP65mSvgCXUGxACbxVNAfkLhNR\n" + + "QOsHriRB3X1Q3nvO9PetC6wKlvE9jlnDDj7D+1j1r1CHO7ms1fq8rfcQYdkanDtu\n" + + "4AlHo8v+SSWX16MIXFRYDj2VVHmyPtgbltcg4zGAuwT746FdLI94uXjJjq1IOr/v\n" + + "0VIlwE5ORWH5Xc+5Tj+oFWK0E4a4GHDgtKKhn2m72hN56/GkPKGkguP5NRS1qYYV\n" + + "/EFkdyQMOV8J1M7HaicSft4OL6eKjTrgo93+kHk+tv0Dc6cpVBnalX3TorG8QI6B\n" + + "cHj1XQd78oAlAC+/jF4pc0mwi0un49kdK9gRfQIDAQABoyMwITAfBgNVHSMEGDAW\n" + + "gBQN3ZPJ/ku9NbfomXiQ+9taPdsVTDANBgkqhkiG9w0BAQsFAAOCAQEApXS0nKwm\n" + + "Kp8gpmO2yG1rpd1+2wBABiMU4JZaTqmma24DQ3RzyS+V2TeRb29dl5oTUEm98uc0\n" + + "GPZvhK8z5RFr4YE17dc04nI/VaNDCw4y1NALXGs+AHkjoPjLyGbWpi1S+gfq2sNB\n" + + "Ekkjp6COb/cb9yiFXOGVls7UOIjnVZVd0r7KaPFjZhYh82/f4PA/A1SnIKd1+nfH\n" + + "2yk7mSJNC7Z3qIVDL8MM/jBVwiC3uNe5GPB2uwhd7k5LGAVN3j4HQQGB0Sz+VC1h\n" + + "92oi6xDa+YBva2fvHuCd8P50DDjxmp9CemC7rnZ5j8egj88w14X44Xjb/Fd/ApG9\n" + + "e57NnbT7KM+Grw==\n" + + "-----END CERTIFICATE-----", + "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCzN8GhtZ9kinwC\n" + + "ALo+JYMNq8/rmZK+AJdQbEAJvFU0B+QuE1FA6weuJEHdfVDee870960LrAqW8T2O\n" + + "WcMOPsP7WPWvUIc7uazV+ryt9xBh2RqcO27gCUejy/5JJZfXowhcVFgOPZVUebI+\n" +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AMJOCM4KZw5mmh4XOEq09Ivba8AHU7DbaTv3\n" + + "7QL7KnbaUWRB26HHzIMYVh0el6T+KADf8NXCiMTr+bfpfbL3dxoiF3zhAoGAbCJD\n" + + "Qse1dBs/cKYCHfkSOsI5T6kx52Tw0jS6Y4X/FOBjyqr/elyEexbdk8PH9Ar931Qr\n" + + "NKMvn8oA4iA/PRrXX7M2yi3YQrWwbkGYWYjtzrzEAdzmg+5eARKAeJrZ8/bg9l3U\n" + + "ttKaItJsDPlizn8rngy3FsJpR9aSAMK6/+wOiYkCgYEA1tZkI1rD1W9NYZtbI9BE\n" + + "qlJVFi2PBOJMKNuWdouPX3HLQ72GJSQff2BFzLTELjweVVJ0SvY4IipzpQOHQOBy\n" + + "5qh/p6izXJZh3IHtvwVBjHoEVplg1b2+I5e3jDCfqnwcQw82dW5SxOJMg1h/BD0I\n" + + "qAL3go42DYeYhu/WnECMeis="), + + EE_EC_RSA_SECP256R1( + "EC", + // SHA256withRSA, curve secp256r1 + // Validity + // Not Before: May 22 07:18:16 2018 GMT + // Not After : May 21 07:18:16 2028 GMT + // Authority Key Identifier: + // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C + "-----BEGIN CERTIFICATE-----\n" + + "MIICazCCAVOgAwIBAgIJAO2+yPcFryUUMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + + "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + + "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0yODA1MjEwNzE4MTZaMFUxCzAJBgNVBAYT\n" + + "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + + "ZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0D\n" + + "AQcDQgAE59MERNTlVZ1eeps8Z3Oue5ZkgQdPtD+WIE6tj3PbIKpxGPDxvfNP959A\n" + + "yQjEK/ehWQVrCMmNoEkIzY+IIBgB06MjMCEwHwYDVR0jBBgwFoAUDd2Tyf5LvTW3\n" + + "6Jl4kPvbWj3bFUwwDQYJKoZIhvcNAQELBQADggEBAFOTVEqs70ykhZiIdrEsF1Ra\n" + + "I3B2rLvwXZk52uSltk2/bzVvewA577ZCoxQ1pL7ynkisPfBN1uVYtHjM1VA3RC+4\n" + + "+TAK78dnI7otYjWoHp5rvs4l6c/IbOspS290IlNuDUxMErEm5wxIwj+Aukx/1y68\n" + + "hOyCvHBLMY2c1LskH1MMBbDuS1aI+lnGpToi+MoYObxGcV458vxuT8+wwV8Fkpvd\n" + + "ll8IIFmeNPRv+1E+lXbES6CSNCVaZ/lFhPgdgYKleN7sfspiz50DG4dqafuEAaX5\n" + + "xaK1NWXJxTRz0ROH/IUziyuDW6jphrlgit4+3NCzp6vP9hAJQ8Vhcj0n15BKHIQ=\n" + + "-----END CERTIFICATE-----", + "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGVc7hICpmp91jbYe\n" + + "nrr8nYHD37RZP3VENY+szuA7WjuhRANCAATn0wRE1OVVnV56mzxnc657lmSBB0+0\n" + + "P5YgTq2Pc9sgqnEY8PG980/3n0DJCMQr96FZBWsIyY2gSQjNj4ggGAHT"), + + EE_RSA_512( + "RSA", + // md5WithRSAEncryption, 512 bits + // Validity + // Not Before: Nov 7 13:55:52 2011 GMT + // Not After : Jul 25 13:55:52 2031 GMT + // X509v3 Authority Key Identifier: + // B9:7C:D5:D9:DF:A7:4C:03:AE:FD:0E:27:5B:31:95:6C:C7:F3:75:E1 + "-----BEGIN CERTIFICATE-----\n" + + "MIICNDCCAZ2gAwIBAgIBDDANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJVUzEN\n" + + "MAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2UwH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A7W\n" + + "ZQIgJerEorw4aCAuzQPxiGu57PB6GRamAihEAtoRTBQlH0ECIQDN08FgTtnesgCU\n" + + "DFYLLcw1CiHvc7fZw4neBDHCrC8NtQIgA8TOUkGnpCZlQ0KaI8KfKWI+vxFcgFnH\n" + + "3fnqsTgaUs4=" + ), + + EE_DSA_2048( + "DSA", + // SHA256withDSA, 2048 bits + // Validity + // Not Before: May 22 07:18:20 2018 GMT + // Not After : May 17 07:18:20 2038 GMT + // Authority Key Identifier: + // 76:66:9E:F7:3B:DD:45:E5:3B:D9:72:3C:3F:F0:54:39:86:31:26:53 + "-----BEGIN CERTIFICATE-----\n" + + "MIIEnDCCBEGgAwIBAgIJAP/jh1qVhNVjMAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" + + "EwJVUzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2\n" + + "Y2UwHhcNMTgwNTIyMDcxODIwWhcNMzgwNTE3MDcxODIwWjBVMQswCQYDVQQGEwJV\n" + + "UzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2Ux\n" + + "GDAWBgNVBAMMD1JlZ3Jlc3Npb24gVGVzdDCCA0cwggI6BgcqhkjOOAQBMIICLQKC\n" + + "AQEAmlavgoJrMcjqWRVcDE2dmWAPREgnzQvneEDef68cprDzjSwvOs5QeFyx75ib\n" + + "ado1e6jO/rW1prCGWHDD1oA/Tn4Pk3vu0nUxzvl1qATc+aJbpUU5Op0bvp6LbCsQ\n" + + "QslV9FeRh7Eb7bP6gpc/kHCBzEgC1VCK7prccXWy+t6SMOHbND3h+UbckfSaUuaV\n" + + "sVJNTD1D6GElfRj4Nmz1BGPfSYvKorwNZEU3gXwFgtDoAcGx7tcyClLpDHfqRfw/\n" + + "7yiqLyeiP7D4hl5lMNouJWDlAdMFp0FMgS3s9VDFinIcr6VtBWMTG7+4+czHAB+3\n" + + "fvrwlqNzhBn3uFHrekN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oIBAQCaVq+CgmsxyOpZFVwMTZ2ZYA9E\n" + + "SCfNC+d4QN5/rxymsPONLC86zlB4XLHvmJtp2jV7qM7+tbWmsIZYcMPWgD9Ofg+T\n" + + "e+7SdTHO+XWoBNz5olulRTk6nRu+notsKxBCyVX0V5GHsRvts/qClz+QcIHMSALV\n" + + "UIrumtxxdbL63pIw4ds0PeH5RtyR9JpS5pWxUk1MPUPoYSV9GPg2bPUEY99Ji8qi\n" + + "vA1kRTeBfAWC0OgBwbHu1zIKUukMd+pF/D/vKKovJ6I/sPiGXmUw2i4lYOUB0wWn\n" + + "QUyBLez1UMWKchyvpW0FYxMbv7j5zMcAH7d++vCWo3OEGfe4Uet6Q3/Dx83HAiEA\n" + + "mjtJp7XNrsgxbRDqETkHhv6zYH8Voo+gDgSO1m7XcH0CggEBAI5moswp++plZSBP\n" + + "Q9DdCNHt0AV13Toj1jf5M5DNmTX6P6/D/oRfi8Ui1fiCKFv+7lD0J2anCFUaLtu+\n" + + "j7v78gp5OChDp/n49K6DtKtZZRDmw/Bpm6LNdknmdN5kO5wVzbIXHTCCeNs/CJTF\n" + + "mSU5PvEaI4y3M5NraSgLPkq4gEv7/A8orGbKmj1Whj3F9t1Tosxdm/+WkPldMz2t\n" + + "gev+9RM2S6S9XoembRgwRaFVkpQmKoKpOoZcdqV47FLDq5BYH/5POeJ9wLuAHjxQ\n" + + "5CMKo4p/lW7BCd4kuGWFT+OFFXfG2v6EtlqFbXBiFWLxyMsOtkUqWARCqEHhyucl\n" + + "TSYlj60EIgIgLfA75+8KcKxdN8mr6gzGjQe7jPFGG42Ejhd7Q2F4wuw="), + + EE_DSA_1024( + "DSA", + // dsaWithSHA1, 1024 bits + // Validity + // Not Before: Apr 24 12:25:43 2020 GMT + // Not After : Apr 22 12:25:43 2030 GMT + // Authority Key Identifier: + // E1:3C:01:52:EB:D1:38:F7:CF:F1:E3:5E:DB:54:75:7F:5E:AB:2D:36 + "-----BEGIN CERTIFICATE-----\n" + + "MIIDADCC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zzMhZ9St/Vo/YdgNTHdTw4cm14CFQCE6tWG157Wl5YFyYsGHsLY\n" + + "NN8uCA==\n" + + "-----END CERTIFICATE-----", + "MIIBSwIBADCCASwGByqGSM44BAEwggEfAoGBAO30pMWCEpTCU/ovDeVTm5R4Y6z2\n" + + "AMt6Edv2F0Fuk9IQjIZvI5sYJNWwyHfWSh68bDNORJArUWGqmoOGWXhnXssL9yMM\n" + + "GKgkHxrZD8E/UALHUgAWMBjq5YRLWbQRtckOOHPkc/1bPj7ZAMmW3+VRtYksRW/W\n" + + "yOUBSVifWtlaWYefAhUAghgC0KCuDLED/Fe9lpQewb7fXq8CgYEAwsbtBjNoma9C\n" + + "fA2gKPfwoUuJuxO4eic/SjptnBYc2BnpJFFzc58u58s+kKYG7n/CjRSo7aqFAwvL\n" + + "ZXFUAFJU3BEgtE2V0d4dtYZfcMyAYRPpCdY/L9SgMXzmiTsTm5OUBLyGgOY/o4hx\n" + + "sEUubQ6ssDmrc/npsDGb9cCpwjQRJTYEFgIUNRiLmNzfTYOuVsjkySPzP5gPImM="), + + EE_ED25519( + "EdDSA", + // ED25519 + // Validity + // Not Before: May 24 23:32:36 2020 GMT + // Not After : May 22 23:32:36 2030 GMT + // X509v3 Authority Key Identifier: + // keyid:06:76:DB:88:EB:61:55:4C:C9:63:41:C2:A0:A8:57:3F:D7:F1:B8:EC + "-----BEGIN CERTIFICATE-----\n" + + "MIIBlDCCAUagAwIBAgIUFTt/jcgQ65nhTG8LkrWFJhhEGuwwBQYDK2VwMDsxCzAJ\n" + + "BgNVBAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3Qg\n" + + "U2VyaXZjZTAeFw0yMDA1MjQyMzMyMzZaFw0zMDA1MjIyMzMyMzZaMFUxCzAJBgNV\n" + + "BAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + + "aXZjZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MCowBQYDK2VwAyEAGAYQmKb7\n" + + "WNYpVxIdsc49lI1emNjF06/Jl85zlG0wc9OjQjBAMB0GA1UdDgQWBBQkJ2E4/S8Z\n" + + "EIM1v9uTc0eYtYNk3zAfBgNVHSMEGDAWgBQGdtuI62FVTMljQcKgqFc/1/G47DAF\n" + + "BgMrZXADQQCVZnl/AyIEtZ8r45e/hcfxwuezgRX+7e9NHZFV1A/TMGcBRORDfDUi\n" + + "bbh72K528fjT7P4/WoXvm1zJKOAzUOUL\n" + + "-----END CERTIFICATE-----", + "MC4CAQAwBQYDK2VwBCIEIGBmdh4tfc0lng/LWokhfFLlo0ZlmTn2lbI639qou2KP"), + + EE_ED448( + "EdDSA", + // ED448 + // Validity + // Not Before: May 24 23:23:43 2020 GMT + // Not After : May 22 23:23:43 2030 GMT + // X509v3 Authority Key Identifier: + // keyid:F5:D5:9D:FB:6F:B7:50:29:DF:F0:B8:83:10:5F:9B:C4:A8:1C:E9:F4 + "-----BEGIN CERTIFICATE-----\n" + + "MIIB3zCCAV+gAwIBAgIUNlWzFrH2+BILqM3SNYQjKoY98S8wBQYDK2VxMDsxCzAJ\n" + + "BgNVBAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3Qg\n" + + "U2VyaXZjZTAeFw0yMDA1MjQyMzIzNDNaFw0zMDA1MjIyMzIzNDNaMFUxCzAJBgNV\n" + + "BAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + + "aXZjZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MEMwBQYDK2VxAzoAoIubPNAg\n" + + "F11u3MQ5d9wujg10+80I0xzYzTqzzXrfJNtw+eU8NbUk86xiCvlMzJRH0Oo3DbY8\n" + + "NAKAo0IwQDAdBgNVHQ4EFgQUUiI1+qT1x+HsDgfZRIU6hUaAbmUwHwYDVR0jBBgw\n" + + "FoAU9dWd+2+3UCnf8LiDEF+bxKgc6fQwBQYDK2VxA3MAx8P0mle08s5YDd/p58dt\n" + + "yORqvDPwo5IYPasqN8Zeen1B9u1xF/kvDGFxCJ6D9Gi4ynnDx0FZFMkA83evZcxJ\n" + + "+X+swt7FyHwXrdkZcvjRKEcsWhkj+0FlxYF/NZzLTGuGIPYJnRLEwf/zr+5NDxKs\n" + + "fCoA\n" + + "-----END CERTIFICATE-----", + "MEcCAQAwBQYDK2VxBDsEOfbhmUSuKP9WCO7Nr6JxVq5rfJESk1MNMyYhC134SiAP\n" + + "Suw0Cu7RZVadpfPR7Kiwb2b/JXjMdY1HAA=="), + + EE_RSASSA_PSS( + "RSASSA-PSS", + // Signature Algorithm: rsassaPss + // Hash Algorithm: sha256 + // Mask Algorithm: mgf1 with sha256 + // + // Validity + // Not Before: Jun 6 07:11:00 2018 GMT + // Not After : Jun 1 07:11:00 2038 GMT + // X509v3 Authority Key Identifier: + // 1F:16:2B:79:8A:55:89:99:98:02:5F:84:18:D0:7B:1A:23:D8:88:0C + "-----BEGIN CERTIFICATE-----\n" + + "MIIDZjCCAh2gAwIBAgIUHxwPs3eAgJ057nJwiLgWZWeNqdgwPgYJKoZIhvcNAQEK\n" + + "MDGgDTALBglghkgBZQMEAgGhGjAYBgkqhkiG9w0BAQgwCwYJYIZIAWUDBAIBogQC\n" + + "AgDeMBQxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0xODA2MDYwNzExMDBaFw0zODA2\n" + + "MDEwNzExMDBaMBQxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASAwCwYJKoZIhvcNAQEK\n" + + "A4IBDwAwggEKAoIBAQCl8r4Qrg27BYUO/1Va2Ix8QPGzN/lvzmKvP5Ff26ovNW4v\n" + + "RUx68HzAhhiWtcl+PwLSbJqJreEkTlle7PnRAypby3fO7ZAK0Y3YiHquaBg7d+7Y\n" + + "FhhHwv8gG0lZcyA0BkXFJHqdq76qar0xHC6DVezXm0K3mcceymG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IPDSLwlLpLM6Scw4vI822uvnXl/DWxOo\n" + + "sM1n7Jj59QLUhGPDhvYpI+/rjC4wcUQe4qR3hMbUKBVnD6u7RsU9iQKBgQCQ17VK\n" + + "7bSCRfuRaxaoGADww7gOTv5rQ6qr1xjpxb7D1hFGR9Rc+smCsPB/GZZXQjK44SWj\n" + + "WX3ED4Ubzaxmpe4cbNu+O5XMSmWQwB36RFBHUwdE5/nXdqDFzu/qNqJrqZLBmVKP\n" + + "ofaiiWffsaytVvotmT6+atElvAMbAua42V+nAQKBgHtIn3mYMHLriYGhQzpkFEA2\n" + + "8YcAMlKppueOMAKVy8nLu2r3MidmLAhMiKJQKG45I3Yg0/t/25tXLiOPJlwrOebh\n" + + "xQqUBI/JUOIpGAEnr48jhOXnCS+i+z294G5U/RgjXrlR4bCPvrtCmwzWwe0h79w2\n" + + "Q2hO5ZTW6UD9CVA85whf"); + + final String keyAlgo; + final String certStr; + final String privKeyStr; + + Cert(String keyAlgo, String certStr, String privKeyStr) { + this.keyAlgo = keyAlgo; + this.certStr = certStr; + this.privKeyStr = privKeyStr; } - - // Create an SSLContext object. - TrustManagerFactory tmf = - TrustManagerFactory.getInstance(params.tmAlgorithm); - tmf.init(ts); - - TrustManager[] tms = tmf.getTrustManagers(); - return tms[0]; } } diff --git a/test/jdk/javax/net/ssl/templates/SSLEngineTemplate.java b/test/jdk/javax/net/ssl/templates/SSLEngineTemplate.java index 621aaea354634..08d95fcd4c9dd 100644 --- a/test/jdk/javax/net/ssl/templates/SSLEngineTemplate.java +++ b/test/jdk/javax/net/ssl/templates/SSLEngineTemplate.java @@ -51,7 +51,7 @@ * (wrap/unwrap) pass before any application data is consumed or * produced. */ -public class SSLEngineTemplate implements SSLContextTemplate { +public class SSLEngineTemplate extends SSLContextTemplate { protected final SSLEngine clientEngine; // client Engine protected final ByteBuffer clientOut; // write side of clientEngine protected final ByteBuffer clientIn; // read side of clientEngine diff --git a/test/jdk/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java b/test/jdk/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java deleted file mode 100644 index 54b4e3c684072..0000000000000 --- a/test/jdk/javax/net/ssl/templates/SSLSocketSSLEngineTemplate.java +++ /dev/null @@ -1,532 +0,0 @@ -/* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. - * 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. - */ - -// -// SunJSSE does not support dynamic system properties, no way to re-use -// system properties in samevm/agentvm mode. -// - -/* - * @test - * @bug 7105780 - * @summary Add SSLSocket client/SSLEngine server to templates directory. - * @run main/othervm SSLSocketSSLEngineTemplate TLSv1 - * @run main/othervm SSLSocketSSLEngineTemplate TLSv1.1 - * @run main/othervm SSLSocketSSLEngineTemplate TLSv1.2 - * @run main/othervm SSLSocketSSLEngineTemplate TLSv1.3 - */ - -/** - * A SSLSocket/SSLEngine interop test case. This is not the way to - * code SSLEngine-based servers, but works for what we need to do here, - * which is to make sure that SSLEngine/SSLSockets can talk to each other. - * SSLEngines can use direct or indirect buffers, and different code - * is used to get at the buffer contents internally, so we test that here. - * - * The test creates one SSLSocket (client) and one SSLEngine (server). - * The SSLSocket talks to a raw ServerSocket, and the server code - * does the translation between byte [] and ByteBuffers that the SSLEngine - * can use. The "transport" layer consists of a Socket Input/OutputStream - * and two byte buffers for the SSLEngines: think of them - * as directly connected pipes. - * - * Again, this is a *very* simple example: real code will be much more - * involved. For example, different threading and I/O models could be - * used, transport mechanisms could close unexpectedly, and so on. - * - * When this application runs, notice that several messages - * (wrap/unwrap) pass before any application data is consumed or - * produced. (For more information, please see the SSL/TLS - * specifications.) There may several steps for a successful handshake, - * so it's typical to see the following series of operations: - * - * client server message - * ====== ====== ======= - * write() ... ClientHello - * ... unwrap() ClientHello - * ... wrap() ServerHello/Certificate - * read() ... ServerHello/Certificate - * write() ... ClientKeyExchange - * write() ... ChangeCipherSpec - * write() ... Finished - * ... unwrap() ClientKeyExchange - * ... unwrap() ChangeCipherSpec - * ... unwrap() Finished - * ... wrap() ChangeCipherSpec - * ... wrap() Finished - * read() ... ChangeCipherSpec - * read() ... Finished - */ -import javax.net.ssl.*; -import javax.net.ssl.SSLEngineResult.*; -import java.io.*; -import java.net.*; -import java.security.*; -import java.nio.*; - -public class SSLSocketSSLEngineTemplate { - - /* - * Enables logging of the SSL/TLS operations. - */ - private static final boolean logging = true; - - /* - * Enables the JSSE system debugging system property: - * - * -Djavax.net.debug=all - * - * This gives a lot of low-level information about operations underway, - * including specific handshake messages, and might be best examined - * after gaining some familiarity with this application. - */ - private static final boolean debug = false; - private final SSLContext sslc; - private SSLEngine serverEngine; // server-side SSLEngine - private SSLSocket clientSocket; - - private final byte[] serverMsg = - "Hi there Client, I'm a Server.".getBytes(); - private final byte[] clientMsg = - "Hello Server, I'm a Client! Pleased to meet you!".getBytes(); - - private ByteBuffer serverOut; // write side of serverEngine - private ByteBuffer serverIn; // read side of serverEngine - - private volatile Exception clientException; - private volatile Exception serverException; - - /* - * For data transport, this example uses local ByteBuffers. - */ - private ByteBuffer cTOs; // "reliable" transport client->server - private ByteBuffer sTOc; // "reliable" transport server->client - - /* - * The following is to set up the keystores/trust material. - */ - private static final String pathToStores = "../etc"; - private static final String keyStoreFile = "keystore"; - private static final String trustStoreFile = "truststore"; - private static final String keyFilename = - System.getProperty("test.src", ".") + "/" + pathToStores - + "/" + keyStoreFile; - private static final String trustFilename = - System.getProperty("test.src", ".") + "/" + pathToStores - + "/" + trustStoreFile; - - /* - * Main entry point for this test. - */ - public static void main(String args[]) throws Exception { - String protocol = args[0]; - - // reset security properties to make sure that the algorithms - // and keys used in this test are not disabled. - Security.setProperty("jdk.tls.disabledAlgorithms", ""); - Security.setProperty("jdk.certpath.disabledAlgorithms", ""); - - if (debug) { - System.setProperty("javax.net.debug", "all"); - } - - /* - * Run the tests with direct and indirect buffers. - */ - SSLSocketSSLEngineTemplate test = - new SSLSocketSSLEngineTemplate(protocol); - log("-------------------------------------"); - log("Testing " + protocol + " for direct buffers ..."); - test.runTest(true); - - log("---------------------------------------"); - log("Testing " + protocol + " for indirect buffers ..."); - test.runTest(false); - - log("Test Passed."); - } - - /* - * Create an initialized SSLContext to use for these tests. - */ - public SSLSocketSSLEngineTemplate(String protocol) throws Exception { - - KeyStore ks = KeyStore.getInstance("JKS"); - KeyStore ts = KeyStore.getInstance("JKS"); - - char[] passphrase = "passphrase".toCharArray(); - - try (FileInputStream keyFile = new FileInputStream(keyFilename); - FileInputStream trustFile = new FileInputStream(trustFilename)) { - ks.load(keyFile, passphrase); - ts.load(trustFile, passphrase); - } - - KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(ks, passphrase); - - TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); - tmf.init(ts); - - SSLContext sslCtx = SSLContext.getInstance(protocol); - - sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - - sslc = sslCtx; - } - - /* - * Run the test. - * - * Sit in a tight loop, with the server engine calling wrap/unwrap - * regardless of whether data is available or not. We do this until - * we get the application data. Then we shutdown and go to the next one. - * - * The main loop handles all of the I/O phases of the SSLEngine's - * lifetime: - * - * initial handshaking - * application data transfer - * engine closing - * - * One could easily separate these phases into separate - * sections of code. - */ - private void runTest(boolean direct) throws Exception { - clientSocket = null; - boolean serverClose = direct; - - // generates the server-side Socket - try (ServerSocket serverSocket = new ServerSocket()) { - serverSocket.setReuseAddress(false); - serverSocket.bind(null); - int port = serverSocket.getLocalPort(); - log("Port: " + port); - Thread thread = createClientThread(port, serverClose); - - createSSLEngine(); - createBuffers(direct); - - // server-side socket that will read - try (Socket socket = serverSocket.accept()) { - socket.setSoTimeout(500); - - boolean closed = false; - // will try to read one more time in case client message - // is fragmented to multiple pieces - boolean retry = true; - - InputStream is = socket.getInputStream(); - OutputStream os = socket.getOutputStream(); - - SSLEngineResult serverResult; // results from last operation - - /* - * Examining the SSLEngineResults could be much more involved, - * and may alter the overall flow of the application. - * - * For example, if we received a BUFFER_OVERFLOW when trying - * to write to the output pipe, we could reallocate a larger - * pipe, but instead we wait for the peer to drain it. - */ - byte[] inbound = new byte[8192]; - byte[] outbound = new byte[8192]; - - while (!isEngineClosed(serverEngine)) { - int len; - - // Inbound data - log("================"); - - // Read from the Client side. - try { - len = is.read(inbound); - if (len == -1) { - logSocketStatus(clientSocket); - if (clientSocket.isClosed() - || clientSocket.isOutputShutdown()) { - log("Client socket was closed or shutdown output"); - break; - } else { - throw new Exception("Unexpected EOF"); - } - } - cTOs.put(inbound, 0, len); - } catch (SocketTimeoutException ste) { - // swallow. Nothing yet, probably waiting on us. - } - - cTOs.flip(); - - serverResult = serverEngine.unwrap(cTOs, serverIn); - log("server unwrap: ", serverResult); - runDelegatedTasks(serverResult, serverEngine); - cTOs.compact(); - - // Outbound data - log("----"); - - serverResult = serverEngine.wrap(serverOut, sTOc); - log("server wrap: ", serverResult); - runDelegatedTasks(serverResult, serverEngine); - - sTOc.flip(); - - if ((len = sTOc.remaining()) != 0) { - sTOc.get(outbound, 0, len); - os.write(outbound, 0, len); - // Give the other side a chance to process - } - - sTOc.compact(); - - if (!closed && (serverOut.remaining() == 0)) { - closed = true; - - /* - * We'll alternate initiatating the shutdown. - * When the server initiates, it will take one more - * loop, but tests the orderly shutdown. - */ - if (serverClose) { - serverEngine.closeOutbound(); - } - serverIn.flip(); - - /* - * A sanity check to ensure we got what was sent. - */ - if (serverIn.remaining() != clientMsg.length) { - if (retry && - serverIn.remaining() < clientMsg.length) { - log("Need to read more from client"); - serverIn.compact(); - retry = false; - continue; - } else { - throw new Exception( - "Client: Data length error"); - } - } - - for (int i = 0; i < clientMsg.length; i++) { - if (clientMsg[i] != serverIn.get()) { - throw new Exception( - "Client: Data content error"); - } - } - serverIn.compact(); - } - } - } catch (Exception e) { - serverException = e; - } finally { - // Wait for the client to join up with us. - if (thread != null) { - thread.join(); - } - } - } finally { - if (serverException != null) { - if (clientException != null) { - serverException.initCause(clientException); - } - throw serverException; - } - if (clientException != null) { - if (serverException != null) { - clientException.initCause(serverException); - } - throw clientException; - } - } - } - - /* - * Create a client thread which does simple SSLSocket operations. - * We'll write and read one data packet. - */ - private Thread createClientThread(final int port, - final boolean serverClose) throws Exception { - - Thread t = new Thread("ClientThread") { - - @Override - public void run() { - // client-side socket - try (SSLSocket sslSocket = (SSLSocket)sslc.getSocketFactory(). - createSocket("localhost", port)) { - clientSocket = sslSocket; - - OutputStream os = sslSocket.getOutputStream(); - InputStream is = sslSocket.getInputStream(); - - // write(byte[]) goes in one shot. - os.write(clientMsg); - - byte[] inbound = new byte[2048]; - int pos = 0; - - int len; - while ((len = is.read(inbound, pos, 2048 - pos)) != -1) { - pos += len; - // Let the client do the closing. - if ((pos == serverMsg.length) && !serverClose) { - sslSocket.close(); - break; - } - } - - if (pos != serverMsg.length) { - throw new Exception("Client: Data length error"); - } - - for (int i = 0; i < serverMsg.length; i++) { - if (inbound[i] != serverMsg[i]) { - throw new Exception("Client: Data content error"); - } - } - } catch (Exception e) { - clientException = e; - } - } - }; - t.start(); - return t; - } - - /* - * Using the SSLContext created during object creation, - * create/configure the SSLEngines we'll use for this test. - */ - private void createSSLEngine() throws Exception { - /* - * Configure the serverEngine to act as a server in the SSL/TLS - * handshake. - */ - serverEngine = sslc.createSSLEngine(); - serverEngine.setUseClientMode(false); - serverEngine.getNeedClientAuth(); - } - - /* - * Create and size the buffers appropriately. - */ - private void createBuffers(boolean direct) { - - SSLSession session = serverEngine.getSession(); - int appBufferMax = session.getApplicationBufferSize(); - int netBufferMax = session.getPacketBufferSize(); - - /* - * We'll make the input buffers a bit bigger than the max needed - * size, so that unwrap()s following a successful data transfer - * won't generate BUFFER_OVERFLOWS. - * - * We'll use a mix of direct and indirect ByteBuffers for - * tutorial purposes only. In reality, only use direct - * ByteBuffers when they give a clear performance enhancement. - */ - if (direct) { - serverIn = ByteBuffer.allocateDirect(appBufferMax + 50); - cTOs = ByteBuffer.allocateDirect(netBufferMax); - sTOc = ByteBuffer.allocateDirect(netBufferMax); - } else { - serverIn = ByteBuffer.allocate(appBufferMax + 50); - cTOs = ByteBuffer.allocate(netBufferMax); - sTOc = ByteBuffer.allocate(netBufferMax); - } - - serverOut = ByteBuffer.wrap(serverMsg); - } - - /* - * If the result indicates that we have outstanding tasks to do, - * go ahead and run them in this thread. - */ - private static void runDelegatedTasks(SSLEngineResult result, - SSLEngine engine) throws Exception { - - if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) { - Runnable runnable; - while ((runnable = engine.getDelegatedTask()) != null) { - log("\trunning delegated task..."); - runnable.run(); - } - HandshakeStatus hsStatus = engine.getHandshakeStatus(); - if (hsStatus == HandshakeStatus.NEED_TASK) { - throw new Exception( - "handshake shouldn't need additional tasks"); - } - log("\tnew HandshakeStatus: " + hsStatus); - } - } - - private static boolean isEngineClosed(SSLEngine engine) { - return (engine.isOutboundDone() && engine.isInboundDone()); - } - - private static void logSocketStatus(Socket socket) { - log("##### " + socket + " #####"); - log("isBound: " + socket.isBound()); - log("isConnected: " + socket.isConnected()); - log("isClosed: " + socket.isClosed()); - log("isInputShutdown: " + socket.isInputShutdown()); - log("isOutputShutdown: " + socket.isOutputShutdown()); - } - - /* - * Logging code - */ - private static boolean resultOnce = true; - - private static void log(String str, SSLEngineResult result) { - if (!logging) { - return; - } - if (resultOnce) { - resultOnce = false; - log("The format of the SSLEngineResult is: \n" - + "\t\"getStatus() / getHandshakeStatus()\" +\n" - + "\t\"bytesConsumed() / bytesProduced()\"\n"); - } - HandshakeStatus hsStatus = result.getHandshakeStatus(); - log(str - + result.getStatus() + "/" + hsStatus + ", " - + result.bytesConsumed() + "/" + result.bytesProduced() - + " bytes"); - if (hsStatus == HandshakeStatus.FINISHED) { - log("\t...ready for application data"); - } - } - - private static void log(String str) { - if (logging) { - if (debug) { - System.err.println(str); - } else { - System.out.println(str); - } - } - } -} diff --git a/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java b/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java index ce2e3ee121be4..fa6cccbcdcf6d 100644 --- a/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java +++ b/test/jdk/javax/net/ssl/templates/SSLSocketTemplate.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 @@ -34,27 +34,17 @@ * @run main/othervm SSLSocketTemplate */ -import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; -import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManagerFactory; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.SocketTimeoutException; -import java.security.KeyStore; -import java.security.PrivateKey; -import java.security.KeyFactory; -import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; -import java.security.spec.PKCS8EncodedKeySpec; -import java.util.Base64; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -66,7 +56,7 @@ * test/jdk/sun/security/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java * test/jdk/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java */ -public class SSLSocketTemplate { +public class SSLSocketTemplate extends SSLContextTemplate { /* * ================== @@ -128,53 +118,6 @@ protected void runClientApplication(int serverPort) throws Exception { // blank } - /* - * Create an instance of SSLContext for client use. - */ - protected SSLContext createClientSSLContext() throws Exception { - return createSSLContext(TRUSTED_CERTS, END_ENTITY_CERTS, - getClientContextParameters()); - } - - /* - * Create an instance of SSLContext for server use. - */ - protected SSLContext createServerSSLContext() throws Exception { - return createSSLContext(TRUSTED_CERTS, END_ENTITY_CERTS, - getServerContextParameters()); - } - - /* - * The parameters used to configure SSLContext. - */ - protected static final class ContextParameters { - final String contextProtocol; - final String tmAlgorithm; - final String kmAlgorithm; - - ContextParameters(String contextProtocol, - String tmAlgorithm, String kmAlgorithm) { - - this.contextProtocol = contextProtocol; - this.tmAlgorithm = tmAlgorithm; - this.kmAlgorithm = kmAlgorithm; - } - } - - /* - * Get the client side parameters of SSLContext. - */ - protected ContextParameters getClientContextParameters() { - return new ContextParameters("TLS", "PKIX", "NewSunX509"); - } - - /* - * Get the server side parameters of SSLContext. - */ - protected ContextParameters getServerContextParameters() { - return new ContextParameters("TLS", "PKIX", "NewSunX509"); - } - /* * Does the client side use customized connection other than * explicit Socket.connect(), for example, URL.openConnection()? @@ -360,114 +303,6 @@ protected void doClientSide() throws Exception { } } - /* - * ============================================= - * Stuffs to customize the SSLContext instances. - */ - - /* - * ======================================= - * Certificates and keys used in the test. - */ - // Trusted certificates. - protected final static Cert[] TRUSTED_CERTS = { - Cert.CA_ECDSA_SECP256R1, - Cert.CA_RSA_2048, - Cert.CA_DSA_2048 }; - - // End entity certificate. - protected final static Cert[] END_ENTITY_CERTS = { - Cert.EE_ECDSA_SECP256R1, - Cert.EE_RSA_2048, - Cert.EE_EC_RSA_SECP256R1, - Cert.EE_DSA_2048 }; - - /* - * Create an instance of SSLContext with the specified trust/key materials. - */ - public static SSLContext createSSLContext( - Cert[] trustedCerts, - Cert[] endEntityCerts, - ContextParameters params) throws Exception { - - KeyStore ts = null; // trust store - KeyStore ks = null; // key store - char passphrase[] = "passphrase".toCharArray(); - - // Generate certificate from cert string. - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - // Import the trused certs. - ByteArrayInputStream is; - if (trustedCerts != null && trustedCerts.length != 0) { - ts = KeyStore.getInstance("JKS"); - ts.load(null, null); - - Certificate[] trustedCert = new Certificate[trustedCerts.length]; - for (int i = 0; i < trustedCerts.length; i++) { - is = new ByteArrayInputStream(trustedCerts[i].certStr.getBytes()); - try { - trustedCert[i] = cf.generateCertificate(is); - } finally { - is.close(); - } - - ts.setCertificateEntry( - "trusted-cert-" + trustedCerts[i].name(), trustedCert[i]); - } - } - - // Import the key materials. - if (endEntityCerts != null && endEntityCerts.length != 0) { - ks = KeyStore.getInstance("JKS"); - ks.load(null, null); - - for (int i = 0; i < endEntityCerts.length; i++) { - // generate the private key. - PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( - Base64.getMimeDecoder().decode(endEntityCerts[i].privKeyStr)); - KeyFactory kf = - KeyFactory.getInstance( - endEntityCerts[i].keyAlgo); - PrivateKey priKey = kf.generatePrivate(priKeySpec); - - // generate certificate chain - is = new ByteArrayInputStream( - endEntityCerts[i].certStr.getBytes()); - Certificate keyCert = null; - try { - keyCert = cf.generateCertificate(is); - } finally { - is.close(); - } - - Certificate[] chain = new Certificate[] { keyCert }; - - // import the key entry. - ks.setKeyEntry("cert-" + endEntityCerts[i].name(), - priKey, passphrase, chain); - } - } - - // Create an SSLContext object. - TrustManagerFactory tmf = - TrustManagerFactory.getInstance(params.tmAlgorithm); - tmf.init(ts); - - SSLContext context = SSLContext.getInstance(params.contextProtocol); - if (endEntityCerts != null && endEntityCerts.length != 0 && ks != null) { - KeyManagerFactory kmf = - KeyManagerFactory.getInstance(params.kmAlgorithm); - kmf.init(ks, passphrase); - - context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - } else { - context.init(null, tmf.getTrustManagers(), null); - } - - return context; - } - /* * ================================================= * Stuffs to boot up the client-server mode testing. @@ -597,7 +432,7 @@ public void run() { } } - private void startClient(boolean newThread) throws Exception { + private void startClient(boolean newThread) { if (newThread) { clientThread = new Thread() { @Override @@ -629,573 +464,4 @@ private synchronized void logException(String prefix, Throwable cause) { cause.printStackTrace(System.out); } - public static enum Cert { - - CA_ECDSA_SECP256R1( - "EC", - // SHA256withECDSA, curve secp256r1 - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Subject Key Identifier: - // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 - "-----BEGIN CERTIFICATE-----\n" + - "MIIBvjCCAWOgAwIBAgIJAIvFG6GbTroCMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMDsxCzAJBgNVBAYTAlVT\n" + - "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTBZ\n" + - "MBMGByqGSM49AgEGCCqGSM49AwEHA0IABBz1WeVb6gM2mh85z3QlvaB/l11b5h0v\n" + - "LIzmkC3DKlVukZT+ltH2Eq1oEkpXuf7QmbM0ibrUgtjsWH3mULfmcWmjUDBOMB0G\n" + - "A1UdDgQWBBRgz71z//oaMNKk7NNJcUbvGjWghjAfBgNVHSMEGDAWgBRgz71z//oa\n" + - "MNKk7NNJcUbvGjWghjAMBgNVHRMEBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQCG\n" + - "6wluh1r2/T6L31mZXRKf9JxeSf9pIzoLj+8xQeUChQIhAJ09wAi1kV8yePLh2FD9\n" + - "2YEHlSQUAbwwqCDEVB5KxaqP\n" + - "-----END CERTIFICATE-----", - "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg/HcHdoLJCdq3haVd\n" + - "XZTSKP00YzM3xX97l98vGL/RI1KhRANCAAQc9VnlW+oDNpofOc90Jb2gf5ddW+Yd\n" + - "LyyM5pAtwypVbpGU/pbR9hKtaBJKV7n+0JmzNIm61ILY7Fh95lC35nFp"), - - CA_ECDSA_SECP384R1( - "EC", - // SHA384withECDSA, curve secp384r1 - // Validity - // Not Before: Jun 24 08:15:06 2019 GMT - // Not After : Jun 19 08:15:06 2039 GMT - // Subject Key Identifier: - // 0a:93:a9:a0:bf:e7:d5:48:9d:4f:89:15:c6:51:98:80:05:51:4e:4e - "-----BEGIN CERTIFICATE-----\n" + - "MIICCDCCAY6gAwIBAgIUCpOpoL/n1UidT4kVxlGYgAVRTk4wCgYIKoZIzj0EAwMw\n" + - "OzELMAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0Ug\n" + - "VGVzdCBTZXJpdmNlMB4XDTE5MDYyNDA4MTUwNloXDTM5MDYxOTA4MTUwNlowOzEL\n" + - "MAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVz\n" + - "dCBTZXJpdmNlMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAENVQN1wXWFdgC6u/dDdiC\n" + - "y+WtMTF66oL/0BSm+1ZqsogamzCryawOcHgiuXgWzx5CQ3LuOC+tDFyXpGfHuCvb\n" + - "dkzxPrP5n9NrR8/uRPe5l1KOUbchviU8z9cTP+LZxnZDo1MwUTAdBgNVHQ4EFgQU\n" + - "SktSFArR1p/5mXV0kyo0RxIVa/UwHwYDVR0jBBgwFoAUSktSFArR1p/5mXV0kyo0\n" + - "RxIVa/UwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjBZvoNmq3/v\n" + - "RD2gBTyvxjS9h0rsMRLHDnvul/KWngytwGPTOBo0Y8ixQXSjdKoc3rkCMQDkiNgx\n" + - "IDxuHedmrLQKIPnVcthTmwv7//jHiqGoKofwChMo2a1P+DQdhszmeHD/ARQ=\n" + - "-----END CERTIFICATE-----", - "MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDChlbt0NF8oIKODSxn2\n" + - "WXCXuJm3z78LRkzYQS3Nx5NMjei5ytkFZz4qvD4XXMWlTEyhZANiAAQ1VA3XBdYV\n" + - "2ALq790N2ILL5a0xMXrqgv/QFKb7VmqyiBqbMKvJrA5weCK5eBbPHkJDcu44L60M\n" + - "XJekZ8e4K9t2TPE+s/mf02tHz+5E97mXUo5RtyG+JTzP1xM/4tnGdkM="), - - CA_ECDSA_SECP521R1( - "EC", - // SHA512withECDSA, curve secp521r1 - // Validity - // Not Before: Jun 24 08:15:06 2019 GMT - // Not After : Jun 19 08:15:06 2039 GMT - // Subject Key Identifier: - // 25:ca:68:76:6d:29:17:9b:71:78:45:2d:d4:c6:e4:5d:fe:25:ff:90 - "-----BEGIN CERTIFICATE-----\n" + - "MIICUzCCAbSgAwIBAgIUJcpodm0pF5txeEUt1MbkXf4l/5AwCgYIKoZIzj0EAwQw\n" + - "OzELMAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0Ug\n" + - "VGVzdCBTZXJpdmNlMB4XDTE5MDYyNDA4MTUwNloXDTM5MDYxOTA4MTUwNlowOzEL\n" + - "MAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVz\n" + - "dCBTZXJpdmNlMIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQAmFD5VmB2MdyJ6k+E\n" + - "eP4JncrE65ySL07gVmFwnr8otOt3NtRAyzmviMNNXXjo5R5NqNjKP4pr92JjT0sO\n" + - "D65yngkBtH151Ev/fiKPLxkXL9GzfKdWHVhDX7Zg6DUydzukzZV2/dIyloAIqwlz\n" + - "QVKJqT7RypDufdng8hnE9YfKo6ypZiujUzBRMB0GA1UdDgQWBBRAIrxa7WqtqUCe\n" + - "HFuKREDC92spvTAfBgNVHSMEGDAWgBRAIrxa7WqtqUCeHFuKREDC92spvTAPBgNV\n" + - "HRMBAf8EBTADAQH/MAoGCCqGSM49BAMEA4GMADCBiAJCAe22iirZnODCmlpxcv57\n" + - "3g5BEE60C+dtYmTqR4DtFyDaTRQ5CFf4ZxvQPIbD+SXi5Cbrl6qtrZG0cjUihPkC\n" + - "Hi1hAkIAiEcO7nMPgQLny+GrciojfN+bZXME/dPz6KHBm/89f8Me+jawVnv6y+df\n" + - "2Sbafh1KV6ntWQtB4bK3MXV8Ym9Eg1I=\n" + - "-----END CERTIFICATE-----", - "MIHuAgEAMBAGByqGSM49AgEGBSuBBAAjBIHWMIHTAgEBBEIAV8dZszV6+nLw3LeA\n" + - "Q+qLJLGaqyjlsQkaopCPcmoRdy1HX6AzB/YnKsPkHp/9DQN6A2JgUhFG5B0XvKSk\n" + - "BqNNuSGhgYkDgYYABACYUPlWYHYx3InqT4R4/gmdysTrnJIvTuBWYXCevyi063c2\n" + - "1EDLOa+Iw01deOjlHk2o2Mo/imv3YmNPSw4PrnKeCQG0fXnUS/9+Io8vGRcv0bN8\n" + - "p1YdWENftmDoNTJ3O6TNlXb90jKWgAirCXNBUompPtHKkO592eDyGcT1h8qjrKlm\n" + - "Kw=="), - - CA_RSA_2048( - "RSA", - // SHA256withRSA, 2048 bits - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Subject Key Identifier: - // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C - "-----BEGIN CERTIFICATE-----\n" + - "MIIDSTCCAjGgAwIBAgIJAI4ZF3iy8zG+MA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + - "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3Qg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oTpiE2gulfT7Lm+fVM7Ruc=\n" + - "-----END CERTIFICATE-----", - "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC6THGO2lonlwxD\n" + - "Nf2CXyVtu2+J0SBWchGIRJaMhrCk7kIokI3PHKkWRTV3tr8M4gweCMkxJdB45eUB\n" + - "emWkBIbj888L0Jtab+uCq0V65o9xYrECvAeTli7cvcaesQ6rGjEaMjmyyvqCG9tE\n" + - "+X0pRHr5qNb2I54fAl9GM8eRq+cnumEhB0L2DlhMLPGndezpck6EdijHgvMOKqOq\n" + - "7OfaVoOzMZ/b6NtiJg867QG0212womrN8ZRNAadIeZbsn/uVOFIJLKC/Qfa9qD+B\n" + - "qyzRFaCZOe7fJcGkdLqYr9wp0vC3CRC6XoGbm+YIKi2PGT2BUD45SuiMyzpuq1z4\n" + - "GYmd5kS9AgMBAAECggEAFHSoU2MuWwJ+2jJnb5U66t2V1bAcuOE1g5zkWvG/G5z9\n" + - "rq6Qo5kmB8f5ovdx6tw3MGUOklLwnRXBG3RxDJ1iokz3AvkY1clMNsDPlDsUrQKF\n" + - "JSO4QUBQTPSZhnsyfR8XHSU+qJ8Y+ohMfzpVv95BEoCzebtXdVgxVegBlcEmVHo2\n" + - "kMmkRN+bYNsr8eb2r+b0EpyumS39ZgKYh09+cFb78y3T6IFMGcVJTP6nlGBFkmA/\n" + - "25pYeCF2tSki08qtMJZQAvKfw0Kviibk7ZxRbJqmc7B1yfnOEHP6ftjuvKl2+RP/\n" + - "+5P5f8CfIP6gtA0LwSzAqQX/hfIKrGV5j0pCqrD0kQKBgQDeNR6Xi4sXVq79lihO\n" + - "a1bSeV7r8yoQrS8x951uO+ox+UIZ1MsAULadl7zB/P0er92p198I9M/0Jth3KBuS\n" + - "zj45mucvpiiGvmQlMKMEfNq4nN7WHOu55kufPswQB2mR4J3xmwI+4fM/nl1zc82h\n" + - "De8JSazRldJXNhfx0RGFPmgzbwKBgQDWoVXrXLbCAn41oVnWB8vwY9wjt92ztDqJ\n" + - "HMFA/SUohjePep9UDq6ooHyAf/Lz6oE5NgeVpPfTDkgvrCFVKnaWdwALbYoKXT2W\n" + - "9FlyJox6eQzrtHAacj3HJooXWuXlphKSizntfxj3LtMR9BmrmRJOfK+SxNOVJzW2\n" + - "+MowT20EkwKBgHmpB8jdZBgxI7o//m2BI5Y1UZ1KE5vx1kc7VXzHXSBjYqeV9FeF\n" + - "2ZZLP9POWh/1Fh4pzTmwIDODGT2UPhSQy0zq3O0fwkyT7WzXRknsuiwd53u/dejg\n" + - "iEL2NPAJvulZ2+AuiHo5Z99LK8tMeidV46xoJDDUIMgTG+UQHNGhK5gNAoGAZn/S\n" + - "Cn7SgMC0CWSvBHnguULXZO9wH1wZAFYNLL44OqwuaIUFBh2k578M9kkke7woTmwx\n" + - "HxQTjmWpr6qimIuY6q6WBN8hJ2Xz/d1fwhYKzIp20zHuv5KDUlJjbFfqpsuy3u1C\n" + - "kts5zwI7pr1ObRbDGVyOdKcu7HI3QtR5qqyjwaUCgYABo7Wq6oHva/9V34+G3Goh\n" + - "63bYGUnRw2l5BD11yhQv8XzGGZFqZVincD8gltNThB0Dc/BI+qu3ky4YdgdZJZ7K\n" + - "z51GQGtaHEbrHS5caV79yQ8QGY5mUVH3E+VXSxuIqb6pZq2DH4sTAEFHyncddmOH\n" + - "zoXBInYwRG9KE/Bw5elhUw=="), - - CA_DSA_2048( - "DSA", - // SHA256withDSA, 2048 bits - // Validity - // Not Before: May 22 07:18:18 2018 GMT - // Not After : May 17 07:18:18 2038 GMT - // Subject Key Identifier: - // 76:66:9E:F7:3B:DD:45:E5:3B:D9:72:3C:3F:F0:54:39:86:31:26:53 - "-----BEGIN CERTIFICATE-----\n" + - "MIIErjCCBFSgAwIBAgIJAOktYLNCbr02MAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" + - "EwJVUzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2\n" + - "Y2UwHhc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iv5UBfhdPL3f3l9T7JMAKPH6C9Vve\n" + - "OQXE5eGqbjsySbcmseHoYUt1WCSnSda1opX8zchX04e7DhGfE2/L9flpYEoSt8lI\n" + - "vMNjgOwvKdW3yvPt1/eBBHYNFG5gWPv/Q5KoyCtHS03uqGm4rNc/wZTIEEfd66C+\n" + - "QRaUltjOaHmtwOdDHaNqwhYZSVOip+Mo+TfyzHFREcdHLapo7ZXqbdYkRGxRR3d+\n" + - "3DfHaraJO0OKoYlPkr3JMvM/MSGR9AnZOcejUDBOMB0GA1UdDgQWBBR2Zp73O91F\n" + - "5TvZcjw/8FQ5hjEmUzAfBgNVHSMEGDAWgBR2Zp73O91F5TvZcjw/8FQ5hjEmUzAM\n" + - "BgNVHRMEBTADAQH/MAsGCWCGSAFlAwQDAgNHADBEAiBzriYE41M2y9Hy5ppkL0Qn\n" + - "dIlNc8JhXT/PHW7GDtViagIgMko8Qoj9gDGPK3+O9E8DC3wGiiF9CObM4LN387ok\n" + - "J+g=\n" + - "-----END CERTIFICATE-----", - "MIICZQIBADCCAjkGByqGSM44BAEwggIsAoIBAQDuRsj4UptM3ty0rvoInHVCy49O" + - "Yjn0y1L2UNvbGM+Nc5qqywUG3Soh6oCbtkXvbIE2+bLizYxdOO0ziz51N44T7Vpt" + - "l/F84lRiHB8pv0PzHmcUrbf/PLHqq6CN1jisyDC9hnK4rIU/pXBq7R9+k39frntk" + - "p59z0lsscoDaj45ZT+blI2JhS7wH+ECzJXZHfw9lcXMLB4wfMuYlGbF3s3PyxIUW" + - "Uv9Npor6pUcNwDJKvzlXv2bcRVrD9J7H8RBnWbmlBaaaRn4scRb8pqwd/iedXE7f" + - "qWQQ6g9stA2H3PvPIgrOI8B033AyKS2+d/BwYwY9qxILUBEkJgdKKA//sLD7AiEA" + - "tW2HIYBJTbQ2C9xYKS4DUlGKe4CFr/XoWguyzts+24kCggEAYrbxTpw5FI2vDQBe" + - "5Q6TlW+YqUPEonAS1t5EGpsYcrssYGcsvz6I2f6D6K5Klv0/wNK4ZxujLLBKQLXY" + - "sFQfnKwWBqN23MJhMSYXTienWLihaaT1oQsCjB7PZ6SvpagTJfJeY+fMZXBXgu2X" + - "xn/BmBpIRVtHOOLxEITDG2nOmU0z+JsPtbe8SX5gzJSxMiKU12gAJPLqFS1s0Fp0" + - "eNLB4sm70tLtycUJG+/8vLTjmbvKpc/2Dku5UOlMVBl9uwntRNPmoHz6YXraEQJU" + - "tXHs6lmu6+uBmtJ5I9ZMJHEao4E4icdDcJ1F6+/FQFxYVRfefjt5X6ob3bRBrZIQ" + - "xj4OzQQjAiEAsceWOM8do4etxp2zgnoNXV8PUUyqWhz1+0srcKV7FR4="), - - CA_DSA_1024( - "DSA", - // dsaWithSHA1, 1024 bits - // Validity - // Not Before: Apr 24 12:25:43 2020 GMT - // Not After : Apr 22 12:25:43 2030 GMT - // Authority Key Identifier: - // E1:3C:01:52:EB:D1:38:F7:CF:F1:E3:5E:DB:54:75:7F:5E:AB:2D:36 - "-----BEGIN CERTIFICATE-----\n" + - "MIIC9TCCArWgAwIBAgIUd52yKk0OxQuxdaYRAfq5VLuF1ZAwCQYHKoZIzjgEAzAu\n" + - "MQswCQYDVQQGEwJVUzENMAsGA1UECgwESmF2YTEQMA4GA1UECwwHU3VuSlNTRTAe\n" + - "Fw0yMDA0MjQxMjI1NDJaFw0zMDA0MjIxMjI1NDJaMC4xCzAJBgNVBAYTAlVTMQ0w\n" + - "CwYDVQQKDARKYXZhMRAwDgYDVQQLDAdTdW5KU1NFMIIBtjCCASsGByqGSM44BAEw\n" + - "ggEeAoGBAKgyb2XpANq43T8yBf5v0PTBOddLPxd0f0FotASron5rQr86JjBTfgIW\n" + - "oE4u7nYlO6bp/M4Dw6qZr+HaDu9taIDOj6LL51eUShVsOgS7XZcUzLT8vPnkEDDo\n" + - "u326x0B7fuNCbMLm+ipM2d4FhLUTt4Qb5TcY6l7dOGHeWiL7nl43AhUAoGr8DY2m\n" + - "WHZPHk2XbZ5wpaM2lLcCgYBKiFbFFViH/ylHJRPtYtjtJw4ls1scbVP4TRHnKoZc\n" + - "HPAird1fDYgGC2b0GQNAMABhI+L+ogxS7qakySpJCheuN25AjiSyilygQdlXoWRt\n" + - "Mggsh8EQZT7iP4V4e9m3xRHzb5ECvsSTdZB1BQMcC90W2Avq+orqgBnr2in9UEd8\n" + - "qwOBhAACgYAgVWxjYWlWIv7s4BnNMQoPKppi205f3aC6wv6Rqk4BnYYYrFONEmzQ\n" + - "hzj6lSXfxLpTu4lg2zNeIraZggoS0ztkbZNNADEmAHx+OLshiJJxu2/KfoopJOZg\n" + - "8ARmuaKOkWbkW9y4hWhfBlVwZbckG3Eibff0xronIXXy7B7UKaccyqNTMFEwHQYD\n" + - "VR0OBBYEFOE8AVLr0Tj3z/HjXttUdX9eqy02MB8GA1UdIwQYMBaAFOE8AVLr0Tj3\n" + - "z/HjXttUdX9eqy02MA8GA1UdEwEB/wQFMAMBAf8wCQYHKoZIzjgEAwMvADAsAhRC\n" + - "YLduLniBEJ51SfBWIkvNW6OG7QIUSKaTY6rgEFDEMoTqOjFChR22nkk=\n" + - "-----END CERTIFICATE-----", - "MIIBSgIBADCCASsGByqGSM44BAEwggEeAoGBAKgyb2XpANq43T8yBf5v0PTBOddL\n" + - "Pxd0f0FotASron5rQr86JjBTfgIWoE4u7nYlO6bp/M4Dw6qZr+HaDu9taIDOj6LL\n" + - "51eUShVsOgS7XZcUzLT8vPnkEDDou326x0B7fuNCbMLm+ipM2d4FhLUTt4Qb5TcY\n" + - "6l7dOGHeWiL7nl43AhUAoGr8DY2mWHZPHk2XbZ5wpaM2lLcCgYBKiFbFFViH/ylH\n" + - "JRPtYtjtJw4ls1scbVP4TRHnKoZcHPAird1fDYgGC2b0GQNAMABhI+L+ogxS7qak\n" + - "ySpJCheuN25AjiSyilygQdlXoWRtMggsh8EQZT7iP4V4e9m3xRHzb5ECvsSTdZB1\n" + - "BQMcC90W2Avq+orqgBnr2in9UEd8qwQWAhQ7rSn+WvIxeuZ/CK4p04eMe5JzpA=="), - - CA_ED25519( - "EdDSA", - // ED25519 - // Validity - // Not Before: May 24 23:32:35 2020 GMT - // Not After : May 22 23:32:35 2030 GMT - // X509v3 Authority Key Identifier: - // keyid:06:76:DB:88:EB:61:55:4C:C9:63:41:C2:A0:A8:57:3F:D7:F1:B8:EC - "-----BEGIN CERTIFICATE-----\n" + - "MIIByTCCAXugAwIBAgIUCyxKvhErehsygx50JYArsHby9hAwBQYDK2VwMDsxCzAJ\n" + - "BgNVBAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3Qg\n" + - "U2VyaXZjZTAeFw0yMDA1MjQyMzMyMzVaFw0zMDA1MjIyMzMyMzVaMDsxCzAJBgNV\n" + - "BAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + - "aXZjZTAqMAUGAytlcAMhAKdotuYIkH8PYbopSLbaf1BtqUY2d6AbTgK2prMzQ6B3\n" + - "o4GQMIGNMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFAZ224jrYVVMyWNBwqCo\n" + - "Vz/X8bjsMB8GA1UdIwQYMBaAFAZ224jrYVVMyWNBwqCoVz/X8bjsMA4GA1UdDwEB\n" + - "/wQEAwIBhjAqBgNVHSUBAf8EIDAeBggrBgEFBQcDAwYIKwYBBQUHAwgGCCsGAQUF\n" + - "BwMJMAUGAytlcANBADVAArvME8xFigFhCCCOTBoy/4ldGkDZQ/GT3Q6xnAP558FU\n" + - "0G32OprKQZP43D9bmFU0LMgCVM9bHWU+bu/10AU=\n" + - "-----END CERTIFICATE-----", - "MC4CAQAwBQYDK2VwBCIEII/VYp8nu/eqq2L5y7/3IzavBgis4LWP6Rikv0N8SpgL"), - - CA_ED448( - "EdDSA", - // ED448 - // Validity - // Not Before: May 24 23:23:43 2020 GMT - // Not After : May 22 23:23:43 2030 GMT - // X509v3 Authority Key Identifier: - // keyid:F5:D5:9D:FB:6F:B7:50:29:DF:F0:B8:83:10:5F:9B:C4:A8:1C:E9:F4 - "-----BEGIN CERTIFICATE-----\n" + - "MIICFDCCAZSgAwIBAgIUKcmLeKilq0LN40sniBJO7F1gb/owBQYDK2VxMDsxCzAJ\n" + - "BgNVBAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3Qg\n" + - "U2VyaXZjZTAeFw0yMDA1MjQyMzIzNDNaFw0zMDA1MjIyMzIzNDNaMDsxCzAJBgNV\n" + - "BAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + - "aXZjZTBDMAUGAytlcQM6APYP8iSXS8xPVDike5RgCByfTtg4GGtpYfoBtt6G5szA\n" + - "55ExAKjm03wtk29nEPU2mCHF2QgfBzUrgKOBkDCBjTAPBgNVHRMBAf8EBTADAQH/\n" + - "MB0GA1UdDgQWBBT11Z37b7dQKd/wuIMQX5vEqBzp9DAfBgNVHSMEGDAWgBT11Z37\n" + - "b7dQKd/wuIMQX5vEqBzp9DAOBgNVHQ8BAf8EBAMCAYYwKgYDVR0lAQH/BCAwHgYI\n" + - "KwYBBQUHAwMGCCsGAQUFBwMIBggrBgEFBQcDCTAFBgMrZXEDcwAlRXA2gPb52yV3\n" + - "MKJErjmKlYSFExj5w5jafbbd0QgI1yDs+qSaZLjQ8ljwabmLDg+KR+167m0djQDI\n" + - "OOoVuL7bgM0RL836KnuuBzm+gTdPp0gCXy3k9lL0KA0V2YLJHXXzu3suu+7rdgoP\n" + - "plCh2hWdLgA=\n" + - "-----END CERTIFICATE-----", - "MEcCAQAwBQYDK2VxBDsEOd6/hRZqkUyTlJSwdN5gO/HnoWYda1fD83YUm5j6m2Bg\n" + - "hAQi+QadFsQLD7R6PI/4Q0twXqlKnxU5Ug=="), - - EE_ECDSA_SECP256R1( - "EC", - // SHA256withECDSA, curve secp256r1 - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Authority Key Identifier: - // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 - "-----BEGIN CERTIFICATE-----\n" + - "MIIBqjCCAVCgAwIBAgIJAPLY8qZjgNRAMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMFUxCzAJBgNVBAYTAlVT\n" + - "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTEY\n" + - "MBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD\n" + - "QgAEb+9n05qfXnfHUb0xtQJNS4JeSi6IjOfW5NqchvKnfJey9VkJzR7QHLuOESdf\n" + - "xlR7q8YIWgih3iWLGfB+wxHiOqMjMCEwHwYDVR0jBBgwFoAUYM+9c//6GjDSpOzT\n" + - "SXFG7xo1oIYwCgYIKoZIzj0EAwIDSAAwRQIgWpRegWXMheiD3qFdd8kMdrkLxRbq\n" + - "1zj8nQMEwFTUjjQCIQDRIrAjZX+YXHN9b0SoWWLPUq0HmiFIi8RwMnO//wJIGQ==\n" + - "-----END CERTIFICATE-----", - "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgn5K03bpTLjEtFQRa\n" + - "JUtx22gtmGEvvSUSQdimhGthdtihRANCAARv72fTmp9ed8dRvTG1Ak1Lgl5KLoiM\n" + - "59bk2pyG8qd8l7L1WQnNHtAcu44RJ1/GVHurxghaCKHeJYsZ8H7DEeI6"), - - EE_ECDSA_SECP384R1( - "EC", - // SHA384withECDSA, curve secp384r1 - // Validity - // Not Before: Jun 24 08:15:06 2019 GMT - // Not After : Jun 19 08:15:06 2039 GMT - // Authority Key Identifier: - // 40:2D:AA:EE:66:AA:33:27:AD:9B:5D:52:9B:60:67:6A:2B:AD:52:D2 - "-----BEGIN CERTIFICATE-----\n" + - "MIICEjCCAZegAwIBAgIUS3F0AqAXWRg07CnbknJzxofyBQMwCgYIKoZIzj0EAwMw\n" + - "OzELMAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0Ug\n" + - "VGVzdCBTZXJpdmNlMB4XDTE5MDYyNDA4MTUwNloXDTM5MDYxOTA4MTUwNlowVTEL\n" + - "MAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVz\n" + - "dCBTZXJpdmNlMRgwFgYDVQQDDA9SZWdyZXNzaW9uIFRlc3QwdjAQBgcqhkjOPQIB\n" + - "BgUrgQQAIgNiAARqElz8b6T07eyKomIinhztV3/3XBk9bKGtJ0W+JOltjuhMmP/w\n" + - "G8ASSevpgqgpi6EzpBZaaJxE3zNfkNnxXOZmQi2Ypd1uK0zRdbEOKg0XOcTTZwEj\n" + - "iLjYmt3O0pwpklijQjBAMB0GA1UdDgQWBBRALaruZqozJ62bXVKbYGdqK61S0jAf\n" + - "BgNVHSMEGDAWgBRKS1IUCtHWn/mZdXSTKjRHEhVr9TAKBggqhkjOPQQDAwNpADBm\n" + - "AjEArVDFKf48xijN6huVUJzKCOP0zlWB5Js+DItIkZmLQuhciPLhLIB/rChf3Y4C\n" + - "xuP4AjEAmfLhQRI0O3pifpYzYSVh2G7/jHNG4eO+2dvgAcU+Lh2IIj/cpLaPFSvL\n" + - "J8FXY9Nj\n" + - "-----END CERTIFICATE-----", - "MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDASuI9EtK29APXPipkc\n" + - "qDA+qwlewMjv/OcjUJ77kP1Vz62oVF9iY9SRIyFIUju8wt+hZANiAARqElz8b6T0\n" + - "7eyKomIinhztV3/3XBk9bKGtJ0W+JOltjuhMmP/wG8ASSevpgqgpi6EzpBZaaJxE\n" + - "3zNfkNnxXOZmQi2Ypd1uK0zRdbEOKg0XOcTTZwEjiLjYmt3O0pwpklg="), - - EE_ECDSA_SECP521R1( - "EC", - // SHA512withECDSA, curve secp521r1 - // Validity - // Not Before: Jun 24 08:15:06 2019 GMT - // Not After : Jun 19 08:15:06 2039 GMT - // Authority Key Identifier: - // 7B:AA:79:A4:49:DD:59:34:F0:86:6C:51:C7:30:F4:CE:C5:81:8A:28 - "-----BEGIN CERTIFICATE-----\n" + - "MIICXDCCAb2gAwIBAgIUck4QTsbHNqUfPxfGPJLYbedFPdswCgYIKoZIzj0EAwQw\n" + - "OzELMAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0Ug\n" + - "VGVzdCBTZXJpdmNlMB4XDTE5MDYyNDA4MTUwNloXDTM5MDYxOTA4MTUwNlowVTEL\n" + - "MAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVz\n" + - "dCBTZXJpdmNlMRgwFgYDVQQDDA9SZWdyZXNzaW9uIFRlc3QwgZswEAYHKoZIzj0C\n" + - "AQYFK4EEACMDgYYABAGa2zDLhYQHHCLI3YBqFYJTzrnDIjzwXrxhcRTS8DYkcrjZ\n" + - "+Fih1YyNhix0sdjH+3EqElXAHHuVzn3n3hPOtQCWlQCICkErB34S0cvmtRkeW8Fi\n" + - "hrR5tvJEzEZjPSgwn81kKyhV2L70je6i7Cw884Va8bODckpgw0vTmbQb7T9dupkv\n" + - "1aNCMEAwHQYDVR0OBBYEFHuqeaRJ3Vk08IZsUccw9M7FgYooMB8GA1UdIwQYMBaA\n" + - "FEAivFrtaq2pQJ4cW4pEQML3aym9MAoGCCqGSM49BAMEA4GMADCBiAJCAb33KHdY\n" + - "WDbusORWoY8Euglpd5zsF15hJsk7wtpD5HST1/NWmdCx405w+TV6a9Gr4VPHeaIQ\n" + - "99i/+f237ALL5p6IAkIBbwwFL1vt3c/bx+niyuffQPNjly80rdC9puqAqriSiboS\n" + - "efhxjidJ9HLaIRCMEPyd6vAsC8mO8YvL1uCuEQLsiGM=\n" + - "-----END CERTIFICATE-----", - "MIHuAgEAMBAGByqGSM49AgEGBSuBBAAjBIHWMIHTAgEBBEIB8C/2OX2Dt9vFszzV\n" + - "hcAe0CbkMlvu9uQ/L7Vz88heuIj0rUZIPGshvgIJt1hCMT8HZxYHvDa4lbUvqjFB\n" + - "+zafvPWhgYkDgYYABAGa2zDLhYQHHCLI3YBqFYJTzrnDIjzwXrxhcRTS8DYkcrjZ\n" + - "+Fih1YyNhix0sdjH+3EqElXAHHuVzn3n3hPOtQCWlQCICkErB34S0cvmtRkeW8Fi\n" + - "hrR5tvJEzEZjPSgwn81kKyhV2L70je6i7Cw884Va8bODckpgw0vTmbQb7T9dupkv\n" + - "1Q=="), - - EE_RSA_2048( - "RSA", - // SHA256withRSA, 2048 bits - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Authority Key Identifier: - // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C - "-----BEGIN CERTIFICATE-----\n" + - "MIIDNjCCAh6gAwIBAgIJAO2+yPcFryUTMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + - "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + - "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMFUxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MIIBIjANBgkqhkiG9w0BAQEFAAOC\n" + - "AQ8AMIIBCgKCAQEAszfBobWfZIp8AgC6PiWDDavP65mSvgCXUGxACbxVNAfkLhNR\n" + - "QOsHriRB3X1Q3nvO9PetC6wKlvE9jlnDDj7D+1j1r1CHO7ms1fq8rfcQYdkanDtu\n" + - "4AlHo8v+SSWX16MIXFRYDj2VVHmyPtgbltcg4zGAuwT746FdLI94uXjJjq1IOr/v\n" + - "0VIlwE5ORWH5Xc+5Tj+oFWK0E4a4GHDgtKKhn2m72hN56/GkPKGkguP5NRS1qYYV\n" + - "/EFkdyQMOV8J1M7HaicSft4OL6eKjTrgo93+kHk+tv0Dc6cpVBnalX3TorG8QI6B\n" + - "cHj1XQd78oAlAC+/jF4pc0mwi0un49kdK9gRfQIDAQABoyMwITAfBgNVHSMEGDAW\n" + - "gBQN3ZPJ/ku9NbfomXiQ+9taPdsVTDANBgkqhkiG9w0BAQsFAAOCAQEApXS0nKwm\n" + - "Kp8gpmO2yG1rpd1+2wBABiMU4JZaTqmma24DQ3RzyS+V2TeRb29dl5oTUEm98uc0\n" + - "GPZvhK8z5RFr4YE17dc04nI/VaNDCw4y1NALXGs+AHkjoPjLyGbWpi1S+gfq2sNB\n" + - "Ekkjp6COb/cb9yiFXOGVls7UOIjnVZVd0r7KaPFjZhYh82/f4PA/A1SnIKd1+nfH\n" + - "2yk7mSJNC7Z3qIVDL8MM/jBVwiC3uNe5GPB2uwhd7k5LGAVN3j4HQQGB0Sz+VC1h\n" + - "92oi6xDa+YBva2fvHuCd8P50DDjxmp9CemC7rnZ5j8egj88w14X44Xjb/Fd/ApG9\n" + - "e57NnbT7KM+Grw==\n" + - "-----END CERTIFICATE-----", - "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCzN8GhtZ9kinwC\n" + - "ALo+JYMNq8/rmZK+AJdQbEAJvFU0B+QuE1FA6weuJEHdfVDee870960LrAqW8T2O\n" + - "WcMOPsP7WPWvUIc7uazV+ryt9xBh2RqcO27gCUejy/5JJZfXowhcVFgOPZVUebI+\n" + - "2BuW1yDjMYC7BPvjoV0sj3i5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HU7DbaTv3\n" + - "7QL7KnbaUWRB26HHzIMYVh0el6T+KADf8NXCiMTr+bfpfbL3dxoiF3zhAoGAbCJD\n" + - "Qse1dBs/cKYCHfkSOsI5T6kx52Tw0jS6Y4X/FOBjyqr/elyEexbdk8PH9Ar931Qr\n" + - "NKMvn8oA4iA/PRrXX7M2yi3YQrWwbkGYWYjtzrzEAdzmg+5eARKAeJrZ8/bg9l3U\n" + - "ttKaItJsDPlizn8rngy3FsJpR9aSAMK6/+wOiYkCgYEA1tZkI1rD1W9NYZtbI9BE\n" + - "qlJVFi2PBOJMKNuWdouPX3HLQ72GJSQff2BFzLTELjweVVJ0SvY4IipzpQOHQOBy\n" + - "5qh/p6izXJZh3IHtvwVBjHoEVplg1b2+I5e3jDCfqnwcQw82dW5SxOJMg1h/BD0I\n" + - "qAL3go42DYeYhu/WnECMeis="), - - EE_EC_RSA_SECP256R1( - "EC", - // SHA256withRSA, curve secp256r1 - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 21 07:18:16 2028 GMT - // Authority Key Identifier: - // 0D:DD:93:C9:FE:4B:BD:35:B7:E8:99:78:90:FB:DB:5A:3D:DB:15:4C - "-----BEGIN CERTIFICATE-----\n" + - "MIICazCCAVOgAwIBAgIJAO2+yPcFryUUMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" + - "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + - "aXZjZTAeFw0xODA1MjIwNzE4MTZaFw0yODA1MjEwNzE4MTZaMFUxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0D\n" + - "AQcDQgAE59MERNTlVZ1eeps8Z3Oue5ZkgQdPtD+WIE6tj3PbIKpxGPDxvfNP959A\n" + - "yQjEK/ehWQVrCMmNoEkIzY+IIBgB06MjMCEwHwYDVR0jBBgwFoAUDd2Tyf5LvTW3\n" + - "6Jl4kPvbWj3bFUwwDQYJKoZIhvcNAQELBQADggEBAFOTVEqs70ykhZiIdrEsF1Ra\n" + - "I3B2rLvwXZk52uSltk2/bzVvewA577ZCoxQ1pL7ynkisPfBN1uVYtHjM1VA3RC+4\n" + - "+TAK78dnI7otYjWoHp5rvs4l6c/IbOspS290IlNuDUxMErEm5wxIwj+Aukx/1y68\n" + - "hOyCvHBLMY2c1LskH1MMBbDuS1aI+lnGpToi+MoYObxGcV458vxuT8+wwV8Fkpvd\n" + - "ll8IIFmeNPRv+1E+lXbES6CSNCVaZ/lFhPgdgYKleN7sfspiz50DG4dqafuEAaX5\n" + - "xaK1NWXJxTRz0ROH/IUziyuDW6jphrlgit4+3NCzp6vP9hAJQ8Vhcj0n15BKHIQ=\n" + - "-----END CERTIFICATE-----", - "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGVc7hICpmp91jbYe\n" + - "nrr8nYHD37RZP3VENY+szuA7WjuhRANCAATn0wRE1OVVnV56mzxnc657lmSBB0+0\n" + - "P5YgTq2Pc9sgqnEY8PG980/3n0DJCMQr96FZBWsIyY2gSQjNj4ggGAHT"), - - EE_DSA_2048( - "DSA", - // SHA256withDSA, 2048 bits - // Validity - // Not Before: May 22 07:18:20 2018 GMT - // Not After : May 17 07:18:20 2038 GMT - // Authority Key Identifier: - // 76:66:9E:F7:3B:DD:45:E5:3B:D9:72:3C:3F:F0:54:39:86:31:26:53 - "-----BEGIN CERTIFICATE-----\n" + - "MIIEnDCCBEGgAwIBAgIJAP/jh1qVhNVjMAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" + - "EwJVUzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2\n" + - "Y2UwHhcNMTgwNTIyMDcxODIwWhcNMzg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Ltu+\n" + - "j7v78gp5OChDp/n49K6DtKtZZRDmw/Bpm6LNdknmdN5kO5wVzbIXHTCCeNs/CJTF\n" + - "mSU5PvEaI4y3M5NraSgLPkq4gEv7/A8orGbKmj1Whj3F9t1Tosxdm/+WkPldMz2t\n" + - "gev+9RM2S6S9XoembRgwRaFVkpQmKoKpOoZcdqV47FLDq5BYH/5POeJ9wLuAHjxQ\n" + - "5CMKo4p/lW7BCd4kuGWFT+OFFXfG2v6EtlqFbXBiFWLxyMsOtkUqWARCqEHhyucl\n" + - "TSYlj60EIgIgLfA75+8KcKxdN8mr6gzGjQe7jPFGG42Ejhd7Q2F4wuw="), - - EE_DSA_1024( - "DSA", - // dsaWithSHA1, 1024 bits - // Validity - // Not Before: Apr 24 12:25:43 2020 GMT - // Not After : Apr 22 12:25:43 2030 GMT - // Authority Key Identifier: - // E1:3C:01:52:EB:D1:38:F7:CF:F1:E3:5E:DB:54:75:7F:5E:AB:2D:36 - "-----BEGIN CERTIFICATE-----\n" + - "MIIDADCCAr+gAwIBAgIUd2XJ5F2VTbk9a92w/NzLXR5zjUQwCQYHKoZIzjgEAzAu\n" + - "MQswCQYDVQQGEwJVUzENMAsGA1UECgwESmF2YTEQMA4GA1UECwwHU3VuSlNTRTAe\n" + - "Fw0yMDA0MjQxMjI1NDNaFw0zMDA0MjIxMjI1NDNaMEgxCzAJBgNVBAYTAlVTMQ0w\n" + - "CwYDVQQKDARKYXZhMRAwDgYDVQQLDAdTdW5KU1NFMRgwFgYDVQQDDA9SZWdyZXNz\n" + - "aW9uIFRlc3QwggG3MIIBLAYHKoZIzjgEATCCAR8CgYEA7fSkxYISlMJT+i8N5VOb\n" + - "lHhjrPYAy3oR2/YXQW6T0hCMhm8jmxgk1bDId9ZKHrxsM05EkCtRYaqag4ZZeGde\n" + - "ywv3IwwYqCQfGtkPwT9QAsdSABYwGOrlhEtZtBG1yQ44c+Rz/Vs+PtkAyZbf5VG1\n" + - "iSxFb9bI5QFJWJ9a2VpZh58CFQCCGALQoK4MsQP8V72WlB7Bvt9erwKBgQDCxu0G\n" + - "M2iZr0J8DaAo9/ChS4m7E7h6Jz9KOm2cFhzYGekkUXNzny7nyz6Qpgbuf8KNFKjt\n" + - "qoUDC8tlcVQAUlTcESC0TZXR3h21hl9wzIBhE+kJ1j8v1KAxfOaJOxObk5QEvIaA\n" + - "5j+jiHGwRS5tDqywOatz+emwMZv1wKnCNBElNgOBhAACgYBHjuQKucCuuvy/4DpG\n" + - "rSIzdueK+HrzOW8h2pfvz3lzpsyV6XJPC6we9CjaQjU01VcjwN2PoYtbGyml0pbK\n" + - "We4sdgn6LDL1aCM/WKRSxGHVTx+wkhKQ719YtiC0T6sA+eLirc6VT3/6+FbQWC+2\n" + - "bG7N19sGpV/RAXMBpRXUnBJSQaNCMEAwHQYDVR0OBBYEFNNZxyxuQmKvWowofr/S\n" + - "HdCIS+W8MB8GA1UdIwQYMBaAFOE8AVLr0Tj3z/HjXttUdX9eqy02MAkGByqGSM44\n" + - "BAMDMAAwLQIUUzzMhZ9St/Vo/YdgNTHdTw4cm14CFQCE6tWG157Wl5YFyYsGHsLY\n" + - "NN8uCA==\n" + - "-----END CERTIFICATE-----", - "MIIBSwIBADCCASwGByqGSM44BAEwggEfAoGBAO30pMWCEpTCU/ovDeVTm5R4Y6z2\n" + - "AMt6Edv2F0Fuk9IQjIZvI5sYJNWwyHfWSh68bDNORJArUWGqmoOGWXhnXssL9yMM\n" + - "GKgkHxrZD8E/UALHUgAWMBjq5YRLWbQRtckOOHPkc/1bPj7ZAMmW3+VRtYksRW/W\n" + - "yOUBSVifWtlaWYefAhUAghgC0KCuDLED/Fe9lpQewb7fXq8CgYEAwsbtBjNoma9C\n" + - "fA2gKPfwoUuJuxO4eic/SjptnBYc2BnpJFFzc58u58s+kKYG7n/CjRSo7aqFAwvL\n" + - "ZXFUAFJU3BEgtE2V0d4dtYZfcMyAYRPpCdY/L9SgMXzmiTsTm5OUBLyGgOY/o4hx\n" + - "sEUubQ6ssDmrc/npsDGb9cCpwjQRJTYEFgIUNRiLmNzfTYOuVsjkySPzP5gPImM="), - - EE_ED25519( - "EdDSA", - // ED25519 - // Validity - // Not Before: May 24 23:32:36 2020 GMT - // Not After : May 22 23:32:36 2030 GMT - // X509v3 Authority Key Identifier: - // keyid:06:76:DB:88:EB:61:55:4C:C9:63:41:C2:A0:A8:57:3F:D7:F1:B8:EC - "-----BEGIN CERTIFICATE-----\n" + - "MIIBlDCCAUagAwIBAgIUFTt/jcgQ65nhTG8LkrWFJhhEGuwwBQYDK2VwMDsxCzAJ\n" + - "BgNVBAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3Qg\n" + - "U2VyaXZjZTAeFw0yMDA1MjQyMzMyMzZaFw0zMDA1MjIyMzMyMzZaMFUxCzAJBgNV\n" + - "BAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + - "aXZjZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MCowBQYDK2VwAyEAGAYQmKb7\n" + - "WNYpVxIdsc49lI1emNjF06/Jl85zlG0wc9OjQjBAMB0GA1UdDgQWBBQkJ2E4/S8Z\n" + - "EIM1v9uTc0eYtYNk3zAfBgNVHSMEGDAWgBQGdtuI62FVTMljQcKgqFc/1/G47DAF\n" + - "BgMrZXADQQCVZnl/AyIEtZ8r45e/hcfxwuezgRX+7e9NHZFV1A/TMGcBRORDfDUi\n" + - "bbh72K528fjT7P4/WoXvm1zJKOAzUOUL\n" + - "-----END CERTIFICATE-----", - "MC4CAQAwBQYDK2VwBCIEIGBmdh4tfc0lng/LWokhfFLlo0ZlmTn2lbI639qou2KP"), - - EE_ED448( - "EdDSA", - // ED448 - // Validity - // Not Before: May 24 23:23:43 2020 GMT - // Not After : May 22 23:23:43 2030 GMT - // X509v3 Authority Key Identifier: - // keyid:F5:D5:9D:FB:6F:B7:50:29:DF:F0:B8:83:10:5F:9B:C4:A8:1C:E9:F4 - "-----BEGIN CERTIFICATE-----\n" + - "MIIB3zCCAV+gAwIBAgIUNlWzFrH2+BILqM3SNYQjKoY98S8wBQYDK2VxMDsxCzAJ\n" + - "BgNVBAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3Qg\n" + - "U2VyaXZjZTAeFw0yMDA1MjQyMzIzNDNaFw0zMDA1MjIyMzIzNDNaMFUxCzAJBgNV\n" + - "BAYTAlVTMQ0wCwYDVQQKDARqYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" + - "aXZjZTEYMBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MEMwBQYDK2VxAzoAoIubPNAg\n" + - "F11u3MQ5d9wujg10+80I0xzYzTqzzXrfJNtw+eU8NbUk86xiCvlMzJRH0Oo3DbY8\n" + - "NAKAo0IwQDAdBgNVHQ4EFgQUUiI1+qT1x+HsDgfZRIU6hUaAbmUwHwYDVR0jBBgw\n" + - "FoAU9dWd+2+3UCnf8LiDEF+bxKgc6fQwBQYDK2VxA3MAx8P0mle08s5YDd/p58dt\n" + - "yORqvDPwo5IYPasqN8Zeen1B9u1xF/kvDGFxCJ6D9Gi4ynnDx0FZFMkA83evZcxJ\n" + - "+X+swt7FyHwXrdkZcvjRKEcsWhkj+0FlxYF/NZzLTGuGIPYJnRLEwf/zr+5NDxKs\n" + - "fCoA\n" + - "-----END CERTIFICATE-----", - "MEcCAQAwBQYDK2VxBDsEOfbhmUSuKP9WCO7Nr6JxVq5rfJESk1MNMyYhC134SiAP\n" + - "Suw0Cu7RZVadpfPR7Kiwb2b/JXjMdY1HAA=="); - - final String keyAlgo; - final String certStr; - final String privKeyStr; - - Cert(String keyAlgo, String certStr, String privKeyStr) { - this.keyAlgo = keyAlgo; - this.certStr = certStr; - this.privKeyStr = privKeyStr; - } - } } diff --git a/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java b/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java index 66efefeee4a4a..734906f03e1fe 100644 --- a/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java +++ b/test/jdk/sun/security/ssl/ALPN/AlpnGreaseTest.java @@ -53,7 +53,7 @@ * (wrap/unwrap) pass before any application data is consumed or * produced. */ -public class AlpnGreaseTest implements SSLContextTemplate { +public class AlpnGreaseTest extends SSLContextTemplate { private final SSLEngine clientEngine; // client Engine private final ByteBuffer clientOut; // write side of clientEngine diff --git a/test/jdk/sun/security/ssl/CipherSuite/DisabledCurve.java b/test/jdk/sun/security/ssl/CipherSuite/DisabledCurve.java index e63c16895129e..26304c5df957c 100644 --- a/test/jdk/sun/security/ssl/CipherSuite/DisabledCurve.java +++ b/test/jdk/sun/security/ssl/CipherSuite/DisabledCurve.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 @@ -48,21 +48,23 @@ public class DisabledCurve extends SSLSocketTemplate { { { "TLSv1.2" }, { "TLSv1.2" } }, { { "TLSv1.1" }, { "TLSv1.1" } }, { { "TLSv1" }, { "TLSv1" } } }; + @Override protected SSLContext createClientSSLContext() throws Exception { return createSSLContext( - new SSLSocketTemplate.Cert[] { - SSLSocketTemplate.Cert.CA_ECDSA_SECP384R1 }, - new SSLSocketTemplate.Cert[] { - SSLSocketTemplate.Cert.EE_ECDSA_SECP384R1 }, + new SSLContextTemplate.Cert[] { + SSLContextTemplate.Cert.CA_ECDSA_SECP384R1 }, + new SSLContextTemplate.Cert[] { + SSLContextTemplate.Cert.EE_ECDSA_SECP384R1 }, getClientContextParameters()); } + @Override protected SSLContext createServerSSLContext() throws Exception { return createSSLContext( - new SSLSocketTemplate.Cert[] { - SSLSocketTemplate.Cert.CA_ECDSA_SECP384R1 }, - new SSLSocketTemplate.Cert[] { - SSLSocketTemplate.Cert.EE_ECDSA_SECP384R1 }, + new SSLContextTemplate.Cert[] { + SSLContextTemplate.Cert.CA_ECDSA_SECP384R1 }, + new SSLContextTemplate.Cert[] { + SSLContextTemplate.Cert.EE_ECDSA_SECP384R1 }, getServerContextParameters()); } diff --git a/test/jdk/sun/security/ssl/CipherSuite/RestrictSignatureScheme.java b/test/jdk/sun/security/ssl/CipherSuite/RestrictSignatureScheme.java index 3dde234a2ceb3..eebff3ec96cff 100644 --- a/test/jdk/sun/security/ssl/CipherSuite/RestrictSignatureScheme.java +++ b/test/jdk/sun/security/ssl/CipherSuite/RestrictSignatureScheme.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 @@ -28,21 +28,12 @@ * @summary Restrict signature algorithms and named groups * @run main/othervm RestrictSignatureScheme */ -import java.io.ByteArrayInputStream; -import java.security.KeyFactory; -import java.security.KeyStore; -import java.security.PrivateKey; + import java.security.Security; -import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; -import java.security.spec.PKCS8EncodedKeySpec; import java.util.Arrays; -import java.util.Base64; -import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLServerSocket; -import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.SSLException; public class RestrictSignatureScheme extends SSLSocketTemplate { @@ -58,16 +49,20 @@ public class RestrictSignatureScheme extends SSLSocketTemplate { private final SSLContext context; RestrictSignatureScheme() throws Exception { - this.context = createSSLContext(); + this.context = createSSLContext( + new Cert[]{Cert.EE_RSASSA_PSS}, + new Cert[]{Cert.EE_RSASSA_PSS}, + new ContextParameters("TLS", "PKIX", "NewSunX509") + ); } @Override - protected SSLContext createClientSSLContext() throws Exception { + public SSLContext createClientSSLContext() throws Exception { return context; } @Override - protected SSLContext createServerSSLContext() throws Exception { + public SSLContext createServerSSLContext() throws Exception { return context; } @@ -117,116 +112,4 @@ public static void main(String[] args) throws Exception { throw new Exception("The test case should be disabled"); } } - - - private static final String trustedCertStr = - /** - * Signature Algorithm: rsassaPss - * Issuer: CN = localhost - * Validity Not Before: Jun 6 07:11:00 2018 GMT - * Not After : Jun 1 07:11:00 2038 GMT - * Subject: CN = localhost - * Public Key Algorithm: rsassaPss - */ - "-----BEGIN CERTIFICATE-----\n" - + "MIIDZjCCAh2gAwIBAgIUHxwPs3eAgJ057nJwiLgWZWeNqdgwPgYJKoZIhvcNAQEK\n" - + "MDGgDTALBglghkgBZQMEAgGhGjAYBgkqhkiG9w0BAQgwCwYJYIZIAWUDBAIBogQC\n" - + "AgDeMBQxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0xODA2MDYwNzExMDBaFw0zODA2\n" - + "MDEwNzExMDBaMBQxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASAwCwYJKoZIhvcNAQEK\n" - + "A4IBDwAwggEKAoIBAQCl8r4Qrg27BYUO/1Va2Ix8QPGzN/lvzmKvP5Ff26ovNW4v\n" - + "RUx68HzAhhiWtcl+PwLSbJqJreEkTlle7PnRAypby3fO7ZAK0Y3YiHquaBg7d+7Y\n" - + "FhhHwv8gG0lZcyA0BkXFJHqdq76qar0xHC6DVezXm0K3mcceymGtFR9BzWmAj+7D\n" - + "YsSwvtTQ7WNoQmf0cdDMSM71IwaTwIwvT2wzX1vv5hcdDyXdr64WFqWSA9sNJ2K6\n" - + "arxaaU1klwKSgDokF6njafWQ4UxdR67d5W1MYoiioDs2Yy3utsMpO2OUzZVBZNdT\n" - + "gkr1jsJhIurpz/5K51lwJIRQBezEFSb+60AFVoMJAgMBAAGjUDBOMB0GA1UdDgQW\n" - + "BBQfFit5ilWJmZgCX4QY0HsaI9iIDDAfBgNVHSMEGDAWgBQfFit5ilWJmZgCX4QY\n" - + "0HsaI9iIDDAMBgNVHRMEBTADAQH/MD4GCSqGSIb3DQEBCjAxoA0wCwYJYIZIAWUD\n" - + "BAIBoRowGAYJKoZIhvcNAQEIMAsGCWCGSAFlAwQCAaIEAgIA3gOCAQEAa4yUQ3gh\n" - + "d1YWPdEa1sv2hdkhtenw6m5yxbmaQl2+nIKSpk4RfpXC7K1EYwBF8TdfFbD8hGGh\n" - + "5n81BT0/dn1R9SRGCv7KTxx4lfQt31frlsw/tVciwyXQtcUZ6DqfnLP0/aRVLNgx\n" - + "zaP542JUHFYLTC3EGz2zUgv70ZUTlIsPG3/p8YO1iXdnYGQyzOuQPUBpI7nS7UtR\n" - + "Ug8VE9ACpBxxI3qChMahFZGHlXCCSjSmxpQa6UO4SQl8q5tPNnqdzWwvAW8qkCy4\n" - + "6barRQ4sMcGayhHh/uSTx7bcl0FMJpcI1ygbw7/Pc03zKtw0gMTBMns7q4yXjb/u\n" - + "ef47nW0t+LRAAg==\n" - + "-----END CERTIFICATE-----\n"; - - private static final String keyCertStr = trustedCertStr; - - private static final String privateKey = - "MIIEuwIBADALBgkqhkiG9w0BAQoEggSnMIIEowIBAAKCAQEApfK+EK4NuwWFDv9V\n" - + "WtiMfEDxszf5b85irz+RX9uqLzVuL0VMevB8wIYYlrXJfj8C0myaia3hJE5ZXuz5\n" - + "0QMqW8t3zu2QCtGN2Ih6rmgYO3fu2BYYR8L/IBtJWXMgNAZFxSR6nau+qmq9MRwu\n" - + "g1Xs15tCt5nHHsphrRUfQc1pgI/uw2LEsL7U0O1jaEJn9HHQzEjO9SMGk8CML09s\n" - + "M19b7+YXHQ8l3a+uFhalkgPbDSdiumq8WmlNZJcCkoA6JBep42n1kOFMXUeu3eVt\n" - + "TGKIoqA7NmMt7rbDKTtjlM2VQWTXU4JK9Y7CYSLq6c/+SudZcCSEUAXsxBUm/utA\n" - + "BVaDCQIDAQABAoIBAAc4vRS0vlw5LUUtz2UYr2Ro3xvRf8Vh0eGWfpkRUiKjzJu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ofaiiWffsaytVvotmT6+atElvAMbAua42V+nAQKBgHtIn3mYMHLriYGhQzpkFEA2\n" - + "8YcAMlKppueOMAKVy8nLu2r3MidmLAhMiKJQKG45I3Yg0/t/25tXLiOPJlwrOebh\n" - + "xQqUBI/JUOIpGAEnr48jhOXnCS+i+z294G5U/RgjXrlR4bCPvrtCmwzWwe0h79w2\n" - + "Q2hO5ZTW6UD9CVA85whf"; - - private static SSLContext createSSLContext() throws Exception { - // Generate certificate from cert string - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - // Create a key store - KeyStore ts = KeyStore.getInstance("PKCS12"); - KeyStore ks = KeyStore.getInstance("PKCS12"); - ts.load(null, null); - ks.load(null, null); - char passphrase[] = "passphrase".toCharArray(); - - // Import the trusted cert - ts.setCertificateEntry("trusted-cert-RSASSA-PSS", - cf.generateCertificate(new ByteArrayInputStream( - trustedCertStr.getBytes()))); - - boolean hasKeyMaterials = keyCertStr != null && privateKey != null; - if (hasKeyMaterials) { - - // Generate the private key. - PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( - Base64.getMimeDecoder().decode(privateKey)); - KeyFactory kf = KeyFactory.getInstance("RSASSA-PSS"); - PrivateKey priKey = kf.generatePrivate(priKeySpec); - - // Generate certificate chain - Certificate keyCert = cf.generateCertificate( - new ByteArrayInputStream(keyCertStr.getBytes())); - Certificate[] chain = new Certificate[]{keyCert}; - - // Import the key entry. - ks.setKeyEntry("cert-RSASSA-PSS", priKey, passphrase, chain); - } - - // Create SSL context - TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX"); - tmf.init(ts); - - SSLContext context = SSLContext.getInstance("TLS"); - if (hasKeyMaterials) { - KeyManagerFactory kmf = KeyManagerFactory.getInstance("NewSunX509"); - kmf.init(ks, passphrase); - context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - } else { - context.init(null, tmf.getTrustManagers(), null); - } - - return context; - } } diff --git a/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java index a3e355af361ed..497544bafc622 100644 --- a/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java +++ b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineBadBufferArrayAccess.java @@ -30,7 +30,7 @@ * @test * @bug 7031830 * @summary bad_record_mac failure on TLSv1.2 enabled connection with SSLEngine - * @library /test/lib + * @library /test/lib /javax/net/ssl/templates * @run main/othervm SSLEngineBadBufferArrayAccess */ @@ -82,19 +82,19 @@ import javax.net.ssl.SSLEngineResult.*; import java.io.*; import java.net.*; -import java.security.*; import java.nio.*; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import jdk.test.lib.security.SecurityUtils; -public class SSLEngineBadBufferArrayAccess { +public class SSLEngineBadBufferArrayAccess extends SSLContextTemplate { /* * Enables logging of the SSL/TLS operations. */ - private static boolean logging = true; + private final static boolean logging = Boolean.parseBoolean( + System.getProperty("test.logging", "true")); /* * Enables the JSSE system debugging system property: @@ -105,8 +105,9 @@ public class SSLEngineBadBufferArrayAccess { * including specific handshake messages, and might be best examined * after gaining some familiarity with this application. */ - private static boolean debug = false; - private SSLContext sslc; + private final static boolean debug = Boolean.getBoolean("test.debug"); + private final String PROTOCOL; + private SSLEngine serverEngine; // server-side SSLEngine private final byte[] serverMsg = "Hi there Client, I'm a Server".getBytes(); @@ -124,20 +125,6 @@ public class SSLEngineBadBufferArrayAccess { private ByteBuffer cTOs; // "reliable" transport client->server private ByteBuffer sTOc; // "reliable" transport server->client - /* - * The following is to set up the keystores/trust material. - */ - private static final String pathToStores = "../../../../javax/net/ssl/etc"; - private static final String keyStoreFile = "keystore"; - private static final String trustStoreFile = "truststore"; - private static final String passwd = "passphrase"; - private static String keyFilename = - System.getProperty("test.src", ".") + "/" + pathToStores - + "/" + keyStoreFile; - private static String trustFilename = - System.getProperty("test.src", ".") + "/" + pathToStores - + "/" + trustStoreFile; - /* * Is the server ready to serve? */ @@ -156,7 +143,7 @@ public class SSLEngineBadBufferArrayAccess { /* * Main entry point for this test. */ - public static void main(String args[]) throws Exception { + public static void main(String[] args) throws Exception { if (debug) { System.setProperty("javax.net.debug", "all"); } @@ -165,7 +152,7 @@ public static void main(String args[]) throws Exception { SecurityUtils.removeFromDisabledTlsAlgs("TLSv1", "TLSv1.1"); String [] protocols = new String [] { - "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2" }; + "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"}; for (String protocol : protocols) { /* @@ -184,32 +171,18 @@ public static void main(String args[]) throws Exception { /* * Create an initialized SSLContext to use for these tests. */ - public SSLEngineBadBufferArrayAccess(String protocol) throws Exception { - - KeyStore ks = KeyStore.getInstance("JKS"); - KeyStore ts = KeyStore.getInstance("JKS"); - - char[] passphrase = "passphrase".toCharArray(); - - try (FileInputStream fis = new FileInputStream(keyFilename)) { - ks.load(fis, passphrase); - } - - try (FileInputStream fis = new FileInputStream(trustFilename)) { - ts.load(fis, passphrase); - } - - KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(ks, passphrase); - - TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); - tmf.init(ts); - - SSLContext sslCtx = SSLContext.getInstance(protocol); + public SSLEngineBadBufferArrayAccess(String protocol) { + PROTOCOL = protocol; + } - sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + @Override + protected ContextParameters getServerContextParameters() { + return new ContextParameters(PROTOCOL, "PKIX", "NewSunX509"); + } - sslc = sslCtx; + @Override + protected ContextParameters getClientContextParameters() { + return new ContextParameters(PROTOCOL, "PKIX", "NewSunX509"); } /* @@ -232,6 +205,7 @@ public SSLEngineBadBufferArrayAccess(String protocol) throws Exception { private void runTest(boolean direct) throws Exception { boolean serverClose = direct; + System.out.println("Running test serverClose = " + serverClose); ServerSocket serverSocket = new ServerSocket(0); serverPort = serverSocket.getLocalPort(); @@ -244,7 +218,7 @@ private void runTest(boolean direct) throws Exception { Socket socket; try { serverSocket.setSoTimeout(30000); - socket = (Socket) serverSocket.accept(); + socket = serverSocket.accept(); } catch (SocketTimeoutException ste) { serverSocket.close(); @@ -327,7 +301,7 @@ void runServerApplication(Socket socket, boolean direct, byte[] outbound = new byte[8192]; while (!isEngineClosed(serverEngine)) { - int len = 0; + int len; // Inbound data log("================"); @@ -336,7 +310,14 @@ void runServerApplication(Socket socket, boolean direct, try { len = is.read(inbound); if (len == -1) { - throw new Exception("Unexpected EOF"); + logSocketStatus(socket); + if (socket.isClosed() + || socket.isOutputShutdown()) { + log("Client socket was closed or shutdown output"); + break; + } else { + throw new Exception("Unexpected EOF"); + } } cTOs.put(inbound, 0, len); } catch (SocketTimeoutException ste) { @@ -372,16 +353,13 @@ void runServerApplication(Socket socket, boolean direct, closed = true; /* - * We'll alternate initiatating the shutdown. + * We'll alternate initiating the shutdown. * When the server initiates, it will take one more * loop, but tests the orderly shutdown. */ if (serverClose) { serverEngine.closeOutbound(); } - } - - if (closed && isEngineClosed(serverEngine)) { serverIn.flip(); /* @@ -403,6 +381,7 @@ void runServerApplication(Socket socket, boolean direct, } } serverIn.compact(); + break; } } } @@ -450,7 +429,7 @@ void doClientSide(boolean serverClose) throws Exception { return; } - SSLSocketFactory sslsf = sslc.getSocketFactory(); + SSLSocketFactory sslsf = createClientSSLContext().getSocketFactory(); try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket()) { try { sslSocket.connect( @@ -492,6 +471,7 @@ void runClientApplication(SSLSocket sslSocket, boolean serverClose) InputStream is = sslSocket.getInputStream(); // write(byte[]) goes in one shot. + System.out.println("writing message to server."); os.write(clientMsg); byte[] inbound = new byte[2048]; @@ -499,14 +479,16 @@ void runClientApplication(SSLSocket sslSocket, boolean serverClose) int len; while ((len = is.read(inbound, pos, 2048 - pos)) != -1) { + System.out.printf("Client read %d bytes. Waiting for %d from server.%n", len, serverMsg.length); pos += len; // Let the client do the closing. if ((pos == serverMsg.length) && !serverClose) { + System.out.println("Closing the socket"); sslSocket.close(); break; } } - + System.out.println("Read everything we're going to, I guess."); if (pos != serverMsg.length) { throw new Exception("Client: Data length error"); } @@ -527,7 +509,7 @@ private void createSSLEngine() throws Exception { * Configure the serverEngine to act as a server in the SSL/TLS * handshake. */ - serverEngine = sslc.createSSLEngine(); + serverEngine = createServerSSLContext().createSSLEngine(); serverEngine.setUseClientMode(false); serverEngine.getNeedClientAuth(); } @@ -589,6 +571,15 @@ private static boolean isEngineClosed(SSLEngine engine) { return (engine.isOutboundDone() && engine.isInboundDone()); } + private static void logSocketStatus(Socket socket) { + log("##### " + socket + " #####"); + log("isBound: " + socket.isBound()); + log("isConnected: " + socket.isConnected()); + log("isClosed: " + socket.isClosed()); + log("isInputShutdown: " + socket.isInputShutdown()); + log("isOutputShutdown: " + socket.isOutputShutdown()); + } + /* * Logging code */ diff --git a/test/jdk/sun/security/ssl/SSLSessionImpl/InvalidateSession.java b/test/jdk/sun/security/ssl/SSLSessionImpl/InvalidateSession.java index 2a13a8cdb8fc3..87eeeaebfdba1 100644 --- a/test/jdk/sun/security/ssl/SSLSessionImpl/InvalidateSession.java +++ b/test/jdk/sun/security/ssl/SSLSessionImpl/InvalidateSession.java @@ -37,7 +37,7 @@ import jdk.test.lib.security.SecurityUtils; -public class InvalidateSession implements SSLContextTemplate { +public class InvalidateSession extends SSLContextTemplate { static ServerSocketFactory serverSsf = null; static SSLSocketFactory clientSsf = null; diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/ClientSocketCloseHang.java b/test/jdk/sun/security/ssl/SSLSocketImpl/ClientSocketCloseHang.java index 249aab13291bd..e21cc314775bc 100644 --- a/test/jdk/sun/security/ssl/SSLSocketImpl/ClientSocketCloseHang.java +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/ClientSocketCloseHang.java @@ -34,7 +34,7 @@ import javax.net.ssl.*; import java.net.InetAddress; -public class ClientSocketCloseHang implements SSLContextTemplate { +public class ClientSocketCloseHang extends SSLContextTemplate { public static void main(String[] args) throws Exception { System.setProperty("jdk.tls.client.protocols", args[0]); diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketBruceForceClose.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketBruceForceClose.java index b220a3d434bf7..bbc8a4f8bf55a 100644 --- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketBruceForceClose.java +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketBruceForceClose.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 @@ -31,117 +31,72 @@ * @bug 8209333 * @summary Socket reset issue for TLS 1.3 socket close * @library /javax/net/ssl/templates - * @run main/othervm SSLSocketBruceForceClose + * @run main/othervm SSLSocketBruteForceClose */ import javax.net.ssl.*; import java.io.*; -import java.net.InetAddress; +import java.net.SocketException; -public class SSLSocketBruceForceClose implements SSLContextTemplate { +public class SSLSocketBruteForceClose extends SSLSocketTemplate { public static void main(String[] args) throws Exception { for (int i = 0; i<= 10; i++) { System.err.println("==================================="); System.err.println("loop " + i); System.err.println("==================================="); - new SSLSocketBruceForceClose().test(); + new SSLSocketBruteForceClose().run(); } } - private void test() throws Exception { - SSLServerSocket listenSocket = null; - SSLSocket serverSocket = null; - ClientSocket clientSocket = null; - try { - SSLServerSocketFactory serversocketfactory = - createServerSSLContext().getServerSocketFactory(); - listenSocket = - (SSLServerSocket)serversocketfactory.createServerSocket(0); - listenSocket.setNeedClientAuth(false); - listenSocket.setEnableSessionCreation(true); - listenSocket.setUseClientMode(false); - - - System.err.println("Starting client"); - clientSocket = new ClientSocket(listenSocket.getLocalPort()); - clientSocket.start(); - - System.err.println("Accepting client requests"); - serverSocket = (SSLSocket) listenSocket.accept(); - - System.err.println("Reading data from client"); - BufferedReader serverReader = new BufferedReader( - new InputStreamReader(serverSocket.getInputStream())); - String data = serverReader.readLine(); - System.err.println("Received data from client: " + data); - - System.err.println("Reading more data from client"); - data = serverReader.readLine(); - System.err.println("Received data from client: " + data); - } finally { - if (listenSocket != null) { - listenSocket.close(); - } - - if (serverSocket != null) { - serverSocket.close(); - } - } - - if (clientSocket != null && clientSocket.clientException != null) { - throw clientSocket.clientException; - } + @Override + protected void configureServerSocket(SSLServerSocket socket) { + socket.setNeedClientAuth(false); + socket.setEnableSessionCreation(true); + socket.setUseClientMode(false); } - private class ClientSocket extends Thread{ - int serverPort = 0; - Exception clientException; + @Override + protected void runServerApplication(SSLSocket socket) throws Exception { + System.err.println("Reading data from client"); + BufferedReader serverReader = new BufferedReader( + new InputStreamReader(socket.getInputStream())); + String data = serverReader.readLine(); + System.err.println("Received data from client: " + data); + + System.err.println("Reading more data from client"); + data = serverReader.readLine(); + System.err.println("Received data from client: " + data); + } - public ClientSocket(int serverPort) { - this.serverPort = serverPort; + @Override + protected void configureClientSocket(SSLSocket socket) { + try { + socket.setSoLinger(true, 3); + socket.setSoTimeout(1000); + } catch (SocketException exc) { + throw new RuntimeException("Could not configure client socket", exc); } + } - @Override - public void run() { - SSLSocket clientSocket = null; - String clientData = "Hi, I am client"; - try { - System.err.println( - "Connecting to server at port " + serverPort); - SSLSocketFactory sslSocketFactory = - createClientSSLContext().getSocketFactory(); - clientSocket = (SSLSocket)sslSocketFactory.createSocket( - InetAddress.getLocalHost(), serverPort); - clientSocket.setSoLinger(true, 3); - clientSocket.setSoTimeout(1000); - + @Override + protected void runClientApplication(SSLSocket socket) throws Exception { + String clientData = "Hi, I am client"; - System.err.println("Sending data to server ..."); + System.err.println("Sending data to server ..."); + BufferedWriter os = new BufferedWriter( + new OutputStreamWriter(socket.getOutputStream())); + os.write(clientData, 0, clientData.length()); + os.newLine(); + os.flush(); - BufferedWriter os = new BufferedWriter( - new OutputStreamWriter(clientSocket.getOutputStream())); - os.write(clientData, 0, clientData.length()); - os.newLine(); - os.flush(); + System.err.println("Sending more data to server ..."); + os.write(clientData, 0, clientData.length()); + os.newLine(); + os.flush(); - System.err.println("Sending more data to server ..."); - os.write(clientData, 0, clientData.length()); - os.newLine(); - os.flush(); - } catch (Exception e) { - clientException = e; - } finally { - if (clientSocket != null) { - try{ - clientSocket.close(); - System.err.println("client socket closed"); - } catch (IOException ioe) { - clientException = ioe; - } - } - } - } + socket.close(); + System.err.println("client socket closed"); } } diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketBruteForceClose.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketBruteForceClose.java new file mode 100644 index 0000000000000..bbc8a4f8bf55a --- /dev/null +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketBruteForceClose.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// +// Please run in othervm mode. SunJSSE does not support dynamic system +// properties, no way to re-use system properties in samevm/agentvm mode. +// + +/* + * @test + * @bug 8209333 + * @summary Socket reset issue for TLS 1.3 socket close + * @library /javax/net/ssl/templates + * @run main/othervm SSLSocketBruteForceClose + */ + +import javax.net.ssl.*; +import java.io.*; +import java.net.SocketException; + +public class SSLSocketBruteForceClose extends SSLSocketTemplate { + + public static void main(String[] args) throws Exception { + for (int i = 0; i<= 10; i++) { + System.err.println("==================================="); + System.err.println("loop " + i); + System.err.println("==================================="); + new SSLSocketBruteForceClose().run(); + } + } + + @Override + protected void configureServerSocket(SSLServerSocket socket) { + socket.setNeedClientAuth(false); + socket.setEnableSessionCreation(true); + socket.setUseClientMode(false); + } + + @Override + protected void runServerApplication(SSLSocket socket) throws Exception { + System.err.println("Reading data from client"); + BufferedReader serverReader = new BufferedReader( + new InputStreamReader(socket.getInputStream())); + String data = serverReader.readLine(); + System.err.println("Received data from client: " + data); + + System.err.println("Reading more data from client"); + data = serverReader.readLine(); + System.err.println("Received data from client: " + data); + } + + @Override + protected void configureClientSocket(SSLSocket socket) { + try { + socket.setSoLinger(true, 3); + socket.setSoTimeout(1000); + } catch (SocketException exc) { + throw new RuntimeException("Could not configure client socket", exc); + } + } + + @Override + protected void runClientApplication(SSLSocket socket) throws Exception { + String clientData = "Hi, I am client"; + + System.err.println("Sending data to server ..."); + BufferedWriter os = new BufferedWriter( + new OutputStreamWriter(socket.getOutputStream())); + os.write(clientData, 0, clientData.length()); + os.newLine(); + os.flush(); + + System.err.println("Sending more data to server ..."); + os.write(clientData, 0, clientData.length()); + os.newLine(); + os.flush(); + + socket.close(); + System.err.println("client socket closed"); + } +} + diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketClose.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketClose.java index 47a06093e3fe6..2ca82ef514e6b 100644 --- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketClose.java +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketClose.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 @@ -37,123 +37,79 @@ import javax.net.ssl.*; import java.io.*; import java.net.InetAddress; +import java.net.SocketException; -public class SSLSocketClose implements SSLContextTemplate { +public class SSLSocketClose extends SSLSocketTemplate { public static void main(String[] args) throws Exception { for (int i = 0; i<= 10; i++) { - System.err.println("==================================="); - System.err.println("loop " + i); - System.err.println("==================================="); - new SSLSocketClose().test(); + System.out.println("==================================="); + System.out.println("loop " + i); + System.out.println("==================================="); + new SSLSocketClose().run(); } } - private void test() throws Exception { - SSLServerSocket listenSocket = null; - SSLSocket serverSocket = null; - ClientSocket clientSocket = null; - try { - SSLServerSocketFactory serversocketfactory = - createServerSSLContext().getServerSocketFactory(); - listenSocket = - (SSLServerSocket)serversocketfactory.createServerSocket(0); - listenSocket.setNeedClientAuth(false); - listenSocket.setEnableSessionCreation(true); - listenSocket.setUseClientMode(false); - - - System.err.println("Starting client"); - clientSocket = new ClientSocket(listenSocket.getLocalPort()); - clientSocket.start(); - - System.err.println("Accepting client requests"); - serverSocket = (SSLSocket) listenSocket.accept(); - - System.err.println("Reading data from client"); - BufferedReader serverReader = new BufferedReader( - new InputStreamReader(serverSocket.getInputStream())); - String data = serverReader.readLine(); - System.err.println("Received data from client: " + data); - - System.err.println("Sending data to client ..."); - String serverData = "Hi, I am server"; - BufferedWriter os = new BufferedWriter( - new OutputStreamWriter(serverSocket.getOutputStream())); - os.write(serverData, 0, serverData.length()); - os.newLine(); - os.flush(); - - System.err.println("Reading more data from client"); - data = serverReader.readLine(); - System.err.println("Received data from client: " + data); - } finally { - if (listenSocket != null) { - listenSocket.close(); - } - - if (serverSocket != null) { - serverSocket.close(); - } - } - - if (clientSocket != null && clientSocket.clientException != null) { - throw clientSocket.clientException; - } + @Override + protected void configureServerSocket(SSLServerSocket socket) { + socket.setNeedClientAuth(false); + socket.setEnableSessionCreation(true); + socket.setUseClientMode(false); } - private class ClientSocket extends Thread{ - int serverPort = 0; - Exception clientException; + @Override + protected void runServerApplication(SSLSocket socket) throws Exception { + System.out.println("Reading data from client"); + BufferedReader serverReader = new BufferedReader( + new InputStreamReader(socket.getInputStream())); + String data = serverReader.readLine(); + System.out.println("Received data from client: " + data); + + System.out.println("Sending data to client ..."); + String serverData = "Hi, I am server"; + BufferedWriter os = new BufferedWriter( + new OutputStreamWriter(socket.getOutputStream())); + os.write(serverData, 0, serverData.length()); + os.newLine(); + os.flush(); + + System.out.println("Reading more data from client"); + data = serverReader.readLine(); + System.out.println("Received data from client: " + data); + } - public ClientSocket(int serverPort) { - this.serverPort = serverPort; + @Override + protected void configureClientSocket(SSLSocket socket) { + try { + socket.setSoLinger(true, 3); + } catch (SocketException e) { + throw new RuntimeException("Could not configure client socket", e); } + } - @Override - public void run() { - SSLSocket clientSocket = null; - String clientData = "Hi, I am client"; - try { - System.err.println( - "Connecting to server at port " + serverPort); - SSLSocketFactory sslSocketFactory = - createClientSSLContext().getSocketFactory(); - clientSocket = (SSLSocket)sslSocketFactory.createSocket( - InetAddress.getLocalHost(), serverPort); - clientSocket.setSoLinger(true, 3); - - System.err.println("Sending data to server ..."); - - BufferedWriter os = new BufferedWriter( - new OutputStreamWriter(clientSocket.getOutputStream())); - os.write(clientData, 0, clientData.length()); - os.newLine(); - os.flush(); - - System.err.println("Reading data from server"); - BufferedReader is = new BufferedReader( - new InputStreamReader(clientSocket.getInputStream())); - String data = is.readLine(); - System.err.println("Received Data from server: " + data); - - System.err.println("Sending more data to server ..."); - os.write(clientData, 0, clientData.length()); - os.newLine(); - os.flush(); - } catch (Exception e) { - clientException = e; - } finally { - if (clientSocket != null) { - try{ - clientSocket.close(); - System.err.println("client socket closed"); - } catch (IOException ioe) { - clientException = ioe; - } - } - } - } + @Override + protected void runClientApplication(SSLSocket socket) throws Exception { + String clientData = "Hi, I am client"; + System.out.println("Sending data to server ..."); + + BufferedWriter os = new BufferedWriter( + new OutputStreamWriter(socket.getOutputStream())); + os.write(clientData, 0, clientData.length()); + os.newLine(); + os.flush(); + + System.out.println("Reading data from server"); + BufferedReader is = new BufferedReader( + new InputStreamReader(socket.getInputStream())); + String data = is.readLine(); + System.out.println("Received Data from server: " + data); + + System.out.println("Sending more data to server ..."); + os.write(clientData, 0, clientData.length()); + os.newLine(); + os.flush(); + + socket.close(); } } diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SocketExceptionForSocketIssues.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SocketExceptionForSocketIssues.java index dcaf6dab977f4..8a406ee65bbfd 100644 --- a/test/jdk/sun/security/ssl/SSLSocketImpl/SocketExceptionForSocketIssues.java +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SocketExceptionForSocketIssues.java @@ -37,126 +37,84 @@ import javax.net.ssl.*; import java.io.*; import java.net.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; -public class SocketExceptionForSocketIssues implements SSLContextTemplate { +public class SocketExceptionForSocketIssues extends SSLSocketTemplate { + + private final CountDownLatch waitForClient = new CountDownLatch(1); public static void main(String[] args) throws Exception { - System.err.println("==================================="); - new SocketExceptionForSocketIssues().test(); + System.out.println("==================================="); + new SocketExceptionForSocketIssues().run(); + } + + @Override + protected void configureServerSocket(SSLServerSocket socket) { + socket.setNeedClientAuth(false); + socket.setEnableSessionCreation(true); + socket.setUseClientMode(false); } - private void test() throws Exception { - SSLServerSocket listenSocket = null; - SSLSocket serverSocket = null; - ClientSocket clientSocket = null; + @Override + protected void runServerApplication(SSLSocket socket) throws Exception { try { - SSLServerSocketFactory serversocketfactory = - createServerSSLContext().getServerSocketFactory(); - listenSocket = - (SSLServerSocket)serversocketfactory.createServerSocket(0); - listenSocket.setNeedClientAuth(false); - listenSocket.setEnableSessionCreation(true); - listenSocket.setUseClientMode(false); - - System.err.println("Starting client"); - clientSocket = new ClientSocket(listenSocket.getLocalPort()); - clientSocket.start(); - - System.err.println("Accepting client requests"); - serverSocket = (SSLSocket)listenSocket.accept(); - - if (!clientSocket.isDone) { - System.err.println("Waiting 3 seconds for client "); - Thread.sleep(3000); + if (!waitForClient.await(5, TimeUnit.SECONDS)) { + throw new RuntimeException("Client didn't complete within 5 seconds."); } - System.err.println("Sending data to client ..."); + System.out.println("Sending data to client ..."); String serverData = "Hi, I am server"; BufferedWriter os = new BufferedWriter( - new OutputStreamWriter(serverSocket.getOutputStream())); + new OutputStreamWriter(socket.getOutputStream())); os.write(serverData, 0, serverData.length()); os.newLine(); os.flush(); - } catch (SSLProtocolException | SSLHandshakeException sslhe) { - throw sslhe; + throw new RuntimeException("The expected SocketException was not thrown."); } catch (SocketException se) { // the expected exception, ignore it - System.err.println("server exception: " + se); - } finally { - if (listenSocket != null) { - listenSocket.close(); - } - - if (serverSocket != null) { - serverSocket.close(); - } + System.out.println("Caught expected SocketException: " + se); } + } - if (clientSocket != null && clientSocket.clientException != null) { - throw clientSocket.clientException; + @Override + protected void configureClientSocket(SSLSocket socket) { + try { + socket.setSoLinger(true, 3); + socket.setSoTimeout(100); + } catch (SocketException exc) { + throw new RuntimeException("Could not configure client socket.", exc); } } + @Override + protected void runClientApplication(SSLSocket socket) throws Exception { + try { + String clientData = "Hi, I am client"; + BufferedWriter os = new BufferedWriter( + new OutputStreamWriter(socket.getOutputStream())); + os.write(clientData, 0, clientData.length()); + os.newLine(); + os.flush(); + + System.out.println("Reading data from server"); + BufferedReader is = new BufferedReader( + new InputStreamReader(socket.getInputStream())); + String data = is.readLine(); + System.out.println("Received Data from server: " + data); + throw new RuntimeException("The expected client exception was not thrown."); - private class ClientSocket extends Thread{ - boolean isDone = false; - int serverPort = 0; - Exception clientException; + } catch (SSLProtocolException | SSLHandshakeException sslhe) { + System.err.println("Client had unexpected SSL exception: " + sslhe); + throw sslhe; - public ClientSocket(int serverPort) { - this.serverPort = serverPort; - } + } catch (SSLException | SocketTimeoutException ssle) { + // the expected exception, ignore it + System.out.println("Caught expected client exception: " + ssle); - @Override - public void run() { - SSLSocket clientSocket = null; - String clientData = "Hi, I am client"; - try { - System.err.println( - "Connecting to server at port " + serverPort); - SSLSocketFactory sslSocketFactory = - createClientSSLContext().getSocketFactory(); - clientSocket = (SSLSocket)sslSocketFactory.createSocket( - InetAddress.getLocalHost(), serverPort); - clientSocket.setSoLinger(true, 3); - clientSocket.setSoTimeout(100); - - - System.err.println("Sending data to server ..."); - - BufferedWriter os = new BufferedWriter( - new OutputStreamWriter(clientSocket.getOutputStream())); - os.write(clientData, 0, clientData.length()); - os.newLine(); - os.flush(); - - System.err.println("Reading data from server"); - BufferedReader is = new BufferedReader( - new InputStreamReader(clientSocket.getInputStream())); - String data = is.readLine(); - System.err.println("Received Data from server: " + data); - } catch (SSLProtocolException | SSLHandshakeException sslhe) { - clientException = sslhe; - System.err.println("unexpected client exception: " + sslhe); - } catch (SSLException | SocketTimeoutException ssle) { - // the expected exception, ignore it - System.err.println("expected client exception: " + ssle); - } catch (Exception e) { - clientException = e; - System.err.println("unexpected client exception: " + e); - } finally { - if (clientSocket != null) { - try { - clientSocket.close(); - System.err.println("client socket closed"); - } catch (IOException ioe) { - clientException = ioe; - } - } - - isDone = true; - } + } finally { + waitForClient.countDown(); } } } diff --git a/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS12.java b/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS12.java index d7d068f339d6a..30a01552b301e 100644 --- a/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS12.java +++ b/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS12.java @@ -61,115 +61,7 @@ public class SigAlgosExtTestWithTLS12 extends SSLEngineTemplate { private static final boolean EXPECT_FAIL = Boolean.getBoolean("test.expectFail"); - private static final String[] CA_CERTS = new String[] { - // SHA256withECDSA, curve secp256r1 - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Subject Key Identifier: - // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 - "-----BEGIN CERTIFICATE-----\n" + - "MIIBvjCCAWOgAwIBAgIJAIvFG6GbTroCMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMDsxCzAJBgNVBAYTAlVT\n" + - "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTBZ\n" + - "MBMGByqGSM49AgEGCCqGSM49AwEHA0IABBz1WeVb6gM2mh85z3QlvaB/l11b5h0v\n" + - "LIzmkC3DKlVukZT+ltH2Eq1oEkpXuf7QmbM0ibrUgtjsWH3mULfmcWmjUDBOMB0G\n" + - "A1UdDgQWBBRgz71z//oaMNKk7NNJcUbvGjWghjAfBgNVHSMEGDAWgBRgz71z//oa\n" + - "MNKk7NNJcUbvGjWghjAMBgNVHRMEBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQCG\n" + - "6wluh1r2/T6L31mZXRKf9JxeSf9pIzoLj+8xQeUChQIhAJ09wAi1kV8yePLh2FD9\n" + - "2YEHlSQUAbwwqCDEVB5KxaqP\n" + - "-----END CERTIFICATE-----", - - // SHA384withECDSA, curve secp384r1 - // Validity - // Not Before: Jun 24 08:15:06 2019 GMT - // Not After : Jun 19 08:15:06 2039 GMT - // Subject Key Identifier: - // 0a:93:a9:a0:bf:e7:d5:48:9d:4f:89:15:c6:51:98:80:05:51:4e:4e - "-----BEGIN CERTIFICATE-----\n" + - "MIICCDCCAY6gAwIBAgIUCpOpoL/n1UidT4kVxlGYgAVRTk4wCgYIKoZIzj0EAwMw\n" + - "OzELMAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0Ug\n" + - "VGVzdCBTZXJpdmNlMB4XDTE5MDYyNDA4MTUwNloXDTM5MDYxOTA4MTUwNlowOzEL\n" + - "MAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVz\n" + - "dCBTZXJpdmNlMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAENVQN1wXWFdgC6u/dDdiC\n" + - "y+WtMTF66oL/0BSm+1ZqsogamzCryawOcHgiuXgWzx5CQ3LuOC+tDFyXpGfHuCvb\n" + - "dkzxPrP5n9NrR8/uRPe5l1KOUbchviU8z9cTP+LZxnZDo1MwUTAdBgNVHQ4EFgQU\n" + - "SktSFArR1p/5mXV0kyo0RxIVa/UwHwYDVR0jBBgwFoAUSktSFArR1p/5mXV0kyo0\n" + - "RxIVa/UwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjBZvoNmq3/v\n" + - "RD2gBTyvxjS9h0rsMRLHDnvul/KWngytwGPTOBo0Y8ixQXSjdKoc3rkCMQDkiNgx\n" + - "IDxuHedmrLQKIPnVcthTmwv7//jHiqGoKofwChMo2a1P+DQdhszmeHD/ARQ=\n" + - "-----END CERTIFICATE-----" - }; - - private static final String[] EE_CERTS = new String[] { - // SHA256withECDSA, curve secp256r1 - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Authority Key Identifier: - // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 - "-----BEGIN CERTIFICATE-----\n" + - "MIIBqjCCAVCgAwIBAgIJAPLY8qZjgNRAMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMFUxCzAJBgNVBAYTAlVT\n" + - "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTEY\n" + - "MBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD\n" + - "QgAEb+9n05qfXnfHUb0xtQJNS4JeSi6IjOfW5NqchvKnfJey9VkJzR7QHLuOESdf\n" + - "xlR7q8YIWgih3iWLGfB+wxHiOqMjMCEwHwYDVR0jBBgwFoAUYM+9c//6GjDSpOzT\n" + - "SXFG7xo1oIYwCgYIKoZIzj0EAwIDSAAwRQIgWpRegWXMheiD3qFdd8kMdrkLxRbq\n" + - "1zj8nQMEwFTUjjQCIQDRIrAjZX+YXHN9b0SoWWLPUq0HmiFIi8RwMnO//wJIGQ==\n" + - "-----END CERTIFICATE-----", - - // SHA384withECDSA, curve secp384r1 - // Validity - // Not Before: Jun 24 08:15:06 2019 GMT - // Not After : Jun 19 08:15:06 2039 GMT - // Authority Key Identifier: - // 40:2D:AA:EE:66:AA:33:27:AD:9B:5D:52:9B:60:67:6A:2B:AD:52:D2 - "-----BEGIN CERTIFICATE-----\n" + - "MIICEjCCAZegAwIBAgIUS3F0AqAXWRg07CnbknJzxofyBQMwCgYIKoZIzj0EAwMw\n" + - "OzELMAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0Ug\n" + - "VGVzdCBTZXJpdmNlMB4XDTE5MDYyNDA4MTUwNloXDTM5MDYxOTA4MTUwNlowVTEL\n" + - "MAkGA1UEBhMCVVMxDTALBgNVBAoMBEphdmExHTAbBgNVBAsMFFN1bkpTU0UgVGVz\n" + - "dCBTZXJpdmNlMRgwFgYDVQQDDA9SZWdyZXNzaW9uIFRlc3QwdjAQBgcqhkjOPQIB\n" + - "BgUrgQQAIgNiAARqElz8b6T07eyKomIinhztV3/3XBk9bKGtJ0W+JOltjuhMmP/w\n" + - "G8ASSevpgqgpi6EzpBZaaJxE3zNfkNnxXOZmQi2Ypd1uK0zRdbEOKg0XOcTTZwEj\n" + - "iLjYmt3O0pwpklijQjBAMB0GA1UdDgQWBBRALaruZqozJ62bXVKbYGdqK61S0jAf\n" + - "BgNVHSMEGDAWgBRKS1IUCtHWn/mZdXSTKjRHEhVr9TAKBggqhkjOPQQDAwNpADBm\n" + - "AjEArVDFKf48xijN6huVUJzKCOP0zlWB5Js+DItIkZmLQuhciPLhLIB/rChf3Y4C\n" + - "xuP4AjEAmfLhQRI0O3pifpYzYSVh2G7/jHNG4eO+2dvgAcU+Lh2IIj/cpLaPFSvL\n" + - "J8FXY9Nj\n" + - "-----END CERTIFICATE-----" - }; - - private static final String[] EE_KEYS = new String[] { - "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgn5K03bpTLjEtFQRa\n" + - "JUtx22gtmGEvvSUSQdimhGthdtihRANCAARv72fTmp9ed8dRvTG1Ak1Lgl5KLoiM\n" + - "59bk2pyG8qd8l7L1WQnNHtAcu44RJ1/GVHurxghaCKHeJYsZ8H7DEeI6", - "MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDASuI9EtK29APXPipkc\n" + - "qDA+qwlewMjv/OcjUJ77kP1Vz62oVF9iY9SRIyFIUju8wt+hZANiAARqElz8b6T0\n" + - "7eyKomIinhztV3/3XBk9bKGtJ0W+JOltjuhMmP/wG8ASSevpgqgpi6EzpBZaaJxE\n" + - "3zNfkNnxXOZmQi2Ypd1uK0zRdbEOKg0XOcTTZwEjiLjYmt3O0pwpklg=" - }; - - private static final String[] EE_ALGS = new String[] { - "EC", - "EC" - }; - - private static final String[] EE_ALIASES = new String[] { - "EC-SHA256", - "EC-SHA384" - }; - - private static final Map SIG_SCHEMES_MAP = Map.of( - 0x0403, "ecdsa_secp256r1_sha256", - 0x0503, "ecdsa_secp384r1_sha384"); - - private static final int TLS_HS_CLI_HELLO = 1; private static final int TLS_HS_CERT_REQ = 13; - private static final int HELLO_EXT_SIG_ALGS = 13; public SigAlgosExtTestWithTLS12() throws Exception { super(); @@ -178,36 +70,31 @@ public SigAlgosExtTestWithTLS12() throws Exception { /* * Create an instance of KeyManager for client use. */ - public KeyManager createClientKeyManager() throws Exception { - return SSLContextTemplate.createKeyManager( - EE_CERTS, - EE_KEYS, - EE_ALGS, - EE_ALIASES, - getServerContextParameters()); + @Override + protected KeyManager createClientKeyManager() throws Exception { + return createKeyManager( + new Cert[]{Cert.EE_ECDSA_SECP256R1, Cert.EE_ECDSA_SECP384R1}, + getClientContextParameters()); } @Override public TrustManager createClientTrustManager() throws Exception { - return SSLContextTemplate.createTrustManager( - CA_CERTS, + return createTrustManager( + new Cert[]{Cert.CA_ECDSA_SECP256R1, Cert.CA_ECDSA_SECP384R1}, getServerContextParameters()); } @Override public KeyManager createServerKeyManager() throws Exception { - return SSLContextTemplate.createKeyManager( - EE_CERTS, - EE_KEYS, - EE_ALGS, - EE_ALIASES, + return createKeyManager( + new Cert[]{Cert.EE_ECDSA_SECP256R1, Cert.EE_ECDSA_SECP384R1}, getServerContextParameters()); } @Override public TrustManager createServerTrustManager() throws Exception { - return SSLContextTemplate.createTrustManager( - CA_CERTS, + return createTrustManager( + new Cert[]{Cert.CA_ECDSA_SECP256R1, Cert.CA_ECDSA_SECP384R1}, getServerContextParameters()); } diff --git a/test/jdk/sun/security/ssl/SignatureScheme/Tls13NamedGroups.java b/test/jdk/sun/security/ssl/SignatureScheme/Tls13NamedGroups.java index fa876db5b3c44..ed428df60bc70 100644 --- a/test/jdk/sun/security/ssl/SignatureScheme/Tls13NamedGroups.java +++ b/test/jdk/sun/security/ssl/SignatureScheme/Tls13NamedGroups.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 @@ -37,14 +37,7 @@ * @run main/othervm Tls13NamedGroups */ -import java.net.*; -import java.io.*; import javax.net.ssl.*; -import java.security.*; -import java.security.cert.*; -import java.security.spec.*; -import java.security.interfaces.*; -import java.util.Base64; public class Tls13NamedGroups extends SSLSocketTemplate { @@ -56,8 +49,10 @@ public static void main(String[] args) throws Exception { } @Override - protected SSLContext createServerSSLContext() throws Exception { - return generateSSLContext(); + public SSLContext createServerSSLContext() throws Exception { + return createSSLContext(new Cert[]{Cert.CA_ECDSA_SECP256R1}, + new Cert[]{Cert.EE_ECDSA_SECP256R1}, + new ContextParameters("TLSv1.3", "PKIX", "NewSunX509")); } @Override @@ -66,123 +61,9 @@ protected void configureServerSocket(SSLServerSocket socket) { } @Override - protected SSLContext createClientSSLContext() throws Exception { - return generateSSLContext(); - } - - /* - * ============================================================= - * The remainder is just support stuff - */ - - // Certificates and key used in the test. - // - // Trusted Certificate. - static String trustedCertStr = - // SHA256withECDSA, curve prime256v1 - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Subject Key Identifier: - // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 - "-----BEGIN CERTIFICATE-----\n" + - "MIIBvjCCAWOgAwIBAgIJAIvFG6GbTroCMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMDsxCzAJBgNVBAYTAlVT\n" + - "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTBZ\n" + - "MBMGByqGSM49AgEGCCqGSM49AwEHA0IABBz1WeVb6gM2mh85z3QlvaB/l11b5h0v\n" + - "LIzmkC3DKlVukZT+ltH2Eq1oEkpXuf7QmbM0ibrUgtjsWH3mULfmcWmjUDBOMB0G\n" + - "A1UdDgQWBBRgz71z//oaMNKk7NNJcUbvGjWghjAfBgNVHSMEGDAWgBRgz71z//oa\n" + - "MNKk7NNJcUbvGjWghjAMBgNVHRMEBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQCG\n" + - "6wluh1r2/T6L31mZXRKf9JxeSf9pIzoLj+8xQeUChQIhAJ09wAi1kV8yePLh2FD9\n" + - "2YEHlSQUAbwwqCDEVB5KxaqP\n" + - "-----END CERTIFICATE-----"; - // -----BEGIN PRIVATE KEY----- - // MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg/HcHdoLJCdq3haVd - // XZTSKP00YzM3xX97l98vGL/RI1KhRANCAAQc9VnlW+oDNpofOc90Jb2gf5ddW+Yd - // LyyM5pAtwypVbpGU/pbR9hKtaBJKV7n+0JmzNIm61ILY7Fh95lC35nFp - // -----END PRIVATE KEY----- - - // End entity certificate. - static String targetCertStr = - // SHA256withECDSA, curve prime256v1 - // Validity - // Not Before: May 22 07:18:16 2018 GMT - // Not After : May 17 07:18:16 2038 GMT - // Authority Key Identifier: - // 60:CF:BD:73:FF:FA:1A:30:D2:A4:EC:D3:49:71:46:EF:1A:35:A0:86 - "-----BEGIN CERTIFICATE-----\n" + - "MIIBqjCCAVCgAwIBAgIJAPLY8qZjgNRAMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" + - "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" + - "ZTAeFw0xODA1MjIwNzE4MTZaFw0zODA1MTcwNzE4MTZaMFUxCzAJBgNVBAYTAlVT\n" + - "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTEY\n" + - "MBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD\n" + - "QgAEb+9n05qfXnfHUb0xtQJNS4JeSi6IjOfW5NqchvKnfJey9VkJzR7QHLuOESdf\n" + - "xlR7q8YIWgih3iWLGfB+wxHiOqMjMCEwHwYDVR0jBBgwFoAUYM+9c//6GjDSpOzT\n" + - "SXFG7xo1oIYwCgYIKoZIzj0EAwIDSAAwRQIgWpRegWXMheiD3qFdd8kMdrkLxRbq\n" + - "1zj8nQMEwFTUjjQCIQDRIrAjZX+YXHN9b0SoWWLPUq0HmiFIi8RwMnO//wJIGQ==\n" + - "-----END CERTIFICATE-----"; - - // Private key in the format of PKCS#8. - static String targetPrivateKey = - // - // EC private key related to cert endEntityCertStrs[0]. - // - "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgn5K03bpTLjEtFQRa\n" + - "JUtx22gtmGEvvSUSQdimhGthdtihRANCAARv72fTmp9ed8dRvTG1Ak1Lgl5KLoiM\n" + - "59bk2pyG8qd8l7L1WQnNHtAcu44RJ1/GVHurxghaCKHeJYsZ8H7DEeI6"; - - static char passphrase[] = "passphrase".toCharArray(); - - // Create the SSLContext instance. - private static SSLContext generateSSLContext() throws Exception { - - // generate certificate from cert string - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - // create a key store - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(null, null); - - // import the trused cert - X509Certificate trusedCert = null; - ByteArrayInputStream is = - new ByteArrayInputStream(trustedCertStr.getBytes()); - trusedCert = (X509Certificate)cf.generateCertificate(is); - is.close(); - - ks.setCertificateEntry("Trusted EC Signer", trusedCert); - - // generate the private key. - PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( - Base64.getMimeDecoder().decode(targetPrivateKey)); - KeyFactory kf = KeyFactory.getInstance("EC"); - ECPrivateKey priKey = - (ECPrivateKey)kf.generatePrivate(priKeySpec); - - // generate certificate chain - is = new ByteArrayInputStream(targetCertStr.getBytes()); - X509Certificate keyCert = (X509Certificate)cf.generateCertificate(is); - is.close(); - - X509Certificate[] chain = new X509Certificate[2]; - chain[0] = keyCert; - chain[1] = trusedCert; - - // import the key entry and the chain - ks.setKeyEntry("TheKey", priKey, passphrase, chain); - - // create SSL context - TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX"); - tmf.init(ks); - - KeyManagerFactory kmf = KeyManagerFactory.getInstance("NewSunX509"); - kmf.init(ks, passphrase); - - SSLContext ctx = SSLContext.getInstance("TLSv1.3"); - ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - ks = null; - - return ctx; + public SSLContext createClientSSLContext() throws Exception { + return createSSLContext(new Cert[]{Cert.CA_ECDSA_SECP256R1}, + new Cert[]{Cert.EE_ECDSA_SECP256R1}, + new ContextParameters("TLSv1.3", "PKIX", "NewSunX509")); } } diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/TooManyCAs.java b/test/jdk/sun/security/ssl/X509TrustManagerImpl/TooManyCAs.java index 9e44b1cdc9452..41b7055e5fbc0 100644 --- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/TooManyCAs.java +++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/TooManyCAs.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 @@ -32,18 +32,17 @@ import javax.net.ssl.*; import javax.security.auth.x500.X500Principal; import java.io.*; -import java.net.InetAddress; import java.net.Socket; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -import java.util.Arrays; +import java.util.concurrent.CyclicBarrier; /** * Check if the connection can be established if the client or server trusts * more CAs such that it exceeds the size limit of the certificate_authorities * extension (2^16). */ -public class TooManyCAs implements SSLContextTemplate { +public class TooManyCAs extends SSLSocketTemplate { private static final String[][][] protocols = { {{"TLSv1.3"}, {"TLSv1.3"}}, @@ -55,44 +54,54 @@ public class TooManyCAs implements SSLContextTemplate { private final String[] serverProtocols; private final boolean needClientAuth; + /* + * Used to synchronize client and server; there were intermittent + * failures on Windows due to the connection being killed. + */ + private final CyclicBarrier barrier = new CyclicBarrier(2); + TooManyCAs(int index, boolean needClientAuth) { this.clientProtocols = protocols[index][0]; this.serverProtocols = protocols[index][1]; this.needClientAuth = needClientAuth; + + System.out.printf("Testing%n\tclient protocols: %s%n\t" + + "server protocols: %s%n\tneed client auth: %s%n", + String.join(", ", clientProtocols), + String.join(", ", serverProtocols), + needClientAuth); } - // Servers are configured before clients, increment test case after. - void configureClientSocket(SSLSocket clientSocket) { - System.err.print("Setting client protocol(s): "); - Arrays.stream(clientProtocols).forEachOrdered(System.err::print); - System.err.println(); + @Override + protected void configureClientSocket(SSLSocket clientSocket) { + System.out.println("Setting client protocol(s): " + + String.join(",", clientProtocols)); clientSocket.setEnabledProtocols(clientProtocols); } - void configureServerSocket(SSLServerSocket serverSocket) { - System.err.print("Setting server protocol(s): "); - Arrays.stream(serverProtocols).forEachOrdered(System.err::print); - System.err.println(); + @Override + protected void configureServerSocket(SSLServerSocket serverSocket) { + serverSocket.setNeedClientAuth(needClientAuth); + serverSocket.setEnableSessionCreation(true); + serverSocket.setUseClientMode(false); + + System.out.println("Setting server protocol(s): " + + String.join(",", serverProtocols)); serverSocket.setEnabledProtocols(serverProtocols); - if (needClientAuth) { - serverSocket.setNeedClientAuth(true); - } } @Override - public TrustManager createClientTrustManager() throws Exception { - TrustManager trustManager = - SSLContextTemplate.super.createClientTrustManager(); + protected TrustManager createClientTrustManager() throws Exception { + TrustManager trustManager = super.createClientTrustManager(); return new BogusX509TrustManager( (X509TrustManager)trustManager); } @Override - public TrustManager createServerTrustManager() throws Exception { - TrustManager trustManager = - SSLContextTemplate.super.createServerTrustManager(); + protected TrustManager createServerTrustManager() throws Exception { + TrustManager trustManager = super.createServerTrustManager(); return new BogusX509TrustManager( (X509TrustManager)trustManager); } @@ -107,104 +116,42 @@ public static void main(String[] args) throws Exception { } } - private void run() throws Exception { - SSLServerSocket listenSocket = null; - SSLSocket serverSocket = null; - ClientSocket clientSocket = null; + @Override + protected void runServerApplication(SSLSocket socket) throws Exception { try { - SSLServerSocketFactory serversocketfactory = - createServerSSLContext().getServerSocketFactory(); - listenSocket = - (SSLServerSocket)serversocketfactory.createServerSocket(0); - listenSocket.setNeedClientAuth(false); - listenSocket.setEnableSessionCreation(true); - listenSocket.setUseClientMode(false); - configureServerSocket(listenSocket); - - System.err.println("Starting client"); - clientSocket = new ClientSocket(listenSocket.getLocalPort()); - clientSocket.start(); - - System.err.println("Accepting client requests"); - serverSocket = (SSLSocket)listenSocket.accept(); - - if (!clientSocket.isDone) { - System.err.println("Waiting 3 seconds for client "); - Thread.sleep(3000); - } - - System.err.println("Sending data to client ..."); + System.out.println("Sending data to client ..."); String serverData = "Hi, I am server"; BufferedWriter os = new BufferedWriter( - new OutputStreamWriter(serverSocket.getOutputStream())); + new OutputStreamWriter(socket.getOutputStream())); os.write(serverData, 0, serverData.length()); os.newLine(); os.flush(); } finally { - if (listenSocket != null) { - listenSocket.close(); - } - - if (serverSocket != null) { - serverSocket.close(); - } - } - - if (clientSocket != null && clientSocket.clientException != null) { - throw clientSocket.clientException; + barrier.await(); + System.out.println("Server done"); } } - private class ClientSocket extends Thread{ - boolean isDone = false; - int serverPort = 0; - Exception clientException; + @Override + protected void runClientApplication(SSLSocket socket) throws Exception { + try { + String clientData = "Hi, I am client"; + System.out.println("Sending data to server ..."); - public ClientSocket(int serverPort) { - this.serverPort = serverPort; - } + BufferedWriter os = new BufferedWriter( + new OutputStreamWriter(socket.getOutputStream())); + os.write(clientData, 0, clientData.length()); + os.newLine(); + os.flush(); - @Override - public void run() { - SSLSocket clientSocket = null; - String clientData = "Hi, I am client"; - try { - System.err.println( - "Connecting to server at port " + serverPort); - SSLSocketFactory sslSocketFactory = - createClientSSLContext().getSocketFactory(); - clientSocket = (SSLSocket)sslSocketFactory.createSocket( - InetAddress.getLocalHost(), serverPort); - configureClientSocket(clientSocket); - - System.err.println("Sending data to server ..."); - - BufferedWriter os = new BufferedWriter( - new OutputStreamWriter(clientSocket.getOutputStream())); - os.write(clientData, 0, clientData.length()); - os.newLine(); - os.flush(); - - System.err.println("Reading data from server"); - BufferedReader is = new BufferedReader( - new InputStreamReader(clientSocket.getInputStream())); - String data = is.readLine(); - System.err.println("Received Data from server: " + data); - } catch (Exception e) { - clientException = e; - System.err.println("unexpected client exception: " + e); - } finally { - if (clientSocket != null) { - try { - clientSocket.close(); - System.err.println("client socket closed"); - } catch (IOException ioe) { - clientException = ioe; - } - } - - isDone = true; - } + System.out.println("Reading data from server"); + BufferedReader is = new BufferedReader( + new InputStreamReader(socket.getInputStream())); + String data = is.readLine(); + System.out.println("Received Data from server: " + data); + } finally { + barrier.await(); + System.out.println("client done."); } } @@ -273,7 +220,7 @@ public X509Certificate[] getAcceptedIssuers() { for (int i = 0; i < duplicated; i++) { System.arraycopy(trustedCerts, 0, returnedCAs, - i * trustedCerts.length + 0, trustedCerts.length); + i * trustedCerts.length, trustedCerts.length); } return returnedCAs; From d00e1a31d49433408120a06e6fefe02533e9b156 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 11 Oct 2023 08:24:37 +0000 Subject: [PATCH 223/341] 8308116: jdk.test.lib.compiler.InMemoryJavaCompiler.compile does not close files Reviewed-by: lucy Backport-of: e9320f31dcc4ff5197e8c3bca504a7d5c1a9035e --- .../lib/compiler/InMemoryJavaCompiler.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java b/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java index 9444e4cc97b50..ec3a8317a4318 100644 --- a/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java +++ b/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, 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 @@ -32,10 +32,11 @@ import java.util.Arrays; import java.util.List; -import javax.tools.ForwardingJavaFileManager; import javax.tools.FileObject; +import javax.tools.ForwardingJavaFileManager; import javax.tools.JavaCompiler; import javax.tools.JavaCompiler.CompilationTask; +import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.JavaFileObject.Kind; import javax.tools.SimpleJavaFileObject; @@ -167,25 +168,12 @@ public boolean hasLocation(Location location) { * @param className The name of the class * @param sourceCode The source code for the class with name {@code className} * @param options additional command line options - * @throws RuntimeException if the compilation did not succeed + * @throws RuntimeException if the compilation did not succeed or if closing + * the {@code JavaFileManager} used for the compilation did not succeed * @return The resulting byte code from the compilation */ public static byte[] compile(String className, CharSequence sourceCode, String... options) { MemoryJavaFileObject file = new MemoryJavaFileObject(className, sourceCode); - CompilationTask task = getCompilationTask(file, options); - - if(!task.call()) { - throw new RuntimeException("Could not compile " + className + " with source code " + sourceCode); - } - - return file.getByteCode(); - } - - private static JavaCompiler getCompiler() { - return ToolProvider.getSystemJavaCompiler(); - } - - private static CompilationTask getCompilationTask(MemoryJavaFileObject file, String... options) { List opts = new ArrayList<>(); String moduleOverride = null; for (String opt : options) { @@ -195,6 +183,19 @@ private static CompilationTask getCompilationTask(MemoryJavaFileObject file, Str opts.add(opt); } } - return getCompiler().getTask(null, new FileManagerWrapper(file, moduleOverride), null, opts, null, Arrays.asList(file)); + try (JavaFileManager fileManager = new FileManagerWrapper(file, moduleOverride)) { + CompilationTask task = getCompiler().getTask(null, fileManager, null, opts, null, Arrays.asList(file)); + if (!task.call()) { + throw new RuntimeException("Could not compile " + className + " with source code " + sourceCode); + } + + return file.getByteCode(); + } catch (IOException ioe) { + throw new RuntimeException(ioe); + } + } + + private static JavaCompiler getCompiler() { + return ToolProvider.getSystemJavaCompiler(); } } From a81b08872e3fe08bff70783611b9fafc8c791615 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 11 Oct 2023 08:27:16 +0000 Subject: [PATCH 224/341] 8232839: JDI AfterThreadDeathTest.java failed due to "FAILED: Did not get expected IllegalThreadStateException on a StepRequest.enable()" Backport-of: 84184f947342fd1adbe4e3f2230ce3de4ae6007e --- test/jdk/ProblemList.txt | 2 -- .../jdk/com/sun/jdi/AfterThreadDeathTest.java | 32 ++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index ba2113e797e34..9096e3b4b90b1 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -757,8 +757,6 @@ com/sun/jdi/NashornPopFrameTest.java 8225620 generic- com/sun/jdi/InvokeHangTest.java 8218463 linux-all -com/sun/jdi/AfterThreadDeathTest.java 8232839 linux-all - ############################################################################ # jdk_time diff --git a/test/jdk/com/sun/jdi/AfterThreadDeathTest.java b/test/jdk/com/sun/jdi/AfterThreadDeathTest.java index 61435a64a61cb..2790402144247 100644 --- a/test/jdk/com/sun/jdi/AfterThreadDeathTest.java +++ b/test/jdk/com/sun/jdi/AfterThreadDeathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,9 +51,9 @@ public static void main(String[] args){ public class AfterThreadDeathTest extends TestScaffold { ReferenceType targetClass; ThreadReference mainThread; - StepRequest stepRequest = null; EventRequestManager erm; - boolean mainIsDead; + volatile boolean mainIsDead = false; + volatile boolean gotExpectedThreadStart = false; AfterThreadDeathTest (String args[]) { super(args); @@ -68,20 +68,23 @@ public static void main(String[] args) throws Exception { public void threadStarted(ThreadStartEvent event) { println("Got ThreadStartEvent: " + event); - if (stepRequest != null) { - erm.deleteEventRequest(stepRequest); - stepRequest = null; - println("Deleted stepRequest"); + // We don't want to attempt the StepRequest.enable() until we recieve + // the ThreadStartEvent for the "DestroyJavaVM" thread. See JDK-8232839. + if (!event.thread().name().equals("DestroyJavaVM")) { + return; } + gotExpectedThreadStart = true; - if (mainIsDead) { + if (!mainIsDead) { + failure("FAILED: Got expected ThreadStartEvent before \"main\" ThreadDeathEvent"); + } else { // Here is the odd thing about this test; whatever thread this event // is for, we do a step on the mainThread. If the mainThread is // already dead, we should get the exception. Note that we don't // come here for the start of the main thread. - stepRequest = erm.createStepRequest(mainThread, - StepRequest.STEP_LINE, - StepRequest.STEP_OVER); + StepRequest stepRequest = erm.createStepRequest(mainThread, + StepRequest.STEP_LINE, + StepRequest.STEP_OVER); stepRequest.addCountFilter(1); stepRequest.setSuspendPolicy (EventRequest.SUSPEND_ALL); try { @@ -146,6 +149,13 @@ protected void runTests() throws Exception { */ listenUntilVMDisconnect(); + if (!gotExpectedThreadStart) { + failure("FAILED: never got expected ThreadStartEvent"); + } + if (!mainIsDead) { + failure("FAILED: never got ThreadDeathEvent for \"main\" thread"); + } + /* * deal with results of test * if anything has called failure("foo") testFailed will be true From baf717ffe375cf4088db48a371a8996fa61aa275 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 11 Oct 2023 08:32:42 +0000 Subject: [PATCH 225/341] 8309974: some JVMCI tests fail when VM options include -XX:+EnableJVMCI Backport-of: 8b4af46be4447a7bc3b58f4054488e8bc50ee111 --- .../jtreg/compiler/jvmci/events/JvmciShutdownEventTest.java | 4 ++-- .../hotspot/test/HotSpotConstantReflectionProviderTest.java | 2 +- test/hotspot/jtreg/compiler/jvmci/meta/StableFieldTest.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.java b/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.java index cdcde2d3ee3b2..0242f548cca58 100644 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.java @@ -35,9 +35,9 @@ * * @build compiler.jvmci.common.JVMCIHelpers * compiler.jvmci.events.JvmciShutdownEventListener - * @run driver jdk.test.lib.FileInstaller ./JvmciShutdownEventTest.config + * @run main/othervm jdk.test.lib.FileInstaller ./JvmciShutdownEventTest.config * ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator - * @run driver jdk.test.lib.helpers.ClassFileInstaller + * @run main/othervm jdk.test.lib.helpers.ClassFileInstaller * compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler * compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory * compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java index 637b4437bacac..59a4933d79341 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java @@ -31,7 +31,7 @@ * java.base/jdk.internal.misc * @library /test/lib /compiler/jvmci/jdk.vm.ci.hotspot.test/src * @build jdk.vm.ci.hotspot.test.DummyClass - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.vm.ci.hotspot.test.DummyClass + * @run main/othervm jdk.test.lib.helpers.ClassFileInstaller jdk.vm.ci.hotspot.test.DummyClass * @run testng/othervm/timeout=300 -Xbootclasspath/a:. * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI * -XX:-UseJVMCICompiler jdk.vm.ci.hotspot.test.HotSpotConstantReflectionProviderTest diff --git a/test/hotspot/jtreg/compiler/jvmci/meta/StableFieldTest.java b/test/hotspot/jtreg/compiler/jvmci/meta/StableFieldTest.java index cb3236b7cbf6a..51989a2cd065a 100644 --- a/test/hotspot/jtreg/compiler/jvmci/meta/StableFieldTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/meta/StableFieldTest.java @@ -33,7 +33,7 @@ * jdk.internal.vm.ci/jdk.vm.ci.runtime * * @compile StableFieldTest.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller compiler.jvmci.meta.StableFieldTest + * @run main/othervm jdk.test.lib.helpers.ClassFileInstaller compiler.jvmci.meta.StableFieldTest * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler -Xbootclasspath/a:. compiler.jvmci.meta.StableFieldTest */ From 179c60f99f384b7c28bf324f930aa2e886e0cc30 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 11 Oct 2023 08:35:19 +0000 Subject: [PATCH 226/341] 8301247: JPackage app-image exe launches multiple exe's in JDK 17+ Reviewed-by: lucy Backport-of: dcea9bf087c87548d9caa899c52e95d17478da22 --- .../native/applauncher/WinLauncher.cpp | 41 ++--- .../{msiwrapper => common}/Executor.cpp | 51 +++++- .../native/{msiwrapper => common}/Executor.h | 31 +++- .../jpackage/windows/Win8301247Test.java | 164 ++++++++++++++++++ 4 files changed, 258 insertions(+), 29 deletions(-) rename src/jdk.jpackage/windows/native/{msiwrapper => common}/Executor.cpp (71%) rename src/jdk.jpackage/windows/native/{msiwrapper => common}/Executor.h (76%) create mode 100644 test/jdk/tools/jpackage/windows/Win8301247Test.java diff --git a/src/jdk.jpackage/windows/native/applauncher/WinLauncher.cpp b/src/jdk.jpackage/windows/native/applauncher/WinLauncher.cpp index 74fe6c315e579..9a3cbaaaefb38 100644 --- a/src/jdk.jpackage/windows/native/applauncher/WinLauncher.cpp +++ b/src/jdk.jpackage/windows/native/applauncher/WinLauncher.cpp @@ -34,6 +34,7 @@ #include "Dll.h" #include "WinApp.h" #include "Toolbox.h" +#include "Executor.h" #include "FileUtils.h" #include "UniqueHandle.h" #include "ErrorHandling.h" @@ -157,29 +158,29 @@ void launchApp() { jvm = std::unique_ptr(); - STARTUPINFOW si; - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - - PROCESS_INFORMATION pi; - ZeroMemory(&pi, sizeof(pi)); - - if (!CreateProcessW(launcherPath.c_str(), GetCommandLineW(), - NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) { - JP_THROW(SysError(tstrings::any() << "CreateProcessW() failed", - CreateProcessW)); + UniqueHandle jobHandle(CreateJobObject(NULL, NULL)); + if (jobHandle.get() == NULL) { + JP_THROW(SysError(tstrings::any() << "CreateJobObject() failed", + CreateJobObject)); + } + JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobInfo = { }; + jobInfo.BasicLimitInformation.LimitFlags = + JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; + if (!SetInformationJobObject(jobHandle.get(), + JobObjectExtendedLimitInformation, &jobInfo, sizeof(jobInfo))) { + JP_THROW(SysError(tstrings::any() << + "SetInformationJobObject() failed", + SetInformationJobObject)); } - WaitForSingleObject(pi.hProcess, INFINITE); - - UniqueHandle childProcessHandle(pi.hProcess); - UniqueHandle childThreadHandle(pi.hThread); + Executor exec(launcherPath); + exec.visible(true).withJobObject(jobHandle.get()).suspended(true).inherit(true); + const auto args = SysInfo::getCommandArgs(); + std::for_each(args.begin(), args.end(), [&exec] (const tstring& arg) { + exec.arg(arg); + }); - DWORD exitCode; - if (!GetExitCodeProcess(pi.hProcess, &exitCode)) { - JP_THROW(SysError(tstrings::any() << "GetExitCodeProcess() failed", - GetExitCodeProcess)); - } + DWORD exitCode = static_cast(exec.execAndWaitForExit()); exit(exitCode); return; diff --git a/src/jdk.jpackage/windows/native/msiwrapper/Executor.cpp b/src/jdk.jpackage/windows/native/common/Executor.cpp similarity index 71% rename from src/jdk.jpackage/windows/native/msiwrapper/Executor.cpp rename to src/jdk.jpackage/windows/native/common/Executor.cpp index 5535d81b482c0..edb850afdbb25 100644 --- a/src/jdk.jpackage/windows/native/msiwrapper/Executor.cpp +++ b/src/jdk.jpackage/windows/native/common/Executor.cpp @@ -60,7 +60,15 @@ std::wstring Executor::args() const { int Executor::execAndWaitForExit() const { - UniqueHandle h = startProcess(); + UniqueHandle threadHandle; + UniqueHandle h = startProcess(&threadHandle); + + if (theSuspended) { + LOG_TRACE(tstrings::any() << "ResumeThread()"); + if (((DWORD)-1) == ResumeThread(threadHandle.get())) { + JP_THROW(SysError("ResumeThread() failed", ResumeThread)); + } + } const DWORD res = ::WaitForSingleObject(h.get(), INFINITE); if (WAIT_FAILED == res) { @@ -85,7 +93,7 @@ int Executor::execAndWaitForExit() const { } -UniqueHandle Executor::startProcess() const { +UniqueHandle Executor::startProcess(UniqueHandle* threadHandle) const { const std::wstring argsStr = args(); std::vector argsBuffer(argsStr.begin(), argsStr.end()); @@ -100,6 +108,10 @@ UniqueHandle Executor::startProcess() const { DWORD creationFlags = 0; + if (theSuspended) { + creationFlags |= CREATE_SUSPENDED; + } + if (!theVisible) { // For GUI applications. startupInfo.dwFlags |= STARTF_USESHOWWINDOW; @@ -110,10 +122,21 @@ UniqueHandle Executor::startProcess() const { } tstrings::any msg; - msg << "CreateProcess(" << appPath << ", " << argsStr << ")"; + msg << "CreateProcess"; + if (theSuspended) { + msg << "[suspended]"; + } + if (theVisible) { + msg << "[visible]"; + } + if (theInherit) { + msg << "[inherit]"; + } + msg << "(" << appPath << ", " << argsStr << ")"; - if (!CreateProcess(appPath.c_str(), argsBuffer.data(), NULL, NULL, FALSE, - creationFlags, NULL, NULL, &startupInfo, &processInfo)) { + if (!CreateProcess(appPath.c_str(), argsBuffer.data(), NULL, NULL, + theInherit ? TRUE : FALSE, creationFlags, NULL, NULL, + &startupInfo, &processInfo)) { msg << " failed"; JP_THROW(SysError(msg, CreateProcess)); } @@ -121,8 +144,22 @@ UniqueHandle Executor::startProcess() const { msg << " succeeded; PID=" << processInfo.dwProcessId; LOG_TRACE(msg); - // Close unneeded handles immediately. - UniqueHandle(processInfo.hThread); + if (threadHandle) { + *threadHandle = UniqueHandle(processInfo.hThread); + } else { + // Close unneeded handle immediately. + UniqueHandle(processInfo.hThread); + } + + if (jobHandle != NULL) { + LOG_TRACE(tstrings::any() << "AssignProcessToJobObject(PID=" + << processInfo.dwProcessId << ")"); + if (!AssignProcessToJobObject(jobHandle, processInfo.hProcess)) { + JP_THROW(SysError(tstrings::any() << + "AssignProcessToJobObject() failed", + AssignProcessToJobObject)); + } + } // Return process handle. return UniqueHandle(processInfo.hProcess); diff --git a/src/jdk.jpackage/windows/native/msiwrapper/Executor.h b/src/jdk.jpackage/windows/native/common/Executor.h similarity index 76% rename from src/jdk.jpackage/windows/native/msiwrapper/Executor.h rename to src/jdk.jpackage/windows/native/common/Executor.h index 72f33db57b506..a6edcbd4f76ba 100644 --- a/src/jdk.jpackage/windows/native/msiwrapper/Executor.h +++ b/src/jdk.jpackage/windows/native/common/Executor.h @@ -33,7 +33,7 @@ class Executor { public: explicit Executor(const std::wstring& appPath=std::wstring()) { - app(appPath).visible(false); + app(appPath).visible(false).suspended(false).withJobObject(NULL).inherit(false); } /** @@ -65,6 +65,30 @@ class Executor { return *this; } + /** + * Controls if the process should inherit handles. + */ + Executor& inherit(bool v) { + theInherit = v; + return *this; + } + + /** + * Controls if the process should be started suspended. + */ + Executor& suspended(bool v) { + theSuspended = v; + return *this; + } + + /** + * Use the given job object with started process. + */ + Executor& withJobObject(HANDLE v) { + jobHandle = v; + return *this; + } + /** * Starts application process and blocks waiting when the started * process terminates. @@ -74,9 +98,12 @@ class Executor { int execAndWaitForExit() const; private: - UniqueHandle startProcess() const; + UniqueHandle startProcess(UniqueHandle* threadHandle=0) const; bool theVisible; + bool theInherit; + bool theSuspended; + HANDLE jobHandle; tstring_array argsArray; std::wstring appPath; }; diff --git a/test/jdk/tools/jpackage/windows/Win8301247Test.java b/test/jdk/tools/jpackage/windows/Win8301247Test.java new file mode 100644 index 0000000000000..ed435bb9cc29e --- /dev/null +++ b/test/jdk/tools/jpackage/windows/Win8301247Test.java @@ -0,0 +1,164 @@ +/* + * 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 java.io.IOException; +import java.time.Duration; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Stream; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Executor; +import jdk.jpackage.test.HelloApp; +import jdk.jpackage.test.TKit; + +/** + * Test that terminating of the parent app launcher process automatically + * terminates child app launcher process. + */ + +/* + * @test + * @summary Test case for JDK-8301247 + * @library ../helpers + * @build jdk.jpackage.test.* + * @build Win8301247Test + * @requires (os.family == "windows") + * @modules jdk.jpackage/jdk.jpackage.internal + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=Win8301247Test + */ +public class Win8301247Test { + + @Test + public void test() throws IOException, InterruptedException { + JPackageCommand cmd = JPackageCommand.helloAppImage(); + + // Launch the app in a way it doesn't exit to let us trap app laucnher + // processes in the process list + cmd.addArguments("--java-options", "-Djpackage.test.noexit=true"); + cmd.executeAndAssertImageCreated(); + + if (!cmd.canRunLauncher("Not running the test")) { + return; + } + + ExecutorService exec = null; + try { + // Launch the app in a separate thread + exec = Executors.newSingleThreadExecutor(); + exec.execute(() -> { + HelloApp.executeLauncher(cmd); + }); + + // Wait a bit to let the app start + Thread.sleep(10000); + + // Get PID of the main app launcher process + final long pid = findMainAppLauncherPID(cmd, 2).get(); + + // Kill the main app launcher process + Executor.of("taskkill", "/F", "/PID", Long.toString(pid)). + dumpOutput(true).execute(); + + // Wait a bit and check if child app launcher process is still running (it must NOT) + Thread.sleep(5000); + + findMainAppLauncherPID(cmd, 0); + } finally { + if (exec != null) { + exec.shutdown(); + } + } + } + + private static Optional findMainAppLauncherPID(JPackageCommand cmd, + int expectedCount) { + // Get the list of PIDs and PPIDs of app launcher processes. + // wmic process where (name = "foo.exe") get ProcessID,ParentProcessID + List output = Executor.of("wmic", "process", "where", "(name", + "=", + "\"" + cmd.appLauncherPath().getFileName().toString() + "\"", + ")", "get", "ProcessID,ParentProcessID").dumpOutput(true). + saveOutput().executeAndGetOutput(); + + if (output.isEmpty()) { + throw new NoSuchElementException(); + } + String first = output.get(0); + + if (expectedCount == 0) { + TKit.assertEquals("No Instance(s) Available.", first. + trim(), "Check no app launcher processes found running"); + return Optional.empty(); + } + + String[] headers = Stream.of(first.split("\\s+", 2)).map( + String::trim).map(String::toLowerCase).toArray(String[]::new); + Pattern pattern; + if (headers[0].equals("parentprocessid") && headers[1].equals( + "processid")) { + pattern = Pattern.compile("^(?\\d+)\\s+(?\\d+)\\s+$"); + } else if (headers[1].equals("parentprocessid") && headers[0].equals( + "processid")) { + pattern = Pattern.compile("^(?\\d+)\\s+(?\\d+)\\s+$"); + } else { + throw new RuntimeException( + "Unrecognizable output of \'wmic process\' command"); + } + + List processes = output.stream().skip(1).map(line -> { + Matcher m = pattern.matcher(line); + long[] pids = null; + if (m.matches()) { + pids = new long[]{Long.parseLong(m.group("pid")), Long. + parseLong(m.group("ppid"))}; + } + return pids; + }).filter(Objects::nonNull).toList(); + + TKit.assertEquals(expectedCount, processes.size(), String.format( + "Check [%d] app launcher processes found running", expectedCount)); + + switch (expectedCount) { + case 2 -> { + if (processes.get(0)[0] == processes.get(1)[1]) { + return Optional.of(processes.get(0)[0]); + } else if (processes.get(1)[0] == processes.get(0)[1]) { + return Optional.of(processes.get(1)[0]); + } else { + throw new RuntimeException( + "App launcher processes unrelated"); + } + } + default -> + throw new IllegalArgumentException(); + } + } +} From 8853be60470f7f623734da0189a93b31aeee1df0 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 11 Oct 2023 08:40:13 +0000 Subject: [PATCH 227/341] 8316906: Clarify TLABWasteTargetPercent flag Backport-of: 77fac0f4c6692bcc06456d03a4329d9f8ddeeded --- src/hotspot/share/gc/shared/tlab_globals.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/shared/tlab_globals.hpp b/src/hotspot/share/gc/shared/tlab_globals.hpp index 8ecc5283642ba..0b047b4b9e8ac 100644 --- a/src/hotspot/share/gc/shared/tlab_globals.hpp +++ b/src/hotspot/share/gc/shared/tlab_globals.hpp @@ -70,10 +70,13 @@ "Allocation averaging weight") \ range(0, 100) \ \ + /* At GC all TLABs are retired, and each thread's active */ \ + /* TLAB is assumed to be half full on average. The */ \ + /* remaining space is waste, proportional to TLAB size. */ \ + product(uintx, TLABWasteTargetPercent, 1, \ + "Percentage of Eden that can be wasted (half-full TLABs at GC)") \ /* Limit the lower bound of this flag to 1 as it is used */ \ /* in a division expression. */ \ - product(uintx, TLABWasteTargetPercent, 1, \ - "Percentage of Eden that can be wasted") \ range(1, 100) \ \ product(uintx, TLABRefillWasteFraction, 64, \ From c8c1c6af2b8a66069c43a11e4d0e2e54ffe0bf5f Mon Sep 17 00:00:00 2001 From: Ilya Gavrilin Date: Wed, 11 Oct 2023 14:38:49 +0000 Subject: [PATCH 228/341] 8313779: RISC-V: use andn / orn in the MD5 instrinsic Backport-of: 4726960fcdc9489fb8f9c7e1a100828f1347c30c --- .../cpu/riscv/macroAssembler_riscv.cpp | 22 +++++++++++++++++++ .../cpu/riscv/macroAssembler_riscv.hpp | 4 ++++ src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 15 +++++-------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index a63de2ad5be76..83be79bcc7e56 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -1571,6 +1571,28 @@ void MacroAssembler::xorrw(Register Rd, Register Rs1, Register Rs2) { sign_extend(Rd, Rd, 32); } +// Rd = Rs1 & (~Rd2) +void MacroAssembler::andn(Register Rd, Register Rs1, Register Rs2) { + if (UseZbb) { + Assembler::andn(Rd, Rs1, Rs2); + return; + } + + notr(Rd, Rs2); + andr(Rd, Rs1, Rd); +} + +// Rd = Rs1 | (~Rd2) +void MacroAssembler::orn(Register Rd, Register Rs1, Register Rs2) { + if (UseZbb) { + Assembler::orn(Rd, Rs1, Rs2); + return; + } + + notr(Rd, Rs2); + orr(Rd, Rs1, Rd); +} + // Note: load_unsigned_short used to be called load_unsigned_word. int MacroAssembler::load_unsigned_short(Register dst, Address src) { int off = offset(); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 2eada49233bfe..3f26f4e95d581 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -736,6 +736,10 @@ class MacroAssembler: public Assembler { void orrw(Register Rd, Register Rs1, Register Rs2); void xorrw(Register Rd, Register Rs1, Register Rs2); + // logic with negate + void andn(Register Rd, Register Rs1, Register Rs2); + void orn(Register Rd, Register Rs1, Register Rs2); + // revb void revb_h_h(Register Rd, Register Rs, Register tmp = t0); // reverse bytes in halfword in lower 16 bits, sign-extend void revb_w_w(Register Rd, Register Rs, Register tmp1 = t0, Register tmp2 = t1); // reverse bytes in lower word, sign-extend diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 0416f6bca6d99..f59c8fb6a3dba 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -3733,7 +3733,7 @@ class StubGenerator: public StubCodeGenerator { // rtmp1 = rtmp1 + x + ac reg_cache.get_u32(rtmp2, k, rmask32); __ addw(rtmp1, rtmp1, rtmp2); - __ li(rtmp2, t); + __ mv(rtmp2, t); __ addw(rtmp1, rtmp1, rtmp2); // a += rtmp1 + x + ac @@ -3754,8 +3754,7 @@ class StubGenerator: public StubCodeGenerator { __ andr(rtmp1, b, c); // rtmp2 = (~b) & d - __ notr(rtmp2, b); - __ andr(rtmp2, rtmp2, d); + __ andn(rtmp2, d, b); // rtmp1 = (b & c) | ((~b) & d) __ orr(rtmp1, rtmp1, rtmp2); @@ -3773,9 +3772,8 @@ class StubGenerator: public StubCodeGenerator { // rtmp1 = b & d __ andr(rtmp1, b, d); - // rtmp2 = (c & (~d)) - __ notr(rtmp2, d); - __ andr(rtmp2, rtmp2, c); + // rtmp2 = c & (~d) + __ andn(rtmp2, c, d); // rtmp1 = (b & d) | (c & (~d)) __ orr(rtmp1, rtmp1, rtmp2); @@ -3805,8 +3803,7 @@ class StubGenerator: public StubCodeGenerator { int k, int s, int t, Register rtmp1, Register rtmp2, Register rmask32) { // rtmp1 = c ^ (b | (~d)) - __ notr(rtmp2, d); - __ orr(rtmp1, b, rtmp2); + __ orn(rtmp1, b, d); __ xorr(rtmp1, c, rtmp1); m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, @@ -3929,7 +3926,7 @@ class StubGenerator: public StubCodeGenerator { __ mv(ofs, ofs_arg); __ mv(limit, limit_arg); } - __ li(rmask32, MASK_32); + __ mv(rmask32, MASK_32); // to minimize the number of memory operations: // read the 4 state 4-byte values in pairs, with a single ld, From 5a007106696a0cf4022bb24ddf58390a2484ca2b Mon Sep 17 00:00:00 2001 From: Aleksei Voitylov Date: Wed, 21 Jun 2023 13:36:34 +0000 Subject: [PATCH 229/341] 8296581: Better system proxy support Reviewed-by: mbalao Backport-of: 111811e64245ae720a0617b7de0c52c60bb2bac1 --- src/java.base/windows/native/libnet/DefaultProxySelector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.base/windows/native/libnet/DefaultProxySelector.c b/src/java.base/windows/native/libnet/DefaultProxySelector.c index af21216178aed..51add618f47d4 100644 --- a/src/java.base/windows/native/libnet/DefaultProxySelector.c +++ b/src/java.base/windows/native/libnet/DefaultProxySelector.c @@ -243,7 +243,7 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env, if (use_auto_proxy) { WCHAR url[MAX_STR_LEN]; /* Create url for WinHttpGetProxyForUrl */ - _snwprintf(url, sizeof(url) - 1, L"%s://%s", lpProto, lpHost); + swprintf(url, MAX_STR_LEN, L"%s://%s", lpProto, lpHost); /* Get proxy for URL from Windows */ use_auto_proxy = WinHttpGetProxyForUrl(session, &url[0], &auto_proxy_options, &proxy_info); if (use_auto_proxy) { From 9b1d4bc1515d6de052497f4c1087ca7d22b2c410 Mon Sep 17 00:00:00 2001 From: Aleksei Voitylov Date: Fri, 23 Jun 2023 14:54:42 +0000 Subject: [PATCH 230/341] 8297856: Improve handling of Bidi characters Reviewed-by: mbalao Backport-of: 244b89fc786894cb8cca742f91875ebb98b603ff --- src/java.base/share/classes/jdk/internal/icu/text/BidiBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.base/share/classes/jdk/internal/icu/text/BidiBase.java b/src/java.base/share/classes/jdk/internal/icu/text/BidiBase.java index 1714c15143a6b..ae834f0658477 100644 --- a/src/java.base/share/classes/jdk/internal/icu/text/BidiBase.java +++ b/src/java.base/share/classes/jdk/internal/icu/text/BidiBase.java @@ -4595,7 +4595,7 @@ public static void reorderVisually(byte[] levels, objectStart + " is out of range 0 to " + (objects.length-1)); } - if (0 > count || objects.length < (objectStart+count)) { + if (0 > count || objects.length - count < objectStart) { throw new IllegalArgumentException("Value count " + count + " is less than zero, or objectStart + count" + " is beyond objects length " + objects.length); From 3a391232c8aa4fdf54d73ec725bdb4b4e9192bb5 Mon Sep 17 00:00:00 2001 From: Alexey Bakhtin Date: Wed, 6 Sep 2023 15:15:46 -0700 Subject: [PATCH 231/341] 8309966: Enhanced TLS connections Reviewed-by: mbalao Backport-of: d25ee81f56d67f2c51ba8b8c59f470c6f88ae47f --- .../security/cert/CertPathHelperImpl.java | 11 +- .../java/security/cert/X509CertSelector.java | 14 +-- .../provider/certpath/CertPathHelper.java | 14 +-- .../provider/certpath/ForwardBuilder.java | 65 ----------- .../provider/certpath/ForwardState.java | 50 -------- .../provider/certpath/SunCertPathBuilder.java | 109 ++++++++++++++---- 6 files changed, 90 insertions(+), 173 deletions(-) diff --git a/src/java.base/share/classes/java/security/cert/CertPathHelperImpl.java b/src/java.base/share/classes/java/security/cert/CertPathHelperImpl.java index bd6545a735753..3da6cb3dd4f07 100644 --- a/src/java.base/share/classes/java/security/cert/CertPathHelperImpl.java +++ b/src/java.base/share/classes/java/security/cert/CertPathHelperImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2020, 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 @@ -25,12 +25,10 @@ package java.security.cert; -import java.util.*; +import java.util.Date; import sun.security.provider.certpath.CertPathHelper; -import sun.security.x509.GeneralNameInterface; - /** * Helper class that allows the Sun CertPath provider to access * implementation dependent APIs in CertPath framework. @@ -55,11 +53,6 @@ static synchronized void initialize() { } } - protected void implSetPathToNames(X509CertSelector sel, - Set names) { - sel.setPathToNamesInternal(names); - } - protected void implSetDateAndTime(X509CRLSelector sel, Date date, long skew) { sel.setDateAndTime(date, skew); } diff --git a/src/java.base/share/classes/java/security/cert/X509CertSelector.java b/src/java.base/share/classes/java/security/cert/X509CertSelector.java index 356e53e21fa21..b838b3f51c2b7 100644 --- a/src/java.base/share/classes/java/security/cert/X509CertSelector.java +++ b/src/java.base/share/classes/java/security/cert/X509CertSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, 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 @@ -87,10 +87,6 @@ public class X509CertSelector implements CertSelector { private static final ObjectIdentifier ANY_EXTENDED_KEY_USAGE = ObjectIdentifier.of(KnownOIDs.anyExtendedKeyUsage); - static { - CertPathHelperImpl.initialize(); - } - private BigInteger serialNumber; private X500Principal issuer; private X500Principal subject; @@ -1159,14 +1155,6 @@ public void setPathToNames(Collection> names) throws IOException { } } - // called from CertPathHelper - void setPathToNamesInternal(Set names) { - // set names to non-null dummy value - // this breaks getPathToNames() - pathToNames = Collections.>emptySet(); - pathToGeneralNames = names; - } - /** * Adds a name to the pathToNames criterion. The {@code X509Certificate} * must not include name constraints that would prohibit building a diff --git a/src/java.base/share/classes/sun/security/provider/certpath/CertPathHelper.java b/src/java.base/share/classes/sun/security/provider/certpath/CertPathHelper.java index 7c02007422d9f..ebc2200f0e642 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/CertPathHelper.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/CertPathHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2020, 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 @@ -26,14 +26,10 @@ package sun.security.provider.certpath; import java.util.Date; -import java.util.Set; import java.security.cert.TrustAnchor; -import java.security.cert.X509CertSelector; import java.security.cert.X509CRLSelector; -import sun.security.x509.GeneralNameInterface; - /** * Helper class that allows access to JDK specific known-public methods in the * java.security.cert package. It relies on a subclass in the @@ -55,18 +51,10 @@ protected CertPathHelper() { // empty } - protected abstract void implSetPathToNames(X509CertSelector sel, - Set names); - protected abstract void implSetDateAndTime(X509CRLSelector sel, Date date, long skew); protected abstract boolean implIsJdkCA(TrustAnchor anchor); - static void setPathToNames(X509CertSelector sel, - Set names) { - instance.implSetPathToNames(sel, names); - } - public static void setDateAndTime(X509CRLSelector sel, Date date, long skew) { instance.implSetDateAndTime(sel, date, skew); } diff --git a/src/java.base/share/classes/sun/security/provider/certpath/ForwardBuilder.java b/src/java.base/share/classes/sun/security/provider/certpath/ForwardBuilder.java index f05a924440ba1..2fbeb8856eec9 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/ForwardBuilder.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/ForwardBuilder.java @@ -48,7 +48,6 @@ import sun.security.x509.AuthorityInfoAccessExtension; import sun.security.x509.AuthorityKeyIdentifierExtension; import static sun.security.x509.PKIXExtensions.*; -import sun.security.x509.SubjectAlternativeNameExtension; import sun.security.x509.X500Name; import sun.security.x509.X509CertImpl; @@ -258,14 +257,6 @@ private void getMatchingCACerts(ForwardState currentState, */ caSelector.setSubject(currentState.issuerDN); - /* - * Match on subjectNamesTraversed (both DNs and AltNames) - * (checks that current cert's name constraints permit it - * to certify all the DNs and AltNames that have been traversed) - */ - CertPathHelper.setPathToNames - (caSelector, currentState.subjectNamesTraversed); - /* * check the validity period */ @@ -704,19 +695,6 @@ void verifyCert(X509Certificate cert, State currentState, // Don't bother to verify untrusted certificate more. currState.untrustedChecker.check(cert, Collections.emptySet()); - /* - * Abort if we encounter the same certificate or a certificate with - * the same public key, subject DN, and subjectAltNames as a cert - * that is already in path. - */ - for (X509Certificate cpListCert : certPathList) { - if (repeated(cpListCert, cert)) { - throw new CertPathValidatorException( - "cert with repeated subject, public key, and " + - "subjectAltNames detected"); - } - } - /* check if trusted cert */ boolean isTrustedCert = trustedCerts.contains(cert); @@ -794,49 +772,6 @@ void verifyCert(X509Certificate cert, State currentState, } } - /** - * Return true if two certificates are equal or have the same subject, - * public key, and subject alternative names. - */ - private static boolean repeated( - X509Certificate currCert, X509Certificate nextCert) { - if (currCert.equals(nextCert)) { - return true; - } - return (currCert.getSubjectX500Principal().equals( - nextCert.getSubjectX500Principal()) && - currCert.getPublicKey().equals(nextCert.getPublicKey()) && - altNamesEqual(currCert, nextCert)); - } - - /** - * Return true if two certificates have the same subject alternative names. - */ - private static boolean altNamesEqual( - X509Certificate currCert, X509Certificate nextCert) { - X509CertImpl curr, next; - try { - curr = X509CertImpl.toImpl(currCert); - next = X509CertImpl.toImpl(nextCert); - } catch (CertificateException ce) { - return false; - } - - SubjectAlternativeNameExtension currAltNameExt = - curr.getSubjectAlternativeNameExtension(); - SubjectAlternativeNameExtension nextAltNameExt = - next.getSubjectAlternativeNameExtension(); - if (currAltNameExt != null) { - if (nextAltNameExt == null) { - return false; - } - return Arrays.equals(currAltNameExt.getExtensionValue(), - nextAltNameExt.getExtensionValue()); - } else { - return (nextAltNameExt == null); - } - } - /** * Verifies whether the input certificate completes the path. * First checks the cert against each trust anchor that was specified, diff --git a/src/java.base/share/classes/sun/security/provider/certpath/ForwardState.java b/src/java.base/share/classes/sun/security/provider/certpath/ForwardState.java index 9d7af9b169baa..9a5088babf21c 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/ForwardState.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/ForwardState.java @@ -31,17 +31,11 @@ import java.security.cert.PKIXCertPathChecker; import java.security.cert.X509Certificate; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.ListIterator; import javax.security.auth.x500.X500Principal; import sun.security.util.Debug; -import sun.security.x509.SubjectAlternativeNameExtension; -import sun.security.x509.GeneralNames; -import sun.security.x509.GeneralName; -import sun.security.x509.GeneralNameInterface; -import sun.security.x509.X500Name; import sun.security.x509.X509CertImpl; /** @@ -61,9 +55,6 @@ class ForwardState implements State { /* The last cert in the path */ X509CertImpl cert; - /* The set of subjectDNs and subjectAltNames of all certs in the path */ - HashSet subjectNamesTraversed; - /* * The number of intermediate CA certs which have been traversed so * far in the path @@ -73,7 +64,6 @@ class ForwardState implements State { /* Flag indicating if state is initial (path is just starting) */ private boolean init = true; - /* the untrusted certificates checker */ UntrustedChecker untrustedChecker; @@ -104,8 +94,6 @@ public String toString() { sb.append("\n issuerDN of last cert: ").append(issuerDN); sb.append("\n traversedCACerts: ").append(traversedCACerts); sb.append("\n init: ").append(String.valueOf(init)); - sb.append("\n subjectNamesTraversed: \n").append - (subjectNamesTraversed); sb.append("\n selfIssued: ").append (String.valueOf(selfIssued)); sb.append("]\n"); @@ -120,7 +108,6 @@ public String toString() { public void initState(List certPathCheckers) throws CertPathValidatorException { - subjectNamesTraversed = new HashSet(); traversedCACerts = 0; /* @@ -170,32 +157,6 @@ public void updateState(X509Certificate cert) } } - /* update subjectNamesTraversed only if this is the EE cert or if - this cert is not self-issued */ - if (init || !selfIssued) { - X500Principal subjName = cert.getSubjectX500Principal(); - subjectNamesTraversed.add(X500Name.asX500Name(subjName)); - - try { - SubjectAlternativeNameExtension subjAltNameExt - = icert.getSubjectAlternativeNameExtension(); - if (subjAltNameExt != null) { - GeneralNames gNames = subjAltNameExt.get( - SubjectAlternativeNameExtension.SUBJECT_NAME); - for (GeneralName gName : gNames.names()) { - subjectNamesTraversed.add(gName.getName()); - } - } - } catch (IOException e) { - if (debug != null) { - debug.println("ForwardState.updateState() unexpected " - + "exception"); - e.printStackTrace(); - } - throw new CertPathValidatorException(e); - } - } - init = false; } @@ -203,10 +164,6 @@ public void updateState(X509Certificate cert) * Clone current state. The state is cloned as each cert is * added to the path. This is necessary if backtracking occurs, * and a prior state needs to be restored. - * - * Note that this is a SMART clone. Not all fields are fully copied, - * because some of them will - * not have their contents modified by subsequent calls to updateState. */ @Override @SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly @@ -226,13 +183,6 @@ public Object clone() { } } - /* - * Shallow copy traversed names. There is no need to - * deep copy contents, since the elements of the Set - * are never modified by subsequent calls to updateState(). - */ - clonedState.subjectNamesTraversed - = (HashSet)subjectNamesTraversed.clone(); return clonedState; } catch (CloneNotSupportedException e) { throw new InternalError(e.toString(), e); diff --git a/src/java.base/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java b/src/java.base/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java index fd4eb9543e92e..fd5a01a923d15 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java @@ -33,6 +33,7 @@ import java.security.cert.CertPathValidatorException.BasicReason; import java.security.cert.PKIXReason; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -42,6 +43,7 @@ import sun.security.provider.certpath.PKIX.BuilderParams; import static sun.security.x509.PKIXExtensions.*; +import sun.security.x509.SubjectAlternativeNameExtension; import sun.security.x509.X509CertImpl; import sun.security.util.Debug; @@ -265,7 +267,7 @@ private void depthFirstSearchForward(X500Principal dN, */ Collection certs = builder.getMatchingCerts(currentState, buildParams.certStores()); - List vertices = addVertices(certs, adjList); + List vertices = addVertices(certs, adjList, cpList); if (debug != null) { debug.println("SunCertPathBuilder.depthFirstSearchForward(): " + "certs.size=" + vertices.size()); @@ -325,17 +327,32 @@ private void depthFirstSearchForward(X500Principal dN, * cert (which is signed by the trusted public key), but * don't add it yet to the cpList */ + PublicKey rootKey = cert.getPublicKey(); if (builder.trustAnchor.getTrustedCert() == null) { appendedCerts.add(0, cert); + rootKey = builder.trustAnchor.getCAPublicKey(); + if (debug != null) + debug.println( + "SunCertPathBuilder.depthFirstSearchForward " + + "using buildParams public key: " + + rootKey.toString()); } + TrustAnchor anchor = new TrustAnchor + (cert.getSubjectX500Principal(), rootKey, null); + // add the basic checker + List checkers = new ArrayList<>(); + BasicChecker basicChecker = new BasicChecker(anchor, + buildParams.date(), + buildParams.sigProvider(), + true); + checkers.add(basicChecker); Set initExpPolSet = Collections.singleton(PolicyChecker.ANY_POLICY); PolicyNodeImpl rootNode = new PolicyNodeImpl(null, PolicyChecker.ANY_POLICY, null, false, initExpPolSet, false); - List checkers = new ArrayList<>(); PolicyChecker policyChecker = new PolicyChecker(buildParams.initialPolicies(), appendedCerts.size(), @@ -346,28 +363,13 @@ private void depthFirstSearchForward(X500Principal dN, rootNode); checkers.add(policyChecker); + // add the constraints checker + checkers.add(new ConstraintsChecker(appendedCerts.size())); + // add the algorithm checker checkers.add(new AlgorithmChecker(builder.trustAnchor, buildParams.timestamp(), buildParams.variant())); - PublicKey rootKey = cert.getPublicKey(); - if (builder.trustAnchor.getTrustedCert() == null) { - rootKey = builder.trustAnchor.getCAPublicKey(); - if (debug != null) - debug.println( - "SunCertPathBuilder.depthFirstSearchForward " + - "using buildParams public key: " + - rootKey.toString()); - } - TrustAnchor anchor = new TrustAnchor - (cert.getSubjectX500Principal(), rootKey, null); - - // add the basic checker - BasicChecker basicChecker = new BasicChecker(anchor, - buildParams.date(), - buildParams.sigProvider(), - true); - checkers.add(basicChecker); buildParams.setCertPath(cf.generateCertPath(appendedCerts)); @@ -563,18 +565,79 @@ private void depthFirstSearchForward(X500Principal dN, * adjacency list. */ private static List addVertices(Collection certs, - List> adjList) + List> adjList, + List cpList) { List l = adjList.get(adjList.size() - 1); for (X509Certificate cert : certs) { - Vertex v = new Vertex(cert); - l.add(v); + boolean repeated = false; + for (X509Certificate cpListCert : cpList) { + /* + * Ignore if we encounter the same certificate or a + * certificate with the same public key, subject DN, and + * subjectAltNames as a cert that is already in path. + */ + if (repeated(cpListCert, cert)) { + if (debug != null) { + debug.println("cert with repeated subject, " + + "public key, and subjectAltNames detected"); + } + repeated = true; + break; + } + } + if (!repeated) { + l.add(new Vertex(cert)); + } } return l; } + /** + * Return true if two certificates are equal or have the same subject, + * public key, and subject alternative names. + */ + private static boolean repeated( + X509Certificate currCert, X509Certificate nextCert) { + if (currCert.equals(nextCert)) { + return true; + } + return (currCert.getSubjectX500Principal().equals( + nextCert.getSubjectX500Principal()) && + currCert.getPublicKey().equals(nextCert.getPublicKey()) && + altNamesEqual(currCert, nextCert)); + } + + /** + * Return true if two certificates have the same subject alternative names. + */ + private static boolean altNamesEqual( + X509Certificate currCert, X509Certificate nextCert) { + X509CertImpl curr, next; + try { + curr = X509CertImpl.toImpl(currCert); + next = X509CertImpl.toImpl(nextCert); + } catch (CertificateException ce) { + return false; + } + + SubjectAlternativeNameExtension currAltNameExt = + curr.getSubjectAlternativeNameExtension(); + SubjectAlternativeNameExtension nextAltNameExt = + next.getSubjectAlternativeNameExtension(); + if (currAltNameExt != null) { + if (nextAltNameExt == null) { + return false; + } + return Arrays.equals(currAltNameExt.getExtensionValue(), + nextAltNameExt.getExtensionValue()); + } else { + return (nextAltNameExt == null); + } + } + /** * Returns true if trust anchor certificate matches specified * certificate constraints. From 95f51289b6d6bda233bf853bca2fc0cfe30fdb04 Mon Sep 17 00:00:00 2001 From: Martin Balao Date: Tue, 8 Aug 2023 15:11:39 +0000 Subject: [PATCH 232/341] 8312248: Enhanced archival support redux Reviewed-by: andrew Backport-of: c2100a627d578901dffbbe631e5a6c9b88ca2209 --- src/hotspot/share/memory/metaspace.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/memory/metaspace.cpp b/src/hotspot/share/memory/metaspace.cpp index 3f29a72a86d75..0f81ebd4f53ab 100644 --- a/src/hotspot/share/memory/metaspace.cpp +++ b/src/hotspot/share/memory/metaspace.cpp @@ -634,11 +634,12 @@ ReservedSpace Metaspace::reserve_address_space_for_compressed_classes(size_t siz // (the OS already assigned it for something else), go to the next position, wrapping // around if necessary, until we exhaust all the items. os::init_random((int)os::javaTimeNanos()); - r = os::random(); + r = ABS(os::random() % len); log_info(metaspace)("Randomizing compressed class space: start from %d out of %d locations", r % len, len); } for (int i = 0; i < len; i++) { + assert((i + r) >= 0, "should never underflow because len is small integer"); address a = list.at((i + r) % len); ReservedSpace rs(size, Metaspace::reserve_alignment(), os::vm_page_size(), (char*)a); From 5147fd4b5047436b0b750ddd4d2a0b99a04b2494 Mon Sep 17 00:00:00 2001 From: Martin Balao Date: Wed, 23 Aug 2023 18:38:58 +0000 Subject: [PATCH 233/341] 8314649: Enhanced archival support redux Reviewed-by: andrew Backport-of: 1e16543a605a4be4f7430125aa488446a1c82d05 --- src/hotspot/share/memory/metaspace.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/memory/metaspace.cpp b/src/hotspot/share/memory/metaspace.cpp index 0f81ebd4f53ab..1e897615eafca 100644 --- a/src/hotspot/share/memory/metaspace.cpp +++ b/src/hotspot/share/memory/metaspace.cpp @@ -634,9 +634,10 @@ ReservedSpace Metaspace::reserve_address_space_for_compressed_classes(size_t siz // (the OS already assigned it for something else), go to the next position, wrapping // around if necessary, until we exhaust all the items. os::init_random((int)os::javaTimeNanos()); - r = ABS(os::random() % len); + r = ABS(os::random()) % len; + assert(r >= 0, "must be"); log_info(metaspace)("Randomizing compressed class space: start from %d out of %d locations", - r % len, len); + r, len); } for (int i = 0; i < len; i++) { assert((i + r) >= 0, "should never underflow because len is small integer"); From 32562861533268fc750f3a88e93ae20e8fc821b2 Mon Sep 17 00:00:00 2001 From: Yuri Nesterenko Date: Thu, 28 Apr 2022 02:48:20 +0000 Subject: [PATCH 234/341] 8284910: Buffer clean in PasswordCallback Reviewed-by: mbalao Backport-of: 89fd6d34f859d61d9cf5a1edf9419eee7c338390 --- .../auth/callback/PasswordCallback.java | 40 ++++++++++-- .../PasswordCallback/CheckCleanerBound.java | 61 +++++++++++++++++++ .../PasswordCallback/PasswordCleanup.java | 52 ++++++++++++++++ 3 files changed, 147 insertions(+), 6 deletions(-) create mode 100644 test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java create mode 100644 test/jdk/javax/security/auth/callback/PasswordCallback/PasswordCleanup.java diff --git a/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java b/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java index 36a54b7995847..69f57eb36f44e 100644 --- a/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java +++ b/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. * 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,11 @@ package javax.security.auth.callback; +import java.lang.ref.Cleaner; +import java.util.Arrays; + +import jdk.internal.ref.CleanerFactory; + /** *

Underlying security services instantiate and pass a * {@code PasswordCallback} to the {@code handle} @@ -38,16 +43,20 @@ public class PasswordCallback implements Callback, java.io.Serializable { @java.io.Serial private static final long serialVersionUID = 2267422647454909926L; + private transient Cleaner.Cleanable cleanable; + /** * @serial * @since 1.4 */ - private String prompt; + private final String prompt; + /** * @serial * @since 1.4 */ - private boolean echoOn; + private final boolean echoOn; + /** * @serial * @since 1.4 @@ -106,7 +115,19 @@ public boolean isEchoOn() { * @see #getPassword */ public void setPassword(char[] password) { + // Cleanup the last buffered password copy. + if (cleanable != null) { + cleanable.clean(); + cleanable = null; + } + + // Set the retrieved password. this.inputPassword = (password == null ? null : password.clone()); + + if (this.inputPassword != null) { + cleanable = CleanerFactory.cleaner().register( + this, cleanerFor(inputPassword)); + } } /** @@ -126,9 +147,16 @@ public char[] getPassword() { * Clear the retrieved password. */ public void clearPassword() { - if (inputPassword != null) { - for (int i = 0; i < inputPassword.length; i++) - inputPassword[i] = ' '; + // Cleanup the last retrieved password copy. + if (cleanable != null) { + cleanable.clean(); + cleanable = null; } } + + private static Runnable cleanerFor(char[] password) { + return () -> { + Arrays.fill(password, ' '); + }; + } } diff --git a/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java b/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java new file mode 100644 index 0000000000000..cc995893f65ed --- /dev/null +++ b/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * 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 8284910 + * @summary Check that the cleaner is not bound to the PasswordCallback object + */ + +import javax.security.auth.callback.PasswordCallback; +import java.util.WeakHashMap; + +public final class CheckCleanerBound { + private final static WeakHashMap weakHashMap = + new WeakHashMap<>(); + + public static void main(String[] args) throws Exception { + // Create an object + PasswordCallback passwordCallback = + new PasswordCallback("Password: ", false); + passwordCallback.setPassword("ThisIsAPassword".toCharArray()); + + weakHashMap.put(passwordCallback, null); + passwordCallback = null; + + // Check if the PasswordCallback object could be collected. + // Wait to trigger the cleanup. + for (int i = 0; i < 10 && weakHashMap.size() != 0; i++) { + System.gc(); + } + + // Check if the object has been collected. The collection will not + // happen if the cleaner implementation in PasswordCallback is bound + // to the PasswordCallback object. + if (weakHashMap.size() > 0) { + throw new RuntimeException( + "PasswordCallback object is not released"); + } + } +} + diff --git a/test/jdk/javax/security/auth/callback/PasswordCallback/PasswordCleanup.java b/test/jdk/javax/security/auth/callback/PasswordCallback/PasswordCleanup.java new file mode 100644 index 0000000000000..ea8b1d1c14596 --- /dev/null +++ b/test/jdk/javax/security/auth/callback/PasswordCallback/PasswordCleanup.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. + * 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 8284910 + * @summary Check that PasswordCallback.clearPassword() clears the password + */ + +import javax.security.auth.callback.PasswordCallback; +import java.util.Arrays; + +public final class PasswordCleanup { + public static void main(String[] args) throws Exception { + // Create an object + PasswordCallback passwordCallback = + new PasswordCallback("Password: ", false); + passwordCallback.setPassword("ThisIsAPassword".toCharArray()); + char[] originPassword = passwordCallback.getPassword(); + + // Use password clear method. + passwordCallback.clearPassword(); + + // Check that the password is cleared. + char[] clearedPassword = passwordCallback.getPassword(); + if (Arrays.equals(originPassword, clearedPassword)) { + throw new RuntimeException( + "PasswordCallback.clearPassword() does not clear passwords"); + } + } +} + From 87c0d671e711ec9eefd6b18be00a0b26ffaab9a7 Mon Sep 17 00:00:00 2001 From: Yuri Nesterenko Date: Fri, 18 Aug 2023 15:01:58 +0300 Subject: [PATCH 235/341] 8286503: Enhance security classes Backport-of: 7f5e120a631ffda3e6d5efc03bae572b21877b69 --- .../com/sun/crypto/provider/DESKey.java | 27 +++++++-- .../com/sun/crypto/provider/DESedeKey.java | 29 ++++++++-- .../com/sun/crypto/provider/DHPrivateKey.java | 34 +++++++++-- .../com/sun/crypto/provider/DHPublicKey.java | 34 +++++++++-- .../com/sun/crypto/provider/PBEKey.java | 39 ++++++++++--- .../sun/crypto/provider/PBKDF2KeyImpl.java | 44 +++++++++++--- .../provider/TlsMasterSecretGenerator.java | 27 +++++++-- .../classes/java/security/CodeSigner.java | 15 +++-- .../javax/crypto/spec/SecretKeySpec.java | 27 ++++++++- .../auth/callback/ChoiceCallback.java | 53 ++++++++++++++--- .../auth/callback/ConfirmationCallback.java | 47 ++++++++++----- .../auth/callback/PasswordCallback.java | 29 +++++++++- .../security/provider/DSAPublicKeyImpl.java | 27 +++++++-- .../sun/security/provider/PolicyFile.java | 31 +++++++++- .../sun/security/provider/SecureRandom.java | 54 +++++++++++++++--- .../provider/certpath/X509CertPath.java | 23 ++++++-- .../security/rsa/RSAPrivateCrtKeyImpl.java | 22 ++++++- .../sun/security/rsa/RSAPrivateKeyImpl.java | 29 ++++++++-- .../sun/security/rsa/RSAPublicKeyImpl.java | 24 +++++++- .../sun/security/x509/X509CertImpl.java | 30 ++++++---- .../classes/sun/security/pkcs11/Token.java | 24 +++++++- .../sun/security/ec/ECPrivateKeyImpl.java | 21 ++++++- .../sun/security/ec/ECPublicKeyImpl.java | 26 ++++++++- .../sun/security/ec/XDHPrivateKeyImpl.java | 18 +++++- .../sun/security/ec/XDHPublicKeyImpl.java | 25 +++++++- .../security/ec/ed/EdDSAPrivateKeyImpl.java | 21 ++++++- .../security/ec/ed/EdDSAPublicKeyImpl.java | 25 +++++++- .../sun/security/mscapi/CPrivateKey.java | 26 ++++++++- .../sun/security/mscapi/CPublicKey.java | 31 +++++++++- .../com/sun/security/auth/LdapPrincipal.java | 33 ++++++++++- .../sun/security/auth/NTDomainPrincipal.java | 30 ++++++++-- .../classes/com/sun/security/auth/NTSid.java | 38 ++++++++++-- .../sun/security/auth/NTUserPrincipal.java | 31 ++++++++-- .../auth/UnixNumericGroupPrincipal.java | 32 +++++++++-- .../auth/UnixNumericUserPrincipal.java | 30 ++++++++-- .../com/sun/security/auth/UnixPrincipal.java | 30 ++++++++-- .../com/sun/security/auth/UserPrincipal.java | 22 ++++++- test/jdk/java/security/KeyRep/RSA.pre.1.5.key | Bin 1803 -> 0 bytes test/jdk/java/security/KeyRep/SerialOld.java | 14 +++-- 39 files changed, 955 insertions(+), 167 deletions(-) delete mode 100644 test/jdk/java/security/KeyRep/RSA.pre.1.5.key diff --git a/src/java.base/share/classes/com/sun/crypto/provider/DESKey.java b/src/java.base/share/classes/com/sun/crypto/provider/DESKey.java index 21e7247e87b90..daea2659f6353 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/DESKey.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/DESKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package com.sun.crypto.provider; +import java.io.IOException; +import java.io.InvalidObjectException; import java.lang.ref.Reference; import java.security.MessageDigest; import java.security.KeyRep; @@ -44,7 +46,7 @@ final class DESKey implements SecretKey { @java.io.Serial - static final long serialVersionUID = 7724971015953279128L; + private static final long serialVersionUID = 7724971015953279128L; private byte[] key; @@ -113,7 +115,7 @@ public int hashCode() { for (int i = 1; i < this.key.length; i++) { retval += this.key[i] * i; } - return(retval ^= "des".hashCode()); + return(retval ^ "des".hashCode()); } public boolean equals(Object obj) { @@ -134,15 +136,28 @@ public boolean equals(Object obj) { } /** - * readObject is called to restore the state of this key from - * a stream. + * Restores the state of this object from the stream. + * + * @param s the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded */ @java.io.Serial private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException + throws IOException, ClassNotFoundException { s.defaultReadObject(); + if ((key == null) || (key.length != DESKeySpec.DES_KEY_LEN)) { + throw new InvalidObjectException("Wrong key size"); + } key = key.clone(); + + DESKeyGenerator.setParityBit(key, 0); + + // Use the cleaner to zero the key when no longer referenced + final byte[] k = key; + CleanerFactory.cleaner().register(this, + () -> java.util.Arrays.fill(k, (byte)0x00)); } /** diff --git a/src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java b/src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java index 2847f30501793..031495f27a441 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/DESedeKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package com.sun.crypto.provider; +import java.io.IOException; +import java.io.InvalidObjectException; import java.lang.ref.Reference; import java.security.MessageDigest; import java.security.KeyRep; @@ -44,7 +46,7 @@ final class DESedeKey implements SecretKey { @java.io.Serial - static final long serialVersionUID = 2463986565756745178L; + private static final long serialVersionUID = 2463986565756745178L; private byte[] key; @@ -112,7 +114,7 @@ public int hashCode() { for (int i = 1; i < this.key.length; i++) { retval += this.key[i] * i; } - return(retval ^= "desede".hashCode()); + return(retval ^ "desede".hashCode()); } public boolean equals(Object obj) { @@ -134,15 +136,30 @@ public boolean equals(Object obj) { } /** - * readObject is called to restore the state of this key from - * a stream. + * Restores the state of this object from the stream. + * + * @param s the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded */ @java.io.Serial private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException + throws IOException, ClassNotFoundException { s.defaultReadObject(); + if ((key == null) || (key.length != DESedeKeySpec.DES_EDE_KEY_LEN)) { + throw new InvalidObjectException("Wrong key size"); + } key = key.clone(); + + DESKeyGenerator.setParityBit(key, 0); + DESKeyGenerator.setParityBit(key, 8); + DESKeyGenerator.setParityBit(key, 16); + + // Use the cleaner to zero the key when no longer referenced + final byte[] k = key; + CleanerFactory.cleaner().register(this, + () -> java.util.Arrays.fill(k, (byte)0x00)); } /** diff --git a/src/java.base/share/classes/com/sun/crypto/provider/DHPrivateKey.java b/src/java.base/share/classes/com/sun/crypto/provider/DHPrivateKey.java index dcce2c4efa5a5..b584ac415f75d 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/DHPrivateKey.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/DHPrivateKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,8 +41,6 @@ * algorithm. * * @author Jan Luehe - * - * * @see DHPublicKey * @see java.security.KeyAgreement */ @@ -50,7 +48,7 @@ final class DHPrivateKey implements PrivateKey, javax.crypto.interfaces.DHPrivateKey, Serializable { @java.io.Serial - static final long serialVersionUID = 7565477590005668886L; + private static final long serialVersionUID = 7565477590005668886L; // only supported version of PKCS#8 PrivateKeyInfo private static final BigInteger PKCS8_VERSION = BigInteger.ZERO; @@ -65,10 +63,10 @@ final class DHPrivateKey implements PrivateKey, private byte[] encodedKey; // the prime modulus - private BigInteger p; + private final BigInteger p; // the base generator - private BigInteger g; + private final BigInteger g; // the private-value length (optional) private int l; @@ -336,4 +334,28 @@ private Object writeReplace() throws java.io.ObjectStreamException { getFormat(), encodedKey); } + + /** + * Restores the state of this object from the stream. + *

+ * JDK 1.5+ objects use KeyReps instead. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if ((key == null) || (key.length == 0)) { + throw new InvalidObjectException("key not deserializable"); + } + this.key = key.clone(); + if ((encodedKey == null) || (encodedKey.length == 0)) { + throw new InvalidObjectException( + "encoded key not deserializable"); + } + this.encodedKey = encodedKey.clone(); + } } diff --git a/src/java.base/share/classes/com/sun/crypto/provider/DHPublicKey.java b/src/java.base/share/classes/com/sun/crypto/provider/DHPublicKey.java index bf33173ff2ebb..622aa2a512d98 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/DHPublicKey.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/DHPublicKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,8 +40,6 @@ * A public key in X.509 format for the Diffie-Hellman key agreement algorithm. * * @author Jan Luehe - * - * * @see DHPrivateKey * @see javax.crypto.KeyAgreement */ @@ -49,7 +47,7 @@ final class DHPublicKey implements PublicKey, javax.crypto.interfaces.DHPublicKey, Serializable { @java.io.Serial - static final long serialVersionUID = 7647557958927458271L; + private static final long serialVersionUID = 7647557958927458271L; // the public key private BigInteger y; @@ -61,10 +59,10 @@ final class DHPublicKey implements PublicKey, private byte[] encodedKey; // the prime modulus - private BigInteger p; + private final BigInteger p; // the base generator - private BigInteger g; + private final BigInteger g; // the private-value length (optional) private int l; @@ -324,4 +322,28 @@ private Object writeReplace() throws java.io.ObjectStreamException { getFormat(), getEncoded()); } + + /** + * Restores the state of this object from the stream. + *

+ * JDK 1.5+ objects use KeyReps instead. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if ((key == null) || (key.length == 0)) { + throw new InvalidObjectException("key not deserializable"); + } + this.key = key.clone(); + if ((encodedKey == null) || (encodedKey.length == 0)) { + throw new InvalidObjectException( + "encoded key not deserializable"); + } + this.encodedKey = encodedKey.clone(); + } } diff --git a/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java b/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java index 15c9c1f3d59c9..67efe74f8587a 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package com.sun.crypto.provider; +import java.io.IOException; +import java.io.InvalidObjectException; import java.lang.ref.Reference; import java.security.MessageDigest; import java.security.KeyRep; @@ -45,11 +47,11 @@ final class PBEKey implements SecretKey { @java.io.Serial - static final long serialVersionUID = -2234768909660948176L; + private static final long serialVersionUID = -2234768909660948176L; private byte[] key; - private String type; + private final String type; /** * Creates a PBE key from a given PBE key specification. @@ -110,7 +112,7 @@ public int hashCode() { for (int i = 1; i < this.key.length; i++) { retval += this.key[i] * i; } - return(retval ^= getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode()); + return(retval ^ getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode()); } public boolean equals(Object obj) { @@ -144,15 +146,38 @@ public void destroy() { } /** - * readObject is called to restore the state of this key from - * a stream. + * Restores the state of this object from the stream. + * + * @param s the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded */ @java.io.Serial private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException + throws IOException, ClassNotFoundException { s.defaultReadObject(); + if (key == null) { + throw new InvalidObjectException( + "PBEKey couldn't be deserialized"); + } key = key.clone(); + + // Accept "\0" to signify "zero-length password with no terminator". + if (!(key.length == 1 && key[0] == 0)) { + for (int i = 0; i < key.length; i++) { + if ((key[i] < '\u0020') || (key[i] > '\u007E')) { + throw new InvalidObjectException( + "PBEKey had non-ASCII chars"); + } + } + } + + // Use the cleaner to zero the key when no longer referenced + final byte[] k = this.key; + CleanerFactory.cleaner().register(this, + () -> Arrays.fill(k, (byte) 0x00)); + } diff --git a/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java b/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java index 1588385d6531b..29e331b944a4e 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java @@ -25,7 +25,7 @@ package com.sun.crypto.provider; -import java.io.ObjectStreamException; +import java.io.*; import java.lang.ref.Reference; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -57,14 +57,14 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey { @java.io.Serial - static final long serialVersionUID = -2234868909660948157L; + private static final long serialVersionUID = -2234868909660948157L; - private char[] passwd; - private byte[] salt; - private int iterCount; + private final char[] passwd; + private final byte[] salt; + private final int iterCount; private byte[] key; - private Mac prf; + private final Mac prf; private static byte[] getPasswordBytes(char[] passwd) { CharBuffer cb = CharBuffer.wrap(passwd); @@ -146,13 +146,14 @@ private static byte[] deriveKey(final Mac prf, final byte[] password, int intR = keyLength - (intL - 1)*hlen; // residue byte[] ui = new byte[hlen]; byte[] ti = new byte[hlen]; + String algName = prf.getAlgorithm(); // SecretKeySpec cannot be used, since password can be empty here. SecretKey macKey = new SecretKey() { @java.io.Serial private static final long serialVersionUID = 7874493593505141603L; @Override public String getAlgorithm() { - return prf.getAlgorithm(); + return algName; } @Override public String getFormat() { @@ -165,18 +166,27 @@ public byte[] getEncoded() { @Override public int hashCode() { return Arrays.hashCode(password) * 41 + - prf.getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode(); + algName.toLowerCase(Locale.ENGLISH).hashCode(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (this.getClass() != obj.getClass()) return false; SecretKey sk = (SecretKey)obj; - return prf.getAlgorithm().equalsIgnoreCase( + return algName.equalsIgnoreCase( sk.getAlgorithm()) && MessageDigest.isEqual(password, sk.getEncoded()); } + // This derived key can't be deserialized. + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "PBKDF2KeyImpl SecretKeys are not " + + "directly deserializable"); + } }; + prf.init(macKey); byte[] ibytes = new byte[4]; @@ -290,4 +300,20 @@ private Object writeReplace() throws ObjectStreamException { return new KeyRep(KeyRep.Type.SECRET, getAlgorithm(), getFormat(), key); } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this class is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "PBKDF2KeyImpl keys are not directly deserializable"); + } } diff --git a/src/java.base/share/classes/com/sun/crypto/provider/TlsMasterSecretGenerator.java b/src/java.base/share/classes/com/sun/crypto/provider/TlsMasterSecretGenerator.java index c533506b05fc0..09ab8143bdd1e 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/TlsMasterSecretGenerator.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/TlsMasterSecretGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, 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 @@ -25,6 +25,9 @@ package com.sun.crypto.provider; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.*; import java.security.spec.AlgorithmParameterSpec; import java.util.Arrays; @@ -62,11 +65,11 @@ protected void engineInit(SecureRandom random) { @SuppressWarnings("deprecation") protected void engineInit(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException { - if (params instanceof TlsMasterSecretParameterSpec == false) { + if (!(params instanceof TlsMasterSecretParameterSpec)) { throw new InvalidAlgorithmParameterException(MSG); } this.spec = (TlsMasterSecretParameterSpec)params; - if ("RAW".equals(spec.getPremasterSecret().getFormat()) == false) { + if (!"RAW".equals(spec.getPremasterSecret().getFormat())) { throw new InvalidAlgorithmParameterException( "Key format must be RAW"); } @@ -193,6 +196,22 @@ public byte[] getEncoded() { return key.clone(); } - } + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if ((key == null) || (key.length == 0)) { + throw new InvalidObjectException("TlsMasterSecretKey is null"); + } + key = key.clone(); + } + } } diff --git a/src/java.base/share/classes/java/security/CodeSigner.java b/src/java.base/share/classes/java/security/CodeSigner.java index 99748210d79cc..5306d17c8dbcb 100644 --- a/src/java.base/share/classes/java/security/CodeSigner.java +++ b/src/java.base/share/classes/java/security/CodeSigner.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 @@ -156,9 +156,9 @@ public boolean equals(Object obj) { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("("); - sb.append("Signer: " + signerCertPath.getCertificates().get(0)); + sb.append("Signer: ").append(signerCertPath.getCertificates().get(0)); if (timestamp != null) { - sb.append("timestamp: " + timestamp); + sb.append("timestamp: ").append(timestamp); } sb.append(")"); return sb.toString(); @@ -174,8 +174,11 @@ public String toString() { */ @java.io.Serial private void readObject(ObjectInputStream ois) - throws IOException, ClassNotFoundException { - ois.defaultReadObject(); - myhash = -1; + throws IOException, ClassNotFoundException { + ois.defaultReadObject(); + if (signerCertPath == null) { + throw new InvalidObjectException("signerCertPath is null"); + } + myhash = -1; } } diff --git a/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java b/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java index 41d4acab7483c..e691fa9fb6671 100644 --- a/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,9 @@ import jdk.internal.access.JavaxCryptoSpecAccess; import jdk.internal.access.SharedSecrets; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.MessageDigest; import java.security.spec.KeySpec; import java.util.Arrays; @@ -259,4 +262,26 @@ public boolean equals(Object obj) { void clear() { Arrays.fill(key, (byte)0); } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + + if (key == null || algorithm == null) { + throw new InvalidObjectException("Missing argument"); + } + + this.key = key.clone(); + if (key.length == 0) { + throw new InvalidObjectException("Invalid key length"); + } + } } diff --git a/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java b/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java index f708df1c812bb..973d11b1c7e88 100644 --- a/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java +++ b/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, 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 @@ -25,6 +25,10 @@ package javax.security.auth.callback; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; + /** *

Underlying security services instantiate and pass a * {@code ChoiceCallback} to the {@code handle} @@ -48,7 +52,7 @@ public class ChoiceCallback implements Callback, java.io.Serializable { * @serial the list of choices * @since 1.4 */ - private final String[] choices; + private String[] choices; /** * @serial the choice to be used as the default choice * @since 1.4 @@ -72,7 +76,6 @@ public class ChoiceCallback implements Callback, java.io.Serializable { * a list of choices, a default choice, and a boolean specifying * whether or not multiple selections from the list of choices are allowed. * - * * @param prompt the prompt used to describe the list of choices. * * @param choices the list of choices. The array is cloned to protect @@ -105,15 +108,15 @@ public ChoiceCallback(String prompt, String[] choices, defaultChoice < 0 || defaultChoice >= choices.length) throw new IllegalArgumentException(); + this.prompt = prompt; + this.defaultChoice = defaultChoice; + this.multipleSelectionsAllowed = multipleSelectionsAllowed; + + this.choices = choices.clone(); for (int i = 0; i < choices.length; i++) { if (choices[i] == null || choices[i].isEmpty()) throw new IllegalArgumentException(); } - - this.prompt = prompt; - this.choices = choices.clone(); - this.defaultChoice = defaultChoice; - this.multipleSelectionsAllowed = multipleSelectionsAllowed; } /** @@ -197,4 +200,38 @@ public void setSelectedIndexes(int[] selections) { public int[] getSelectedIndexes() { return selections == null ? null : selections.clone(); } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + + if ((prompt == null) || prompt.isEmpty() || + (choices == null) || (choices.length == 0) || + (defaultChoice < 0) || (defaultChoice >= choices.length)) { + throw new InvalidObjectException( + "Missing/invalid prompt/choices"); + } + + choices = choices.clone(); + for (int i = 0; i < choices.length; i++) { + if ((choices[i] == null) || choices[i].isEmpty()) + throw new InvalidObjectException("Null/empty choices"); + } + + if (selections != null) { + selections = selections.clone(); + if (!multipleSelectionsAllowed && (selections.length != 1)) { + throw new InvalidObjectException( + "Multiple selections not allowed"); + } + } + } } diff --git a/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java b/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java index 926a3d889e2d5..437ce7041a7d7 100644 --- a/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java +++ b/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, 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 @@ -25,6 +25,9 @@ package javax.security.auth.callback; +import java.io.IOException; +import java.io.ObjectInputStream; + /** *

Underlying security services instantiate and pass a * {@code ConfirmationCallback} to the {@code handle} @@ -147,7 +150,7 @@ public class ConfirmationCallback implements Callback, java.io.Serializable { * @serial * @since 1.4 */ - private final String[] options; + private String[] options; /** * @serial * @since 1.4 @@ -252,16 +255,16 @@ public ConfirmationCallback(int messageType, defaultOption < 0 || defaultOption >= options.length) throw new IllegalArgumentException(); - for (int i = 0; i < options.length; i++) { - if (options[i] == null || options[i].isEmpty()) - throw new IllegalArgumentException(); - } - this.prompt = null; this.messageType = messageType; this.optionType = UNSPECIFIED_OPTION; - this.options = options.clone(); this.defaultOption = defaultOption; + + this.options = options.clone(); + for (int i = 0; i < options.length; i++) { + if (options[i] == null || options[i].isEmpty()) + throw new IllegalArgumentException(); + } } /** @@ -372,16 +375,16 @@ public ConfirmationCallback(String prompt, int messageType, defaultOption < 0 || defaultOption >= options.length) throw new IllegalArgumentException(); - for (int i = 0; i < options.length; i++) { - if (options[i] == null || options[i].isEmpty()) - throw new IllegalArgumentException(); - } - this.prompt = prompt; this.messageType = messageType; this.optionType = UNSPECIFIED_OPTION; - this.options = options.clone(); this.defaultOption = defaultOption; + + this.options = options.clone(); + for (int i = 0; i < options.length; i++) { + if (options[i] == null || options[i].isEmpty()) + throw new IllegalArgumentException(); + } } /** @@ -487,4 +490,20 @@ public void setSelectedIndex(int selection) { public int getSelectedIndex() { return selection; } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if (options != null) { + options = options.clone(); + } + } } diff --git a/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java b/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java index 69f57eb36f44e..5e0f6bb5fde32 100644 --- a/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java +++ b/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,10 @@ import jdk.internal.ref.CleanerFactory; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; + /** *

Underlying security services instantiate and pass a * {@code PasswordCallback} to the {@code handle} @@ -159,4 +163,27 @@ private static Runnable cleanerFor(char[] password) { Arrays.fill(password, ' '); }; } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + + if (prompt == null || prompt.isEmpty()) { + throw new InvalidObjectException("Missing prompt"); + } + + if (inputPassword != null) { + inputPassword = inputPassword.clone(); + cleanable = CleanerFactory.cleaner().register( + this, cleanerFor(inputPassword)); + } + } } diff --git a/src/java.base/share/classes/sun/security/provider/DSAPublicKeyImpl.java b/src/java.base/share/classes/sun/security/provider/DSAPublicKeyImpl.java index 2c402ef28637f..ca84d202c1464 100644 --- a/src/java.base/share/classes/sun/security/provider/DSAPublicKeyImpl.java +++ b/src/java.base/share/classes/sun/security/provider/DSAPublicKeyImpl.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 @@ -25,17 +25,20 @@ package sun.security.provider; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.math.BigInteger; import java.security.KeyRep; import java.security.InvalidKeyException; /** * An X.509 public key for the Digital Signature Algorithm. - * + *

* The difference between DSAPublicKeyImpl and DSAPublicKey is that * DSAPublicKeyImpl calls writeReplace with KeyRep, and DSAPublicKey * calls writeObject. - * + *

* See the comments in DSAKeyFactory, 4532506, and 6232513. * */ @@ -72,10 +75,26 @@ public DSAPublicKeyImpl(byte[] encoded) throws InvalidKeyException { } @java.io.Serial - protected Object writeReplace() throws java.io.ObjectStreamException { + private Object writeReplace() throws java.io.ObjectStreamException { return new KeyRep(KeyRep.Type.PUBLIC, getAlgorithm(), getFormat(), getEncoded()); } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "DSAPublicKeyImpl keys are not directly deserializable"); + } } diff --git a/src/java.base/share/classes/sun/security/provider/PolicyFile.java b/src/java.base/share/classes/sun/security/provider/PolicyFile.java index a9be95dd5983f..3dfc12ac377ad 100644 --- a/src/java.base/share/classes/sun/security/provider/PolicyFile.java +++ b/src/java.base/share/classes/sun/security/provider/PolicyFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2097,8 +2097,17 @@ public SelfPermission(String type, String name, String actions, this.actions.equals(that.actions))) return false; - if (this.certs.length != that.certs.length) + if ((this.certs == null) && (that.certs == null)) { + return true; + } + + if ((this.certs == null) || (that.certs == null)) { + return false; + } + + if (this.certs.length != that.certs.length) { return false; + } int i,j; boolean match; @@ -2168,7 +2177,7 @@ public String getSelfActions() { } public Certificate[] getCerts() { - return certs; + return (certs == null ? null : certs.clone()); } /** @@ -2181,6 +2190,22 @@ public Certificate[] getCerts() { @Override public String toString() { return "(SelfPermission " + type + " " + name + " " + actions + ")"; } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if (certs != null) { + this.certs = certs.clone(); + } + } } /** diff --git a/src/java.base/share/classes/sun/security/provider/SecureRandom.java b/src/java.base/share/classes/sun/security/provider/SecureRandom.java index 0ccaa81289cb9..c5e901322fb52 100644 --- a/src/java.base/share/classes/sun/security/provider/SecureRandom.java +++ b/src/java.base/share/classes/sun/security/provider/SecureRandom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, 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 sun.security.provider; import java.io.IOException; +import java.io.InvalidObjectException; import java.security.MessageDigest; import java.security.SecureRandomSpi; import java.security.NoSuchAlgorithmException; @@ -193,7 +194,7 @@ private static void updateState(byte[] state, byte[] output) { /** * This static object will be seeded by SeedGenerator, and used * to seed future instances of SHA1PRNG SecureRandoms. - * + *

* Bloch, Effective Java Second Edition: Item 71 */ private static class SeederHolder { @@ -268,18 +269,24 @@ public synchronized void engineNextBytes(byte[] result) { } /* - * readObject is called to restore the state of the random object from - * a stream. We have to create a new instance of MessageDigest, because + * This method is called to restore the state of the random object from + * a stream. + *

+ * We have to create a new instance of {@code MessageDigest}, because * it is not included in the stream (it is marked "transient"). - * - * Note that the engineNextBytes() method invoked on the restored random - * object will yield the exact same (random) bytes as the original. + *

+ * Note that the {@code engineNextBytes()} method invoked on the restored + * random object will yield the exact same (random) bytes as the original. * If you do not want this behaviour, you should re-seed the restored - * random object, using engineSetSeed(). + * random object, using {@code engineSetSeed()}. + * + * @param s the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded */ @java.io.Serial private void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException { + throws IOException, ClassNotFoundException { s.defaultReadObject (); @@ -298,5 +305,34 @@ private void readObject(java.io.ObjectInputStream s) "internal error: SHA-1 not available.", exc); } } + + // Various consistency checks + if ((remainder == null) && (remCount > 0)) { + throw new InvalidObjectException( + "Remainder indicated, but no data available"); + } + + // Not yet allocated state + if (state == null) { + if (remainder == null) { + return; + } else { + throw new InvalidObjectException( + "Inconsistent buffer allocations"); + } + } + + // Sanity check on sizes/pointer + if ((state.length != DIGEST_SIZE) || + ((remainder != null) && (remainder.length != DIGEST_SIZE)) || + (remCount < 0 ) || (remCount >= DIGEST_SIZE)) { + throw new InvalidObjectException( + "Inconsistent buffer sizes/state"); + } + + state = state.clone(); + if (remainder != null) { + remainder = remainder.clone(); + } } } diff --git a/src/java.base/share/classes/sun/security/provider/certpath/X509CertPath.java b/src/java.base/share/classes/sun/security/provider/certpath/X509CertPath.java index e8e1e82be8b9f..d692f592e8da3 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/X509CertPath.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/X509CertPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, 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,10 +25,7 @@ package sun.security.provider.certpath; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.security.cert.CertificateEncodingException; import java.security.cert.Certificate; import java.security.cert.CertificateException; @@ -396,4 +393,20 @@ public Iterator getEncodings() { public List getCertificates() { return certs; } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "X509CertPaths are not directly deserializable"); + } } diff --git a/src/java.base/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java b/src/java.base/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java index fbc9fda05faf2..4c5af4b953c39 100644 --- a/src/java.base/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java +++ b/src/java.base/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.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 @@ -26,6 +26,8 @@ package sun.security.rsa; import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.math.BigInteger; import java.security.*; @@ -43,7 +45,7 @@ * RSA private key implementation for "RSA", "RSASSA-PSS" algorithms in CRT form. * For non-CRT private keys, see RSAPrivateKeyImpl. We need separate classes * to ensure correct behavior in instanceof checks, etc. - * + *

* Note: RSA keys must be at least 512 bits long * * @see RSAPrivateKeyImpl @@ -361,4 +363,20 @@ private void parseKeyBits() throws InvalidKeyException { throw new InvalidKeyException("Invalid RSA private key", e); } } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "RSAPrivateCrtKeyImpl keys are not directly deserializable"); + } } diff --git a/src/java.base/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java b/src/java.base/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java index 699a5db636752..5a645c7e88744 100644 --- a/src/java.base/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java +++ b/src/java.base/share/classes/sun/security/rsa/RSAPrivateKeyImpl.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 @@ -26,6 +26,8 @@ package sun.security.rsa; import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.math.BigInteger; import java.security.*; @@ -40,10 +42,11 @@ /** * RSA private key implementation for "RSA", "RSASSA-PSS" algorithms in non-CRT - * form (modulus, private exponent only). For CRT private keys, see - * RSAPrivateCrtKeyImpl. We need separate classes to ensure correct behavior - * in instanceof checks, etc. - * + * form (modulus, private exponent only). + *

+ * For CRT private keys, see RSAPrivateCrtKeyImpl. We need separate classes + * to ensure correct behavior in instanceof checks, etc. + *

* Note: RSA keys must be at least 512 bits long * * @see RSAPrivateCrtKeyImpl @@ -147,4 +150,20 @@ public String toString() { + " bits" + "\n params: " + keyParams + "\n modulus: " + n + "\n private exponent: " + d; } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "RSAPrivateKeyImpl keys are not directly deserializable"); + } } diff --git a/src/java.base/share/classes/sun/security/rsa/RSAPublicKeyImpl.java b/src/java.base/share/classes/sun/security/rsa/RSAPublicKeyImpl.java index d5002c1500026..61522cad2fe25 100644 --- a/src/java.base/share/classes/sun/security/rsa/RSAPublicKeyImpl.java +++ b/src/java.base/share/classes/sun/security/rsa/RSAPublicKeyImpl.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 @@ -26,6 +26,8 @@ package sun.security.rsa; import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.math.BigInteger; import java.security.*; @@ -39,7 +41,7 @@ /** * RSA public key implementation for "RSA", "RSASSA-PSS" algorithms. - * + *

* Note: RSA keys must be at least 512 bits long * * @see RSAPrivateCrtKeyImpl @@ -238,10 +240,26 @@ public String toString() { } @java.io.Serial - protected Object writeReplace() throws java.io.ObjectStreamException { + private Object writeReplace() throws java.io.ObjectStreamException { return new KeyRep(KeyRep.Type.PUBLIC, getAlgorithm(), getFormat(), getEncoded()); } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "RSAPublicKeyImpl keys are not directly deserializable"); + } } diff --git a/src/java.base/share/classes/sun/security/x509/X509CertImpl.java b/src/java.base/share/classes/sun/security/x509/X509CertImpl.java index 254016d6a28ee..5a296bf9494f5 100644 --- a/src/java.base/share/classes/sun/security/x509/X509CertImpl.java +++ b/src/java.base/share/classes/sun/security/x509/X509CertImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2021, 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 @@ -25,13 +25,7 @@ package sun.security.x509; -import java.io.BufferedReader; -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; +import java.io.*; import java.math.BigInteger; import java.security.*; import java.security.cert.*; @@ -629,7 +623,7 @@ public void checkValidity(Date date) /** * Return the requested attribute from the certificate. - * + *

* Note that the X509CertInfo is not cloned for performance reasons. * Callers must ensure that they do not modify it. All other * attributes are cloned. @@ -1534,7 +1528,7 @@ private static Collection> makeAltNames(GeneralNames names) { for (GeneralName gname : names.names()) { GeneralNameInterface name = gname.getName(); List nameEntry = new ArrayList<>(2); - nameEntry.add(Integer.valueOf(name.getType())); + nameEntry.add(name.getType()); switch (name.getType()) { case GeneralNameInterface.NAME_RFC822: nameEntry.add(((RFC822Name) name).getName()); @@ -1972,4 +1966,20 @@ public static String getFingerprint(String algorithm, } } } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "X509CertImpls are not directly deserializable"); + } } diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Token.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Token.java index 9858a5faedfae..1f94fe3e18a0d 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Token.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Token.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 @@ -419,13 +419,30 @@ private synchronized byte[] getTokenId() { private static final List> serializedTokens = new ArrayList>(); + @java.io.Serial private Object writeReplace() throws ObjectStreamException { if (isValid() == false) { - throw new NotSerializableException("Token has been removed"); + throw new InvalidObjectException("Token has been removed"); } return new TokenRep(this); } + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "Tokens are not directly deserializable"); + } + // serialized representation of a token // tokens can only be de-serialized within the same VM invocation // and if the token has not been removed in the meantime @@ -439,6 +456,7 @@ private static class TokenRep implements Serializable { tokenId = token.getTokenId(); } + @java.io.Serial private Object readResolve() throws ObjectStreamException { for (Reference tokenRef : serializedTokens) { Token token = tokenRef.get(); @@ -448,7 +466,7 @@ private Object readResolve() throws ObjectStreamException { } } } - throw new NotSerializableException("Could not find token"); + throw new InvalidObjectException("Could not find token"); } } diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECPrivateKeyImpl.java b/src/jdk.crypto.ec/share/classes/sun/security/ec/ECPrivateKeyImpl.java index bf940a731005c..88cde0c55dfe7 100644 --- a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECPrivateKeyImpl.java +++ b/src/jdk.crypto.ec/share/classes/sun/security/ec/ECPrivateKeyImpl.java @@ -26,6 +26,8 @@ package sun.security.ec; import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.math.BigInteger; import java.security.*; @@ -39,7 +41,7 @@ /** * Key implementation for EC private keys. - * + *

* ASN.1 syntax for EC private keys from SEC 1 v1.5 (draft): * *

@@ -62,6 +64,7 @@
  */
 public final class ECPrivateKeyImpl extends PKCS8Key implements ECPrivateKey {
 
+    @java.io.Serial
     private static final long serialVersionUID = 88695385615075129L;
 
     private BigInteger s;       // private value
@@ -205,4 +208,20 @@ private void parseKeyBits() throws InvalidKeyException {
             throw new InvalidKeyException("Invalid EC private key", e);
         }
     }
+
+    /**
+     * Restores the state of this object from the stream.
+     * 

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "ECPrivateKeyImpl keys are not directly deserializable"); + } } diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECPublicKeyImpl.java b/src/jdk.crypto.ec/share/classes/sun/security/ec/ECPublicKeyImpl.java index bc403026c4d2b..c88fa450734bf 100644 --- a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECPublicKeyImpl.java +++ b/src/jdk.crypto.ec/share/classes/sun/security/ec/ECPublicKeyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,8 @@ import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.*; import java.security.interfaces.*; import java.security.spec.*; @@ -44,6 +46,7 @@ */ public final class ECPublicKeyImpl extends X509Key implements ECPublicKey { + @java.io.Serial private static final long serialVersionUID = -2462037275160462289L; private ECPoint w; @@ -122,10 +125,27 @@ public String toString() { + "\n parameters: " + params; } - protected Object writeReplace() throws java.io.ObjectStreamException { + @java.io.Serial + private Object writeReplace() throws java.io.ObjectStreamException { return new KeyRep(KeyRep.Type.PUBLIC, getAlgorithm(), getFormat(), getEncoded()); } -} + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "ECPublicKeyImpl keys are not directly deserializable"); + } +} \ No newline at end of file diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPrivateKeyImpl.java b/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPrivateKeyImpl.java index beeda53006fec..4764110b117a2 100644 --- a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPrivateKeyImpl.java +++ b/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPrivateKeyImpl.java @@ -37,6 +37,7 @@ public final class XDHPrivateKeyImpl extends PKCS8Key implements XECPrivateKey { + @java.io.Serial private static final long serialVersionUID = 1L; private final AlgorithmParameterSpec paramSpec; @@ -101,5 +102,20 @@ public AlgorithmParameterSpec getParams() { public Optional getScalar() { return Optional.of(getK()); } -} + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "XDHPrivateKeyImpl keys are not directly deserializable"); + } +} diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPublicKeyImpl.java b/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPublicKeyImpl.java index 0b9b6d93c0421..a2a21d2d98b34 100644 --- a/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPublicKeyImpl.java +++ b/src/jdk.crypto.ec/share/classes/sun/security/ec/XDHPublicKeyImpl.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,9 @@ package sun.security.ec; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.math.BigInteger; import java.security.InvalidKeyException; import java.security.KeyRep; @@ -40,6 +43,7 @@ public final class XDHPublicKeyImpl extends X509Key implements XECPublicKey { + @java.io.Serial private static final long serialVersionUID = 1L; private final BigInteger u; @@ -107,7 +111,8 @@ public String getAlgorithm() { return "XDH"; } - protected Object writeReplace() throws java.io.ObjectStreamException { + @java.io.Serial + private Object writeReplace() throws java.io.ObjectStreamException { return new KeyRep(KeyRep.Type.PUBLIC, getAlgorithm(), getFormat(), @@ -130,5 +135,21 @@ private static void reverse(byte [] arr) { j--; } } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "XDHPublicKeyImpl keys are not directly deserializable"); + } } diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPrivateKeyImpl.java b/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPrivateKeyImpl.java index a4f769e55f67e..8f7cbd2b3f9ff 100644 --- a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPrivateKeyImpl.java +++ b/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPrivateKeyImpl.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 @@ -26,6 +26,8 @@ package sun.security.ec.ed; import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.InvalidKeyException; import java.security.ProviderException; import java.security.interfaces.EdECPrivateKey; @@ -39,6 +41,7 @@ public final class EdDSAPrivateKeyImpl extends PKCS8Key implements EdECPrivateKey { + @java.io.Serial private static final long serialVersionUID = 1L; private final NamedParameterSpec paramSpec; @@ -104,4 +107,20 @@ public NamedParameterSpec getParams() { public Optional getBytes() { return Optional.of(getKey()); } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "EdDSAPrivateKeyImpl keys are not directly deserializable"); + } } diff --git a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPublicKeyImpl.java b/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPublicKeyImpl.java index ebc51e9a82112..8a6407fb146d1 100644 --- a/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPublicKeyImpl.java +++ b/src/jdk.crypto.ec/share/classes/sun/security/ec/ed/EdDSAPublicKeyImpl.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,9 @@ package sun.security.ec.ed; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.math.BigInteger; import java.security.InvalidKeyException; import java.security.KeyRep; @@ -39,6 +42,7 @@ public final class EdDSAPublicKeyImpl extends X509Key implements EdECPublicKey { + @java.io.Serial private static final long serialVersionUID = 1L; private final EdECPoint point; @@ -106,7 +110,8 @@ public String getAlgorithm() { return "EdDSA"; } - protected Object writeReplace() throws java.io.ObjectStreamException { + @java.io.Serial + private Object writeReplace() throws java.io.ObjectStreamException { return new KeyRep(KeyRep.Type.PUBLIC, getAlgorithm(), getFormat(), getEncoded()); } @@ -127,4 +132,20 @@ private static void reverse(byte [] arr) { j--; } } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "EdDSAPublicKeyImpl keys are not directly deserializable"); + } } diff --git a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPrivateKey.java b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPrivateKey.java index a65ea4458901a..91a7775b8bdd3 100644 --- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPrivateKey.java +++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPrivateKey.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 @@ -25,6 +25,9 @@ package sun.security.mscapi; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.PrivateKey; /** @@ -35,6 +38,7 @@ */ class CPrivateKey extends CKey implements PrivateKey { + @java.io.Serial private static final long serialVersionUID = 8113152807912338063L; private CPrivateKey(String alg, NativeHandles handles, int keyLength) { @@ -72,8 +76,26 @@ public String toString() { } // This class is not serializable + @java.io.Serial private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - throw new java.io.NotSerializableException(); + throw new java.io.InvalidObjectException( + "CPrivateKeys are not serializable"); + } + + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "CPrivateKeys are not deserializable"); } } diff --git a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPublicKey.java b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPublicKey.java index 35e25e90647c6..efbd74c5bb846 100644 --- a/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPublicKey.java +++ b/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPublicKey.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 @@ -25,6 +25,9 @@ package sun.security.mscapi; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.math.BigInteger; import java.security.AlgorithmParameters; import java.security.KeyException; @@ -50,6 +53,7 @@ */ public abstract class CPublicKey extends CKey implements PublicKey { + @java.io.Serial private static final long serialVersionUID = -2289561342425825391L; protected byte[] encoding = null; @@ -57,6 +61,8 @@ public abstract class CPublicKey extends CKey implements PublicKey { public static class CECPublicKey extends CPublicKey implements ECPublicKey { private ECPoint w = null; + + @java.io.Serial private static final long serialVersionUID = 12L; CECPublicKey(NativeHandles handles, int keyLength) { @@ -108,7 +114,7 @@ public ECParameterSpec getParams() { public String toString() { StringBuffer sb = new StringBuffer(); - sb.append(algorithm + "PublicKey [size=").append(keyLength) + sb.append(algorithm).append("PublicKey [size=").append(keyLength) .append("]\n ECPoint: ").append(getW()) .append("\n params: ").append(getParams()); return sb.toString(); @@ -119,6 +125,8 @@ public static class CRSAPublicKey extends CPublicKey implements RSAPublicKey { private BigInteger modulus = null; private BigInteger exponent = null; + + @java.io.Serial private static final long serialVersionUID = 12L; CRSAPublicKey(NativeHandles handles, int keyLength) { @@ -127,7 +135,7 @@ public static class CRSAPublicKey extends CPublicKey implements RSAPublicKey { public String toString() { StringBuffer sb = new StringBuffer(); - sb.append(algorithm + "PublicKey [size=").append(keyLength) + sb.append(algorithm).append("PublicKey [size=").append(keyLength) .append(" bits, type="); if (handles.hCryptKey != 0) { sb.append(getKeyType(handles.hCryptKey)) @@ -214,6 +222,7 @@ public String getFormat() { return "X.509"; } + @java.io.Serial protected Object writeReplace() throws java.io.ObjectStreamException { return new KeyRep(KeyRep.Type.PUBLIC, getAlgorithm(), @@ -221,6 +230,22 @@ protected Object writeReplace() throws java.io.ObjectStreamException { getEncoded()); } + /** + * Restores the state of this object from the stream. + *

+ * Deserialization of this object is not supported. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + throw new InvalidObjectException( + "CPublicKeys are not deserializable"); + } + // Returns the CAPI or CNG representation of the key. native byte[] getPublicKeyBlob(long hCryptProv, long hCryptKey) throws KeyException; diff --git a/src/jdk.security.auth/share/classes/com/sun/security/auth/LdapPrincipal.java b/src/jdk.security.auth/share/classes/com/sun/security/auth/LdapPrincipal.java index 6af39422d5ffb..9ab71de3cfdc4 100644 --- a/src/jdk.security.auth/share/classes/com/sun/security/auth/LdapPrincipal.java +++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/LdapPrincipal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,9 @@ package com.sun.security.auth; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.Principal; import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; @@ -47,6 +50,7 @@ */ public final class LdapPrincipal implements Principal, java.io.Serializable { + @java.io.Serial private static final long serialVersionUID = 6820120005580754861L; /** @@ -135,4 +139,31 @@ public String toString() { private LdapName getLdapName(String name) throws InvalidNameException { return new LdapName(name); } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if ((name == null) || (nameString == null)) { + throw new InvalidObjectException( + "null name/nameString is illegal"); + } + try { + if (!name.equals(getLdapName(nameString))) { + throw new InvalidObjectException("Inconsistent names"); + } + } catch (InvalidNameException e) { + InvalidObjectException nse = new InvalidObjectException( + "Invalid Name"); + nse.initCause(e); + throw nse; + } + } } diff --git a/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java b/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java index ed9c2eff568e5..771df0f60973c 100644 --- a/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java +++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/NTDomainPrincipal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, 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 @@ -25,6 +25,9 @@ package com.sun.security.auth; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.Principal; /** @@ -47,6 +50,7 @@ */ public class NTDomainPrincipal implements Principal, java.io.Serializable { + @java.io.Serial private static final long serialVersionUID = -4408637351440771220L; /** @@ -120,9 +124,7 @@ public boolean equals(Object o) { return false; NTDomainPrincipal that = (NTDomainPrincipal)o; - if (name.equals(that.getName())) - return true; - return false; + return name.equals(that.getName()); } /** @@ -133,4 +135,24 @@ public boolean equals(Object o) { public int hashCode() { return this.getName().hashCode(); } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if (name == null) { + java.text.MessageFormat form = new java.text.MessageFormat + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); + Object[] source = {"name"}; + throw new InvalidObjectException(form.format(source)); + } + } } diff --git a/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java b/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java index b5e2dc7d6d62e..1bf37f6461d05 100644 --- a/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java +++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/NTSid.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, 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 @@ -25,6 +25,9 @@ package com.sun.security.auth; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.Principal; /** @@ -49,6 +52,7 @@ */ public class NTSid implements Principal, java.io.Serializable { + @java.io.Serial private static final long serialVersionUID = 4412290580770249885L; /** @@ -80,7 +84,7 @@ public NTSid (String stringSid) { (sun.security.util.ResourcesMgr.getAuthResourceString ("Invalid.NTSid.value")); } - sid = new String(stringSid); + sid = stringSid; } /** @@ -128,10 +132,7 @@ public boolean equals(Object o) { return false; NTSid that = (NTSid)o; - if (sid.equals(that.sid)) { - return true; - } - return false; + return sid.equals(that.sid); } /** @@ -142,4 +143,29 @@ public boolean equals(Object o) { public int hashCode() { return sid.hashCode(); } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if (sid == null) { + java.text.MessageFormat form = new java.text.MessageFormat + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); + Object[] source = {"stringSid"}; + throw new InvalidObjectException(form.format(source)); + } + if (sid.length() == 0) { + throw new InvalidObjectException + (sun.security.util.ResourcesMgr.getAuthResourceString + ("Invalid.NTSid.value")); + } + } } diff --git a/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java b/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java index a7c2ce97cd077..d4b9dcef3a9f0 100644 --- a/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java +++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/NTUserPrincipal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, 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 @@ -25,6 +25,9 @@ package com.sun.security.auth; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.Principal; /** @@ -43,6 +46,7 @@ */ public class NTUserPrincipal implements Principal, java.io.Serializable { + @java.io.Serial private static final long serialVersionUID = -8737649811939033735L; /** @@ -114,9 +118,7 @@ public boolean equals(Object o) { return false; NTUserPrincipal that = (NTUserPrincipal)o; - if (name.equals(that.getName())) - return true; - return false; + return name.equals(that.getName()); } /** @@ -127,4 +129,25 @@ public boolean equals(Object o) { public int hashCode() { return this.getName().hashCode(); } + + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if (name == null) { + java.text.MessageFormat form = new java.text.MessageFormat + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); + Object[] source = {"name"}; + throw new InvalidObjectException(form.format(source)); + } + } } diff --git a/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java b/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java index 2780f56ff3b60..e8c12e2918dc2 100644 --- a/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java +++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, 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,9 @@ package com.sun.security.auth; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.Principal; import java.util.Objects; @@ -46,6 +49,7 @@ public class UnixNumericGroupPrincipal implements Principal, java.io.Serializable { + @java.io.Serial private static final long serialVersionUID = 3941535899328403223L; /** @@ -184,10 +188,8 @@ public boolean equals(Object o) { return false; UnixNumericGroupPrincipal that = (UnixNumericGroupPrincipal)o; - if (this.getName().equals(that.getName()) && - this.isPrimaryGroup() == that.isPrimaryGroup()) - return true; - return false; + return this.getName().equals(that.getName()) && + this.isPrimaryGroup() == that.isPrimaryGroup(); } /** @@ -198,4 +200,24 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(name, isPrimaryGroup()); } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if (name == null) { + java.text.MessageFormat form = new java.text.MessageFormat + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); + Object[] source = {"name"}; + throw new InvalidObjectException(form.format(source)); + } + } } diff --git a/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java b/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java index 30a1e9ca81d56..2a48332eeddc2 100644 --- a/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java +++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, 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,9 @@ package com.sun.security.auth; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.Principal; /** @@ -44,6 +47,7 @@ public class UnixNumericUserPrincipal implements Principal, java.io.Serializable { + @java.io.Serial private static final long serialVersionUID = -4329764253802397821L; /** @@ -146,9 +150,7 @@ public boolean equals(Object o) { return false; UnixNumericUserPrincipal that = (UnixNumericUserPrincipal)o; - if (this.getName().equals(that.getName())) - return true; - return false; + return this.getName().equals(that.getName()); } /** @@ -159,4 +161,24 @@ public boolean equals(Object o) { public int hashCode() { return name.hashCode(); } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if (name == null) { + java.text.MessageFormat form = new java.text.MessageFormat + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); + Object[] source = {"name"}; + throw new InvalidObjectException(form.format(source)); + } + } } diff --git a/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java b/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java index fde93a62a537d..b8a80f75aad97 100644 --- a/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java +++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/UnixPrincipal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, 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,9 @@ package com.sun.security.auth; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.Principal; /** @@ -43,6 +46,7 @@ */ public class UnixPrincipal implements Principal, java.io.Serializable { + @java.io.Serial private static final long serialVersionUID = -2951667807323493631L; /** @@ -115,9 +119,7 @@ public boolean equals(Object o) { return false; UnixPrincipal that = (UnixPrincipal)o; - if (this.getName().equals(that.getName())) - return true; - return false; + return this.getName().equals(that.getName()); } /** @@ -128,4 +130,24 @@ public boolean equals(Object o) { public int hashCode() { return name.hashCode(); } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if (name == null) { + java.text.MessageFormat form = new java.text.MessageFormat + (sun.security.util.ResourcesMgr.getAuthResourceString + ("invalid.null.input.value")); + Object[] source = {"name"}; + throw new InvalidObjectException(form.format(source)); + } + } } diff --git a/src/jdk.security.auth/share/classes/com/sun/security/auth/UserPrincipal.java b/src/jdk.security.auth/share/classes/com/sun/security/auth/UserPrincipal.java index 04b133e400488..03f382d82f748 100644 --- a/src/jdk.security.auth/share/classes/com/sun/security/auth/UserPrincipal.java +++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/UserPrincipal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, 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 @@ -25,6 +25,9 @@ package com.sun.security.auth; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.security.Principal; /** @@ -44,6 +47,7 @@ */ public final class UserPrincipal implements Principal, java.io.Serializable { + @java.io.Serial private static final long serialVersionUID = 892106070870210969L; /** @@ -109,4 +113,20 @@ public String getName() { public String toString() { return name; } + + /** + * Restores the state of this object from the stream. + * + * @param stream the {@code ObjectInputStream} from which data is read + * @throws IOException if an I/O error occurs + * @throws ClassNotFoundException if a serialized class cannot be loaded + */ + @java.io.Serial + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + if (name == null) { + throw new InvalidObjectException("null name is illegal"); + } + } } diff --git a/test/jdk/java/security/KeyRep/RSA.pre.1.5.key b/test/jdk/java/security/KeyRep/RSA.pre.1.5.key deleted file mode 100644 index 0c15a06c9cd1422eeb75657122a85db1111a1485..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1803 zcmZ4UmVvdnh(REy#I0-cTtjYPQX=x=4Vi1#a6H7Amoifus^GZ_FQ;UGs zGo}x?&x^Zy-moU9WY8S*=Lr)lZoBf_KY1%pc z^DSY`F;m?Ocug7l4qg1^75AoV`PY8`@CULxJy$8%|Ls^akx7x^tJHI$TV2WAFBM|u zS}d27tgt$HOtH}0Ejilwl8LwHbfA*u^Ed4JJ@-Nm%X_cCDgS=ld6Blw_nZJvlb-*w z$0dwQGl5F_zuB4W-?(e8wSV@uh?(m9H-FAv_~S!=Fnd`eN6nA<^-Kz00a34Ry;zu7 zl(Zl>=ZGl7O|t=QFY^sw#b)ln-SJ?~Tg{WX*K6_=H; zzhn5@>Bjd~Zmj?&GZAp|1|=0eL{jPbGhcqC^>0~b1~yLyj-<>I=ls&V5>EzBAk!x` zFTEtglR-Ewv#7YlFF&s;wJ6`IvLw~7G}n`XCnvu=wYVfWwZthCsDZ6GGd-^~H=2Pn zH!(dgv!pZyoRT5u?t5(!@-R zB?^SnDN%+HN~S~^LMS^BWeB0{07~nMD1{fSNQD)EQBC2DNxBEy>IQme?hZMMa5~sAVHaKL<+LSRQ8(gH|Rodovh#P^&bo09h#rB7^~H C((W$+ diff --git a/test/jdk/java/security/KeyRep/SerialOld.java b/test/jdk/java/security/KeyRep/SerialOld.java index fe8eb32d0454a..0729883cd2f76 100644 --- a/test/jdk/java/security/KeyRep/SerialOld.java +++ b/test/jdk/java/security/KeyRep/SerialOld.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * 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,14 +23,13 @@ /* * @test 1.1, 03/08/13 - * @bug 4532506 + * @bug 4532506 8301126 * @summary Serializing KeyPair on one VM (Sun), * and Deserializing on another (IBM) fails * @run main/othervm/java.security.policy=SerialOld.policy SerialOld */ import java.io.*; -import java.security.*; public class SerialOld { public static void main(String[] args) throws Exception { @@ -40,10 +39,15 @@ public static void main(String[] args) throws Exception { deserializeTigerKey("DSA"); deserializeTigerKey("RSA"); - // verify pre-tiger keys still deserialize in our VM + // verify pre-tiger keys still deserialize in our VM. + + // There used to be a RSA test here, but the serialized file contained + // classes introduced in JDK 5.0 (sun.security.rsa.RSA*). The older + // RSA keys from JDK 1.4.2 were of class JSA_* which were removed when + // sun.security.rsa was introduced. (See JDK-8301126 for more + // details.) The test/data has been removed. deserializeKey("DSA"); - deserializeKey("RSA"); deserializeKey("DH"); deserializeKey("AES"); deserializeKey("Blowfish"); From ba64034c79f83b2cd899e1998c217a75fe2ee75f Mon Sep 17 00:00:00 2001 From: Yuri Nesterenko Date: Thu, 28 Sep 2023 12:00:14 +0300 Subject: [PATCH 236/341] 8317040: Exclude cleaner test failing on older releases Reviewed-by: mbalao, andrew, clanger --- test/jdk/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 33af3a2bcff7f..fb6d61ff142c5 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -655,6 +655,7 @@ com/sun/security/sasl/gsskerb/ConfSecurityLayer.java 8039280 generic- com/sun/security/sasl/gsskerb/NoSecurityLayer.java 8039280 generic-all javax/security/auth/kerberos/KerberosHashEqualsTest.java 8039280 generic-all javax/security/auth/kerberos/KerberosTixDateTest.java 8039280 generic-all +javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java 8285785,8286045,8287596 generic-all sun/security/provider/PolicyFile/GrantAllPermToExtWhenNoPolicy.java 8039280 generic-all sun/security/provider/PolicyParser/ExtDirsChange.java 8039280 generic-all sun/security/provider/PolicyParser/PrincipalExpansionError.java 8039280 generic-all From c2bd1ee67db35fddedc6c30302ecbf241d0b788c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Sun, 8 Oct 2023 15:17:24 +0000 Subject: [PATCH 237/341] 8317121: vector_masked_load instruction is moved too early after JDK-8286941 Backport-of: cfabcbf85837e97bdd6c9e4e06e875ecbaa70084 --- src/hotspot/share/opto/memnode.cpp | 9 +- .../vectorization/TestMaskedVectors.java | 118 ++++++++++++++++++ 2 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/vectorization/TestMaskedVectors.java diff --git a/src/hotspot/share/opto/memnode.cpp b/src/hotspot/share/opto/memnode.cpp index 2ee1e5f52f766..f81e80fec0ea0 100644 --- a/src/hotspot/share/opto/memnode.cpp +++ b/src/hotspot/share/opto/memnode.cpp @@ -579,8 +579,13 @@ Node* LoadNode::find_previous_arraycopy(PhaseTransform* phase, Node* ld_alloc, N Node* dest = ac->in(ArrayCopyNode::Dest); if (dest == ld_base) { - const TypeX *ld_offs_t = phase->type(ld_offs)->isa_intptr_t(); - if (ac->modifies(ld_offs_t->_lo, ld_offs_t->_hi, phase, can_see_stored_value)) { + const TypeX* ld_offs_t = phase->type(ld_offs)->isa_intptr_t(); + assert(!ld_offs_t->empty(), "dead reference should be checked already"); + // Take into account vector or unsafe access size + jlong ld_size_in_bytes = (jlong)memory_size(); + jlong offset_hi = ld_offs_t->_hi + ld_size_in_bytes - 1; + offset_hi = MIN2(offset_hi, (jlong)(TypeX::MAX->_hi)); // Take care for overflow in 32-bit VM + if (ac->modifies(ld_offs_t->_lo, (intptr_t)offset_hi, phase, can_see_stored_value)) { return ac; } if (!can_see_stored_value) { diff --git a/test/hotspot/jtreg/compiler/vectorization/TestMaskedVectors.java b/test/hotspot/jtreg/compiler/vectorization/TestMaskedVectors.java new file mode 100644 index 0000000000000..c106a9bc69cb9 --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorization/TestMaskedVectors.java @@ -0,0 +1,118 @@ +/* + * 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 8317121 + * @summary Test masked vectors and unsafe access to memory modified by arraycopy + * @requires vm.compiler2.enabled + * @modules java.base/jdk.internal.misc + * @library /test/lib / + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation -Xbatch -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,TestMaskedVectors::test* -XX:+StressLCM -XX:+StressGCM -XX:StressSeed=2210259638 TestMaskedVectors + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation -Xbatch -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,TestMaskedVectors::test* -XX:+StressLCM -XX:+StressGCM TestMaskedVectors + */ + +import java.lang.reflect.*; +import java.util.*; + +import jdk.internal.misc.Unsafe; + +public class TestMaskedVectors { + + private static Unsafe UNSAFE = Unsafe.getUnsafe(); + private static final long BASE_OFFSET = UNSAFE.arrayBaseOffset(byte[].class); + + static void testLoadVectorMasked(byte[] src, byte[] dst, int len) { + byte[] tmp = new byte[64]; + + // (3) The LoadVectorMasked is found to be dependent on below arraycopy and + // therefore scheduled just below it. As a result, the LoadVectorMasked misses the + // updated elements at index 16..48 and dst will contain incorrect values. + System.arraycopy(src, 0, tmp, 0, 16); + + // (2) The LoadVectorMasked is incorrectly found to be independent of this arraycopy + // because the LoadVectorMasked has offset 0 whereas the arraycopy writes offset >= 16. + // The problem is that MemNode::find_previous_store() -> LoadNode::find_previous_arraycopy() + // -> ArrayCopyNode::modifies does not account for the size of the load. + System.arraycopy(src, 0, tmp, 16, 48); + + // (1) The following arraycopy is expanded into a LoadVectorMasked and a + // StoreVectorMasked in PhaseMacroExpand::generate_partial_inlining_block(). + System.arraycopy(tmp, 0, dst, 0, len); + } + + static long testUnsafeGetLong(byte[] src) { + byte[] tmp = new byte[16]; + + // (3) The unsafe load is found to be dependent on below arraycopy and + // therefore scheduled just below it. As a result, the unsafe load misses the + // updated elements at index 1..16 and therefore returns an incorrect result. + System.arraycopy(src, 0, tmp, 0, 16); + + // (2) The unsafe load is incorrectly found to be independent of this arraycopy + // because the load has offset 0 in 'tmp' whereas the arraycopy writes offsets >= 1. + // The problem is that MemNode::find_previous_store() -> LoadNode::find_previous_arraycopy() + // -> ArrayCopyNode::modifies does not account for the size of the load. + System.arraycopy(src, 0, tmp, 1, 15); + + // (1) Below unsafe load reads the first 8 (byte) array elements. + return UNSAFE.getLong(tmp, BASE_OFFSET); + } + + public static void main(String[] args) { + // Initialize src array with increasing byte values + byte[] src = new byte[64]; + for (byte i = 0; i < src.length; ++i) { + src[i] = (byte)i; + } + + // Compute expected outputs once + byte[] golden1 = new byte[64]; + testLoadVectorMasked(src, golden1, 64); + + long golden2 = testUnsafeGetLong(src); + + // Trigger compilation of test methods and verify the results + for (int i = 0; i < 50_000; ++i) { + int len = i % 32; + byte[] dst = new byte[len]; + testLoadVectorMasked(src, dst, len); + + boolean error = false; + for (int j = 0; j < dst.length; ++j) { + if (dst[j] != golden1[j]) { + System.out.println("Incorrect value of element " + j + ": Expected " + golden1[j] + " but got " + dst[j]); + error = true; + } + } + if (error) { + throw new RuntimeException("Test LoadVectorMasked failed"); + } + + long res = testUnsafeGetLong(src); + if (res != golden2) { + throw new RuntimeException("Incorrect result in test UnsafeGetLong: Expected " + golden2 + " but got " + res); + } + } + } +} From 9c16e89d275654cee98f5374434bea2097dda91e Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Fri, 6 Oct 2023 07:31:00 +0200 Subject: [PATCH 238/341] 8317643: [17u] Remove designator DEFAULT_PROMOTED_VERSION_PRE=ea for release 17.0.9 Reviewed-by: goetz --- make/conf/version-numbers.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/conf/version-numbers.conf b/make/conf/version-numbers.conf index c188a694618ec..2b37ac661cb78 100644 --- a/make/conf/version-numbers.conf +++ b/make/conf/version-numbers.conf @@ -39,4 +39,4 @@ DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_VERSION_DOCS_API_SINCE=11 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="16 17" DEFAULT_JDK_SOURCE_TARGET_VERSION=17 -DEFAULT_PROMOTED_VERSION_PRE=ea +DEFAULT_PROMOTED_VERSION_PRE= From 8a92a6571f76ddfd54623da218b1249764cf710d Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 12 Oct 2023 06:10:30 +0000 Subject: [PATCH 239/341] 8317706: Exclude java/awt/Graphics2D/DrawString/RotTransText.java on linux Backport-of: 064a21d6d7a82ed4f43a099757698ed872c9cf7d --- test/jdk/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 9096e3b4b90b1..f84087c0908f2 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -507,6 +507,7 @@ java/awt/Robot/Delay/InterruptOfDelay.java 8265986 macosx-all java/awt/MenuBar/TestNoScreenMenuBar.java 8265987 macosx-all java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java 8266283 generic-all +java/awt/Graphics2D/DrawString/RotTransText.java 8316878 linux-all java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.java 8257529 windows-x64 java/awt/Window/GetScreenLocation/GetScreenLocationTest.java 8225787 linux-x64 From fa42a3ebab176454421b1fe6106c403be50a9a1d Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 12 Oct 2023 06:11:04 +0000 Subject: [PATCH 240/341] 8317705: ProblemList sun/tools/jstat/jstatLineCountsX.sh on linux-ppc64le and aix due to JDK-8248691 Backport-of: 7d0a937446d37ef2cd88ebf91b3a429134d447a0 --- test/jdk/ProblemList.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index f84087c0908f2..c0c364d57167d 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -783,10 +783,10 @@ sun/tools/jstatd/TestJstatdDefaults.java 8081569,8226420 sun/tools/jstatd/TestJstatdRmiPort.java 8226420,8251259 windows-all sun/tools/jstatd/TestJstatdServer.java 8081569,8226420 windows-all -sun/tools/jstat/jstatLineCounts1.sh 8268211 linux-aarch64 -sun/tools/jstat/jstatLineCounts2.sh 8268211 linux-aarch64 -sun/tools/jstat/jstatLineCounts3.sh 8268211 linux-aarch64 -sun/tools/jstat/jstatLineCounts4.sh 8268211 linux-aarch64 +sun/tools/jstat/jstatLineCounts1.sh 8248691,8268211 linux-ppc64le,aix-ppc64,linux-aarch64 +sun/tools/jstat/jstatLineCounts2.sh 8248691,8268211 linux-ppc64le,aix-ppc64,linux-aarch64 +sun/tools/jstat/jstatLineCounts3.sh 8248691,8268211 linux-ppc64le,aix-ppc64,linux-aarch64 +sun/tools/jstat/jstatLineCounts4.sh 8248691,8268211 linux-ppc64le,aix-ppc64,linux-aarch64 ############################################################################ From c17878a93b6b2c52380f8240a88f463adadba1c2 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 12 Oct 2023 07:19:29 +0000 Subject: [PATCH 241/341] 8270199: Most SA tests are skipped on macosx-aarch64 because all executables are signed Reviewed-by: lucy Backport-of: 16e0ad0ad088af3ba1c9903ed8df60799a1ba651 --- test/hotspot/jtreg/ProblemList.txt | 6 +- ...stMutuallyExclusivePlatformPredicates.java | 4 +- test/lib/jdk/test/lib/Platform.java | 63 ++++++++++--------- test/lib/jdk/test/lib/SA/SATestUtils.java | 6 +- test/lib/jdk/test/lib/util/CoreUtils.java | 8 +-- 5 files changed, 47 insertions(+), 40 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 9038d3348e57e..c352c78edf3bc 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -120,10 +120,10 @@ serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-all,windows-x64 serviceability/sa/ClhsdbCDSCore.java 8294316,8269982,8267433 macosx-aarch64,macosx-x64 serviceability/sa/ClhsdbFindPC.java#id1 8294316,8269982,8267433 macosx-aarch64,macosx-x64 serviceability/sa/ClhsdbFindPC.java#id3 8294316,8269982,8267433 macosx-aarch64,macosx-x64 -serviceability/sa/ClhsdbPmap.java#id1 8294316,8267433 macosx-x64 +serviceability/sa/ClhsdbPmap.java#id1 8294316,8269982,8267433 macosx-aarch64,macosx-x64 serviceability/sa/ClhsdbPstack.java#id1 8294316,8269982,8267433 macosx-aarch64,macosx-x64 -serviceability/sa/TestJmapCore.java 8294316,8267433 macosx-x64 -serviceability/sa/TestJmapCoreMetaspace.java 8294316,8267433 macosx-x64 +serviceability/sa/TestJmapCore.java 8294316,8269982,8267433 macosx-aarch64,macosx-x64 +serviceability/sa/TestJmapCoreMetaspace.java 8294316,8269982,8267433 macosx-aarch64,macosx-x64 ############################################################################# diff --git a/test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java b/test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java index c71a6034748ab..045be5361d74b 100644 --- a/test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java +++ b/test/lib-test/jdk/test/lib/TestMutuallyExclusivePlatformPredicates.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. * 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 @@ private static enum MethodGroup { IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isMusl", "isSlowDebugBuild", "hasSA", "isRoot", "isTieredSupported", "areCustomLoadersSupportedForCDS", "isDefaultCDSArchiveSupported", - "isSignedOSX"); + "isHardenedOSX"); public final List methodNames; diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java index a4f2c03d10f43..01e332b3e19ec 100644 --- a/test/lib/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. * 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,13 +261,13 @@ public static boolean hasSA() { } /** - * Return true if the test JDK is signed, otherwise false. Only valid on OSX. + * Return true if the test JDK is hardened, otherwise false. Only valid on OSX. */ - public static boolean isSignedOSX() throws IOException { - // We only care about signed binaries for 10.14 and later (actually 10.14.5, but + public static boolean isHardenedOSX() throws IOException { + // We only care about hardened binaries for 10.14 and later (actually 10.14.5, but // for simplicity we'll also include earlier 10.14 versions). if (getOsVersionMajor() == 10 && getOsVersionMinor() < 14) { - return false; // assume not signed + return false; // assume not hardened } // Find the path to the java binary. @@ -279,38 +279,45 @@ public static boolean isSignedOSX() throws IOException { } // Run codesign on the java binary. - ProcessBuilder pb = new ProcessBuilder("codesign", "-d", "-v", javaFileName); - pb.redirectError(ProcessBuilder.Redirect.DISCARD); - pb.redirectOutput(ProcessBuilder.Redirect.DISCARD); + ProcessBuilder pb = new ProcessBuilder("codesign", "--display", "--verbose", javaFileName); + pb.redirectErrorStream(true); // redirect stderr to stdout Process codesignProcess = pb.start(); + BufferedReader is = new BufferedReader(new InputStreamReader(codesignProcess.getInputStream())); + String line; + boolean isHardened = false; + boolean hardenedStatusConfirmed = false; // set true when we confirm whether or not hardened + while ((line = is.readLine()) != null) { + System.out.println("STDOUT: " + line); + if (line.indexOf("flags=0x10000(runtime)") != -1 ) { + hardenedStatusConfirmed = true; + isHardened = true; + System.out.println("Target JDK is hardened. Some tests may be skipped."); + } else if (line.indexOf("flags=0x20002(adhoc,linker-signed)") != -1 ) { + hardenedStatusConfirmed = true; + isHardened = false; + System.out.println("Target JDK is adhoc signed, but not hardened."); + } else if (line.indexOf("code object is not signed at all") != -1) { + hardenedStatusConfirmed = true; + isHardened = false; + System.out.println("Target JDK is not signed, therefore not hardened."); + } + } + if (!hardenedStatusConfirmed) { + System.out.println("Could not confirm if TargetJDK is hardened. Assuming not hardened."); + isHardened = false; + } + try { if (codesignProcess.waitFor(10, TimeUnit.SECONDS) == false) { - System.err.println("Timed out waiting for the codesign process to complete. Assuming not signed."); + System.err.println("Timed out waiting for the codesign process to complete. Assuming not hardened."); codesignProcess.destroyForcibly(); - return false; // assume not signed + return false; // assume not hardened } } catch (InterruptedException e) { throw new RuntimeException(e); } - // Check codesign result to see if java binary is signed. Here are the - // exit code meanings: - // 0: signed - // 1: not signed - // 2: invalid arguments - // 3: only has meaning with the -R argument. - // So we should always get 0 or 1 as an exit value. - if (codesignProcess.exitValue() == 0) { - System.out.println("Target JDK is signed. Some tests may be skipped."); - return true; // signed - } else if (codesignProcess.exitValue() == 1) { - System.out.println("Target JDK is not signed."); - return false; // not signed - } else { - System.err.println("Executing codesign failed. Assuming unsigned: " + - codesignProcess.exitValue()); - return false; // not signed - } + return isHardened; } private static boolean isArch(String archnameRE) { diff --git a/test/lib/jdk/test/lib/SA/SATestUtils.java b/test/lib/jdk/test/lib/SA/SATestUtils.java index 0ba91f2a994ff..d4daf5ef145dd 100644 --- a/test/lib/jdk/test/lib/SA/SATestUtils.java +++ b/test/lib/jdk/test/lib/SA/SATestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. * 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,8 +63,8 @@ public static void skipIfCannotAttach() { throw new SkippedException("SA Attach not expected to work. Ptrace attach not supported."); } } else if (Platform.isOSX()) { - if (Platform.isSignedOSX()) { - throw new SkippedException("SA Attach not expected to work. JDK is signed."); + if (Platform.isHardenedOSX()) { + throw new SkippedException("SA Attach not expected to work. JDK is hardened."); } if (!Platform.isRoot() && !canAddPrivileges()) { throw new SkippedException("SA Attach not expected to work. Insufficient privileges (not root and can't use sudo)."); diff --git a/test/lib/jdk/test/lib/util/CoreUtils.java b/test/lib/jdk/test/lib/util/CoreUtils.java index d7e68e82f427e..95a71abb7eb63 100644 --- a/test/lib/jdk/test/lib/util/CoreUtils.java +++ b/test/lib/jdk/test/lib/util/CoreUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * 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,12 +136,12 @@ public static String getCoreFileLocation(String crashOutputString, long pid) thr if (!coresDir.canWrite()) { throw new SkippedException("Directory \"" + coresDir + "\" is not writable"); } - if (Platform.isSignedOSX()) { + if (Platform.isHardenedOSX()) { if (Platform.getOsVersionMajor() > 10 || (Platform.getOsVersionMajor() == 10 && Platform.getOsVersionMinor() >= 15)) { - // We can't generate cores files with signed binaries on OSX 10.15 and later. - throw new SkippedException("Cannot produce core file with signed binary on OSX 10.15 and later"); + // We can't generate cores files with hardened binaries on OSX 10.15 and later. + throw new SkippedException("Cannot produce core file with hardened binary on OSX 10.15 and later"); } } } else if (Platform.isLinux()) { From 7c26fd89923aad3bca4df64a24b7a12df7a56c16 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 16 Oct 2023 15:20:15 +0000 Subject: [PATCH 242/341] 8297640: Increase buffer size for buf (insert_features_names) in Abstract_VM_Version::insert_features_names Backport-of: 2f83b5c487f112c175d081ca5882f5032518937a --- src/hotspot/cpu/x86/vm_version_x86.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/cpu/x86/vm_version_x86.cpp b/src/hotspot/cpu/x86/vm_version_x86.cpp index 2dacfaad5f69b..a6b7d27e22f86 100644 --- a/src/hotspot/cpu/x86/vm_version_x86.cpp +++ b/src/hotspot/cpu/x86/vm_version_x86.cpp @@ -787,7 +787,7 @@ void VM_Version::get_processor_features() { _has_intel_jcc_erratum = IntelJccErratumMitigation; } - char buf[512]; + char buf[1024]; int res = jio_snprintf( buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d microcode 0x%x", From 18d61ea85967e23a0a2dbd5650c55fbf59e4a3c9 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 16 Oct 2023 15:26:48 +0000 Subject: [PATCH 243/341] 8041447: Test javax/swing/dnd/7171812/bug7171812.java fails with java.lang.RuntimeException: Test failed, scroll on drag doesn't work Backport-of: 2c52cf07469970f730aa7397f9f6b98534af3a44 --- test/jdk/ProblemList.txt | 1 - .../javax/swing/dnd/7171812/bug7171812.java | 43 +++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index c0c364d57167d..9191c3123ca15 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -127,7 +127,6 @@ java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion.java 8060176 java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_1.java 8060176 windows-all,macosx-all java/awt/dnd/MissingEventsOnModalDialog/MissingEventsOnModalDialogTest.java 8164464 linux-all,macosx-all java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.java 8171510 macosx-all -javax/swing/dnd/7171812/bug7171812.java 8041447 macosx-all java/awt/Focus/ChoiceFocus/ChoiceFocus.java 8169103 windows-all,macosx-all java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java 8198618 macosx-all java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java 6986252 macosx-all diff --git a/test/jdk/javax/swing/dnd/7171812/bug7171812.java b/test/jdk/javax/swing/dnd/7171812/bug7171812.java index ff985b1a42682..405ef6c5a4683 100644 --- a/test/jdk/javax/swing/dnd/7171812/bug7171812.java +++ b/test/jdk/javax/swing/dnd/7171812/bug7171812.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 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 @@ -26,26 +26,40 @@ * @key headful * @bug 7171812 * @summary [macosx] Views keep scrolling back to the drag position after DnD - * @author Alexander Zuev * @run main bug7171812 */ -import java.awt.*; -import java.awt.dnd.*; +import java.awt.BorderLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; import java.awt.event.InputEvent; -import javax.swing.*; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; public class bug7171812 { static JFrame mainFrame; static String listData[]; static JListWithScroll list; static JScrollPane scrollPane; + static volatile Point pt; + static volatile int height; /** * @param args the command line arguments */ public static void main(String[] args) throws Exception{ + Robot robot = new Robot(); + robot.setAutoDelay(100); + robot.setAutoWaitForIdle(true); + SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { @@ -53,18 +67,21 @@ public void run() { } }); - Robot robot = new Robot(); - robot.setAutoDelay(10); robot.waitForIdle(); - robot.mouseMove(scrollPane.getLocationOnScreen().x + 5, scrollPane.getLocationOnScreen().y + 5); - robot.mousePress(InputEvent.BUTTON1_MASK); - for(int offset = 5; offset < scrollPane.getHeight()-20; offset++) { - robot.mouseMove(scrollPane.getLocationOnScreen().x+5, scrollPane.getLocationOnScreen().y+offset); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + pt = scrollPane.getLocationOnScreen(); + height = scrollPane.getHeight(); + }); + robot.mouseMove(pt.x + 5, pt.y + 5); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for(int offset = 5; offset < height - 20; offset++) { + robot.mouseMove(pt.x + 5, pt.y + offset); } for(int offset = 5; offset < 195; offset++) { - robot.mouseMove(scrollPane.getLocationOnScreen().x+offset, scrollPane.getLocationOnScreen().y+scrollPane.getHeight()-20); + robot.mouseMove(pt.x + offset, pt.y + height - 20); } - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); try { SwingUtilities.invokeAndWait(new Runnable() { @Override From 3637245782c54b137f5078d09d3ead9fe3626e43 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Tue, 17 Oct 2023 04:58:35 +0000 Subject: [PATCH 244/341] 8317772: NMT: Make peak values available in release builds Backport-of: 32ccf018eb32726e60126dcfd69d1be9ac80ec42 --- src/hotspot/share/services/mallocTracker.cpp | 2 -- src/hotspot/share/services/mallocTracker.hpp | 15 +++++---------- src/hotspot/share/services/memReporter.cpp | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/hotspot/share/services/mallocTracker.cpp b/src/hotspot/share/services/mallocTracker.cpp index 494527ec4500a..ed5b6b6691e87 100644 --- a/src/hotspot/share/services/mallocTracker.cpp +++ b/src/hotspot/share/services/mallocTracker.cpp @@ -33,7 +33,6 @@ size_t MallocMemorySummary::_snapshot[CALC_OBJ_SIZE_IN_TYPE(MallocMemorySnapshot, size_t)]; -#ifdef ASSERT void MemoryCounter::update_peak(size_t size, size_t cnt) { size_t peak_sz = peak_size(); while (peak_sz < size) { @@ -47,7 +46,6 @@ void MemoryCounter::update_peak(size_t size, size_t cnt) { } } } -#endif // ASSERT // Total malloc'd memory used by arenas size_t MallocMemorySnapshot::total_arena() const { diff --git a/src/hotspot/share/services/mallocTracker.hpp b/src/hotspot/share/services/mallocTracker.hpp index c458d35500342..abeab0944f048 100644 --- a/src/hotspot/share/services/mallocTracker.hpp +++ b/src/hotspot/share/services/mallocTracker.hpp @@ -43,25 +43,20 @@ class MemoryCounter { volatile size_t _count; volatile size_t _size; -#ifdef ASSERT // Peak size and count. Note: Peak count is the count at the point // peak size was reached, not the absolute highest peak count. volatile size_t _peak_count; volatile size_t _peak_size; void update_peak(size_t size, size_t cnt); -#endif // ASSERT public: - MemoryCounter() : _count(0), _size(0) { - DEBUG_ONLY(_peak_count = 0;) - DEBUG_ONLY(_peak_size = 0;) - } + MemoryCounter() : _count(0), _size(0), _peak_count(0), _peak_size(0) {} inline void allocate(size_t sz) { size_t cnt = Atomic::add(&_count, size_t(1), memory_order_relaxed); if (sz > 0) { size_t sum = Atomic::add(&_size, sz, memory_order_relaxed); - DEBUG_ONLY(update_peak(sum, cnt);) + update_peak(sum, cnt); } } @@ -78,7 +73,7 @@ class MemoryCounter { if (sz != 0) { assert(sz >= 0 || size() >= size_t(-sz), "Must be"); size_t sum = Atomic::add(&_size, size_t(sz), memory_order_relaxed); - DEBUG_ONLY(update_peak(sum, _count);) + update_peak(sum, _count); } } @@ -86,11 +81,11 @@ class MemoryCounter { inline size_t size() const { return Atomic::load(&_size); } inline size_t peak_count() const { - return DEBUG_ONLY(Atomic::load(&_peak_count)) NOT_DEBUG(0); + return Atomic::load(&_peak_count); } inline size_t peak_size() const { - return DEBUG_ONLY(Atomic::load(&_peak_size)) NOT_DEBUG(0); + return Atomic::load(&_peak_size); } }; diff --git a/src/hotspot/share/services/memReporter.cpp b/src/hotspot/share/services/memReporter.cpp index 538b2d50b7452..50ffd1feaddb4 100644 --- a/src/hotspot/share/services/memReporter.cpp +++ b/src/hotspot/share/services/memReporter.cpp @@ -235,7 +235,7 @@ void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, // report malloc'd memory if (amount_in_current_scale(malloc_memory->malloc_size()) > 0 - DEBUG_ONLY(|| amount_in_current_scale(malloc_memory->malloc_peak_size()) > 0)) { + || amount_in_current_scale(malloc_memory->malloc_peak_size()) > 0) { print_malloc_line(malloc_memory->malloc_counter()); } From 052a05d1186919424e1d47544dbd566abcb35533 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Tue, 17 Oct 2023 07:15:36 +0000 Subject: [PATCH 245/341] 8310321: make JDKOPT_CHECK_CODESIGN_PARAMS more verbose Backport-of: 9eed049098b1ad98f6c061b88f21ca0e7ae3483f --- make/autoconf/jdk-options.m4 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index 07f3da53abcf9..a5557fe0a1881 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -725,6 +725,9 @@ AC_DEFUN([JDKOPT_CHECK_CODESIGN_PARAMS], $RM "$CODESIGN_TESTFILE" $TOUCH "$CODESIGN_TESTFILE" CODESIGN_SUCCESS=false + + $ECHO "check codesign, calling $CODESIGN $PARAMS $CODESIGN_TESTFILE" >&AS_MESSAGE_LOG_FD + eval \"$CODESIGN\" $PARAMS \"$CODESIGN_TESTFILE\" 2>&AS_MESSAGE_LOG_FD \ >&AS_MESSAGE_LOG_FD && CODESIGN_SUCCESS=true $RM "$CODESIGN_TESTFILE" From b07d8c225e154af496c8bdf0513590e659b02ef1 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Tue, 17 Oct 2023 07:16:03 +0000 Subject: [PATCH 246/341] 8313691: use close after failing os::fdopen in vmError and ciEnv Backport-of: 96304f37f8344b0c0e271ff9cda84961519d5109 --- src/hotspot/share/ci/ciEnv.cpp | 2 ++ src/hotspot/share/utilities/vmError.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/hotspot/share/ci/ciEnv.cpp b/src/hotspot/share/ci/ciEnv.cpp index 9c722724afed6..f14a83799766e 100644 --- a/src/hotspot/share/ci/ciEnv.cpp +++ b/src/hotspot/share/ci/ciEnv.cpp @@ -1250,6 +1250,7 @@ void ciEnv::dump_replay_data(int compile_id) { tty->print_cr("# Compiler replay data is saved as: %s", buffer); } else { tty->print_cr("# Can't open file to dump replay data."); + close(fd); } } } @@ -1273,6 +1274,7 @@ void ciEnv::dump_inline_data(int compile_id) { tty->print_cr("%s", buffer); } else { tty->print_cr("# Can't open file to dump inline data."); + close(fd); } } } diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index f20a99638d493..a425debd4b873 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -1759,6 +1759,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt int e = errno; out.print_raw("#\n# Can't open file to dump replay data. Error: "); out.print_raw_cr(os::strerror(e)); + close(fd); } } } From 436f148a595d149000e70962ba40680b43106706 Mon Sep 17 00:00:00 2001 From: amosshi Date: Tue, 17 Oct 2023 07:30:17 +0000 Subject: [PATCH 247/341] 8296275: Write a test to verify setAccelerator method of JMenuItem Backport-of: b005013a0015656b7f6ccc26f8a13c44d61f77b9 --- .../JMenuItemSetAcceleratorTest.java | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 test/jdk/javax/swing/JMenuItem/JMenuItemSetAcceleratorTest.java diff --git a/test/jdk/javax/swing/JMenuItem/JMenuItemSetAcceleratorTest.java b/test/jdk/javax/swing/JMenuItem/JMenuItemSetAcceleratorTest.java new file mode 100644 index 0000000000000..ff96c2b3aecba --- /dev/null +++ b/test/jdk/javax/swing/JMenuItem/JMenuItemSetAcceleratorTest.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; + +/* + * @test + * @key headful + * @bug 8296275 + * @summary To verify the setAccelerator method of JMenuItem. + * @requires (os.family=="mac") + * @run main JMenuItemSetAcceleratorTest + */ + +public class JMenuItemSetAcceleratorTest { + private static JFrame frame; + private static final CountDownLatch actionLatch = new CountDownLatch(1); + private volatile static Point frameAt; + private volatile static Dimension frameSize; + + private static void createAndShow() { + frame = new JFrame("JMenuItem.setAccelerator"); + frame.setLayout(new FlowLayout()); + + JMenuBar bar = new JMenuBar(); + JMenu menu = new JMenu("File"); + JMenuItem menuItem = new JMenuItem("Menu Item"); + + menuItem.setAccelerator( + KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.META_DOWN_MASK)); + menuItem.addActionListener(e -> { + System.out.println("menu item action."); + actionLatch.countDown(); + }); + + menu.add(menuItem); + bar.add(menu); + + frame.setJMenuBar(bar); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(JMenuItemSetAcceleratorTest::createAndShow); + + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.setAutoWaitForIdle(true); + + EventQueue.invokeAndWait(() -> { + frameAt = frame.getLocationOnScreen(); + frameSize = frame.getSize(); + }); + + robot.mouseMove(frameAt.x + frameSize.width / 2, + frameAt.y + frameSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + + robot.keyPress(KeyEvent.VK_META); + robot.keyPress(KeyEvent.VK_M); + robot.keyRelease(KeyEvent.VK_M); + robot.keyRelease(KeyEvent.VK_META); + + if (!actionLatch.await(5, TimeUnit.SECONDS)) { + throw new RuntimeException( + "Hasn't received the JMenuItem action event by pressing " + + "accelerator keys, test fails."); + } + System.out.println("Test passed, received action event on menu item."); + } finally { + SwingUtilities.invokeAndWait(JMenuItemSetAcceleratorTest::disposeFrame); + } + } + + public static void disposeFrame() { + if (frame != null) { + frame.dispose(); + } + } +} From f7fb52b790dc01471c3e8e30dd978abaf1291166 Mon Sep 17 00:00:00 2001 From: amosshi Date: Tue, 17 Oct 2023 07:35:17 +0000 Subject: [PATCH 248/341] 8300272: Improve readability of the test JarWithOneNonDisabledDigestAlg Backport-of: cf46004f276293ce8b092fe17ae579cbe45914a2 --- .../JarWithOneNonDisabledDigestAlg.java | 133 +++++++++++------- 1 file changed, 83 insertions(+), 50 deletions(-) diff --git a/test/jdk/jdk/security/jarsigner/JarWithOneNonDisabledDigestAlg.java b/test/jdk/jdk/security/jarsigner/JarWithOneNonDisabledDigestAlg.java index 899500672ad4d..f0c25dc85bbe0 100644 --- a/test/jdk/jdk/security/jarsigner/JarWithOneNonDisabledDigestAlg.java +++ b/test/jdk/jdk/security/jarsigner/JarWithOneNonDisabledDigestAlg.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 @@ -27,6 +27,7 @@ * @summary Check that jar entry with at least one non-disabled digest * algorithm in manifest is treated as signed * @modules java.base/sun.security.tools.keytool + * @modules java.base/sun.security.util * @library /test/lib * @build jdk.test.lib.util.JarUtils * jdk.test.lib.security.SecurityUtils @@ -34,61 +35,94 @@ */ import java.io.InputStream; -import java.io.FileInputStream; -import java.io.FileOutputStream; +import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.security.CodeSigner; import java.security.KeyStore; +import java.security.cert.CertPathValidatorException; +import java.util.Collections; +import java.util.Date; import java.util.Enumeration; -import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.zip.ZipFile; import jdk.security.jarsigner.JarSigner; import jdk.test.lib.util.JarUtils; -import jdk.test.lib.security.SecurityUtils; +import sun.security.util.ConstraintsParameters; +import sun.security.util.DisabledAlgorithmConstraints; +import sun.security.util.JarConstraintsParameters; public class JarWithOneNonDisabledDigestAlg { private static final String PASS = "changeit"; - private static final String TESTFILE1 = "testfile1"; - private static final String TESTFILE2 = "testfile2"; + private static final Path TESTFILE1 = Path.of("testfile1"); + private static final Path TESTFILE2 = Path.of("testfile2"); + private static final Path UNSIGNED_JAR = Path.of("unsigned.jar"); + private static final Path SIGNED_JAR = Path.of("signed.jar"); + private static final Path SIGNED_TWICE_JAR = Path.of("signed2.jar"); + private static final Path MULTI_SIGNED_JAR = Path.of("multi-signed.jar"); + private static final Path CURRENT_DIR = Path.of("."); public static void main(String[] args) throws Exception { - SecurityUtils.removeFromDisabledAlgs("jdk.jar.disabledAlgorithms", - List.of("SHA1")); - Files.write(Path.of(TESTFILE1), TESTFILE1.getBytes()); - JarUtils.createJarFile(Path.of("unsigned.jar"), Path.of("."), - Path.of(TESTFILE1)); + // Sanity check: Assert that MD5 is disabled, SHA-256 enabled + checkDigestAlgorithmPermits(); - genkeypair("-alias SHA1 -sigalg SHA1withRSA"); - genkeypair("-alias SHA256 -sigalg SHA256withRSA"); + // Create an unsigned JAR with a single file + Files.write(TESTFILE1, TESTFILE1.toString().getBytes()); + JarUtils.createJarFile(UNSIGNED_JAR, CURRENT_DIR, TESTFILE1); - KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); - try (FileInputStream fis = new FileInputStream("keystore")) { - ks.load(fis, PASS.toCharArray()); - } + // Generate a keystore with two different signers + genkeypair("-alias SIGNER1"); + genkeypair("-alias SIGNER2"); + KeyStore ks = loadKeyStore(); // Sign JAR twice with same signer but different digest algorithms // so that each entry in manifest file contains two digest values. - signJarFile(ks, "SHA1", "MD5", "unsigned.jar", "signed.jar"); - signJarFile(ks, "SHA1", "SHA1", "signed.jar", "signed2.jar"); - checkThatJarIsSigned("signed2.jar", false); + // Note that MD5 is a disabled digest algorithm, while SHA-256 is not + signJarFile(ks, "SIGNER1", "MD5", UNSIGNED_JAR, SIGNED_JAR); + signJarFile(ks, "SIGNER1", "SHA256", SIGNED_JAR, SIGNED_TWICE_JAR); + checkThatJarIsSigned(SIGNED_TWICE_JAR, Map.of(TESTFILE1.toString(), 1)); // add another file to the JAR - Files.write(Path.of(TESTFILE2), "testFile2".getBytes()); - JarUtils.updateJarFile(Path.of("signed2.jar"), Path.of("."), - Path.of(TESTFILE2)); + Files.write(TESTFILE2, TESTFILE2.toString().getBytes()); + JarUtils.updateJarFile(SIGNED_TWICE_JAR, CURRENT_DIR, TESTFILE2); + + // Sign the updated JAR, now with a different signer and with an enabled digest alg + signJarFile(ks, "SIGNER2", "SHA256", SIGNED_TWICE_JAR, MULTI_SIGNED_JAR); - // Sign again with different signer (SHA256) and SHA-1 digestalg. - // TESTFILE1 should have two signers and TESTFILE2 should have one - // signer. - signJarFile(ks, "SHA256", "SHA1", "signed2.jar", "multi-signed.jar"); + // TESTFILE1 should have two signers and TESTFILE2 should have one signer. + checkThatJarIsSigned(MULTI_SIGNED_JAR, + Map.of(TESTFILE1.toString(), 2, + TESTFILE2.toString(), 1) + ); + } - checkThatJarIsSigned("multi-signed.jar", true); + private static void checkDigestAlgorithmPermits() throws Exception { + ConstraintsParameters cp = new JarConstraintsParameters(Collections.emptyList(), new Date()); + DisabledAlgorithmConstraints jarConstraints = DisabledAlgorithmConstraints.jarConstraints(); + try { + jarConstraints.permits("MD5", cp, false); + throw new Exception("This test assumes that MD5 is disabled"); + } catch (CertPathValidatorException e) { + // Ignore + } + try { + jarConstraints.permits("SHA256", cp, false); + } catch (CertPathValidatorException e) { + throw new Exception("This test assumes that SHA256 is enabled"); + } + } + + private static KeyStore loadKeyStore() throws Exception { + KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); + try (InputStream fis = Files.newInputStream(Path.of("keystore"))) { + ks.load(fis, PASS.toCharArray()); + } + return ks; } private static KeyStore.PrivateKeyEntry getEntry(KeyStore ks, String alias) @@ -101,12 +135,13 @@ private static KeyStore.PrivateKeyEntry getEntry(KeyStore ks, String alias) private static void genkeypair(String cmd) throws Exception { cmd = "-genkeypair -keystore keystore -storepass " + PASS + - " -keypass " + PASS + " -keyalg rsa -dname CN=Duke " + cmd; + " -keypass " + PASS + " -keyalg rsa -sigalg SHA256withRSA " + + "-dname CN=Duke " + cmd; sun.security.tools.keytool.Main.main(cmd.split(" ")); } private static void signJarFile(KeyStore ks, String alias, - String digestAlg, String inputFile, String outputFile) + String digestAlg, Path inputFile, Path outputFile) throws Exception { JarSigner signer = new JarSigner.Builder(getEntry(ks, alias)) @@ -114,38 +149,36 @@ private static void signJarFile(KeyStore ks, String alias, .signerName(alias) .build(); - try (ZipFile in = new ZipFile(inputFile); - FileOutputStream out = new FileOutputStream(outputFile)) { + try (ZipFile in = new ZipFile(inputFile.toFile()); + OutputStream out = Files.newOutputStream(outputFile)) { signer.sign(in, out); } } - private static void checkThatJarIsSigned(String jarFile, boolean multi) + private static void checkThatJarIsSigned(Path jarFile, Map expected) throws Exception { - try (JarFile jf = new JarFile(jarFile, true)) { + try (JarFile jf = new JarFile(jarFile.toFile(), true)) { Enumeration entries = jf.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || isSigningRelated(entry.getName())) { continue; } - InputStream is = jf.getInputStream(entry); - while (is.read() != -1); + try (InputStream is = jf.getInputStream(entry)) { + is.transferTo(OutputStream.nullOutputStream()); + } CodeSigner[] signers = entry.getCodeSigners(); - if (signers == null) { - throw new Exception("JarEntry " + entry.getName() + - " is not signed"); - } else if (multi) { - if (entry.getName().equals(TESTFILE1) && - signers.length != 2) { - throw new Exception("Unexpected number of signers " + - "for " + entry.getName() + ": " + signers.length); - } else if (entry.getName().equals(TESTFILE2) && - signers.length != 1) { - throw new Exception("Unexpected number of signers " + - "for " + entry.getName() + ": " + signers.length); - } + if (!expected.containsKey(entry.getName())) { + throw new Exception("Unexpected entry " + entry.getName()); + } + int expectedSigners = expected.get(entry.getName()); + int actualSigners = signers == null ? 0 : signers.length; + + if (expectedSigners != actualSigners) { + throw new Exception("Unexpected number of signers " + + "for " + entry.getName() + ": " + actualSigners + + ", expected " + expectedSigners); } } } From 7c3e0d4886a85955c34647121dc8473a82bec3b4 Mon Sep 17 00:00:00 2001 From: amosshi Date: Tue, 17 Oct 2023 07:46:13 +0000 Subject: [PATCH 249/341] 8301570: Test runtime/jni/nativeStack/ needs to detach the native thread Backport-of: d269ebbad2286b57802a075091b0cc32110dfcc7 --- .../jtreg/runtime/jni/nativeStack/libnativeStack.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/jni/nativeStack/libnativeStack.c b/test/hotspot/jtreg/runtime/jni/nativeStack/libnativeStack.c index c8b9c9a999e67..4087e874c93d6 100644 --- a/test/hotspot/jtreg/runtime/jni/nativeStack/libnativeStack.c +++ b/test/hotspot/jtreg/runtime/jni/nativeStack/libnativeStack.c @@ -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 @@ -85,6 +85,13 @@ static void * thread_start(void* unused) { (*env)->ExceptionDescribe(env); exit(1); } + + res = (*jvm)->DetachCurrentThread(jvm); + if (res != JNI_OK) { + fprintf(stderr, "Test ERROR. Can't detach current thread: %d\n", res); + exit(1); + } + printf("Native thread terminating\n"); return NULL; From 111b52376b76f870b095159b8222c32bb0e55514 Mon Sep 17 00:00:00 2001 From: amosshi Date: Tue, 17 Oct 2023 07:49:19 +0000 Subject: [PATCH 250/341] 8300259: Add test coverage for processing of pending block files in signed JARs Backport-of: c129ce4660e6c9b5365c8bf89fb916e2a7c28e98 --- .../jar/JarFile/SignedJarPendingBlock.java | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 test/jdk/java/util/jar/JarFile/SignedJarPendingBlock.java diff --git a/test/jdk/java/util/jar/JarFile/SignedJarPendingBlock.java b/test/jdk/java/util/jar/JarFile/SignedJarPendingBlock.java new file mode 100644 index 0000000000000..a6f9955a507cf --- /dev/null +++ b/test/jdk/java/util/jar/JarFile/SignedJarPendingBlock.java @@ -0,0 +1,173 @@ +/* + * 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 + * @modules java.base/sun.security.tools.keytool + * @summary JARs with pending block files (where .RSA comes before .SF) should verify correctly + */ + +import jdk.security.jarsigner.JarSigner; + +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.KeyStore; +import java.util.Collections; +import java.util.jar.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; + +public class SignedJarPendingBlock { + + public static void main(String[] args) throws Exception { + Path jar = createJarFile(); + Path signed = signJarFile(jar); + Path pendingBlocks = moveBlockFirst(signed); + Path invalid = invalidate(pendingBlocks); + + // 1: Regular signed JAR with no pending blocks should verify + checkSigned(signed); + + // 2: Signed jar with pending blocks should verify + checkSigned(pendingBlocks); + + // 3: Invalid signed jar with pending blocks should throw SecurityException + try { + checkSigned(invalid); + throw new Exception("Expected invalid digest to be detected"); + } catch (SecurityException se) { + // Ignore + } + } + + private static void checkSigned(Path b) throws Exception { + try (JarFile jf = new JarFile(b.toFile(), true)) { + + JarEntry je = jf.getJarEntry("a.txt"); + try (InputStream in = jf.getInputStream(je)) { + in.transferTo(OutputStream.nullOutputStream()); + } + } + } + + /** + * Invalidate signed file by modifying the contents of "a.txt" + */ + private static Path invalidate(Path s) throws Exception{ + Path invalid = Path.of("pending-block-file-invalidated.jar"); + + try (ZipFile zip = new ZipFile(s.toFile()); + ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(invalid))) { + + for (ZipEntry ze : Collections.list(zip.entries())) { + String name = ze.getName(); + out.putNextEntry(new ZipEntry(name)); + + if (name.equals("a.txt")) { + // Change the contents of a.txt to trigger SignatureException + out.write("b".getBytes(StandardCharsets.UTF_8)); + } else { + try (InputStream in = zip.getInputStream(ze)) { + in.transferTo(out); + } + } + } + } + return invalid; + } + + private static Path moveBlockFirst(Path s) throws Exception { + Path b = Path.of("pending-block-file-blockfirst.jar"); + try (ZipFile in = new ZipFile(s.toFile()); + ZipOutputStream out = new ZipOutputStream(Files.newOutputStream(b))) { + + copy("META-INF/MANIFEST.MF", in, out); + + // Switch the order of the RSA and SF files + copy("META-INF/SIGNER.RSA", in, out); + copy("META-INF/SIGNER.SF", in, out); + + copy("a.txt", in, out); + } + return b; + } + + /** + * Copy an entry from a ZipFile to a ZipOutputStream + */ + private static void copy(String name, ZipFile in, ZipOutputStream out) throws Exception { + out.putNextEntry(new ZipEntry(name)); + try (InputStream is = in.getInputStream(in.getEntry(name))) { + is.transferTo(out); + } + } + + private static Path signJarFile(Path j) throws Exception { + Path s = Path.of("pending-block-file-signed.jar"); + + Files.deleteIfExists(Path.of("ks")); + + sun.security.tools.keytool.Main.main( + ("-keystore ks -storepass changeit -keypass changeit -dname" + + " CN=SIGNER" +" -alias r -genkeypair -keyalg rsa").split(" ")); + + char[] pass = "changeit".toCharArray(); + + KeyStore ks = KeyStore.getInstance(new File("ks"), pass); + + KeyStore.PrivateKeyEntry pke = (KeyStore.PrivateKeyEntry) + ks.getEntry("r", new KeyStore.PasswordProtection(pass)); + + JarSigner signer = new JarSigner.Builder(pke) + .digestAlgorithm("SHA-256") + .signatureAlgorithm("SHA256withRSA") + .signerName("SIGNER") + .build(); + + try (ZipFile in = new ZipFile(j.toFile()); + OutputStream out = Files.newOutputStream(s)) { + signer.sign(in, out); + } + + return s; + } + + /** + * Create a jar file with single entry "a.txt" containing "a" + */ + private static Path createJarFile() throws Exception { + Path jar = Path.of("pending-block-file.jar"); + Manifest manifest = new Manifest(); + manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); + try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(jar),manifest)) { + out.putNextEntry(new JarEntry("a.txt")); + out.write("a".getBytes(StandardCharsets.UTF_8)); + } + return jar; + } +} From 1b858f124d0b4a6c5dfbb41bad32f79d8bb88b04 Mon Sep 17 00:00:00 2001 From: Sonia Zaldana Calles Date: Tue, 17 Oct 2023 07:51:59 +0000 Subject: [PATCH 251/341] 8302525: Write a test to check various components send Events while mouse and key are used simultaneously Backport-of: c7517b3decdc55edb7f0ce6e6aa09a6b653c747d --- .../MouseAndKeyEventStressTest.java | 556 ++++++++++++++++++ 1 file changed, 556 insertions(+) create mode 100644 test/jdk/java/awt/event/StressTest/MouseAndKeyEventStressTest.java diff --git a/test/jdk/java/awt/event/StressTest/MouseAndKeyEventStressTest.java b/test/jdk/java/awt/event/StressTest/MouseAndKeyEventStressTest.java new file mode 100644 index 0000000000000..2d9563ab2f18e --- /dev/null +++ b/test/jdk/java/awt/event/StressTest/MouseAndKeyEventStressTest.java @@ -0,0 +1,556 @@ +/* + * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Button; +import java.awt.Canvas; +import java.awt.Checkbox; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.List; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @key headful + * @bug 8302525 + * @summary Test performs various mouse and key operations to check events are getting triggered properly. + * @run main MouseAndKeyEventStressTest + */ +public class MouseAndKeyEventStressTest { + + private volatile static int mouseButtonTypes[] = + { InputEvent.BUTTON1_DOWN_MASK, InputEvent.BUTTON2_DOWN_MASK, + InputEvent.BUTTON3_DOWN_MASK }; + private volatile static String mouseButtonNames[] = + { "BUTTON1", "BUTTON2", "BUTTON3" }; + + private static Frame frame; + private volatile static Canvas canvas; + private volatile static Button button; + private volatile static List list; + private volatile static Choice choice; + private volatile static Checkbox checkbox; + private volatile static Component[] components; + + private volatile static boolean keyPressed; + private volatile static boolean keyReleased; + private volatile static boolean mousePressed; + private volatile static boolean mouseReleased; + private volatile static boolean actionPerformed; + private volatile static boolean itemEventPerformed; + + private volatile static Robot robot; + private volatile static Point compAt; + private volatile static Dimension compSize; + + private static void initializeGUI() { + frame = new Frame("Test Frame"); + frame.setLayout(new FlowLayout()); + canvas = new Canvas(); + canvas.setSize(50, 50); + canvas.setBackground(Color.red); + button = new Button("Button"); + list = new List(); + list.add("One"); + list.add("Two"); + list.add("Three"); + choice = new Choice(); + for (int i = 0; i < 8; i++) { + choice.add("Choice " + i); + } + choice.select(3); + checkbox = new Checkbox("Checkbox"); + + components = new Component[] { canvas, button, list, choice, checkbox }; + + button.addActionListener((actionEvent) -> { + actionPerformed = true; + System.out.println("button Got an actionEvent: " + actionEvent); + }); + checkbox.addItemListener((itemEvent) -> { + itemEventPerformed = true; + System.out.println("checkbox Got a ItemEvent: " + itemEvent); + }); + list.addItemListener((itemEvent) -> { + itemEventPerformed = true; + System.out.println("List Got a ItemEvent: " + itemEvent); + }); + choice.addItemListener((itemEvent) -> { + itemEventPerformed = true; + System.out.println("Choice Got a ItemEvent: " + itemEvent); + }); + for (int i = 0; i < components.length; i++) { + components[i].addKeyListener(new KeyAdapter() { + + public void keyPressed(KeyEvent ke) { + System.out.println("Got a keyPressedSource: " + ke); + keyPressed = true; + } + + public void keyReleased(KeyEvent ke) { + System.out.println("Got a keyReleasedSource: " + ke); + keyReleased = true; + } + }); + components[i].addMouseListener(new MouseAdapter() { + + public void mousePressed(MouseEvent me) { + mousePressed = true; + System.out.println("Got a mousePressSource: " + me); + } + + public void mouseReleased(MouseEvent me) { + mouseReleased = true; + System.out.println("Got a mouseReleaseSource: " + me); + } + + }); + frame.add(components[i]); + } + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(MouseAndKeyEventStressTest::initializeGUI); + doTest(); + } finally { + EventQueue.invokeAndWait(MouseAndKeyEventStressTest::disposeFrame); + } + } + + private static void doTest() throws Exception { + robot = new Robot(); + robot.setAutoDelay(100); + robot.waitForIdle(); + + canvasMouseKeyTest(); + buttonMouseKeyTest(); + listMouseKeyTest(); + choiceMouseKeyTest(); + checkboxMouseKeyTest(); + + System.out.println("Test passed!"); + } + + private static void canvasMouseKeyTest() throws Exception { + Component component = canvas; + robot.waitForIdle(); + + for (int i = 0; i < mouseButtonTypes.length; i++) { + resetValues(); + EventQueue.invokeAndWait(() -> { + compAt = component.getLocationOnScreen(); + compSize = component.getSize(); + }); + + robot.mouseMove(compAt.x + compSize.width / 2, + compAt.y + compSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + if (!mousePressed) { + throw new RuntimeException( + "FAIL: Moving focus. mousePressed event did not occur for " + + component.getClass()); + } + + resetValues(); + robot.keyPress(KeyEvent.VK_A); + robot.waitForIdle(); + if (!keyPressed) { + throw new RuntimeException( + "FAIL: keyPressed event " + "did not occur for " + + component.getClass() + " for key A"); + } + + resetValues(); + robot.mousePress(mouseButtonTypes[i]); + robot.waitForIdle(); + if (!mousePressed) { + throw new RuntimeException( + "FAIL: mousePressed event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + resetValues(); + robot.mouseRelease(mouseButtonTypes[i]); + robot.waitForIdle(); + if (!mouseReleased) { + throw new RuntimeException( + "FAIL: mouseReleased event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + resetValues(); + robot.keyRelease(KeyEvent.VK_A); + robot.waitForIdle(); + if (!keyReleased) { + throw new RuntimeException("FAIL: keyReleased event " + + "did not occur for " + component.getClass()); + } + + keyType(KeyEvent.VK_ESCAPE); + robot.waitForIdle(); + } + System.out.println("Test passed:" + component); + } + + private static void buttonMouseKeyTest() throws Exception { + Component component = button; + robot.waitForIdle(); + + for (int i = 0; i < mouseButtonTypes.length; i++) { + resetValues(); + EventQueue.invokeAndWait(() -> { + compAt = component.getLocationOnScreen(); + compSize = component.getSize(); + }); + + robot.mouseMove(compAt.x + compSize.width / 2, + compAt.y + compSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + if (!mousePressed) { + throw new RuntimeException( + "FAIL: Moving focus. mousePressed event did not occur for " + + component.getClass()); + } + + resetValues(); + robot.keyPress(KeyEvent.VK_A); + robot.waitForIdle(); + if (!keyPressed) { + throw new RuntimeException( + "FAIL: keyPressed event " + "did not occur for " + + component.getClass() + " for key A"); + } + + resetValues(); + robot.mousePress(mouseButtonTypes[i]); + robot.waitForIdle(); + if (!mousePressed) { + throw new RuntimeException( + "FAIL: mousePressed event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + resetValues(); + robot.mouseRelease(mouseButtonTypes[i]); + robot.waitForIdle(); + + if (!actionPerformed) { + throw new RuntimeException( + "FAIL: action event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + if (!mouseReleased) { + throw new RuntimeException( + "FAIL: mouseReleased event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + resetValues(); + robot.keyRelease(KeyEvent.VK_A); + robot.waitForIdle(); + if (!keyReleased) { + throw new RuntimeException("FAIL: keyReleased event " + + "did not occur for " + component.getClass()); + } + + keyType(KeyEvent.VK_ESCAPE); + robot.waitForIdle(); + } + System.out.println("Test passed:" + component); + } + + private static void listMouseKeyTest() throws Exception { + Component component = list; + robot.waitForIdle(); + + for (int i = 0; i < mouseButtonTypes.length; i++) { + resetValues(); + EventQueue.invokeAndWait(() -> { + compAt = component.getLocationOnScreen(); + compSize = component.getSize(); + }); + + robot.mouseMove(compAt.x + compSize.width / 2, + compAt.y + compSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + if (!mousePressed) { + throw new RuntimeException( + "FAIL: Moving focus. mousePressed event did not occur for " + + component.getClass()); + } + + resetValues(); + robot.keyPress(KeyEvent.VK_A); + robot.waitForIdle(); + if (!keyPressed) { + throw new RuntimeException( + "FAIL: keyPressed event " + "did not occur for " + + component.getClass() + " for key A"); + } + + resetValues(); + robot.mousePress(mouseButtonTypes[i]); + robot.waitForIdle(); + if (!mousePressed) { + throw new RuntimeException( + "FAIL: mousePressed event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + resetValues(); + robot.mouseRelease(mouseButtonTypes[i]); + robot.waitForIdle(); + + if (!itemEventPerformed) { + throw new RuntimeException("FAIL: Item event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + if (!mouseReleased) { + throw new RuntimeException( + "FAIL: mouseReleased event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + resetValues(); + robot.keyRelease(KeyEvent.VK_A); + robot.waitForIdle(); + if (!keyReleased) { + throw new RuntimeException("FAIL: keyReleased event " + + "did not occur for " + component.getClass()); + } + + keyType(KeyEvent.VK_ESCAPE); + robot.waitForIdle(); + } + System.out.println("Test passed:" + component); + } + + private static void choiceMouseKeyTest() throws Exception { + Component component = choice; + robot.waitForIdle(); + + for (int i = 0; i < mouseButtonTypes.length; i++) { + resetValues(); + EventQueue.invokeAndWait(() -> { + compAt = component.getLocationOnScreen(); + compSize = component.getSize(); + }); + + robot.mouseMove(compAt.x + compSize.width / 2, + compAt.y + compSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + if (!mousePressed) { + throw new RuntimeException( + "FAIL: Moving focus. mousePressed event did not occur for " + + component.getClass()); + } + + if (component instanceof Choice) { + keyType(KeyEvent.VK_ESCAPE); + } + + resetValues(); + robot.keyPress(KeyEvent.VK_A); + robot.waitForIdle(); + if (!keyPressed) { + throw new RuntimeException( + "FAIL: keyPressed event " + "did not occur for " + + component.getClass() + " for key A"); + } + + resetValues(); + robot.mousePress(mouseButtonTypes[i]); + robot.waitForIdle(); + if (!mousePressed) { + throw new RuntimeException( + "FAIL: mousePressed event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + resetValues(); + boolean isMac = + System.getProperty("os.name").toLowerCase().contains("os x"); + if (isMac) { + // Choice's pop-up menu is drawn in front of choice. So + // choice can not get mouse events generated by robot, + // that's why test is made to dispath event. + MouseEvent me = + new MouseEvent(choice, MouseEvent.MOUSE_RELEASED, + System.currentTimeMillis(), mouseButtonTypes[i], + compSize.width, compSize.height, 1, false); + choice.dispatchEvent(me); + } else { + robot.mouseRelease(mouseButtonTypes[i]); + } + robot.waitForIdle(); + + if (!mouseReleased) { + throw new RuntimeException( + "FAIL: mouseReleased event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + robot.mouseMove(compAt.x + compSize.width / 2, + compAt.y + compSize.height + 30); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + + if (!itemEventPerformed) { + throw new RuntimeException("FAIL: Item event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + resetValues(); + robot.keyRelease(KeyEvent.VK_A); + robot.waitForIdle(); + if (!keyReleased) { + throw new RuntimeException("FAIL: keyReleased event " + + "did not occur for " + component.getClass()); + } + + keyType(KeyEvent.VK_ESCAPE); + robot.waitForIdle(); + } + System.out.println("Test passed:" + component); + } + + private static void checkboxMouseKeyTest() throws Exception { + Component component = checkbox; + robot.waitForIdle(); + for (int i = 0; i < mouseButtonTypes.length; i++) { + + resetValues(); + EventQueue.invokeAndWait(() -> { + compAt = component.getLocationOnScreen(); + compSize = component.getSize(); + }); + + robot.mouseMove(compAt.x + compSize.width / 2, + compAt.y + compSize.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + if (!mousePressed) { + throw new RuntimeException( + "FAIL: Moving focus. mousePressed event did not occur for " + + component.getClass()); + } + + resetValues(); + robot.keyPress(KeyEvent.VK_A); + robot.waitForIdle(); + if (!keyPressed) { + throw new RuntimeException( + "FAIL: keyPressed event " + "did not occur for " + + component.getClass() + " for key A"); + } + + resetValues(); + robot.mousePress(mouseButtonTypes[i]); + robot.waitForIdle(); + if (!mousePressed) { + throw new RuntimeException( + "FAIL: mousePressed event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + resetValues(); + robot.mouseRelease(mouseButtonTypes[i]); + robot.waitForIdle(); + if (!mouseReleased) { + throw new RuntimeException( + "FAIL: mouseReleased event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + if (!itemEventPerformed) { + throw new RuntimeException("FAIL: Item event did not occur for " + + component.getClass() + " for " + mouseButtonNames[i]); + } + + resetValues(); + robot.keyRelease(KeyEvent.VK_A); + robot.waitForIdle(); + if (!keyReleased) { + throw new RuntimeException("FAIL: keyReleased event " + + "did not occur for " + component.getClass()); + } + + keyType(KeyEvent.VK_ESCAPE); + robot.waitForIdle(); + } + System.out.println("Test passed:" + component); + } + + private static void resetValues() { + keyPressed = false; + keyReleased = false; + mousePressed = false; + mouseReleased = false; + } + + private static void keyType(int key) throws Exception { + robot.keyPress(key); + robot.keyRelease(key); + } + + public static void disposeFrame() { + if (frame != null) { + frame.dispose(); + } + } + +} From 1c5d92f99a160d2bd79bced08daba0fa50a5beca Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 17 Oct 2023 08:32:02 +0000 Subject: [PATCH 252/341] 8315062: [GHA] get-bootjdk action should return the abolute path Reviewed-by: xliu Backport-of: 99ea8bf2b962011e57d02a93217d65d7259e8f80 --- .github/actions/get-bootjdk/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/get-bootjdk/action.yml b/.github/actions/get-bootjdk/action.yml index 19c3a0128f4d4..1e569dd47c570 100644 --- a/.github/actions/get-bootjdk/action.yml +++ b/.github/actions/get-bootjdk/action.yml @@ -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 @@ -104,6 +104,6 @@ runs: - name: 'Export path to where BootJDK is installed' id: path-name run: | - # Export the path - echo 'path=bootjdk/jdk' >> $GITHUB_OUTPUT + # Export the absolute path + echo "path=`pwd`/bootjdk/jdk" >> $GITHUB_OUTPUT shell: bash From 80460e38f3d9dc0198ad55ccde4e304162488cd0 Mon Sep 17 00:00:00 2001 From: Olga Mikhaltsova Date: Tue, 17 Oct 2023 14:13:00 +0000 Subject: [PATCH 253/341] 8310268: RISC-V: misaligned memory access in String.Compare intrinsic Reviewed-by: vkempik Backport-of: d6245b6832ccd1da04616e8ba4b90321b2551971 --- .../cpu/riscv/c2_MacroAssembler_riscv.cpp | 34 ++-- .../cpu/riscv/macroAssembler_riscv.cpp | 30 ++-- src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 145 +++++++++--------- .../TestStringCompareToDifferentLength.java | 12 +- 4 files changed, 101 insertions(+), 120 deletions(-) diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index 50bb9506a8266..ac473c141366f 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -861,9 +861,10 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2, // load first parts of strings and finish initialization while loading { if (str1_isL == str2_isL) { // LL or UU + // check if str1 and str2 is same pointer + beq(str1, str2, DONE); // load 8 bytes once to compare ld(tmp1, Address(str1)); - beq(str1, str2, DONE); ld(tmp2, Address(str2)); mv(t0, STUB_THRESHOLD); bge(cnt2, t0, STUB); @@ -906,9 +907,8 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2, addi(cnt1, cnt1, 8); } addi(cnt2, cnt2, isUL ? 4 : 8); + bne(tmp1, tmp2, DIFFERENCE); bgez(cnt2, TAIL); - xorr(tmp3, tmp1, tmp2); - bnez(tmp3, DIFFERENCE); // main loop bind(NEXT_WORD); @@ -937,38 +937,30 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2, addi(cnt1, cnt1, 8); addi(cnt2, cnt2, 4); } - bgez(cnt2, TAIL); - - xorr(tmp3, tmp1, tmp2); - beqz(tmp3, NEXT_WORD); - j(DIFFERENCE); + bne(tmp1, tmp2, DIFFERENCE); + bltz(cnt2, NEXT_WORD); bind(TAIL); - xorr(tmp3, tmp1, tmp2); - bnez(tmp3, DIFFERENCE); - // Last longword. In the case where length == 4 we compare the - // same longword twice, but that's still faster than another - // conditional branch. if (str1_isL == str2_isL) { // LL or UU - ld(tmp1, Address(str1)); - ld(tmp2, Address(str2)); + load_long_misaligned(tmp1, Address(str1), tmp3, isLL ? 1 : 2); + load_long_misaligned(tmp2, Address(str2), tmp3, isLL ? 1 : 2); } else if (isLU) { // LU case - lwu(tmp1, Address(str1)); - ld(tmp2, Address(str2)); + load_int_misaligned(tmp1, Address(str1), tmp3, false); + load_long_misaligned(tmp2, Address(str2), tmp3, 2); inflate_lo32(tmp3, tmp1); mv(tmp1, tmp3); } else { // UL case - lwu(tmp2, Address(str2)); - ld(tmp1, Address(str1)); + load_int_misaligned(tmp2, Address(str2), tmp3, false); + load_long_misaligned(tmp1, Address(str1), tmp3, 2); inflate_lo32(tmp3, tmp2); mv(tmp2, tmp3); } bind(TAIL_CHECK); - xorr(tmp3, tmp1, tmp2); - beqz(tmp3, DONE); + beq(tmp1, tmp2, DONE); // Find the first different characters in the longwords and // compute their difference. bind(DIFFERENCE); + xorr(tmp3, tmp1, tmp2); ctzc_bit(result, tmp3, isLL); // count zero from lsb to msb srl(tmp1, tmp1, result); srl(tmp2, tmp2, result); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 83be79bcc7e56..005b674b33e17 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -4131,18 +4131,17 @@ void MacroAssembler::ctzc_bit(Register Rd, Register Rs, bool isLL, Register tmp1 void MacroAssembler::inflate_lo32(Register Rd, Register Rs, Register tmp1, Register tmp2) { assert_different_registers(Rd, Rs, tmp1, tmp2); - mv(tmp1, 0xFF); - mv(Rd, zr); - for (int i = 0; i <= 3; i++) { + mv(tmp1, 0xFF000000); // first byte mask at lower word + andr(Rd, Rs, tmp1); + for (int i = 0; i < 2; i++) { + slli(Rd, Rd, wordSize); + srli(tmp1, tmp1, wordSize); andr(tmp2, Rs, tmp1); - if (i) { - slli(tmp2, tmp2, i * 8); - } orr(Rd, Rd, tmp2); - if (i != 3) { - slli(tmp1, tmp1, 8); - } } + slli(Rd, Rd, wordSize); + andi(tmp2, Rs, 0xFF); // last byte mask at lower word + orr(Rd, Rd, tmp2); } // This instruction reads adjacent 4 bytes from the upper half of source register, @@ -4151,17 +4150,8 @@ void MacroAssembler::inflate_lo32(Register Rd, Register Rs, Register tmp1, Regis // Rd: 00A700A600A500A4 void MacroAssembler::inflate_hi32(Register Rd, Register Rs, Register tmp1, Register tmp2) { assert_different_registers(Rd, Rs, tmp1, tmp2); - - mv(tmp1, 0xFF00000000); - mv(Rd, zr); - for (int i = 0; i <= 3; i++) { - andr(tmp2, Rs, tmp1); - orr(Rd, Rd, tmp2); - srli(Rd, Rd, 8); - if (i != 3) { - slli(tmp1, tmp1, 8); - } - } + srli(Rs, Rs, 32); // only upper 32 bits are needed + inflate_lo32(Rd, Rs, tmp1, tmp2); } // The size of the blocks erased by the zero_blocks stub. We must diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index f59c8fb6a3dba..9bbc19dcf28ec 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -2311,24 +2311,21 @@ class StubGenerator: public StubCodeGenerator { } // code for comparing 8 characters of strings with Latin1 and Utf16 encoding - void compare_string_8_x_LU(Register tmpL, Register tmpU, Label &DIFF1, - Label &DIFF2) { - const Register strU = x12, curU = x7, strL = x29, tmp = x30; - __ ld(tmpL, Address(strL)); - __ addi(strL, strL, 8); + void compare_string_8_x_LU(Register tmpL, Register tmpU, Register strL, Register strU, Label& DIFF) { + const Register tmp = x30, tmpLval = x12; + __ ld(tmpLval, Address(strL)); + __ addi(strL, strL, wordSize); __ ld(tmpU, Address(strU)); - __ addi(strU, strU, 8); - __ inflate_lo32(tmp, tmpL); - __ mv(t0, tmp); - __ xorr(tmp, curU, t0); - __ bnez(tmp, DIFF2); - - __ ld(curU, Address(strU)); - __ addi(strU, strU, 8); - __ inflate_hi32(tmp, tmpL); - __ mv(t0, tmp); - __ xorr(tmp, tmpU, t0); - __ bnez(tmp, DIFF1); + __ addi(strU, strU, wordSize); + __ inflate_lo32(tmpL, tmpLval); + __ xorr(tmp, tmpU, tmpL); + __ bnez(tmp, DIFF); + + __ ld(tmpU, Address(strU)); + __ addi(strU, strU, wordSize); + __ inflate_hi32(tmpL, tmpLval); + __ xorr(tmp, tmpU, tmpL); + __ bnez(tmp, DIFF); } // x10 = result @@ -2343,11 +2340,9 @@ class StubGenerator: public StubCodeGenerator { __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", isLU ? "compare_long_string_different_encoding LU" : "compare_long_string_different_encoding UL"); address entry = __ pc(); - Label SMALL_LOOP, TAIL, TAIL_LOAD_16, LOAD_LAST, DIFF1, DIFF2, - DONE, CALCULATE_DIFFERENCE; - const Register result = x10, str1 = x11, cnt1 = x12, str2 = x13, cnt2 = x14, - tmp1 = x28, tmp2 = x29, tmp3 = x30, tmp4 = x7, tmp5 = x31; - RegSet spilled_regs = RegSet::of(tmp4, tmp5); + Label SMALL_LOOP, TAIL, LOAD_LAST, DONE, CALCULATE_DIFFERENCE; + const Register result = x10, str1 = x11, str2 = x13, cnt2 = x14, + tmp1 = x28, tmp2 = x29, tmp3 = x30, tmp4 = x12; // cnt2 == amount of characters left to compare // Check already loaded first 4 symbols @@ -2355,77 +2350,81 @@ class StubGenerator: public StubCodeGenerator { __ mv(isLU ? tmp1 : tmp2, tmp3); __ addi(str1, str1, isLU ? wordSize / 2 : wordSize); __ addi(str2, str2, isLU ? wordSize : wordSize / 2); - __ sub(cnt2, cnt2, 8); // Already loaded 4 symbols. Last 4 is special case. - __ push_reg(spilled_regs, sp); + __ sub(cnt2, cnt2, wordSize / 2); // Already loaded 4 symbols - if (isLU) { - __ add(str1, str1, cnt2); - __ shadd(str2, cnt2, str2, t0, 1); - } else { - __ shadd(str1, cnt2, str1, t0, 1); - __ add(str2, str2, cnt2); - } __ xorr(tmp3, tmp1, tmp2); - __ mv(tmp5, tmp2); __ bnez(tmp3, CALCULATE_DIFFERENCE); Register strU = isLU ? str2 : str1, strL = isLU ? str1 : str2, - tmpU = isLU ? tmp5 : tmp1, // where to keep U for comparison - tmpL = isLU ? tmp1 : tmp5; // where to keep L for comparison + tmpU = isLU ? tmp2 : tmp1, // where to keep U for comparison + tmpL = isLU ? tmp1 : tmp2; // where to keep L for comparison - __ sub(tmp2, strL, cnt2); // strL pointer to load from - __ slli(t0, cnt2, 1); - __ sub(cnt1, strU, t0); // strU pointer to load from + // make sure main loop is 8 byte-aligned, we should load another 4 bytes from strL + // cnt2 is >= 68 here, no need to check it for >= 0 + __ lwu(tmpL, Address(strL)); + __ addi(strL, strL, wordSize / 2); + __ ld(tmpU, Address(strU)); + __ addi(strU, strU, wordSize); + __ inflate_lo32(tmp3, tmpL); + __ mv(tmpL, tmp3); + __ xorr(tmp3, tmpU, tmpL); + __ bnez(tmp3, CALCULATE_DIFFERENCE); + __ addi(cnt2, cnt2, -wordSize / 2); - __ ld(tmp4, Address(cnt1)); - __ addi(cnt1, cnt1, 8); - __ beqz(cnt2, LOAD_LAST); // no characters left except last load - __ sub(cnt2, cnt2, 16); + // we are now 8-bytes aligned on strL + __ sub(cnt2, cnt2, wordSize * 2); __ bltz(cnt2, TAIL); __ bind(SMALL_LOOP); // smaller loop - __ sub(cnt2, cnt2, 16); - compare_string_8_x_LU(tmpL, tmpU, DIFF1, DIFF2); - compare_string_8_x_LU(tmpL, tmpU, DIFF1, DIFF2); + __ sub(cnt2, cnt2, wordSize * 2); + compare_string_8_x_LU(tmpL, tmpU, strL, strU, CALCULATE_DIFFERENCE); + compare_string_8_x_LU(tmpL, tmpU, strL, strU, CALCULATE_DIFFERENCE); __ bgez(cnt2, SMALL_LOOP); - __ addi(t0, cnt2, 16); - __ beqz(t0, LOAD_LAST); - __ bind(TAIL); // 1..15 characters left until last load (last 4 characters) - // Address of 8 bytes before last 4 characters in UTF-16 string - __ shadd(cnt1, cnt2, cnt1, t0, 1); - // Address of 16 bytes before last 4 characters in Latin1 string - __ add(tmp2, tmp2, cnt2); - __ ld(tmp4, Address(cnt1, -8)); - // last 16 characters before last load - compare_string_8_x_LU(tmpL, tmpU, DIFF1, DIFF2); - compare_string_8_x_LU(tmpL, tmpU, DIFF1, DIFF2); - __ j(LOAD_LAST); - __ bind(DIFF2); - __ mv(tmpU, tmp4); - __ bind(DIFF1); - __ mv(tmpL, t0); - __ j(CALCULATE_DIFFERENCE); - __ bind(LOAD_LAST); - // Last 4 UTF-16 characters are already pre-loaded into tmp4 by compare_string_8_x_LU. - // No need to load it again - __ mv(tmpU, tmp4); - __ ld(tmpL, Address(strL)); + __ addi(t0, cnt2, wordSize * 2); + __ beqz(t0, DONE); + __ bind(TAIL); // 1..15 characters left + // Aligned access. Load bytes in portions - 4, 2, 1. + + __ addi(t0, cnt2, wordSize); + __ addi(cnt2, cnt2, wordSize * 2); // amount of characters left to process + __ bltz(t0, LOAD_LAST); + // remaining characters are greater than or equals to 8, we can do one compare_string_8_x_LU + compare_string_8_x_LU(tmpL, tmpU, strL, strU, CALCULATE_DIFFERENCE); + __ addi(cnt2, cnt2, -wordSize); + __ beqz(cnt2, DONE); // no character left + __ bind(LOAD_LAST); // cnt2 = 1..7 characters left + + __ addi(cnt2, cnt2, -wordSize); // cnt2 is now an offset in strL which points to last 8 bytes + __ slli(t0, cnt2, 1); // t0 is now an offset in strU which points to last 16 bytes + __ add(strL, strL, cnt2); // Address of last 8 bytes in Latin1 string + __ add(strU, strU, t0); // Address of last 16 bytes in UTF-16 string + __ load_int_misaligned(tmpL, Address(strL), t0, false); + __ load_long_misaligned(tmpU, Address(strU), t0, 2); __ inflate_lo32(tmp3, tmpL); __ mv(tmpL, tmp3); __ xorr(tmp3, tmpU, tmpL); - __ beqz(tmp3, DONE); + __ bnez(tmp3, CALCULATE_DIFFERENCE); + + __ addi(strL, strL, wordSize / 2); // Address of last 4 bytes in Latin1 string + __ addi(strU, strU, wordSize); // Address of last 8 bytes in UTF-16 string + __ load_int_misaligned(tmpL, Address(strL), t0, false); + __ load_long_misaligned(tmpU, Address(strU), t0, 2); + __ inflate_lo32(tmp3, tmpL); + __ mv(tmpL, tmp3); + __ xorr(tmp3, tmpU, tmpL); + __ bnez(tmp3, CALCULATE_DIFFERENCE); + __ j(DONE); // no character left // Find the first different characters in the longwords and // compute their difference. __ bind(CALCULATE_DIFFERENCE); __ ctzc_bit(tmp4, tmp3); __ srl(tmp1, tmp1, tmp4); - __ srl(tmp5, tmp5, tmp4); + __ srl(tmp2, tmp2, tmp4); __ andi(tmp1, tmp1, 0xFFFF); - __ andi(tmp5, tmp5, 0xFFFF); - __ sub(result, tmp1, tmp5); + __ andi(tmp2, tmp2, 0xFFFF); + __ sub(result, tmp1, tmp2); __ bind(DONE); - __ pop_reg(spilled_regs, sp); __ ret(); return entry; } @@ -2527,9 +2526,9 @@ class StubGenerator: public StubCodeGenerator { __ xorr(tmp4, tmp1, tmp2); __ bnez(tmp4, DIFF); __ add(str1, str1, cnt2); - __ ld(tmp5, Address(str1)); + __ load_long_misaligned(tmp5, Address(str1), tmp3, isLL ? 1 : 2); __ add(str2, str2, cnt2); - __ ld(cnt1, Address(str2)); + __ load_long_misaligned(cnt1, Address(str2), tmp3, isLL ? 1 : 2); __ xorr(tmp4, tmp5, cnt1); __ beqz(tmp4, LENGTH_DIFF); // Find the first different characters in the longwords and diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java index aaee43e688276..26bc03c271bc7 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestStringCompareToDifferentLength.java @@ -24,20 +24,20 @@ /* * @test - * @requires os.arch=="aarch64" + * @requires os.arch=="aarch64" | os.arch=="riscv64" * @summary String::compareTo implementation uses different algorithms for * different string length. This test creates string with specified * size and longer string, which is same at beginning. * Expecting length delta to be returned. Test class takes 2 * parameters: , - * Input parameters for this test are set according to Aarch64 + * Input parameters for this test are set according to Aarch64/RISC-V * String::compareTo intrinsic implementation specifics. Aarch64 * implementation has 1, 4, 8 -bytes loops for length < 72 and - * 16, 32, 64 -characters loops for length >= 72. Code is also affected + * 16, 32, 64 -characters loops for length >= 72. Aarch64 Code is also affected * by SoftwarePrefetchHintDistance vm flag value. - * @run main/othervm -XX:SoftwarePrefetchHintDistance=192 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 23 24 25 71 72 73 88 90 192 193 208 209 - * @run main/othervm -XX:SoftwarePrefetchHintDistance=16 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 23 24 25 71 72 73 88 90 - * @run main/othervm -XX:SoftwarePrefetchHintDistance=-1 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 23 24 25 71 72 73 88 90 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:SoftwarePrefetchHintDistance=192 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 23 24 25 71 72 73 88 90 192 193 208 209 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:SoftwarePrefetchHintDistance=16 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 23 24 25 71 72 73 88 90 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:SoftwarePrefetchHintDistance=-1 compiler.intrinsics.string.TestStringCompareToDifferentLength 4 2 5 10 13 17 20 23 24 25 71 72 73 88 90 */ package compiler.intrinsics.string; From 2a5daea9499d9269a5b9afe181f18aa35584fa0c Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 18 Oct 2023 06:40:04 +0000 Subject: [PATCH 254/341] 8315214: Do not run sun/tools/jhsdb tests concurrently Reviewed-by: mdoerr Backport-of: 1e7e2bcf3560e1ad39516fb604e4d8bf85bb54e0 --- test/jdk/TEST.ROOT | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT index 3499b3030678c..6126ddadbbaa5 100644 --- a/test/jdk/TEST.ROOT +++ b/test/jdk/TEST.ROOT @@ -32,7 +32,8 @@ java/rmi/Naming java/util/prefs sun/management/jmxremote \ sun/tools/jstatd sun/tools/jcmd \ sun/tools/jinfo sun/tools/jmap sun/tools/jps sun/tools/jstack sun/tools/jstat \ com/sun/tools/attach sun/security/mscapi java/util/Arrays/largeMemory \ -java/util/BitSet/stream javax/rmi java/net/httpclient/websocket +java/util/BitSet/stream javax/rmi java/net/httpclient/websocket \ +sun/tools/jhsdb # Group definitions groups=TEST.groups From 99149158c98265fb2a727ea4d5c3b07cf1f991a9 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 18 Oct 2023 07:39:43 +0000 Subject: [PATCH 255/341] 8262901: [macos_aarch64] NativeCallTest expected:<-3.8194101E18> but was:<3.02668882E10> 8296821: compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java fails after JDK-8262901 Reviewed-by: lucy Backport-of: 6b456f7a9b6344506033dfdc5a59c0f3e95c4b2a --- .../jdk/vm/ci/code/TargetDescription.java | 4 ++ .../AArch64HotSpotJVMCIBackendFactory.java | 2 +- .../aarch64/AArch64HotSpotRegisterConfig.java | 29 +++++++++-- .../aarch64/AArch64HotSpotVMConfig.java | 3 -- test/hotspot/jtreg/ProblemList.txt | 1 - .../jdk.vm.ci.code.test/libNativeCallTest.c | 33 +++++++++++++ .../jdk/vm/ci/code/test/NativeCallTest.java | 48 ++++++++++++++++++- .../test/aarch64/AArch64TestAssembler.java | 6 +-- .../code/test/amd64/AMD64TestAssembler.java | 6 +-- 9 files changed, 115 insertions(+), 17 deletions(-) diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/TargetDescription.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/TargetDescription.java index 14fa507174a8f..c728fe578dd27 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/TargetDescription.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/TargetDescription.java @@ -25,6 +25,7 @@ import static jdk.vm.ci.meta.MetaUtil.identityHashCodeString; import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.services.Services; /** * Represents the target machine for a compiler, including the CPU architecture, the size of @@ -32,6 +33,9 @@ */ public class TargetDescription { + public final boolean linuxOs = Services.getSavedProperty("os.name", "").startsWith("Linux"); + public final boolean macOs = Services.getSavedProperty("os.name", "").startsWith("Mac"); + public final Architecture arch; /** diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java index e18c819393cd4..9d7d4748fdd3f 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java @@ -93,7 +93,7 @@ private static RegisterConfig createRegisterConfig(AArch64HotSpotVMConfig config // ARMv8 defines r18 as being available to the platform ABI. Windows // and Darwin use it for such. Linux doesn't assign it and thus r18 can // be used as an additional register. - boolean canUsePlatformRegister = config.linuxOs; + boolean canUsePlatformRegister = target.linuxOs; return new AArch64HotSpotRegisterConfig(target, config.useCompressedOops, canUsePlatformRegister); } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java index 72b13ff6ac6f6..0786ddcc08763 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java @@ -228,6 +228,27 @@ public RegisterArray getCallingConventionRegisters(Type type, JavaKind kind) { } } + private int parseStackArg(ValueKind valueKind, AllocatableValue[] locations, int index, int currentStackOffset, HotSpotCallingConventionType type) { + int kindSize = valueKind.getPlatformKind().getSizeInBytes(); + locations[index] = StackSlot.get(valueKind, currentStackOffset, !type.out); + currentStackOffset += Math.max(kindSize, target.wordSize); + return currentStackOffset; + } + + private int parseDarwinNativeStackArg(ValueKind valueKind, AllocatableValue[] locations, int index, int currentStackOffset, HotSpotCallingConventionType type) { + int kindSize = valueKind.getPlatformKind().getSizeInBytes(); + if (currentStackOffset % kindSize != 0) { + // In MacOS natural alignment is used + // See https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms + currentStackOffset += kindSize - currentStackOffset % kindSize; + } + locations[index] = StackSlot.get(valueKind, currentStackOffset, !type.out); + // In MacOS "Function arguments may consume slots on the stack that are not multiples of 8 bytes" + // See https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms + currentStackOffset += kindSize; + return currentStackOffset; + } + private CallingConvention callingConvention(RegisterArray generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, ValueKindFactory valueKindFactory) { AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; @@ -264,9 +285,11 @@ private CallingConvention callingConvention(RegisterArray generalParameterRegist } if (locations[i] == null) { - ValueKind valueKind = valueKindFactory.getValueKind(kind); - locations[i] = StackSlot.get(valueKind, currentStackOffset, !type.out); - currentStackOffset += Math.max(valueKind.getPlatformKind().getSizeInBytes(), target.wordSize); + if (target.macOs && type == HotSpotCallingConventionType.NativeCall) { + currentStackOffset = parseDarwinNativeStackArg(valueKindFactory.getValueKind(kind), locations, i, currentStackOffset, type); + } else { + currentStackOffset = parseStackArg(valueKindFactory.getValueKind(kind), locations, i, currentStackOffset, type); + } } } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java index d9fb914d8ab6f..8e1c1bcfb1f57 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java @@ -24,7 +24,6 @@ import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; import jdk.vm.ci.hotspot.HotSpotVMConfigStore; -import jdk.vm.ci.services.Services; /** * Used to access native configuration details. @@ -37,8 +36,6 @@ class AArch64HotSpotVMConfig extends HotSpotVMConfigAccess { super(config); } - final boolean linuxOs = Services.getSavedProperty("os.name", "").startsWith("Linux"); - final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); // CPU Capabilities diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index c352c78edf3bc..9779973d4fcec 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -43,7 +43,6 @@ compiler/ciReplay/TestSAServer.java 8029528 generic-all compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java 8225370 generic-all compiler/jvmci/compilerToVM/GetFlagValueTest.java 8204459 generic-all -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java 8262901 macosx-aarch64 compiler/tiered/LevelTransitionTest.java 8067651 generic-all compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java 8190680 generic-all diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c index 085fff1cf2768..88dbc92a04e77 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c @@ -189,6 +189,39 @@ JNIEXPORT jfloat JNICALL Java_jdk_vm_ci_code_test_NativeCallTest__1L32SDILDS(JNI a, b, c, d, e, f); } +jint JNICALL I32I(jint i00, jint i01, jint i02, jint i03, jint i04, jint i05, jint i06, jint i07, + jint i08, jint i09, jint i0a, jint i0b, jint i0c, jint i0d, jint i0e, jint i0f, + jint i10, jint i11, jint i12, jint i13, jint i14, jint i15, jint i16, jint i17, + jint i18, jint i19, jint i1a, jint i1b, jint i1c, jint i1d, jint i1e, jint i1f, + jint a) { + return i00 + i01 + i02 + i03 + i04 + i05 + i06 + i07 + + i08 + i09 + i0a + i0b + i0c + i0d + i0e + i0f + + i10 + i11 + i12 + i13 + i14 + i15 + i16 + i17 + + i18 + i19 + i1a + i1b + i1c + i1d + i1e + i1f + + a; +} + +JNIEXPORT jlong JNICALL Java_jdk_vm_ci_code_test_NativeCallTest_getI32I(JNIEnv *env, jclass clazz) { + return (jlong) (intptr_t) I32I; +} + +JNIEXPORT jint JNICALL Java_jdk_vm_ci_code_test_NativeCallTest__1I32I(JNIEnv *env, jclass clazz, + jint i00, jint i01, jint i02, jint i03, + jint i04, jint i05, jint i06, jint i07, + jint i08, jint i09, jint i0a, jint i0b, + jint i0c, jint i0d, jint i0e, jint i0f, + jint i10, jint i11, jint i12, jint i13, + jint i14, jint i15, jint i16, jint i17, + jint i18, jint i19, jint i1a, jint i1b, + jint i1c, jint i1d, jint i1e, jint i1f, + jint a) { + return I32I(i00, i01, i02, i03, i04, i05, i06, i07, + i08, i09, i0a, i0b, i0c, i0d, i0e, i0f, + i10, i11, i12, i13, i14, i15, i16, i17, + i18, i19, i1a, i1b, i1c, i1d, i1e, i1f, + a); +} + #ifdef __cplusplus } #endif diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java index dce107095d54d..0f5c8be3f2dae 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java @@ -125,6 +125,26 @@ public void testI32SDILDS() { test("I32SDILDS", getI32SDILDS(), float.class, argClazz, argValues); } + @Test + public void testI32I() { + int sCount = 32; + // Pairs of , + Object[] remainingArgs = new Object[]{ + 12, int.class + }; + Class[] argClazz = new Class[sCount + remainingArgs.length / 2]; + Object[] argValues = new Object[sCount + remainingArgs.length / 2]; + for (int i = 0; i < sCount; i++) { + argValues[i] = i; + argClazz[i] = int.class; + } + for (int i = 0; i < remainingArgs.length; i += 2) { + argValues[sCount + i / 2] = remainingArgs[i + 0]; + argClazz[sCount + i / 2] = (Class) remainingArgs[i + 1]; + } + test("I32I", getI32I(), int.class, argClazz, argValues); + } + public void test(String name, long addr, Class returnClazz, Class[] types, Object[] values) { try { test(asm -> { @@ -138,7 +158,13 @@ public void test(String name, long addr, Class returnClazz, Class[] types, asm.emitCallPrologue(cc, values); asm.emitCall(addr); asm.emitCallEpilogue(cc); - asm.emitFloatRet(((RegisterValue) cc.getReturn()).getRegister()); + if (returnClazz == float.class) { + asm.emitFloatRet(((RegisterValue) cc.getReturn()).getRegister()); + } else if (returnClazz == int.class) { + asm.emitIntRet(((RegisterValue) cc.getReturn()).getRegister()); + } else { + assert false : "Unimplemented return type: " + returnClazz; + } }, getMethod(name, types), values); } catch (Throwable e) { e.printStackTrace(); @@ -244,4 +270,24 @@ public static float L32SDILDS(long l00, long l01, long l02, long l03, long l04, l18, l19, l1a, l1b, l1c, l1d, l1e, l1f, a, b, c, d, e, f); } + + public static native long getI32I(); + + public static native int _I32I(int i00, int i01, int i02, int i03, int i04, int i05, int i06, int i07, + int i08, int i09, int i0a, int i0b, int i0c, int i0d, int i0e, int i0f, + int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17, + int i18, int i19, int i1a, int i1b, int i1c, int i1d, int i1e, int i1f, + int a); + + public static int I32I(int i00, int i01, int i02, int i03, int i04, int i05, int i06, int i07, + int i08, int i09, int i0a, int i0b, int i0c, int i0d, int i0e, int i0f, + int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17, + int i18, int i19, int i1a, int i1b, int i1c, int i1d, int i1e, int i1f, + int a) { + return _I32I(i00, i01, i02, i03, i04, i05, i06, i07, + i08, i09, i0a, i0b, i0c, i0d, i0e, i0f, + i10, i11, i12, i13, i14, i15, i16, i17, + i18, i19, i1a, i1b, i1c, i1d, i1e, i1f, + a); + } } diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java index 098095598ba69..b71c7ced45629 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java @@ -269,8 +269,7 @@ public void emitEpilogue() { @Override public void emitCallPrologue(CallingConvention cc, Object... prim) { - emitGrowStack(cc.getStackSize()); - frameSize += cc.getStackSize(); + growFrame(cc.getStackSize()); AllocatableValue[] args = cc.getArguments(); for (int i = 0; i < args.length; i++) { emitLoad(args[i], prim[i]); @@ -279,8 +278,7 @@ public void emitCallPrologue(CallingConvention cc, Object... prim) { @Override public void emitCallEpilogue(CallingConvention cc) { - emitGrowStack(-cc.getStackSize()); - frameSize -= cc.getStackSize(); + growFrame(-cc.getStackSize()); } @Override diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java index fd1eff615f258..a0fcdd2b0a988 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java @@ -403,8 +403,7 @@ public void emitLoad(AllocatableValue av, Object prim) { @Override public void emitCallPrologue(CallingConvention cc, Object... prim) { - emitGrowStack(cc.getStackSize()); - frameSize += cc.getStackSize(); + growFrame(cc.getStackSize()); AllocatableValue[] args = cc.getArguments(); // Do the emission in reverse, this avoids register collisons of xmm0 - which is used a // scratch register when putting arguments on the stack. @@ -427,7 +426,6 @@ public void emitCall(long addr) { @Override public void emitCallEpilogue(CallingConvention cc) { - emitGrowStack(-cc.getStackSize()); - frameSize -= cc.getStackSize(); + growFrame(-cc.getStackSize()); } } From a41b60ec7eed1ddff488758334fe04be0fe8d7f8 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 18 Oct 2023 07:42:15 +0000 Subject: [PATCH 256/341] 8306280: Open source several choice AWT tests Backport-of: d03128d0e5158ea967e714341c019b9af00ac4a1 --- test/jdk/java/awt/Choice/EmptyChoiceTest.java | 85 ++++++++++ .../jdk/java/awt/Choice/InsertRemoveTest.java | 92 +++++++++++ .../java/awt/Choice/OpenedChoiceHangs.java | 145 ++++++++++++++++++ .../awt/Choice/PressOutsideOpenedChoice.java | 113 ++++++++++++++ 4 files changed, 435 insertions(+) create mode 100644 test/jdk/java/awt/Choice/EmptyChoiceTest.java create mode 100644 test/jdk/java/awt/Choice/InsertRemoveTest.java create mode 100644 test/jdk/java/awt/Choice/OpenedChoiceHangs.java create mode 100644 test/jdk/java/awt/Choice/PressOutsideOpenedChoice.java diff --git a/test/jdk/java/awt/Choice/EmptyChoiceTest.java b/test/jdk/java/awt/Choice/EmptyChoiceTest.java new file mode 100644 index 0000000000000..cf799979acf9b --- /dev/null +++ b/test/jdk/java/awt/Choice/EmptyChoiceTest.java @@ -0,0 +1,85 @@ +/* + * 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 + * 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 4908468 + @summary Linux Empty Choice throws NPE + @key headful + @run main EmptyChoiceTest +*/ +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.lang.reflect.InvocationTargetException; + +public class EmptyChoiceTest +{ + Frame frame; + Choice choice = null; + + public static void main(String[] args) throws + InterruptedException, + InvocationTargetException { + EventQueue.invokeAndWait(() -> { + EmptyChoiceTest emptyChoiceTest = new EmptyChoiceTest(); + emptyChoiceTest.init(); + emptyChoiceTest.test(); + }); + } + + public void init() { + frame = new Frame(); + frame.setLayout(new BorderLayout()); + choice = new Choice(); + frame.add(choice, BorderLayout.NORTH); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frame.validate(); + } + + public void test () { + try { + int iWidth = choice.getWidth(); + int iHeight = choice.getHeight(); + Image componentImage = + choice.createImage(iWidth, iHeight); + Graphics graphics = + componentImage.getGraphics(); + graphics.setClip(0, 0, iWidth, iHeight); + choice.printAll(graphics); + System.out.println("PrintAll successful!"); + } catch (NullPointerException exp) { + throw new RuntimeException("Test failed. " + + "Empty Choice printAll throws NullPointerException"); + } catch (Exception exc){ + throw new RuntimeException("Test failed.", exc); + } finally { + frame.dispose(); + } + } +} diff --git a/test/jdk/java/awt/Choice/InsertRemoveTest.java b/test/jdk/java/awt/Choice/InsertRemoveTest.java new file mode 100644 index 0000000000000..37c2f15f65a01 --- /dev/null +++ b/test/jdk/java/awt/Choice/InsertRemoveTest.java @@ -0,0 +1,92 @@ +/* + * 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 + * 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 4115130 + @summary Tests Inserting/Removing items doesn't cause crash. + @key headful + @run main InsertRemoveTest + */ + +import java.awt.BorderLayout; +import java.awt.Choice; +import java.awt.EventQueue; +import java.awt.Frame; +import java.lang.reflect.InvocationTargetException; + +public class InsertRemoveTest { + Choice choice1; + Choice choice2; + Choice choice3; + Frame f; + int itemCount = 0; + int iterCount = 0; + + public static void main(String[] args) + throws InterruptedException, InvocationTargetException { + EventQueue.invokeAndWait(() -> new InsertRemoveTest().start()); + } + + public void start() { + f = new Frame("Check Choice"); + f.setLayout(new BorderLayout()); + + choice1 = new Choice(); + choice2 = new Choice(); + choice3 = new Choice(); + + f.add(choice1, BorderLayout.NORTH); + f.add(choice3, BorderLayout.CENTER); + f.add(choice2, BorderLayout.SOUTH); + + f.pack(); + f.setLocationRelativeTo(null); + f.setVisible(true); + + try { + for (int i = 0; i < 50; i++) { + if (choice1 != null && itemCount < 40) { + choice1.insert("I am Choice, yes I am : " + iterCount, + 0); + choice2.add("I am the same, yes I am : " + iterCount); + choice3.insert("I am the same, yes I am : " + iterCount, + 10); + itemCount++; + iterCount++; + } + if (itemCount >= 20 && choice1 != null + && choice1.getItemCount() > 0) { + choice1.remove(0); + choice2.remove(10); + choice3.remove(19); + itemCount--; + } + f.validate(); + } + } finally { + f.dispose(); + } + } + +} diff --git a/test/jdk/java/awt/Choice/OpenedChoiceHangs.java b/test/jdk/java/awt/Choice/OpenedChoiceHangs.java new file mode 100644 index 0000000000000..cd05391836265 --- /dev/null +++ b/test/jdk/java/awt/Choice/OpenedChoiceHangs.java @@ -0,0 +1,145 @@ +/* + * 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 + * 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 6246503 + @summary Disabling a choice after selection locks keyboard, \ + mouse and makes the system unusable + @key headful + @run main OpenedChoiceHangs +*/ + +import java.awt.AWTException; +import java.awt.Button; +import java.awt.Choice; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.event.FocusEvent; +import java.awt.event.InputEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; + +public class OpenedChoiceHangs implements ItemListener { + static final Object FOCUS_LOCK = new Object(); + + Frame frame; + Choice ch = new Choice(); + Button b = new Button("A button"); + Robot robot; + + public static void main(String[] args) + throws InterruptedException, InvocationTargetException { + OpenedChoiceHangs openedChoiceHangs = new OpenedChoiceHangs(); + EventQueue.invokeAndWait(openedChoiceHangs::init); + openedChoiceHangs.test(); + } + + public void init() { + frame = new Frame(); + + frame.setLayout(new FlowLayout()); + for (int i = 1; i < 10; i++) { + ch.add("item " + i); + } + frame.add(ch); + frame.add(b); + ch.setBackground(new Color(255, 0, 0)); + ch.setForeground(new Color(255, 0, 0)); + ch.addItemListener(this); + + frame.setSize(200, 200); + frame.setVisible(true); + frame.setLocationRelativeTo(null); + frame.validate(); + } + + public void test() { + try { + robot = new Robot(); + robot.setAutoDelay(100); + robot.setAutoWaitForIdle(true); + robot.delay(1000); + robot.mouseMove(ch.getLocationOnScreen().x + ch.getWidth() / 2, + ch.getLocationOnScreen().y + ch.getHeight() / 2); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.delay(1000); + if (!ch.isFocusOwner()) { + synchronized (FOCUS_LOCK) { + FOCUS_LOCK.wait(3000); + } + } + if (!ch.isFocusOwner()){ + throw new RuntimeException( + "Test failed. Choice has no focus after mouse press."); + } + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.delay(1000); + + robot.keyPress(KeyEvent.VK_UP); + robot.keyRelease(KeyEvent.VK_UP); + robot.delay(1000); + + Color color = robot.getPixelColor( + ch.getLocationOnScreen().x + ch.getWidth() / 2, + ch.getLocationOnScreen().y + ch.getHeight() * 4); + System.out.println("Color is " + color); + if (color.equals(new Color(255, 0,0))){ + throw new RuntimeException( + "Test failed. Choice is disabled and still opened. "); + } + } catch (AWTException e) { + throw new RuntimeException( + "Test interrupted due to AWTException. Robot=" + robot, e); + } catch (InterruptedException e) { + throw new RuntimeException("Test interrupted. Robot=" + robot, e); + } finally { + EventQueue.invokeLater(frame::dispose); + } + + System.out.println("Test passed: Choice became closed after disabling."); + } + + public void itemStateChanged (ItemEvent ie) { + System.out.println("Choice Item has changed: "+ie); + ch.setEnabled(false); + } + public void focusGained(FocusEvent fEvent){ + System.out.println("focusGained"+fEvent); + synchronized(FOCUS_LOCK){ + FOCUS_LOCK.notify(); + } + } + + public void focusLost(FocusEvent fEvent){ + System.out.println("focusLost"+fEvent); + } +} diff --git a/test/jdk/java/awt/Choice/PressOutsideOpenedChoice.java b/test/jdk/java/awt/Choice/PressOutsideOpenedChoice.java new file mode 100644 index 0000000000000..60803e775adbc --- /dev/null +++ b/test/jdk/java/awt/Choice/PressOutsideOpenedChoice.java @@ -0,0 +1,113 @@ +/* + * 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 + * 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 6259328 + @summary Choice scrolls when dragging the parent frame while drop-down \ + is active + @key headful + @run main PressOutsideOpenedChoice +*/ + + +import java.awt.Choice; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.lang.reflect.InvocationTargetException; + +public class PressOutsideOpenedChoice extends Frame { + Robot robot; + Choice choice1 = new Choice(); + Point pt; + + public static void main(String[] args) + throws InterruptedException, InvocationTargetException { + PressOutsideOpenedChoice pressOutsideOpenedChoice = + new PressOutsideOpenedChoice(); + EventQueue.invokeAndWait(pressOutsideOpenedChoice::init); + pressOutsideOpenedChoice.start(); + } + + public void init() { + for (int i = 1; i < 50; i++) { + choice1.add("item-" + i); + } + choice1.setForeground(Color.red); + choice1.setBackground(Color.red); + add(choice1); + setLayout(new FlowLayout()); + setSize (200,200); + setLocationRelativeTo(null); + setVisible(true); + validate(); + } + + public void start() { + try { + robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(50); + robot.delay(1000); + testPressOutsideOpenedChoice(InputEvent.BUTTON1_DOWN_MASK); + } catch (Throwable e) { + throw new RuntimeException("Test failed. Exception thrown: " + e); + } finally { + EventQueue.invokeLater(this::dispose); + } + } + + public void testPressOutsideOpenedChoice(int button) { + pt = choice1.getLocationOnScreen(); + robot.mouseMove(pt.x + choice1.getWidth() - choice1.getHeight() / 4, + pt.y + choice1.getHeight() / 2); + robot.delay(100); + robot.mousePress(button); + robot.mouseRelease(button); + robot.delay(200); + //move mouse outside of the choice + robot.mouseMove(pt.x - choice1.getWidth() / 2, + pt.y + choice1.getHeight() / 2); + robot.delay(400); + robot.mousePress(button); + robot.mouseRelease(button); + robot.delay(200); + Color color = robot.getPixelColor(pt.x + choice1.getWidth() / 2, + pt.y + 3 * choice1.getHeight()); + System.out.println("color got " + + robot.getPixelColor(pt.x + choice1.getWidth() / 2, + pt.y + 3 * choice1.getHeight())); + if (color.equals(Color.red)) { + throw new RuntimeException("Test failed. Choice didn't close " + + "after mouse press outside of Choice " + button); + } else { + System.out.println("Test passed. " + + "Choice closed with MousePress outside"); + } + } +} From 4d246bb6508df31a8329255f7f567f45e59c0971 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Wed, 18 Oct 2023 16:56:52 +0000 Subject: [PATCH 257/341] 8297142: jdk/jfr/event/runtime/TestShutdown.java fails on Linux ppc64le and Linux aarch64 Backport-of: bde0e35ded82ab5e95452dc8da36c63e084536a2 --- test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java index 543cde82380b0..71b617ecd79f5 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. * 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,6 +92,7 @@ private static void runSubtest(int subTestIndex) throws Exception { ProcessBuilder pb = ProcessTools.createTestJvm( "-Xlog:jfr=debug", "-XX:-CreateCoredumpOnCrash", + "-XX:-TieredCompilation", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:StartFlightRecording:filename=./dumped.jfr,dumponexit=true,settings=default", "jdk.jfr.event.runtime.TestShutdownEvent$TestMain", From 5e3d47dbfa86bfeccb7f9c58f33e0e72371a2399 Mon Sep 17 00:00:00 2001 From: amosshi Date: Thu, 19 Oct 2023 09:10:34 +0000 Subject: [PATCH 258/341] 8297296: java/awt/Mouse/EnterExitEvents/DragWindowTest.java fails with "No MouseReleased event on label!" Reviewed-by: goetz Backport-of: 0ed6d0b456e58e4122b97c3d12faabada0d8c530 --- test/jdk/ProblemList.txt | 1 - .../Mouse/EnterExitEvents/DragWindowTest.java | 26 ++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index f96b62dc719c8..5eb6db1a02e37 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -386,7 +386,6 @@ java/awt/Modal/MultipleDialogs/MultipleDialogs3Test.java 8198665 macosx-all java/awt/Modal/MultipleDialogs/MultipleDialogs4Test.java 8198665 macosx-all java/awt/Modal/MultipleDialogs/MultipleDialogs5Test.java 8198665 macosx-all java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java 8177326 macosx-all -java/awt/Mouse/EnterExitEvents/DragWindowTest.java 8023562 macosx-all java/awt/Mouse/EnterExitEvents/ResizingFrameTest.java 8005021 macosx-all java/awt/Mouse/EnterExitEvents/FullscreenEnterEventTest.java 8051455 macosx-all java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Standard.java 7124407 macosx-all diff --git a/test/jdk/java/awt/Mouse/EnterExitEvents/DragWindowTest.java b/test/jdk/java/awt/Mouse/EnterExitEvents/DragWindowTest.java index 4067bcea32ed1..4f789668c4a5c 100644 --- a/test/jdk/java/awt/Mouse/EnterExitEvents/DragWindowTest.java +++ b/test/jdk/java/awt/Mouse/EnterExitEvents/DragWindowTest.java @@ -34,11 +34,23 @@ * @run main DragWindowTest */ -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import java.util.concurrent.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Window; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import java.util.concurrent.Callable; import test.java.awt.regtesthelpers.Util; @@ -55,7 +67,7 @@ public class DragWindowTest { public static void main(String[] args) throws Exception { Robot robot = new Robot(); - robot.setAutoDelay(50); + robot.setAutoDelay(100); SwingUtilities.invokeAndWait(new Runnable() { @@ -65,6 +77,7 @@ public void run() { } }); + robot.delay(250); robot.waitForIdle(); Point pointToClick = Util.invokeOnEDT(new Callable() { @@ -134,6 +147,7 @@ private static void createAndShowGUI() { panel.add(button, BorderLayout.CENTER); frame.getContentPane().add(panel); + frame.setLocationRelativeTo(null); frame.setVisible(true); } From 05c6ae47e0c5dbeccaea74e72beca07c28880dc6 Mon Sep 17 00:00:00 2001 From: Deepa Kumari Date: Thu, 19 Oct 2023 09:15:05 +0000 Subject: [PATCH 259/341] 8312078: [PPC] JcmdScale.java Failing on AIX Backport-of: c1a3f143bf881dac6d6e517293c79a68129c6f5a --- src/hotspot/share/services/nmtDCmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/services/nmtDCmd.cpp b/src/hotspot/share/services/nmtDCmd.cpp index 972b838543208..6c87a664f7952 100644 --- a/src/hotspot/share/services/nmtDCmd.cpp +++ b/src/hotspot/share/services/nmtDCmd.cpp @@ -80,7 +80,7 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) { return; } - const char* scale_value = _scale.value(); + const char* scale_value = _scale.value() != nullptr ? _scale.value() : "(null)"; size_t scale_unit = get_scale(scale_value); if (scale_unit == 0) { output()->print_cr("Incorrect scale value: %s", scale_value); From e80200f3ddaf57fa8a2ccc23222242d0c997bea7 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 20 Oct 2023 06:35:41 +0000 Subject: [PATCH 260/341] 8312395: Improve assertions in growableArray Reviewed-by: clanger Backport-of: b772e67e2929afd9f9d6a4b08713e41f891667c0 --- src/hotspot/share/utilities/growableArray.hpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/utilities/growableArray.hpp b/src/hotspot/share/utilities/growableArray.hpp index b75283843eb79..84d4c1b3ba291 100644 --- a/src/hotspot/share/utilities/growableArray.hpp +++ b/src/hotspot/share/utilities/growableArray.hpp @@ -142,17 +142,17 @@ class GrowableArrayView : public GrowableArrayBase { } E& at(int i) { - assert(0 <= i && i < _len, "illegal index"); + assert(0 <= i && i < _len, "illegal index %d for length %d", i, _len); return _data[i]; } E const& at(int i) const { - assert(0 <= i && i < _len, "illegal index"); + assert(0 <= i && i < _len, "illegal index %d for length %d", i, _len); return _data[i]; } E* adr_at(int i) const { - assert(0 <= i && i < _len, "illegal index"); + assert(0 <= i && i < _len, "illegal index %d for length %d", i, _len); return &_data[i]; } @@ -184,7 +184,7 @@ class GrowableArrayView : public GrowableArrayBase { } void at_put(int i, const E& elem) { - assert(0 <= i && i < _len, "illegal index"); + assert(0 <= i && i < _len, "illegal index %d for length %d", i, _len); _data[i] = elem; } @@ -245,7 +245,7 @@ class GrowableArrayView : public GrowableArrayBase { } void remove_at(int index) { - assert(0 <= index && index < _len, "illegal index"); + assert(0 <= index && index < _len, "illegal index %d for length %d", index, _len); for (int j = index + 1; j < _len; j++) { _data[j-1] = _data[j]; } @@ -262,7 +262,7 @@ class GrowableArrayView : public GrowableArrayBase { // The order is changed. void delete_at(int index) { - assert(0 <= index && index < _len, "illegal index"); + assert(0 <= index && index < _len, "illegal index %d for length %d", index, _len); if (index < --_len) { // Replace removed element with last one. _data[index] = _data[_len]; @@ -390,7 +390,7 @@ class GrowableArrayWithAllocator : public GrowableArrayView { void push(const E& elem) { append(elem); } E at_grow(int i, const E& fill = E()) { - assert(0 <= i, "negative index"); + assert(0 <= i, "negative index %d", i); if (i >= this->_len) { if (i >= this->_max) grow(i); for (int j = this->_len; j <= i; j++) @@ -401,7 +401,7 @@ class GrowableArrayWithAllocator : public GrowableArrayView { } void at_put_grow(int i, const E& elem, const E& fill = E()) { - assert(0 <= i, "negative index"); + assert(0 <= i, "negative index %d", i); if (i >= this->_len) { if (i >= this->_max) grow(i); for (int j = this->_len; j < i; j++) @@ -413,7 +413,7 @@ class GrowableArrayWithAllocator : public GrowableArrayView { // inserts the given element before the element at index i void insert_before(const int idx, const E& elem) { - assert(0 <= idx && idx <= this->_len, "illegal index"); + assert(0 <= idx && idx <= this->_len, "illegal index %d for length %d", idx, this->_len); if (this->_len == this->_max) grow(this->_len); for (int j = this->_len - 1; j >= idx; j--) { this->_data[j + 1] = this->_data[j]; @@ -423,7 +423,7 @@ class GrowableArrayWithAllocator : public GrowableArrayView { } void insert_before(const int idx, const GrowableArrayView* array) { - assert(0 <= idx && idx <= this->_len, "illegal index"); + assert(0 <= idx && idx <= this->_len, "illegal index %d for length %d", idx, this->_len); int array_len = array->length(); int new_len = this->_len + array_len; if (new_len >= this->_max) grow(new_len); From 10b7536fc31e250a122f8eceb487349f961e5640 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 23 Oct 2023 14:48:28 +0000 Subject: [PATCH 261/341] 8275333: Print count in "Too many recored phases?" assert Backport-of: 45ebf85ca9a1e071955ba2e3cb32449bfbd85d14 --- src/hotspot/share/gc/shared/gcTimer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/shared/gcTimer.cpp b/src/hotspot/share/gc/shared/gcTimer.cpp index ca835e30ed339..d7669604d8294 100644 --- a/src/hotspot/share/gc/shared/gcTimer.cpp +++ b/src/hotspot/share/gc/shared/gcTimer.cpp @@ -130,7 +130,7 @@ void TimePartitions::clear() { } void TimePartitions::report_gc_phase_start(const char* name, const Ticks& time, GCPhase::PhaseType type) { - assert(_phases->length() <= 1000, "Too many recored phases?"); + assert(_phases->length() <= 1000, "Too many recorded phases? (count: %d)", _phases->length()); int level = _active_phases.count(); From 64146764a32bc8b7d7622e6f5e015a1a25f97ba3 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 23 Oct 2023 14:50:50 +0000 Subject: [PATCH 262/341] 8291154: Create a non static nested class without enclosing class throws VerifyError Backport-of: f96aee74010476a850175f7012c196e40a31c188 --- .../classes/com/sun/tools/javac/comp/Lower.java | 8 +++++++- .../javac/nested/StaticNestedNonStaticSuper.java | 13 +++++++++++++ .../javac/nested/StaticNestedNonStaticSuper.out | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/langtools/tools/javac/nested/StaticNestedNonStaticSuper.java create mode 100644 test/langtools/tools/javac/nested/StaticNestedNonStaticSuper.out diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java index dd9f550771852..8e7d82d2b70a0 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java @@ -3007,7 +3007,8 @@ public void visitApply(JCMethodInvocation tree) { // is qualified, pass qualifier as first argument in front of // the explicit constructor arguments. If the call // is not qualified, pass the correct outer instance as - // first argument. + // first argument. If we are a static class, there is no + // such outer instance, so generate an error. if (c.hasOuterInstance()) { JCExpression thisArg; if (tree.meth.hasTag(SELECT)) { @@ -3018,6 +3019,11 @@ public void visitApply(JCMethodInvocation tree) { } else if (c.isDirectlyOrIndirectlyLocal() || methName == names._this){ // local class or this() call thisArg = makeThis(tree.meth.pos(), c.type.getEnclosingType().tsym); + } else if (currentClass.isStatic()) { + // super() call from static nested class - invalid + log.error(tree.pos(), + Errors.NoEnclInstanceOfTypeInScope(c.type.getEnclosingType().tsym)); + thisArg = make.Literal(BOT, null).setType(syms.botType); } else { // super() call of nested class - never pick 'this' thisArg = makeOwnerThisN(tree.meth.pos(), c, false); diff --git a/test/langtools/tools/javac/nested/StaticNestedNonStaticSuper.java b/test/langtools/tools/javac/nested/StaticNestedNonStaticSuper.java new file mode 100644 index 0000000000000..5230efac24ad2 --- /dev/null +++ b/test/langtools/tools/javac/nested/StaticNestedNonStaticSuper.java @@ -0,0 +1,13 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8291154 + * @summary Disallow static nested subclasses of non-static nested classes + * @compile/fail/ref=StaticNestedNonStaticSuper.out -XDrawDiagnostics StaticNestedNonStaticSuper.java + */ + +class StaticNestedNonStaticSuper{ + public abstract class NonStaticNested { + public static class StaticNested extends NonStaticNested { + } + } +} diff --git a/test/langtools/tools/javac/nested/StaticNestedNonStaticSuper.out b/test/langtools/tools/javac/nested/StaticNestedNonStaticSuper.out new file mode 100644 index 0000000000000..bb251bd3154bc --- /dev/null +++ b/test/langtools/tools/javac/nested/StaticNestedNonStaticSuper.out @@ -0,0 +1,2 @@ +StaticNestedNonStaticSuper.java:10:23: compiler.err.no.encl.instance.of.type.in.scope: StaticNestedNonStaticSuper +1 error From f1ce4efb74fc31060747ec68f7aa28e1aa570768 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 23 Oct 2023 14:54:03 +0000 Subject: [PATCH 263/341] 8317967: Enhance test/jdk/javax/net/ssl/TLSCommon/SSLEngineTestCase.java to handle default cases Backport-of: 9728e21db1b35e487c562690de659aac386aa99d --- .../javax/net/ssl/TLSCommon/SSLEngineTestCase.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/jdk/javax/net/ssl/TLSCommon/SSLEngineTestCase.java b/test/jdk/javax/net/ssl/TLSCommon/SSLEngineTestCase.java index 57548ce750d04..dce28edadf24d 100644 --- a/test/jdk/javax/net/ssl/TLSCommon/SSLEngineTestCase.java +++ b/test/jdk/javax/net/ssl/TLSCommon/SSLEngineTestCase.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 @@ -134,7 +134,7 @@ public enum HandshakeMode { * e.g. "TLSv1", "TLSv1.1", "TLSv1.2", "DTLSv1.0", "DTLSv1.2". */ public static final String TESTED_SECURITY_PROTOCOL - = System.getProperty("test.security.protocol", "TLS"); + = System.getProperty("test.security.protocol"); /** * Test mode: "norm", "norm_sni" or "krb". * Modes "norm" and "norm_sni" are used to run @@ -738,13 +738,18 @@ public void runTests() { case "TLSv1.1": runTests(Ciphers.SUPPORTED_NON_KRB_NON_SHA_CIPHERS); break; - case "DTLSv1.1": + case "DTLS": + case "DTLSv1.2": + case "TLS": case "TLSv1.2": runTests(Ciphers.SUPPORTED_NON_KRB_CIPHERS); break; case "TLSv1.3": runTests(Ciphers.TLS13_CIPHERS); break; + default: + throw new Error("Test error: Unsupported test " + + "security protocol: " + TESTED_SECURITY_PROTOCOL); } break; case "krb": From 73c3316c2fb658c4d495433c79d616a1fbe61209 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 23 Oct 2023 14:56:38 +0000 Subject: [PATCH 264/341] 8268916: Tests for AffirmTrust roots Backport-of: 8c1bb2b28066ee32bef22110df06318d938c7d8b --- .../certification/CAInterop.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java index 2cf9ae88397ab..2c6d787afad67 100644 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java @@ -352,6 +352,46 @@ * @run main/othervm -Djava.security.debug=certpath CAInterop certignarootca CRL */ +/* + * @test id=affirmtrustcommercialca + * @bug 8040012 + * @summary Interoperability tests with AffirmTrust Commercial CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop affirmtrustcommercialca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop affirmtrustcommercialca CRL + */ + +/* + * @test id=affirmtrustnetworkingca + * @bug 8040012 + * @summary Interoperability tests with AffirmTrust Networking CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop affirmtrustnetworkingca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop affirmtrustnetworkingca CRL + */ + +/* + * @test id=affirmtrustpremiumca + * @bug 8040012 + * @summary Interoperability tests with AffirmTrust Premium CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop affirmtrustpremiumca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop affirmtrustpremiumca CRL + */ + +/* + * @test id=affirmtrustpremiumeccca + * @bug 8040012 + * @summary Interoperability tests with AffirmTrust Premium ECC CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop affirmtrustpremiumeccca OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop affirmtrustpremiumeccca CRL + */ + /** * Collection of certificate validation tests for interoperability with external CAs */ @@ -479,6 +519,20 @@ private CATestURLs getTestURLs(String alias) { new CATestURLs("https://valid.servicesca.dhimyotis.com", "https://revoked.servicesca.dhimyotis.com"); + // These are listed at https://www.affirmtrust.com/resources/ + case "affirmtrustcommercialca" -> + new CATestURLs("https://validcommercial.affirmtrust.com", + "https://revokedcommercial.affirmtrust.com"); + case "affirmtrustnetworkingca" -> + new CATestURLs("https://validnetworking.affirmtrust.com", + "https://revokednetworking.affirmtrust.com"); + case "affirmtrustpremiumca" -> + new CATestURLs("https://validpremium.affirmtrust.com", + "https://revokedpremium.affirmtrust.com"); + case "affirmtrustpremiumeccca" -> + new CATestURLs("https://validpremiumecc.affirmtrust.com", + "https://revokedpremiumecc.affirmtrust.com"); + default -> throw new RuntimeException("No test setup found for: " + alias); }; } From 9a1f8cbfc223fa0eb2b369334730db87de8cb16e Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 25 Oct 2023 07:26:34 +0000 Subject: [PATCH 265/341] 8311511: Improve description of NativeLibrary JFR event Backport-of: 848abd2831ab38d99b6b76b55cbe8d84c28be330 --- src/hotspot/share/jfr/metadata/metadata.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/jfr/metadata/metadata.xml b/src/hotspot/share/jfr/metadata/metadata.xml index f75df93e6735a..1c1fe5d0657ae 100644 --- a/src/hotspot/share/jfr/metadata/metadata.xml +++ b/src/hotspot/share/jfr/metadata/metadata.xml @@ -865,10 +865,11 @@ - + - + Date: Wed, 25 Oct 2023 07:51:32 +0000 Subject: [PATCH 266/341] 8275329: ZGC: vmTestbase/gc/gctests/SoftReference/soft004/soft004.java fails with assert(_phases->length() <= 1000) failed: Too many recored phases? Backport-of: 6b833db3f9cace8fbb09bb803ba31208e37a4622 --- src/hotspot/share/gc/shared/gcTimer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/shared/gcTimer.cpp b/src/hotspot/share/gc/shared/gcTimer.cpp index d7669604d8294..00a712c6a9767 100644 --- a/src/hotspot/share/gc/shared/gcTimer.cpp +++ b/src/hotspot/share/gc/shared/gcTimer.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc/shared/gcTimer.hpp" +#include "gc/shared/gc_globals.hpp" #include "utilities/growableArray.hpp" // the "time" parameter for most functions @@ -130,7 +131,7 @@ void TimePartitions::clear() { } void TimePartitions::report_gc_phase_start(const char* name, const Ticks& time, GCPhase::PhaseType type) { - assert(_phases->length() <= 1000, "Too many recorded phases? (count: %d)", _phases->length()); + assert(UseZGC || _phases->length() <= 1000, "Too many recorded phases? (count: %d)", _phases->length()); int level = _active_phases.count(); From 748ccc53978b6c226b08d4df1345f5dfdd0d32c0 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Oct 2023 07:54:30 +0000 Subject: [PATCH 267/341] 8176567: nsk/jdi/ReferenceType/instances/instances002: TestFailure: Unexpected size of referenceType.instances(nsk.share.jdi.TestInterfaceImplementer1): 11, expected: 10 Backport-of: 46fd683820bb7149c0605a0ba03f59e76de69c16 --- .../share/native/libjdwp/invoker.c | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c b/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c index ed2fb873f2d91..a7cb81abd6ac4 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c +++ b/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -753,7 +753,9 @@ invoker_completeInvokeRequest(jthread thread) } id = request->id; exc = request->exception; + request->exception = NULL; returnValue = request->returnValue; + request->returnValue.l = NULL; /* Release return value and exception references, but delay the release * until after the return packet was sent. */ @@ -796,23 +798,20 @@ invoker_completeInvokeRequest(jthread thread) (void)outStream_writeObjectTag(env, &out, exc); (void)outStream_writeObjectRef(env, &out, exc); outStream_sendReply(&out); + /* + * Delete potentially saved global references for return value + * and exception. This must be done before sending the reply or + * these objects will briefly be viewable by the debugger as live + * when they shouldn't be. + */ + if (mustReleaseReturnValue && returnValue.l != NULL) { + tossGlobalRef(env, &returnValue.l); + } + if (exc != NULL) { + tossGlobalRef(env, &exc); + } outStream_destroy(&out); } - - /* - * Delete potentially saved global references of return value - * and exception - */ - eventHandler_lock(); // for proper lock order - debugMonitorEnter(invokerLock); - if (mustReleaseReturnValue && returnValue.l != NULL) { - tossGlobalRef(env, &returnValue.l); - } - if (exc != NULL) { - tossGlobalRef(env, &exc); - } - debugMonitorExit(invokerLock); - eventHandler_unlock(); } jboolean From 5eeb41a7294f56bc258a154c043bc540cb8de5c4 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Oct 2023 08:00:27 +0000 Subject: [PATCH 268/341] 8293563: [macos-aarch64] SA core file tests failing with sun.jvm.hotspot.oops.UnknownOopException Reviewed-by: lucy Backport-of: 76f1865124025ee6f788a50e1377b82fd577548f --- test/hotspot/jtreg/ProblemList.txt | 14 +++++++------- .../jtreg/serviceability/sa/ClhsdbCDSCore.java | 3 ++- .../jtreg/serviceability/sa/ClhsdbFindPC.java | 4 ++-- .../jtreg/serviceability/sa/ClhsdbPmap.java | 4 ++-- .../jtreg/serviceability/sa/ClhsdbPstack.java | 4 ++-- .../jtreg/serviceability/sa/TestJmapCore.java | 3 ++- test/lib/jdk/test/lib/util/CoreUtils.java | 10 ++++++++++ 7 files changed, 27 insertions(+), 15 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 9779973d4fcec..fda77c82c0a67 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -116,13 +116,13 @@ serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.j serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-all,windows-x64 -serviceability/sa/ClhsdbCDSCore.java 8294316,8269982,8267433 macosx-aarch64,macosx-x64 -serviceability/sa/ClhsdbFindPC.java#id1 8294316,8269982,8267433 macosx-aarch64,macosx-x64 -serviceability/sa/ClhsdbFindPC.java#id3 8294316,8269982,8267433 macosx-aarch64,macosx-x64 -serviceability/sa/ClhsdbPmap.java#id1 8294316,8269982,8267433 macosx-aarch64,macosx-x64 -serviceability/sa/ClhsdbPstack.java#id1 8294316,8269982,8267433 macosx-aarch64,macosx-x64 -serviceability/sa/TestJmapCore.java 8294316,8269982,8267433 macosx-aarch64,macosx-x64 -serviceability/sa/TestJmapCoreMetaspace.java 8294316,8269982,8267433 macosx-aarch64,macosx-x64 +serviceability/sa/ClhsdbCDSCore.java 8294316,8267433 macosx-x64 +serviceability/sa/ClhsdbFindPC.java#id1 8294316,8267433 macosx-x64 +serviceability/sa/ClhsdbFindPC.java#id3 8294316,8267433 macosx-x64 +serviceability/sa/ClhsdbPmap.java#id1 8294316,8267433 macosx-x64 +serviceability/sa/ClhsdbPstack.java#id1 8294316,8267433 macosx-x64 +serviceability/sa/TestJmapCore.java 8294316,8267433 macosx-x64 +serviceability/sa/TestJmapCoreMetaspace.java 8294316,8267433 macosx-x64 ############################################################################# diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java index 1f705d3526b15..3655a8c8847f2 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. * 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,6 +82,7 @@ public static void main(String[] args) throws Exception { "-Xshare:auto", "-XX:+ProfileInterpreter", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", + CoreUtils.getAlwaysPretouchArg(true), CrashApp.class.getName() }; diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java index ed712294143c8..3a4be1880a0af 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java @@ -93,9 +93,9 @@ private static void testFindPC(boolean withXcomp, boolean withCore) throws Excep theApp = new LingeredApp(); theApp.setForceCrash(withCore); if (withXcomp) { - LingeredApp.startApp(theApp, "-Xcomp"); + LingeredApp.startApp(theApp, "-Xcomp", CoreUtils.getAlwaysPretouchArg(withCore)); } else { - LingeredApp.startApp(theApp, "-Xint"); + LingeredApp.startApp(theApp, "-Xint", CoreUtils.getAlwaysPretouchArg(withCore)); } System.out.print("Started LingeredApp "); if (withXcomp) { diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java index 6f0023a21e96d..e8a2209f92336 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. * 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 { ClhsdbLauncher test = new ClhsdbLauncher(); theApp = new LingeredApp(); theApp.setForceCrash(withCore); - LingeredApp.startApp(theApp); + LingeredApp.startApp(theApp, CoreUtils.getAlwaysPretouchArg(withCore)); System.out.println("Started LingeredApp with pid " + theApp.getPid()); if (withCore) { diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java index e4101a8c372f6..7429d283b0c88 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. * 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 { ClhsdbLauncher test = new ClhsdbLauncher(); theApp = new LingeredApp(); theApp.setForceCrash(withCore); - LingeredApp.startApp(theApp); + LingeredApp.startApp(theApp, CoreUtils.getAlwaysPretouchArg(withCore)); System.out.println("Started LingeredApp with pid " + theApp.getPid()); if (withCore) { diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java index e00cb43ddbbd4..34cac852c7b2a 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. * 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,6 +75,7 @@ static void test(String type) throws Throwable { "-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. + CoreUtils.getAlwaysPretouchArg(true), Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "--show-version", TestJmapCore.class.getName(), type); diff --git a/test/lib/jdk/test/lib/util/CoreUtils.java b/test/lib/jdk/test/lib/util/CoreUtils.java index 95a71abb7eb63..b3521a8c4a1bb 100644 --- a/test/lib/jdk/test/lib/util/CoreUtils.java +++ b/test/lib/jdk/test/lib/util/CoreUtils.java @@ -258,4 +258,14 @@ private static void unzipCores(File dir) { } } + public static String getAlwaysPretouchArg(boolean withCore) { + // macosx-aarch64 has an issue where sometimes the java heap will not be dumped to the + // core file. Using -XX:+AlwaysPreTouch fixes the problem. + if (withCore && Platform.isOSX() && Platform.isAArch64()) { + return "-XX:+AlwaysPreTouch"; + } else { + return "-XX:-AlwaysPreTouch"; + } + } + } From 8bde7d403366acbdba52afe2c2d153d822e10fcd Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Oct 2023 08:03:05 +0000 Subject: [PATCH 269/341] 8239801: [macos] java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java fails Backport-of: b6dddf4ce6072416e17cadefbd8280f959fd93ca --- test/jdk/ProblemList.txt | 1 - .../AccessibleChoiceTest.java | 35 +++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 5eb6db1a02e37..73c2df650e396 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -119,7 +119,6 @@ java/awt/Focus/FocusOwnerFrameOnClick/FocusOwnerFrameOnClick.java 8081489 generi java/awt/Focus/IconifiedFrameFocusChangeTest/IconifiedFrameFocusChangeTest.java 6849364 generic-all java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusToFrontTest.java 6848406 generic-all java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusSetVisibleTest.java 6848407 generic-all -java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java 8239801 macosx-all java/awt/Frame/MaximizedUndecorated/MaximizedUndecorated.java 8022302 generic-all java/awt/Frame/FrameLocation/FrameLocation.java 8233703 linux-all java/awt/FileDialog/FileDialogIconTest/FileDialogIconTest.java 8160558 windows-all diff --git a/test/jdk/java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java b/test/jdk/java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java index d8a54f52c64ad..7f17c1978e4ec 100644 --- a/test/jdk/java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java +++ b/test/jdk/java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. * 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 @@ import java.awt.Choice; import java.awt.FlowLayout; import java.awt.Frame; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; import java.awt.Point; import java.awt.Robot; import java.awt.Window; @@ -32,9 +34,14 @@ import java.awt.event.FocusEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import javax.imageio.ImageIO; + /** * @test * @bug 4478780 @@ -49,12 +56,12 @@ public class AccessibleChoiceTest { Button def = new Button("default owner"); CountDownLatch go = new CountDownLatch(1); - public static void main(final String[] args) { + public static void main(final String[] args) throws IOException { AccessibleChoiceTest app = new AccessibleChoiceTest(); app.test(); } - private void test() { + private void test() throws IOException { try { init(); start(); @@ -77,7 +84,7 @@ public void focusGained(FocusEvent e) { win.add(choice); } - public void start () { + public void start () throws IOException { frame.setVisible(true); win.pack(); win.setLocation(100, 200); @@ -89,15 +96,16 @@ public void start () { } catch (Exception ex) { throw new RuntimeException("Can't create robot"); } - robot.delay(2000); + robot.waitForIdle(); + robot.delay(1000); robot.setAutoDelay(150); robot.setAutoWaitForIdle(true); // Focus default button and wait till it gets focus Point loc = def.getLocationOnScreen(); robot.mouseMove(loc.x+2, loc.y+2); - robot.mousePress(InputEvent.BUTTON1_MASK); - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); try { go.await(1, TimeUnit.SECONDS); @@ -120,10 +128,13 @@ public void start () { robot.keyPress(KeyEvent.VK_DOWN); robot.keyRelease(KeyEvent.VK_DOWN); + robot.delay(500); + String osName = System.getProperty("os.name").toLowerCase(); if (osName.startsWith("mac")) { robot.keyPress(KeyEvent.VK_DOWN); robot.keyRelease(KeyEvent.VK_DOWN); + robot.delay(500); robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); } @@ -132,6 +143,16 @@ public void start () { // On success second item should be selected if (choice.getSelectedItem() != choice.getItem(1)) { + // Print out os name to check if mac conditional is relevant + System.err.println("Failed on os: " + osName); + + // Save image to better debug the status of test when failing + GraphicsConfiguration ge = GraphicsEnvironment + .getLocalGraphicsEnvironment().getDefaultScreenDevice() + .getDefaultConfiguration(); + BufferedImage failImage = robot.createScreenCapture(ge.getBounds()); + ImageIO.write(failImage, "png", new File("failImage.png")); + throw new RuntimeException("Choice can't be controlled by keyboard"); } } From 39c8bb24aa8641d53a71a85e3eaed05600c7cfec Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Oct 2023 08:09:49 +0000 Subject: [PATCH 270/341] 8202931: [macos] java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java fails Backport-of: f80faced6e6c6c1b10541a8b0c91625215c9ef43 --- test/jdk/ProblemList.txt | 1 - .../ChoicePopupLocation/ChoicePopupLocation.java | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 73c2df650e396..f8b2c057cfc60 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -463,7 +463,6 @@ java/awt/Debug/DumpOnKey/DumpOnKey.java 8202667 windows-all java/awt/Focus/WindowUpdateFocusabilityTest/WindowUpdateFocusabilityTest.java 8202926 linux-all java/awt/datatransfer/ConstructFlavoredObjectTest/ConstructFlavoredObjectTest.java 8202860 linux-all java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.java 8202882,8255898 linux-all,macosx-all -java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java 8202931 macosx-all,linux-all java/awt/Focus/NonFocusableBlockedOwnerTest/NonFocusableBlockedOwnerTest.java 7124275 macosx-all java/awt/Focus/TranserFocusToWindow/TranserFocusToWindow.java 6848810 macosx-all,linux-all java/awt/Component/NativeInLightShow/NativeInLightShow.java 8202932 linux-all diff --git a/test/jdk/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java b/test/jdk/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java index 37396a79fa45d..229b0492f2476 100644 --- a/test/jdk/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java +++ b/test/jdk/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,10 @@ import java.awt.Robot; import java.awt.Toolkit; import java.awt.event.InputEvent; +import java.awt.image.BufferedImage; +import java.io.File; + +import javax.imageio.ImageIO; /** * @test @@ -44,6 +48,7 @@ public final class ChoicePopupLocation { private static final int SIZE = 350; private static int frameWidth; + private static Rectangle bounds; public static void main(final String[] args) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); @@ -52,7 +57,7 @@ public static void main(final String[] args) throws Exception { Point right = null; for (GraphicsDevice sd : sds) { GraphicsConfiguration gc = sd.getDefaultConfiguration(); - Rectangle bounds = gc.getBounds(); + bounds = gc.getBounds(); if (left == null || left.x > bounds.x) { left = new Point(bounds.x, bounds.y + bounds.height / 2); } @@ -120,6 +125,8 @@ private static void openPopup(final Choice choice) throws Exception { robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.waitForIdle(); if (choice.getSelectedIndex() == 0) { + BufferedImage failImage = robot.createScreenCapture(bounds); + ImageIO.write(failImage, "png", new File("failImage.png")); throw new RuntimeException(); } } From c83100c6bf17b10b3d03480fea51b29f795ca466 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 25 Oct 2023 08:12:21 +0000 Subject: [PATCH 271/341] 8299207: [Testbug] Add back test/jdk/java/awt/Graphics2D/DrawPrimitivesTest.java Backport-of: 5e001d6ff34e2cc954f824117a73dd39f09a81c1 --- .../awt/Graphics2D/DrawPrimitivesTest.java | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 test/jdk/java/awt/Graphics2D/DrawPrimitivesTest.java diff --git a/test/jdk/java/awt/Graphics2D/DrawPrimitivesTest.java b/test/jdk/java/awt/Graphics2D/DrawPrimitivesTest.java new file mode 100644 index 0000000000000..55baf940f879f --- /dev/null +++ b/test/jdk/java/awt/Graphics2D/DrawPrimitivesTest.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, JetBrains s.r.o.. All rights reserved. + * 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 + * @key headful + * @bug 8287600 8291266 8299207 + * @requires os.family == "mac" + * @summary [macosx] Some primitives do not render in metal pipeline + * @run main DrawPrimitivesTest + */ + +import java.awt.AWTException; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.RenderingHints; +import java.awt.Robot; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.CountDownLatch; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +public abstract class DrawPrimitivesTest extends JFrame { + private final static int W = 800; + private final static int H = 800; + private final static Color[] color = { Color.RED, Color.BLUE, Color.GREEN}; + private final static int COLOR_TOLERANCE = 10; + private final CountDownLatch latchRender = new CountDownLatch(1); + private volatile int frameX0 = 0; + private volatile int frameY0 = 0; + private final String name; + + + private static boolean isAlmostEqual(Color c1, Color c2) { + return Math.abs(c1.getRed() - c2.getRed()) < COLOR_TOLERANCE && + Math.abs(c1.getGreen() - c2.getGreen()) < COLOR_TOLERANCE && + Math.abs(c1.getBlue() - c2.getBlue()) < COLOR_TOLERANCE; + + } + + public static void main(String[] args) throws InterruptedException, AWTException, InvocationTargetException { + new DrawPrimitivesTest("drawLine") { + public void renderPrimitive(Graphics2D g2d, int x0, int y0, int w, int h) { + g2d.drawLine(x0, y0, x0+w, y0+h); + } + }.runTest(); + + new DrawPrimitivesTest("fillRect") { + public void renderPrimitive(Graphics2D g2d, int x0, int y0, int w, int h) { + g2d.fillRect(x0, y0, w, h); + } + }.runTest(); + + new DrawPrimitivesTest("fillOvalAA") { + public void renderPrimitive(Graphics2D g2d, int x0, int y0, int w, int h) { + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.fillOval(x0, y0, w, h); + } + }.runTest(); + } + + public abstract void renderPrimitive(Graphics2D g2d, int x0, int y0, int w, int h); + + public DrawPrimitivesTest(String name) { + super(); + this.name = name; + } + + public void runTest() throws InterruptedException, InvocationTargetException, AWTException { + SwingUtilities.invokeLater(() -> { + add(new JPanel() { + @Override + public Dimension getPreferredSize() { + return new Dimension(W, H); + } + + @Override + public void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + g2d.setColor(Color.YELLOW); + int c = 0; + for (int i = 0; i < W; i += 10) { + for (int j = 0; j < H; j += 10) { + c = (c + 1) % color.length; + g2d.setColor(color[c]); + renderPrimitive(g2d, i, j, 10, 10); + } + } + Point p = getLocationOnScreen(); + frameX0 = p.x; + frameY0 = p.y - getInsets().top; + + latchRender.countDown(); + } + }); + setPreferredSize(new Dimension(W, H)); + pack(); + setVisible(true); + }); + + latchRender.await(); + Thread.sleep(1000); + + Robot robot = new Robot(); + + boolean hasEmptyContent = true; + l:for (int i = frameX0 + W/3; i < frameX0 + (2*W)/3; i++) { + for (int j = 0; j < 10; j += 2) { + if (isAlmostEqual(robot.getPixelColor(i, frameY0 + H / 2 + j), Color.RED)) { + hasEmptyContent = false; + break l; + } + } + } + + SwingUtilities.invokeAndWait(() -> { + setVisible(false); + dispose(); + }); + + if (hasEmptyContent) { + throw new RuntimeException(name + ": Empty content"); + } + } +} From 73e47450a35d09730c84be59e0a287ea61994e9f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 25 Oct 2023 08:33:19 +0000 Subject: [PATCH 272/341] 8312592: New parentheses warnings after HarfBuzz 7.2.0 update Reviewed-by: phh Backport-of: ea067fc3d2b1fecda694442c7921ecb980377c1e --- make/modules/java.desktop/lib/Awt2dLibraries.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/modules/java.desktop/lib/Awt2dLibraries.gmk b/make/modules/java.desktop/lib/Awt2dLibraries.gmk index b9e84d322277f..e0c6ee7ff1086 100644 --- a/make/modules/java.desktop/lib/Awt2dLibraries.gmk +++ b/make/modules/java.desktop/lib/Awt2dLibraries.gmk @@ -461,7 +461,7 @@ else LIBFONTMANAGER_EXCLUDE_FILES += libharfbuzz/hb-ft.cc HARFBUZZ_DISABLED_WARNINGS_gcc := type-limits missing-field-initializers strict-aliasing \ - array-bounds + array-bounds parentheses # noexcept-type required for GCC 7 builds. Not required for GCC 8+. # expansion-to-defined required for GCC 9 builds. Not required for GCC 10+. HARFBUZZ_DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \ From d4fe30dd6bd724017b543abf7c3fd5a17137904a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 25 Oct 2023 08:33:59 +0000 Subject: [PATCH 273/341] 8316778: test hprof lib: invalid array element type from JavaValueArray.elementSize Backport-of: f7deaf4bef21cb86fcc8a6c10454fbd6bbbba2d9 --- .../jdk/test/lib/hprof/HprofTest.java | 171 ++++++++++++++++++ .../jdk/test/lib/hprof/model/JavaObject.java | 4 +- .../test/lib/hprof/model/JavaValueArray.java | 32 +++- 3 files changed, 196 insertions(+), 11 deletions(-) create mode 100644 test/lib-test/jdk/test/lib/hprof/HprofTest.java diff --git a/test/lib-test/jdk/test/lib/hprof/HprofTest.java b/test/lib-test/jdk/test/lib/hprof/HprofTest.java new file mode 100644 index 0000000000000..a439b413fa446 --- /dev/null +++ b/test/lib-test/jdk/test/lib/hprof/HprofTest.java @@ -0,0 +1,171 @@ +/* + * 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 java.io.File; +import java.lang.ref.Reference; +import java.util.Enumeration; +import java.util.concurrent.TimeUnit; + +import jdk.test.lib.Asserts; +import jdk.test.lib.JDKToolLauncher; +import jdk.test.lib.apps.LingeredApp; +import jdk.test.lib.process.ProcessTools; + +import jdk.test.lib.hprof.model.JavaClass; +import jdk.test.lib.hprof.model.JavaHeapObject; +import jdk.test.lib.hprof.model.JavaObject; +import jdk.test.lib.hprof.model.JavaValueArray; +import jdk.test.lib.hprof.model.JavaThing; +import jdk.test.lib.hprof.model.Snapshot; +import jdk.test.lib.hprof.parser.Reader; + +/** + * @test + * @bug 8316778 + * @library /test/lib + * @run main HprofTest + */ + +class HprofTestTarg extends LingeredApp { + // Array of primitive types + int[] intArray = new int[2]; + // String + String str = "test_string"; + + public static void main(String[] args) { + HprofTestTarg testObj = new HprofTestTarg(); + + LingeredApp.main(args); + + Reference.reachabilityFence(testObj); + } + +} + + +public class HprofTest { + + public static void main(String[] args) throws Exception { + File dumpFile = new File("Myheapdump.hprof"); + createDump(dumpFile); + test(dumpFile); + } + + private static void createDump(File dumpFile) throws Exception { + LingeredApp theApp = null; + try { + theApp = new HprofTestTarg(); + + LingeredApp.startApp(theApp); + + //jcmd GC.heap_dump + JDKToolLauncher launcher = JDKToolLauncher + .createUsingTestJDK("jcmd") + .addToolArg(Long.toString(theApp.getPid())) + .addToolArg("GC.heap_dump") + .addToolArg(dumpFile.getAbsolutePath()); + Process p = ProcessTools.startProcess("jcmd", new ProcessBuilder(launcher.getCommand())); + while (!p.waitFor(5, TimeUnit.SECONDS)) { + if (!theApp.getProcess().isAlive()) { + log("ERROR: target VM died, killing jcmd..."); + p.destroyForcibly(); + throw new Exception("Target VM died"); + } + } + + if (p.exitValue() != 0) { + throw new Exception("Jcmd exited with code " + p.exitValue()); + } + } finally { + LingeredApp.stopApp(theApp); + } + } + + private static void test(File dumpFile) throws Exception { + Asserts.assertTrue(dumpFile.exists(), "Heap dump file not found."); + + log("Reading " + dumpFile + "..."); + try (Snapshot snapshot = Reader.readFile(dumpFile.getPath(), true, 0)) { + log("Resolving snapshot..."); + snapshot.resolve(true); + log("Snapshot resolved."); + + JavaObject testObj = getTestObject(snapshot); + testPrimitiveArray(testObj); + testString(testObj); + } + + } + + // verifies JavaValueArray.valueString does not throw + // "invalid array element type" exception + private static void testPrimitiveArray(JavaObject obj) { + JavaHeapObject field = getObjectField(obj, "intArray"); + Asserts.assertTrue(field instanceof JavaValueArray); + log("int array: " + ((JavaValueArray)field).valueString()); + } + + // verifies JavaObject.toString returns String value + private static void testString(JavaObject obj) { + JavaHeapObject field = getObjectField(obj, "str"); + Asserts.assertTrue(field instanceof JavaObject); + JavaObject javaObj = (JavaObject)field; + Asserts.assertTrue(javaObj.getClazz().isString()); + log("string: " + javaObj.toString()); + assert(javaObj.toString().contains(new HprofTestTarg().str)); + } + + + private static JavaHeapObject getObjectField(JavaObject obj, String fieldName) { + JavaThing thing = obj.getField(fieldName); + // only non-primitive types are supported + return (JavaHeapObject)thing; + } + + // gets test HprofTestTarg + private static JavaObject getTestObject(Snapshot snapshot) { + String testClassName = HprofTestTarg.class.getName(); + JavaHeapObject testObject = getObjects(snapshot, testClassName).nextElement(); + Asserts.assertTrue(testObject instanceof JavaObject); + return (JavaObject)testObject; + } + + // finds all objects of the specified type + private static Enumeration getObjects(Snapshot snapshot, String className) { + log("Looking for '" + className + "' objects..."); + JavaClass jClass = snapshot.findClass(className); + if (jClass == null) { + throw new RuntimeException("Class '" + className + "' not found"); + } + int instanceCount = jClass.getInstancesCount(false); + if (instanceCount < 1) { + throw new RuntimeException("Not instances of '" + className + "' found"); + } + log("Found " + instanceCount + " instance(s)."); + return jClass.getInstances(false); + } + + private static void log(Object s) { + System.out.println(s); + } +} diff --git a/test/lib/jdk/test/lib/hprof/model/JavaObject.java b/test/lib/jdk/test/lib/hprof/model/JavaObject.java index f19a2bc051e42..54b156c1f01a6 100644 --- a/test/lib/jdk/test/lib/hprof/model/JavaObject.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, 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 @@ -192,7 +192,7 @@ public String toString() { if (getClazz().isString()) { JavaThing value = getField("value"); if (value instanceof JavaValueArray) { - return ((JavaValueArray)value).valueString(); + return ((JavaValueArray)value).valueAsString(); } else { return "null"; } diff --git a/test/lib/jdk/test/lib/hprof/model/JavaValueArray.java b/test/lib/jdk/test/lib/hprof/model/JavaValueArray.java index d8b7a505ffb88..9582def2da314 100644 --- a/test/lib/jdk/test/lib/hprof/model/JavaValueArray.java +++ b/test/lib/jdk/test/lib/hprof/model/JavaValueArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, 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 @@ -68,17 +68,17 @@ private static String arrayTypeName(byte sig) { private static int elementSize(byte type) { switch (type) { - case T_BYTE: - case T_BOOLEAN: + case 'B': + case 'Z': return 1; - case T_CHAR: - case T_SHORT: + case 'C': + case 'S': return 2; - case T_INT: - case T_FLOAT: + case 'I': + case 'F': return 4; - case T_LONG: - case T_DOUBLE: + case 'J': + case 'D': return 8; default: throw new RuntimeException("invalid array element type: " + type); @@ -351,4 +351,18 @@ public String valueString(boolean bigLimit) { } return result.toString(); } + + // Tries to represent the value as string (used by JavaObject.toString). + public String valueAsString() { + if (getElementType() == 'B') { + JavaThing[] things = getValue(); + byte[] bytes = new byte[things.length]; + for (int i = 0; i < things.length; i++) { + bytes[i] = ((JavaByte)things[i]).value; + } + return new String(bytes); + } + // fallback + return valueString(); + } } From 2a9f6e8f6f552547ea42813bd21502a3a427d162 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 25 Oct 2023 10:35:53 +0000 Subject: [PATCH 274/341] 8315644: increase timeout of sun/security/tools/jarsigner/Warning.java Backport-of: 8bbebbba8fb870987295cb5f96147a9f9c5bfa6c --- test/jdk/sun/security/tools/jarsigner/Warning.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/sun/security/tools/jarsigner/Warning.java b/test/jdk/sun/security/tools/jarsigner/Warning.java index 47e36999077a8..08a9ad2478dec 100644 --- a/test/jdk/sun/security/tools/jarsigner/Warning.java +++ b/test/jdk/sun/security/tools/jarsigner/Warning.java @@ -36,7 +36,7 @@ * @summary warnings, errors and -strict * @library /lib/testlibrary /test/lib * @build jdk.test.lib.util.JarUtils - * @run main Warning + * @run main/othervm/timeout=400 Warning */ public class Warning { From 8258f274649ca0ebecd92eabd2774689cd4e670e Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 26 Oct 2023 07:43:30 +0000 Subject: [PATCH 275/341] 8313252: Java_sun_awt_windows_ThemeReader_paintBackground release resources in early returns Backport-of: 3671d83c87302ead09d4ebce9cb85bdd803a0c20 --- src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp b/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp index 4a32b8e5b894a..97a496ff74c67 100644 --- a/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp +++ b/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp @@ -427,6 +427,7 @@ JNIEXPORT void JNICALL Java_sun_awt_windows_ThemeReader_paintBackground NULL, 0); if (hDibSection == NULL) { DTRACE_PRINTLN("Error creating DIB section"); + DeleteDC(memDC); ReleaseDC(NULL,defaultDC); return; } From 2c75188edd6f719a77f954ada98460ab67fbb813 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 26 Oct 2023 18:10:43 +0000 Subject: [PATCH 276/341] 8225313: serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java failed with Unexpected high difference percentage Backport-of: 09e5321763f3fafe2b0b562f99ec0cd55a59583c --- test/hotspot/jtreg/ProblemList.txt | 2 -- .../HeapMonitorStatArrayCorrectnessTest.java | 18 ++++++++------- .../HeapMonitorStatIntervalTest.java | 8 +++---- .../HeapMonitorStatObjectCorrectnessTest.java | 22 ++++++++----------- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index fda77c82c0a67..a3c4930731ae9 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -111,8 +111,6 @@ runtime/CompressedOops/CompressedClassPointers.java 8305765 generic-all serviceability/sa/sadebugd/DebugdConnectTest.java 8239062,8270326 macosx-x64,macosx-aarch64 serviceability/sa/TestRevPtrsForInvokeDynamic.java 8241235 generic-all -serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java 8214032 generic-all -serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java 8224150 generic-all serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-all,windows-x64 diff --git a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java index d3b0d12920162..032657a0a3c32 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -36,10 +36,16 @@ public class HeapMonitorStatArrayCorrectnessTest { private static final int maxCount = 10; - // Do 100000 iterations and expect maxIteration / multiplier samples. - private static final int maxIteration = 100000; + // Do 200000 iterations and expect maxIteration / multiplier samples. + private static final int maxIteration = 200_000; private static int array[]; + // 15% error ensures a sanity test without becoming flaky. + // Flakiness is due to the fact that this test is dependent on the sampling interval, which is a + // statistical geometric variable around the sampling interval. This means that the test could be + // unlucky and not achieve the mean average fast enough for the test case. + private static final int acceptedErrorPercentage = 15; + private static void allocate(int size) { for (int j = 0; j < maxIteration; j++) { array = new int[size]; @@ -85,11 +91,7 @@ public static void main(String[] args) { expected *= 4; expected /= samplingMultiplier; - // 10% error ensures a sanity test without becoming flaky. - // Flakiness is due to the fact that this test is dependent on the sampling interval, which is a - // statistical geometric variable around the sampling interval. This means that the test could be - // unlucky and not achieve the mean average fast enough for the test case. - if (HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) { + if (HeapMonitor.statsHaveExpectedNumberSamples((int) expected, acceptedErrorPercentage)) { break; } } diff --git a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java index 3dd9d3d334b18..e08454a485716 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java @@ -42,7 +42,7 @@ private static boolean testIntervalOnce(int interval, boolean throwIfFailure) { HeapMonitor.enableSamplingEvents(); int allocationTotal = 10 * 1024 * 1024; - int allocationIterations = 10; + int allocationIterations = 20; double actualCount = 0; for (int i = 0; i < allocationIterations; i++) { @@ -58,13 +58,13 @@ private static boolean testIntervalOnce(int interval, boolean throwIfFailure) { double error = Math.abs(actualCount - expectedCount); double errorPercentage = error / expectedCount * 100; - boolean success = (errorPercentage < 10.0); + boolean success = (errorPercentage < 15.0); System.out.println("Interval: " + interval + ", throw if failure: " + throwIfFailure + " - Expected count: " + expectedCount + ", allocationIterations: " + allocationIterations + ", actualCount: " + actualCount + " -> " + success); if (!success && throwIfFailure) { - throw new RuntimeException("Interval average over 10% for interval " + interval + " -> " + throw new RuntimeException("Interval average over 15% for interval " + interval + " -> " + actualCount + ", " + expectedCount); } @@ -74,7 +74,7 @@ private static boolean testIntervalOnce(int interval, boolean throwIfFailure) { private static void testInterval(int interval) { // Test the interval twice, it can happen that the test is "unlucky" and the interval just goes above - // the 10% mark. So try again to squash flakiness. + // the 15% mark. So try again to squash flakiness. // Flakiness is due to the fact that this test is dependent on the sampling interval, which is a // statistical geometric variable around the sampling interval. This means that the test could be // unlucky and not achieve the mean average fast enough for the test case. diff --git a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java index 5ecc48b0af1ca..8f55dd1166673 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatObjectCorrectnessTest.java @@ -36,11 +36,15 @@ /** This test is checking the object allocation path works with heap sampling. */ public class HeapMonitorStatObjectCorrectnessTest { - // Do 200000 iterations and expect maxIteration / multiplier samples. - private static final int maxIteration = 200000; + // Do 400000 iterations and expect maxIteration / multiplier samples. + private static final int maxIteration = 400_000; private static BigObject obj; - private native static boolean statsHaveExpectedNumberSamples(int expected, int percentError); + // 15% error ensures a sanity test without becoming flaky. + // Flakiness is due to the fact that this test is dependent on the sampling interval, which is a + // statistical geometric variable around the sampling interval. This means that the test could be + // unlucky and not achieve the mean average fast enough for the test case. + private static final int acceptedErrorPercentage = 15; private static void allocate() { emptyStorage(); @@ -83,11 +87,7 @@ private static void testBigAllocationInterval() { double expected = maxIteration; expected /= samplingMultiplier; - // 10% error ensures a sanity test without becoming flaky. - // Flakiness is due to the fact that this test is dependent on the sampling interval, which is a - // statistical geometric variable around the sampling interval. This means that the test could be - // unlucky and not achieve the mean average fast enough for the test case. - if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) { + if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, acceptedErrorPercentage)) { throw new RuntimeException("Statistics should show about " + expected + " samples."); } } @@ -108,11 +108,7 @@ private static void testEveryAllocationSampled() { double expected = maxIteration; - // 10% error ensures a sanity test without becoming flaky. - // Flakiness is due to the fact that this test is dependent on the sampling interval, which is a - // statistical geometric variable around the sampling interval. This means that the test could be - // unlucky and not achieve the mean average fast enough for the test case. - if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) { + if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, acceptedErrorPercentage)) { throw new RuntimeException("Statistics should show about " + expected + " samples."); } } From 93127b4e9b035fed31915a43a670e4776a413436 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 26 Oct 2023 18:13:03 +0000 Subject: [PATCH 277/341] 8273456: Do not hold ttyLock around stack walking 8273629: compiler/uncommontrap/TestDeoptOOM.java fails with release VMs Reviewed-by: lucy, phh Backport-of: 461a467f91ba19ae35d7833b7d3e74f62f52e19c --- src/hotspot/share/prims/whitebox.cpp | 11 +- src/hotspot/share/runtime/deoptimization.cpp | 121 +++++++++--------- src/hotspot/share/runtime/deoptimization.hpp | 1 - .../compiler/uncommontrap/TestDeoptOOM.java | 15 ++- 4 files changed, 79 insertions(+), 69 deletions(-) diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 5a610227e7c75..319e18dab8f91 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -2318,22 +2318,19 @@ WB_ENTRY(void, WB_CheckThreadObjOfTerminatingThread(JNIEnv* env, jobject wb, job WB_END WB_ENTRY(void, WB_VerifyFrames(JNIEnv* env, jobject wb, jboolean log, jboolean update_map)) - intx tty_token = -1; - if (log) { - tty_token = ttyLocker::hold_tty(); - tty->print_cr("[WhiteBox::VerifyFrames] Walking Frames"); - } ResourceMark rm; // for verify + stringStream st; for (StackFrameStream fst(JavaThread::current(), update_map, true); !fst.is_done(); fst.next()) { frame* current_frame = fst.current(); if (log) { - current_frame->print_value(); + current_frame->print_value_on(&st, NULL); } current_frame->verify(fst.register_map()); } if (log) { + tty->print_cr("[WhiteBox::VerifyFrames] Walking Frames"); + tty->print_raw(st.as_string()); tty->print_cr("[WhiteBox::VerifyFrames] Done"); - ttyLocker::release_tty(tty_token); } WB_END diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index 852186aa272bb..c8357b1927a51 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -144,14 +144,16 @@ int Deoptimization::UnrollBlock::size_of_frames() const { void Deoptimization::UnrollBlock::print() { - ttyLocker ttyl; - tty->print_cr("UnrollBlock"); - tty->print_cr(" size_of_deoptimized_frame = %d", _size_of_deoptimized_frame); - tty->print( " frame_sizes: "); + ResourceMark rm; + stringStream st; + st.print_cr("UnrollBlock"); + st.print_cr(" size_of_deoptimized_frame = %d", _size_of_deoptimized_frame); + st.print( " frame_sizes: "); for (int index = 0; index < number_of_frames(); index++) { - tty->print(INTX_FORMAT " ", frame_sizes()[index]); + st.print(INTX_FORMAT " ", frame_sizes()[index]); } - tty->cr(); + st.cr(); + tty->print_raw(st.as_string()); } @@ -180,6 +182,38 @@ JRT_BLOCK_ENTRY(Deoptimization::UnrollBlock*, Deoptimization::fetch_unroll_info( JRT_END #if COMPILER2_OR_JVMCI +#ifndef PRODUCT +// print information about reallocated objects +static void print_objects(JavaThread* deoptee_thread, + GrowableArray* objects, bool realloc_failures) { + ResourceMark rm; + stringStream st; // change to logStream with logging + st.print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, p2i(deoptee_thread)); + fieldDescriptor fd; + + for (int i = 0; i < objects->length(); i++) { + ObjectValue* sv = (ObjectValue*) objects->at(i); + Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()()); + Handle obj = sv->value(); + + st.print(" object <" INTPTR_FORMAT "> of type ", p2i(sv->value()())); + k->print_value_on(&st); + assert(obj.not_null() || realloc_failures, "reallocation was missed"); + if (obj.is_null()) { + st.print(" allocation failed"); + } else { + st.print(" allocated (%d bytes)", obj->size() * HeapWordSize); + } + st.cr(); + + if (Verbose && !obj.is_null()) { + k->oop_print_on(obj(), &st); + } + } + tty->print_raw(st.as_string()); +} +#endif + static bool rematerialize_objects(JavaThread* thread, int exec_mode, CompiledMethod* compiled_method, frame& deoptee, RegisterMap& map, GrowableArray* chunk, bool& deoptimized_objects) { @@ -211,7 +245,6 @@ static bool rematerialize_objects(JavaThread* thread, int exec_mode, CompiledMet return_value = Handle(thread, result); assert(Universe::heap()->is_in_or_null(result), "must be heap pointer"); if (TraceDeoptimization) { - ttyLocker ttyl; tty->print_cr("SAVED OOP RESULT " INTPTR_FORMAT " in thread " INTPTR_FORMAT, p2i(result), p2i(thread)); } } @@ -232,9 +265,7 @@ static bool rematerialize_objects(JavaThread* thread, int exec_mode, CompiledMet Deoptimization::reassign_fields(&deoptee, &map, objects, realloc_failures, skip_internal); #ifndef PRODUCT if (TraceDeoptimization) { - ttyLocker ttyl; - tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, p2i(deoptee_thread)); - Deoptimization::print_objects(objects, realloc_failures); + print_objects(deoptee_thread, objects, realloc_failures); } #endif } @@ -264,29 +295,31 @@ static void restore_eliminated_locks(JavaThread* thread, GrowableArraylength(); j++) { MonitorInfo* mi = monitors->at(j); if (mi->eliminated()) { if (first) { first = false; - tty->print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT, p2i(thread)); + st.print_cr("RELOCK OBJECTS in thread " INTPTR_FORMAT, p2i(thread)); } if (exec_mode == Deoptimization::Unpack_none) { ObjectMonitor* monitor = deoptee_thread->current_waiting_monitor(); if (monitor != NULL && monitor->object() == mi->owner()) { - tty->print_cr(" object <" INTPTR_FORMAT "> DEFERRED relocking after wait", p2i(mi->owner())); + st.print_cr(" object <" INTPTR_FORMAT "> DEFERRED relocking after wait", p2i(mi->owner())); continue; } } if (mi->owner_is_scalar_replaced()) { Klass* k = java_lang_Class::as_Klass(mi->owner_klass()); - tty->print_cr(" failed reallocation for klass %s", k->external_name()); + st.print_cr(" failed reallocation for klass %s", k->external_name()); } else { - tty->print_cr(" object <" INTPTR_FORMAT "> locked", p2i(mi->owner())); + st.print_cr(" object <" INTPTR_FORMAT "> locked", p2i(mi->owner())); } } } + tty->print_raw(st.as_string()); } #endif // !PRODUCT } @@ -612,7 +645,6 @@ Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread if (array->frames() > 1) { if (VerifyStack && TraceDeoptimization) { - ttyLocker ttyl; tty->print_cr("Deoptimizing method containing inlining"); } } @@ -721,7 +753,6 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m #ifndef PRODUCT if (TraceDeoptimization) { - ttyLocker ttyl; tty->print_cr("DEOPT UNPACKING thread " INTPTR_FORMAT " vframeArray " INTPTR_FORMAT " mode %d", p2i(thread), p2i(array), exec_mode); } @@ -844,8 +875,6 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m (iframe->interpreter_frame_expression_stack_size() == mask.expression_stack_size() + cur_invoke_parameter_size)) )) { { - ttyLocker ttyl; - // Print out some information that will help us debug the problem tty->print_cr("Wrong number of expression stack elements during deoptimization"); tty->print_cr(" Error occurred while verifying frame %d (0..%d, 0 is topmost)", i, cur_array->frames() - 1); @@ -870,7 +899,7 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m tty->print_cr(" %s (bci %d)", el->method()->name_and_sig_as_C_string(), el->bci()); } cur_array->print_on_2(tty); - } // release tty lock before calling guarantee + } guarantee(false, "wrong number of expression stack elements during deopt"); } VerifyOopClosure verify; @@ -1499,34 +1528,6 @@ bool Deoptimization::relock_objects(JavaThread* thread, GrowableArray* objects, bool realloc_failures) { - fieldDescriptor fd; - - for (int i = 0; i < objects->length(); i++) { - ObjectValue* sv = (ObjectValue*) objects->at(i); - Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()()); - Handle obj = sv->value(); - - tty->print(" object <" INTPTR_FORMAT "> of type ", p2i(sv->value()())); - k->print_value(); - assert(obj.not_null() || realloc_failures, "reallocation was missed"); - if (obj.is_null()) { - tty->print(" allocation failed"); - } else { - tty->print(" allocated (%d bytes)", obj->size() * HeapWordSize); - } - tty->cr(); - - if (Verbose && !obj.is_null()) { - k->oop_print_on(obj(), tty); - } - } -} -#endif #endif // COMPILER2_OR_JVMCI vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray* chunk, bool realloc_failures) { @@ -1534,14 +1535,15 @@ vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, Re #ifndef PRODUCT if (PrintDeoptimizationDetails) { - ttyLocker ttyl; - tty->print("DEOPT PACKING thread " INTPTR_FORMAT " ", p2i(thread)); - fr.print_on(tty); - tty->print_cr(" Virtual frames (innermost first):"); + ResourceMark rm; + stringStream st; + st.print("DEOPT PACKING thread " INTPTR_FORMAT " ", p2i(thread)); + fr.print_on(&st); + st.print_cr(" Virtual frames (innermost first):"); for (int index = 0; index < chunk->length(); index++) { compiledVFrame* vf = chunk->at(index); - tty->print(" %2d - ", index); - vf->print_value(); + st.print(" %2d - ", index); + vf->print_value_on(&st); int bci = chunk->at(index)->raw_bci(); const char* code_name; if (bci == SynchronizationEntryBCI) { @@ -1550,13 +1552,14 @@ vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, Re Bytecodes::Code code = vf->method()->code_at(bci); code_name = Bytecodes::name(code); } - tty->print(" - %s", code_name); - tty->print_cr(" @ bci %d ", bci); + st.print(" - %s", code_name); + st.print_cr(" @ bci %d ", bci); if (Verbose) { - vf->print(); - tty->cr(); + vf->print_on(&st); + st.cr(); } } + tty->print_raw(st.as_string()); } #endif @@ -1579,7 +1582,6 @@ vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, Re #ifndef PRODUCT if (PrintDeoptimizationDetails) { - ttyLocker ttyl; tty->print_cr(" Created vframeArray " INTPTR_FORMAT, p2i(array)); } #endif // PRODUCT @@ -1980,7 +1982,6 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr bool is_receiver_constraint_failure = COMPILER2_PRESENT(VerifyReceiverTypes &&) (reason == Deoptimization::Reason_receiver_constraint); if (TraceDeoptimization || is_receiver_constraint_failure) { - ttyLocker ttyl; tty->print_cr(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=" INTPTR_FORMAT ", method=%s" JVMCI_ONLY(", debug_id=%d"), trap_scope->bci(), p2i(fr.pc()), fr.pc() - nm->code_begin(), trap_scope->method()->name_and_sig_as_C_string() #if INCLUDE_JVMCI , debug_id diff --git a/src/hotspot/share/runtime/deoptimization.hpp b/src/hotspot/share/runtime/deoptimization.hpp index 4452e7a15572e..75007d8fc33e5 100644 --- a/src/hotspot/share/runtime/deoptimization.hpp +++ b/src/hotspot/share/runtime/deoptimization.hpp @@ -191,7 +191,6 @@ class Deoptimization : AllStatic { static bool relock_objects(JavaThread* thread, GrowableArray* monitors, JavaThread* deoptee_thread, frame& fr, int exec_mode, bool realloc_failures); static void pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array); - NOT_PRODUCT(static void print_objects(GrowableArray* objects, bool realloc_failures);) #endif // COMPILER2_OR_JVMCI public: diff --git a/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java b/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java index d02911c343cdd..43ccca32c9994 100644 --- a/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java +++ b/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,19 @@ * compiler.uncommontrap.TestDeoptOOM */ +/* + * @test + * @bug 8273456 + * @summary Test that ttyLock isn't held when taking StackWatermark_lock + * @requires !vm.graal.enabled & vm.gc.Z + * @run main/othervm -XX:-BackgroundCompilation -Xmx128M -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack + * -XX:CompileCommand=exclude,compiler.uncommontrap.TestDeoptOOM::main + * -XX:CompileCommand=exclude,compiler.uncommontrap.TestDeoptOOM::m9_1 + * -XX:+UnlockDiagnosticVMOptions + * -XX:+UseZGC -XX:+LogCompilation -XX:+PrintDeoptimizationDetails -XX:+TraceDeoptimization -XX:+Verbose + * compiler.uncommontrap.TestDeoptOOM + */ + package compiler.uncommontrap; public class TestDeoptOOM { From 5a9cebac5f721efcae9124b0c700ae3969cb0273 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 26 Oct 2023 18:15:51 +0000 Subject: [PATCH 278/341] 8228990: JFR: TestNetworkUtilizationEvent.java expects 2+ Network interfaces on Linux but finding 1 Backport-of: e21b527b185888699d0bbb64c5e6bfacab337ce4 --- test/jdk/ProblemList.txt | 1 - .../runtime/TestNetworkUtilizationEvent.java | 19 ++++--------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index f8b2c057cfc60..bc73a1d5386e1 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -797,7 +797,6 @@ javax/script/Test7.java 8239361 generic- # jdk_jfr -jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java 8228990,8229370 generic-all jdk/jfr/event/compiler/TestCodeSweeper.java 8225209 generic-all jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows-all jdk/jfr/startupargs/TestStartName.java 8214685 windows-x64 diff --git a/test/jdk/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java b/test/jdk/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java index 8c77212c352bb..a1b5485a5bd7c 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java @@ -59,25 +59,17 @@ public static void main(String[] args) throws Throwable { String msg = "hello!"; byte[] buf = msg.getBytes(); forceEndChunk(); - // Send a few packets both to the loopback address as well to an - // external + // Send a few packets to the loopback address DatagramPacket packet = new DatagramPacket(buf, buf.length, InetAddress.getLoopbackAddress(), 12345); for (int i = 0; i < packetSendCount; ++i) { socket.send(packet); } - packet = new DatagramPacket(buf, buf.length, InetAddress.getByName("10.0.0.0"), 12345); - for (int i = 0; i < packetSendCount; ++i) { - socket.send(packet); - } forceEndChunk(); socket.close(); - // Now there should have been traffic on at least two different - // interfaces recording.stop(); Set networkInterfaces = new HashSet<>(); List events = Events.fromRecording(recording); - Events.hasEvents(events); for (RecordedEvent event : events) { System.out.println(event); Events.assertField(event, "writeRate").atLeast(0L).atMost(1000L * Integer.MAX_VALUE); @@ -87,13 +79,10 @@ public static void main(String[] args) throws Throwable { networkInterfaces.add(event.getString("networkInterface")); } } - - if (Platform.isWindows()) { - // Windows does not track statistics for the loopback - // interface + // Windows does not track statistics for the loopback + // interface + if (!Platform.isWindows()) { Asserts.assertGreaterThanOrEqual(networkInterfaces.size(), 1); - } else { - Asserts.assertGreaterThanOrEqual(networkInterfaces.size(), 2); } } From f85053f578125d1af7c3c762d966fee8283a6ce2 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 26 Oct 2023 18:18:59 +0000 Subject: [PATCH 279/341] 8291911: java/io/File/GetXSpace.java fails with "53687091200 != 161051996160" 8298619: java/io/File/GetXSpace.java is failing 8305646: compile error on Alpine with gcc12 after 8298619 in libGetXSpace.c 8309216: Cast from jchar* to char* in test java/io/GetXSpace.java Reviewed-by: lucy Backport-of: 749335d34ac570760279ac81308d5d323aba4067 --- make/test/JtregNativeJdk.gmk | 2 + test/jdk/java/io/File/GetXSpace.java | 198 ++++++++++++++++----------- test/jdk/java/io/File/libGetXSpace.c | 164 ++++++++++++++++++++++ 3 files changed, 286 insertions(+), 78 deletions(-) create mode 100644 test/jdk/java/io/File/libGetXSpace.c diff --git a/make/test/JtregNativeJdk.gmk b/make/test/JtregNativeJdk.gmk index 270ff93d1475d..c62d9d76c55de 100644 --- a/make/test/JtregNativeJdk.gmk +++ b/make/test/JtregNativeJdk.gmk @@ -66,9 +66,11 @@ ifeq ($(call isTargetOs, windows), true) BUILD_JDK_JTREG_EXECUTABLES_LIBS_exeCallerAccessTest := jvm.lib BUILD_JDK_JTREG_EXECUTABLES_LIBS_exerevokeall := advapi32.lib BUILD_JDK_JTREG_LIBRARIES_CFLAGS_libAsyncStackWalk := /EHsc + BUILD_JDK_JTREG_LIBRARIES_LIBS_libGetXSpace := $(WIN_LIB_JAVA) else BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava BUILD_JDK_JTREG_LIBRARIES_LIBS_libDirectIO := -ljava + BUILD_JDK_JTREG_LIBRARIES_LIBS_libGetXSpace := -ljava BUILD_JDK_JTREG_EXCLUDE += exerevokeall.c ifeq ($(call isTargetOs, linux), true) BUILD_JDK_JTREG_LIBRARIES_LIBS_libInheritedChannel := -ljava diff --git a/test/jdk/java/io/File/GetXSpace.java b/test/jdk/java/io/File/GetXSpace.java index ac80bdf68fd2c..79fd10d453346 100644 --- a/test/jdk/java/io/File/GetXSpace.java +++ b/test/jdk/java/io/File/GetXSpace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ * @summary Basic functionality of File.get-X-Space methods. * @library .. /test/lib * @build jdk.test.lib.Platform - * @run main/othervm -Djava.security.manager=allow GetXSpace + * @run main/othervm/native -Djava.security.manager=allow GetXSpace */ import java.io.BufferedReader; @@ -52,13 +52,13 @@ @SuppressWarnings("removal") public class GetXSpace { + static { + System.loadLibrary("GetXSpace"); + } private static SecurityManager [] sma = { null, new Allow(), new DenyFSA(), new DenyRead() }; - // FileSystem Total Used Available Use% MountedOn - private static final Pattern DF_PATTERN = Pattern.compile("([^\\s]+)\\s+(\\d+)\\s+\\d+\\s+(\\d+)\\s+\\d+%\\s+([^\\s].*)\n"); - private static int fail = 0; private static int pass = 0; private static Throwable first; @@ -100,39 +100,46 @@ private static void setFirst(String s) { } private static class Space { - private static final long KSIZE = 1024; private final String name; + private final long size; private final long total; private final long free; + private final long available; - Space(String total, String free, String name) { - try { - this.total = Long.parseLong(total) * KSIZE; - this.free = Long.parseLong(free) * KSIZE; - } catch (NumberFormatException x) { - throw new RuntimeException("the regex should have caught this", x); - } + Space(String name) { this.name = name; + long[] sizes = new long[4]; + if (getSpace0(name, sizes)) + System.err.println("WARNING: total space is estimated"); + this.size = sizes[0]; + this.total = sizes[1]; + this.free = sizes[2]; + this.available = sizes[3]; } String name() { return name; } + long size() { return size; } long total() { return total; } + long available() { return available; } long free() { return free; } + boolean woomFree(long freeSpace) { - return ((freeSpace >= (free / 10)) && (freeSpace <= (free * 10))); + return ((freeSpace >= (available / 10)) && + (freeSpace <= (available * 10))); } + public String toString() { - return String.format("%s (%d/%d)", name, free, total); + return String.format("%s (%d/%d/%d)", name, total, free, available); } } - private static ArrayList space(String f) throws IOException { + private static void diskFree() throws IOException { ArrayList al = new ArrayList<>(); - String cmd = "df -k -P" + (f == null ? "" : " " + f); + String cmd = "fsutil volume diskFree C:\\"; StringBuilder sb = new StringBuilder(); Process p = Runtime.getRuntime().exec(cmd); - try (BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()))) { + try (BufferedReader in = p.inputReader()) { String s; int i = 0; while ((s = in.readLine()) != null) { @@ -142,33 +149,18 @@ private static ArrayList space(String f) throws IOException { } } out.println(sb); + } - Matcher m = DF_PATTERN.matcher(sb); - int j = 0; - while (j < sb.length()) { - if (m.find(j)) { - // swap can change while this test is running - if (!m.group(1).equals("swap")) { - String name = f; - if (name == null) { - // cygwin's df lists windows path as FileSystem (1st group) - name = Platform.isWindows() ? m.group(1) : m.group(4); - } - al.add(new Space(m.group(2), m.group(3), name));; - } - j = m.end(); - } else { - throw new RuntimeException("unrecognized df output format: " - + "charAt(" + j + ") = '" - + sb.charAt(j) + "'"); - } - } + private static ArrayList paths() throws IOException { + ArrayList al = new ArrayList<>(); - if (al.size() == 0) { - // df did not produce output - String name = (f == null ? "" : f); - al.add(new Space("0", "0", name)); + File[] roots = File.listRoots(); + long[] space = new long[4]; + for (File root : roots) { + String path = root.toString(); + al.add(path); } + return al; } @@ -208,14 +200,15 @@ private static void compare(Space s) { long fs = f.getFreeSpace(); long us = f.getUsableSpace(); - out.format("%s:%n", s.name()); - String fmt = " %-4s total= %12d free = %12d usable = %12d%n"; - out.format(fmt, "df", s.total(), 0, s.free()); - out.format(fmt, "getX", ts, fs, us); + out.format("%s (%d):%n", s.name(), s.size()); + String fmt = " %-4s total = %12d free = %12d usable = %12d%n"; + out.format(fmt, "getSpace0", s.total(), s.free(), s.available()); + out.format(fmt, "getXSpace", ts, fs, us); // If the file system can dynamically change size, this check will fail. // This can happen on macOS for the /dev files system. - if (ts != s.total() && (!Platform.isOSX() || !s.name().equals("/dev"))) { + if (ts != s.total() + && (!Platform.isOSX() || !s.name().equals("/dev"))) { long blockSize = 1; long numBlocks = 0; try { @@ -232,34 +225,76 @@ private static void compare(Space s) { throw new RuntimeException(e); } - // On macOS, the number of 1024 byte blocks might be incorrectly - // calculated by 'df' using integer division by 2 of the number of - // 512 byte blocks, resulting in a size smaller than the actual - // value when the number of blocks is odd. - if (!Platform.isOSX() || blockSize != 512 || numBlocks % 2 == 0 - || ts - s.total() != 512) { - fail(s.name(), s.total(), "!=", ts); + if (Platform.isWindows()) { + if (ts > s.total()) { + fail(s.name() + " total space", ts, ">", s.total()); + } + } else if (ts != s.total()) { + fail(s.name() + " total space", ts, "!=", s.total()); } } else { pass(); } - // unix df returns statvfs.f_bavail + // unix usable space is from statvfs.f_bavail long tsp = (!Platform.isWindows() ? us : fs); if (!s.woomFree(tsp)) { - fail(s.name(), s.free(), "??", tsp); + fail(s.name(), s.available(), "??", tsp); } else { pass(); } - if (fs > s.total()) { - fail(s.name(), s.total(), ">", fs); + // + // Invariants are: + // total space <= size + // total space == size (Unix) + // free space <= total space (if no quotas in effect) (Windows) + // free space < size (if quotas in effect) (Windows) + // usable space <= total space + // usable space <= free space + // + + // total space <= size + if (ts > s.size()) { + fail(s.name() + " size", ts, ">", s.size()); } else { pass(); } + // On Unix the total space should always be the volume size + if (Platform.isWindows()) { + // ts != s.size() indicates that quotas are in effect + if (ts == s.size() && fs > s.total()) { + fail(s.name() + " free space", fs, ">", s.total()); + } else if (ts < s.size() && fs > s.size()) { + fail(s.name() + " free space (quota)", fs, ">", s.size()); + } else { + pass(); + } + } else { // not Windows + if (ts != s.size()) { + fail(s.name() + " total space", ts, "!=", s.size()); + } else { + pass(); + } + } + + // usable space <= total space if (us > s.total()) { - fail(s.name(), s.total(), ">", us); + fail(s.name() + " usable space", us, ">", s.total()); + } else { + pass(); + } + + // usable space <= free space + if (us > s.free()) { + // free and usable change dynamically + System.err.println("Warning: us > s.free()"); + if (1.0 - Math.abs((double)s.free()/(double)us) > 0.01) { + fail(s.name() + " usable vs. free space", us, ">", s.free()); + } else { + pass(); + } } else { pass(); } @@ -316,14 +351,14 @@ private static class Deny extends SecurityManager { public void checkPermission(Permission p) { if (p.implies(new RuntimePermission("setSecurityManager")) || p.implies(new RuntimePermission("getProtectionDomain"))) - return; + return; super.checkPermission(p); } public void checkPermission(Permission p, Object context) { if (p.implies(new RuntimePermission("setSecurityManager")) || p.implies(new RuntimePermission("getProtectionDomain"))) - return; + return; super.checkPermission(p, context); } } @@ -355,17 +390,11 @@ public void checkRead(String file) { private static int testFile(Path dir) { String dirName = dir.toString(); out.format("--- Testing %s%n", dirName); - ArrayList l; - try { - l = space(dirName); - } catch (IOException x) { - throw new RuntimeException(dirName + " can't get file system information", x); - } - compare(l.get(0)); + compare(new Space(dir.getRoot().toString())); if (fail != 0) { err.format("%d tests: %d failure(s); first: %s%n", - fail + pass, fail, first); + fail + pass, fail, first); } else { out.format("all %d tests passed%n", fail + pass); } @@ -373,13 +402,16 @@ private static int testFile(Path dir) { return fail != 0 ? 1 : 0; } - private static int testDF() { - out.println("--- Testing df"); - // Find all of the partitions on the machine and verify that the size - // returned by "df" is equivalent to File.getXSpace() values. - ArrayList l; + private static int testVolumes() { + out.println("--- Testing volumes"); + // Find all of the partitions on the machine and verify that the sizes + // returned by File::getXSpace are equivalent to those from getSpace0 + ArrayList l; try { - l = space(null); + l = paths(); + if (Platform.isWindows()) { + diskFree(); + } } catch (IOException x) { throw new RuntimeException("can't get file system information", x); } @@ -395,7 +427,8 @@ private static int testDF() { out.format("%nSecurityManager = %s%n" , (sm == null ? "null" : sm.getClass().getName())); - for (var s : l) { + for (var p : l) { + Space s = new Space(p); if (sm instanceof Deny) { tryCatch(s); } else { @@ -410,7 +443,7 @@ private static int testDF() { if (fail != 0) { err.format("%d tests: %d failure(s); first: %s%n", - fail + pass, fail, first); + fail + pass, fail, first); } else { out.format("all %d tests passed%n", fail + pass); } @@ -433,7 +466,7 @@ private static void allow(Path path) throws IOException { } public static void main(String[] args) throws Exception { - int failedTests = testDF(); + int failedTests = testVolumes(); reset(); Path tmpDir = Files.createTempDirectory(null); @@ -452,4 +485,13 @@ public static void main(String[] args) throws Exception { throw new RuntimeException(failedTests + " test(s) failed"); } } + + // + // root the root of the volume + // size[0] total size: number of bytes in the volume + // size[1] total space: number of bytes visible to the caller + // size[2] free space: number of free bytes in the volume + // size[3] usable space: number of bytes available to the caller + // + private static native boolean getSpace0(String root, long[] space); } diff --git a/test/jdk/java/io/File/libGetXSpace.c b/test/jdk/java/io/File/libGetXSpace.c new file mode 100644 index 0000000000000..7a6cdf0d1dcf3 --- /dev/null +++ b/test/jdk/java/io/File/libGetXSpace.c @@ -0,0 +1,164 @@ +/* + * 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. + */ +#include +#include "jni.h" +#include "jni_util.h" +#ifdef _WIN64 +#include +#include +#include +#else +#include +#include +#if __APPLE__ +#include +#include +#else +#include +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _WIN64 +jboolean initialized = JNI_FALSE; +BOOL(WINAPI * pfnGetDiskSpaceInformation)(LPCWSTR, LPVOID) = NULL; +#endif + +// +// root the root of the volume +// sizes[0] total size: number of bytes in the volume +// sizes[1] total space: number of bytes visible to the caller +// sizes[2] free space: number of free bytes in the volume +// sizes[3] usable space: number of bytes available to the caller +// +JNIEXPORT jboolean JNICALL +Java_GetXSpace_getSpace0 + (JNIEnv *env, jclass cls, jstring root, jlongArray sizes) +{ + jboolean totalSpaceIsEstimated = JNI_FALSE; + jlong array[4]; + const jchar* strchars = (*env)->GetStringChars(env, root, NULL); + if (strchars == NULL) { + JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", + "GetStringChars"); + return JNI_FALSE; + } + +#ifdef _WIN64 + if (initialized == JNI_FALSE) { + initialized = JNI_TRUE; + HMODULE hmod = GetModuleHandleW(L"kernel32"); + if (hmod != NULL) { + *(FARPROC*)&pfnGetDiskSpaceInformation = + GetProcAddress(hmod, "GetDiskSpaceInformationW"); + } + } + + LPCWSTR path = (LPCWSTR)strchars; + + if (pfnGetDiskSpaceInformation != NULL) { + // use GetDiskSpaceInformationW + DISK_SPACE_INFORMATION diskSpaceInfo; + BOOL hres = pfnGetDiskSpaceInformation(path, &diskSpaceInfo); + (*env)->ReleaseStringChars(env, root, strchars); + if (FAILED(hres)) { + JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", + "GetDiskSpaceInformationW"); + return totalSpaceIsEstimated; + } + + ULONGLONG bytesPerAllocationUnit = + diskSpaceInfo.SectorsPerAllocationUnit*diskSpaceInfo.BytesPerSector; + array[0] = (jlong)(diskSpaceInfo.ActualTotalAllocationUnits* + bytesPerAllocationUnit); + array[1] = (jlong)(diskSpaceInfo.CallerTotalAllocationUnits* + bytesPerAllocationUnit); + array[2] = (jlong)(diskSpaceInfo.ActualAvailableAllocationUnits* + bytesPerAllocationUnit); + array[3] = (jlong)(diskSpaceInfo.CallerAvailableAllocationUnits* + bytesPerAllocationUnit); + } else { + totalSpaceIsEstimated = JNI_TRUE; + + // if GetDiskSpaceInformationW is unavailable ("The specified + // procedure could not be found"), fall back to GetDiskFreeSpaceExW + ULARGE_INTEGER freeBytesAvailable; + ULARGE_INTEGER totalNumberOfBytes; + ULARGE_INTEGER totalNumberOfFreeBytes; + + BOOL hres = GetDiskFreeSpaceExW(path, &freeBytesAvailable, + &totalNumberOfBytes, &totalNumberOfFreeBytes); + (*env)->ReleaseStringChars(env, root, strchars); + if (FAILED(hres)) { + JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", + "GetDiskFreeSpaceExW"); + return totalSpaceIsEstimated; + } + + // If quotas are in effect, it is impossible to obtain the volume size, + // so estimate it as free + used = free + (visible - available) + ULONGLONG used = totalNumberOfBytes.QuadPart - freeBytesAvailable.QuadPart; + array[0] = (jlong)(totalNumberOfFreeBytes.QuadPart + used); + array[1] = (jlong)totalNumberOfBytes.QuadPart; + array[2] = (jlong)totalNumberOfFreeBytes.QuadPart; + array[3] = (jlong)freeBytesAvailable.QuadPart; + } +#else + int len = (int)(*env)->GetStringLength(env, root); + char* chars = (char*)malloc((len + 1)*sizeof(char)); + if (chars == NULL) { + (*env)->ReleaseStringChars(env, root, strchars); + JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", + "malloc"); + return JNI_FALSE; + } + + for (int i = 0; i < len; i++) { + chars[i] = (char)strchars[i]; + } + chars[len] = '\0'; + (*env)->ReleaseStringChars(env, root, strchars); + + struct statfs buf; + int result = statfs((const char*)chars, &buf); + free(chars); + if (result < 0) { + JNU_ThrowByNameWithLastError(env, "java/lang/RuntimeException", + strerror(errno)); + return totalSpaceIsEstimated; + } + + array[0] = (jlong)(buf.f_blocks*buf.f_bsize); + array[1] = array[0]; // number visible is the same as the total size + array[2] = (jlong)(buf.f_bfree*buf.f_bsize); + array[3] = (jlong)(buf.f_bavail*buf.f_bsize); +#endif + (*env)->SetLongArrayRegion(env, sizes, 0, 4, array); + return totalSpaceIsEstimated; +} +#ifdef __cplusplus +} +#endif From fc288568f2c589975463d30f8c6d0e2484f0bf14 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 26 Oct 2023 18:20:58 +0000 Subject: [PATCH 280/341] 8308910: Allow executeAndLog to accept running process Reviewed-by: lucy Backport-of: 024d9b131d6c2d5ee6c8cafdb05b9e9e299d588e --- test/lib/jdk/test/lib/cds/CDSTestUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/lib/jdk/test/lib/cds/CDSTestUtils.java b/test/lib/jdk/test/lib/cds/CDSTestUtils.java index 9840da9fa89cb..4ebe24915849a 100644 --- a/test/lib/jdk/test/lib/cds/CDSTestUtils.java +++ b/test/lib/jdk/test/lib/cds/CDSTestUtils.java @@ -594,8 +594,12 @@ public static File getSourceFile(String name) { // ============================= Logging public static OutputAnalyzer executeAndLog(ProcessBuilder pb, String logName) throws Exception { + return executeAndLog(pb.start(), logName); + } + + public static OutputAnalyzer executeAndLog(Process process, String logName) throws Exception { long started = System.currentTimeMillis(); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); + OutputAnalyzer output = new OutputAnalyzer(process); String logFileNameStem = String.format("%04d", getNextLogCounter()) + "-" + logName; From 3af0c4fb872a12dcf5c4356f225439fc42a68703 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 26 Oct 2023 18:23:26 +0000 Subject: [PATCH 281/341] 8317373: Add Telia Root CA v2 Reviewed-by: phh Backport-of: d3ebb4a155be8ed93e79b6b58c645e861ec30267 --- make/data/cacerts/teliarootcav2 | 39 +++++++++++++++++++ .../certification/CAInterop.java | 14 +++++++ .../security/lib/cacerts/VerifyCACerts.java | 8 ++-- 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 make/data/cacerts/teliarootcav2 diff --git a/make/data/cacerts/teliarootcav2 b/make/data/cacerts/teliarootcav2 new file mode 100644 index 0000000000000..24ed624291f8e --- /dev/null +++ b/make/data/cacerts/teliarootcav2 @@ -0,0 +1,39 @@ +Owner: CN=Telia Root CA v2, O=Telia Finland Oyj, C=FI +Issuer: CN=Telia Root CA v2, O=Telia Finland Oyj, C=FI +Serial number: 1675f27d6fe7ae3e4acbe095b059e +Valid from: Thu Nov 29 11:55:54 GMT 2018 until: Sun Nov 29 11:55:54 GMT 2043 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFdDCCA1ygAwIBAgIPAWd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5MB0GA1UdDgQWBBRy +rOQzeapFh/b9rB2e1scvhtgkOTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw +AwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAoDtZpwmUPjaE0n4vOaWWl/oRrfxn83EJ +8rKJhGdEr7nv7ZbsnGTbMjBvZ5qsfl+yqwE2foH65IRe0qw24GtixX1LDoJt0nZi +0f6X+J8wfBj5tFJ3gh1229MdqfDBmgC9bXXYfef6xzijnHDoRnkDry5023X4blMM +A8iZGok1GTzTyVR8qPAs5m4HeW9q4ebqkYJpCh3DflminmtGFZhb069GHWLIzoBS +SRE/yQQSwxN8PzuKlts8oB4KtItUsiRnDe+Cy748fdHif64W1lZYudogsYMVoe+K +TTJvQS8TUoKU1xrBeKJR3Stwbbca+few4GeXVtt8YVMJAygCQMez2P2ccGrGKMOF +6eLtGpOg3kuYooQ+BXcBlj37tCAPnHICehIv1aO6UXivKitEZU61/Qrowc15h2Er +3oBXRb9n8ZuRXqWk7FlIEA04x7D6w0RtBPV4UBySllva9bguulvP5fBqnUsvWHMt +Ty3EHD70sz+rFQ47GUGKpMFXEmZxTPpT41frYpUJnlTd0cI8Vzy9OK2YZLe4A5pT +VmBds9hCG1xLEooc6+t9xnppxyd/pPiL8uSUZodL6ZQHCRJ5irLrdATczvREWeAW +ysUsWNc8e89ihmpQfTU2Zqf7N+cox9jQraVplI/owd8k+BsHMYeB2F326CjYSlKA +rBPuUBQemMc= +-----END CERTIFICATE----- diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java index 2c6d787afad67..dbdcb810c478d 100644 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java @@ -392,6 +392,16 @@ * @run main/othervm -Djava.security.debug=certpath CAInterop affirmtrustpremiumeccca CRL */ +/* + * @test id=teliarootcav2 + * @bug 8317373 + * @summary Interoperability tests with Telia Root CA V2 + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop teliarootcav2 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop teliarootcav2 CRL + */ + /** * Collection of certificate validation tests for interoperability with external CAs */ @@ -533,6 +543,10 @@ private CATestURLs getTestURLs(String alias) { new CATestURLs("https://validpremiumecc.affirmtrust.com", "https://revokedpremiumecc.affirmtrust.com"); + case "teliarootcav2" -> + new CATestURLs("https://juolukka.cover.telia.fi:10600", + "https://juolukka.cover.telia.fi:10601"); + default -> throw new RuntimeException("No test setup found for: " + alias); }; } diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java index 02831a9deaf5c..f8d8be1f425be 100644 --- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java +++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java @@ -28,7 +28,7 @@ * 8209452 8209506 8210432 8195793 8216577 8222089 8222133 8222137 8222136 * 8223499 8225392 8232019 8234245 8233223 8225068 8225069 8243321 8243320 * 8243559 8225072 8258630 8259312 8256421 8225081 8225082 8225083 8245654 - * 8305975 8304760 8307134 8295894 8314960 + * 8305975 8304760 8307134 8295894 8314960 8317373 * @summary Check root CA entries in cacerts file */ import java.io.ByteArrayInputStream; @@ -47,12 +47,12 @@ public class VerifyCACerts { + File.separator + "security" + File.separator + "cacerts"; // The numbers of certs now. - private static final int COUNT = 97; + private static final int COUNT = 98; // SHA-256 of cacerts, can be generated with // shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95 private static final String CHECKSUM - = "88:72:92:56:FF:E5:A3:E4:39:98:6D:18:0B:BA:CC:0B:66:CB:1D:6D:52:CE:D7:C8:AD:63:B7:F1:5F:02:24:52"; + = "63:A7:1F:4F:8E:4B:A1:04:DE:BB:EC:2E:31:35:5B:5A:19:D4:B1:C0:59:62:B1:13:65:C3:AE:C7:DB:78:9A:1E"; // Hex formatter to upper case with ":" delimiter private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase(); @@ -254,6 +254,8 @@ public class VerifyCACerts { "34:9D:FA:40:58:C5:E2:63:12:3B:39:8A:E7:95:57:3C:4E:13:13:C8:3F:E6:8F:93:55:6C:D5:E8:03:1B:3C:7D"); put("certignarootca [jdk]", "D4:8D:3D:23:EE:DB:50:A4:59:E5:51:97:60:1C:27:77:4B:9D:7B:18:C9:4D:5A:05:95:11:A1:02:50:B9:31:68"); + put("teliarootcav2 [jdk]", + "24:2B:69:74:2F:CB:1E:5B:2A:BF:98:89:8B:94:57:21:87:54:4E:5B:4D:99:11:78:65:73:62:1F:6A:74:B8:2C"); } }; From 03552eea32372d2ef52ef2f29611b16a5a672a47 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 27 Oct 2023 10:53:54 +0000 Subject: [PATCH 282/341] 8314883: Java_java_util_prefs_FileSystemPreferences_lockFile0 write result errno in missing case Backport-of: 97b94cb1cdeba00f4bba7326a300c0336950f3ec --- src/java.prefs/unix/native/libprefs/FileSystemPreferences.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c b/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c index c591f04d30a8f..4e15ddd6e015d 100644 --- a/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c +++ b/src/java.prefs/unix/native/libprefs/FileSystemPreferences.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,7 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, jclass thisclass, jstring java_fname, jint permission, jboolean shared) { const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL); int fd, rc; - int result[2]; + int result[2] = {0, 0}; jintArray javaResult = NULL; int old_umask; FLOCK fl; @@ -90,6 +90,7 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, if (shared == JNI_TRUE) { fd = open(fname, O_RDONLY, 0); + result[1] = errno; } else { old_umask = umask(0); fd = open(fname, O_WRONLY|O_CREAT, permission); From 28e9fd3576ab2df6fa78fead7e40597b5ed4d2dc Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 27 Oct 2023 10:55:58 +0000 Subject: [PATCH 283/341] 8313164: src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp GetRGBPixels adjust releasing of resources Backport-of: b7545a69a27f255cbf26071be5b88f6e3e6b3cd6 --- .../native/libawt/windows/awt_Robot.cpp | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp b/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp index 0afce8727e098..d42c9b149b4ef 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019, 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 @@ -170,6 +170,8 @@ static void GetRGBPixels(jint x, jint y, jint width, jint height, jintArray pixe // create an offscreen bitmap hbitmap = ::CreateCompatibleBitmap(hdcScreen, width, height); if (hbitmap == NULL) { + ::DeleteDC(hdcMem); + ::DeleteDC(hdcScreen); throw std::bad_alloc(); } hOldBitmap = (HBITMAP)::SelectObject(hdcMem, hbitmap); @@ -189,9 +191,21 @@ static void GetRGBPixels(jint x, jint y, jint width, jint height, jintArray pixe static const int BITS_PER_PIXEL = 32; static const int BYTES_PER_PIXEL = BITS_PER_PIXEL/8; - if (!IS_SAFE_SIZE_MUL(width, height)) throw std::bad_alloc(); + if (!IS_SAFE_SIZE_MUL(width, height)) { + ::DeleteObject(hbitmap); + ::DeleteDC(hdcMem); + ::DeleteDC(hdcScreen); + throw std::bad_alloc(); + } + int numPixels = width*height; - if (!IS_SAFE_SIZE_MUL(BYTES_PER_PIXEL, numPixels)) throw std::bad_alloc(); + if (!IS_SAFE_SIZE_MUL(BYTES_PER_PIXEL, numPixels)) { + ::DeleteObject(hbitmap); + ::DeleteDC(hdcMem); + ::DeleteDC(hdcScreen); + throw std::bad_alloc(); + } + int pixelDataSize = BYTES_PER_PIXEL*numPixels; DASSERT(pixelDataSize > 0 && pixelDataSize % 4 == 0); // allocate memory for BITMAPINFO + pixel data @@ -202,6 +216,9 @@ static void GetRGBPixels(jint x, jint y, jint width, jint height, jintArray pixe // See MSDN docs for BITMAPINFOHEADER -bchristi if (!IS_SAFE_SIZE_ADD(sizeof(BITMAPINFOHEADER) + 3 * sizeof(RGBQUAD), pixelDataSize)) { + ::DeleteObject(hbitmap); + ::DeleteDC(hdcMem); + ::DeleteDC(hdcScreen); throw std::bad_alloc(); } BITMAPINFO * pinfo = (BITMAPINFO *)(new BYTE[sizeof(BITMAPINFOHEADER) + 3 * sizeof(RGBQUAD) + pixelDataSize]); From d7dd1f06727cc752c80fd71eee51a7cbe51528ef Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 27 Oct 2023 11:00:25 +0000 Subject: [PATCH 284/341] 8315499: build using devkit on Linux ppc64le RHEL puts path to devkit into libsplashscreen Backport-of: ed2b4673de6893047407c61f82b5e68741459876 --- make/autoconf/lib-x11.m4 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/make/autoconf/lib-x11.m4 b/make/autoconf/lib-x11.m4 index 97a3f24a2dbf7..b1902a432a1e0 100644 --- a/make/autoconf/lib-x11.m4 +++ b/make/autoconf/lib-x11.m4 @@ -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 @@ -35,6 +35,7 @@ AC_DEFUN_ONCE([LIB_SETUP_X11], X_CFLAGS= X_LIBS= else + x_libraries_orig="$x_libraries" if test "x${with_x}" = xno; then AC_MSG_ERROR([It is not possible to disable the use of X11. Remove the --without-x option.]) @@ -48,6 +49,7 @@ AC_DEFUN_ONCE([LIB_SETUP_X11], fi if test "x$x_libraries" = xNONE; then x_libraries="${with_x}/lib" + x_libraries_orig="$x_libraries" fi else # Check if the user has specified sysroot, but not --with-x, --x-includes or --x-libraries. @@ -82,8 +84,8 @@ AC_DEFUN_ONCE([LIB_SETUP_X11], AC_PATH_XTRA # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling - # this doesn't make sense so we remove it. - if test "x$COMPILE_TYPE" = xcross; then + # this doesn't make sense so we remove it; same for sysroot (devkit). + if test "x$COMPILE_TYPE" = xcross || (test "x$SYSROOT" != "x" && test "x$x_libraries_orig" = xNONE); then X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'` fi From 03e32320057884749e9319348a5278d8dd3a3bb1 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 30 Oct 2023 10:02:38 +0000 Subject: [PATCH 285/341] 6445283: ProgressMonitorInputStream not large file aware (>2GB) Backport-of: a17fce7507c7d485d51f98fadd444235ea31058d --- .../swing/ProgressMonitorInputStream.java | 48 ++++++---- .../swing/ProgressMonitor/ProgressTest.java | 90 +++++++++++++++++++ 2 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 test/jdk/javax/swing/ProgressMonitor/ProgressTest.java diff --git a/src/java.desktop/share/classes/javax/swing/ProgressMonitorInputStream.java b/src/java.desktop/share/classes/javax/swing/ProgressMonitorInputStream.java index 86f41552eff3e..d82e2999b8b91 100644 --- a/src/java.desktop/share/classes/javax/swing/ProgressMonitorInputStream.java +++ b/src/java.desktop/share/classes/javax/swing/ProgressMonitorInputStream.java @@ -67,7 +67,8 @@ public class ProgressMonitorInputStream extends FilterInputStream private ProgressMonitor monitor; private int nread = 0; private int size = 0; - + Component parentComponent; + Object message; /** * Constructs an object to monitor the progress of an input stream. @@ -88,6 +89,8 @@ public ProgressMonitorInputStream(Component parentComponent, catch(IOException ioe) { size = 0; } + this.parentComponent = parentComponent; + this.message = message; monitor = new ProgressMonitor(parentComponent, message, null, 0, size); } @@ -119,6 +122,25 @@ public int read() throws IOException { return c; } + private void setProgress(int nr) throws IOException { + if (nr > 0) { + if (nread + nr > nread) { + monitor.setProgress(nread += nr); + } else { + size = in.available(); + nread = 0; + monitor.close(); + monitor = new ProgressMonitor(this.parentComponent, + this.message, null, 0, size); + } + } + if (monitor.isCanceled()) { + InterruptedIOException exc = + new InterruptedIOException("progress"); + exc.bytesTransferred = nread; + throw exc; + } + } /** * Overrides FilterInputStream.read @@ -126,13 +148,7 @@ public int read() throws IOException { */ public int read(byte[] b) throws IOException { int nr = in.read(b); - if (nr > 0) monitor.setProgress(nread += nr); - if (monitor.isCanceled()) { - InterruptedIOException exc = - new InterruptedIOException("progress"); - exc.bytesTransferred = nread; - throw exc; - } + setProgress(nr); return nr; } @@ -145,13 +161,7 @@ public int read(byte[] b, int off, int len) throws IOException { int nr = in.read(b, off, len); - if (nr > 0) monitor.setProgress(nread += nr); - if (monitor.isCanceled()) { - InterruptedIOException exc = - new InterruptedIOException("progress"); - exc.bytesTransferred = nread; - throw exc; - } + setProgress(nr); return nr; } @@ -162,7 +172,13 @@ public int read(byte[] b, */ public long skip(long n) throws IOException { long nr = in.skip(n); - if (nr > 0) monitor.setProgress(nread += nr); + if (nr > 0) { + if ((int)(nread + nr) > nread) { + monitor.setProgress(nread += nr); + } else { + monitor.setProgress(monitor.getMaximum()); + } + } return nr; } diff --git a/test/jdk/javax/swing/ProgressMonitor/ProgressTest.java b/test/jdk/javax/swing/ProgressMonitor/ProgressTest.java new file mode 100644 index 0000000000000..e79bf7973b1ec --- /dev/null +++ b/test/jdk/javax/swing/ProgressMonitor/ProgressTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * 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 8054572 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Tests if JComboBox displays correctly when editable/non-editable + * @run main/manual ProgressTest + */ + +import java.io.InputStream; + +import javax.swing.JFrame; +import javax.swing.ProgressMonitorInputStream; +import javax.swing.SwingUtilities; + +public class ProgressTest { + + private static final String instructionsText = + "A ProgressMonitor will be shown." + + " If it shows blank progressbar after 2048MB bytes read,"+ + " press Fail else press Pass"; + + private static JFrame frame; + + public static void main(String[] args) throws Exception { + + PassFailJFrame pfjFrame = new PassFailJFrame("JScrollPane " + + "Test Instructions", instructionsText, 5); + + final long SIZE = (long) (Integer.MAX_VALUE * 1.5); + + InputStream fileIn = new InputStream() { + long read = 0; + + @Override + public int available() { + return (int) Math.min(SIZE - read, Integer.MAX_VALUE); + } + + @Override + public int read() { + return (SIZE - read++ > 0) ? 1 : -1; + } + }; + + ProgressMonitorInputStream pmis = + new ProgressMonitorInputStream(null, "Reading File", fileIn); + + Thread thread = new Thread() { + public void run() { + byte[] buffer = new byte[512]; + int nb = 0; + long total = 0; + while (true) { + try { + nb = pmis.read(buffer); + } catch (Exception e){} + if (nb == 0) break; + total += nb; + + pmis.getProgressMonitor().setNote(total/(1024*1024)+" MB Read"); + } + } + }; + thread.start(); + pfjFrame.awaitAndCheck(); + } +} From d61229d22091b4756051f12578fedff714e8822f Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 30 Oct 2023 10:06:34 +0000 Subject: [PATCH 286/341] 8314144: gc/g1/ihop/TestIHOPStatic.java fails due to extra concurrent mark with -Xcomp Backport-of: 1925508425cf1b2d46173754077a588290253430 --- test/hotspot/jtreg/gc/g1/ihop/TestIHOPErgo.java | 1 + test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/gc/g1/ihop/TestIHOPErgo.java b/test/hotspot/jtreg/gc/g1/ihop/TestIHOPErgo.java index 43dcdeeb788b0..a93232dd82e01 100644 --- a/test/hotspot/jtreg/gc/g1/ihop/TestIHOPErgo.java +++ b/test/hotspot/jtreg/gc/g1/ihop/TestIHOPErgo.java @@ -30,6 +30,7 @@ * @requires !vm.flightRecorder * @requires vm.opt.ExplicitGCInvokesConcurrent != true * @requires vm.opt.MaxGCPauseMillis == "null" + * @requires vm.compMode != "Xcomp" * @library /test/lib / * @modules java.base/jdk.internal.misc * @modules java.management diff --git a/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java b/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java index b948448cadf6c..c84374fa359c0 100644 --- a/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java +++ b/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java @@ -28,7 +28,8 @@ * @requires vm.gc.G1 * @requires !vm.flightRecorder * @requires vm.opt.ExplicitGCInvokesConcurrent != true - * @requires !(vm.graal.enabled & vm.compMode == "Xcomp") + * @requires !vm.graal.enabled + * @requires vm.compMode != "Xcomp" * @requires os.maxMemory > 1G * @library /test/lib / * @modules java.base/jdk.internal.misc From 4a638cb64b2ebd03823b9441e01e8899d6798fae Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 30 Oct 2023 10:09:01 +0000 Subject: [PATCH 287/341] 8318705: [macos] ProblemList java/rmi/registry/multipleRegistries/MultipleRegistries.java Backport-of: 37c40a11a78f8b1f290cb04ce5b087904651907e --- test/jdk/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index bc73a1d5386e1..154fa026c78d6 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -611,6 +611,7 @@ java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java 7146541 linux-al java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java 7191877 generic-all java/rmi/registry/readTest/CodebaseTest.java 8173324 windows-all +java/rmi/registry/multipleRegistries/MultipleRegistries.java 8268182 macosx-all java/rmi/Naming/DefaultRegistryPort.java 8005619 windows-all java/rmi/Naming/legalRegistryNames/LegalRegistryNames.java 8005619 windows-all From 57bf412983c106b2cc35ff522a7582278c4ffecf Mon Sep 17 00:00:00 2001 From: Terry Chow Date: Mon, 30 Oct 2023 23:03:43 +0000 Subject: [PATCH 288/341] 8308593: Add KEEPALIVE Extended Socket Options Support for Windows Reviewed-by: djelinski, phh Backport-of: f3ade388dac0b882e671462caa762138f44817fb --- make/modules/jdk.net/Lib.gmk | 7 +- .../classes/jdk/net/LinuxSocketOptions.java | 12 +- .../native/libextnet/LinuxSocketOptions.c | 8 +- .../classes/jdk/net/MacOSXSocketOptions.java | 12 +- .../native/libextnet/MacOSXSocketOptions.c | 8 +- .../jdk/net/ExtendedSocketOptions.java | 20 +- .../classes/jdk/net/WindowsSocketOptions.java | 92 ++++++++++ .../native/libextnet/WindowsSocketOptions.c | 171 ++++++++++++++++++ 8 files changed, 298 insertions(+), 32 deletions(-) create mode 100644 src/jdk.net/windows/classes/jdk/net/WindowsSocketOptions.java create mode 100644 src/jdk.net/windows/native/libextnet/WindowsSocketOptions.c diff --git a/make/modules/jdk.net/Lib.gmk b/make/modules/jdk.net/Lib.gmk index 3c9d1055fccea..3333a1eec9696 100644 --- a/make/modules/jdk.net/Lib.gmk +++ b/make/modules/jdk.net/Lib.gmk @@ -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 @@ -27,7 +27,7 @@ include LibCommon.gmk ################################################################################ -ifeq ($(call isTargetOs, linux macosx), true) +ifeq ($(call isTargetOs, linux macosx windows), true) $(eval $(call SetupJdkLibrary, BUILD_LIBEXTNET, \ NAME := extnet, \ @@ -35,8 +35,9 @@ ifeq ($(call isTargetOs, linux macosx), true) CFLAGS := $(CFLAGS_JDKLIB), \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LIBS := -ljava, \ + LIBS_unix := -ljava, \ LIBS_linux := -ljvm, \ + LIBS_windows := jvm.lib ws2_32.lib $(WIN_JAVA_LIB), \ )) $(BUILD_LIBEXTNET): $(call FindLib, java.base, java) diff --git a/src/jdk.net/linux/classes/jdk/net/LinuxSocketOptions.java b/src/jdk.net/linux/classes/jdk/net/LinuxSocketOptions.java index f5282ae5b6d26..d11ba52f67ead 100644 --- a/src/jdk.net/linux/classes/jdk/net/LinuxSocketOptions.java +++ b/src/jdk.net/linux/classes/jdk/net/LinuxSocketOptions.java @@ -63,8 +63,8 @@ boolean peerCredentialsSupported() { } @Override - void setTcpkeepAliveProbes(int fd, final int value) throws SocketException { - setTcpkeepAliveProbes0(fd, value); + void setTcpKeepAliveProbes(int fd, final int value) throws SocketException { + setTcpKeepAliveProbes0(fd, value); } @Override @@ -78,8 +78,8 @@ void setTcpKeepAliveIntvl(int fd, final int value) throws SocketException { } @Override - int getTcpkeepAliveProbes(int fd) throws SocketException { - return getTcpkeepAliveProbes0(fd); + int getTcpKeepAliveProbes(int fd) throws SocketException { + return getTcpKeepAliveProbes0(fd); } @Override @@ -112,10 +112,10 @@ UnixDomainPrincipal getSoPeerCred(int fd) throws SocketException { return new UnixDomainPrincipal(user, group); } - private static native void setTcpkeepAliveProbes0(int fd, int value) throws SocketException; + private static native void setTcpKeepAliveProbes0(int fd, int value) throws SocketException; private static native void setTcpKeepAliveTime0(int fd, int value) throws SocketException; private static native void setTcpKeepAliveIntvl0(int fd, int value) throws SocketException; - private static native int getTcpkeepAliveProbes0(int fd) throws SocketException; + private static native int getTcpKeepAliveProbes0(int fd) throws SocketException; private static native int getTcpKeepAliveTime0(int fd) throws SocketException; private static native int getTcpKeepAliveIntvl0(int fd) throws SocketException; private static native void setQuickAck0(int fd, boolean on) throws SocketException; diff --git a/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c b/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c index ce603bb11f218..90124494e1e91 100644 --- a/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c +++ b/src/jdk.net/linux/native/libextnet/LinuxSocketOptions.c @@ -147,10 +147,10 @@ JNIEXPORT jboolean JNICALL Java_jdk_net_LinuxSocketOptions_keepAliveOptionsSuppo /* * Class: jdk_net_LinuxSocketOptions - * Method: setTcpkeepAliveProbes0 + * Method: setTcpKeepAliveProbes0 * Signature: (II)V */ -JNIEXPORT void JNICALL Java_jdk_net_LinuxSocketOptions_setTcpkeepAliveProbes0 +JNIEXPORT void JNICALL Java_jdk_net_LinuxSocketOptions_setTcpKeepAliveProbes0 (JNIEnv *env, jobject unused, jint fd, jint optval) { jint rv = setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &optval, sizeof (optval)); handleError(env, rv, "set option TCP_KEEPCNT failed"); @@ -180,10 +180,10 @@ JNIEXPORT void JNICALL Java_jdk_net_LinuxSocketOptions_setTcpKeepAliveIntvl0 /* * Class: jdk_net_LinuxSocketOptions - * Method: getTcpkeepAliveProbes0 + * Method: getTcpKeepAliveProbes0 * Signature: (I)I; */ -JNIEXPORT jint JNICALL Java_jdk_net_LinuxSocketOptions_getTcpkeepAliveProbes0 +JNIEXPORT jint JNICALL Java_jdk_net_LinuxSocketOptions_getTcpKeepAliveProbes0 (JNIEnv *env, jobject unused, jint fd) { jint optval, rv; socklen_t sz = sizeof (optval); diff --git a/src/jdk.net/macosx/classes/jdk/net/MacOSXSocketOptions.java b/src/jdk.net/macosx/classes/jdk/net/MacOSXSocketOptions.java index ac1bacc771699..0a239b4d59bee 100644 --- a/src/jdk.net/macosx/classes/jdk/net/MacOSXSocketOptions.java +++ b/src/jdk.net/macosx/classes/jdk/net/MacOSXSocketOptions.java @@ -44,8 +44,8 @@ boolean keepAliveOptionsSupported() { } @Override - void setTcpkeepAliveProbes(int fd, final int value) throws SocketException { - setTcpkeepAliveProbes0(fd, value); + void setTcpKeepAliveProbes(int fd, final int value) throws SocketException { + setTcpKeepAliveProbes0(fd, value); } @Override @@ -64,8 +64,8 @@ void setTcpKeepAliveIntvl(int fd, final int value) throws SocketException { } @Override - int getTcpkeepAliveProbes(int fd) throws SocketException { - return getTcpkeepAliveProbes0(fd); + int getTcpKeepAliveProbes(int fd) throws SocketException { + return getTcpKeepAliveProbes0(fd); } @Override @@ -88,10 +88,10 @@ UnixDomainPrincipal getSoPeerCred(int fd) throws SocketException { return new UnixDomainPrincipal(user, group); } - private static native void setTcpkeepAliveProbes0(int fd, int value) throws SocketException; + private static native void setTcpKeepAliveProbes0(int fd, int value) throws SocketException; private static native void setTcpKeepAliveTime0(int fd, int value) throws SocketException; private static native void setTcpKeepAliveIntvl0(int fd, int value) throws SocketException; - private static native int getTcpkeepAliveProbes0(int fd) throws SocketException; + private static native int getTcpKeepAliveProbes0(int fd) throws SocketException; private static native int getTcpKeepAliveTime0(int fd) throws SocketException; private static native int getTcpKeepAliveIntvl0(int fd) throws SocketException; private static native long getSoPeerCred0(int fd) throws SocketException; diff --git a/src/jdk.net/macosx/native/libextnet/MacOSXSocketOptions.c b/src/jdk.net/macosx/native/libextnet/MacOSXSocketOptions.c index 2e908c1f91854..abc756edbcdcd 100644 --- a/src/jdk.net/macosx/native/libextnet/MacOSXSocketOptions.c +++ b/src/jdk.net/macosx/native/libextnet/MacOSXSocketOptions.c @@ -79,10 +79,10 @@ JNIEXPORT jboolean JNICALL Java_jdk_net_MacOSXSocketOptions_keepAliveOptionsSupp /* * Class: jdk_net_MacOSXSocketOptions - * Method: setTcpkeepAliveProbes0 + * Method: setTcpKeepAliveProbes0 * Signature: (II)V */ -JNIEXPORT void JNICALL Java_jdk_net_MacOSXSocketOptions_setTcpkeepAliveProbes0 +JNIEXPORT void JNICALL Java_jdk_net_MacOSXSocketOptions_setTcpKeepAliveProbes0 (JNIEnv *env, jobject unused, jint fd, jint optval) { jint rv = setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &optval, sizeof (optval)); handleError(env, rv, "set option TCP_KEEPCNT failed"); @@ -112,10 +112,10 @@ JNIEXPORT void JNICALL Java_jdk_net_MacOSXSocketOptions_setTcpKeepAliveIntvl0 /* * Class: jdk_net_MacOSXSocketOptions - * Method: getTcpkeepAliveProbes0 + * Method: getTcpKeepAliveProbes0 * Signature: (I)I; */ -JNIEXPORT jint JNICALL Java_jdk_net_MacOSXSocketOptions_getTcpkeepAliveProbes0 +JNIEXPORT jint JNICALL Java_jdk_net_MacOSXSocketOptions_getTcpKeepAliveProbes0 (JNIEnv *env, jobject unused, jint fd) { jint optval, rv; socklen_t sz = sizeof (optval); diff --git a/src/jdk.net/share/classes/jdk/net/ExtendedSocketOptions.java b/src/jdk.net/share/classes/jdk/net/ExtendedSocketOptions.java index 0641ba48dcfe5..faaac59fd8606 100644 --- a/src/jdk.net/share/classes/jdk/net/ExtendedSocketOptions.java +++ b/src/jdk.net/share/classes/jdk/net/ExtendedSocketOptions.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 @@ -247,7 +247,7 @@ public void setOption(FileDescriptor fd, if (option == TCP_QUICKACK) { setQuickAckOption(fd, (boolean) value); } else if (option == TCP_KEEPCOUNT) { - setTcpkeepAliveProbes(fd, (Integer) value); + setTcpKeepAliveProbes(fd, (Integer) value); } else if (option == TCP_KEEPIDLE) { setTcpKeepAliveTime(fd, (Integer) value); } else if (option == TCP_KEEPINTERVAL) { @@ -276,7 +276,7 @@ public Object getOption(FileDescriptor fd, if (option == TCP_QUICKACK) { return getQuickAckOption(fd); } else if (option == TCP_KEEPCOUNT) { - return getTcpkeepAliveProbes(fd); + return getTcpKeepAliveProbes(fd); } else if (option == TCP_KEEPIDLE) { return getTcpKeepAliveTime(fd); } else if (option == TCP_KEEPINTERVAL) { @@ -310,9 +310,9 @@ private static Object getQuickAckOption(FileDescriptor fd) return platformSocketOptions.getQuickAck(fdAccess.get(fd)); } - private static void setTcpkeepAliveProbes(FileDescriptor fd, int value) + private static void setTcpKeepAliveProbes(FileDescriptor fd, int value) throws SocketException { - platformSocketOptions.setTcpkeepAliveProbes(fdAccess.get(fd), value); + platformSocketOptions.setTcpKeepAliveProbes(fdAccess.get(fd), value); } private static void setTcpKeepAliveTime(FileDescriptor fd, int value) @@ -325,8 +325,8 @@ private static void setTcpKeepAliveIntvl(FileDescriptor fd, int value) platformSocketOptions.setTcpKeepAliveIntvl(fdAccess.get(fd), value); } - private static int getTcpkeepAliveProbes(FileDescriptor fd) throws SocketException { - return platformSocketOptions.getTcpkeepAliveProbes(fdAccess.get(fd)); + private static int getTcpKeepAliveProbes(FileDescriptor fd) throws SocketException { + return platformSocketOptions.getTcpKeepAliveProbes(fdAccess.get(fd)); } private static int getTcpKeepAliveTime(FileDescriptor fd) throws SocketException { @@ -368,6 +368,8 @@ public String run() { return newInstance("jdk.net.LinuxSocketOptions"); } else if (osname.startsWith("Mac")) { return newInstance("jdk.net.MacOSXSocketOptions"); + } else if (osname.startsWith("Windows")) { + return newInstance("jdk.net.WindowsSocketOptions"); } else { return new PlatformSocketOptions(); } @@ -399,7 +401,7 @@ boolean keepAliveOptionsSupported() { return false; } - void setTcpkeepAliveProbes(int fd, final int value) throws SocketException { + void setTcpKeepAliveProbes(int fd, final int value) throws SocketException { throw new UnsupportedOperationException("unsupported TCP_KEEPCNT option"); } @@ -415,7 +417,7 @@ void setTcpKeepAliveIntvl(int fd, final int value) throws SocketException { throw new UnsupportedOperationException("unsupported TCP_KEEPINTVL option"); } - int getTcpkeepAliveProbes(int fd) throws SocketException { + int getTcpKeepAliveProbes(int fd) throws SocketException { throw new UnsupportedOperationException("unsupported TCP_KEEPCNT option"); } diff --git a/src/jdk.net/windows/classes/jdk/net/WindowsSocketOptions.java b/src/jdk.net/windows/classes/jdk/net/WindowsSocketOptions.java new file mode 100644 index 0000000000000..019dd6a0d3d97 --- /dev/null +++ b/src/jdk.net/windows/classes/jdk/net/WindowsSocketOptions.java @@ -0,0 +1,92 @@ +/* + * 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 jdk.net; + +import java.net.SocketException; +import java.security.AccessController; +import java.security.PrivilegedAction; +import jdk.net.ExtendedSocketOptions.PlatformSocketOptions; + + +@SuppressWarnings("removal") +class WindowsSocketOptions extends PlatformSocketOptions { + + public WindowsSocketOptions() { + } + + @Override + boolean keepAliveOptionsSupported() { + return keepAliveOptionsSupported0(); + } + + @Override + void setTcpKeepAliveProbes(int fd, final int value) throws SocketException { + setTcpKeepAliveProbes0(fd, value); + } + + @Override + int getTcpKeepAliveProbes(int fd) throws SocketException { + return getTcpKeepAliveProbes0(fd); + } + + @Override + void setTcpKeepAliveTime(int fd, final int value) throws SocketException { + setTcpKeepAliveTime0(fd, value); + } + + @Override + int getTcpKeepAliveTime(int fd) throws SocketException { + return getTcpKeepAliveTime0(fd); + } + + @Override + void setTcpKeepAliveIntvl(int fd, final int value) throws SocketException { + setTcpKeepAliveIntvl0(fd, value); + } + + @Override + int getTcpKeepAliveIntvl(int fd) throws SocketException { + return getTcpKeepAliveIntvl0(fd); + } + + private static native boolean keepAliveOptionsSupported0(); + private static native void setTcpKeepAliveProbes0(int fd, int value) throws SocketException; + private static native int getTcpKeepAliveProbes0(int fd) throws SocketException; + private static native void setTcpKeepAliveTime0(int fd, int value) throws SocketException; + private static native int getTcpKeepAliveTime0(int fd) throws SocketException; + private static native void setTcpKeepAliveIntvl0(int fd, int value) throws SocketException; + private static native int getTcpKeepAliveIntvl0(int fd) throws SocketException; + + static { + if (System.getSecurityManager() == null) { + System.loadLibrary("extnet"); + } else { + AccessController.doPrivileged((PrivilegedAction) () -> { + System.loadLibrary("extnet"); + return null; + }); + } + } +} diff --git a/src/jdk.net/windows/native/libextnet/WindowsSocketOptions.c b/src/jdk.net/windows/native/libextnet/WindowsSocketOptions.c new file mode 100644 index 0000000000000..578a37f64141c --- /dev/null +++ b/src/jdk.net/windows/native/libextnet/WindowsSocketOptions.c @@ -0,0 +1,171 @@ +/* + * 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. + */ + +#include +#include + +#include + +#include "jni.h" +#include "jni_util.h" +#include "jvm.h" + +static void handleError(JNIEnv *env, jint rv, const char *errmsg) { + if (rv < 0) { + int error = WSAGetLastError(); + if (error == WSAENOPROTOOPT) { + JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", + "unsupported socket option"); + } else { + JNU_ThrowByNameWithLastError(env, "java/net/SocketException", errmsg); + } + } +} + +static jint socketOptionSupported(jint level, jint optname) { + WSADATA wsaData; + jint error = WSAStartup(MAKEWORD(2, 2), &wsaData); + + if (error != 0) { + return 0; + } + + SOCKET sock; + jint one = 1; + jint rv; + socklen_t sz = sizeof(one); + + /* First try IPv6; fall back to IPv4. */ + sock = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP); + if (sock == INVALID_SOCKET) { + error = WSAGetLastError(); + if (error == WSAEPFNOSUPPORT || error == WSAEAFNOSUPPORT) { + sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + } + if (sock == INVALID_SOCKET) { + return 0; + } + } + + rv = getsockopt(sock, level, optname, (char*) &one, &sz); + error = WSAGetLastError(); + + if (rv != 0 && error == WSAENOPROTOOPT) { + rv = 0; + } else { + rv = 1; + } + + closesocket(sock); + WSACleanup(); + + return rv; +} + +/* + * Class: jdk_net_WindowsSocketOptions + * Method: keepAliveOptionsSupported0 + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_jdk_net_WindowsSocketOptions_keepAliveOptionsSupported0 +(JNIEnv *env, jobject unused) { + return socketOptionSupported(IPPROTO_TCP, TCP_KEEPIDLE) && socketOptionSupported(IPPROTO_TCP, TCP_KEEPCNT) + && socketOptionSupported(IPPROTO_TCP, TCP_KEEPINTVL); +} + +/* + * Class: jdk_net_WindowsSocketOptions + * Method: setTcpKeepAliveProbes0 + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_jdk_net_WindowsSocketOptions_setTcpKeepAliveProbes0 +(JNIEnv *env, jobject unused, jint fd, jint optval) { + jint rv = setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, (char*) &optval, sizeof(optval)); + handleError(env, rv, "set option TCP_KEEPCNT failed"); +} + +/* + * Class: jdk_net_WindowsSocketOptions + * Method: getTcpKeepAliveProbes0 + * Signature: (I)I; + */ +JNIEXPORT jint JNICALL Java_jdk_net_WindowsSocketOptions_getTcpKeepAliveProbes0 +(JNIEnv *env, jobject unused, jint fd) { + jint optval, rv; + socklen_t sz = sizeof(optval); + rv = getsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, (char*) &optval, &sz); + handleError(env, rv, "get option TCP_KEEPCNT failed"); + return optval; +} + +/* + * Class: jdk_net_WindowsSocketOptions + * Method: setTcpKeepAliveTime0 + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_jdk_net_WindowsSocketOptions_setTcpKeepAliveTime0 +(JNIEnv *env, jobject unused, jint fd, jint optval) { + jint rv = setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, (char*) &optval, sizeof(optval)); + handleError(env, rv, "set option TCP_KEEPIDLE failed"); +} + +/* + * Class: jdk_net_WindowsSocketOptions + * Method: getTcpKeepAliveTime0 + * Signature: (I)I; + */ +JNIEXPORT jint JNICALL Java_jdk_net_WindowsSocketOptions_getTcpKeepAliveTime0 +(JNIEnv *env, jobject unused, jint fd) { + jint optval, rv; + socklen_t sz = sizeof(optval); + rv = getsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, (char*) &optval, &sz); + handleError(env, rv, "get option TCP_KEEPIDLE failed"); + return optval; +} + +/* + * Class: jdk_net_WindowsSocketOptions + * Method: setTcpKeepAliveIntvl0 + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_jdk_net_WindowsSocketOptions_setTcpKeepAliveIntvl0 +(JNIEnv *env, jobject unused, jint fd, jint optval) { + jint rv = setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, (char*) &optval, sizeof(optval)); + handleError(env, rv, "set option TCP_KEEPINTVL failed"); +} + +/* + * Class: jdk_net_WindowsSocketOptions + * Method: getTcpKeepAliveIntvl0 + * Signature: (I)I; + */ +JNIEXPORT jint JNICALL Java_jdk_net_WindowsSocketOptions_getTcpKeepAliveIntvl0 +(JNIEnv *env, jobject unused, jint fd) { + jint optval, rv; + socklen_t sz = sizeof(optval); + rv = getsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, (char*) &optval, &sz); + handleError(env, rv, "get option TCP_KEEPINTVL failed"); + return optval; +} From 8922e529016c1b79194e4e3b5b9f0d07e6431dec Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 2 Nov 2023 08:03:11 +0000 Subject: [PATCH 289/341] 8312612: handle WideCharToMultiByte return values Backport-of: d9559f9b24ee76c074cefcaf256d11ef5a7cc5b7 --- .../native/libawt/windows/awt_Font.cpp | 14 +++++++++---- .../native/libawt/windows/awt_PrintJob.cpp | 10 ++++++--- .../PLATFORM_API_WinOS_Charset_Util.cpp | 21 +++++++++++++------ 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp b/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp index 3a63408294ec4..a7eedd888f37f 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_Font.cpp @@ -1790,10 +1790,16 @@ void CCombinedSegTable::GetEUDCFileName(LPWSTR lpszFileName, int cchFileName) DWORD dwBytes = sizeof(szFileName); // try Typeface-specific EUDC font char szTmpName[80]; - VERIFY(::WideCharToMultiByte(CP_ACP, 0, szFamilyName, -1, - szTmpName, sizeof(szTmpName), NULL, NULL)); - LONG lStatus = ::RegQueryValueExA(hKey, (LPCSTR) szTmpName, - NULL, &dwType, szFileName, &dwBytes); + int nb = ::WideCharToMultiByte(CP_ACP, 0, szFamilyName, -1, + szTmpName, sizeof(szTmpName), NULL, NULL); + VERIFY(nb); + + LONG lStatus = 1; + if (nb > 0) { + lStatus = ::RegQueryValueExA(hKey, (LPCSTR) szTmpName, + NULL, &dwType, szFileName, &dwBytes); + } + BOOL fUseDefault = FALSE; if (lStatus != ERROR_SUCCESS){ // try System default EUDC font if (m_fTTEUDCFileExist == FALSE) diff --git a/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp b/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp index 0fbb6b2bd00cc..f8899037ea547 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_PrintJob.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2021, 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 @@ -3925,9 +3925,13 @@ static void throwPrinterException(JNIEnv *env, DWORD err) { sizeof(t_errStr), NULL ); - WideCharToMultiByte(CP_UTF8, 0, t_errStr, -1, + int nb = WideCharToMultiByte(CP_UTF8, 0, t_errStr, -1, errStr, sizeof(errStr), NULL, NULL); - JNU_ThrowByName(env, PRINTEREXCEPTION_STR, errStr); + if (nb > 0) { + JNU_ThrowByName(env, PRINTEREXCEPTION_STR, errStr); + } else { + JNU_ThrowByName(env, PRINTEREXCEPTION_STR, "secondary error during OS message extraction"); + } } diff --git a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_Charset_Util.cpp b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_Charset_Util.cpp index 6179d7bbf4b86..0f207437523af 100644 --- a/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_Charset_Util.cpp +++ b/src/java.desktop/windows/native/libjsound/PLATFORM_API_WinOS_Charset_Util.cpp @@ -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 @@ -35,16 +35,25 @@ LPSTR UnicodeToUTF8(const LPCWSTR lpUnicodeStr) { DWORD dwUTF8Len = WideCharToMultiByte(CP_UTF8, 0, lpUnicodeStr, -1, nullptr, 0, nullptr, nullptr); LPSTR lpUTF8Str = new CHAR[dwUTF8Len]; + if (lpUTF8Str == NULL) return NULL; memset(lpUTF8Str, 0, sizeof(CHAR) * (dwUTF8Len)); - WideCharToMultiByte(CP_UTF8, 0, lpUnicodeStr, -1, lpUTF8Str, dwUTF8Len, nullptr, nullptr); - return lpUTF8Str; + int nb = WideCharToMultiByte(CP_UTF8, 0, lpUnicodeStr, -1, lpUTF8Str, dwUTF8Len, nullptr, nullptr); + if (nb > 0) { + return lpUTF8Str; + } + delete[] lpUTF8Str; + return NULL; } void UnicodeToUTF8AndCopy(LPSTR dest, LPCWSTR src, SIZE_T maxLength) { LPSTR utf8EncodedName = UnicodeToUTF8(src); - strncpy(dest, utf8EncodedName, maxLength - 1); - delete[] utf8EncodedName; - dest[maxLength - 1] = '\0'; + if (utf8EncodedName != NULL) { + strncpy(dest, utf8EncodedName, maxLength - 1); + delete[] utf8EncodedName; + dest[maxLength - 1] = '\0'; + } else { + if (maxLength > 0) dest[0] = '\0'; + } } #ifdef __cplusplus From 594e5d77f43ac511a848a5226a38381857632f2c Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 2 Nov 2023 08:17:48 +0000 Subject: [PATCH 290/341] 8312467: relax the builddir check in make/autoconf/basic.m4 Backport-of: 6e3cc131daa9f3b883164333bdaad7aa3a6ca018 --- make/autoconf/basic.m4 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/make/autoconf/basic.m4 b/make/autoconf/basic.m4 index 8461815d7718a..3e5e22b53af43 100644 --- a/make/autoconf/basic.m4 +++ b/make/autoconf/basic.m4 @@ -358,9 +358,9 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR], # WARNING: This might be a bad thing to do. You need to be sure you want to # have a configuration in this directory. Do some sanity checks! - if test ! -e "$OUTPUTDIR/spec.gmk"; then - # If we have a spec.gmk, we have run here before and we are OK. Otherwise, check for - # other files + if test ! -e "$OUTPUTDIR/spec.gmk" && test ! -e "$OUTPUTDIR/configure-support/generated-configure.sh"; then + # If we have a spec.gmk or configure-support/generated-configure.sh, + # we have run here before and we are OK. Otherwise, check for other files files_present=`$LS $OUTPUTDIR` # Configure has already touched config.log and confdefs.h in the current dir when this check # is performed. @@ -375,8 +375,9 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR], AC_MSG_NOTICE([Current directory is $CONFIGURE_START_DIR.]) AC_MSG_NOTICE([Since this is not the source root, configure will output the configuration here]) AC_MSG_NOTICE([(as opposed to creating a configuration in /build/).]) - AC_MSG_NOTICE([However, this directory is not empty. This is not allowed, since it could]) - AC_MSG_NOTICE([seriously mess up just about everything.]) + AC_MSG_NOTICE([However, this directory is not empty, additionally to some allowed files]) + AC_MSG_NOTICE([it contains $filtered_files.]) + AC_MSG_NOTICE([This is not allowed, since it could seriously mess up just about everything.]) AC_MSG_NOTICE([Try 'cd $TOPDIR' and restart configure]) AC_MSG_NOTICE([(or create a new empty directory and cd to it).]) AC_MSG_ERROR([Will not continue creating configuration in $CONFIGURE_START_DIR]) From 348a703c25e025ac170d45f5c2ddec28d8ac67b6 Mon Sep 17 00:00:00 2001 From: Gui Cao Date: Thu, 2 Nov 2023 11:08:42 +0000 Subject: [PATCH 291/341] 8318953: RISC-V: Small refactoring for MacroAssembler::test_bit Reviewed-by: fyang Backport-of: 988e1dfe6ec9b5e77d2e8a78eb792a127c6fe907 --- src/hotspot/cpu/riscv/macroAssembler_riscv.cpp | 10 ++++++++-- src/hotspot/cpu/riscv/macroAssembler_riscv.hpp | 2 +- src/hotspot/cpu/riscv/riscv.ad | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 005b674b33e17..c26409669875d 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -4518,11 +4518,17 @@ void MacroAssembler::cmp_l2i(Register dst, Register src1, Register src2, Registe bind(done); } -void MacroAssembler::test_bit(Register Rd, Register Rs, uint32_t bit_pos, Register tmp) { +void MacroAssembler::test_bit(Register Rd, Register Rs, uint32_t bit_pos) { assert(bit_pos < 64, "invalid bit range"); if (UseZbs) { bexti(Rd, Rs, bit_pos); return; } - andi(Rd, Rs, 1UL << bit_pos, tmp); + int64_t imm = (int64_t)(1UL << bit_pos); + if (is_simm12(imm)) { + and_imm12(Rd, Rs, imm); + } else { + srli(Rd, Rs, bit_pos); + and_imm12(Rd, Rd, 1); + } } diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 3f26f4e95d581..6d6a6496565fb 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -1144,7 +1144,7 @@ class MacroAssembler: public Assembler { void shadd(Register Rd, Register Rs1, Register Rs2, Register tmp, int shamt); // test single bit in Rs, result is set to Rd - void test_bit(Register Rd, Register Rs, uint32_t bit_pos, Register tmp = t0); + void test_bit(Register Rd, Register Rs, uint32_t bit_pos); // Here the float instructions with safe deal with some exceptions. // e.g. convert from NaN, +Inf, -Inf to int, float, double diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 6037a115b746b..86b0e0a36f72f 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -2318,7 +2318,7 @@ encode %{ if (DiagnoseSyncOnValueBasedClasses != 0) { __ load_klass(flag, oop); __ lwu(flag, Address(flag, Klass::access_flags_offset())); - __ test_bit(flag, flag, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS), tmp /* tmp */); + __ test_bit(flag, flag, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS)); __ bnez(flag, cont, true /* is_far */); } From a273858429294355d36e44b625cf30898b15a3c9 Mon Sep 17 00:00:00 2001 From: Frederic Thevenet Date: Fri, 3 Nov 2023 12:02:44 +0000 Subject: [PATCH 292/341] 8318669: Target OS detection in 'test-prebuilt' makefile target is incorrect when running on MSYS2 Backport-of: 202c0137b86cd7bcbe0c1eddf2657f45698ab667 --- make/RunTestsPrebuilt.gmk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/make/RunTestsPrebuilt.gmk b/make/RunTestsPrebuilt.gmk index 85c6bae63993a..b3afaa7fe67b0 100644 --- a/make/RunTestsPrebuilt.gmk +++ b/make/RunTestsPrebuilt.gmk @@ -157,6 +157,10 @@ ifeq ($(UNAME_OS), CYGWIN) OPENJDK_TARGET_OS := windows OPENJDK_TARGET_OS_TYPE := windows OPENJDK_TARGET_OS_ENV := windows.cygwin +else ifeq ($(UNAME_OS), MINGW64) + OPENJDK_TARGET_OS := windows + OPENJDK_TARGET_OS_TYPE := windows + OPENJDK_TARGET_OS_ENV := windows.msys2 else OPENJDK_TARGET_OS_TYPE:=unix ifeq ($(UNAME_OS), Linux) @@ -169,6 +173,9 @@ else OPENJDK_TARGET_OS_ENV := $(OPENJDK_TARGET_OS) endif +# Sanity check env detection +$(info Detected target OS, type and env: [$(OPENJDK_TARGET_OS)] [$(OPENJDK_TARGET_OS_TYPE)] [$(OPENJDK_TARGET_OS_ENV)]) + # Assume little endian unless otherwise specified OPENJDK_TARGET_CPU_ENDIAN := little From d4ed7c277039b5e34acc000fbecf448061a334a8 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 3 Nov 2023 12:04:52 +0000 Subject: [PATCH 293/341] 8318855: Extra file added by mistake during the backport of JDK-8283326 Reviewed-by: mdoerr --- src/hotspot/share/runtime/safefetch.inline.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/hotspot/share/runtime/safefetch.inline.hpp diff --git a/src/hotspot/share/runtime/safefetch.inline.hpp b/src/hotspot/share/runtime/safefetch.inline.hpp deleted file mode 100644 index e69de29bb2d1d..0000000000000 From cd6cb730c934d8e16d4bd8e3342e59e806f158f9 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 6 Nov 2023 06:57:17 +0000 Subject: [PATCH 294/341] 8310265: (process) jspawnhelper should not use argv[0] Reviewed-by: stuefe Backport-of: 47d00a4cbeff5d757dda9c660dfd2385c02a57d7 --- .../unix/native/jspawnhelper/jspawnhelper.c | 4 ++-- src/java.base/unix/native/libjava/ProcessImpl_md.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/java.base/unix/native/jspawnhelper/jspawnhelper.c b/src/java.base/unix/native/jspawnhelper/jspawnhelper.c index 13882017163f8..dec17f01598f2 100644 --- a/src/java.base/unix/native/jspawnhelper/jspawnhelper.c +++ b/src/java.base/unix/native/jspawnhelper/jspawnhelper.c @@ -134,10 +134,10 @@ int main(int argc, char *argv[]) { ChildStuff c; int t; struct stat buf; - /* argv[0] contains the fd number to read all the child info */ + /* argv[1] contains the fd number to read all the child info */ int r, fdin, fdout; - r = sscanf (argv[argc-1], "%d:%d", &fdin, &fdout); + r = sscanf (argv[1], "%d:%d", &fdin, &fdout); if (r == 2 && fcntl(fdin, F_GETFD) != -1) { fstat(fdin, &buf); if (!S_ISFIFO(buf.st_mode)) diff --git a/src/java.base/unix/native/libjava/ProcessImpl_md.c b/src/java.base/unix/native/libjava/ProcessImpl_md.c index 9dea3110c2bf5..35a949dd19719 100644 --- a/src/java.base/unix/native/libjava/ProcessImpl_md.c +++ b/src/java.base/unix/native/libjava/ProcessImpl_md.c @@ -491,16 +491,20 @@ spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) jboolean isCopy; int i, offset, rval, bufsize, magic; char *buf, buf1[16]; - char *hlpargs[2]; + char *hlpargs[3]; SpawnInfo sp; /* need to tell helper which fd is for receiving the childstuff * and which fd to send response back on */ snprintf(buf1, sizeof(buf1), "%d:%d", c->childenv[0], c->fail[1]); - /* put the fd string as argument to the helper cmd */ - hlpargs[0] = buf1; - hlpargs[1] = 0; + /* NULL-terminated argv array. + * argv[0] contains path to jspawnhelper, to follow conventions. + * argv[1] contains the fd string as argument to jspawnhelper + */ + hlpargs[0] = (char*)helperpath; + hlpargs[1] = buf1; + hlpargs[2] = NULL; /* Following items are sent down the pipe to the helper * after it is spawned. From 253acc68d1209cdf008a299a111cc8442982d98a Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:09:48 +0000 Subject: [PATCH 295/341] 8271826: mark hotspot runtime/condy tests which ignore external VM flags Backport-of: d3b40cb68323a1b0efa461b4a415793415a2deef --- test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java | 3 ++- test/hotspot/jtreg/runtime/condy/CondyLDCTest.java | 3 ++- .../hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java | 3 ++- .../jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java | 3 ++- .../jtreg/runtime/condy/staticInit/TestInitException.java | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java b/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java index 339bc87be5934..4ae0eaa0df3b4 100644 --- a/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java +++ b/test/hotspot/jtreg/runtime/condy/BadBSMUseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8186211 * @summary CONSTANT_Dynamic_info structure's tries to use a BSM index whose signature is for an invokedynamic and vice versa. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile CondyUsesIndyBSM.jcod diff --git a/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java b/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java index 57f011181dd87..ef26a6bf67466 100644 --- a/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java +++ b/test/hotspot/jtreg/runtime/condy/CondyLDCTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8186211 * @summary Tests various ldc, ldc_w, ldc2_w instructions of CONSTANT_Dynamic. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile CondyUseLDC_W.jasm diff --git a/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java b/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java index 9b584ffbd58e8..2de9e7286668d 100644 --- a/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java +++ b/test/hotspot/jtreg/runtime/condy/CondyNewInvokeSpecialTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8186211 * @summary Test CONSTANT_Dynamic where the BSM is invoked via a REF_newInvokeSpecial. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile CondyNewInvokeSpecial.jasm diff --git a/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java b/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java index b3bf6e7f2915f..cb4b6960cf967 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, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @bug 8216970 * @summary Ensure escape analysis can handle an ldc of a dynamic * constant whose return type is an array of boolean. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile TestEscapeThroughInvokeWithCondy$A.jasm diff --git a/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java b/test/hotspot/jtreg/runtime/condy/staticInit/TestInitException.java index ecd945be87f7a..c8b8aeba22e4d 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, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ * @test * @bug 8228485 * @summary Correctly handle initialization error for Condy BSM. + * @requires vm.flagless * @modules java.base/jdk.internal.misc * @library /test/lib * @compile Example.jasm From e3d52aa778cebac92ebf495127b70e30b8b20348 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:11:31 +0000 Subject: [PATCH 296/341] 8269425: 2 jdk/jfr/api/consumer/streaming tests failed to attach Backport-of: fffa73c1ef377eb28371fc4094eea8725850de7d --- test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/streaming/TestJVMExit.java | 4 ++-- test/lib/jdk/test/lib/jfr/StreamingUtils.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java index 3c6620b8caf4f..c1594462a8030 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @library /test/lib /test/jdk * @modules jdk.jfr jdk.attach java.base/jdk.internal.misc * - * @run main/othervm jdk.jfr.api.consumer.streaming.TestJVMCrash + * @run main/othervm -Dsun.tools.attach.attachTimeout=100000 jdk.jfr.api.consumer.streaming.TestJVMCrash */ public class TestJVMCrash { diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMExit.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMExit.java index c4bdfdf6402d6..5b30a52e4b757 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMExit.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMExit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * 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 @@ * @library /test/lib /test/jdk * @modules jdk.jfr jdk.attach java.base/jdk.internal.misc * - * @run main/othervm jdk.jfr.api.consumer.streaming.TestJVMExit + * @run main/othervm -Dsun.tools.attach.attachTimeout=100000 jdk.jfr.api.consumer.streaming.TestJVMExit */ public class TestJVMExit { diff --git a/test/lib/jdk/test/lib/jfr/StreamingUtils.java b/test/lib/jdk/test/lib/jfr/StreamingUtils.java index cb95c3d25d89f..7461cfd0b63a1 100644 --- a/test/lib/jdk/test/lib/jfr/StreamingUtils.java +++ b/test/lib/jdk/test/lib/jfr/StreamingUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * 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,8 +51,8 @@ public static Path getJfrRepository(Process process) throws Exception { try { VirtualMachine vm = VirtualMachine.attach(String.valueOf(process.pid())); String repo = vm.getSystemProperties().getProperty("jdk.jfr.repository"); + vm.detach(); if (repo != null) { - vm.detach(); System.out.println("JFR repository: " + repo); return Paths.get(repo); } From 401969c232bc838529fa742a5f1a5f7e4c2f83aa Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:13:30 +0000 Subject: [PATCH 297/341] 8298905: Test "java/awt/print/PrinterJob/ImagePrinting/PrintARGBImage.java" fails because the frames of instruction does not display Backport-of: d1026720d323d0acd9bd8d85d5caba7185107863 --- .../PrinterJob/ImagePrinting/PrintARGBImage.java | 1 + .../awt/print/PrinterJob/PageRangesDlgTest.java | 1 + .../javax/swing/ProgressMonitor/ProgressTest.java | 14 ++++++-------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/jdk/java/awt/print/PrinterJob/ImagePrinting/PrintARGBImage.java b/test/jdk/java/awt/print/PrinterJob/ImagePrinting/PrintARGBImage.java index cba4e358c4c82..4bef1cce0f5af 100644 --- a/test/jdk/java/awt/print/PrinterJob/ImagePrinting/PrintARGBImage.java +++ b/test/jdk/java/awt/print/PrinterJob/ImagePrinting/PrintARGBImage.java @@ -54,6 +54,7 @@ public static void main(String[] args) throws InterruptedException, """; PassFailJFrame passFailJFrame = new PassFailJFrame(instruction, 10); + PassFailJFrame.positionTestWindow(null, PassFailJFrame.Position.HORIZONTAL); try { PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPrintable(new PrintARGBImage()); diff --git a/test/jdk/java/awt/print/PrinterJob/PageRangesDlgTest.java b/test/jdk/java/awt/print/PrinterJob/PageRangesDlgTest.java index 4b1b860492a61..cc5cfccc735e4 100644 --- a/test/jdk/java/awt/print/PrinterJob/PageRangesDlgTest.java +++ b/test/jdk/java/awt/print/PrinterJob/PageRangesDlgTest.java @@ -81,6 +81,7 @@ public static void main(String[] args) throws Exception { """; PassFailJFrame passFailJFrame = new PassFailJFrame(instruction, 10); + PassFailJFrame.positionTestWindow(null, PassFailJFrame.Position.HORIZONTAL); showPrintDialogs(); passFailJFrame.awaitAndCheck(); } diff --git a/test/jdk/javax/swing/ProgressMonitor/ProgressTest.java b/test/jdk/javax/swing/ProgressMonitor/ProgressTest.java index e79bf7973b1ec..776cb720ae168 100644 --- a/test/jdk/javax/swing/ProgressMonitor/ProgressTest.java +++ b/test/jdk/javax/swing/ProgressMonitor/ProgressTest.java @@ -22,32 +22,29 @@ */ /* @test - * @bug 8054572 + * @bug 6445283 * @library /java/awt/regtesthelpers * @build PassFailJFrame - * @summary Tests if JComboBox displays correctly when editable/non-editable + * @summary Tests if ProgressMonitorInputStream reports progress accurately * @run main/manual ProgressTest */ import java.io.InputStream; -import javax.swing.JFrame; import javax.swing.ProgressMonitorInputStream; -import javax.swing.SwingUtilities; public class ProgressTest { private static final String instructionsText = - "A ProgressMonitor will be shown." + - " If it shows blank progressbar after 2048MB bytes read,"+ + "A ProgressMonitor will be shown.\n" + + " If it shows blank progressbar after 2048MB bytes read,\n"+ " press Fail else press Pass"; - private static JFrame frame; - public static void main(String[] args) throws Exception { PassFailJFrame pfjFrame = new PassFailJFrame("JScrollPane " + "Test Instructions", instructionsText, 5); + PassFailJFrame.positionTestWindow(null, PassFailJFrame.Position.VERTICAL); final long SIZE = (long) (Integer.MAX_VALUE * 1.5); @@ -85,6 +82,7 @@ public void run() { } }; thread.start(); + pfjFrame.awaitAndCheck(); } } From 340a389a7ee544fbc796df96069d2d5c561466d3 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:15:48 +0000 Subject: [PATCH 298/341] 8309778: java/nio/file/Files/CopyAndMove.java fails when using second test directory Backport-of: cfae6ef2f61f0a6611de2f66e6e773c547ba7878 --- test/jdk/java/nio/file/Files/CopyAndMove.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/nio/file/Files/CopyAndMove.java b/test/jdk/java/nio/file/Files/CopyAndMove.java index 981fb332fc0c4..48e06159b4584 100644 --- a/test/jdk/java/nio/file/Files/CopyAndMove.java +++ b/test/jdk/java/nio/file/Files/CopyAndMove.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -892,7 +892,7 @@ static void testCopyFileToFile(Path dir1, Path dir2, boolean supportsLinks) if (supportsLinks) { source = createSourceFile(dir1); link = dir1.resolve("link"); - createSymbolicLink(link, source); + createSymbolicLink(link, source.getFileName()); target = getTargetFile(dir2); copyAndVerify(link, target); delete(link); From 8018d07929a6894a288e91a26809e88217371f16 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:17:51 +0000 Subject: [PATCH 299/341] 8301457: Code in SendPortZero.java is uncommented even after JDK-8236852 was fixed Backport-of: 298dda4c985ddda84e264aff86ea45c849bb171c --- .../java/net/DatagramSocket/SendPortZero.java | 24 ++++++++++--------- .../net/MulticastSocket/SendPortZero.java | 22 ++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/jdk/java/net/DatagramSocket/SendPortZero.java b/test/jdk/java/net/DatagramSocket/SendPortZero.java index 5c60df3a24414..4d2602cdd87a0 100644 --- a/test/jdk/java/net/DatagramSocket/SendPortZero.java +++ b/test/jdk/java/net/DatagramSocket/SendPortZero.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 @@ -29,6 +29,7 @@ import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; +import java.net.InetSocketAddress; import java.net.InetAddress; import java.net.MulticastSocket; import java.net.SocketException; @@ -70,7 +71,7 @@ public void setUp() throws IOException { // Addresses loopbackAddr = InetAddress.getLoopbackAddress(); - //wildcardAddr = new InetSocketAddress(0).getAddress(); + wildcardAddr = new InetSocketAddress(0).getAddress(); // Packets // loopback w/port 0 @@ -78,29 +79,30 @@ public void setUp() throws IOException { loopbackZeroPkt.setAddress(loopbackAddr); loopbackZeroPkt.setPort(0); - /* - //Commented until JDK-8236852 is fixed - // wildcard w/port 0 wildcardZeroPkt = new DatagramPacket(buf, 0, buf.length); wildcardZeroPkt.setAddress(wildcardAddr); wildcardZeroPkt.setPort(0); - //Commented until JDK-8236807 is fixed - // wildcard addr w/valid port + // Not currently tested. See JDK-8236807 wildcardValidPkt = new DatagramPacket(buf, 0, buf.length); - var addr = socket.getAddress(); - wildcardValidPkt.setAddress(addr); - wildcardValidPkt.setPort(socket.getLocalPort()); - */ + wildcardValidPkt.setAddress(wildcardAddr); + wildcardValidPkt.setPort(datagramSocket.getLocalPort()); } @DataProvider(name = "data") public Object[][] variants() { return new Object[][]{ { datagramSocket, loopbackZeroPkt }, + { datagramSocket, wildcardZeroPkt }, + // Re-enable when JDK-8236807 fixed + //{ datagramSocket, wildcardValidPkt }, + { datagramSocketAdaptor, loopbackZeroPkt }, + { datagramSocketAdaptor, wildcardZeroPkt }, + // Re-enable when JDK-8236807 fixed + //{ datagramSocketAdaptor, wildcardValidPkt }, }; } diff --git a/test/jdk/java/net/MulticastSocket/SendPortZero.java b/test/jdk/java/net/MulticastSocket/SendPortZero.java index e07743ba9fee2..b7712dbdbfb62 100644 --- a/test/jdk/java/net/MulticastSocket/SendPortZero.java +++ b/test/jdk/java/net/MulticastSocket/SendPortZero.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 @@ -30,6 +30,7 @@ import java.net.DatagramPacket; import java.net.MulticastSocket; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.MulticastSocket; import java.net.SocketException; import java.net.SocketPermission; @@ -69,7 +70,7 @@ public void setUp() throws IOException { // Addresses loopbackAddr = InetAddress.getLoopbackAddress(); - //wildcardAddr = new InetSocketAddress(0).getAddress(); + wildcardAddr = new InetSocketAddress(0).getAddress(); // Packets // loopback w/port 0 @@ -77,28 +78,25 @@ public void setUp() throws IOException { loopbackZeroPkt.setAddress(loopbackAddr); loopbackZeroPkt.setPort(0); - /* - //Commented until JDK-8236852 is fixed - // wildcard w/port 0 wildcardZeroPkt = new DatagramPacket(buf, 0, buf.length); wildcardZeroPkt.setAddress(wildcardAddr); wildcardZeroPkt.setPort(0); - //Commented until JDK-8236807 is fixed - // wildcard addr w/valid port + // Not currently tested. See JDK-8236807 wildcardValidPkt = new DatagramPacket(buf, 0, buf.length); - var addr = socket.getAddress(); - wildcardValidPkt.setAddress(addr); - wildcardValidPkt.setPort(socket.getLocalPort()); - */ + wildcardValidPkt.setAddress(wildcardAddr); + wildcardValidPkt.setPort(multicastSocket.getLocalPort()); } @DataProvider(name = "data") public Object[][] variants() { return new Object[][]{ - { multicastSocket, loopbackZeroPkt } + { multicastSocket, loopbackZeroPkt }, + { multicastSocket, wildcardZeroPkt }, + // Not currently tested. See JDK-8236807 + //{ multicastSocket, wildcardValidPkt } }; } From 4b6ac09ae98e10a58155b95d289c30278eeae666 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:20:06 +0000 Subject: [PATCH 300/341] 8317327: Remove JT_JAVA dead code in jib-profiles.js Backport-of: 69489427e941daeac6fdd7f52a6129612b70ce53 --- make/conf/jib-profiles.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index 5c4afc9fd0301..4ee43abe774bd 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -917,10 +917,7 @@ var getJibProfilesProfiles = function (input, common, data) { target_os: input.build_os, target_cpu: input.build_cpu, dependencies: [ "jtreg", "gnumake", "boot_jdk", "devkit", "jib" ], - labels: "test", - environment: { - "JT_JAVA": common.boot_jdk_home - } + labels: "test" } }; profiles = concatObjects(profiles, testOnlyProfiles); From fa307335e19902cce85762d01a9bed6404627d8e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 6 Nov 2023 11:56:45 +0000 Subject: [PATCH 301/341] 8318889: C2: add bailout after assert Bad graph detected in build_loop_late Backport-of: 83eb20651f6b5fa0540a339921c8ad0a6d370bb7 --- src/hotspot/share/opto/loopnode.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index e2a5d26b14db4..f30ef59d2e453 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -3898,6 +3898,7 @@ void PhaseIdealLoop::build_and_optimize() { NOT_PRODUCT( C->verify_graph_edges(); ) worklist.push(C->top()); build_loop_late( visited, worklist, nstack ); + if (C->failing()) { return; } if (_verify_only) { C->restore_major_progress(old_progress); @@ -5218,6 +5219,7 @@ void PhaseIdealLoop::build_loop_late( VectorSet &visited, Node_List &worklist, N } else { // All of n's children have been processed, complete post-processing. build_loop_late_post(n); + if (C->failing()) { return; } if (nstack.is_empty()) { // Finished all nodes on stack. // Process next node on the worklist. @@ -5363,13 +5365,15 @@ void PhaseIdealLoop::build_loop_late_post_work(Node *n, bool pinned) { Node *legal = LCA; // Walk 'legal' up the IDOM chain Node *least = legal; // Best legal position so far while( early != legal ) { // While not at earliest legal -#ifdef ASSERT if (legal->is_Start() && !early->is_Root()) { +#ifdef ASSERT // Bad graph. Print idom path and fail. dump_bad_graph("Bad graph detected in build_loop_late", n, early, LCA); assert(false, "Bad graph detected in build_loop_late"); - } #endif + C->record_method_not_compilable("Bad graph detected in build_loop_late"); + return; + } // Find least loop nesting depth legal = idom(legal); // Bump up the IDOM tree // Check for lower nesting depth From f60d396ca32e5ca9e6c492fa9fc1c138da08cffe Mon Sep 17 00:00:00 2001 From: Johannes Bechberger Date: Mon, 6 Nov 2023 23:40:26 +0000 Subject: [PATCH 302/341] 8317920: JDWP-agent sends broken exception event with onthrow option Reviewed-by: phh --- .../share/native/libjdwp/debugInit.c | 44 +++-- test/jdk/com/sun/jdi/JdwpOnThrowTest.java | 157 ++++++++++++++++++ .../jdk/com/sun/jdi/ThrowCaughtException.java | 36 ++++ test/jdk/com/sun/jdi/lib/jdb/Debuggee.java | 39 ++++- 4 files changed, 255 insertions(+), 21 deletions(-) create mode 100644 test/jdk/com/sun/jdi/JdwpOnThrowTest.java create mode 100644 test/jdk/com/sun/jdi/ThrowCaughtException.java diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c b/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c index 860b5cc190337..1ea0241516478 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c +++ b/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c @@ -102,7 +102,7 @@ static void JNICALL cbEarlyVMDeath(jvmtiEnv*, JNIEnv *); static void JNICALL cbEarlyException(jvmtiEnv*, JNIEnv *, jthread, jmethodID, jlocation, jobject, jmethodID, jlocation); -static void initialize(JNIEnv *env, jthread thread, EventIndex triggering_ei); +static void initialize(JNIEnv *env, jthread thread, EventIndex triggering_ei, EventInfo *opt_info); static jboolean parseOptions(char *str); /* @@ -438,7 +438,7 @@ cbEarlyVMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) EXIT_ERROR(AGENT_ERROR_INTERNAL,"VM dead at VM_INIT time"); } if (initOnStartup) - initialize(env, thread, EI_VM_INIT); + initialize(env, thread, EI_VM_INIT, NULL); vmInitialized = JNI_TRUE; LOG_MISC(("END cbEarlyVMInit")); } @@ -491,6 +491,16 @@ cbEarlyException(jvmtiEnv *jvmti_env, JNIEnv *env, LOG_MISC(("VM is not initialized yet")); return; } + EventInfo info; + info.ei = EI_EXCEPTION; + info.thread = thread; + info.clazz = getMethodClass(jvmti_env, method); + info.method = method; + info.location = location; + info.object = exception; + info.u.exception.catch_clazz = getMethodClass(jvmti_env, catch_method); + info.u.exception.catch_method = catch_method; + info.u.exception.catch_location = catch_location; /* * We want to preserve any current exception that might get wiped @@ -505,24 +515,22 @@ cbEarlyException(jvmtiEnv *jvmti_env, JNIEnv *env, if (initOnUncaught && catch_method == NULL) { LOG_MISC(("Initializing on uncaught exception")); - initialize(env, thread, EI_EXCEPTION); + initialize(env, thread, EI_EXCEPTION, &info); } else if (initOnException != NULL) { - jclass clazz; - - /* Get class of exception thrown */ - clazz = JNI_FUNC_PTR(env,GetObjectClass)(env, exception); - if ( clazz != NULL ) { + jclass exception_clazz = JNI_FUNC_PTR(env, GetObjectClass)(env, exception); + /* check class of exception thrown */ + if ( exception_clazz != NULL ) { char *signature = NULL; /* initing on throw, check */ - error = classSignature(clazz, &signature, NULL); + error = classSignature(exception_clazz, &signature, NULL); LOG_MISC(("Checking specific exception: looking for %s, got %s", initOnException, signature)); if ( (error==JVMTI_ERROR_NONE) && (strcmp(signature, initOnException) == 0)) { LOG_MISC(("Initializing on specific exception")); - initialize(env, thread, EI_EXCEPTION); + initialize(env, thread, EI_EXCEPTION, &info); } else { error = AGENT_ERROR_INTERNAL; /* Just to cause restore */ } @@ -663,9 +671,11 @@ jniFatalError(JNIEnv *env, const char *msg, jvmtiError error, int exit_code) /* * Initialize debugger back end modules + * + * @param opt_info optional event info to use, might be null */ static void -initialize(JNIEnv *env, jthread thread, EventIndex triggering_ei) +initialize(JNIEnv *env, jthread thread, EventIndex triggering_ei, EventInfo *opt_info) { jvmtiError error; EnumerateArg arg; @@ -753,13 +763,13 @@ initialize(JNIEnv *env, jthread thread, EventIndex triggering_ei) * can get in the queue (from other not-yet-suspended threads) * before this one does. (Also need to handle allocation error below?) */ - EventInfo info; struct bag *initEventBag; - LOG_MISC(("triggering_ei != EI_VM_INIT")); + LOG_MISC(("triggering_ei == EI_EXCEPTION")); + JDI_ASSERT(triggering_ei == EI_EXCEPTION); + JDI_ASSERT(opt_info != NULL); initEventBag = eventHelper_createEventBag(); - (void)memset(&info,0,sizeof(info)); - info.ei = triggering_ei; - eventHelper_recordEvent(&info, 0, suspendPolicy, initEventBag); + threadControl_onEventHandlerEntry(currentSessionID, opt_info, NULL); + eventHelper_recordEvent(opt_info, 0, suspendPolicy, initEventBag); (void)eventHelper_reportEvents(currentSessionID, initEventBag); bagDestroyBag(initEventBag); } @@ -1394,7 +1404,7 @@ JNIEXPORT char const* JNICALL debugInit_startDebuggingViaCommand(JNIEnv* env, jt if (!startedViaJcmd) { startedViaJcmd = JNI_TRUE; is_first_start = JNI_TRUE; - initialize(env, thread, EI_VM_INIT); + initialize(env, thread, EI_VM_INIT, NULL); } bagEnumerateOver(transports, getFirstTransport, &spec); diff --git a/test/jdk/com/sun/jdi/JdwpOnThrowTest.java b/test/jdk/com/sun/jdi/JdwpOnThrowTest.java new file mode 100644 index 0000000000000..d083b2a0e84cd --- /dev/null +++ b/test/jdk/com/sun/jdi/JdwpOnThrowTest.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2023 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 com.sun.jdi.Bootstrap; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.connect.AttachingConnector; +import com.sun.jdi.connect.Connector; +import com.sun.jdi.connect.IllegalConnectorArgumentsException; +import com.sun.jdi.event.EventIterator; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.event.Event; +import com.sun.jdi.event.ExceptionEvent; +import lib.jdb.Debuggee; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/* + * @test + * @bug 8317920 + * @summary Tests for JDWP agent to send valid exception event with onthrow option + * @library /test/lib + * + * @build ThrowCaughtException JdwpOnThrowTest + * @run main/othervm JdwpOnThrowTest + */ +public class JdwpOnThrowTest { + + private static long TIMEOUT = 10000; + + private static String ATTACH_CONNECTOR = "com.sun.jdi.SocketAttach"; + // cache socket attaching connector + private static AttachingConnector attachingConnector; + + public static void main(String[] args) throws Exception { + int port = findFreePort(); + try (Debuggee debuggee = Debuggee.launcher("ThrowCaughtException").setAddress("localhost:" + port) + .enableOnThrow("Ex", "Start").setSuspended(true).launch()) { + VirtualMachine vm = null; + try { + vm = attach("localhost", "" + port); + EventQueue queue = vm.eventQueue(); + log("Waiting for exception event"); + long start = System.currentTimeMillis(); + while (start + TIMEOUT > System.currentTimeMillis()) { + EventSet eventSet = queue.remove(TIMEOUT); + EventIterator eventIterator = eventSet.eventIterator(); + while(eventIterator.hasNext() && start + TIMEOUT > System.currentTimeMillis()) { + Event event = eventIterator.next(); + if (event instanceof ExceptionEvent ex) { + verifyExceptionEvent(ex); + log("Received exception event: " + event); + vm.dispose(); + return; + } + log("Received event: " + event); + } + } + throw new RuntimeException("ERROR: failed to receive exception event"); + } catch (IOException ex) { + throw new RuntimeException("ERROR: failed to attach", ex); + } + } + } + + private static void verifyExceptionEvent(ExceptionEvent ex) throws Exception { + if (ex.exception() == null) { + throw new RuntimeException("Exception is null"); + } + if (ex.exception().type() == null) { + throw new RuntimeException("Exception type is null"); + } + if (ex.exception().referenceType() == null) { + throw new RuntimeException("Exception reference type is null"); + } + if (ex.catchLocation() == null) { + throw new RuntimeException("Exception catch location is null"); + } + if (!ex.location().equals(ex.thread().frame(0).location())) { + throw new RuntimeException( + String.format("Throw location %s and location of first frame %s are not equal", + ex.location(), ex.thread().frame(0).location())); + } + if (!ex.exception().type().name().equals("Ex")) { + throw new RuntimeException("Exception has wrong type: " + ex.exception().type().name()); + } + } + + private static int findFreePort() { + try (ServerSocket socket = new ServerSocket(0)) { + return socket.getLocalPort(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static VirtualMachine attach(String address, String port) throws IOException { + if (attachingConnector == null) { + attachingConnector = (AttachingConnector)getConnector(ATTACH_CONNECTOR); + } + Map args = attachingConnector.defaultArguments(); + setConnectorArg(args, "hostname", address); + setConnectorArg(args, "port", port); + try { + return attachingConnector.attach(args); + } catch (IllegalConnectorArgumentsException e) { + // unexpected.. wrap in RuntimeException + throw new RuntimeException(e); + } + } + + private static Connector getConnector(String name) { + for (Connector connector : Bootstrap.virtualMachineManager().allConnectors()) { + if (connector.name().equalsIgnoreCase(name)) { + return connector; + } + } + throw new IllegalArgumentException("Connector " + name + " not found"); + } + + private static void setConnectorArg(Map args, String name, String value) { + Connector.Argument arg = args.get(name); + if (arg == null) { + throw new IllegalArgumentException("Argument " + name + " is not defined"); + } + arg.setValue(value); + } + + private static void log(Object o) { + System.out.println(String.valueOf(o)); + } + +} diff --git a/test/jdk/com/sun/jdi/ThrowCaughtException.java b/test/jdk/com/sun/jdi/ThrowCaughtException.java new file mode 100644 index 0000000000000..38253ad8875c3 --- /dev/null +++ b/test/jdk/com/sun/jdi/ThrowCaughtException.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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. + */ + + public class ThrowCaughtException { + public static void main(String args[]) throws Exception { + try { + System.out.println("Start"); + throw new Ex(); + } catch (Exception e) { + System.out.println(e); + } + } +} + +class Ex extends RuntimeException { +} diff --git a/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java b/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java index 71b3eb28d6dfb..b1a1b58e45817 100644 --- a/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java +++ b/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, 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 @@ -69,6 +69,9 @@ public static class Launcher { private String transport = "dt_socket"; private String address = null; private boolean suspended = true; + private String onthrow = ""; + private boolean waitForPortPrint = true; + private String expectedOutputBeforeThrow = ""; private Launcher(String mainClass) { this.mainClass = mainClass; @@ -101,21 +104,31 @@ public Launcher setSuspended(boolean value) { return this; } + // required to pass non null port with address and emit string before the throw + public Launcher enableOnThrow(String value, String expectedOutputBeforeThrow) { + this.onthrow = value; + this.waitForPortPrint = false; + this.expectedOutputBeforeThrow = expectedOutputBeforeThrow; + return this; + } + public ProcessBuilder prepare() { List debuggeeArgs = new LinkedList<>(); if (vmOptions != null) { debuggeeArgs.add(vmOptions); } + String onthrowArgs = onthrow.isEmpty() ? "" : ",onthrow=" + onthrow + ",launch=exit"; debuggeeArgs.add("-agentlib:jdwp=transport=" + transport + (address == null ? "" : ",address=" + address) - + ",server=y,suspend=" + (suspended ? "y" : "n")); + + ",server=y,suspend=" + (suspended ? "y" : "n") + + onthrowArgs); debuggeeArgs.addAll(options); debuggeeArgs.add(mainClass); return ProcessTools.createTestJvm(debuggeeArgs); } public Debuggee launch(String name) { - return new Debuggee(prepare(), name); + return new Debuggee(prepare(), name, waitForPortPrint, expectedOutputBeforeThrow); } public Debuggee launch() { return launch("debuggee"); @@ -123,10 +136,22 @@ public Debuggee launch() { } // starts the process, waits for "Listening for transport" output and detects transport/address - private Debuggee(ProcessBuilder pb, String name) { + private Debuggee(ProcessBuilder pb, String name, boolean waitForPortPrint, String expectedOutputBeforeThrow) { // debuggeeListen[0] - transport, debuggeeListen[1] - address String[] debuggeeListen = new String[2]; Pattern listenRegexp = Pattern.compile("Listening for transport \\b(.+)\\b at address: \\b(.+)\\b"); + if (!waitForPortPrint) { + try { + p = ProcessTools.startProcess(name, pb, s -> {output.add(s);}, s -> { + return s.equals(expectedOutputBeforeThrow); + }, 30, TimeUnit.SECONDS); + } catch (IOException | InterruptedException | TimeoutException ex) { + throw new RuntimeException("failed to launch debuggee", ex); + } + transport = null; + address = null; + return; + } try { p = ProcessTools.startProcess(name, pb, s -> output.add(s), // output consumer @@ -175,10 +200,16 @@ public String getOutput() { } String getTransport() { + if (transport == null) { + throw new IllegalStateException("transport is not available"); + } return transport; } public String getAddress() { + if (address == null) { + throw new IllegalStateException("address is not available"); + } return address; } From 64c20485bc1df425bc84ea3397717ade20516757 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Nov 2023 10:56:45 +0000 Subject: [PATCH 303/341] 8299241: jdk/jfr/api/consumer/streaming/TestJVMCrash.java generates unnecessary core file Backport-of: 188911c925e4067c7f912c5ddb6f715bad7a3892 --- test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java | 4 ++-- test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java index c1594462a8030..be5acdddd75a4 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. * 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 TestJVMCrash { public static void main(String... args) throws Exception { int id = 1; while (true) { - try (TestProcess process = new TestProcess("crash-application-" + id++)) { + try (TestProcess process = new TestProcess("crash-application-" + id++, false /* createCore */)) { AtomicInteger eventCounter = new AtomicInteger(); try (EventStream es = EventStream.openRepository(process.getRepository())) { // Start from first event in repository diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java index 4c03668cec27d..8643ec35bc243 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, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. * 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,11 +54,16 @@ private static class TestEvent extends Event { private final Path path; public TestProcess(String name) throws IOException { + this(name, true /* createCore */); + } + + public TestProcess(String name, boolean createCore) throws IOException { this.path = Paths.get("action-" + System.currentTimeMillis()).toAbsolutePath(); String[] args = { "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:StartFlightRecording:settings=none", + "-XX:" + (createCore ? "+" : "-") + "CreateCoredumpOnCrash", TestProcess.class.getName(), path.toString() }; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); From aaa26d5abfd5250329f8b8ed13dfcca074f33f7d Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Nov 2023 10:59:10 +0000 Subject: [PATCH 304/341] 8307123: Fix deprecation warnings in DPrinter Backport-of: b76f320e76f0fb58c598fdd7a5937f1b5bb1de15 --- test/langtools/tools/javac/lib/DPrinter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/langtools/tools/javac/lib/DPrinter.java b/test/langtools/tools/javac/lib/DPrinter.java index e230113864439..bea439a2eab5b 100644 --- a/test/langtools/tools/javac/lib/DPrinter.java +++ b/test/langtools/tools/javac/lib/DPrinter.java @@ -601,6 +601,7 @@ protected void indent(int n) { protected Object getField(Object o, Class clazz, String name) { try { Field f = clazz.getDeclaredField(name); + @SuppressWarnings("deprecation") boolean prev = f.isAccessible(); f.setAccessible(true); try { @@ -618,6 +619,7 @@ protected Object getField(Object o, Class clazz, String name) { protected Object callMethod(Object o, Class clazz, String name) { try { Method m = clazz.getDeclaredMethod(name); + @SuppressWarnings("deprecation") boolean prev = m.isAccessible(); m.setAccessible(true); try { From d760d9d7b40f601bcadf0ef1f7dfe763ee27a2a7 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Nov 2023 11:10:48 +0000 Subject: [PATCH 305/341] 8314242: Update applications/scimark/Scimark.java to accept VM flags Backport-of: 6bf4a33593bfe0df9b5ba81de5321a04f4dbe0ea --- test/hotspot/jtreg/applications/scimark/Scimark.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/applications/scimark/Scimark.java b/test/hotspot/jtreg/applications/scimark/Scimark.java index 96c5dccabeff7..8aab97aa2bc02 100644 --- a/test/hotspot/jtreg/applications/scimark/Scimark.java +++ b/test/hotspot/jtreg/applications/scimark/Scimark.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 @@ -24,7 +24,6 @@ /* * @test * @library /test/lib - * @requires vm.flagless * @run driver Scimark */ @@ -47,7 +46,9 @@ public static void main(String... args) throws Exception { + Scimark.class.getName(), e); } - OutputAnalyzer output = new OutputAnalyzer(ProcessTools.createJavaProcessBuilder( + System.setProperty("test.noclasspath", "true"); + + OutputAnalyzer output = new OutputAnalyzer(ProcessTools.createTestJvm( "-cp", artifacts.get("gov.nist.math.scimark-2.0").toString(), "jnt.scimark2.commandline", "-large") .start()); From fc7650f69ea3756c22853ccaf7cdfaca38862e53 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Nov 2023 11:13:16 +0000 Subject: [PATCH 306/341] 8161536: sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java fails with ProviderException Backport-of: 939d7c5d8466f9e392beae2947a494ac28695cc1 --- test/jdk/ProblemList.txt | 2 -- test/jdk/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 154fa026c78d6..cd43a6473d16a 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -630,8 +630,6 @@ com/sun/nio/sctp/SctpChannel/SocketOptionTests.java 8141694 linux-al # jdk_security -sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic-all - javax/net/ssl/DTLS/CipherSuite.java 8202059 macosx-x64 sun/security/smartcardio/TestChannel.java 8039280 generic-all diff --git a/test/jdk/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java b/test/jdk/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java index 43efcd5afbb9e..08b29fe6df189 100644 --- a/test/jdk/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java +++ b/test/jdk/sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.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 @@ -37,7 +37,7 @@ * @run main/othervm -Djdk.tls.namedGroups="secp256r1,sect193r1" * ClientJSSEServerJSSE * @run main/othervm -Djdk.tls.namedGroups="secp256r1,sect193r1" - * ClientJSSEServerJSSE sm policy + * -Djava.security.manager=allow ClientJSSEServerJSSE sm policy */ import java.security.Provider; From 2486ba2899f1e51418fa73f6216b5224b4a348c5 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Nov 2023 11:17:49 +0000 Subject: [PATCH 307/341] 8315415: OutputAnalyzer.shouldMatchByLine() fails in some cases Backport-of: 7b1e2bfe0f805a69b59839b6bf8250b62ea356b8 --- .../jdk/test/lib/process/OutputAnalyzer.java | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/test/lib/jdk/test/lib/process/OutputAnalyzer.java b/test/lib/jdk/test/lib/process/OutputAnalyzer.java index a36c48ce818e7..f554b969f4eee 100644 --- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java +++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.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 @@ -671,15 +671,15 @@ public OutputAnalyzer stdoutShouldMatchByLine(String pattern) { /** * @see #shouldMatchByLine(String, String, String) */ - public OutputAnalyzer shouldMatchByLineFrom(String from, String pattern) { - return shouldMatchByLine(from, null, pattern); + public OutputAnalyzer shouldMatchByLineFrom(String fromPattern, String pattern) { + return shouldMatchByLine(fromPattern, null, pattern); } /** * @see #shouldMatchByLine(String, String, String) */ - public OutputAnalyzer shouldMatchByLineTo(String to, String pattern) { - return shouldMatchByLine(null, to, pattern); + public OutputAnalyzer shouldMatchByLineTo(String toPattern, String pattern) { + return shouldMatchByLine(null, toPattern, pattern); } /** @@ -687,17 +687,17 @@ public OutputAnalyzer shouldMatchByLineTo(String to, String pattern) { * {@code pattern} line by line. The whole output could be matched or * just a subset of it. * - * @param from - * The line (excluded) from where output will be matched. - * Set {@code from} to null for matching from the first line. - * @param to - * The line (excluded) until where output will be matched. - * Set {@code to} to null for matching until the last line. + * @param fromPattern + * The pattern of line (excluded) from where output will be matched. + * Set {@code fromPattern} to null for matching from the first line. + * @param toPattern + * The pattern of line (excluded) until where output will be matched. + * Set {@code toPattern} to null for matching until the last line. * @param pattern * Matching pattern */ - public OutputAnalyzer shouldMatchByLine(String from, String to, String pattern) { - return shouldMatchByLine(getOutput(), from, to, pattern); + public OutputAnalyzer shouldMatchByLine(String fromPattern, String toPattern, String pattern) { + return shouldMatchByLine(getOutput(), fromPattern, toPattern, pattern); } /** @@ -705,34 +705,34 @@ public OutputAnalyzer shouldMatchByLine(String from, String to, String pattern) * {@code pattern} line by line. The whole stdout could be matched or * just a subset of it. * - * @param from - * The line (excluded) from where stdout will be matched. - * Set {@code from} to null for matching from the first line. - * @param to - * The line (excluded) until where stdout will be matched. - * Set {@code to} to null for matching until the last line. + * @param fromPattern + * The pattern of line (excluded) from where stdout will be matched. + * Set {@code fromPattern} to null for matching from the first line. + * @param toPattern + * The pattern of line (excluded) until where stdout will be matched. + * Set {@code toPattern} to null for matching until the last line. * @param pattern * Matching pattern */ - public OutputAnalyzer stdoutShouldMatchByLine(String from, String to, String pattern) { - return shouldMatchByLine(getStdout(), from, to, pattern); + public OutputAnalyzer stdoutShouldMatchByLine(String fromPattern, String toPattern, String pattern) { + return shouldMatchByLine(getStdout(), fromPattern, toPattern, pattern); } - private OutputAnalyzer shouldMatchByLine(String buffer, String from, String to, String pattern) { + private OutputAnalyzer shouldMatchByLine(String buffer, String fromPattern, String toPattern, String pattern) { List lines = asLines(buffer); int fromIndex = 0; - if (from != null) { - fromIndex = indexOf(lines, from, 0) + 1; // + 1 -> apply 'pattern' to lines after 'from' match + if (fromPattern != null) { + fromIndex = indexOf(lines, fromPattern, 0) + 1; // + 1 -> apply 'pattern' to lines after 'from' match Asserts.assertGreaterThan(fromIndex, 0, - "The line/pattern '" + from + "' from where the output should match can not be found"); + "The line matched with pattern '" + fromPattern + "' from where the output should match can not be found"); } int toIndex = lines.size(); - if (to != null) { - toIndex = indexOf(lines, to, fromIndex); + if (toPattern != null) { + toIndex = indexOf(lines, toPattern, fromIndex); Asserts.assertGreaterThan(toIndex, fromIndex, - "The line/pattern '" + to + "' until where the output should match can not be found"); + "The line matched with pattern '" + toPattern + "' until where the output should match can not be found"); } List subList = lines.subList(fromIndex, toIndex); From 5cb86e3fc95fe71b98f9127a070f69ce18a4a37f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 8 Nov 2023 01:01:12 +0000 Subject: [PATCH 308/341] 8273831: PrintServiceLookup spawns 2 threads in the current classloader, getting orphaned Backport-of: 687567822a5380fb7d8c5b54ae548b2a5c848187 --- .../sun/print/PrintServiceLookupProvider.java | 20 +++-- .../sun/print/PrintServiceLookupProvider.java | 29 +++++-- .../FlushCustomClassLoader.java | 84 +++++++++++++++++++ 3 files changed, 117 insertions(+), 16 deletions(-) create mode 100644 test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java diff --git a/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java b/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java index eeff669dfcee7..876913553af0b 100644 --- a/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java +++ b/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java @@ -26,10 +26,8 @@ package sun.print; import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.InputStream; -import java.io.InputStreamReader; import java.io.IOException; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Vector; import java.security.AccessController; @@ -54,6 +52,8 @@ import java.net.URL; import java.nio.file.Files; +import sun.awt.util.ThreadGroupUtils; + /* * Remind: This class uses solaris commands. We also need a linux * version @@ -204,14 +204,18 @@ static int getBSDCommandIndex() { return BSD_LPD; } - + @SuppressWarnings("removal") public PrintServiceLookupProvider() { // start the printer listener thread if (pollServices) { - Thread thr = new Thread(null, new PrinterChangeListener(), - "PrinterListener", 0, false); - thr.setDaemon(true); - thr.start(); + AccessController.doPrivileged((PrivilegedAction) () -> { + Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(), + new PrinterChangeListener(), + "PrinterListener", 0, false); + thr.setContextClassLoader(null); + thr.setDaemon(true); + return thr; + }).start(); IPPPrintService.debug_println(debugPrefix+"polling turned on"); } } diff --git a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java index 1d76ebae4799c..28055c1afece6 100644 --- a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java +++ b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java @@ -25,6 +25,8 @@ package sun.print; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import javax.print.DocFlavor; @@ -41,6 +43,8 @@ import javax.print.attribute.PrintServiceAttributeSet; import javax.print.attribute.standard.PrinterName; +import sun.awt.util.ThreadGroupUtils; + public class PrintServiceLookupProvider extends PrintServiceLookup { private PrintService defaultPrintService; @@ -81,22 +85,31 @@ public static PrintServiceLookupProvider getWin32PrintLUS() { return win32PrintLUS; } + @SuppressWarnings("removal") public PrintServiceLookupProvider() { if (win32PrintLUS == null) { win32PrintLUS = this; // start the local printer listener thread - Thread thr = new Thread(null, new PrinterChangeListener(), - "PrinterListener", 0, false); - thr.setDaemon(true); - thr.start(); + AccessController.doPrivileged((PrivilegedAction) () -> { + Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(), + new PrinterChangeListener(), + "PrinterListener", 0, false); + thr.setContextClassLoader(null); + thr.setDaemon(true); + return thr; + }).start(); // start the remote printer listener thread - Thread remThr = new Thread(null, new RemotePrinterChangeListener(), - "RemotePrinterListener", 0, false); - remThr.setDaemon(true); - remThr.start(); + AccessController.doPrivileged((PrivilegedAction) () -> { + Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(), + new RemotePrinterChangeListener(), + "RemotePrinterListener", 0, false); + thr.setContextClassLoader(null); + thr.setDaemon(true); + return thr; + }).start(); } /* else condition ought to never happen! */ } diff --git a/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java b/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java new file mode 100644 index 0000000000000..6e0a25a69d0a5 --- /dev/null +++ b/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java @@ -0,0 +1,84 @@ +/* + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.EventQueue; +import java.lang.ref.Reference; +import java.lang.ref.WeakReference; +import java.net.URL; +import java.net.URLClassLoader; + +import javax.print.DocFlavor; +import javax.print.PrintServiceLookup; + +/** + * @test + * @bug 8273831 + * @summary Tests custom class loader cleanup + */ +public final class FlushCustomClassLoader { + + public static void main(String[] args) throws Exception { + Reference loader = getLoader("testMethod"); + + int attempt = 0; + while (loader.get() != null) { + if (++attempt > 10) { + throw new RuntimeException("Too many attempts: " + attempt); + } + System.gc(); + Thread.sleep(1000); + System.out.println("Not freed, attempt: " + attempt); + } + } + + public static void testMethod() { + DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; + PrintServiceLookup.lookupPrintServices(flavor, null); + } + + private static Reference getLoader(String m) throws Exception { + /* + * The print services are stored per the AppContext, and each AppContext + * caches the "current" class loader during creation. + * see javax.print.PrintServiceLookup. + * + * To prevent AppContext from cache our test loader we force AppContext + * creation early by the invokeAndWait. + * The "EventQueue.invokeAndWait(() -> {});" can be removed when the + * AppContext usage will be deleted in the PrintServiceLookup + */ + EventQueue.invokeAndWait(() -> {}); + + URL url = FlushCustomClassLoader.class.getProtectionDomain() + .getCodeSource().getLocation(); + URLClassLoader loader = new URLClassLoader(new URL[]{url}, null); + + Thread ct = Thread.currentThread(); + ct.setContextClassLoader(loader); + Class cls = Class.forName("FlushCustomClassLoader", true, loader); + cls.getDeclaredMethod(m).invoke(null); + ct.setContextClassLoader(null); + loader.close(); + return new WeakReference<>(loader); + } +} From 1240b3415143de20c2a985784ad46915d4aad2b0 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 8 Nov 2023 05:40:09 +0000 Subject: [PATCH 309/341] 8276819: javax/print/PrintServiceLookup/FlushCustomClassLoader.java fails to free Backport-of: 7c2c58587d4eda5523331eae45e7d897252dc097 --- .../PrintServiceLookup/FlushCustomClassLoader.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java b/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java index 6e0a25a69d0a5..4ec95fb75354e 100644 --- a/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java +++ b/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java @@ -34,6 +34,9 @@ * @test * @bug 8273831 * @summary Tests custom class loader cleanup + * @library /javax/swing/regtesthelpers + * @build Util + * @run main/timeout=60/othervm -mx32m FlushCustomClassLoader */ public final class FlushCustomClassLoader { @@ -42,12 +45,8 @@ public static void main(String[] args) throws Exception { int attempt = 0; while (loader.get() != null) { - if (++attempt > 10) { - throw new RuntimeException("Too many attempts: " + attempt); - } - System.gc(); - Thread.sleep(1000); - System.out.println("Not freed, attempt: " + attempt); + Util.generateOOME(); + System.out.println("Not freed, attempt: " + attempt++); } } From a4fe7ac147705c96682ce472964d464c30a87e0e Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 8 Nov 2023 20:53:16 +0000 Subject: [PATCH 310/341] 8316461: Fix: make test outputs TEST SUCCESS after unsuccessful exit Backport-of: e30e3564420c631f08ac3d613ab91c93227a00b3 --- make/RunTests.gmk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/make/RunTests.gmk b/make/RunTests.gmk index ebc96272d66ea..9a0eb11d040a0 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -841,8 +841,9 @@ define SetupRunJtregTestBody endif endif - clean-workdir-$1: + clean-outputdirs-$1: $$(RM) -r $$($1_TEST_SUPPORT_DIR) + $$(RM) -r $$($1_TEST_RESULTS_DIR) $1_COMMAND_LINE := \ $$(JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \ @@ -887,7 +888,7 @@ define SetupRunJtregTestBody done endif - run-test-$1: pre-run-test clean-workdir-$1 + run-test-$1: pre-run-test clean-outputdirs-$1 $$(call LogWarn) $$(call LogWarn, Running test '$$($1_TEST)') $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR) \ @@ -924,9 +925,9 @@ define SetupRunJtregTestBody $$(eval $1_TOTAL := 1) \ ) - $1: run-test-$1 parse-test-$1 clean-workdir-$1 + $1: run-test-$1 parse-test-$1 clean-outputdirs-$1 - TARGETS += $1 run-test-$1 parse-test-$1 clean-workdir-$1 + TARGETS += $1 run-test-$1 parse-test-$1 clean-outputdirs-$1 TEST_TARGETS += parse-test-$1 endef From 8b9a72ef6c0ec4467e02d3dc83eb78fb4aa73a5c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 9 Nov 2023 14:55:41 +0000 Subject: [PATCH 311/341] 8317374: Add Let's Encrypt ISRG Root X2 Reviewed-by: mdoerr Backport-of: e6f46a43268808d0cbbb3bb93c73aa8e4cbfad83 --- make/data/cacerts/letsencryptisrgx2 | 21 +++++++++++++++++++ .../certification/CAInterop.java | 14 ++++++++++++- .../security/lib/cacerts/VerifyCACerts.java | 8 ++++--- 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 make/data/cacerts/letsencryptisrgx2 diff --git a/make/data/cacerts/letsencryptisrgx2 b/make/data/cacerts/letsencryptisrgx2 new file mode 100644 index 0000000000000..455822e13a810 --- /dev/null +++ b/make/data/cacerts/letsencryptisrgx2 @@ -0,0 +1,21 @@ +Owner: CN=ISRG Root X2, O=Internet Security Research Group, C=US +Issuer: CN=ISRG Root X2, O=Internet Security Research Group, C=US +Serial number: 41d29dd172eaeea780c12c6ce92f8752 +Valid from: Fri Sep 04 00:00:00 GMT 2020 until: Mon Sep 17 16:00:00 GMT 2040 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICGzCCAaGgAwIBAgIQQdKd0XLq7qeAwSxs6S+HUjAKBggqhkjOPQQDAzBPMQsw +CQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2gg +R3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBYMjAeFw0yMDA5MDQwMDAwMDBaFw00 +MDA5MTcxNjAwMDBaME8xCzAJBgNVBAYTAlVTMSkwJwYDVQQKEyBJbnRlcm5ldCBT +ZWN1cml0eSBSZXNlYXJjaCBHcm91cDEVMBMGA1UEAxMMSVNSRyBSb290IFgyMHYw +EAYHKoZIzj0CAQYFK4EEACIDYgAEzZvVn4CDCuwJSvMWSj5cz3es3mcFDR0HttwW ++1qLFNvicWDEukWVEYmO6gbf9yoWHKS5xcUy4APgHoIYOIvXRdgKam7mAHf7AlF9 +ItgKbppbd9/w+kHsOdx1ymgHDB/qo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0T +AQH/BAUwAwEB/zAdBgNVHQ4EFgQUfEKWrt5LSDv6kviejM9ti6lyN5UwCgYIKoZI +zj0EAwMDaAAwZQIwe3lORlCEwkSHRhtFcP9Ymd70/aTSVaYgLXTWNLxBo1BfASdW +tL4ndQavEi51mI38AjEAi/V3bNTIZargCyzuFJ0nN6T5U6VR5CmD1/iQMVtCnwr1 +/q4AaOeMSQ+2b1tbFfLn +-----END CERTIFICATE----- diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java index dbdcb810c478d..a890040e3a159 100644 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java @@ -136,12 +136,21 @@ /* * @test id=letsencryptisrgx1 * @bug 8189131 - * @summary Interoperability tests with Let's Encrypt CA + * @summary Interoperability tests with Let's Encrypt ISRG Root X1 CA * @library /test/lib * @build jtreg.SkippedException ValidatePathWithURL CAInterop * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop letsencryptisrgx1 DEFAULT */ +/* + * @test id=letsencryptisrgx2 + * @bug 8317374 + * @summary Interoperability tests with Let's Encrypt ISRG Root X2 CA + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop letsencryptisrgx2 DEFAULT + */ + /* * @test id=globalsignrootcar6 * @bug 8216577 @@ -455,6 +464,9 @@ private CATestURLs getTestURLs(String alias) { case "letsencryptisrgx1" -> new CATestURLs("https://valid-isrgrootx1.letsencrypt.org", "https://revoked-isrgrootx1.letsencrypt.org"); + case "letsencryptisrgx2" -> + new CATestURLs("https://valid-isrgrootx2.letsencrypt.org", + "https://revoked-isrgrootx2.letsencrypt.org"); case "globalsignrootcar6" -> new CATestURLs("https://valid.r6.roots.globalsign.com", diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java index f8d8be1f425be..5084c77e25cdd 100644 --- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java +++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java @@ -28,7 +28,7 @@ * 8209452 8209506 8210432 8195793 8216577 8222089 8222133 8222137 8222136 * 8223499 8225392 8232019 8234245 8233223 8225068 8225069 8243321 8243320 * 8243559 8225072 8258630 8259312 8256421 8225081 8225082 8225083 8245654 - * 8305975 8304760 8307134 8295894 8314960 8317373 + * 8305975 8304760 8307134 8295894 8314960 8317373 8317374 * @summary Check root CA entries in cacerts file */ import java.io.ByteArrayInputStream; @@ -47,12 +47,12 @@ public class VerifyCACerts { + File.separator + "security" + File.separator + "cacerts"; // The numbers of certs now. - private static final int COUNT = 98; + private static final int COUNT = 99; // SHA-256 of cacerts, can be generated with // shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95 private static final String CHECKSUM - = "63:A7:1F:4F:8E:4B:A1:04:DE:BB:EC:2E:31:35:5B:5A:19:D4:B1:C0:59:62:B1:13:65:C3:AE:C7:DB:78:9A:1E"; + = "DA:61:45:1C:93:F3:6A:30:24:68:C6:72:BC:C5:E6:E4:E3:BA:6A:AE:36:29:7B:45:53:B7:10:53:52:7D:7E:A5"; // Hex formatter to upper case with ":" delimiter private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase(); @@ -146,6 +146,8 @@ public class VerifyCACerts { "5D:56:49:9B:E4:D2:E0:8B:CF:CA:D0:8A:3E:38:72:3D:50:50:3B:DE:70:69:48:E4:2F:55:60:30:19:E5:28:AE"); put("letsencryptisrgx1 [jdk]", "96:BC:EC:06:26:49:76:F3:74:60:77:9A:CF:28:C5:A7:CF:E8:A3:C0:AA:E1:1A:8F:FC:EE:05:C0:BD:DF:08:C6"); + put("letsencryptisrgx2 [jdk]", + "69:72:9B:8E:15:A8:6E:FC:17:7A:57:AF:B7:17:1D:FC:64:AD:D2:8C:2F:CA:8C:F1:50:7E:34:45:3C:CB:14:70"); put("luxtrustglobalrootca [jdk]", "A1:B2:DB:EB:64:E7:06:C6:16:9E:3C:41:18:B2:3B:AA:09:01:8A:84:27:66:6D:8B:F0:E2:88:91:EC:05:19:50"); put("quovadisrootca [jdk]", From 312f8c0594904d32af1c9a0c898aa14514821598 Mon Sep 17 00:00:00 2001 From: Feilong Jiang Date: Fri, 10 Nov 2023 02:39:24 +0000 Subject: [PATCH 312/341] 8319525: RISC-V: Rename *_riscv64.ad files to *_riscv.ad under riscv/gc Reviewed-by: fyang Backport-of: b2504a0f9cff1f4fdf8f5bb20c4b48a53ba0be77 --- .../gc/shenandoah/{shenandoah_riscv64.ad => shenandoah_riscv.ad} | 0 src/hotspot/cpu/riscv/gc/z/{z_riscv64.ad => z_riscv.ad} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/hotspot/cpu/riscv/gc/shenandoah/{shenandoah_riscv64.ad => shenandoah_riscv.ad} (100%) rename src/hotspot/cpu/riscv/gc/z/{z_riscv64.ad => z_riscv.ad} (100%) diff --git a/src/hotspot/cpu/riscv/gc/shenandoah/shenandoah_riscv64.ad b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoah_riscv.ad similarity index 100% rename from src/hotspot/cpu/riscv/gc/shenandoah/shenandoah_riscv64.ad rename to src/hotspot/cpu/riscv/gc/shenandoah/shenandoah_riscv.ad diff --git a/src/hotspot/cpu/riscv/gc/z/z_riscv64.ad b/src/hotspot/cpu/riscv/gc/z/z_riscv.ad similarity index 100% rename from src/hotspot/cpu/riscv/gc/z/z_riscv64.ad rename to src/hotspot/cpu/riscv/gc/z/z_riscv.ad From b50655948063df828be9cec993a687578e0d204d Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Fri, 10 Nov 2023 11:07:35 +0000 Subject: [PATCH 313/341] 8309258: RISC-V: Add riscv_hwprobe syscall 8315206: RISC-V: hwprobe query is_set return wrong value 8316859: RISC-V: Disable detection of V through HWCAP Reviewed-by: fyang Backport-of: 31b6fd775f1c4f2841d9a52ad5f275ad446ee661 --- src/hotspot/cpu/riscv/vm_version_riscv.cpp | 44 ++-- src/hotspot/cpu/riscv/vm_version_riscv.hpp | 194 ++++++++++++--- .../os_cpu/linux_riscv/riscv_hwprobe.cpp | 136 +++++++++++ .../os_cpu/linux_riscv/riscv_hwprobe.hpp | 39 +++ .../linux_riscv/vm_version_linux_riscv.cpp | 230 ++++++++++++++---- 5 files changed, 535 insertions(+), 108 deletions(-) create mode 100644 src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp create mode 100644 src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.hpp diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index 1ce789dcc47f2..6d3640b7fe27e 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2023, Rivos Inc. All rights reserved. * 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,10 +33,18 @@ #include OS_HEADER_INLINE(os) -const char* VM_Version::_uarch = ""; -const char* VM_Version::_vm_mode = ""; uint32_t VM_Version::_initial_vector_length = 0; +#define DEF_RV_FEATURE(NAME, PRETTY, BIT, FSTRING, FLAGF) \ +VM_Version::NAME##RVFeatureValue VM_Version::NAME(PRETTY, BIT, FSTRING); +RV_FEATURE_FLAGS(DEF_RV_FEATURE) + +#define ADD_RV_FEATURE_IN_LIST(NAME, PRETTY, BIT, FSTRING, FLAGF) \ + &VM_Version::NAME, +VM_Version::RVFeatureValue* VM_Version::_feature_list[] = { +RV_FEATURE_FLAGS(ADD_RV_FEATURE_IN_LIST) + nullptr}; + void VM_Version::initialize() { _supports_cx8 = true; _supports_atomic_getset4 = true; @@ -43,13 +52,14 @@ void VM_Version::initialize() { _supports_atomic_getset8 = true; _supports_atomic_getadd8 = true; - get_os_cpu_info(); + setup_cpu_available_features(); // check if satp.mode is supported, currently supports up to SV48(RV64) - if (get_satp_mode() > VM_SV48) { + if (satp_mode.value() > VM_SV48 || satp_mode.value() < VM_MBARE) { vm_exit_during_initialization( - err_msg("Unsupported satp mode: %s. Only satp modes up to sv48 are supported for now.", - _vm_mode)); + err_msg( + "Unsupported satp mode: SV%d. Only satp modes up to sv48 are supported for now.", + (int)satp_mode.value())); } if (FLAG_IS_DEFAULT(UseFMA)) { @@ -121,22 +131,26 @@ void VM_Version::initialize() { } if (UseRVV) { - if (!(_features & CPU_V)) { + if (!ext_V.enabled()) { warning("RVV is not supported on this CPU"); FLAG_SET_DEFAULT(UseRVV, false); } else { // read vector length from vector CSR vlenb - _initial_vector_length = get_current_vector_length(); + _initial_vector_length = cpu_vector_length(); } } - if (UseRVC && !(_features & CPU_C)) { + if (UseRVC && !ext_C.enabled()) { warning("RVC is not supported on this CPU"); FLAG_SET_DEFAULT(UseRVC, false); } if (FLAG_IS_DEFAULT(AvoidUnalignedAccesses)) { - FLAG_SET_DEFAULT(AvoidUnalignedAccesses, true); + if (unaligned_access.value() != MISALIGNED_FAST) { + FLAG_SET_DEFAULT(AvoidUnalignedAccesses, true); + } else { + FLAG_SET_DEFAULT(AvoidUnalignedAccesses, false); + } } if (UseZbb) { @@ -147,16 +161,6 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UsePopCountInstruction, false); } - char buf[512]; - buf[0] = '\0'; - if (_uarch != NULL && strcmp(_uarch, "") != 0) snprintf(buf, sizeof(buf), "%s,", _uarch); - strcat(buf, "rv64"); -#define ADD_FEATURE_IF_SUPPORTED(id, name, bit) if (_features & CPU_##id) strcat(buf, name); - CPU_FEATURE_FLAGS(ADD_FEATURE_IF_SUPPORTED) -#undef ADD_FEATURE_IF_SUPPORTED - - _features_string = os::strdup(buf); - #ifdef COMPILER2 c2_initialize(); #endif // COMPILER2 diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.hpp b/src/hotspot/cpu/riscv/vm_version_riscv.hpp index 39c127e9285b7..3d91fa986f889 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.hpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.hpp @@ -2,6 +2,7 @@ * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2023, Rivos Inc. All rights reserved. * 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,53 +31,174 @@ #include "runtime/abstract_vm_version.hpp" #include "runtime/arguments.hpp" #include "runtime/globals_extension.hpp" +#include "utilities/globalDefinitions.hpp" +#include "utilities/growableArray.hpp" #include "utilities/sizes.hpp" +class RiscvHwprobe; + class VM_Version : public Abstract_VM_Version { -#ifdef COMPILER2 -private: - static void c2_initialize(); -#endif // COMPILER2 + friend RiscvHwprobe; + private: + class RVFeatureValue { + const char* const _pretty; + const bool _feature_string; + const uint64_t _feature_bit; + bool _enabled; + int64_t _value; + public: + RVFeatureValue(const char* pretty, int bit_num, bool fstring) : + _pretty(pretty), _feature_string(fstring), _feature_bit(nth_bit(bit_num)), + _enabled(false), _value(-1) { + } + void enable_feature(int64_t value = 0) { + _enabled = true; + _value = value; + } + const char* const pretty() { return _pretty; } + const uint64_t feature_bit() { return _feature_bit; } + const bool feature_string() { return _feature_string; } + bool enabled() { return _enabled; } + int64_t value() { return _value; } + virtual void update_flag() = 0; + }; -// VM modes (satp.mode) privileged ISA 1.10 -enum VM_MODE { - VM_MBARE = 0, - VM_SV39 = 8, - VM_SV48 = 9, - VM_SV57 = 10, - VM_SV64 = 11 -}; + #define UPDATE_DEFAULT(flag) \ + void update_flag() { \ + assert(enabled(), "Must be."); \ + if (FLAG_IS_DEFAULT(flag)) { \ + FLAG_SET_DEFAULT(flag, true); \ + } \ + } \ + + #define NO_UPDATE_DEFAULT \ + void update_flag() {} \ + + // Frozen standard extensions + // I RV64I + // M Integer Multiplication and Division + // A Atomic Instructions + // F Single-Precision Floating-Point + // D Single-Precision Floating-Point + // (G = M + A + F + D) + // Q Quad-Precision Floating-Point + // C Compressed Instructions + // H Hypervisor + // + // Others, open and non-standard + // V Vector + // + // Cache Management Operations + // Zicbom Cache Block Management Operations + // Zicboz Cache Block Zero Operations + // Zicbop Cache Block Prefetch Operations + // + // Bit-manipulation + // Zba Address generation instructions + // Zbb Basic bit-manipulation + // Zbc Carry-less multiplication + // Zbs Single-bit instructions + // + // Zicsr Control and Status Register (CSR) Instructions + // Zifencei Instruction-Fetch Fence + // Zic64b Cache blocks must be 64 bytes in size, naturally aligned in the address space. + // Zihintpause Pause instruction HINT + // + // Other features and settings + // mvendorid Manufactory JEDEC id encoded, ISA vol 2 3.1.2.. + // marchid Id for microarch. Mvendorid plus marchid uniquely identify the microarch. + // mimpid A unique encoding of the version of the processor implementation. + // unaligned_access Unaligned memory accesses (unknown, unspported, emulated, slow, firmware, fast) + // satp mode SATP bits (number of virtual addr bits) mbare, sv39, sv48, sv57, sv64 + + #define RV_NO_FLAG_BIT (BitsPerWord+1) // nth_bit will return 0 on values larger than BitsPerWord + + // declaration name , extension name, bit pos ,in str, mapped flag) + #define RV_FEATURE_FLAGS(decl) \ + decl(ext_I , "i" , ('I' - 'A'), true , NO_UPDATE_DEFAULT) \ + decl(ext_M , "m" , ('M' - 'A'), true , NO_UPDATE_DEFAULT) \ + decl(ext_A , "a" , ('A' - 'A'), true , NO_UPDATE_DEFAULT) \ + decl(ext_F , "f" , ('F' - 'A'), true , NO_UPDATE_DEFAULT) \ + decl(ext_D , "d" , ('D' - 'A'), true , NO_UPDATE_DEFAULT) \ + decl(ext_C , "c" , ('C' - 'A'), true , UPDATE_DEFAULT(UseRVC)) \ + decl(ext_Q , "q" , ('Q' - 'A'), true , NO_UPDATE_DEFAULT) \ + decl(ext_H , "h" , ('H' - 'A'), true , NO_UPDATE_DEFAULT) \ + decl(ext_V , "v" , ('V' - 'A'), true , UPDATE_DEFAULT(UseRVV)) \ + decl(ext_Zicbom , "Zicbom" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \ + decl(ext_Zicboz , "Zicboz" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \ + decl(ext_Zicbop , "Zicbop" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \ + decl(ext_Zba , "Zba" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZba)) \ + decl(ext_Zbb , "Zbb" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZbb)) \ + decl(ext_Zbc , "Zbc" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \ + decl(ext_Zbs , "Zbs" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZbs)) \ + decl(ext_Zicsr , "Zicsr" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \ + decl(ext_Zifencei , "Zifencei" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \ + decl(ext_Zic64b , "Zic64b" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \ + decl(ext_Zihintpause , "Zihintpause" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \ + decl(mvendorid , "VendorId" , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT) \ + decl(marchid , "ArchId" , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT) \ + decl(mimpid , "ImpId" , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT) \ + decl(unaligned_access, "Unaligned" , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT) \ + decl(satp_mode , "SATP" , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT) \ + + #define DECLARE_RV_FEATURE(NAME, PRETTY, BIT, FSTRING, FLAGF) \ + struct NAME##RVFeatureValue : public RVFeatureValue { \ + NAME##RVFeatureValue(const char* pretty, int bit, bool fstring) : \ + RVFeatureValue(pretty, bit, fstring) {} \ + FLAGF; \ + }; \ + static NAME##RVFeatureValue NAME; \ + + RV_FEATURE_FLAGS(DECLARE_RV_FEATURE) + #undef DECLARE_RV_FEATURE + + // VM modes (satp.mode) privileged ISA 1.10 + enum VM_MODE : int { + VM_NOTSET = -1, + VM_MBARE = 0, + VM_SV39 = 39, + VM_SV48 = 48, + VM_SV57 = 57, + VM_SV64 = 64 + }; + + static VM_MODE parse_satp_mode(const char* vm_mode); + + // Values from riscv_hwprobe() + enum UNALIGNED_ACCESS : int { + MISALIGNED_UNKNOWN = 0, + MISALIGNED_EMULATED = 1, + MISALIGNED_SLOW = 2, + MISALIGNED_FAST = 3, + MISALIGNED_UNSUPPORTED = 4 + }; -protected: - static const char* _uarch; - static const char* _vm_mode; + // Null terminated list + static RVFeatureValue* _feature_list[]; + + // Enables features in _feature_list + static void setup_cpu_available_features(); + // Helper for specific queries + static void os_aux_features(); + static char* os_uarch_additional_features(); + static void vendor_features(); + // Vendors specific features + static void rivos_features(); + + // Determine vector length iff ext_V/UseRVV + static uint32_t cpu_vector_length(); static uint32_t _initial_vector_length; - static void get_os_cpu_info(); - static uint32_t get_current_vector_length(); - static VM_MODE get_satp_mode(); -public: +#ifdef COMPILER2 + static void c2_initialize(); +#endif // COMPILER2 + + public: // Initialization static void initialize(); + static void initialize_cpu_information(); constexpr static bool supports_stack_watermark_barrier() { return true; } - - enum Feature_Flag { -#define CPU_FEATURE_FLAGS(decl) \ - decl(I, "i", 8) \ - decl(M, "m", 12) \ - decl(A, "a", 0) \ - decl(F, "f", 5) \ - decl(D, "d", 3) \ - decl(C, "c", 2) \ - decl(V, "v", 21) - -#define DECLARE_CPU_FEATURE_FLAG(id, name, bit) CPU_##id = (1 << bit), - CPU_FEATURE_FLAGS(DECLARE_CPU_FEATURE_FLAG) -#undef DECLARE_CPU_FEATURE_FLAG - }; - - static void initialize_cpu_information(void); }; #endif // CPU_RISCV_VM_VERSION_RISCV_HPP diff --git a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp new file mode 100644 index 0000000000000..f8e42a132072d --- /dev/null +++ b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, Rivos Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "logging/log.hpp" +#include "riscv_hwprobe.hpp" +#include "runtime/os.hpp" +#include "runtime/vm_version.hpp" +#include "utilities/debug.hpp" + +#include +#include +#include + +// Syscall defined in kernel 6.4 and the defines will be in asm/hwprobe.h +#define RISCV_HWPROBE_KEY_MVENDORID 0 +#define RISCV_HWPROBE_KEY_MARCHID 1 +#define RISCV_HWPROBE_KEY_MIMPID 2 + +#define RISCV_HWPROBE_KEY_BASE_BEHAVIOR 3 +#define RISCV_HWPROBE_BASE_BEHAVIOR_IMA (1 << 0) + +#define RISCV_HWPROBE_KEY_IMA_EXT_0 4 +#define RISCV_HWPROBE_IMA_FD (1 << 0) +#define RISCV_HWPROBE_IMA_C (1 << 1) + +#define RISCV_HWPROBE_KEY_CPUPERF_0 5 +#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0) +#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0) +#define RISCV_HWPROBE_MISALIGNED_SLOW (2 << 0) +#define RISCV_HWPROBE_MISALIGNED_FAST (3 << 0) +#define RISCV_HWPROBE_MISALIGNED_UNSUPPORTED (4 << 0) +#define RISCV_HWPROBE_MISALIGNED_MASK (7 << 0) + +#ifndef NR_riscv_hwprobe +#ifndef NR_arch_specific_syscall +#define NR_arch_specific_syscall 244 +#endif +#define NR_riscv_hwprobe (NR_arch_specific_syscall + 14) +#endif + +struct riscv_hwprobe { + int64_t key; + uint64_t value; +}; + +long sys_riscv_hwprobe(struct riscv_hwprobe *pairs, size_t pairc, + size_t cpuc, cpu_set_t *cpus, + unsigned int flags) { + return syscall(NR_riscv_hwprobe, pairs, pairc, cpuc, cpus, 0 /* flags*/); +} + +static bool rw_hwprobe_completed = false; + +static struct riscv_hwprobe query[] = {{RISCV_HWPROBE_KEY_MVENDORID, 0}, + {RISCV_HWPROBE_KEY_MARCHID, 0}, + {RISCV_HWPROBE_KEY_MIMPID, 0}, + {RISCV_HWPROBE_KEY_BASE_BEHAVIOR, 0}, + {RISCV_HWPROBE_KEY_IMA_EXT_0, 0}, + {RISCV_HWPROBE_KEY_CPUPERF_0, 0}}; + +bool RiscvHwprobe::probe_features() { + assert(!rw_hwprobe_completed, "Called twice."); + int ret = sys_riscv_hwprobe(&query[0], sizeof(query) / sizeof(query[0]), 0, nullptr, 0); + rw_hwprobe_completed = true; + if (ret != 0) { + log_debug(os, cpu)("riscv_hwprobe unsupported"); + return false; + } + log_debug(os, cpu)("riscv_hwprobe supported"); + add_features_from_query_result(); + return true; +} + +static bool is_valid(int64_t key) { + return query[key].key != -1; +} + +static bool is_set(int64_t key, uint64_t value_mask) { + if (is_valid(key)) { + return (query[key].value & value_mask) != 0; + } + return false; +} + +void RiscvHwprobe::add_features_from_query_result() { + assert(rw_hwprobe_completed, "hwprobe not init yet."); + + if (is_valid(RISCV_HWPROBE_KEY_MVENDORID)) { + VM_Version::mvendorid.enable_feature(query[RISCV_HWPROBE_KEY_MVENDORID].value); + } + if (is_valid(RISCV_HWPROBE_KEY_MARCHID)) { + VM_Version::marchid.enable_feature(query[RISCV_HWPROBE_KEY_MARCHID].value); + } + if (is_valid(RISCV_HWPROBE_KEY_MIMPID)) { + VM_Version::mimpid.enable_feature(query[RISCV_HWPROBE_KEY_MIMPID].value); + } + if (is_set(RISCV_HWPROBE_KEY_BASE_BEHAVIOR, RISCV_HWPROBE_BASE_BEHAVIOR_IMA)) { + VM_Version::ext_I.enable_feature(); + VM_Version::ext_M.enable_feature(); + VM_Version::ext_A.enable_feature(); + } + if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_IMA_FD)) { + VM_Version::ext_F.enable_feature(); + VM_Version::ext_D.enable_feature(); + } + if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_IMA_C)) { + VM_Version::ext_C.enable_feature(); + } + if (is_valid(RISCV_HWPROBE_KEY_CPUPERF_0)) { + VM_Version::unaligned_access.enable_feature( + query[RISCV_HWPROBE_KEY_CPUPERF_0].value & RISCV_HWPROBE_MISALIGNED_MASK); + } +} diff --git a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.hpp b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.hpp new file mode 100644 index 0000000000000..a8d2e8f74dff9 --- /dev/null +++ b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, Rivos Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef OS_LINUX_RISCV_HWPROBE_LINUX_HPP +#define OS_LINUX_RISCV_HWPROBE_LINUX_HPP + +#include "memory/allStatic.hpp" +#include "runtime/vm_version.hpp" +#include "utilities/growableArray.hpp" + +class RiscvHwprobe: public AllStatic { + static void add_features_from_query_result(); + public: + static bool probe_features(); +}; + +#endif // OS_LINUX_RISCV_HWPROBE_LINUX_HPP diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index 8d13894031287..8e47411169e1f 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2023, Rivos Inc. All rights reserved. * 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,39 +26,50 @@ #include "precompiled.hpp" #include "asm/register.hpp" +#include "logging/log.hpp" +#include "riscv_hwprobe.hpp" #include "runtime/os.hpp" #include "runtime/os.inline.hpp" #include "runtime/vm_version.hpp" #include +#include #include #ifndef HWCAP_ISA_I -#define HWCAP_ISA_I (1 << ('I' - 'A')) +#define HWCAP_ISA_I nth_bit('I' - 'A') #endif #ifndef HWCAP_ISA_M -#define HWCAP_ISA_M (1 << ('M' - 'A')) +#define HWCAP_ISA_M nth_bit('M' - 'A') #endif #ifndef HWCAP_ISA_A -#define HWCAP_ISA_A (1 << ('A' - 'A')) +#define HWCAP_ISA_A nth_bit('A' - 'A') #endif #ifndef HWCAP_ISA_F -#define HWCAP_ISA_F (1 << ('F' - 'A')) +#define HWCAP_ISA_F nth_bit('F' - 'A') #endif #ifndef HWCAP_ISA_D -#define HWCAP_ISA_D (1 << ('D' - 'A')) +#define HWCAP_ISA_D nth_bit('D' - 'A') #endif #ifndef HWCAP_ISA_C -#define HWCAP_ISA_C (1 << ('C' - 'A')) +#define HWCAP_ISA_C nth_bit('C' - 'A') +#endif + +#ifndef HWCAP_ISA_Q +#define HWCAP_ISA_Q nth_bit('Q' - 'A') +#endif + +#ifndef HWCAP_ISA_H +#define HWCAP_ISA_H nth_bit('H' - 'A') #endif #ifndef HWCAP_ISA_V -#define HWCAP_ISA_V (1 << ('V' - 'A')) +#define HWCAP_ISA_V nth_bit('V' - 'A') #endif #define read_csr(csr) \ @@ -70,68 +82,182 @@ __v; \ }) -uint32_t VM_Version::get_current_vector_length() { - assert(_features & CPU_V, "should not call this"); +uint32_t VM_Version::cpu_vector_length() { + assert(ext_V.enabled(), "should not call this"); return (uint32_t)read_csr(CSR_VLENB); } -VM_Version::VM_MODE VM_Version::get_satp_mode() { - if (!strcmp(_vm_mode, "sv39")) { +void VM_Version::setup_cpu_available_features() { + + assert(ext_I.feature_bit() == HWCAP_ISA_I, "Bit for I must follow Linux HWCAP"); + assert(ext_M.feature_bit() == HWCAP_ISA_M, "Bit for M must follow Linux HWCAP"); + assert(ext_A.feature_bit() == HWCAP_ISA_A, "Bit for A must follow Linux HWCAP"); + assert(ext_F.feature_bit() == HWCAP_ISA_F, "Bit for F must follow Linux HWCAP"); + assert(ext_D.feature_bit() == HWCAP_ISA_D, "Bit for D must follow Linux HWCAP"); + assert(ext_C.feature_bit() == HWCAP_ISA_C, "Bit for C must follow Linux HWCAP"); + assert(ext_Q.feature_bit() == HWCAP_ISA_Q, "Bit for Q must follow Linux HWCAP"); + assert(ext_H.feature_bit() == HWCAP_ISA_H, "Bit for H must follow Linux HWCAP"); + assert(ext_V.feature_bit() == HWCAP_ISA_V, "Bit for V must follow Linux HWCAP"); + + if (!RiscvHwprobe::probe_features()) { + os_aux_features(); + } + char* uarch = os_uarch_additional_features(); + vendor_features(); + + char buf[1024] = {}; + if (uarch != nullptr && strcmp(uarch, "") != 0) { + // Use at max half the buffer. + snprintf(buf, sizeof(buf)/2, "%s,", uarch); + } + os::free((void*) uarch); + strcat(buf, "rv64"); + int i = 0; + while (_feature_list[i] != nullptr) { + if (_feature_list[i]->enabled()) { + log_debug(os, cpu)("Enabled RV64 feature \"%s\" (%ld)", + _feature_list[i]->pretty(), + _feature_list[i]->value()); + // The feature string + if (_feature_list[i]->feature_string()) { + const char* tmp = _feature_list[i]->pretty(); + if (strlen(tmp) == 1) { + strcat(buf, tmp); + } else { + // Feature string is expected to be lower case. + // Turn Zxxx into zxxx + char prebuf[3] = {}; + assert(strlen(tmp) > 1, "Must be"); + prebuf[0] = '_'; + prebuf[1] = (char)tolower(tmp[0]); + strcat(buf, prebuf); + strcat(buf, &tmp[1]); + } + } + // Feature bit + if (_feature_list[i]->feature_bit() != 0) { + _features |= _feature_list[i]->feature_bit(); + } + // Change flag default + _feature_list[i]->update_flag(); + } + i++; + } + + _features_string = os::strdup(buf); +} + +void VM_Version::os_aux_features() { + uint64_t auxv = getauxval(AT_HWCAP); + for (int i = 0; _feature_list[i] != nullptr; i++) { + if (_feature_list[i]->feature_bit() == HWCAP_ISA_V) { + // Special case for V: some dev boards only support RVV version 0.7, while + // the OpenJDK only supports RVV version 1.0. These two versions are not + // compatible with each other. Given the V bit is set through HWCAP on + // some custom kernels, regardless of the version, it can lead to + // generating V instructions on boards that don't support RVV version 1.0 + // (ex: Sipeed LicheePi), leading to a SIGILL. + // That is an acceptable workaround as only Linux Kernel v6.5+ supports V, + // and that version already support hwprobe anyway + continue; + } + if ((_feature_list[i]->feature_bit() & auxv) != 0) { + _feature_list[i]->enable_feature(); + } + } +} + +VM_Version::VM_MODE VM_Version::parse_satp_mode(const char* vm_mode) { + if (!strcmp(vm_mode, "sv39")) { return VM_SV39; - } else if (!strcmp(_vm_mode, "sv48")) { + } else if (!strcmp(vm_mode, "sv48")) { return VM_SV48; - } else if (!strcmp(_vm_mode, "sv57")) { + } else if (!strcmp(vm_mode, "sv57")) { return VM_SV57; - } else if (!strcmp(_vm_mode, "sv64")) { + } else if (!strcmp(vm_mode, "sv64")) { return VM_SV64; } else { return VM_MBARE; } } -void VM_Version::get_os_cpu_info() { +char* VM_Version::os_uarch_additional_features() { + char* ret = nullptr; + VM_MODE mode = VM_NOTSET; - uint64_t auxv = getauxval(AT_HWCAP); + FILE *f = fopen("/proc/cpuinfo", "r"); + if (f == nullptr) { + return nullptr; + } - static_assert(CPU_I == HWCAP_ISA_I, "Flag CPU_I must follow Linux HWCAP"); - static_assert(CPU_M == HWCAP_ISA_M, "Flag CPU_M must follow Linux HWCAP"); - static_assert(CPU_A == HWCAP_ISA_A, "Flag CPU_A must follow Linux HWCAP"); - static_assert(CPU_F == HWCAP_ISA_F, "Flag CPU_F must follow Linux HWCAP"); - static_assert(CPU_D == HWCAP_ISA_D, "Flag CPU_D must follow Linux HWCAP"); - static_assert(CPU_C == HWCAP_ISA_C, "Flag CPU_C must follow Linux HWCAP"); - static_assert(CPU_V == HWCAP_ISA_V, "Flag CPU_V must follow Linux HWCAP"); - - // RISC-V has four bit-manipulation ISA-extensions: Zba/Zbb/Zbc/Zbs. - // Availability for those extensions could not be queried from HWCAP. - // TODO: Add proper detection for those extensions. - _features = auxv & ( - HWCAP_ISA_I | - HWCAP_ISA_M | - HWCAP_ISA_A | - HWCAP_ISA_F | - HWCAP_ISA_D | - HWCAP_ISA_C | - HWCAP_ISA_V); - - if (FILE *f = fopen("/proc/cpuinfo", "r")) { - char buf[512], *p; - while (fgets(buf, sizeof (buf), f) != NULL) { - if ((p = strchr(buf, ':')) != NULL) { + char buf[512], *p; + while (fgets(buf, sizeof (buf), f) != nullptr && + (mode == VM_NOTSET || ret == nullptr)) { + if ((p = strchr(buf, ':')) != nullptr) { + if (mode == VM_NOTSET) { if (strncmp(buf, "mmu", sizeof "mmu" - 1) == 0) { - if (_vm_mode[0] != '\0') { - continue; - } - char* vm_mode = os::strdup(p + 2); - vm_mode[strcspn(vm_mode, "\n")] = '\0'; - _vm_mode = vm_mode; - } else if (strncmp(buf, "uarch", sizeof "uarch" - 1) == 0) { - char* uarch = os::strdup(p + 2); - uarch[strcspn(uarch, "\n")] = '\0'; - _uarch = uarch; - break; + mode = VM_Version::parse_satp_mode(p); + } + } + if (ret == nullptr) { + if (strncmp(buf, "uarch", sizeof "uarch" - 1) == 0) { + ret = os::strdup(p + 2); + ret[strcspn(ret, "\n")] = '\0'; } } } - fclose(f); } + if (mode == VM_NOTSET) { + mode = VM_MBARE; + } + fclose(f); + satp_mode.enable_feature(mode); + return ret; +} + +void VM_Version::vendor_features() { + // JEDEC encoded as ((bank - 1) << 7) | (0x7f & JEDEC) + static constexpr int RIVOS_MVENDORID = 0x6cf; // JEDEC: 0x4f, Bank: 14 + + if (!mvendorid.enabled()) { + return; + } + switch (mvendorid.value()) { + case RIVOS_MVENDORID: + rivos_features(); + break; + default: + break; + } +} + +void VM_Version::rivos_features() { + // Enable common features not dependent on marchid/mimpid. + ext_I.enable_feature(); + ext_M.enable_feature(); + ext_A.enable_feature(); + ext_F.enable_feature(); + ext_D.enable_feature(); + ext_C.enable_feature(); + ext_H.enable_feature(); + ext_V.enable_feature(); + + ext_Zicbom.enable_feature(); + ext_Zicboz.enable_feature(); + ext_Zicbop.enable_feature(); + + ext_Zba.enable_feature(); + ext_Zbb.enable_feature(); + ext_Zbs.enable_feature(); + + ext_Zicsr.enable_feature(); + ext_Zifencei.enable_feature(); + ext_Zic64b.enable_feature(); + ext_Zihintpause.enable_feature(); + + unaligned_access.enable_feature(MISALIGNED_FAST); + satp_mode.enable_feature(VM_SV48); + + // Features dependent on march/mimpid. + // I.e. march.value() and mimplid.value() } From 0cdcc137d7ae52a10bad2b0e917fba5ee50d39d0 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Fri, 10 Nov 2023 15:18:56 +0000 Subject: [PATCH 314/341] 8312126: NullPointerException in CertStore.getCRLs after 8297955 Backport-of: 3c743cfea00692d0b938cb1cbde936084eecf369 --- .../security/provider/certpath/ldap/LDAPCertStoreImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/java.naming/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreImpl.java b/src/java.naming/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreImpl.java index caff5e7610461..39a787bf4fb7d 100644 --- a/src/java.naming/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreImpl.java +++ b/src/java.naming/share/classes/sun/security/provider/certpath/ldap/LDAPCertStoreImpl.java @@ -779,9 +779,13 @@ synchronized Collection getCRLs(X509CRLSelector xsel, } catch (IllegalArgumentException e) { continue; } - } else { + } else if (nameObject instanceof String) { issuerName = (String)nameObject; + } else { + throw new CertStoreException( + "unrecognized issuerName: must be String or byte[]"); } + // If all we want is CA certs, try to get the (probably shorter) ARL Collection entryCRLs = Collections.emptySet(); if (certChecking == null || certChecking.getBasicConstraints() != -1) { From df82c1c6490bb5114fe52e4e1a4faa6aa3a56cfd Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 13 Nov 2023 22:03:24 +0000 Subject: [PATCH 315/341] 8268433: serviceability/dcmd/framework/VMVersionTest.java fails with Unable to send object throw not established PipeIO Listener Thread connection Backport-of: 280f2d57d1f78b3d15dd98e726267a100eb0b5db --- test/hotspot/jtreg/ProblemList-zgc.txt | 4 ---- .../serviceability/dcmd/framework/TestProcessLauncher.java | 6 +++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList-zgc.txt b/test/hotspot/jtreg/ProblemList-zgc.txt index d81f604ca9b24..0a96a797d41d4 100644 --- a/test/hotspot/jtreg/ProblemList-zgc.txt +++ b/test/hotspot/jtreg/ProblemList-zgc.txt @@ -44,7 +44,3 @@ serviceability/sa/TestJmapCoreMetaspace.java 8268722,8268636 serviceability/sa/TestJhsdbJstackMixed.java 8248912 generic-all serviceability/sa/ClhsdbPstack.java#id0 8248912 generic-all serviceability/sa/ClhsdbPstack.java#id1 8248912 generic-all - -serviceability/dcmd/framework/HelpTest.java 8268433 windows-x64 -serviceability/dcmd/framework/InvalidCommandTest.java 8268433 windows-x64 -serviceability/dcmd/framework/VMVersionTest.java 8268433 windows-x64 diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java b/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java index 8953c8586dcc1..ec41c8b10de28 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java +++ b/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessLauncher.java @@ -77,7 +77,11 @@ public Process launch() { public void quit() { if (pipe != null) { - pipe.println("quit"); + if (pipe.isConnected()) { + pipe.println("quit"); + } else { + System.out.println("WARNING: IOPipe is not connected"); + } } } From 74d8e49388b22846dc6ad29529e5b6b7df4642b6 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 15 Nov 2023 07:28:04 +0000 Subject: [PATCH 316/341] 8285785: CheckCleanerBound test fails with PasswordCallback object is not released Reviewed-by: mbaesken Backport-of: b9d1e85151d9d4016639e6298c90737db10f6072 --- test/jdk/ProblemList.txt | 2 +- .../auth/callback/PasswordCallback/CheckCleanerBound.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index cd43a6473d16a..05bf219cb54d9 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -650,7 +650,7 @@ com/sun/security/sasl/gsskerb/ConfSecurityLayer.java 8039280 generic- com/sun/security/sasl/gsskerb/NoSecurityLayer.java 8039280 generic-all javax/security/auth/kerberos/KerberosHashEqualsTest.java 8039280 generic-all javax/security/auth/kerberos/KerberosTixDateTest.java 8039280 generic-all -javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java 8285785,8286045,8287596 generic-all +javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java 8286045 generic-all sun/security/provider/PolicyFile/GrantAllPermToExtWhenNoPolicy.java 8039280 generic-all sun/security/provider/PolicyParser/ExtDirsChange.java 8039280 generic-all sun/security/provider/PolicyParser/PrincipalExpansionError.java 8039280 generic-all diff --git a/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java b/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java index cc995893f65ed..5d8a5cfea2784 100644 --- a/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java +++ b/test/jdk/javax/security/auth/callback/PasswordCallback/CheckCleanerBound.java @@ -47,6 +47,7 @@ public static void main(String[] args) throws Exception { // Wait to trigger the cleanup. for (int i = 0; i < 10 && weakHashMap.size() != 0; i++) { System.gc(); + Thread.sleep(100); } // Check if the object has been collected. The collection will not From 49d5323e09da67cb9eedbdee9f0cf9ebc7fbc9df Mon Sep 17 00:00:00 2001 From: Gui Cao Date: Thu, 16 Nov 2023 08:51:29 +0000 Subject: [PATCH 317/341] 8319184: RISC-V: improve MD5 intrinsic Backport-of: fa331d71288f36ba67ee36af4c17ab80e9f2a23d --- src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 249 +++++++++--------- 1 file changed, 127 insertions(+), 122 deletions(-) diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 9bbc19dcf28ec..64705da20dc96 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -3703,43 +3703,46 @@ class StubGenerator: public StubCodeGenerator { } } - void gen_loads(Register base) { - for (uint i = 0; i < L; i += 1) { - __ ld(_regs[i], Address(base, 8 * i)); - } + // generate load for the i'th register + void gen_load(uint i, Register base) { + assert(i < L, "invalid i: %u", i); + __ ld(_regs[i], Address(base, 8 * i)); } - // Generate code extracting i-th unsigned word (4 bytes). - void get_u32(Register dest, uint i, Register rmask32) { + // add i'th 32-bit integer to dest + void add_u32(const Register dest, uint i, const Register rtmp = t0) { assert(i < 2 * L, "invalid i: %u", i); - if (i % 2 == 0) { - __ andr(dest, _regs[i / 2], rmask32); + if (is_even(i)) { + // Use the bottom 32 bits. No need to mask off the top 32 bits + // as addw will do the right thing. + __ addw(dest, dest, _regs[i / 2]); } else { - __ srli(dest, _regs[i / 2], 32); + // Use the top 32 bits by right-shifting them. + __ srli(rtmp, _regs[i / 2], 32); + __ addw(dest, dest, rtmp); } } }; typedef RegCache<8> BufRegCache; - // a += rtmp1 + x + ac; + // a += value + x + ac; // a = Integer.rotateLeft(a, s) + b; void m5_FF_GG_HH_II_epilogue(BufRegCache& reg_cache, Register a, Register b, Register c, Register d, int k, int s, int t, - Register rtmp1, Register rtmp2, Register rmask32) { - // rtmp1 = rtmp1 + x + ac - reg_cache.get_u32(rtmp2, k, rmask32); - __ addw(rtmp1, rtmp1, rtmp2); - __ mv(rtmp2, t); - __ addw(rtmp1, rtmp1, rtmp2); + Register value) { + // a += ac + __ addw(a, a, t, t1); - // a += rtmp1 + x + ac - __ addw(a, a, rtmp1); + // a += x; + reg_cache.add_u32(a, k); + // a += value; + __ addw(a, a, value); // a = Integer.rotateLeft(a, s) + b; - __ rolw_imm(a, a, s, rtmp1); + __ rolw_imm(a, a, s); __ addw(a, a, b); } @@ -3748,7 +3751,7 @@ class StubGenerator: public StubCodeGenerator { void md5_FF(BufRegCache& reg_cache, Register a, Register b, Register c, Register d, int k, int s, int t, - Register rtmp1, Register rtmp2, Register rmask32) { + Register rtmp1, Register rtmp2) { // rtmp1 = b & c __ andr(rtmp1, b, c); @@ -3758,8 +3761,7 @@ class StubGenerator: public StubCodeGenerator { // rtmp1 = (b & c) | ((~b) & d) __ orr(rtmp1, rtmp1, rtmp2); - m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, - rtmp1, rtmp2, rmask32); + m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, rtmp1); } // a += ((b & d) | (c & (~d))) + x + ac; @@ -3767,7 +3769,7 @@ class StubGenerator: public StubCodeGenerator { void md5_GG(BufRegCache& reg_cache, Register a, Register b, Register c, Register d, int k, int s, int t, - Register rtmp1, Register rtmp2, Register rmask32) { + Register rtmp1, Register rtmp2) { // rtmp1 = b & d __ andr(rtmp1, b, d); @@ -3777,8 +3779,7 @@ class StubGenerator: public StubCodeGenerator { // rtmp1 = (b & d) | (c & (~d)) __ orr(rtmp1, rtmp1, rtmp2); - m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, - rtmp1, rtmp2, rmask32); + m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, rtmp1); } // a += ((b ^ c) ^ d) + x + ac; @@ -3786,13 +3787,12 @@ class StubGenerator: public StubCodeGenerator { void md5_HH(BufRegCache& reg_cache, Register a, Register b, Register c, Register d, int k, int s, int t, - Register rtmp1, Register rtmp2, Register rmask32) { + Register rtmp1, Register rtmp2) { // rtmp1 = (b ^ c) ^ d - __ xorr(rtmp1, b, c); - __ xorr(rtmp1, rtmp1, d); + __ xorr(rtmp2, b, c); + __ xorr(rtmp1, rtmp2, d); - m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, - rtmp1, rtmp2, rmask32); + m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, rtmp1); } // a += (c ^ (b | (~d))) + x + ac; @@ -3800,13 +3800,12 @@ class StubGenerator: public StubCodeGenerator { void md5_II(BufRegCache& reg_cache, Register a, Register b, Register c, Register d, int k, int s, int t, - Register rtmp1, Register rtmp2, Register rmask32) { + Register rtmp1, Register rtmp2) { // rtmp1 = c ^ (b | (~d)) - __ orn(rtmp1, b, d); - __ xorr(rtmp1, c, rtmp1); + __ orn(rtmp2, b, d); + __ xorr(rtmp1, c, rtmp2); - m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, - rtmp1, rtmp2, rmask32); + m5_FF_GG_HH_II_epilogue(reg_cache, a, b, c, d, k, s, t, rtmp1); } // Arguments: @@ -3823,11 +3822,11 @@ class StubGenerator: public StubCodeGenerator { // x2 sp (stack pointer) // x3 gp (global pointer) // x4 tp (thread pointer) - // x5 t0 state0 - // x6 t1 state1 - // x7 t2 state2 + // x5 t0 (tmp register) + // x6 t1 (tmp register) + // x7 t2 state0 // x8 f0/s0 (frame pointer) - // x9 s1 state3 [saved-reg] + // x9 s1 // x10 a0 rtmp1 / c_rarg0 // x11 a1 rtmp2 / c_rarg1 // x12 a2 a / c_rarg2 @@ -3838,9 +3837,9 @@ class StubGenerator: public StubCodeGenerator { // x17 a7 state // x18 s2 ofs [saved-reg] (multi_block == True) // x19 s3 limit [saved-reg] (multi_block == True) - // x20 s4 - // x21 s5 - // x22 s6 mask32 [saved-reg] + // x20 s4 state1 [saved-reg] + // x21 s5 state2 [saved-reg] + // x22 s6 state3 [saved-reg] // x23 s7 // x24 s8 buf0 [saved-reg] // x25 s9 buf1 [saved-reg] @@ -3873,6 +3872,8 @@ class StubGenerator: public StubCodeGenerator { const int S43 = 15; const int S44 = 21; + const int64_t mask32 = 0xffffffff; + Register buf_arg = c_rarg0; // a0 Register state_arg = c_rarg1; // a1 Register ofs_arg = c_rarg2; // a2 @@ -3892,18 +3893,15 @@ class StubGenerator: public StubCodeGenerator { Register c = x14; // a4 Register d = x15; // a5 - Register state0 = x5; // t0 - Register state1 = x6; // t1 - Register state2 = x7; // t2 - Register state3 = x9; // s1 + Register state0 = x7; // t2 + Register state1 = x20; // s4 + Register state2 = x21; // s5 + Register state3 = x22; // s6 - // using x9->x11 to allow compressed instructions + // using x10->x11 to allow compressed instructions Register rtmp1 = x10; // a0 Register rtmp2 = x11; // a1 - const int64_t MASK_32 = 0xffffffff; - Register rmask32 = x22; // s6 - RegSet reg_cache_saved_regs = RegSet::of(x24, x25, x26, x27); // s8, s9, s10, s11 RegSet reg_cache_regs; reg_cache_regs += reg_cache_saved_regs; @@ -3914,7 +3912,7 @@ class StubGenerator: public StubCodeGenerator { if (multi_block) { saved_regs += RegSet::of(ofs, limit); } - saved_regs += RegSet::of(state3, rmask32); + saved_regs += RegSet::of(state1, state2, state3); saved_regs += reg_cache_saved_regs; __ push_reg(saved_regs, sp); @@ -3925,99 +3923,105 @@ class StubGenerator: public StubCodeGenerator { __ mv(ofs, ofs_arg); __ mv(limit, limit_arg); } - __ mv(rmask32, MASK_32); // to minimize the number of memory operations: // read the 4 state 4-byte values in pairs, with a single ld, // and split them into 2 registers + __ mv(t0, mask32); __ ld(state0, Address(state)); __ srli(state1, state0, 32); - __ andr(state0, state0, rmask32); + __ andr(state0, state0, t0); __ ld(state2, Address(state, 8)); __ srli(state3, state2, 32); - __ andr(state2, state2, rmask32); + __ andr(state2, state2, t0); Label md5_loop; __ BIND(md5_loop); - reg_cache.gen_loads(buf); - __ mv(a, state0); __ mv(b, state1); __ mv(c, state2); __ mv(d, state3); // Round 1 - md5_FF(reg_cache, a, b, c, d, 0, S11, 0xd76aa478, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, d, a, b, c, 1, S12, 0xe8c7b756, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, c, d, a, b, 2, S13, 0x242070db, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, b, c, d, a, 3, S14, 0xc1bdceee, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, a, b, c, d, 4, S11, 0xf57c0faf, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, d, a, b, c, 5, S12, 0x4787c62a, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, c, d, a, b, 6, S13, 0xa8304613, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, b, c, d, a, 7, S14, 0xfd469501, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, a, b, c, d, 8, S11, 0x698098d8, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, d, a, b, c, 9, S12, 0x8b44f7af, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, c, d, a, b, 10, S13, 0xffff5bb1, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, b, c, d, a, 11, S14, 0x895cd7be, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, a, b, c, d, 12, S11, 0x6b901122, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, d, a, b, c, 13, S12, 0xfd987193, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, c, d, a, b, 14, S13, 0xa679438e, rtmp1, rtmp2, rmask32); - md5_FF(reg_cache, b, c, d, a, 15, S14, 0x49b40821, rtmp1, rtmp2, rmask32); + reg_cache.gen_load(0, buf); + md5_FF(reg_cache, a, b, c, d, 0, S11, 0xd76aa478, rtmp1, rtmp2); + md5_FF(reg_cache, d, a, b, c, 1, S12, 0xe8c7b756, rtmp1, rtmp2); + reg_cache.gen_load(1, buf); + md5_FF(reg_cache, c, d, a, b, 2, S13, 0x242070db, rtmp1, rtmp2); + md5_FF(reg_cache, b, c, d, a, 3, S14, 0xc1bdceee, rtmp1, rtmp2); + reg_cache.gen_load(2, buf); + md5_FF(reg_cache, a, b, c, d, 4, S11, 0xf57c0faf, rtmp1, rtmp2); + md5_FF(reg_cache, d, a, b, c, 5, S12, 0x4787c62a, rtmp1, rtmp2); + reg_cache.gen_load(3, buf); + md5_FF(reg_cache, c, d, a, b, 6, S13, 0xa8304613, rtmp1, rtmp2); + md5_FF(reg_cache, b, c, d, a, 7, S14, 0xfd469501, rtmp1, rtmp2); + reg_cache.gen_load(4, buf); + md5_FF(reg_cache, a, b, c, d, 8, S11, 0x698098d8, rtmp1, rtmp2); + md5_FF(reg_cache, d, a, b, c, 9, S12, 0x8b44f7af, rtmp1, rtmp2); + reg_cache.gen_load(5, buf); + md5_FF(reg_cache, c, d, a, b, 10, S13, 0xffff5bb1, rtmp1, rtmp2); + md5_FF(reg_cache, b, c, d, a, 11, S14, 0x895cd7be, rtmp1, rtmp2); + reg_cache.gen_load(6, buf); + md5_FF(reg_cache, a, b, c, d, 12, S11, 0x6b901122, rtmp1, rtmp2); + md5_FF(reg_cache, d, a, b, c, 13, S12, 0xfd987193, rtmp1, rtmp2); + reg_cache.gen_load(7, buf); + md5_FF(reg_cache, c, d, a, b, 14, S13, 0xa679438e, rtmp1, rtmp2); + md5_FF(reg_cache, b, c, d, a, 15, S14, 0x49b40821, rtmp1, rtmp2); // Round 2 - md5_GG(reg_cache, a, b, c, d, 1, S21, 0xf61e2562, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, d, a, b, c, 6, S22, 0xc040b340, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, c, d, a, b, 11, S23, 0x265e5a51, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, b, c, d, a, 0, S24, 0xe9b6c7aa, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, a, b, c, d, 5, S21, 0xd62f105d, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, d, a, b, c, 10, S22, 0x02441453, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, c, d, a, b, 15, S23, 0xd8a1e681, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, b, c, d, a, 4, S24, 0xe7d3fbc8, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, a, b, c, d, 9, S21, 0x21e1cde6, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, d, a, b, c, 14, S22, 0xc33707d6, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, c, d, a, b, 3, S23, 0xf4d50d87, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, b, c, d, a, 8, S24, 0x455a14ed, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, a, b, c, d, 13, S21, 0xa9e3e905, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, d, a, b, c, 2, S22, 0xfcefa3f8, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, c, d, a, b, 7, S23, 0x676f02d9, rtmp1, rtmp2, rmask32); - md5_GG(reg_cache, b, c, d, a, 12, S24, 0x8d2a4c8a, rtmp1, rtmp2, rmask32); + md5_GG(reg_cache, a, b, c, d, 1, S21, 0xf61e2562, rtmp1, rtmp2); + md5_GG(reg_cache, d, a, b, c, 6, S22, 0xc040b340, rtmp1, rtmp2); + md5_GG(reg_cache, c, d, a, b, 11, S23, 0x265e5a51, rtmp1, rtmp2); + md5_GG(reg_cache, b, c, d, a, 0, S24, 0xe9b6c7aa, rtmp1, rtmp2); + md5_GG(reg_cache, a, b, c, d, 5, S21, 0xd62f105d, rtmp1, rtmp2); + md5_GG(reg_cache, d, a, b, c, 10, S22, 0x02441453, rtmp1, rtmp2); + md5_GG(reg_cache, c, d, a, b, 15, S23, 0xd8a1e681, rtmp1, rtmp2); + md5_GG(reg_cache, b, c, d, a, 4, S24, 0xe7d3fbc8, rtmp1, rtmp2); + md5_GG(reg_cache, a, b, c, d, 9, S21, 0x21e1cde6, rtmp1, rtmp2); + md5_GG(reg_cache, d, a, b, c, 14, S22, 0xc33707d6, rtmp1, rtmp2); + md5_GG(reg_cache, c, d, a, b, 3, S23, 0xf4d50d87, rtmp1, rtmp2); + md5_GG(reg_cache, b, c, d, a, 8, S24, 0x455a14ed, rtmp1, rtmp2); + md5_GG(reg_cache, a, b, c, d, 13, S21, 0xa9e3e905, rtmp1, rtmp2); + md5_GG(reg_cache, d, a, b, c, 2, S22, 0xfcefa3f8, rtmp1, rtmp2); + md5_GG(reg_cache, c, d, a, b, 7, S23, 0x676f02d9, rtmp1, rtmp2); + md5_GG(reg_cache, b, c, d, a, 12, S24, 0x8d2a4c8a, rtmp1, rtmp2); // Round 3 - md5_HH(reg_cache, a, b, c, d, 5, S31, 0xfffa3942, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, d, a, b, c, 8, S32, 0x8771f681, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, c, d, a, b, 11, S33, 0x6d9d6122, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, b, c, d, a, 14, S34, 0xfde5380c, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, a, b, c, d, 1, S31, 0xa4beea44, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, d, a, b, c, 4, S32, 0x4bdecfa9, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, c, d, a, b, 7, S33, 0xf6bb4b60, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, b, c, d, a, 10, S34, 0xbebfbc70, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, a, b, c, d, 13, S31, 0x289b7ec6, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, d, a, b, c, 0, S32, 0xeaa127fa, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, c, d, a, b, 3, S33, 0xd4ef3085, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, b, c, d, a, 6, S34, 0x04881d05, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, a, b, c, d, 9, S31, 0xd9d4d039, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, d, a, b, c, 12, S32, 0xe6db99e5, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, c, d, a, b, 15, S33, 0x1fa27cf8, rtmp1, rtmp2, rmask32); - md5_HH(reg_cache, b, c, d, a, 2, S34, 0xc4ac5665, rtmp1, rtmp2, rmask32); + md5_HH(reg_cache, a, b, c, d, 5, S31, 0xfffa3942, rtmp1, rtmp2); + md5_HH(reg_cache, d, a, b, c, 8, S32, 0x8771f681, rtmp1, rtmp2); + md5_HH(reg_cache, c, d, a, b, 11, S33, 0x6d9d6122, rtmp1, rtmp2); + md5_HH(reg_cache, b, c, d, a, 14, S34, 0xfde5380c, rtmp1, rtmp2); + md5_HH(reg_cache, a, b, c, d, 1, S31, 0xa4beea44, rtmp1, rtmp2); + md5_HH(reg_cache, d, a, b, c, 4, S32, 0x4bdecfa9, rtmp1, rtmp2); + md5_HH(reg_cache, c, d, a, b, 7, S33, 0xf6bb4b60, rtmp1, rtmp2); + md5_HH(reg_cache, b, c, d, a, 10, S34, 0xbebfbc70, rtmp1, rtmp2); + md5_HH(reg_cache, a, b, c, d, 13, S31, 0x289b7ec6, rtmp1, rtmp2); + md5_HH(reg_cache, d, a, b, c, 0, S32, 0xeaa127fa, rtmp1, rtmp2); + md5_HH(reg_cache, c, d, a, b, 3, S33, 0xd4ef3085, rtmp1, rtmp2); + md5_HH(reg_cache, b, c, d, a, 6, S34, 0x04881d05, rtmp1, rtmp2); + md5_HH(reg_cache, a, b, c, d, 9, S31, 0xd9d4d039, rtmp1, rtmp2); + md5_HH(reg_cache, d, a, b, c, 12, S32, 0xe6db99e5, rtmp1, rtmp2); + md5_HH(reg_cache, c, d, a, b, 15, S33, 0x1fa27cf8, rtmp1, rtmp2); + md5_HH(reg_cache, b, c, d, a, 2, S34, 0xc4ac5665, rtmp1, rtmp2); // Round 4 - md5_II(reg_cache, a, b, c, d, 0, S41, 0xf4292244, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, d, a, b, c, 7, S42, 0x432aff97, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, c, d, a, b, 14, S43, 0xab9423a7, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, b, c, d, a, 5, S44, 0xfc93a039, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, a, b, c, d, 12, S41, 0x655b59c3, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, d, a, b, c, 3, S42, 0x8f0ccc92, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, c, d, a, b, 10, S43, 0xffeff47d, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, b, c, d, a, 1, S44, 0x85845dd1, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, a, b, c, d, 8, S41, 0x6fa87e4f, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, d, a, b, c, 15, S42, 0xfe2ce6e0, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, c, d, a, b, 6, S43, 0xa3014314, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, b, c, d, a, 13, S44, 0x4e0811a1, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, a, b, c, d, 4, S41, 0xf7537e82, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, d, a, b, c, 11, S42, 0xbd3af235, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, c, d, a, b, 2, S43, 0x2ad7d2bb, rtmp1, rtmp2, rmask32); - md5_II(reg_cache, b, c, d, a, 9, S44, 0xeb86d391, rtmp1, rtmp2, rmask32); + md5_II(reg_cache, a, b, c, d, 0, S41, 0xf4292244, rtmp1, rtmp2); + md5_II(reg_cache, d, a, b, c, 7, S42, 0x432aff97, rtmp1, rtmp2); + md5_II(reg_cache, c, d, a, b, 14, S43, 0xab9423a7, rtmp1, rtmp2); + md5_II(reg_cache, b, c, d, a, 5, S44, 0xfc93a039, rtmp1, rtmp2); + md5_II(reg_cache, a, b, c, d, 12, S41, 0x655b59c3, rtmp1, rtmp2); + md5_II(reg_cache, d, a, b, c, 3, S42, 0x8f0ccc92, rtmp1, rtmp2); + md5_II(reg_cache, c, d, a, b, 10, S43, 0xffeff47d, rtmp1, rtmp2); + md5_II(reg_cache, b, c, d, a, 1, S44, 0x85845dd1, rtmp1, rtmp2); + md5_II(reg_cache, a, b, c, d, 8, S41, 0x6fa87e4f, rtmp1, rtmp2); + md5_II(reg_cache, d, a, b, c, 15, S42, 0xfe2ce6e0, rtmp1, rtmp2); + md5_II(reg_cache, c, d, a, b, 6, S43, 0xa3014314, rtmp1, rtmp2); + md5_II(reg_cache, b, c, d, a, 13, S44, 0x4e0811a1, rtmp1, rtmp2); + md5_II(reg_cache, a, b, c, d, 4, S41, 0xf7537e82, rtmp1, rtmp2); + md5_II(reg_cache, d, a, b, c, 11, S42, 0xbd3af235, rtmp1, rtmp2); + md5_II(reg_cache, c, d, a, b, 2, S43, 0x2ad7d2bb, rtmp1, rtmp2); + md5_II(reg_cache, b, c, d, a, 9, S44, 0xeb86d391, rtmp1, rtmp2); __ addw(state0, state0, a); __ addw(state1, state1, b); @@ -4034,11 +4038,12 @@ class StubGenerator: public StubCodeGenerator { // to minimize the number of memory operations: // write back the 4 state 4-byte values in pairs, with a single sd - __ andr(state0, state0, rmask32); + __ mv(t0, mask32); + __ andr(state0, state0, t0); __ slli(state1, state1, 32); __ orr(state0, state0, state1); __ sd(state0, Address(state)); - __ andr(state2, state2, rmask32); + __ andr(state2, state2, t0); __ slli(state3, state3, 32); __ orr(state2, state2, state3); __ sd(state2, Address(state, 8)); From 68f72954dca6166758d7da78628afa0aca2caf88 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Thu, 16 Nov 2023 10:36:00 +0000 Subject: [PATCH 318/341] 8315195: RISC-V: Update hwprobe query for new extensions Backport-of: 0d4cadb82468655f4ad3887a14d47e59af620490 --- src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp | 16 ++++++++++++++++ .../linux_riscv/vm_version_linux_riscv.cpp | 10 +--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp index f8e42a132072d..243c4b850ee43 100644 --- a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp +++ b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp @@ -45,6 +45,10 @@ #define RISCV_HWPROBE_KEY_IMA_EXT_0 4 #define RISCV_HWPROBE_IMA_FD (1 << 0) #define RISCV_HWPROBE_IMA_C (1 << 1) +#define RISCV_HWPROBE_IMA_V (1 << 2) +#define RISCV_HWPROBE_EXT_ZBA (1 << 3) +#define RISCV_HWPROBE_EXT_ZBB (1 << 4) +#define RISCV_HWPROBE_EXT_ZBS (1 << 5) #define RISCV_HWPROBE_KEY_CPUPERF_0 5 #define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0) @@ -129,6 +133,18 @@ void RiscvHwprobe::add_features_from_query_result() { if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_IMA_C)) { VM_Version::ext_C.enable_feature(); } + if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_IMA_V)) { + VM_Version::ext_V.enable_feature(); + } + if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_EXT_ZBA)) { + VM_Version::ext_Zba.enable_feature(); + } + if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_EXT_ZBB)) { + VM_Version::ext_Zbb.enable_feature(); + } + if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_EXT_ZBS)) { + VM_Version::ext_Zbs.enable_feature(); + } if (is_valid(RISCV_HWPROBE_KEY_CPUPERF_0)) { VM_Version::unaligned_access.enable_feature( query[RISCV_HWPROBE_KEY_CPUPERF_0].value & RISCV_HWPROBE_MISALIGNED_MASK); diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index 8e47411169e1f..a701b9f7c2109 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -233,19 +233,11 @@ void VM_Version::vendor_features() { void VM_Version::rivos_features() { // Enable common features not dependent on marchid/mimpid. - ext_I.enable_feature(); - ext_M.enable_feature(); - ext_A.enable_feature(); - ext_F.enable_feature(); - ext_D.enable_feature(); - ext_C.enable_feature(); - ext_H.enable_feature(); - ext_V.enable_feature(); - ext_Zicbom.enable_feature(); ext_Zicboz.enable_feature(); ext_Zicbop.enable_feature(); + // If we running on a pre-6.5 kernel ext_Zba.enable_feature(); ext_Zbb.enable_feature(); ext_Zbs.enable_feature(); From 8860bde14cc4b330a7e5f01771e51ecc6f0bb1c3 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 20 Nov 2023 10:42:50 +0000 Subject: [PATCH 319/341] 8294402: Add diagnostic logging to VMProps.checkDockerSupport Backport-of: 03d613bbab99dd84dfc5115a5034c60f4e510259 --- test/jtreg-ext/requires/VMProps.java | 91 +++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 2 deletions(-) diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 08979baae6d86..f127253ee7902 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.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 @@ -27,10 +27,13 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.File; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -87,6 +90,7 @@ public void put(String key, Supplier s) { */ @Override public Map call() { + log("Entering call()"); SafeMap map = new SafeMap(); map.put("vm.flavor", this::vmFlavor); map.put("vm.compMode", this::vmCompMode); @@ -125,6 +129,7 @@ public Map call() { vmOptFinalFlags(map); dump(map.map); + log("Leaving call()"); return map.map; } @@ -432,6 +437,8 @@ protected String isCompiler2Enabled() { * @return true if docker is supported in a given environment */ protected String dockerSupport() { + log("Entering dockerSupport()"); + boolean isSupported = false; if (Platform.isLinux()) { // currently docker testing is only supported for Linux, @@ -450,6 +457,8 @@ protected String dockerSupport() { } } + log("dockerSupport(): platform check: isSupported = " + isSupported); + if (isSupported) { try { isSupported = checkDockerSupport(); @@ -458,15 +467,59 @@ protected String dockerSupport() { } } + log("dockerSupport(): returning isSupported = " + isSupported); return "" + isSupported; } + // Configures process builder to redirect process stdout and stderr to a file. + // Returns file names for stdout and stderr. + private Map redirectOutputToLogFile(String msg, ProcessBuilder pb, String fileNameBase) { + Map result = new HashMap<>(); + String timeStamp = Instant.now().toString().replace(":", "-").replace(".", "-"); + + String stdoutFileName = String.format("./%s-stdout--%s.log", fileNameBase, timeStamp); + pb.redirectOutput(new File(stdoutFileName)); + log(msg + ": child process stdout redirected to " + stdoutFileName); + result.put("stdout", stdoutFileName); + + String stderrFileName = String.format("./%s-stderr--%s.log", fileNameBase, timeStamp); + pb.redirectError(new File(stderrFileName)); + log(msg + ": child process stderr redirected to " + stderrFileName); + result.put("stderr", stderrFileName); + + return result; + } + + private void printLogfileContent(Map logFileNames) { + logFileNames.entrySet().stream() + .forEach(entry -> + { + log("------------- " + entry.getKey()); + try { + Files.lines(Path.of(entry.getValue())) + .forEach(line -> log(line)); + } catch (IOException ie) { + log("Exception while reading file: " + ie); + } + log("-------------"); + }); + } + private boolean checkDockerSupport() throws IOException, InterruptedException { + log("checkDockerSupport(): entering"); ProcessBuilder pb = new ProcessBuilder(Container.ENGINE_COMMAND, "ps"); + Map logFileNames = redirectOutputToLogFile("checkDockerSupport(): ps", + pb, "container-ps"); Process p = pb.start(); p.waitFor(10, TimeUnit.SECONDS); + int exitValue = p.exitValue(); + + log(String.format("checkDockerSupport(): exitValue = %s, pid = %s", exitValue, p.pid())); + if (exitValue != 0) { + printLogfileContent(logFileNames); + } - return (p.exitValue() == 0); + return (exitValue == 0); } /** @@ -581,6 +634,40 @@ protected static void dump(Map map) { } } + /** + * Log diagnostic message. + * + * @param msg + */ + protected static void log(String msg) { + // Always log to a file. + logToFile(msg); + + // Also log to stderr; guarded by property to avoid excessive verbosity. + // By jtreg design stderr produced here will be visible + // in the output of a parent process. Note: stdout should not be used + // for logging as jtreg parses that output directly and only echoes it + // in the event of a failure. + if (Boolean.getBoolean("jtreg.log.vmprops")) { + System.err.println("VMProps: " + msg); + } + } + + /** + * Log diagnostic message to a file. + * + * @param msg + */ + protected static void logToFile(String msg) { + String fileName = "./vmprops.log"; + try { + Files.writeString(Paths.get(fileName), msg + "\n", Charset.forName("ISO-8859-1"), + StandardOpenOption.APPEND, StandardOpenOption.CREATE); + } catch (IOException e) { + throw new RuntimeException("Failed to log into '" + fileName + "'", e); + } + } + /** * This method is for the testing purpose only. * From e0bdb10151a01ab942e5f5be999722db7bfcf457 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 20 Nov 2023 10:47:54 +0000 Subject: [PATCH 320/341] 8307311: Timeouts on one macOS 12.6.1 host of two Swing JTableHeader tests Backport-of: b3cb82b859d22b18343d125349a5aebc0afb8576 --- test/jdk/javax/swing/JTableHeader/6889007/bug6889007.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/jdk/javax/swing/JTableHeader/6889007/bug6889007.java b/test/jdk/javax/swing/JTableHeader/6889007/bug6889007.java index cdceac1f9f278..7b1200241867b 100644 --- a/test/jdk/javax/swing/JTableHeader/6889007/bug6889007.java +++ b/test/jdk/javax/swing/JTableHeader/6889007/bug6889007.java @@ -53,7 +53,6 @@ public class bug6889007 { public static void main(String[] args) throws Exception { try { robot = new Robot(); - robot.setAutoDelay(100); SwingUtilities.invokeAndWait(() -> { frame = new JFrame(); @@ -69,6 +68,7 @@ public static void main(String[] args) throws Exception { frame.add(th); frame.pack(); frame.setLocationRelativeTo(null); + frame.setAlwaysOnTop(true); frame.setVisible(true); }); robot.waitForIdle(); @@ -83,7 +83,7 @@ public static void main(String[] args) throws Exception { int y = point.y + height/2; for(int i = -shift; i < width + 2*shift; i++) { robot.mouseMove(x++, y); - robot.waitForIdle(); + robot.delay(100); } robot.waitForIdle(); // 9 is a magic test number @@ -109,6 +109,8 @@ protected void rolloverColumnUpdated(int oldColumn, int newColumn) { Cursor cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR); if (oldColumn != -1 && newColumn != -1 && header.getCursor() != cursor) { + System.out.println("oldColumn " + oldColumn + " newColumn " + newColumn + + "header.getCursor " + header.getCursor() + " cursor " + cursor); try { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); From c7fb6ea7eb41bac13bc58151c63926934c0c25cd Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 20 Nov 2023 10:50:31 +0000 Subject: [PATCH 321/341] 8318759: Add four DigiCert root certificates Reviewed-by: mbaesken Backport-of: 0ea58048f9b4cdaaa0470b2bcc03913fb3939453 --- make/data/cacerts/digicertcseccrootg5 | 21 ++ make/data/cacerts/digicertcsrsarootg5 | 38 +++ make/data/cacerts/digicerttlseccrootg5 | 21 ++ make/data/cacerts/digicerttlsrsarootg5 | 38 +++ .../certification/CAInterop.java | 27 ++ .../certification/DigicertCSRootG5.java | 303 ++++++++++++++++++ .../security/lib/cacerts/VerifyCACerts.java | 14 +- 7 files changed, 459 insertions(+), 3 deletions(-) create mode 100644 make/data/cacerts/digicertcseccrootg5 create mode 100644 make/data/cacerts/digicertcsrsarootg5 create mode 100644 make/data/cacerts/digicerttlseccrootg5 create mode 100644 make/data/cacerts/digicerttlsrsarootg5 create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/DigicertCSRootG5.java diff --git a/make/data/cacerts/digicertcseccrootg5 b/make/data/cacerts/digicertcseccrootg5 new file mode 100644 index 0000000000000..04e1eb1be688e --- /dev/null +++ b/make/data/cacerts/digicertcseccrootg5 @@ -0,0 +1,21 @@ +Owner: CN=DigiCert CS ECC P384 Root G5, O="DigiCert, Inc.", C=US +Issuer: CN=DigiCert CS ECC P384 Root G5, O="DigiCert, Inc.", C=US +Serial number: 3698fe712d519f3ced0fdb7b1643011 +Valid from: Fri Jan 15 00:00:00 GMT 2021 until: Sun Jan 14 23:59:59 GMT 2046 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICFjCCAZ2gAwIBAgIQA2mP5xLVGfPO0P23sWQwETAKBggqhkjOPQQDAzBNMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJTAjBgNVBAMTHERp +Z2lDZXJ0IENTIEVDQyBQMzg0IFJvb3QgRzUwHhcNMjEwMTE1MDAwMDAwWhcNNDYw +MTE0MjM1OTU5WjBNMQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIElu +Yy4xJTAjBgNVBAMTHERpZ2lDZXJ0IENTIEVDQyBQMzg0IFJvb3QgRzUwdjAQBgcq +hkjOPQIBBgUrgQQAIgNiAAR/FK2Ftpf9AiE1TWDoOJOTmz0FEG2v0/7v+rv7c5nz +7DISjcdouIveiaKIVHeNuyF+M5VWlgno1YyhBLibbhkAYuhCKKZYN4QZVSZ7Mzdn +8ppyraGurgBCPBx+uHqeIZyjQjBAMB0GA1UdDgQWBBTwjJhxOThlwjobphdmHcjt +Zd6SNjAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQD +AwNnADBkAjAjb+EAGSZQ5EYgZYs3p8/rBuHMMskqoewyDXOiHgIcNWEqTmmrOXft +l4jAfWvqid0CMEPx0VijdT6Gm7ZVEYsX9z3+CmnFf07GdRtalMvqERHGCCKI3tB6 +oqV56OMhp80Tsw== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicertcsrsarootg5 b/make/data/cacerts/digicertcsrsarootg5 new file mode 100644 index 0000000000000..fd570aeee8b55 --- /dev/null +++ b/make/data/cacerts/digicertcsrsarootg5 @@ -0,0 +1,38 @@ +Owner: CN=DigiCert CS RSA4096 Root G5, O="DigiCert, Inc.", C=US +Issuer: CN=DigiCert CS RSA4096 Root G5, O="DigiCert, Inc.", C=US +Serial number: 6cee131be6d55c807f7c0c7fb44e620 +Valid from: Fri Jan 15 00:00:00 GMT 2021 until: Sun Jan 14 23:59:59 GMT 2046 +Signature algorithm name: SHA384withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFZDCCA0ygAwIBAgIQBs7hMb5tVcgH98DH+0TmIDANBgkqhkiG9w0BAQwFADBM +MQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJDAiBgNVBAMT +G0RpZ2lDZXJ0IENTIFJTQTQwOTYgUm9vdCBHNTAeFw0yMTAxMTUwMDAwMDBaFw00 +NjAxMTQyMzU5NTlaMEwxCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5EaWdpQ2VydCwg +SW5jLjEk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w41u67uvGUdhYS3A9AW5b3jcOvdCQGVT +kb2ZDZOSVKapN1krm8uZxrw99wSE8JQzHQ+CWjnLLkXDKBmjspuYyPwxa2CP9umG +KLzgPH10XRaJW2kkxxCLxEu7Nk/UWT/DsKSRmfgu0UoBnfWIEu+/WhFqWU9Za1pn +84+0Ew/A2C89KHKqGX8RfWpbn5XnX7eUT/E+oVr/Lcyd3yd3jzJzHGcKdvP6XLG/ +vB29DCibsscXZwszD8O9Ntz7ukILq+2Ew2LWhBapsQdrqW7uxs/msEQpwvCzYYAq +i2/SFFwlh1Rk86RMwaH4p2vq/uo6/HnbDo/cxvPJ1Gze6YOhjh0i7Mk6sgB73Dun +Qhp/3IupET2Op8Agb10JXUNE5o9mzKlbB/Hvm3oOs1ThlP0OLMaT11X9cZg1uAlK +/8YpKCz2Ui3bFBiSJ+IWfozK1GG+goeR65g3P79fXXc/NKwbOEOraHKZMh46Ghml +ozhMI9ej58zVKpIXkAtaS70WvfuGauKJmezkoFUYyaMIHxPgMghy0A== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicerttlseccrootg5 b/make/data/cacerts/digicerttlseccrootg5 new file mode 100644 index 0000000000000..9356292ef086c --- /dev/null +++ b/make/data/cacerts/digicerttlseccrootg5 @@ -0,0 +1,21 @@ +Owner: CN=DigiCert TLS ECC P384 Root G5, O="DigiCert, Inc.", C=US +Issuer: CN=DigiCert TLS ECC P384 Root G5, O="DigiCert, Inc.", C=US +Serial number: 9e09365acf7d9c8b93e1c0b042a2ef3 +Valid from: Fri Jan 15 00:00:00 GMT 2021 until: Sun Jan 14 23:59:59 GMT 2046 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICGTCCAZ+gAwIBAgIQCeCTZaz32ci5PhwLBCou8zAKBggqhkjOPQQDAzBOMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJjAkBgNVBAMTHURp +Z2lDZXJ0IFRMUyBFQ0MgUDM4NCBSb290IEc1MB4XDTIxMDExNTAwMDAwMFoXDTQ2 +MDExNDIzNTk1OVowTjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDkRpZ2lDZXJ0LCBJ +bmMuMSYwJAYDVQQDEx1EaWdpQ2VydCBUTFMgRUNDIFAzODQgUm9vdCBHNTB2MBAG +ByqGSM49AgEGBSuBBAAiA2IABMFEoc8Rl1Ca3iOCNQfN0MsYndLxf3c1TzvdlHJS +7cI7+Oz6e2tYIOyZrsn8aLN1udsJ7MgT9U7GCh1mMEy7H0cKPGEQQil8pQgO4CLp +0zVozptjn4S1mU1YoI71VOeVyaNCMEAwHQYDVR0OBBYEFMFRRVBZqz7nLFr6ICIS +B4CIfBFqMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49 +BAMDA2gAMGUCMQCJao1H5+z8blUD2WdsJk6Dxv3J+ysTvLd6jLRl0mlpYxNjOyZQ +LgGheQaRnUi/wr4CMEfDFXuxoJGZSZOoPHzoRgaLLPIxAJSdYsiJvRmEFOml+wG4 +DXZDjC5Ty3zfDBeWUA== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicerttlsrsarootg5 b/make/data/cacerts/digicerttlsrsarootg5 new file mode 100644 index 0000000000000..ac66e174f06ba --- /dev/null +++ b/make/data/cacerts/digicerttlsrsarootg5 @@ -0,0 +1,38 @@ +Owner: CN=DigiCert TLS RSA4096 Root G5, O="DigiCert, Inc.", C=US +Issuer: CN=DigiCert TLS RSA4096 Root G5, O="DigiCert, Inc.", C=US +Serial number: 8f9b478a8fa7eda6a333789de7ccf8a +Valid from: Fri Jan 15 00:00:00 GMT 2021 until: Sun Jan 14 23:59:59 GMT 2046 +Signature algorithm name: SHA384withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFZjCCA06gAwIBAgIQCPm0eKj6ftpqMzeJ3nzPijAN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0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcN +AQEMBQADggIBAGCmr1tfV9qJ20tQqcQjNSH/0GEwhJG3PxDPJY7Jv0Y02cEhJhxw +GXIeo8mH/qlDZJY6yFMECrZBu8RHANmfGBg7sg7zNOok992vIGCukihfNudd5N7H +PNtQOa27PShNlnx2xlv0wdsUpasZYgcYQF+Xkdycx6u1UQ3maVNVzDl92sURVXLF +O4uJ+DQtpBflF+aZfTCIITfNMBc9uPK8qHWgQ9w+iUuQrm0D4ByjoJYJu32jtyoQ +REtGBzRj7TG5BO6jm5qu5jF49OokYTurWGT/u4cnYiWB39yhL/btp/96j1EuMPik +AdKFOV8BmZZvWltwGUb+hmA+rYAQCd05JS9Yf7vSdPD3Rh9GOUrYU9DzLjtxpdRv +/PNn5AeP3SYZ4Y1b+qOTEZvpyDrDVWiakuFSdjjo4bq9+0/V77PnSIMx8IIh47a+ +p6tv75/fTM8BuGJqIz3nCU2AG3swpMPdB380vqQmsvZB6Akd4yCYqjdP//fx4ilw +MUc/dNAUFvohigLVigmUdy7yWSiLfFCSCmZ4OIN1xLVaqBHG5cGdZlXPU8Sv13WF +qUITVuwhd4GTWgzqltlJyqEI8pc7bZsEGCREjnwB8twl2F6GmrE52/WRMmrRpnCK +ovfepEWFJqgejF0pW8hL2JpqA15w8oVPbEtoL8pU9ozaMv7Da4M/OMZ+ +-----END CERTIFICATE----- diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java index a890040e3a159..621572564223f 100644 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java @@ -301,6 +301,26 @@ * @run main/othervm -Djava.security.debug=certpath CAInterop quovadisrootca3g3 CRL */ +/* + * @test id=digicerttlseccrootg5 + * @bug 8318759 + * @summary Interoperability tests with DigiCert TLS ECC P384 Root G5 + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop digicerttlseccrootg5 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop digicerttlseccrootg5 CRL + */ + +/* + * @test id=digicerttlsrsarootg5 + * @bug 8318759 + * @summary Interoperability tests with DigiCert TLS RSA4096 Root G5 + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop digicerttlsrsarootg5 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop digicerttlsrsarootg5 CRL + */ + /* * @test id=sslrootrsaca * @bug 8243320 @@ -509,6 +529,7 @@ private CATestURLs getTestURLs(String alias) { new CATestURLs("https://actrsaroot2017.pki.microsoft.com", "https://rvkrsaroot2017.pki.microsoft.com"); + // Test URLs are listed at https://www.digicert.com/kb/digicert-root-certificates.htm case "quovadisrootca1g3" -> new CATestURLs("https://quovadis-root-ca-1-g3.chain-demos.digicert.com", "https://quovadis-root-ca-1-g3-revoked.chain-demos.digicert.com"); @@ -518,6 +539,12 @@ private CATestURLs getTestURLs(String alias) { case "quovadisrootca3g3" -> new CATestURLs("https://quovadis-root-ca-3-g3.chain-demos.digicert.com", "https://quovadis-root-ca-3-g3-revoked.chain-demos.digicert.com"); + case "digicerttlseccrootg5" -> + new CATestURLs("https://digicert-tls-ecc-p384-root-g5.chain-demos.digicert.com", + "https://digicert-tls-ecc-p384-root-g5-revoked.chain-demos.digicert.com"); + case "digicerttlsrsarootg5" -> + new CATestURLs("https://digicert-tls-rsa4096-root-g5.chain-demos.digicert.com", + "https://digicert-tls-rsa4096-root-g5-revoked.chain-demos.digicert.com"); case "sslrootrsaca" -> new CATestURLs("https://test-dv-rsa.ssl.com", diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/DigicertCSRootG5.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/DigicertCSRootG5.java new file mode 100644 index 0000000000000..30ad81b1755c8 --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/DigicertCSRootG5.java @@ -0,0 +1,303 @@ +/* + * 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 8318759 + * @summary Interoperability tests with Digicert CS Root G5 certificates + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=ocsp,certpath DigicertCSRootG5 OCSP + * @run main/othervm -Djava.security.debug=certpath DigicertCSRootG5 CRL + */ + +public class DigicertCSRootG5 { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + new Digicert_CS_ECC().runTest(pathValidator); + new Digicert_CS_RSA().runTest(pathValidator); + } +} + +class Digicert_CS_ECC { + + // Owner: CN=DigiCert G5 CS ECC SHA384 2021 CA1, O="DigiCert, Inc.", C=US + // Issuer: CN=DigiCert CS ECC P384 Root G5, O="DigiCert, Inc.", C=US + // Serial number: d926818addd3c47758f0ace9379b2e7 + // Valid from: Wed Feb 10 16:00:00 PST 2021 until: Sun Feb 10 15:59:59 PST 2036 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIDOTCCAsCgAwIBAgIQDZJoGK3dPEd1jwrOk3my5zAKBggqhkjOPQQDAzBNMQsw\n" + + "CQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJTAjBgNVBAMTHERp\n" + + "Z2lDZXJ0IENTIEVDQyBQMzg0IFJvb3QgRzUwHhcNMjEwMjExMDAwMDAwWhcNMzYw\n" + + "MjEwMjM1OTU5WjBTMQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIElu\n" + + "Yy4xKzApBgNVBAMTIkRpZ2lDZXJ0IEc1IENTIEVDQyBTSEEzODQgMjAyMSBDQTEw\n" + + "djAQBgcqhkjOPQIBBgUrgQQAIgNiAAS/zvKH4sLLu/zze3/+vHyfRE5OcO77TNw3\n" + + "MCMAlad2Y/ja50KTooGSmXhfwMXpbBTob7hsoxpvIU92W6DhFn9lg4pcKf5UHLEi\n" + + "0iDdHQ9w0hpFJiMABwK60nk+OwsGTZSjggFdMIIBWTASBgNVHRMBAf8ECDAGAQH/\n" + + "AgEAMB0GA1UdDgQWBBTXHcf6xvqCdCBFcTQSL1XVmEGSXjAfBgNVHSMEGDAWgBTw\n" + + "jJhxOThlwjobphdmHcjtZd6SNjAOBgNVHQ8BAf8EBAMCAYYwEwYDVR0lBAwwCgYI\n" + + "KwYBBQUHAwMweQYIKwYBBQUHAQEEbTBrMCQGCCsGAQUFBzABhhhodHRwOi8vb2Nz\n" + + "cC5kaWdpY2VydC5jb20wQwYIKwYBBQUHMAKGN2h0dHA6Ly9jYWNlcnRzLmRpZ2lj\n" + + "ZXJ0LmNvbS9EaWdpQ2VydENTRUNDUDM4NFJvb3RHNS5jcnQwRQYDVR0fBD4wPDA6\n" + + "oDigNoY0aHR0cDovL2NybDMuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0Q1NFQ0NQMzg0\n" + + "Um9vdEc1LmNybDAcBgNVHSAEFTATMAcGBWeBDAEDMAgGBmeBDAEEATAKBggqhkjO\n" + + "PQQDAwNnADBkAjByCWijRCnJogZf94U5HG/5S4QFMxEOBSAyxECbFxgrXMKXh5qa\n" + + "7oS2F+hT2DPzxTwCMCIthK0X/14bxZvrNNiNSWzer2TDUyRw6HNIfnkHgqaGFQVA\n" + + "KyS5I77prv53stK0XQ==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN="Win The Customer, LLC", O="Win The Customer, LLC", L=Saratoga + // Springs, ST=Utah, C=US, SERIALNUMBER=9637546-0160, OID.2.5.4.15=Private + // Organization, OID.1.3.6.1.4.1.311.60.2.1.2=Utah, OID.1.3.6.1.4.1.311.60.2.1.3=US + // Issuer: CN=DigiCert G5 CS ECC SHA384 2021 CA1, O="DigiCert, Inc.", C=US + // Serial number: b13737c3caf58eecb4359f441522133 + // Valid from: Wed Jan 25 16:00:00 PST 2023 until: Tue Jan 28 15:59:59 PST 2025 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIEEjCCA5mgAwIBAgIQCxNzfDyvWO7LQ1n0QVIhMzAKBggqhkjOPQQDAzBTMQsw\n" + + "CQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xKzApBgNVBAMTIkRp\n" + + "Z2lDZXJ0IEc1IENTIEVDQyBTSEEzODQgMjAyMSBDQTEwHhcNMjMwMTI2MDAwMDAw\n" + + "WhcNMjUwMTI4MjM1OTU5WjCB2TETMBEGCysGAQQBgjc8AgEDEwJVUzEVMBMGCysG\n" + + "AQQBgjc8AgECEwRVdGFoMR0wGwYDVQQPDBRQcml2YXRlIE9yZ2FuaXphdGlvbjEV\n" + + "MBMGA1UEBRMMOTYzNzU0Ni0wMTYwMQswCQYDVQQGEwJVUzENMAsGA1UECBMEVXRh\n" + + "aDEZMBcGA1UEBxMQU2FyYXRvZ2EgU3ByaW5nczEeMBwGA1UEChMVV2luIFRoZSBD\n" + + "dXN0b21lciwgTExDM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Owner: CN=Win the Customer LLC, O=Win the Customer LLC, L=Saratoga Springs, ST=Utah, C=US + // Issuer: CN=DigiCert G5 CS ECC SHA384 2021 CA1, O="DigiCert, Inc.", C=US + // Serial number: 201e51cb1ec8a56a1e8438c95adf024 + // Valid from: Sun Oct 22 17:00:00 PDT 2023 until: Tue Oct 22 16:59:59 PDT 2024 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIFdjCCBP2gAwIBAgIQAgHlHLHsilah6EOMla3wJDAKBggqhkjOPQQDAzBTMQsw\n" + + "CQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xKzApBgNVBAMTIkRp\n" + + "Z2lDZXJ0IEc1IENTIEVDQyBTSEEzODQgMjAyMSBDQTEwHhcNMjMxMDIzMDAwMDAw\n" + + "WhcNMjQxMDIyMjM1OTU5WjB1MQswCQYDVQQGEwJVUzENMAsGA1UECBMEVXRhaDEZ\n" + + "MBcGA1UEBxMQU2FyYXRvZ2EgU3ByaW5nczEdMBsGA1UEChMUV2luIHRoZSBDdXN0\n" + + "b21lciBMTEMxHTAbBgNVBAMTFFdpbiB0aGUgQ3VzdG9tZXIgTExDMIICIjANBgkq\n" + + "hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0o+FWNSfYzJmz+XgA7SRAIQd1H1pYnzq\n" + + "dPyNJJsd1G/nqfeHk/ezEx8Wd7iMJjcPOvKSd14uniAC3ayi3XOKKeFqEw5g5m2/\n" + + "JTO3n8xy9DK5CN1ctpK5Zy+UppOXrtTdBZB74/qSaREOysIfRLnVR4fxNy39urtl\n" + + "TJf0lvzRU9V6BQ3zRjMOCQnY6sueAPoQpVgpCVXkr4obJCkI5arkIQHVpfrcScaJ\n" + + "IzLQ46xL8nxoXPcGhikRystJKdbzg/oCFt68x87uSviZMtkqTHQhzRCzpO5pdx/z\n" + + "g64XZP8fAzSrM/uJCETXxMmazK6ZVkgPu3X4GvjfTfulvcJdxZNMm877NOSICtbL\n" + + "dK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nADBkAjA9aX3CSzCOZiHdC6JBF0nQwPLGNipPdHFMSbINmfpuHCC3Go4prf8M\n" + + "WCsWEQr2gQYCMErfcrU8zfxnQ9SxsmGJ8jkM3MDGvAr0CtzDwmWis32V60jAUFBQ\n" + + "lGm/Mdb5/EqKpw==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Mon Oct 23 14:48:38 PDT 2023", System.out); + } +} + +class Digicert_CS_RSA { + + // Owner: CN=DigiCert G5 CS RSA4096 SHA384 2021 CA1, O="DigiCert, Inc.", C=US + // Issuer: CN=DigiCert CS RSA4096 Root G5, O="DigiCert, Inc.", C=US + // Serial number: 10262e16224ca6dfef584f8c63048db + // Valid from: Wed Feb 10 16:00:00 PST 2021 until: Sun Feb 10 15:59:59 PST 2036 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGjDCCBHSgAwIBAgIQAQJi4WIkym3+9YT4xjBI2zANBgkqhkiG9w0BAQwFADBM\n" + + "MQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJDAiBgNVBAMT\n" + + "G0RpZ2lDZXJ0IENTIFJTQTQwOTYgUm9vdCBHNTAeFw0yMTAyMTEwMDAwMDBaFw0z\n" + + "NjAyMTAyMzU5NTlaMFcxCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5EaWdpQ2VydCwg\n" + + "SW5jLjEvMC0GA1UEAxMmRGlnaUNlcnQgRzUgQ1MgUlNBNDA5NiBTSEEzODQgMjAy\n" + + "MSBDQTEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC1GOMV0tdTLLBk\n" + + "Ylmccgb6bFa9By5zkuLg9NfFMl4y9P9f21C7N+mMA4fWgfjEs+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+ + "MDwwOqA4oDaGNGh0dHA6Ly9jcmwzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydENTUlNB\n" + + "NDA5NlJvb3RHNS5jcmwwHAYDVR0gBBUwEzAHBgVngQwBAzAIBgZngQwBBAEwDQYJ\n" + + "KoZIhvcNAQEMBQADggIBALBxItkM8LmHhbsnkykSN6+HnLj9/hUx9UUcym1Hwoii\n" + + "Bl9VCCpibLDJurx1w19KL5S6j2ggOMn/1zBugWMVhn6j12RzD4HUkfLqNBXzQmRc\n" + + "xZoXxspSgqpk+jd5iMtVSDBzlaF7s1feDh9qKa7O/7OB5KAiIO2VYFx1ia9ne3tV\n" + + "lY98G+3TnEdjo7r9lBi4KDGmDJv56h7Sb4WeVFlJ/8b4u9IHblq3ykQ/LyKuCYDf\n" + + "v2bnqlT+HY4mgU9ZA0WoO/L7V7m0sBrBYhpdM0pmxlqn6mpvWIHA2tC4rsTY2TXn\n" + + "ZlXbyJaMd5mvjRjvK0DF/2yoKC+us/1li2blLZKS9k0Z36/m4D7z5nVXkmUvRvE2\n" + + "70BhJ0NnM5lHtytTR+OgiaPapeiDy6AA+VbdnV7hhINGEhP7tF3IZPPfmKZN7/bN\n" + + "Qr7wuKZx/jO5sTBtblBaOU2+xric+MlTt2k3ilDnO3EzkZOp1JMWnNjAZciRa8Gy\n" + + "bYAXrsxY4vQnxgA7dj1/3KDB+pCRT7CTMOJJQu27OOv0MuNkb1E+8chPx/eFwfrN\n" + + "rft1Eiqp3Te0w4njDkzukP6EMhebcTp3POm0YhMZl8s1fTI6DCcHFwcMVywXiWwv\n" + + "QG+Td+dHlFT0P8jq/ecaMj6s8j69q36MER+QMyrxGAl3MHyEA7BBut1WCh9dsOnY\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN="Win The Customer, LLC", O="Win The Customer, LLC", L=Saratoga + // Springs, ST=Utah, C=US + // Issuer: CN=DigiCert G5 CS RSA4096 SHA384 2021 CA1, O="DigiCert, Inc.", C=US + // Serial number: bfec2fd49eeacb347ddbea5c1576083 + // Valid from: Fri Jun 23 17:00:00 PDT 2023 until: Wed Jun 26 16:59:59 PDT 2024 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIGqzCCBJOgAwIBAgIQC/7C/UnurLNH3b6lwVdggzANBgkqhkiG9w0BAQsFADBX" + + "MQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xLzAtBgNVBAMT" + + "JkRpZ2lDZXJ0IEc1IENTIFJTQTQwOTYgU0hBMzg0IDIwMjEgQ0ExMB4XDTIzMDYy" + + "NDAwMDAwMFoXDTI0MDYyNjIzNTk1OVowdzELMAkGA1UEBhMCVVMxDTALBgNVBAgT" + + "BFV0YWgxGTAXBgNVBAcTEFNhcmF0b2dhIFNwcmluZ3MxHjAcBgNVBAoTFVdpbiBU" + + "aGUgQ3VzdG9tZXIsIExMQzEeMBwGA1UEAxMVV2luIFRoZSBDdXN0b21lciwgTExD" + + "MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAsElsbtoNNIL5fCadUzW+" + + "aDl2LF0c6BRckZSuH1f88tFD5LDjuT+rdIxsjDS/dqedRiilJe40z/3973OZNaxs" + + "wxYCSHhUV9XimSHH0zQ2MpbupdA7aLDYM4tcypam1Zm9q6njLArBUgGVaKYBUZqW" + + "obVh+6aFBzj36u7EmPgLCJsre5oheo8+gOwfu+xVExceoHG+V7XTKhD6vhclS49B" + + "UIHgvpn+/BlB8kjf5M2XzmpfWg9aGq75gnd1ix4fU1BnA0A33cZPrFsi5cMh6NZd" + + "tI4WIpb5P8X17G3yRqNMM/noBvBrtpQHVLpN2C2NLg0YX1FjIK7bcBKFOnIG36ou" + + "vs+QesMyVOXeKKnt1ERBSqwrMjUuqN7W6YnXjoIp7xWxEdIdae+1fDK702zhGaYv" + + "b6pYGoJ7HQI/x7S6kF462qvXsf++yA5kxr2qNTSNY4ZggzEwubvu0PYRYjMHwIUn" + + "SV3ZlRAKXK2AO7GydecW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3jBj7ymGoGuiSV0nU9XPt" + + "yDm1FYYZAH2ykwo8YPZqAcu+EHvyxi1dgOM3ABfoLJfOIYJv2gxPx+KIKzn1wzBS" + + "kk1HMf8xbYXs40vF2Lrb7AQIyLa2ZskJTyfb0dyEyOq+vvVgLA9ZdwidzD1RnVf6" + + "vOb7KbMSBCLK+HGqHrW+hhSDi2vHvSit7Cn+q80ZmzRqvJ/+mVl+ppnjDC7nSLIa" + + "qeG0fvUz6SabPX7yV92D5ARrJJ3xgAvgmgWfuKBV7WlEGCmj0QTWZ0/AFBLzNcq7" + + "+0rgP0GM98MZpKa8pHZaS1A3uP1TFzamfVGdv0FVHXSkN5Kvg0iPh4Qz9TRiCkyE" + + "boJeU1LYdyTrP/+q3zQqsGa9xdQ50EovjWymbvWzCQ==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Win the Customer LLC, O=Win the Customer LLC, L=Saratoga Springs, + // ST=Utah, C=US + // Issuer: CN=DigiCert G5 CS RSA4096 SHA384 2021 CA1, O="DigiCert, Inc.", C=US + // Serial number: f409d101094769abaf06f085f11ca4f + // Valid from: Sun Oct 22 17:00:00 PDT 2023 until: Tue Oct 22 16:59:59 PDT 2024 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIHKTCCBRGgAwIBAgIQD0CdEBCUdpq68G8IXxHKTzANBgkqhkiG9w0BAQsFADBX\n" + + "MQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xLzAtBgNVBAMT\n" + + "JkRpZ2lDZXJ0IEc1IENTIFJTQTQwOTYgU0hBMzg0IDIwMjEgQ0ExMB4XDTIzMTAy\n" + + "MzAwMDAwMFoXDTI0MTAyMjIzNTk1OVowdTELMAkGA1UEBhMCVVMxDTALBgNVBAgT\n" + + "BFV0YWgxGTAXBgNVBAcTEFNhcmF0b2dhIFNwcmluZ3MxHTAbBgNVBAoTFFdpbiB0\n" + + "aGUgQ3VzdG9tZXIgTExDMR0wGwYDVQQD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jIjAaiilaaC\n" + + "MIXwwm3eg/QBgWBUrwXf3YC+1HXkaFDZc5apQ5uaNJPjQo9nQ6xqfpnACXTJ/Lwm\n" + + "JBu4YlXPby5Vh6mWWSyVdbICrCD7BtGP8aSBPFGPEuPEjK32uyeoGWVwwSubVFPX\n" + + "ARhLX5oSFZUySvHgYg==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Mon Oct 23 14:44:23 PDT 2023", System.out); + } +} diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java index 5084c77e25cdd..53a981591163f 100644 --- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java +++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java @@ -28,7 +28,7 @@ * 8209452 8209506 8210432 8195793 8216577 8222089 8222133 8222137 8222136 * 8223499 8225392 8232019 8234245 8233223 8225068 8225069 8243321 8243320 * 8243559 8225072 8258630 8259312 8256421 8225081 8225082 8225083 8245654 - * 8305975 8304760 8307134 8295894 8314960 8317373 8317374 + * 8305975 8304760 8307134 8295894 8314960 8317373 8317374 8318759 * @summary Check root CA entries in cacerts file */ import java.io.ByteArrayInputStream; @@ -47,12 +47,12 @@ public class VerifyCACerts { + File.separator + "security" + File.separator + "cacerts"; // The numbers of certs now. - private static final int COUNT = 99; + private static final int COUNT = 103; // SHA-256 of cacerts, can be generated with // shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95 private static final String CHECKSUM - = "DA:61:45:1C:93:F3:6A:30:24:68:C6:72:BC:C5:E6:E4:E3:BA:6A:AE:36:29:7B:45:53:B7:10:53:52:7D:7E:A5"; + = "A6:73:50:DD:6B:49:E6:F0:E7:E7:7B:F9:F9:11:9F:83:2D:FD:95:97:69:03:54:54:9C:B7:DF:46:A4:05:7A:15"; // Hex formatter to upper case with ":" delimiter private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase(); @@ -162,6 +162,14 @@ public class VerifyCACerts { "18:F1:FC:7F:20:5D:F8:AD:DD:EB:7F:E0:07:DD:57:E3:AF:37:5A:9C:4D:8D:73:54:6B:F4:F1:FE:D1:E1:8D:35"); put("quovadisrootca3g3 [jdk]", "88:EF:81:DE:20:2E:B0:18:45:2E:43:F8:64:72:5C:EA:5F:BD:1F:C2:D9:D2:05:73:07:09:C5:D8:B8:69:0F:46"); + put("digicertcseccrootg5 [jdk]", + "26:C5:6A:D2:20:8D:1E:9B:15:2F:66:85:3B:F4:79:7C:BE:B7:55:2C:1F:3F:47:72:51:E8:CB:1A:E7:E7:97:BF"); + put("digicertcsrsarootg5 [jdk]", + "73:53:B6:D6:C2:D6:DA:42:47:77:3F:3F:07:D0:75:DE:CB:51:34:21:2B:EA:D0:92:8E:F1:F4:61:15:26:09:41"); + put("digicerttlseccrootg5 [jdk]", + "01:8E:13:F0:77:25:32:CF:80:9B:D1:B1:72:81:86:72:83:FC:48:C6:E1:3B:E9:C6:98:12:85:4A:49:0C:1B:05"); + put("digicerttlsrsarootg5 [jdk]", + "37:1A:00:DC:05:33:B3:72:1A:7E:EB:40:E8:41:9E:70:79:9D:2B:0A:0F:2C:1D:80:69:31:65:F7:CE:C4:AD:75"); put("secomscrootca2 [jdk]", "51:3B:2C:EC:B8:10:D4:CD:E5:DD:85:39:1A:DF:C6:C2:DD:60:D8:7B:B7:36:D2:B5:21:48:4A:A4:7A:0E:BE:F6"); put("swisssigngoldg2ca [jdk]", From 9bde50e9b2aa3921f2aa98e5fd4c03297b9f4917 Mon Sep 17 00:00:00 2001 From: Stewart X Addison Date: Mon, 20 Nov 2023 15:42:30 +0000 Subject: [PATCH 322/341] 8319958: test/jdk/java/io/File/libGetXSpace.c does not compile on Windows 32-bit Backport-of: 6a75c2406be620c6410b388a55c544640ad87ac4 --- test/jdk/java/io/File/libGetXSpace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/jdk/java/io/File/libGetXSpace.c b/test/jdk/java/io/File/libGetXSpace.c index 7a6cdf0d1dcf3..4eafb86bf36ac 100644 --- a/test/jdk/java/io/File/libGetXSpace.c +++ b/test/jdk/java/io/File/libGetXSpace.c @@ -23,7 +23,7 @@ #include #include "jni.h" #include "jni_util.h" -#ifdef _WIN64 +#ifdef WINDOWS #include #include #include @@ -42,7 +42,7 @@ extern "C" { #endif -#ifdef _WIN64 +#ifdef WINDOWS jboolean initialized = JNI_FALSE; BOOL(WINAPI * pfnGetDiskSpaceInformation)(LPCWSTR, LPVOID) = NULL; #endif @@ -67,7 +67,7 @@ Java_GetXSpace_getSpace0 return JNI_FALSE; } -#ifdef _WIN64 +#ifdef WINDOWS if (initialized == JNI_FALSE) { initialized = JNI_TRUE; HMODULE hmod = GetModuleHandleW(L"kernel32"); From db83123c5cc054cee5663201ead92410e6487d81 Mon Sep 17 00:00:00 2001 From: Gui Cao Date: Tue, 21 Nov 2023 02:21:51 +0000 Subject: [PATCH 323/341] 8316645: RISC-V: Remove dependency on libatomic by adding cmpxchg 1b Reviewed-by: luhenry, fyang Backport-of: fb055e7e5300958b2a6a290aa6783e8ede929d9a --- make/autoconf/libraries.m4 | 6 -- .../os_cpu/linux_riscv/atomic_linux_riscv.hpp | 73 +++++++++++++++++++ 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/make/autoconf/libraries.m4 b/make/autoconf/libraries.m4 index 366682cf04464..62db5b16c314b 100644 --- a/make/autoconf/libraries.m4 +++ b/make/autoconf/libraries.m4 @@ -146,12 +146,6 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES], fi fi - # Because RISC-V only has word-sized atomics, it requries libatomic where - # other common architectures do not. So link libatomic by default. - if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$OPENJDK_TARGET_CPU" = xriscv64; then - BASIC_JVM_LIBS="$BASIC_JVM_LIBS -latomic" - fi - # perfstat lib if test "x$OPENJDK_TARGET_OS" = xaix; then BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lperfstat" diff --git a/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp b/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp index 11cd9e1d72da8..ba7a35c999440 100644 --- a/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp +++ b/src/hotspot/os_cpu/linux_riscv/atomic_linux_riscv.hpp @@ -33,10 +33,23 @@ // Note that memory_order_conservative requires a full barrier after atomic stores. // See https://patchwork.kernel.org/patch/3575821/ +#if defined(__clang_major__) +#define FULL_COMPILER_ATOMIC_SUPPORT +#elif (__GNUC__ > 13) || ((__GNUC__ == 13) && (__GNUC_MINOR__ >= 2)) +#define FULL_COMPILER_ATOMIC_SUPPORT +#endif + template struct Atomic::PlatformAdd { template D add_and_fetch(D volatile* dest, I add_value, atomic_memory_order order) const { + +#ifndef FULL_COMPILER_ATOMIC_SUPPORT + // If we add add and fetch for sub word and are using older compiler + // it must be added here due to not using lib atomic. + STATIC_ASSERT(byte_size >= 4); +#endif + if (order != memory_order_relaxed) { FULL_MEM_BARRIER; } @@ -55,12 +68,65 @@ struct Atomic::PlatformAdd { } }; +#ifndef FULL_COMPILER_ATOMIC_SUPPORT +template<> +template +inline T Atomic::PlatformCmpxchg<1>::operator()(T volatile* dest __attribute__((unused)), + T compare_value, + T exchange_value, + atomic_memory_order order) const { + STATIC_ASSERT(1 == sizeof(T)); + + if (order != memory_order_relaxed) { + FULL_MEM_BARRIER; + } + + uint32_t volatile* aligned_dst = (uint32_t volatile*)(((uintptr_t)dest) & (~((uintptr_t)0x3))); + int shift = 8 * (((uintptr_t)dest) - ((uintptr_t)aligned_dst)); // 0, 8, 16, 24 + + uint64_t mask = 0xfful << shift; // 0x00000000..FF.. + uint64_t remask = ~mask; // 0xFFFFFFFF..00.. + + uint64_t w_cv = ((uint64_t)(unsigned char)compare_value) << shift; // widen to 64-bit 0x00000000..CC.. + uint64_t w_ev = ((uint64_t)(unsigned char)exchange_value) << shift; // widen to 64-bit 0x00000000..EE.. + + uint64_t old_value; + uint64_t rc_temp; + + __asm__ __volatile__ ( + "1: lr.w %0, %2 \n\t" + " and %1, %0, %5 \n\t" // ignore unrelated bytes and widen to 64-bit 0x00000000..XX.. + " bne %1, %3, 2f \n\t" // compare 64-bit w_cv + " and %1, %0, %6 \n\t" // remove old byte + " or %1, %1, %4 \n\t" // add new byte + " sc.w %1, %1, %2 \n\t" // store new word + " bnez %1, 1b \n\t" + "2: \n\t" + : /*%0*/"=&r" (old_value), /*%1*/"=&r" (rc_temp), /*%2*/"+A" (*aligned_dst) + : /*%3*/"r" (w_cv), /*%4*/"r" (w_ev), /*%5*/"r" (mask), /*%6*/"r" (remask) + : "memory" ); + + if (order != memory_order_relaxed) { + FULL_MEM_BARRIER; + } + + return (T)((old_value & mask) >> shift); +} +#endif + template template inline T Atomic::PlatformXchg::operator()(T volatile* dest, T exchange_value, atomic_memory_order order) const { +#ifndef FULL_COMPILER_ATOMIC_SUPPORT + // If we add xchg for sub word and are using older compiler + // it must be added here due to not using lib atomic. + STATIC_ASSERT(byte_size >= 4); +#endif + STATIC_ASSERT(byte_size == sizeof(T)); + if (order != memory_order_relaxed) { FULL_MEM_BARRIER; } @@ -80,6 +146,11 @@ inline T Atomic::PlatformCmpxchg::operator()(T volatile* dest __attri T compare_value, T exchange_value, atomic_memory_order order) const { + +#ifndef FULL_COMPILER_ATOMIC_SUPPORT + STATIC_ASSERT(byte_size >= 4); +#endif + STATIC_ASSERT(byte_size == sizeof(T)); T value = compare_value; if (order != memory_order_relaxed) { @@ -148,4 +219,6 @@ struct Atomic::PlatformOrderedStore void operator()(volatile T* p, T v) const { release_store(p, v); OrderAccess::fence(); } }; +#undef FULL_COMPILER_ATOMIC_SUPPORT + #endif // OS_CPU_LINUX_RISCV_ATOMIC_LINUX_RISCV_HPP From 3d9cb02d3131a963ddfb5061d84b32e3eda6ad10 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 21 Nov 2023 11:17:06 +0000 Subject: [PATCH 324/341] 8317834: java/lang/Thread/IsAlive.java timed out Backport-of: 5522656af73347439eac6ecfef35d4a8f3dce77d --- test/jdk/java/lang/Thread/IsAlive.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/java/lang/Thread/IsAlive.java b/test/jdk/java/lang/Thread/IsAlive.java index ffb7ca6fea5ca..a95fe345cada2 100644 --- a/test/jdk/java/lang/Thread/IsAlive.java +++ b/test/jdk/java/lang/Thread/IsAlive.java @@ -25,7 +25,7 @@ * @test * @bug 8305425 * @summary Check Thread.isAlive - * @run main/othervm/timeout=10 IsAlive + * @run main/othervm IsAlive */ public class IsAlive { From e4ddf06ae953f9a8306cc7c2122e7886022b10f6 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 21 Nov 2023 11:17:34 +0000 Subject: [PATCH 325/341] 8320053: GHA: Cross-compile gtest code Backport-of: 77a69661145a43ab564832b0354ec32068236214 --- .github/workflows/build-cross-compile.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 8df4fd4b196da..d73bef53bb5b5 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -100,6 +100,10 @@ jobs: with: platform: linux-x64 + - name: 'Get GTest' + id: gtest + uses: ./.github/actions/get-gtest + # Upgrading apt to solve libc6 installation bugs, see JDK-8260460. - name: 'Install toolchain and dependencies' run: | @@ -155,6 +159,7 @@ jobs: --with-conf-name=linux-${{ matrix.target-cpu }} --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} --with-boot-jdk=${{ steps.bootjdk.outputs.path }} + --with-gtest=${{ steps.gtest.outputs.path }} --with-zlib=system --enable-debug --disable-precompiled-headers From c478c811a539e09c87f51be2965919f864d4fde6 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 21 Nov 2023 12:16:18 +0000 Subject: [PATCH 326/341] 8292067: Convert test/sun/management/jmxremote/bootstrap shell tests to java version Backport-of: 3993a1f9eaa8353ab8b24fe56c870580ef34fb52 --- test/jdk/sun/management/jmxremote/RunTest.sh | 33 - .../bootstrap/GeneratePropertyPassword.sh | 131 --- .../jmxremote/bootstrap/RmiBootstrapTest.java | 783 +++++++----------- .../jmxremote/bootstrap/RmiBootstrapTest.sh | 66 -- .../bootstrap/RmiSslBootstrapTest.sh | 64 -- .../bootstrap/RmiSslNoKeyStoreTest.java | 413 ++++----- .../bootstrap/RmiSslNoKeyStoreTest.sh | 62 -- .../jmxremote/bootstrap/RmiTestBase.java | 265 ++++++ .../management/jmxremote/bootstrap/Utils.java | 146 ++++ 9 files changed, 913 insertions(+), 1050 deletions(-) delete mode 100644 test/jdk/sun/management/jmxremote/RunTest.sh delete mode 100644 test/jdk/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh delete mode 100644 test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh delete mode 100644 test/jdk/sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh delete mode 100644 test/jdk/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh create mode 100644 test/jdk/sun/management/jmxremote/bootstrap/RmiTestBase.java diff --git a/test/jdk/sun/management/jmxremote/RunTest.sh b/test/jdk/sun/management/jmxremote/RunTest.sh deleted file mode 100644 index e9a924a89b8a8..0000000000000 --- a/test/jdk/sun/management/jmxremote/RunTest.sh +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. -# 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. -# - -# Execute the test. -# No need to compile (now done by JTReg tags in calling file) -# -echo ${TESTJAVA}/bin/java ${TESTVMOPTS} -Dtest.src=${TESTCLASSES} \ - -classpath ${TESTCLASSPATH} $* || exit 20 - -${TESTJAVA}/bin/java ${TESTVMOPTS} -Dtest.src=${TESTCLASSES} \ - -classpath ${TESTCLASSPATH} $* || exit 20 - -exit 0 diff --git a/test/jdk/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh b/test/jdk/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh deleted file mode 100644 index 98a20edc6316d..0000000000000 --- a/test/jdk/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh +++ /dev/null @@ -1,131 +0,0 @@ -# -# Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. -# 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. -# - -# -# Utility Shell Script for generating .properties files or .password files -# or .access files from a list of input .in files. -# -# Source in this GeneratePropertyPassword.sh and call the function -# generatePropertyPasswordFiles. -# Call restoreFilePermissions to restore file permissions after the test completes -# - - -OS=`uname -s` -UMASK=`umask` - -case $OS in -CYGWIN_NT*) - OS="Windows_NT" - if [ -z "$SystemRoot" ] ; then - SystemRoot=`cygpath $SYSTEMROOT` - fi -esac - -case $OS in -Linux | Darwin | AIX ) - PATHSEP=":" - FILESEP="/" - DFILESEP=$FILESEP - TMP_FILE=${TESTCLASSES}${FILESEP}${TESTCLASS}.sed.tmpfile - -cat < ${TMP_FILE} -s^@TEST-SRC@/^${TESTCLASSES}${DFILESEP}^g -EOF - ;; -Windows_95 | Windows_98 | Windows_NT | Windows_ME | CYGWIN*) - PATHSEP=";" - FILESEP="\\" - DFILESEP=$FILESEP$FILESEP - TMP_FILE=${TESTCLASSES}${FILESEP}${TESTCLASS}.sed.tmpfile - -cat < ${TMP_FILE}0 -s^@TEST-SRC@/^${TESTCLASSES}${DFILESEP}^g -EOF - # Need to put double backslash in the .properties files - cat ${TMP_FILE}0 | sed -e 's^\\\\^ZZZZ^g' | \ - sed -e 's^\\^ZZZZ^g' | \ - sed -e 's^ZZZZ^\\\\\\\\^g' > ${TMP_FILE} - - if [ "$OS" = "Windows_NT" ]; then - USER=`id -u -n` - CACLS="$SystemRoot/system32/cacls.exe" - REVOKEALL="$TESTNATIVEPATH/revokeall.exe" - if [ ! -x "$REVOKEALL" ] ; then - echo "$REVOKEALL doesn't exist or is not executable" - exit 1 - fi - fi - ;; -*) - echo "Unrecognized system! $OS" - exit 1 - ;; -esac - -generatePropertyPasswordFiles() -{ - for f in $@ - do - echo processing $f - suffix=`basename $f .in` - f2="${TESTCLASSES}${FILESEP}${suffix}" - - if [ -f "$f2" ] ; then - rm -f $f2 || echo WARNING: $f2 already exits - unable to remove old copy - fi - - echo creating $f2 - sed -f $TMP_FILE $f > $f2 - - if [ "$OS" = "Windows_NT" ]; then - chown $USER $f2 - # Grant this user full access - echo Y|$CACLS $f2 \/E \/G $USER:F - # Revoke everyone else - $REVOKEALL $f2 - # Display ACLs - $CACLS $f2 - else - chmod 600 $f2 - fi - done -} - -restoreFilePermissions() -{ - for f in $@ - do - suffix=`basename $f .in` - f2="${TESTCLASSES}${FILESEP}${suffix}" - - if [ "$OS" = "Windows_NT" ]; then - # Grant everyone full control - $CACLS $f2 \/E \/G Everyone:F - else - chmod 777 $f2 - fi - - done -} - diff --git a/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java b/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java index 6fe3dab697045..2c494a58c9251 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -20,29 +20,57 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + import sun.management.jmxremote.ConnectorBootstrap; import java.io.File; import java.io.FileInputStream; -import java.io.FilenameFilter; import java.io.IOException; import java.net.BindException; +import java.nio.file.Path; import java.rmi.server.ExportException; -import java.util.Properties; -import java.util.Iterator; -import java.util.Set; +import jdk.internal.agent.AgentConfigurationError; + +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanInfo; +import javax.management.MBeanServerConnection; +import javax.management.ObjectName; +import javax.management.QueryExp; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXConnectorServer; +import javax.management.remote.JMXServiceURL; +import java.security.Security; import java.util.ArrayList; +import java.util.Enumeration; import java.util.HashMap; +import java.util.List; import java.util.Map; -import java.util.Enumeration; - -import javax.management.remote.*; -import javax.management.*; +import java.util.Properties; +import java.util.Set; -import jdk.internal.agent.AgentConfigurationError; +/* + * @test + * @bug 6528083 + * @key intermittent + * @summary Test RMI Bootstrap + * + * @library /test/lib + * + * @run main/timeout=300 RmiBootstrapTest .*_test.*.in + * */ -import java.security.Security; +/* + * @test + * @bug 6528083 + * @key intermittent + * @summary Test RMI Bootstrap + * + * @library /test/lib + * + * @run main/timeout=300 RmiBootstrapTest .*_ssltest.*.in + * */ /** *

This class implements unit test for RMI Bootstrap. @@ -56,7 +84,7 @@ *

The rmi port number can be specified with the "rmi.port" system property. * If not, this test will use the first available port

* - *

When called with some argument, the main() will interprete its args to + *

When called with some argument, the main() will interpret its args to * be Java M&M configuration file names. The filenames are expected to end * with ok.properties or ko.properties - and are interpreted as above.

* @@ -68,160 +96,57 @@ * *

Debug traces are logged in "sun.management.test"

**/ -public class RmiBootstrapTest { +public class RmiBootstrapTest extends RmiTestBase { + static TestLogger log = new TestLogger("RmiBootstrapTest"); // the number of consecutive ports to test for availability private static int MAX_GET_FREE_PORT_TRIES = 10; - static TestLogger log = - new TestLogger("RmiBootstrapTest"); - - /** - * Default values for RMI configuration properties. - **/ - public static interface DefaultValues { - public static final String PORT="0"; - public static final String CONFIG_FILE_NAME="management.properties"; - public static final String USE_SSL="true"; - public static final String USE_AUTHENTICATION="true"; - public static final String PASSWORD_FILE_NAME="jmxremote.password"; - public static final String ACCESS_FILE_NAME="jmxremote.access"; - public static final String KEYSTORE="keystore"; - public static final String KEYSTORE_PASSWD="password"; - public static final String TRUSTSTORE="truststore"; - public static final String TRUSTSTORE_PASSWD="trustword"; - public static final String SSL_NEED_CLIENT_AUTH="false"; - } - - /** - * Names of RMI configuration properties. - **/ - public static interface PropertyNames { - public static final String PORT= - "com.sun.management.jmxremote.port"; - public static final String CONFIG_FILE_NAME= - "com.sun.management.config.file"; - public static final String USE_SSL= - "com.sun.management.jmxremote.ssl"; - public static final String USE_AUTHENTICATION= - "com.sun.management.jmxremote.authenticate"; - public static final String PASSWORD_FILE_NAME= - "com.sun.management.jmxremote.password.file"; - public static final String ACCESS_FILE_NAME= - "com.sun.management.jmxremote.access.file"; - public static final String INSTRUMENT_ALL= - "com.sun.management.instrumentall"; - public static final String CREDENTIALS = - "jmx.remote.credentials"; - public static final String KEYSTORE= - "javax.net.ssl.keyStore"; - public static final String KEYSTORE_PASSWD= - "javax.net.ssl.keyStorePassword"; - public static final String TRUSTSTORE= - "javax.net.ssl.trustStore"; - public static final String TRUSTSTORE_PASSWD= - "javax.net.ssl.trustStorePassword"; - public static final String SSL_ENABLED_CIPHER_SUITES = - "com.sun.management.jmxremote.ssl.enabled.cipher.suites"; - public static final String SSL_ENABLED_PROTOCOLS = - "com.sun.management.jmxremote.ssl.enabled.protocols"; - public static final String SSL_NEED_CLIENT_AUTH = - "com.sun.management.jmxremote.ssl.need.client.auth"; - public static final String SSL_CLIENT_ENABLED_CIPHER_SUITES = - "javax.rmi.ssl.client.enabledCipherSuites"; - } - - /** - * A filter to find all filenames who match *. - * Note that and can overlap. - **/ - private static class ConfigFilenameFilter implements FilenameFilter { - final String suffix; - final String prefix; - ConfigFilenameFilter(String prefix, String suffix) { - this.suffix=suffix; - this.prefix=prefix; - } - public boolean accept(File dir, String name) { - return (name.startsWith(prefix) && name.endsWith(suffix)); - } - } - - /** - * Get all "management*ok.properties" files in the directory - * indicated by the "test.src" management property. - **/ - private static File[] findConfigurationFilesOk() { - final String testSrc = System.getProperty("test.src"); - final File dir = new File(testSrc); - final FilenameFilter filter = - new ConfigFilenameFilter("management_test","ok.properties"); - return dir.listFiles(filter); - } - - /** - * Get all "management*ko.properties" files in the directory - * indicated by the "test.src" management property. - **/ - private static File[] findConfigurationFilesKo() { - final String testSrc = System.getProperty("test.src"); - final File dir = new File(testSrc); - final FilenameFilter filter = - new ConfigFilenameFilter("management_test","ko.properties"); - return dir.listFiles(filter); - } /** * List all MBeans and their attributes. Used to test communication * with the Java M&M MBean Server. + * * @return the number of queried MBeans. */ - public static int listMBeans(MBeanServerConnection server) - throws IOException { - return listMBeans(server,null,null); + public static int listMBeans(MBeanServerConnection server) throws IOException { + return listMBeans(server, null, null); } /** * List all matching MBeans and their attributes. * Used to test communication with the Java M&M MBean Server. + * * @return the number of matching MBeans. */ - public static int listMBeans(MBeanServerConnection server, - ObjectName pattern, QueryExp query) - throws IOException { - - final Set names = server.queryNames(pattern,query); - for (final Iterator i=names.iterator(); i.hasNext(); ) { - ObjectName name = (ObjectName)i.next(); - log.trace("listMBeans","Got MBean: "+name); + public static int listMBeans(MBeanServerConnection server, ObjectName pattern, QueryExp query) + throws IOException { + + final Set names = server.queryNames(pattern, query); + for (ObjectName name : names) { + log.trace("listMBeans", "Got MBean: " + name); try { - MBeanInfo info = - server.getMBeanInfo((ObjectName)name); + MBeanInfo info = server.getMBeanInfo(name); MBeanAttributeInfo[] attrs = info.getAttributes(); - if (attrs == null) continue; - for (int j=0; j credentialFiles = prepareTestFiles(args[0]); + Security.setProperty("jdk.tls.disabledAlgorithms", ""); + + try { + MAX_GET_FREE_PORT_TRIES = Integer.parseInt(System.getProperty("test.getfreeport.max.tries", "10")); + } catch (NumberFormatException ex) { + } + + RmiBootstrapTest manager = new RmiBootstrapTest(); + try { + manager.run(args); + } catch (RuntimeException r) { + System.out.println("Test Failed: " + r.getMessage()); + System.exit(1); + } catch (Throwable t) { + System.out.println("Test Failed: " + t); + t.printStackTrace(); + System.exit(2); + } + System.out.println("**** Test RmiBootstrap Passed ****"); + + grantFilesAccess(credentialFiles, AccessControl.EVERYONE); + } /** * Parses the password file to read the credentials. @@ -266,158 +195,151 @@ private static String getDefaultStoreName(String basename) { * If the password file does not exists, return an empty list. * (File not found = empty file). **/ - private ArrayList readCredentials(String passwordFileName) - throws IOException { + private ArrayList readCredentials(String passwordFileName) throws IOException { final Properties pws = new Properties(); - final ArrayList result = new ArrayList(); + final ArrayList result = new ArrayList(); final File f = new File(passwordFileName); - if (!f.exists()) return result; - FileInputStream fin = new FileInputStream(passwordFileName); - try {pws.load(fin);}finally{fin.close();} - for (Enumeration en=pws.propertyNames();en.hasMoreElements();) { + if (!f.exists()) { + return result; + } + try (FileInputStream fin = new FileInputStream(passwordFileName)){ + pws.load(fin); + } catch (IOException e) { + } + for (Enumeration en = pws.propertyNames(); en.hasMoreElements(); ) { final String[] cred = new String[2]; - cred[0]=(String)en.nextElement(); - cred[1]=pws.getProperty(cred[0]); + cred[0] = (String) en.nextElement(); + cred[1] = pws.getProperty(cred[0]); result.add(cred); } return result; } - /** * Connect with the given url, using all given credentials in turn. * A null entry in the useCredentials arrays indicate a connection * where no credentials are used. - * @param url JMXServiceURL of the server. - * @param useCredentials An array of credentials (a credential - * is a two String array, so this is an array of arrays - * of strings: - * useCredentials[i][0]=subject - * useCredentials[i][1]=password - * if useCredentials[i] == null means no credentials. + * + * @param url JMXServiceURL of the server. + * @param useCredentials An array of credentials (a credential + * is a two String array, so this is an array of + * arrays + * of strings: + * useCredentials[i][0]=subject + * useCredentials[i][1]=password + * if useCredentials[i] == null means no credentials. * @param expectConnectOk true if connection is expected to succeed - * Note: if expectConnectOk=false and the test fails to connect - * the number of failure is not incremented. Conversely, - * if expectConnectOk=false and the test does not fail to - * connect the number of failure is incremented. - * @param expectReadOk true if communication (listMBeans) is expected - * to succeed. - * Note: if expectReadOk=false and the test fails to read MBeans - * the number of failure is not incremented. Conversely, - * if expectReadOk=false and the test does not fail to - * read MBeans the number of failure is incremented. + * Note: if expectConnectOk=false and the test + * fails to connect + * the number of failure is not incremented. + * Conversely, + * if expectConnectOk=false and the test does not + * fail to + * connect the number of failure is incremented. + * @param expectReadOk true if communication (listMBeans) is expected + * to succeed. + * Note: if expectReadOk=false and the test fails + * to read MBeans + * the number of failure is not incremented. + * Conversely, + * if expectReadOk=false and the test does not + * fail to + * read MBeans the number of failure is incremented. * @return number of failure. **/ - public int connectAndRead(JMXServiceURL url, - Object[] useCredentials, - boolean expectConnectOk, - boolean expectReadOk) - throws IOException { + public int connectAndRead(JMXServiceURL url, Object[] useCredentials, + boolean expectConnectOk, boolean expectReadOk) + throws IOException { int errorCount = 0; - for (int i=0 ; i * This method calls connectAndRead(). **/ - public void testCommunication(JMXServiceURL url) - throws IOException { + public void testCommunication(JMXServiceURL url) throws IOException { - final String defaultConf = - getDefaultFileName(DefaultValues.CONFIG_FILE_NAME); - final String confname = - System.getProperty(PropertyNames.CONFIG_FILE_NAME,defaultConf); + final String defaultConf = defaultFileNamePrefix + DefaultValues.CONFIG_FILE_NAME; + final String confname = System.getProperty(PropertyNames.CONFIG_FILE_NAME, defaultConf); final Properties props = new Properties(); final File conf = new File(confname); if (conf.exists()) { FileInputStream fin = new FileInputStream(conf); - try {props.load(fin);} finally {fin.close();} + try { + props.load(fin); + } finally { + fin.close(); + } } // Do we use authentication? - final String useAuthenticationStr = - props.getProperty(PropertyNames.USE_AUTHENTICATION, - DefaultValues.USE_AUTHENTICATION); - final boolean useAuthentication = - Boolean.valueOf(useAuthenticationStr).booleanValue(); + final String useAuthenticationStr = + props.getProperty(PropertyNames.USE_AUTHENTICATION, DefaultValues.USE_AUTHENTICATION); + final boolean useAuthentication = Boolean.valueOf(useAuthenticationStr).booleanValue(); // Get Password File - final String defaultPasswordFileName = Utils.convertPath( - getDefaultFileName(DefaultValues.PASSWORD_FILE_NAME)); - final String passwordFileName = Utils.convertPath( - props.getProperty(PropertyNames.PASSWORD_FILE_NAME, - defaultPasswordFileName)); + final String defaultPasswordFileName = + Utils.convertPath(defaultFileNamePrefix + DefaultValues.PASSWORD_FILE_NAME); + final String passwordFileName = + Utils.convertPath(props.getProperty(PropertyNames.PASSWORD_FILE_NAME, defaultPasswordFileName)); // Get Access File - final String defaultAccessFileName = Utils.convertPath( - getDefaultFileName(DefaultValues.ACCESS_FILE_NAME)); - final String accessFileName = Utils.convertPath( - props.getProperty(PropertyNames.ACCESS_FILE_NAME, - defaultAccessFileName)); + final String defaultAccessFileName = Utils.convertPath(defaultFileNamePrefix + DefaultValues.ACCESS_FILE_NAME); + final String accessFileName = + Utils.convertPath(props.getProperty(PropertyNames.ACCESS_FILE_NAME, defaultAccessFileName)); if (useAuthentication) { System.out.println("PasswordFileName: " + passwordFileName); @@ -580,55 +471,52 @@ public void testCommunication(JMXServiceURL url) } final Object[] allCredentials; - final Object[] noCredentials = { null }; + final Object[] noCredentials = {null}; if (useAuthentication) { final ArrayList l = readCredentials(passwordFileName); - if (l.size() == 0) allCredentials = null; - else allCredentials = l.toArray(); - } else allCredentials = noCredentials; + if (l.size() == 0) { + allCredentials = null; + } else { + allCredentials = l.toArray(); + } + } else { + allCredentials = noCredentials; + } int errorCount = 0; - if (allCredentials!=null) { + if (allCredentials != null) { // Tests that the registered user/passwords are allowed to // connect & read // - errorCount += connectAndRead(url,allCredentials,true,true); + errorCount += connectAndRead(url, allCredentials, true, true); } else { // Tests that no one is allowed // connect & read // - final String[][] someCredentials = { - null, - { "modify", "R&D" }, - { "measure", "QED" } - }; - errorCount += connectAndRead(url,someCredentials,false,false); + final String[][] someCredentials = {null, {"modify", "R&D"}, {"measure", "QED"}}; + errorCount += connectAndRead(url, someCredentials, false, false); } if (useAuthentication && allCredentials != noCredentials) { // Tests that the registered user/passwords are not allowed to // connect & read // - final String[][] badCredentials = { - { "bad.user", "R&D" }, - { "measure", "bad.password" } - }; - errorCount += connectAndRead(url,badCredentials,false,false); + final String[][] badCredentials = {{"bad.user", "R&D"}, {"measure", "bad.password"}}; + errorCount += connectAndRead(url, badCredentials, false, false); } if (errorCount > 0) { - final String err = "Test " + confname + " failed with " + - errorCount + " error(s)"; - log.debug("testCommunication",err); + final String err = "Test " + confname + " failed with " + errorCount + " error(s)"; + log.debug("testCommunication", err); throw new RuntimeException(err); } } - /** * Test the configuration indicated by `file'. * Sets the appropriate System properties for config file and * port and then calls ConnectorBootstrap.initialize(). * eventually cleans up by calling ConnectorBootstrap.terminate(). + * * @return null if the test succeeds, an error message otherwise. **/ private String testConfiguration(File file) throws IOException, InterruptedException { @@ -638,32 +526,30 @@ private String testConfiguration(File file) throws IOException, InterruptedExcep int port = jdk.test.lib.Utils.getFreePort(); final String path; try { - path=(file==null)?null:file.getCanonicalPath(); - } catch(IOException x) { - final String err = "Failed to test configuration " + file + - ": " + x; - log.trace("testConfiguration",err); - log.debug("testConfiguration",x); + path = (file == null) ? null : file.getCanonicalPath(); + } catch (IOException x) { + final String err = "Failed to test configuration " + file + ": " + x; + log.trace("testConfiguration", err); + log.debug("testConfiguration", x); return err; } - final String config = (path==null)?"Default config file":path; + final String config = (path == null) ? "Default config file" : path; System.out.println("***"); - System.out.println("*** Testing configuration (port=" + port + "): " - + path); + System.out.println("*** Testing configuration (port=" + port + "): " + path); System.out.println("***"); - System.setProperty("com.sun.management.jmxremote.port", - Integer.toString(port)); - if (path != null) + System.setProperty("com.sun.management.jmxremote.port", Integer.toString(port)); + if (path != null) { System.setProperty("com.sun.management.config.file", path); - else + } else { System.getProperties().remove("com.sun.management.config.file"); + } - log.trace("testConfiguration","com.sun.management.jmxremote.port="+port); - if (path != null && log.isDebugOn()) - log.trace("testConfiguration", - "com.sun.management.config.file="+path); + log.trace("testConfiguration", "com.sun.management.jmxremote.port=" + port); + if (path != null && log.isDebugOn()) { + log.trace("testConfiguration", "com.sun.management.config.file=" + path); + } checkSslConfiguration(); @@ -673,54 +559,49 @@ private String testConfiguration(File file) throws IOException, InterruptedExcep } catch (AgentConfigurationError x) { if (x.getCause() instanceof ExportException) { if (x.getCause().getCause() instanceof BindException) { - throw (BindException)x.getCause().getCause(); + throw (BindException) x.getCause().getCause(); } } - final String err = "Failed to initialize connector:" + - "\n\tcom.sun.management.jmxremote.port=" + port + - ((path!=null)?"\n\tcom.sun.management.config.file="+path: - "\n\t"+config) + - "\n\tError is: " + x; - log.trace("testConfiguration",err); - log.debug("testConfiguration",x); + final String err = + "Failed to initialize connector:" + "\n\tcom.sun.management.jmxremote.port=" + port + + ((path != null) ? "\n\tcom.sun.management.config.file=" + path : "\n\t" + config) + + "\n\tError is: " + x; + log.trace("testConfiguration", err); + log.debug("testConfiguration", x); return err; } catch (Exception x) { - log.debug("testConfiguration",x); + log.debug("testConfiguration", x); return x.toString(); } try { - JMXServiceURL url = - new JMXServiceURL("rmi",null,0,"/jndi/rmi://localhost:"+ - port+"/jmxrmi"); + JMXServiceURL url = new JMXServiceURL("rmi", null, 0, "/jndi/rmi://localhost:" + port + "/jmxrmi"); try { testCommunication(url); } catch (Exception x) { - final String err = "Failed to connect to agent {url="+url+ - "}: " + x; - log.trace("testConfiguration",err); - log.debug("testConfiguration",x); + final String err = "Failed to connect to agent {url=" + url + "}: " + x; + log.trace("testConfiguration", err); + log.debug("testConfiguration", x); return err; } } catch (Exception x) { - final String err = "Failed to test configuration "+config+ - ": "+x; - log.trace("testConfiguration",err); - log.debug("testConfiguration",x); + final String err = "Failed to test configuration " + config + ": " + x; + log.trace("testConfiguration", err); + log.debug("testConfiguration", x); return err; } finally { try { cs.stop(); } catch (Exception x) { - final String err = "Failed to terminate: "+x; - log.trace("testConfiguration",err); - log.debug("testConfiguration",x); + final String err = "Failed to terminate: " + x; + log.trace("testConfiguration", err); + log.debug("testConfiguration", x); } } System.out.println("Configuration " + config + " successfully tested"); return null; - } catch(BindException ex) { + } catch (BindException ex) { } } System.err.println("Cannot find a free port after " + MAX_GET_FREE_PORT_TRIES + " tries"); @@ -730,17 +611,15 @@ private String testConfiguration(File file) throws IOException, InterruptedExcep /** * Test a configuration file which should make the bootstrap fail. * The test is assumed to have succeeded if the bootstrap fails. + * * @return null if the test succeeds, an error message otherwise. **/ private String testConfigurationKo(File conf) throws InterruptedException, IOException { - String errStr = null; - errStr = testConfiguration(conf); + String errStr = testConfiguration(conf); if (errStr == null) { - return "Configuration " + - conf + " should have failed!"; + return "Configuration " + conf + " should have failed!"; } - System.out.println("Configuration " + - conf + " failed as expected"); + System.out.println("Configuration " + conf + " failed as expected"); log.debug("runko", "Error was: " + errStr); return null; } @@ -748,8 +627,9 @@ private String testConfigurationKo(File conf) throws InterruptedException, IOExc /** * Test a configuration file. Determines whether the bootstrap * should succeed or fail depending on the file name: - * *ok.properties: bootstrap should succeed. - * *ko.properties: bootstrap or connection should fail. + * *ok.properties: bootstrap should succeed. + * *ko.properties: bootstrap or connection should fail. + * * @return null if the test succeeds, an error message otherwise. **/ private String testConfigurationFile(String fileName) throws InterruptedException, IOException { @@ -763,22 +643,23 @@ private String testConfigurationFile(String fileName) throws InterruptedExceptio if (fileName.endsWith("ko.properties")) { return testConfigurationKo(file); } - return fileName + - ": test file suffix must be one of [ko|ok].properties"; + return fileName + ": test file suffix must be one of [ko|ok].properties"; } /** * Find all *ko.property files and test them. * (see findConfigurationFilesKo() and testConfigurationKo()) + * * @throws RuntimeException if the test fails. **/ - public void runko() throws InterruptedException, IOException { - final File[] conf = findConfigurationFilesKo(); - if ((conf == null)||(conf.length == 0)) + public void runko(boolean useSsl) throws InterruptedException, IOException { + final File[] conf = RmiTestBase.findConfigurationFilesKo(useSsl); + if ((conf == null) || (conf.length == 0)) { throw new RuntimeException("No configuration found"); + } String errStr; - for (int i=0;iThis class implements unit test for RMI Bootstrap. * When called with no arguments main() looks in the directory indicated @@ -69,163 +75,113 @@ * *

Debug traces are logged in "sun.management.test"

**/ -public class RmiSslNoKeyStoreTest { - - static TestLogger log = - new TestLogger("RmiSslNoKeyStoreTest"); +public class RmiSslNoKeyStoreTest extends RmiTestBase { + static TestLogger log = new TestLogger("RmiSslNoKeyStoreTest"); /** * When launching several registries, we increment the port number * to avoid falling into "port number already in use" problems. **/ static int testPort = 0; + final String DEFAULT_KEY_STORE = defaultStoreNamePrefix + DefaultValues.KEYSTORE; + final String KEY_STORE = System.getProperty(PropertyNames.KEYSTORE, DEFAULT_KEY_STORE); - /** - * Default values for RMI configuration properties. - **/ - public static interface DefaultValues { - public static final String PORT="0"; - public static final String CONFIG_FILE_NAME="management.properties"; - public static final String USE_SSL="true"; - public static final String USE_AUTHENTICATION="true"; - public static final String PASSWORD_FILE_NAME="jmxremote.password"; - public static final String ACCESS_FILE_NAME="jmxremote.access"; - public static final String KEYSTORE="keystore"; - public static final String KEYSTORE_PASSWD="password"; - public static final String TRUSTSTORE="truststore"; - public static final String TRUSTSTORE_PASSWD="trustword"; - } - - /** - * Names of RMI configuration properties. - **/ - public static interface PropertyNames { - public static final String PORT="com.sun.management.jmxremote.port"; - public static final String CONFIG_FILE_NAME= - "com.sun.management.config.file"; - public static final String USE_SSL="com.sun.management.jmxremote.ssl"; - public static final String USE_AUTHENTICATION= - "com.sun.management.jmxremote.authenticate"; - public static final String PASSWORD_FILE_NAME= - "com.sun.management.jmxremote.password.file"; - public static final String ACCESS_FILE_NAME= - "com.sun.management.jmxremote.access.file"; - public static final String INSTRUMENT_ALL= - "com.sun.management.instrumentall"; - public static final String CREDENTIALS = - "jmx.remote.credentials"; - public static final String KEYSTORE="javax.net.ssl.keyStore"; - public static final String KEYSTORE_PASSWD= - "javax.net.ssl.keyStorePassword"; - public static final String KEYSTORE_TYPE="javax.net.ssl.keyStoreType"; - public static final String TRUSTSTORE="javax.net.ssl.trustStore"; - public static final String TRUSTSTORE_PASSWD= - "javax.net.ssl.trustStorePassword"; - } - - /** - * Compute the full path name for a default file. - * @param basename basename (with extension) of the default file. - * @return ${JRE}/conf/management/${basename} - **/ - private static String getDefaultFileName(String basename) { - final String fileSeparator = File.separator; - final StringBuffer defaultFileName = - new StringBuffer(System.getProperty("java.home")). - append(fileSeparator).append("conf").append(fileSeparator). - append("management").append(fileSeparator). - append(basename); - return defaultFileName.toString(); - } + private static void checkKeystore(Properties props) + throws IOException, GeneralSecurityException { + if (log.isDebugOn()) { + log.debug("checkKeystore", "Checking Keystore configuration"); + } - /** - * Compute the full path name for a default file. - * @param basename basename (with extension) of the default file. - * @return ${JRE}/conf/management/${basename} - **/ - private static String getDefaultStoreName(String basename) { - final String fileSeparator = File.separator; - final StringBuffer defaultFileName = - new StringBuffer(System.getProperty("test.src")). - append(fileSeparator).append("ssl").append(fileSeparator). - append(basename); - return defaultFileName.toString(); - } + final String keyStore = System.getProperty(PropertyNames.KEYSTORE); + if (keyStore == null) { + throw new IllegalArgumentException("System property " + PropertyNames.KEYSTORE + " not specified"); + } - private static void checkKeystore(Properties props) - throws IOException, GeneralSecurityException { - if (log.isDebugOn()) - log.debug("checkKeystore","Checking Keystore configuration"); - - final String keyStore = - System.getProperty(PropertyNames.KEYSTORE); - if (keyStore == null) - throw new IllegalArgumentException("System property " + - PropertyNames.KEYSTORE + - " not specified"); - - final String keyStorePass = - System.getProperty(PropertyNames.KEYSTORE_PASSWD); + final String keyStorePass = System.getProperty(PropertyNames.KEYSTORE_PASSWD); if (keyStorePass == null) { // We don't have the password, we can only check whether the // file exists... // final File ksf = new File(keyStore); - if (! ksf.canRead()) + if (!ksf.canRead()) { throw new IOException(keyStore + ": not readable"); + } - if (log.isDebugOn()) + if (log.isDebugOn()) { log.debug("checkSSL", "No password."); - throw new IllegalArgumentException("System property " + - PropertyNames.KEYSTORE_PASSWD + - " not specified"); + } + throw new IllegalArgumentException("System property " + PropertyNames.KEYSTORE_PASSWD + " not specified"); } // Now we're going to load the keyStore - just to check it's // correct. // - final String keyStoreType = - System.getProperty(PropertyNames.KEYSTORE_TYPE, - KeyStore.getDefaultType()); - final KeyStore ks = KeyStore.getInstance(keyStoreType); + final String keyStoreType = System.getProperty(PropertyNames.KEYSTORE_TYPE, KeyStore.getDefaultType()); + final KeyStore ks = KeyStore.getInstance(keyStoreType); final FileInputStream fin = new FileInputStream(keyStore); - final char keypassword[] = keyStorePass.toCharArray(); + final char keypassword[] = keyStorePass.toCharArray(); try { - ks.load(fin,keypassword); + ks.load(fin, keypassword); } finally { - Arrays.fill(keypassword,' '); + Arrays.fill(keypassword, ' '); fin.close(); } - if (log.isDebugOn()) - log.debug("checkSSL","SSL configuration successfully checked"); + if (log.isDebugOn()) { + log.debug("checkSSL", "SSL configuration successfully checked"); + } + } + + /** + * Calls run(args[]). + * exit(1) if the test fails. + **/ + public static void main(String args[]) throws Exception { + if (args.length == 0) { + throw new IllegalArgumentException("Argument is required for this" + " test"); + } + + final List credentialFiles = prepareTestFiles(args[0]); + + RmiSslNoKeyStoreTest manager = new RmiSslNoKeyStoreTest(); + try { + manager.run(args); + } catch (RuntimeException r) { + System.err.println("Test Failed: " + r.getMessage()); + System.exit(1); + } catch (Throwable t) { + System.err.println("Test Failed: " + t); + t.printStackTrace(); + System.exit(2); + } + System.out.println("**** Test RmiSslNoKeyStoreTest Passed ****"); + + grantFilesAccess(credentialFiles, AccessControl.EVERYONE); } private void checkSslConfiguration() throws Exception { - final String defaultConf = - getDefaultFileName(DefaultValues.CONFIG_FILE_NAME); - final String confname = - System.getProperty(PropertyNames.CONFIG_FILE_NAME,defaultConf); + final String defaultConf = defaultFileNamePrefix + DefaultValues.CONFIG_FILE_NAME; + final String confname = System.getProperty(PropertyNames.CONFIG_FILE_NAME, defaultConf); final Properties props = new Properties(); final File conf = new File(confname); if (conf.exists()) { FileInputStream fin = new FileInputStream(conf); - try {props.load(fin);} finally {fin.close();} + try { + props.load(fin); + } finally { + fin.close(); + } } // Do we use SSL? - final String useSslStr = - props.getProperty(PropertyNames.USE_SSL, - DefaultValues.USE_SSL); - final boolean useSsl = - Boolean.valueOf(useSslStr).booleanValue(); + final String useSslStr = props.getProperty(PropertyNames.USE_SSL, DefaultValues.USE_SSL); + final boolean useSsl = Boolean.valueOf(useSslStr).booleanValue(); - log.debug("checkSslConfiguration",PropertyNames.USE_SSL+"="+useSsl); + log.debug("checkSslConfiguration", PropertyNames.USE_SSL + "=" + useSsl); if (useSsl == false) { - final String msg = - PropertyNames.USE_SSL+"="+useSsl+", can't run test"; + final String msg = PropertyNames.USE_SSL + "=" + useSsl + ", can't run test"; throw new IllegalArgumentException(msg); } @@ -233,7 +189,7 @@ private void checkSslConfiguration() throws Exception { checkKeystore(props); } catch (Exception x) { // Ok! - log.debug("checkSslConfiguration","Test configuration OK: " + x); + log.debug("checkSslConfiguration", "Test configuration OK: " + x); return; } @@ -246,31 +202,30 @@ private void checkSslConfiguration() throws Exception { * Sets the appropriate System properties for config file and * port and then calls ConnectorBootstrap.initialize(). * eventually cleans up by calling ConnectorBootstrap.terminate(). + * * @return null if the test succeeds, an error message otherwise. **/ - private String testConfiguration(File file,int port) { + private String testConfiguration(File file, int port) { - final String path = (file==null)?null:file.getAbsolutePath(); - final String config = (path==null)?"Default config file":path; + final String path = (file == null) ? null : file.getAbsolutePath(); + final String config = (path == null) ? "Default config file" : path; try { System.out.println("***"); - System.out.println("*** Testing configuration (port="+ - port + "): "+ path); + System.out.println("*** Testing configuration (port=" + port + "): " + path); System.out.println("***"); - System.setProperty("com.sun.management.jmxremote.port", - Integer.toString(port)); - if (path != null) + System.setProperty("com.sun.management.jmxremote.port", Integer.toString(port)); + if (path != null) { System.setProperty("com.sun.management.config.file", path); - else - System.getProperties(). - remove("com.sun.management.config.file"); + } else { + System.getProperties().remove("com.sun.management.config.file"); + } - log.trace("testConfiguration","com.sun.management.jmxremote.port="+port); - if (path != null && log.isDebugOn()) - log.trace("testConfiguration", - "com.sun.management.config.file="+path); + log.trace("testConfiguration", "com.sun.management.jmxremote.port=" + port); + if (path != null && log.isDebugOn()) { + log.trace("testConfiguration", "com.sun.management.config.file=" + path); + } checkSslConfiguration(); @@ -278,61 +233,52 @@ private String testConfiguration(File file,int port) { try { cs = ConnectorBootstrap.initialize(); } catch (AgentConfigurationError x) { - final String err = "Failed to initialize connector:" + - "\n\tcom.sun.management.jmxremote.port=" + port + - ((path!=null)?"\n\tcom.sun.management.config.file="+path: - "\n\t"+config) + - "\n\tError is: " + x; + final String err = "Failed to initialize connector:" + "\n\tcom.sun.management.jmxremote.port=" + port + + ((path != null) ? "\n\tcom.sun.management.config.file=" + path : "\n\t" + config) + + "\n\tError is: " + x; - log.trace("testConfiguration","Expected failure: " + err); - log.debug("testConfiguration",x); + log.trace("testConfiguration", "Expected failure: " + err); + log.debug("testConfiguration", x); System.out.println("Got expected failure: " + x); return null; } catch (Exception x) { - log.debug("testConfiguration",x); + log.debug("testConfiguration", x); return x.toString(); } try { - JMXConnector cc = - JMXConnectorFactory.connect(cs.getAddress(), null); + JMXConnector cc = JMXConnectorFactory.connect(cs.getAddress(), null); cc.close(); } catch (IOException x) { - final String err = "Failed to initialize connector:" + - "\n\tcom.sun.management.jmxremote.port=" + port + - ((path!=null)?"\n\tcom.sun.management.config.file="+path: - "\n\t"+config) + - "\n\tError is: " + x; + final String err = "Failed to initialize connector:" + "\n\tcom.sun.management.jmxremote.port=" + port + + ((path != null) ? "\n\tcom.sun.management.config.file=" + path : "\n\t" + config) + + "\n\tError is: " + x; - log.trace("testConfiguration","Expected failure: " + err); - log.debug("testConfiguration",x); + log.trace("testConfiguration", "Expected failure: " + err); + log.debug("testConfiguration", x); System.out.println("Got expected failure: " + x); return null; } catch (Exception x) { - log.debug("testConfiguration",x); + log.debug("testConfiguration", x); return x.toString(); } try { cs.stop(); } catch (Exception x) { - final String err = "Failed to terminate: "+x; - log.trace("testConfiguration",err); - log.debug("testConfiguration",x); + final String err = "Failed to terminate: " + x; + log.trace("testConfiguration", err); + log.debug("testConfiguration", x); } - final String err = "Bootstrap should have failed:" + - "\n\tcom.sun.management.jmxremote.port=" + port + - ((path!=null)?"\n\tcom.sun.management.config.file="+path: - "\n\t"+config); - log.trace("testConfiguration",err); + final String err = "Bootstrap should have failed:" + "\n\tcom.sun.management.jmxremote.port=" + port + + ((path != null) ? "\n\tcom.sun.management.config.file=" + path : "\n\t" + config); + log.trace("testConfiguration", err); return err; } catch (Exception x) { - final String err = "Failed to test bootstrap for:" + - "\n\tcom.sun.management.jmxremote.port=" + port + - ((path!=null)?"\n\tcom.sun.management.config.file="+path: - "\n\t"+config)+ - "\n\tError is: " + x; - - log.trace("testConfiguration",err); - log.debug("testConfiguration",x); + final String err = "Failed to test bootstrap for:" + "\n\tcom.sun.management.jmxremote.port=" + port + + ((path != null) ? "\n\tcom.sun.management.config.file=" + path : "\n\t" + config) + + "\n\tError is: " + x; + + log.trace("testConfiguration", err); + log.debug("testConfiguration", x); return err; } } @@ -340,79 +286,82 @@ private String testConfiguration(File file,int port) { /** * Test a configuration file. Determines whether the bootstrap * should succeed or fail depending on the file name: - * *ok.properties: bootstrap should succeed. - * *ko.properties: bootstrap or connection should fail. + * *ok.properties: bootstrap should succeed. + * *ko.properties: bootstrap or connection should fail. + * * @return null if the test succeeds, an error message otherwise. **/ private String testConfigurationFile(String fileName) { File file = new File(fileName); - final String portStr = System.getProperty("rmi.port","12424"); - final int port = Integer.parseInt(portStr); + final String portStr = System.getProperty("rmi.port", "12424"); + final int port = Integer.parseInt(portStr); - return testConfiguration(file,port+testPort++); + return testConfiguration(file, port + testPort++); } - /** - * Tests the specified configuration files. - * If args[] is not empty, each element in args[] is expected to be - * a filename ending either by ok.properties or ko.properties. - * Otherwise, the configuration files will be automatically determined - * by looking at all *.properties files located in the directory - * indicated by the System property "test.src". - * @throws RuntimeException if the test fails. + * Test a configuration file. **/ - public void run(String args[]) { - final String defaultKeyStore = - getDefaultStoreName(DefaultValues.KEYSTORE); - final String keyStore = - System.getProperty(PropertyNames.KEYSTORE, defaultKeyStore); + private void runConfigurationFile(String fileName) { + String errStr = testConfigurationFile(fileName); + if (errStr != null) { + throw new RuntimeException(errStr); + } - for (int i=0; i*. + * Note that and can overlap. + **/ + static class FilenameFilterFactory { + static FilenameFilter prefixSuffix(final String p, final String s) { + return (dir, name) -> name.startsWith(p) && name.endsWith(s); + } + } + + enum AccessControl { + OWNER, + EVERYONE, + } + + /** + * Default values for RMI configuration properties. + **/ + public interface DefaultValues { + String PORT = "0"; + String CONFIG_FILE_NAME = "management.properties"; + String USE_SSL = "true"; + String USE_AUTHENTICATION = "true"; + String PASSWORD_FILE_NAME = "jmxremote.password"; + String ACCESS_FILE_NAME = "jmxremote.access"; + String KEYSTORE = "keystore"; + String KEYSTORE_PASSWD = "password"; + String TRUSTSTORE = "truststore"; + String TRUSTSTORE_PASSWD = "trustword"; + String SSL_NEED_CLIENT_AUTH = "false"; + } + + /** + * Names of RMI configuration properties. + **/ + public interface PropertyNames { + String PORT = "com.sun.management.jmxremote.port"; + String CONFIG_FILE_NAME = "com.sun.management.config.file"; + String USE_SSL = "com.sun.management.jmxremote.ssl"; + String USE_AUTHENTICATION = "com.sun.management.jmxremote.authenticate"; + String PASSWORD_FILE_NAME = "com.sun.management.jmxremote.password.file"; + String ACCESS_FILE_NAME = "com.sun.management.jmxremote.access.file"; + String INSTRUMENT_ALL = "com.sun.management.instrumentall"; + String CREDENTIALS = "jmx.remote.credentials"; + String KEYSTORE = "javax.net.ssl.keyStore"; + String KEYSTORE_PASSWD = "javax.net.ssl.keyStorePassword"; + String KEYSTORE_TYPE = "javax.net.ssl.keyStoreType"; + String TRUSTSTORE = "javax.net.ssl.trustStore"; + String TRUSTSTORE_PASSWD = "javax.net.ssl.trustStorePassword"; + String SSL_ENABLED_CIPHER_SUITES = "com.sun.management.jmxremote.ssl.enabled.cipher.suites"; + String SSL_ENABLED_PROTOCOLS = "com.sun.management.jmxremote.ssl.enabled.protocols"; + String SSL_NEED_CLIENT_AUTH = "com.sun.management.jmxremote.ssl.need.client.auth"; + String SSL_CLIENT_ENABLED_CIPHER_SUITES = "javax.rmi.ssl.client.enabledCipherSuites"; + } + + /** + * Copy test artifacts to test folder. + * + * @param filenamePattern the filename pattern to look for + * @return files who match the filename pattern + * @throws IOException if error occurs + */ + static List prepareTestFiles(String filenamePattern) throws IOException { + copySsl(); + List files = Utils.findFiles(Paths.get(SRC), (dir, name) -> name.matches(filenamePattern)); + + final Function removeSuffix = (s) -> s.substring(0, s.lastIndexOf(".")); + + List propertyFiles = + Utils.copyFiles(files, Paths.get(DEST), removeSuffix, StandardCopyOption.REPLACE_EXISTING); + + // replace @TEST-SRC@ with the path of the current test folder + if (Platform.isWindows()) { + // On Windows, also replace forward slash or single backslash to double backslashes + Utils.replaceFilesString(propertyFiles, + (s) -> s.replace(TEST_SRC, DEST).replaceAll("[/\\\\]", "\\\\\\\\")); + } else { + Utils.replaceFilesString(propertyFiles, (s) -> s.replace(TEST_SRC, DEST)); + } + + grantFilesAccess(propertyFiles, AccessControl.OWNER); + + return Collections.unmodifiableList(files); + } + + /** + * Grant file access. + * + * @param file file to grant access + * @param access user access or full access + * @throws IOException if error occurs + */ + static void grantAccess(Path file, AccessControl access) throws IOException { + Set attr = file.getFileSystem().supportedFileAttributeViews(); + if (attr.contains("posix")) { + String perms = access == AccessControl.OWNER ? "rw-------" : "rwxrwxrwx"; + Files.setPosixFilePermissions(file, PosixFilePermissions.fromString(perms)); + } else if (attr.contains("acl")) { + AclFileAttributeView view = Files.getFileAttributeView(file, AclFileAttributeView.class); + List acl = new ArrayList<>(); + for (AclEntry thisEntry : view.getAcl()) { + if (access == AccessControl.OWNER) { + if (thisEntry.principal().getName().equals(view.getOwner().getName())) { + acl.add(Utils.allowAccess(thisEntry)); + } else if (thisEntry.type() == AclEntryType.ALLOW) { + acl.add(Utils.revokeAccess(thisEntry)); + } else { + acl.add(thisEntry); + } + } else { + if (!thisEntry.principal().getName().contains("NULL SID") + && thisEntry.type() != AclEntryType.ALLOW) { + acl.add(Utils.allowAccess(thisEntry)); + } else { + acl.add(thisEntry); + } + } + } + view.setAcl(acl); + } else { + throw new RuntimeException("Unsupported file attributes: " + attr); + } + } + + /** + * Grant files' access. + * + * @param files files to grant access + * @param access user access or full access + * @throws IOException if error occurs + */ + static void grantFilesAccess(List files, AccessControl access) throws IOException { + for (Path thisFile : files) { + grantAccess(thisFile, access); + } + } + + /** + * Copy SSL files to test folder. + * + * @throws IOException + */ + static void copySsl() throws IOException { + Path sslSource = Paths.get(SRC_SSL); + Path sslTarget = Paths.get(DEST_SSL); + + List files = Arrays.stream(sslSource.toFile().listFiles()).map(File::toPath).collect(Collectors.toList()); + Utils.copyFiles(files, sslTarget, StandardCopyOption.REPLACE_EXISTING); + + for (Path file : files) { + grantAccess(sslTarget.resolve(file.getFileName()), AccessControl.EVERYONE); + } + } + + /** + * Get all "management*ok.properties" files in the directory + * indicated by the "test.src" management property. + * + * @param useSsl boolean that indicates if test uses SSL + * @return configuration files + **/ + static File[] findConfigurationFilesOk(boolean useSsl) { + String prefix = useSsl ? "management_ssltest" : "management_test"; + return findAllConfigurationFiles(prefix, "ok.properties"); + } + + /** + * Get all "management*ko.properties" files in the directory + * indicated by the "test.src" management property. + * + * @param useSsl boolean that indicates if test uses SSL + * @return configuration files + **/ + static File[] findConfigurationFilesKo(boolean useSsl) { + String prefix = useSsl ? "management_ssltest" : "management_test"; + return findAllConfigurationFiles(prefix, "ko.properties"); + } + + /** + * Get all "management*.properties" files in the directory + * indicated by the "test.src" management property. + * + * @param useSsl boolean that indicates if test uses SSL + * @return configuration files + **/ + static File[] findAllConfigurationFiles(boolean useSsl) { + String prefix = useSsl ? "management_ssltest" : "management_test"; + return findAllConfigurationFiles(prefix, "properties"); + } + + /** + * Get all "management*.properties" files in the directory + * indicated by the "test.src" management property. + * + * @param prefix filename prefix + * @param suffix filename suffix + * @return configuration files + **/ + static File[] findAllConfigurationFiles(String prefix, String suffix) { + final File dir = new File(DEST); + final FilenameFilter filter = FilenameFilterFactory.prefixSuffix(prefix, suffix); + return dir.listFiles(filter); + } +} diff --git a/test/jdk/sun/management/jmxremote/bootstrap/Utils.java b/test/jdk/sun/management/jmxremote/bootstrap/Utils.java index e9325c17eedd4..3a7819fc61b7e 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/Utils.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/Utils.java @@ -21,6 +21,15 @@ * questions. */ +import java.io.*; +import java.nio.file.CopyOption; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.*; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + /** * Utility class. */ @@ -46,4 +55,141 @@ static String convertPath(String path) { String newPath = new String(cs); return newPath; } + + /** + * Return file directories that satisfy the specified filter. + * + * @param searchDirectory the base directory to search + * @param filter a filename filter + * @return file directories + */ + public static List findFiles(Path searchDirectory, + FilenameFilter filter) { + return Arrays.stream(searchDirectory.toFile().listFiles(filter)) + .map(f -> f.toPath()) + .collect(Collectors.toList()); + } + + /** + * Copy files to the target path. + * + * @param source the paths to the files to copy + * @param target the path to the target files + * @param filenameMapper mapper function applied to filenames + * @param options options specifying how the copy should be done + * @return the paths to the target files + * @throws IOException if error occurs + */ + public static List copyFiles(List source, Path target, + Function filenameMapper, + CopyOption... options) throws IOException { + List result = new ArrayList<>(); + + if (!target.toFile().exists()) { + Files.createDirectory(target); + } + + for (Path file : source) { + if (!file.toFile().exists()) { + continue; + } + + String baseName = file.getFileName().toString(); + + Path targetFile = target.resolve(filenameMapper.apply(baseName)); + Files.copy(file, targetFile, options); + result.add(targetFile); + } + return result; + } + + /** + * Copy files to the target path. + * + * @param source the paths to the files to copy + * @param target the path to the target files + * @param options options specifying how the copy should be done + * @return the paths to the target files + * @throws IOException if error occurs + */ + public static List copyFiles(List source, Path target, + CopyOption... options) throws IOException { + return copyFiles(source, target, (s) -> s, options); + } + + /** + * Return an ACL entry that revokes owner access. + * + * @param acl original ACL entry to build from + * @return an ACL entry that revokes all access + */ + public static AclEntry revokeAccess(AclEntry acl) { + return buildAclEntry(acl, AclEntryType.DENY); + } + + /** + * Return an ACL entry that allow owner access. + * @param acl original ACL entry to build from + * @return an ACL entry that allows all access + */ + public static AclEntry allowAccess(AclEntry acl) { + return buildAclEntry(acl, AclEntryType.ALLOW); + } + + /** + * Build an ACL entry with a given ACL entry type. + * + * @param acl original ACL entry to build from + * @return an ACL entry with a given ACL entry type + */ + public static AclEntry buildAclEntry(AclEntry acl, AclEntryType type) { + return AclEntry.newBuilder() + .setType(type) + .setPrincipal(acl.principal()) + .setPermissions(acl.permissions()) + .build(); + } + + /** + * Replace file string by applying the given mapper function. + * + * @param source the file to read + * @param contentMapper the mapper function applied to file's content + * @throws IOException if an I/O error occurs + */ + public static void replaceFileString(Path source, + Function contentMapper) throws IOException { + StringBuilder sb = new StringBuilder(); + String lineSep = System.getProperty("line.separator"); + + try (BufferedReader reader = + new BufferedReader(new FileReader(source.toFile()))) { + + String line; + + // read all and replace all at once?? + while ((line = reader.readLine()) != null) { + sb.append(contentMapper.apply(line)) + .append(lineSep); + } + } + + try (FileWriter writer = new FileWriter(source.toFile())) { + writer.write(sb.toString()); + } + } + + /** + * Replace files' string by applying the given mapper function. + * + * @param source the file to read + * @param contentMapper the mapper function applied to files' content + * @throws IOException if an I/O error occurs + */ + public static void replaceFilesString(List source, + Function contentMapper) throws IOException { + for (Path file : source) { + replaceFileString(file, contentMapper); + } + } } From b7605b7974e62e2f3922501e08897e055470e5e3 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 21 Nov 2023 12:18:39 +0000 Subject: [PATCH 327/341] 8302109: Trivial fixes to btree tests Backport-of: 97d0c8720d46de8bd1620de975f6de3ba3eea560 --- .../nsk/sysdict/vm/stress/btree/btree002/btree002.java | 4 ++-- .../nsk/sysdict/vm/stress/btree/btree005/btree005.java | 4 ++-- .../nsk/sysdict/vm/stress/btree/btree008/btree008.java | 5 +++-- .../nsk/sysdict/vm/stress/btree/btree011/btree011.java | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree002/btree002.java b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree002/btree002.java index 01f6d824411f3..5a4a9fae0d6a0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree002/btree002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree002/btree002.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 @@ -30,7 +30,7 @@ * VM Testbase keywords: [stress, sysdict, stressopt, nonconcurrent] * VM Testbase readme: * DESCRIPTION - * Single thread loads a tree of classes with signle loader. + * Single thread loads a tree of classes with single loader. * The test is deemed failed if loading attempt fails. * The test repeats until the given number of iterations, * or until EndOfMemoryError. diff --git a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree005/btree005.java b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree005/btree005.java index dff11c2e36590..42041c94fcf26 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree005/btree005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree005/btree005.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 @@ -30,7 +30,7 @@ * VM Testbase keywords: [stress, sysdict, stressopt, nonconcurrent] * VM Testbase readme: * DESCRIPTION - * Multiple threads load a tree of classes with signle loader. + * Multiple threads load a tree of classes with single loader. * The test is deemed failed if loading attempt fails. * The test repeats until the given number of iterations, * or until EndOfMemoryError. diff --git a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree008/btree008.java b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree008/btree008.java index 20cc937cfb82f..9861f3c051f09 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree008/btree008.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree008/btree008.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 @@ -30,7 +30,7 @@ * VM Testbase keywords: [stress, sysdict, stressopt, nonconcurrent] * VM Testbase readme: * DESCRIPTION - * Single thread loads a tree of classes with signle loader. + * Single thread loads a tree of classes with single loader. * Then, memory stress is induced to unload the classes. * The test is deemed failed if loading attempt fails; * or if the tested VM crashes. @@ -51,5 +51,6 @@ * -jarpath btree.jar${path.separator}fats.jar * -useSingleLoader * -stressHeap + * -t 1 */ diff --git a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree011/btree011.java b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree011/btree011.java index 8e1720831ecc1..507abcef2786f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree011/btree011.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/sysdict/vm/stress/btree/btree011/btree011.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 @@ -30,7 +30,7 @@ * VM Testbase keywords: [stress, sysdict, stressopt, nonconcurrent] * VM Testbase readme: * DESCRIPTION - * Multiple threads load a tree of classes with signle loader. + * Multiple threads load a tree of classes with single loader. * Then, memory stress is induced to unload the classes. * The test is deemed failed if loading attempt fails; * or if the tested VM crashes. From 2a37bae7af813ac47c67069c02d7b07e8237c5ac Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 21 Nov 2023 12:27:28 +0000 Subject: [PATCH 328/341] 8262186: Call X509KeyManager.chooseClientAlias once for all key types Reviewed-by: phh Backport-of: 3d657eb0a626e33995af5d5ddf12b26d06317962 --- .../sun/security/ssl/CertificateMessage.java | 30 +-- .../sun/security/ssl/CertificateRequest.java | 62 ++--- .../sun/security/ssl/X509Authentication.java | 220 +++++++++--------- .../SSLContextImpl/MultipleChooseAlias.java | 169 ++++++++++++++ 4 files changed, 310 insertions(+), 171 deletions(-) create mode 100644 test/jdk/sun/security/ssl/SSLContextImpl/MultipleChooseAlias.java diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java index d7fce6b1d5be4..5921b7cfca556 100644 --- a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java +++ b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1043,6 +1043,7 @@ private static SSLPossession choosePossession( } Collection checkedKeyTypes = new HashSet<>(); + List supportedKeyTypes = new ArrayList<>(); for (SignatureScheme ss : hc.peerRequestedCertSignSchemes) { if (checkedKeyTypes.contains(ss.keyAlgorithm)) { if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { @@ -1051,6 +1052,7 @@ private static SSLPossession choosePossession( } continue; } + checkedKeyTypes.add(ss.keyAlgorithm); // Don't select a signature scheme unless we will be able to // produce a CertificateVerify message later @@ -1064,36 +1066,28 @@ private static SSLPossession choosePossession( "Unable to produce CertificateVerify for " + "signature scheme: " + ss.name); } - checkedKeyTypes.add(ss.keyAlgorithm); continue; } - SSLAuthentication ka = X509Authentication.valueOf(ss); + X509Authentication ka = X509Authentication.valueOf(ss); if (ka == null) { if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { SSLLogger.warning( "Unsupported authentication scheme: " + ss.name); } - checkedKeyTypes.add(ss.keyAlgorithm); continue; } - - SSLPossession pos = ka.createPossession(hc); - if (pos == null) { - if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { - SSLLogger.warning( - "Unavailable authentication scheme: " + ss.name); - } - continue; - } - - return pos; + supportedKeyTypes.add(ss.keyAlgorithm); } - if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { - SSLLogger.warning("No available authentication scheme"); + SSLPossession pos = X509Authentication + .createPossession(hc, supportedKeyTypes.toArray(String[]::new)); + if (pos == null) { + if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { + SSLLogger.warning("No available authentication scheme"); + } } - return null; + return pos; } private byte[] onProduceCertificate(ClientHandshakeContext chc, diff --git a/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java b/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java index 4def03c6785ae..e13fcd6b9733d 100644 --- a/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java +++ b/src/java.base/share/classes/sun/security/ssl/CertificateRequest.java @@ -45,7 +45,6 @@ import sun.security.ssl.CipherSuite.KeyExchange; import sun.security.ssl.SSLHandshake.HandshakeMessage; import sun.security.ssl.X509Authentication.X509Possession; -import sun.security.ssl.X509Authentication.X509PossessionGenerator; /** * Pack of the CertificateRequest handshake message. @@ -726,10 +725,11 @@ public void consume(ConnectionContext context, chc.handshakeSession.setPeerSupportedSignatureAlgorithms(sss); chc.peerSupportedAuthorities = crm.getAuthorities(); - // For TLS 1.2, we need to use a combination of the CR message's - // allowed key types and the signature algorithms in order to - // find a certificate chain that has the right key and all certs - // using one or more of the allowed cert signature schemes. + // For TLS 1.2, we no longer use the certificate_types field + // from the CertificateRequest message to directly determine + // the SSLPossession. Instead, the choosePossession method + // will use the accepted signature schemes in the message to + // determine the set of acceptable certificate types to select from. SSLPossession pos = choosePossession(chc, crm); if (pos == null) { return; @@ -761,6 +761,7 @@ private static SSLPossession choosePossession(HandshakeContext hc, } Collection checkedKeyTypes = new HashSet<>(); + List supportedKeyTypes = new ArrayList<>(); for (SignatureScheme ss : hc.peerRequestedCertSignSchemes) { if (checkedKeyTypes.contains(ss.keyAlgorithm)) { if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { @@ -769,6 +770,7 @@ private static SSLPossession choosePossession(HandshakeContext hc, } continue; } + checkedKeyTypes.add(ss.keyAlgorithm); // Don't select a signature scheme unless we will be able to // produce a CertificateVerify message later @@ -782,7 +784,6 @@ private static SSLPossession choosePossession(HandshakeContext hc, "Unable to produce CertificateVerify for " + "signature scheme: " + ss.name); } - checkedKeyTypes.add(ss.keyAlgorithm); continue; } @@ -792,45 +793,32 @@ private static SSLPossession choosePossession(HandshakeContext hc, SSLLogger.warning( "Unsupported authentication scheme: " + ss.name); } - checkedKeyTypes.add(ss.keyAlgorithm); continue; } else { - // Any auth object will have a possession generator and - // we need to make sure the key types for that generator - // share at least one common algorithm with the CR's - // allowed key types. - if (ka.possessionGenerator instanceof - X509PossessionGenerator xpg) { - if (Collections.disjoint(crKeyTypes, - Arrays.asList(xpg.keyTypes))) { - if (SSLLogger.isOn && - SSLLogger.isOn("ssl,handshake")) { - SSLLogger.warning( - "Unsupported authentication scheme: " + - ss.name); - } - checkedKeyTypes.add(ss.keyAlgorithm); - continue; + // Any auth object will have a set of allowed key types. + // This set should share at least one common algorithm with + // the CR's allowed key types. + if (Collections.disjoint(crKeyTypes, + Arrays.asList(ka.keyTypes))) { + if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { + SSLLogger.warning( + "Unsupported authentication scheme: " + + ss.name); } + continue; } } - - SSLPossession pos = ka.createPossession(hc); - if (pos == null) { - if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { - SSLLogger.warning( - "Unavailable authentication scheme: " + ss.name); - } - continue; - } - - return pos; + supportedKeyTypes.add(ss.keyAlgorithm); } - if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { - SSLLogger.warning("No available authentication scheme"); + SSLPossession pos = X509Authentication + .createPossession(hc, supportedKeyTypes.toArray(String[]::new)); + if (pos == null) { + if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { + SSLLogger.warning("No available authentication scheme"); + } } - return null; + return pos; } } diff --git a/src/java.base/share/classes/sun/security/ssl/X509Authentication.java b/src/java.base/share/classes/sun/security/ssl/X509Authentication.java index cd41ab506fd94..ba1396f017b16 100644 --- a/src/java.base/share/classes/sun/security/ssl/X509Authentication.java +++ b/src/java.base/share/classes/sun/security/ssl/X509Authentication.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. * 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,52 +35,46 @@ import java.security.spec.ECParameterSpec; import java.security.spec.NamedParameterSpec; import java.util.AbstractMap.SimpleImmutableEntry; +import java.util.Arrays; import java.util.Map; -import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLSocket; import javax.net.ssl.X509ExtendedKeyManager; + import sun.security.ssl.SupportedGroupsExtension.SupportedGroups; enum X509Authentication implements SSLAuthentication { // Require rsaEncryption public key - RSA ("RSA", new X509PossessionGenerator( - new String[]{"RSA"})), + RSA ("RSA", "RSA"), // Require RSASSA-PSS public key - RSASSA_PSS ("RSASSA-PSS", new X509PossessionGenerator( - new String[] {"RSASSA-PSS"})), + RSASSA_PSS ("RSASSA-PSS", "RSASSA-PSS"), // Require rsaEncryption or RSASSA-PSS public key // // Note that this is a specifical scheme for TLS 1.2. (EC)DHE_RSA cipher // suites of TLS 1.2 can use either rsaEncryption or RSASSA-PSS public // key for authentication and handshake. - RSA_OR_PSS ("RSA_OR_PSS", new X509PossessionGenerator( - new String[] {"RSA", "RSASSA-PSS"})), + RSA_OR_PSS ("RSA_OR_PSS", "RSA", "RSASSA-PSS"), // Require DSA public key - DSA ("DSA", new X509PossessionGenerator( - new String[] {"DSA"})), + DSA ("DSA", "DSA"), // Require EC public key - EC ("EC", new X509PossessionGenerator( - new String[] {"EC"})), + EC ("EC", "EC"), // Edwards-Curve key - EDDSA ("EdDSA", new X509PossessionGenerator( - new String[] {"EdDSA"})); + EDDSA ("EdDSA", "EdDSA"); - final String keyType; - final SSLPossessionGenerator possessionGenerator; + final String keyAlgorithm; + final String[] keyTypes; - private X509Authentication(String keyType, - SSLPossessionGenerator possessionGenerator) { - this.keyType = keyType; - this.possessionGenerator = possessionGenerator; + private X509Authentication(String keyAlgorithm, + String... keyTypes) { + this.keyAlgorithm = keyAlgorithm; + this.keyTypes = keyTypes; } static X509Authentication valueOf(SignatureScheme signatureScheme) { for (X509Authentication au : X509Authentication.values()) { - if (au.keyType.equals(signatureScheme.keyAlgorithm)) { + if (au.keyAlgorithm.equals(signatureScheme.keyAlgorithm)) { return au; } } @@ -90,7 +84,7 @@ static X509Authentication valueOf(SignatureScheme signatureScheme) { @Override public SSLPossession createPossession(HandshakeContext handshakeContext) { - return possessionGenerator.createPossession(handshakeContext); + return X509Authentication.createPossession(handshakeContext, keyTypes); } @Override @@ -194,116 +188,109 @@ static final class X509Credentials implements SSLCredentials { } } - static final class X509PossessionGenerator - implements SSLPossessionGenerator { - final String[] keyTypes; + public static SSLPossession createPossession( + HandshakeContext context, String[] keyTypes) { + if (context.sslConfig.isClientMode) { + return createClientPossession( + (ClientHandshakeContext) context, keyTypes); + } else { + return createServerPossession( + (ServerHandshakeContext) context, keyTypes); + } + } - private X509PossessionGenerator(String[] keyTypes) { - this.keyTypes = keyTypes; + // Used by TLS 1.2 and TLS 1.3. + private static SSLPossession createClientPossession( + ClientHandshakeContext chc, String[] keyTypes) { + X509ExtendedKeyManager km = chc.sslContext.getX509KeyManager(); + String clientAlias = null; + if (chc.conContext.transport instanceof SSLSocketImpl socket) { + clientAlias = km.chooseClientAlias( + keyTypes, + chc.peerSupportedAuthorities == null ? null : + chc.peerSupportedAuthorities.clone(), + socket); + } else if (chc.conContext.transport instanceof SSLEngineImpl engine) { + clientAlias = km.chooseEngineClientAlias( + keyTypes, + chc.peerSupportedAuthorities == null ? null : + chc.peerSupportedAuthorities.clone(), + engine); } - @Override - public SSLPossession createPossession(HandshakeContext context) { - if (context.sslConfig.isClientMode) { - for (String keyType : keyTypes) { - SSLPossession poss = createClientPossession( - (ClientHandshakeContext)context, keyType); - if (poss != null) { - return poss; - } - } - } else { - for (String keyType : keyTypes) { - SSLPossession poss = createServerPossession( - (ServerHandshakeContext)context, keyType); - if (poss != null) { - return poss; - } - } + if (clientAlias == null) { + if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { + SSLLogger.finest("No X.509 cert selected for " + + Arrays.toString(keyTypes)); } - return null; } - // Used by TLS 1.2 and TLS 1.3. - private SSLPossession createClientPossession( - ClientHandshakeContext chc, String keyType) { - X509ExtendedKeyManager km = chc.sslContext.getX509KeyManager(); - String clientAlias = null; - if (chc.conContext.transport instanceof SSLSocketImpl) { - clientAlias = km.chooseClientAlias( - new String[] { keyType }, - chc.peerSupportedAuthorities == null ? null : - chc.peerSupportedAuthorities.clone(), - (SSLSocket)chc.conContext.transport); - } else if (chc.conContext.transport instanceof SSLEngineImpl) { - clientAlias = km.chooseEngineClientAlias( - new String[] { keyType }, - chc.peerSupportedAuthorities == null ? null : - chc.peerSupportedAuthorities.clone(), - (SSLEngine)chc.conContext.transport); - } - - if (clientAlias == null) { - if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { - SSLLogger.finest("No X.509 cert selected for " + keyType); - } - return null; - } - - PrivateKey clientPrivateKey = km.getPrivateKey(clientAlias); - if (clientPrivateKey == null) { - if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { - SSLLogger.finest( - clientAlias + " is not a private key entry"); - } - return null; + PrivateKey clientPrivateKey = km.getPrivateKey(clientAlias); + if (clientPrivateKey == null) { + if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { + SSLLogger.finest( + clientAlias + " is not a private key entry"); } + return null; + } - X509Certificate[] clientCerts = km.getCertificateChain(clientAlias); - if ((clientCerts == null) || (clientCerts.length == 0)) { - if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { - SSLLogger.finest(clientAlias + + X509Certificate[] clientCerts = km.getCertificateChain(clientAlias); + if ((clientCerts == null) || (clientCerts.length == 0)) { + if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { + SSLLogger.finest(clientAlias + " is a private key entry with no cert chain stored"); - } - return null; } + return null; + } - PublicKey clientPublicKey = clientCerts[0].getPublicKey(); - if ((!clientPrivateKey.getAlgorithm().equals(keyType)) - || (!clientPublicKey.getAlgorithm().equals(keyType))) { - if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { - SSLLogger.fine( - clientAlias + " private or public key is not of " + - keyType + " algorithm"); - } - return null; + String privateKeyAlgorithm = clientPrivateKey.getAlgorithm(); + if (!Arrays.asList(keyTypes).contains(privateKeyAlgorithm)) { + if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { + SSLLogger.fine( + clientAlias + " private key algorithm " + + privateKeyAlgorithm + " not in request list"); } + return null; + } - return new X509Possession(clientPrivateKey, clientCerts); + String publicKeyAlgorithm = clientCerts[0].getPublicKey().getAlgorithm(); + if (!privateKeyAlgorithm.equals(publicKeyAlgorithm)) { + if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { + SSLLogger.fine( + clientAlias + " private or public key is not of " + + "same algorithm: " + + privateKeyAlgorithm + " vs " + + publicKeyAlgorithm); + } + return null; } - private SSLPossession createServerPossession( - ServerHandshakeContext shc, String keyType) { - X509ExtendedKeyManager km = shc.sslContext.getX509KeyManager(); - String serverAlias = null; - if (shc.conContext.transport instanceof SSLSocketImpl) { + return new X509Possession(clientPrivateKey, clientCerts); + } + + private static SSLPossession createServerPossession( + ServerHandshakeContext shc, String[] keyTypes) { + X509ExtendedKeyManager km = shc.sslContext.getX509KeyManager(); + String serverAlias = null; + for (String keyType : keyTypes) { + if (shc.conContext.transport instanceof SSLSocketImpl socket) { serverAlias = km.chooseServerAlias(keyType, shc.peerSupportedAuthorities == null ? null : shc.peerSupportedAuthorities.clone(), - (SSLSocket)shc.conContext.transport); - } else if (shc.conContext.transport instanceof SSLEngineImpl) { + socket); + } else if (shc.conContext.transport instanceof SSLEngineImpl engine) { serverAlias = km.chooseEngineServerAlias(keyType, shc.peerSupportedAuthorities == null ? null : shc.peerSupportedAuthorities.clone(), - (SSLEngine)shc.conContext.transport); + engine); } if (serverAlias == null) { if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { SSLLogger.finest("No X.509 cert selected for " + keyType); } - return null; + continue; } PrivateKey serverPrivateKey = km.getPrivateKey(serverAlias); @@ -312,7 +299,7 @@ private SSLPossession createServerPossession( SSLLogger.finest( serverAlias + " is not a private key entry"); } - return null; + continue; } X509Certificate[] serverCerts = km.getCertificateChain(serverAlias); @@ -321,7 +308,7 @@ private SSLPossession createServerPossession( SSLLogger.finest( serverAlias + " is not a certificate entry"); } - return null; + continue; } PublicKey serverPublicKey = serverCerts[0].getPublicKey(); @@ -330,9 +317,9 @@ private SSLPossession createServerPossession( if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { SSLLogger.fine( serverAlias + " private or public key is not of " + - keyType + " algorithm"); + keyType + " algorithm"); } - return null; + continue; } // For TLS 1.2 and prior versions, the public key of a EC cert @@ -344,9 +331,9 @@ private SSLPossession createServerPossession( if (!(serverPublicKey instanceof ECPublicKey)) { if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { SSLLogger.warning(serverAlias + - " public key is not an instance of ECPublicKey"); + " public key is not an instance of ECPublicKey"); } - return null; + continue; } // For ECC certs, check whether we support the EC domain @@ -354,24 +341,25 @@ private SSLPossession createServerPossession( // ClientHello extension, check against that too for // TLS 1.2 and prior versions. ECParameterSpec params = - ((ECPublicKey)serverPublicKey).getParams(); + ((ECPublicKey) serverPublicKey).getParams(); NamedGroup namedGroup = NamedGroup.valueOf(params); if ((namedGroup == null) || (!SupportedGroups.isSupported(namedGroup)) || ((shc.clientRequestedNamedGroups != null) && - !shc.clientRequestedNamedGroups.contains(namedGroup))) { + !shc.clientRequestedNamedGroups.contains(namedGroup))) { if (SSLLogger.isOn && SSLLogger.isOn("ssl")) { SSLLogger.warning( - "Unsupported named group (" + namedGroup + - ") used in the " + serverAlias + " certificate"); + "Unsupported named group (" + namedGroup + + ") used in the " + serverAlias + " certificate"); } - return null; + continue; } } return new X509Possession(serverPrivateKey, serverCerts); } + return null; } } diff --git a/test/jdk/sun/security/ssl/SSLContextImpl/MultipleChooseAlias.java b/test/jdk/sun/security/ssl/SSLContextImpl/MultipleChooseAlias.java new file mode 100644 index 0000000000000..5ba949d134d95 --- /dev/null +++ b/test/jdk/sun/security/ssl/SSLContextImpl/MultipleChooseAlias.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * 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. + */ + +// +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. +// + +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.KeyManagerFactorySpi; +import javax.net.ssl.ManagerFactoryParameters; +import javax.net.ssl.SSLServerSocket; +import javax.net.ssl.X509KeyManager; +import java.net.Socket; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.Principal; +import java.security.PrivateKey; +import java.security.Provider; +import java.security.Security; +import java.security.UnrecoverableKeyException; +import java.security.cert.X509Certificate; +import java.util.Arrays; + +/* + * @test + * @bug 8262186 + * @summary Callback semantics of the method X509KeyManager.chooseClientAlias(...) + * @library /javax/net/ssl/templates + * @modules java.base/sun.security.ssl:+open + * java.base/javax.net.ssl:+open + * @run main/othervm MultipleChooseAlias PKIX + * @run main/othervm MultipleChooseAlias SunX509 + */ +public class MultipleChooseAlias extends SSLSocketTemplate { + + static volatile int numOfCalls = 0; + static String kmfAlgorithm = null; + + @Override + protected void configureServerSocket(SSLServerSocket socket) { + socket.setNeedClientAuth(true); + } + + @Override + protected ContextParameters getClientContextParameters() { + return new ContextParameters("TLS", "PKIX", "Mine"); + } + + public static void main(String[] args) throws Exception { + kmfAlgorithm = args[0]; + Security.addProvider(new MyProvider()); + try { + new MultipleChooseAlias().run(); + } catch (Exception e) { + // expected + } + if (numOfCalls != 1) { + throw new RuntimeException("Too many times " + numOfCalls); + } + } + + static class MyProvider extends Provider { + public MyProvider() { + super("Mine", "1", "many many things"); + put("KeyManagerFactory.Mine", "MultipleChooseAlias$MyKMF"); + } + } + + // This KeyManagerFactory impl returns key managers + // wrapped in MyKM + public static class MyKMF extends KeyManagerFactorySpi { + KeyManagerFactory fac; + + public MyKMF() { + try { + fac = KeyManagerFactory.getInstance(kmfAlgorithm); + } catch (Exception e) { + throw new AssertionError(e); + } + } + + @Override + protected void engineInit(KeyStore ks, char[] password) + throws KeyStoreException, NoSuchAlgorithmException, + UnrecoverableKeyException { + fac.init(ks, password); + } + + @Override + protected void engineInit(ManagerFactoryParameters spec) + throws InvalidAlgorithmParameterException { + fac.init(spec); + } + + @Override + protected KeyManager[] engineGetKeyManagers() { + KeyManager[] result = fac.getKeyManagers(); + for (int i = 0; i < result.length; i++) { + result[i] = new MyKM((X509KeyManager)result[i]); + } + return result; + } + } + + // This KeyManager remembers how many times chooseClientAlias is called. + static class MyKM implements X509KeyManager { + + X509KeyManager km; + + MyKM(X509KeyManager km) { + this.km = km; + } + + public String[] getClientAliases(String keyType, Principal[] issuers) { + return km.getClientAliases(keyType, issuers); + } + + public String chooseClientAlias(String[] keyType, Principal[] issuers, + Socket socket) { + System.out.println("chooseClientAlias called on " + + Arrays.toString(keyType)); + numOfCalls++; + return null; // so it will try all key types and finally fails + } + + public String[] getServerAliases(String keyType, Principal[] issuers) { + return getServerAliases(keyType, issuers); + } + + public String chooseServerAlias(String keyType, Principal[] issuers, + Socket socket) { + return km.chooseServerAlias(keyType, issuers, socket); + } + + public X509Certificate[] getCertificateChain(String alias) { + return km.getCertificateChain(alias); + } + + public PrivateKey getPrivateKey(String alias) { + return km.getPrivateKey(alias); + } + } +} From 40c29f7d80b5b67718ce071722bd7cfaecdf9495 Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Tue, 21 Nov 2023 13:35:01 +0000 Subject: [PATCH 329/341] 8279856: Parallel: Use PreservedMarks to record promotion-failed objects Backport-of: 16ec47d5e5bf129fc0910358464ab62bf6ce7ed8 --- src/hotspot/share/gc/parallel/psPromotionManager.cpp | 5 ++++- src/hotspot/share/gc/parallel/psScavenge.cpp | 10 +--------- src/hotspot/share/gc/shared/preservedMarks.cpp | 6 ++++-- src/hotspot/share/gc/shared/preservedMarks.hpp | 1 + src/hotspot/share/gc/shared/preservedMarks.inline.hpp | 6 ++++++ 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/hotspot/share/gc/parallel/psPromotionManager.cpp b/src/hotspot/share/gc/parallel/psPromotionManager.cpp index c5f321f54554a..a99adbd7dae91 100644 --- a/src/hotspot/share/gc/parallel/psPromotionManager.cpp +++ b/src/hotspot/share/gc/parallel/psPromotionManager.cpp @@ -360,7 +360,10 @@ oop PSPromotionManager::oop_promotion_failed(oop obj, markWord obj_mark) { push_contents(obj); - _preserved_marks->push_if_necessary(obj, obj_mark); + // Save the markWord of promotion-failed objs in _preserved_marks for later + // restoration. This way we don't have to walk the young-gen to locate + // these promotion-failed objs. + _preserved_marks->push_always(obj, obj_mark); } else { // We lost, someone else "owns" this object guarantee(obj->is_forwarded(), "Object must be forwarded if the cas failed."); diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp index 20d5caaa84deb..3f41b6f5064de 100644 --- a/src/hotspot/share/gc/parallel/psScavenge.cpp +++ b/src/hotspot/share/gc/parallel/psScavenge.cpp @@ -705,19 +705,11 @@ bool PSScavenge::invoke_no_policy() { return !promotion_failure_occurred; } -// This method iterates over all objects in the young generation, -// removing all forwarding references. It then restores any preserved marks. void PSScavenge::clean_up_failed_promotion() { - ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); - PSYoungGen* young_gen = heap->young_gen(); - - RemoveForwardedPointerClosure remove_fwd_ptr_closure; - young_gen->object_iterate(&remove_fwd_ptr_closure); - PSPromotionManager::restore_preserved_marks(); // Reset the PromotionFailureALot counters. - NOT_PRODUCT(heap->reset_promotion_should_fail();) + NOT_PRODUCT(ParallelScavengeHeap::heap()->reset_promotion_should_fail();) } bool PSScavenge::should_attempt_scavenge() { diff --git a/src/hotspot/share/gc/shared/preservedMarks.cpp b/src/hotspot/share/gc/shared/preservedMarks.cpp index 8dfd7cf0ff426..650c752c3f6dd 100644 --- a/src/hotspot/share/gc/shared/preservedMarks.cpp +++ b/src/hotspot/share/gc/shared/preservedMarks.cpp @@ -124,8 +124,10 @@ class RestorePreservedMarksTask : public AbstractGangTask { ~RestorePreservedMarksTask() { assert(_total_size == _total_size_before, "total_size = %zu before = %zu", _total_size, _total_size_before); - - log_trace(gc)("Restored %zu marks", _total_size); + size_t mem_size = _total_size * (sizeof(oop) + sizeof(markWord)); + log_trace(gc)("Restored %zu marks, occupying %zu %s", _total_size, + byte_size_in_proper_unit(mem_size), + proper_unit_for_byte_size(mem_size)); } }; diff --git a/src/hotspot/share/gc/shared/preservedMarks.hpp b/src/hotspot/share/gc/shared/preservedMarks.hpp index d04d22ef3c91f..921628acdb2a9 100644 --- a/src/hotspot/share/gc/shared/preservedMarks.hpp +++ b/src/hotspot/share/gc/shared/preservedMarks.hpp @@ -58,6 +58,7 @@ class PreservedMarks { size_t size() const { return _stack.size(); } inline void push(oop obj, markWord m); inline void push_if_necessary(oop obj, markWord m); + inline void push_always(oop obj, markWord m); // Iterate over the stack, restore all preserved marks, and // reclaim the memory taken up by the stack segments. void restore(); diff --git a/src/hotspot/share/gc/shared/preservedMarks.inline.hpp b/src/hotspot/share/gc/shared/preservedMarks.inline.hpp index 44bb26f87e66f..1eed29ef72f54 100644 --- a/src/hotspot/share/gc/shared/preservedMarks.inline.hpp +++ b/src/hotspot/share/gc/shared/preservedMarks.inline.hpp @@ -47,6 +47,12 @@ inline void PreservedMarks::push_if_necessary(oop obj, markWord m) { } } +inline void PreservedMarks::push_always(oop obj, markWord m) { + assert(!m.is_marked(), "precondition"); + OopAndMarkWord elem(obj, m); + _stack.push(elem); +} + inline void PreservedMarks::init_forwarded_mark(oop obj) { obj->init_mark(); } From 2da7aeb22d9597fe2db33c04b9f3f706539a3d45 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 22 Nov 2023 08:17:53 +0000 Subject: [PATCH 330/341] 8310656: RISC-V: __builtin___clear_cache can fail silently. Reviewed-by: vkempik, rehn Backport-of: 5f1d762750a0d4c20da5b23d54f922dbb5cbbe34 --- src/hotspot/cpu/riscv/icache_riscv.cpp | 19 +++-- .../os_cpu/linux_riscv/riscv_flush_icache.cpp | 77 +++++++++++++++++++ .../os_cpu/linux_riscv/riscv_flush_icache.hpp | 39 ++++++++++ 3 files changed, 130 insertions(+), 5 deletions(-) create mode 100644 src/hotspot/os_cpu/linux_riscv/riscv_flush_icache.cpp create mode 100644 src/hotspot/os_cpu/linux_riscv/riscv_flush_icache.hpp diff --git a/src/hotspot/cpu/riscv/icache_riscv.cpp b/src/hotspot/cpu/riscv/icache_riscv.cpp index e6c2586e5bde1..d615dcfb9e9ae 100644 --- a/src/hotspot/cpu/riscv/icache_riscv.cpp +++ b/src/hotspot/cpu/riscv/icache_riscv.cpp @@ -1,6 +1,7 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2023, Rivos Inc. All rights reserved. * 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 +26,8 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" +#include "riscv_flush_icache.hpp" +#include "runtime/java.hpp" #include "runtime/icache.hpp" #define __ _masm-> @@ -33,16 +36,22 @@ static int icache_flush(address addr, int lines, int magic) { // To make a store to instruction memory visible to all RISC-V harts, // the writing hart has to execute a data FENCE before requesting that // all remote RISC-V harts execute a FENCE.I. - // - // No sush assurance is defined at the interface level of the builtin - // method, and so we should make sure it works. + + // We need to make sure stores happens before the I/D cache synchronization. __asm__ volatile("fence rw, rw" : : : "memory"); - __builtin___clear_cache(addr, addr + (lines << ICache::log2_line_size)); + RiscvFlushIcache::flush((uintptr_t)addr, ((uintptr_t)lines) << ICache::log2_line_size); + return magic; } void ICacheStubGenerator::generate_icache_flush(ICache::flush_icache_stub_t* flush_icache_stub) { + // Only riscv_flush_icache is supported as I-cache synchronization. + // We must make sure the VM can execute such without error. + if (!RiscvFlushIcache::test()) { + vm_exit_during_initialization("Unable to synchronize I-cache"); + } + address start = (address)icache_flush; *flush_icache_stub = (ICache::flush_icache_stub_t)start; diff --git a/src/hotspot/os_cpu/linux_riscv/riscv_flush_icache.cpp b/src/hotspot/os_cpu/linux_riscv/riscv_flush_icache.cpp new file mode 100644 index 0000000000000..89ca018879172 --- /dev/null +++ b/src/hotspot/os_cpu/linux_riscv/riscv_flush_icache.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, Rivos Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "logging/log.hpp" +#include "riscv_flush_icache.hpp" +#include "runtime/os.hpp" +#include "runtime/vm_version.hpp" +#include "utilities/debug.hpp" + +#include +#include + +#define check_with_errno(check_type, cond, msg) \ + do { \ + int err = errno; \ + check_type(cond, "%s; error='%s' (errno=%s)", msg, os::strerror(err), \ + os::errno_name(err)); \ +} while (false) + +#define assert_with_errno(cond, msg) check_with_errno(assert, cond, msg) +#define guarantee_with_errno(cond, msg) check_with_errno(guarantee, cond, msg) + +#ifndef NR_riscv_flush_icache +#ifndef NR_arch_specific_syscall +#define NR_arch_specific_syscall 244 +#endif +#define NR_riscv_flush_icache (NR_arch_specific_syscall + 15) +#endif + +#define SYS_RISCV_FLUSH_ICACHE_LOCAL 1UL +#define SYS_RISCV_FLUSH_ICACHE_ALL 0UL + +static long sys_flush_icache(uintptr_t start, uintptr_t end , uintptr_t flags) { + return syscall(NR_riscv_flush_icache, start, end, flags); +} + +bool RiscvFlushIcache::test() { + alignas(64) char memory[64]; + long ret = sys_flush_icache((uintptr_t)&memory[0], + (uintptr_t)&memory[sizeof(memory) - 1], + SYS_RISCV_FLUSH_ICACHE_ALL); + if (ret == 0) { + return true; + } + int err = errno; \ + log_error(os)("Syscall: RISCV_FLUSH_ICACHE not available; error='%s' (errno=%s)", + os::strerror(err), os::errno_name(err)); + return false; +} + +void RiscvFlushIcache::flush(uintptr_t start, uintptr_t end) { + long ret = sys_flush_icache(start, end, SYS_RISCV_FLUSH_ICACHE_ALL); + guarantee_with_errno(ret == 0, "riscv_flush_icache failed"); +} diff --git a/src/hotspot/os_cpu/linux_riscv/riscv_flush_icache.hpp b/src/hotspot/os_cpu/linux_riscv/riscv_flush_icache.hpp new file mode 100644 index 0000000000000..34742c173ab21 --- /dev/null +++ b/src/hotspot/os_cpu/linux_riscv/riscv_flush_icache.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, Rivos Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef OS_LINUX_RISCV_FLUSH_ICACHE_LINUX_HPP +#define OS_LINUX_RISCV_FLUSH_ICACHE_LINUX_HPP + +#include "memory/allStatic.hpp" +#include "runtime/vm_version.hpp" +#include "utilities/growableArray.hpp" + +class RiscvFlushIcache: public AllStatic { + public: + static bool test(); + static void flush(uintptr_t start, uintptr_t end); +}; + +#endif // OS_LINUX_RISCV_FLUSH_ICACHE_LINUX_HPP From 0f2da83f79bdccff6dfb823238f971d6eb495ab8 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Wed, 22 Nov 2023 11:59:23 +0000 Subject: [PATCH 331/341] 8316746: Top of lock-stack does not match the unlocked object Reviewed-by: rrich Backport-of: 7d8adfa855e51a90c2f125fc20a06f9a488e6248 --- src/hotspot/cpu/ppc/frame_ppc.inline.hpp | 1 - src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp | 2 +- src/hotspot/cpu/ppc/templateTable_ppc_64.cpp | 140 ++++++++---------- .../jtreg/compiler/locks/TestUnlockOSR.java | 56 +++++++ 4 files changed, 117 insertions(+), 82 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/locks/TestUnlockOSR.java diff --git a/src/hotspot/cpu/ppc/frame_ppc.inline.hpp b/src/hotspot/cpu/ppc/frame_ppc.inline.hpp index 239db8224c0c3..876ad046a0cd5 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.inline.hpp +++ b/src/hotspot/cpu/ppc/frame_ppc.inline.hpp @@ -143,7 +143,6 @@ inline intptr_t* frame::interpreter_frame_mdp_addr() const { return (intptr_t*) &(get_ijava_state()->mdx); } -// Pointer beyond the "oldest/deepest" BasicObjectLock on stack. inline BasicObjectLock* frame::interpreter_frame_monitor_end() const { return (BasicObjectLock*) get_ijava_state()->monitors; } diff --git a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp index 70466fdf3c33f..fb07b3f4465f5 100644 --- a/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp @@ -1933,7 +1933,7 @@ void InterpreterMacroAssembler::profile_parameters_type(Register tmp1, Register } } -// Add a InterpMonitorElem to stack (see frame_sparc.hpp). +// Add a monitor (see frame_ppc.hpp). void InterpreterMacroAssembler::add_monitor_to_stack(bool stack_is_empty, Register Rtemp1, Register Rtemp2) { // Very-local scratch registers. diff --git a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp index 2210e05a410f9..13c13fe843d15 100644 --- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp @@ -4045,90 +4045,78 @@ void TemplateTable::athrow() { // at next monitor exit. void TemplateTable::monitorenter() { transition(atos, vtos); - __ verify_oop(R17_tos); - Register Rcurrent_monitor = R11_scratch1, - Rcurrent_obj = R12_scratch2, + Register Rcurrent_monitor = R3_ARG1, + Rcurrent_obj = R4_ARG2, Robj_to_lock = R17_tos, - Rscratch1 = R3_ARG1, - Rscratch2 = R4_ARG2, - Rscratch3 = R5_ARG3, - Rcurrent_obj_addr = R6_ARG4; + Rscratch1 = R11_scratch1, + Rscratch2 = R12_scratch2, + Rbot = R5_ARG3, + Rfree_slot = R6_ARG4; + + Label Lfound, Lallocate_new; + + __ ld(Rscratch1, _abi0(callers_sp), R1_SP); // load FP + __ li(Rfree_slot, 0); // Points to free slot or null. + + // Set up search loop - start with topmost monitor. + __ mr(Rcurrent_monitor, R26_monitor); + __ addi(Rbot, Rscratch1, -frame::ijava_state_size); // ------------------------------------------------------------------------------ // Null pointer exception. - __ null_check_throw(Robj_to_lock, -1, R11_scratch1); + __ null_check_throw(Robj_to_lock, -1, Rscratch1); - // Try to acquire a lock on the object. - // Repeat until succeeded (i.e., until monitorenter returns true). + // Check if any slot is present => short cut to allocation if not. + __ cmpld(CCR0, Rcurrent_monitor, Rbot); + __ beq(CCR0, Lallocate_new); // ------------------------------------------------------------------------------ // Find a free slot in the monitor block. - Label Lfound, Lexit, Lallocate_new; - ConditionRegister found_free_slot = CCR0, - found_same_obj = CCR1, - reached_limit = CCR6; + // Note: The order of the monitors is important for C2 OSR which derives the + // unlock order from it (see comments for interpreter_frame_monitor_*). { - Label Lloop; - Register Rlimit = Rcurrent_monitor; - - // Set up search loop - start with topmost monitor. - __ add(Rcurrent_obj_addr, BasicObjectLock::obj_offset_in_bytes(), R26_monitor); + Label Lloop, LnotFree, Lexit; - __ ld(Rlimit, 0, R1_SP); - __ addi(Rlimit, Rlimit, - (frame::ijava_state_size + frame::interpreter_frame_monitor_size_in_bytes() - BasicObjectLock::obj_offset_in_bytes())); // Monitor base + __ bind(Lloop); + __ ld(Rcurrent_obj, BasicObjectLock::obj_offset_in_bytes(), Rcurrent_monitor); + // Exit if current entry is for same object; this guarantees, that new monitor + // used for recursive lock is above the older one. + __ cmpd(CCR0, Rcurrent_obj, Robj_to_lock); + __ beq(CCR0, Lexit); // recursive locking - // Check if any slot is present => short cut to allocation if not. - __ cmpld(reached_limit, Rcurrent_obj_addr, Rlimit); - __ bgt(reached_limit, Lallocate_new); + __ cmpdi(CCR0, Rcurrent_obj, 0); + __ bne(CCR0, LnotFree); + __ mr(Rfree_slot, Rcurrent_monitor); // remember free slot closest to the bottom + __ bind(LnotFree); - // Pre-load topmost slot. - __ ld(Rcurrent_obj, 0, Rcurrent_obj_addr); - __ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize); - // The search loop. - __ bind(Lloop); - // Found free slot? - __ cmpdi(found_free_slot, Rcurrent_obj, 0); - // Is this entry for same obj? If so, stop the search and take the found - // free slot or allocate a new one to enable recursive locking. - __ cmpd(found_same_obj, Rcurrent_obj, Robj_to_lock); - __ cmpld(reached_limit, Rcurrent_obj_addr, Rlimit); - __ beq(found_free_slot, Lexit); - __ beq(found_same_obj, Lallocate_new); - __ bgt(reached_limit, Lallocate_new); - // Check if last allocated BasicLockObj reached. - __ ld(Rcurrent_obj, 0, Rcurrent_obj_addr); - __ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize); - // Next iteration if unchecked BasicObjectLocks exist on the stack. - __ b(Lloop); + __ addi(Rcurrent_monitor, Rcurrent_monitor, frame::interpreter_frame_monitor_size_in_bytes()); + __ cmpld(CCR0, Rcurrent_monitor, Rbot); + __ bne(CCR0, Lloop); + __ bind(Lexit); } // ------------------------------------------------------------------------------ // Check if we found a free slot. - __ bind(Lexit); - - __ addi(Rcurrent_monitor, Rcurrent_obj_addr, -(frame::interpreter_frame_monitor_size() * wordSize) - BasicObjectLock::obj_offset_in_bytes()); - __ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, - frame::interpreter_frame_monitor_size() * wordSize); - __ b(Lfound); + __ cmpdi(CCR0, Rfree_slot, 0); + __ bne(CCR0, Lfound); // We didn't find a free BasicObjLock => allocate one. - __ align(32, 12); __ bind(Lallocate_new); __ add_monitor_to_stack(false, Rscratch1, Rscratch2); - __ mr(Rcurrent_monitor, R26_monitor); - __ addi(Rcurrent_obj_addr, R26_monitor, BasicObjectLock::obj_offset_in_bytes()); + __ mr(Rfree_slot, R26_monitor); // ------------------------------------------------------------------------------ // We now have a slot to lock. __ bind(Lfound); // Increment bcp to point to the next bytecode, so exception handling for async. exceptions work correctly. - // The object has already been poped from the stack, so the expression stack looks correct. + // The object has already been popped from the stack, so the expression stack looks correct. __ addi(R14_bcp, R14_bcp, 1); - __ std(Robj_to_lock, 0, Rcurrent_obj_addr); - __ lock_object(Rcurrent_monitor, Robj_to_lock); + __ std(Robj_to_lock, BasicObjectLock::obj_offset_in_bytes(), Rfree_slot); + __ lock_object(Rfree_slot, Robj_to_lock); // Check if there's enough space on the stack for the monitors after locking. // This emits a single store. @@ -4142,46 +4130,40 @@ void TemplateTable::monitorexit() { transition(atos, vtos); __ verify_oop(R17_tos); - Register Rcurrent_monitor = R11_scratch1, - Rcurrent_obj = R12_scratch2, + Register Rcurrent_monitor = R3_ARG1, + Rcurrent_obj = R4_ARG2, Robj_to_lock = R17_tos, - Rcurrent_obj_addr = R3_ARG1, - Rlimit = R4_ARG2; + Rscratch = R11_scratch1, + Rbot = R12_scratch2; + Label Lfound, Lillegal_monitor_state; - // Check corner case: unbalanced monitorEnter / Exit. - __ ld(Rlimit, 0, R1_SP); - __ addi(Rlimit, Rlimit, - (frame::ijava_state_size + frame::interpreter_frame_monitor_size_in_bytes())); // Monitor base + __ ld(Rscratch, _abi0(callers_sp), R1_SP); // load FP + + // Set up search loop - start with topmost monitor. + __ mr(Rcurrent_monitor, R26_monitor); + __ addi(Rbot, Rscratch, -frame::ijava_state_size); // Null pointer check. - __ null_check_throw(Robj_to_lock, -1, R11_scratch1); + __ null_check_throw(Robj_to_lock, -1, Rscratch); - __ cmpld(CCR0, R26_monitor, Rlimit); - __ bgt(CCR0, Lillegal_monitor_state); + // Check corner case: unbalanced monitorEnter / Exit. + __ cmpld(CCR0, Rcurrent_monitor, Rbot); + __ beq(CCR0, Lillegal_monitor_state); // Find the corresponding slot in the monitors stack section. { Label Lloop; - // Start with topmost monitor. - __ addi(Rcurrent_obj_addr, R26_monitor, BasicObjectLock::obj_offset_in_bytes()); - __ addi(Rlimit, Rlimit, BasicObjectLock::obj_offset_in_bytes()); - __ ld(Rcurrent_obj, 0, Rcurrent_obj_addr); - __ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize); - __ bind(Lloop); + __ ld(Rcurrent_obj, BasicObjectLock::obj_offset_in_bytes(), Rcurrent_monitor); // Is this entry for same obj? __ cmpd(CCR0, Rcurrent_obj, Robj_to_lock); __ beq(CCR0, Lfound); - // Check if last allocated BasicLockObj reached. - - __ ld(Rcurrent_obj, 0, Rcurrent_obj_addr); - __ cmpld(CCR0, Rcurrent_obj_addr, Rlimit); - __ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize); - - // Next iteration if unchecked BasicObjectLocks exist on the stack. - __ ble(CCR0, Lloop); + __ addi(Rcurrent_monitor, Rcurrent_monitor, frame::interpreter_frame_monitor_size_in_bytes()); + __ cmpld(CCR0, Rcurrent_monitor, Rbot); + __ bne(CCR0, Lloop); } // Fell through without finding the basic obj lock => throw up! @@ -4191,8 +4173,6 @@ void TemplateTable::monitorexit() { __ align(32, 12); __ bind(Lfound); - __ addi(Rcurrent_monitor, Rcurrent_obj_addr, - -(frame::interpreter_frame_monitor_size() * wordSize) - BasicObjectLock::obj_offset_in_bytes()); __ unlock_object(Rcurrent_monitor); } diff --git a/test/hotspot/jtreg/compiler/locks/TestUnlockOSR.java b/test/hotspot/jtreg/compiler/locks/TestUnlockOSR.java new file mode 100644 index 0000000000000..f2133b49658c6 --- /dev/null +++ b/test/hotspot/jtreg/compiler/locks/TestUnlockOSR.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 SAP SE. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 8316746 + * @summary During OSR, locks get transferred from interpreter frame. + * Check that unlocking 2 such locks works in the OSR compiled nmethod. + * Some platforms verify that the unlocking happens in the corrent order. + * + * @run main/othervm -Xbatch TestUnlockOSR + */ + +public class TestUnlockOSR { + static void test_method(Object a, Object b, int limit) { + synchronized(a) { // allocate space for monitors + synchronized(b) { + } + } // free space to test allocation in reused space + synchronized(a) { // reuse the space + synchronized(b) { + for (int i = 0; i < limit; i++) {} + } + } + } + + public static void main(String[] args) { + Object a = new TestUnlockOSR(), + b = new TestUnlockOSR(); + // avoid uncommon trap before last unlocks + for (int i = 0; i < 100; i++) { test_method(a, b, 0); } + // trigger OSR + test_method(a, b, 100000); + } +} From 5531ca5e3337cc501cbe1c827a5127371aac9780 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 23 Nov 2023 08:46:38 +0000 Subject: [PATCH 332/341] 8313782: Add user-facing warning if THPs are enabled but cannot be used Backport-of: 44b5b81f76567d0b7fc4687e18c53d7ddbd2e982 --- src/hotspot/os/linux/os_linux.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index ee64272258f42..fb2903adc55cb 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -3860,15 +3860,17 @@ void os::large_page_init() { return; } - // 2) check if large pages are configured - if ( ( UseTransparentHugePages && HugePages::supports_thp() == false) || - (!UseTransparentHugePages && HugePages::supports_static_hugepages() == false) ) { - // No large pages configured, return. + // 2) check if the OS supports THPs resp. static hugepages. + if (UseTransparentHugePages && !HugePages::supports_thp()) { + if (!FLAG_IS_DEFAULT(UseTransparentHugePages)) { + log_warning(pagesize)("UseTransparentHugePages disabled, transparent huge pages are not supported by the operating system."); + } + UseLargePages = UseTransparentHugePages = UseHugeTLBFS = UseSHM = false; + return; + } + if (!UseTransparentHugePages && !HugePages::supports_static_hugepages()) { warn_no_large_pages_configured(); - UseLargePages = false; - UseTransparentHugePages = false; - UseHugeTLBFS = false; - UseSHM = false; + UseLargePages = UseTransparentHugePages = UseHugeTLBFS = UseSHM = false; return; } From 1d7bc8f62a505db0be8e4ab9b99c0b3d469a8ab5 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 23 Nov 2023 08:47:00 +0000 Subject: [PATCH 333/341] 8313781: Add regression tests for large page logging and user-facing error messages Backport-of: 99d260c0ccadea60a48dc8c933972615bcd86b65 --- .../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 d335f047c15f0732ce15cb037718ad8e862c8b91 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 23 Nov 2023 09:01:00 +0000 Subject: [PATCH 334/341] 8293343: sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.java failed with "Agent communication error: java.io.EOFException" 8293335: sun/management/jmxremote/bootstrap/RmiBootstrapTest.java#id1failed with "Agent communication error: java.io.EOFException" Backport-of: 91c9091d7e64ba0bdb257521bd15ff183c6839fa --- .../sun/management/jmxremote/bootstrap/RmiBootstrapTest.java | 4 ++-- .../management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.java | 2 +- test/jdk/sun/management/jmxremote/bootstrap/RmiTestBase.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java b/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java index 2c494a58c9251..f41347f7fd209 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/RmiBootstrapTest.java @@ -58,7 +58,7 @@ * * @library /test/lib * - * @run main/timeout=300 RmiBootstrapTest .*_test.*.in + * @run main/othervm/timeout=300 RmiBootstrapTest .*_test.*.in * */ /* @@ -69,7 +69,7 @@ * * @library /test/lib * - * @run main/timeout=300 RmiBootstrapTest .*_ssltest.*.in + * @run main/othervm/timeout=300 RmiBootstrapTest .*_ssltest.*.in * */ /** diff --git a/test/jdk/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.java b/test/jdk/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.java index 41b303399ccb9..78ccaa86c5f79 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.java @@ -48,7 +48,7 @@ * * @library /test/lib * - * @run main/timeout=300 RmiSslNoKeyStoreTest .*_ssltest.*.in + * @run main/othervm/timeout=300 RmiSslNoKeyStoreTest .*_ssltest.*.in * */ /** diff --git a/test/jdk/sun/management/jmxremote/bootstrap/RmiTestBase.java b/test/jdk/sun/management/jmxremote/bootstrap/RmiTestBase.java index 0fb2996f91371..2d6dbbbbe0ff8 100644 --- a/test/jdk/sun/management/jmxremote/bootstrap/RmiTestBase.java +++ b/test/jdk/sun/management/jmxremote/bootstrap/RmiTestBase.java @@ -141,7 +141,7 @@ static List prepareTestFiles(String filenamePattern) throws IOException { grantFilesAccess(propertyFiles, AccessControl.OWNER); - return Collections.unmodifiableList(files); + return Collections.unmodifiableList(propertyFiles); } /** From 770b3d6f3a535050aa408c1d7df434ebe23ca9ce Mon Sep 17 00:00:00 2001 From: Sandhya Viswanathan Date: Tue, 28 Nov 2023 10:55:39 +0000 Subject: [PATCH 335/341] 8320209: VectorMaskGen clobbers rflags on x86_64 Backport-of: b05e69f789fa8c9a5320be5a841317abd3b3a235 --- src/hotspot/cpu/x86/x86.ad | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index 57e22fe79aabb..f62b0abbd23e0 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -8195,9 +8195,9 @@ instruct vmasked_load64(vec dst, memory mem, kReg mask) %{ ins_pipe( pipe_slow ); %} -instruct vmask_gen(kReg dst, rRegL len, rRegL temp) %{ +instruct vmask_gen(kReg dst, rRegL len, rRegL temp, rFlagsReg cr) %{ match(Set dst (VectorMaskGen len)); - effect(TEMP temp); + effect(TEMP temp, KILL cr); format %{ "vector_mask_gen32 $dst, $len \t! vector mask generator" %} ins_encode %{ __ genmask($dst$$KRegister, $len$$Register, $temp$$Register); From 9128c89367a0506dfc7e8bd8ddb896364f4b0c3b Mon Sep 17 00:00:00 2001 From: Francisco Ferrari Bihurriet Date: Tue, 28 Nov 2023 10:57:59 +0000 Subject: [PATCH 336/341] 8277307: Pre shared key sent under both session_ticket and pre_shared_key extensions Backport-of: 4662e06bff2cef7425c194a9cdd7a6fe7469179e --- .../security/ssl/SessionTicketExtension.java | 8 +++++--- .../net/ssl/SSLSession/ResumeTLS13withSNI.java | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/java.base/share/classes/sun/security/ssl/SessionTicketExtension.java b/src/java.base/share/classes/sun/security/ssl/SessionTicketExtension.java index c35e95b661bc0..af9cd69575f3f 100644 --- a/src/java.base/share/classes/sun/security/ssl/SessionTicketExtension.java +++ b/src/java.base/share/classes/sun/security/ssl/SessionTicketExtension.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -403,11 +403,13 @@ public byte[] produce(ConnectionContext context, chc.statelessResumption = true; // If resumption is not in progress, return an empty value - if (!chc.isResumption || chc.resumingSession == null) { + if (!chc.isResumption || chc.resumingSession == null + || chc.resumingSession.getPskIdentity() == null + || chc.resumingSession.getProtocolVersion().useTLS13PlusSpec()) { if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) { SSLLogger.fine("Stateless resumption supported"); } - return new SessionTicketSpec().getEncoded(); + return new byte[0]; } if (chc.localSupportedSignAlgs == null) { diff --git a/test/jdk/javax/net/ssl/SSLSession/ResumeTLS13withSNI.java b/test/jdk/javax/net/ssl/SSLSession/ResumeTLS13withSNI.java index fbb62441e1c05..3e70af733fb81 100644 --- a/test/jdk/javax/net/ssl/SSLSession/ResumeTLS13withSNI.java +++ b/test/jdk/javax/net/ssl/SSLSession/ResumeTLS13withSNI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ /* * @test - * @bug 8211806 8277881 + * @bug 8211806 8277881 8277307 * @summary TLS 1.3 handshake server name indication is missing on a session resume * @run main/othervm ResumeTLS13withSNI */ @@ -102,7 +102,7 @@ public static void main(String args[]) throws Exception { SSLParameters cliSSLParams = clientEngine.getSSLParameters(); cliSSLParams.setServerNames(List.of(SNI_NAME)); clientEngine.setSSLParameters(cliSSLParams); - clientEngine.setEnabledProtocols(new String[] { "TLSv1.3" }); + clientEngine.setEnabledProtocols(new String[] { "TLSv1.2", "TLSv1.3" }); SSLEngine serverEngine = makeEngine(sslCtx, kmf, tmf, false); SSLParameters servSSLParams = serverEngine.getSSLParameters(); @@ -114,7 +114,7 @@ public static void main(String args[]) throws Exception { // Create a new client-side engine which can initiate TLS session // resumption SSLEngine newCliEngine = makeEngine(sslCtx, kmf, tmf, true); - newCliEngine.setEnabledProtocols(new String[] { "TLSv1.3" }); + newCliEngine.setEnabledProtocols(new String[] { "TLSv1.2", "TLSv1.3" }); ByteBuffer resCliHello = getResumptionClientHello(newCliEngine); dumpBuffer("Resumed ClientHello Data", resCliHello); @@ -394,6 +394,16 @@ private static void checkResumedClientHelloSNI(ByteBuffer resCliHello) System.err.println("* Found pre_shared_key Extension"); resCliHello.position(resCliHello.position() + extLen); break; + case 35: // session_ticket + // This is a TLS1.2 extension; should be empty since we're + // negotiating TLS1.3. See JDK-8277307 + System.err.format("* Found session_ticket extension " + + "(%d bytes)\n", extLen); + if (extLen != 0) { + throw new Exception("Unexpected session_ticket content"); + } + resCliHello.position(resCliHello.position() + extLen); + break; default: System.err.format("* Found extension %d (%d bytes)\n", extType, extLen); From 04ac9fed981ba18d8d1dadc3952a3999d5a3ec89 Mon Sep 17 00:00:00 2001 From: Soumadipta Roy Date: Tue, 28 Nov 2023 10:58:20 +0000 Subject: [PATCH 337/341] 8315692: Parallelize gc/stress/TestStressRSetCoarsening.java test Backport-of: a564d436c722f14041231158f21c4ad3a2f6a3a5 --- .../gc/stress/TestStressRSetCoarsening.java | 70 ++++++++++++++++--- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/test/hotspot/jtreg/gc/stress/TestStressRSetCoarsening.java b/test/hotspot/jtreg/gc/stress/TestStressRSetCoarsening.java index b891641690238..2207737623603 100644 --- a/test/hotspot/jtreg/gc/stress/TestStressRSetCoarsening.java +++ b/test/hotspot/jtreg/gc/stress/TestStressRSetCoarsening.java @@ -27,13 +27,12 @@ import jdk.test.whitebox.WhiteBox; /* - * @test TestStressRSetCoarsening.java + * @test * @key stress * @bug 8146984 8147087 * @requires vm.gc.G1 * @requires os.maxMemory > 3G * @requires vm.opt.MaxGCPauseMillis == "null" - * * @summary Stress G1 Remembered Set by creating a lot of cross region links * @modules java.base/jdk.internal.misc * @library /test/lib @@ -42,27 +41,82 @@ * @run main/othervm/timeout=300 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 - * -Xmx500m -XX:G1HeapRegionSize=1m gc.stress.TestStressRSetCoarsening 1 0 300 + * -Xmx500m -XX:G1HeapRegionSize=1m gc.stress.TestStressRSetCoarsening 1 0 300 + */ + +/* + * @test + * @requires vm.gc.G1 + * @requires os.maxMemory > 3G + * @requires vm.opt.MaxGCPauseMillis == "null" + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm/timeout=300 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 - * -Xmx500m -XX:G1HeapRegionSize=8m gc.stress.TestStressRSetCoarsening 1 10 300 + * -Xmx500m -XX:G1HeapRegionSize=8m gc.stress.TestStressRSetCoarsening 1 10 300 + */ + +/* + * @test + * @requires vm.gc.G1 + * @requires os.maxMemory > 3G + * @requires vm.opt.MaxGCPauseMillis == "null" + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm/timeout=300 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 * -Xmx500m -XX:G1HeapRegionSize=32m gc.stress.TestStressRSetCoarsening 42 10 300 + */ + +/* + * @test + * @requires vm.gc.G1 + * @requires os.maxMemory > 3G + * @requires vm.opt.MaxGCPauseMillis == "null" + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm/timeout=300 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 - * -Xmx500m -XX:G1HeapRegionSize=1m gc.stress.TestStressRSetCoarsening 2 0 300 + * -Xmx500m -XX:G1HeapRegionSize=1m gc.stress.TestStressRSetCoarsening 2 0 300 + */ + +/* + * @test + * @requires vm.gc.G1 + * @requires os.maxMemory > 3G + * @requires vm.opt.MaxGCPauseMillis == "null" + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm/timeout=1800 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 - * -Xmx1G -XX:G1HeapRegionSize=1m gc.stress.TestStressRSetCoarsening 500 0 1800 + * -Xmx1G -XX:G1HeapRegionSize=1m gc.stress.TestStressRSetCoarsening 500 0 1800 + */ + +/* + * @test + * @requires vm.gc.G1 + * @requires os.maxMemory > 3G + * @requires vm.opt.MaxGCPauseMillis == "null" + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm/timeout=1800 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:+UseG1GC -Xlog:gc* -XX:MaxGCPauseMillis=1000 - * -Xmx1G -XX:G1HeapRegionSize=1m gc.stress.TestStressRSetCoarsening 10 10 1800 + * -Xmx1G -XX:G1HeapRegionSize=1m gc.stress.TestStressRSetCoarsening 10 10 1800 */ /** @@ -95,7 +149,7 @@ public static void main(String... args) throws InterruptedException { } int objectsPerRegion = Integer.parseInt(args[0]); // 1 means humongous int regsToRefresh = Integer.parseInt(args[1]); // 0 means no regions to refresh at the end of cycle - int timeout = Integer.parseInt(args[2]); // in seconds, test should stop working eariler + int timeout = Integer.parseInt(args[2]); // in seconds, test should stop working earlier new TestStressRSetCoarsening(objectsPerRegion, regsToRefresh, timeout).go(); } From 410b893793c08e7ad120c28a6e0115126cbf9219 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 28 Nov 2023 10:58:39 +0000 Subject: [PATCH 338/341] 8319187: Add three eMudhra emSign roots Reviewed-by: mbaesken Backport-of: 0bda467f6e29c866c661e88a76a9fe3efc0a0d19 --- make/data/cacerts/emsigneccrootcag3 | 22 +++ make/data/cacerts/emsignrootcag1 | 29 +++ make/data/cacerts/emsignrootcag2 | 39 ++++ .../certification/CAInterop.java | 27 +++ .../certification/EmSignRootG2CA.java | 179 ++++++++++++++++++ .../security/lib/cacerts/VerifyCACerts.java | 13 +- 6 files changed, 306 insertions(+), 3 deletions(-) create mode 100644 make/data/cacerts/emsigneccrootcag3 create mode 100644 make/data/cacerts/emsignrootcag1 create mode 100644 make/data/cacerts/emsignrootcag2 create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/EmSignRootG2CA.java diff --git a/make/data/cacerts/emsigneccrootcag3 b/make/data/cacerts/emsigneccrootcag3 new file mode 100644 index 0000000000000..a286f81c2f451 --- /dev/null +++ b/make/data/cacerts/emsigneccrootcag3 @@ -0,0 +1,22 @@ +Owner: CN=emSign ECC Root CA - G3, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN +Issuer: CN=emSign ECC Root CA - G3, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN +Serial number: 3cf607a968700eda8b84 +Valid from: Sun Feb 18 18:30:00 GMT 2018 until: Wed Feb 18 18:30:00 GMT 2043 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG +EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo +bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g +RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ +TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s +b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw +djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0 +WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS +fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB +zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq +hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB +CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD ++JbNR6iC8hZVdyR+EhCVBCyj +-----END CERTIFICATE----- diff --git a/make/data/cacerts/emsignrootcag1 b/make/data/cacerts/emsignrootcag1 new file mode 100644 index 0000000000000..6b06f6689bc0b --- /dev/null +++ b/make/data/cacerts/emsignrootcag1 @@ -0,0 +1,29 @@ +Owner: CN=emSign Root CA - G1, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN +Issuer: CN=emSign Root CA - G1, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN +Serial number: 31f5e4620c6c58edd6d8 +Valid from: Sun Feb 18 18:30:00 GMT 2018 until: Wed Feb 18 18:30:00 GMT 2043 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYD +VQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBU +ZWNobm9sb2dpZXMgTGltaXRlZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBH +MTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgxODMwMDBaMGcxCzAJBgNVBAYTAklO +MRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVkaHJhIFRlY2hub2xv +Z2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQz +f2N4aLTNLnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO +8oG0x5ZOrRkVUkr+PHB1cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aq +d7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHWDV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhM +tTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ6DqS0hdW5TUaQBw+jSzt +Od9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrHhQIDAQAB +o0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQD +AgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31x +PaOfG1vR2vjTnGs2vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjM +wiI/aTvFthUvozXGaCocV685743QNcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6d +GNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q+Mri/Tm3R7nrft8EI6/6nAYH +6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeihU80Bv2noWgby +RQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx +iN66zB+Afko= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/emsignrootcag2 b/make/data/cacerts/emsignrootcag2 new file mode 100644 index 0000000000000..e4e4ddda65a69 --- /dev/null +++ b/make/data/cacerts/emsignrootcag2 @@ -0,0 +1,39 @@ +Owner: CN=emSign Root CA - G2, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN +Issuer: CN=emSign Root CA - G2, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN +Serial number: 864dbf0fe35ed77d8ed8 +Valid from: Sun Feb 18 18:30:00 GMT 2018 until: Wed Feb 18 18:30:00 GMT 2043 +Signature algorithm name: SHA384withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFlTCCA32gAwIBAgILAIZNvw/jXtd9jtgwDQYJKoZIhvcNAQEMBQAwZzELMAkG +A1UEBhMCSU4xEzARBgNVBAsTCmVtU2lnbiBQS0kxJTAjBgNVBAoTHGVNdWRocmEg +VGVjaG5vbG9naWVzIExpbWl0ZWQxHDAaBgNVBAMTE2VtU2lnbiBSb290IENBIC0g +RzIwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBnMQswCQYDVQQGEwJJ +TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s +b2dpZXMgTGltaXRlZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMjCCAiIw +DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMNwGIWW2kHfHK+sXTNwxF07K+IV +ySTuyFM2r1v002wUfcdT+zs5OM5QbMYFFnedXQI6gCFLsjKrcaej48Zt37OyEb3i +aPs7CsP4kAyTwzKH9aZe6gXYHrJq40/ZVMNcQVI2PcIp40B/SAN2gUZ+ZaUtIOvV +jEx26/ebNaXRIsthlkOG/caB+QRwDw1tl7338Zlv0M2oTBUy4B3e7dGP5pgXH71M +jqHPCoNo+xv9f0NTBT+hUDa8h8wUtcGQq9CDeJTpjWcD2bP2AMdVG6oVpMAUeUzo +cCyglvtFdUMjggxBbw4qhau1HXPG8Ot9hwL7ZMi8tkTzrvUIxxb8G9LF/7kKeCE7 +tGZa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zJY2X1vAQ7hVnniCjgaXAGqjsU6sklNM9n +xDx5rFCCCEtj9Kh8UHjGK2QqgP5kwgttjOApQMaCoezMfK4KD7WpOXU= +-----END CERTIFICATE----- diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java index 621572564223f..b5bb698e458f3 100644 --- a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/CAInterop.java @@ -431,6 +431,26 @@ * @run main/othervm -Djava.security.debug=certpath CAInterop teliarootcav2 CRL */ +/* + * @test id=emsignrootcag1 + * @bug 8319187 + * @summary Interoperability tests with eMudhra Root CA G1 + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop emsignrootcag1 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop emsignrootcag1 CRL + */ + +/* + * @test id=emsigneccrootcag3 + * @bug 8319187 + * @summary Interoperability tests with eMudhra ECC Root CA G3 + * @library /test/lib + * @build jtreg.SkippedException ValidatePathWithURL CAInterop + * @run main/othervm -Djava.security.debug=certpath,ocsp CAInterop emsigneccrootcag3 OCSP + * @run main/othervm -Djava.security.debug=certpath CAInterop emsigneccrootcag3 CRL + */ + /** * Collection of certificate validation tests for interoperability with external CAs */ @@ -586,6 +606,13 @@ private CATestURLs getTestURLs(String alias) { new CATestURLs("https://juolukka.cover.telia.fi:10600", "https://juolukka.cover.telia.fi:10601"); + case "emsignrootcag1" -> + new CATestURLs("https://testovg1.emsign.com/RootOVG1.html", + "https://testovg1r.emsign.com/RootOVG1MR.html"); + case "emsigneccrootcag3" -> + new CATestURLs("https://testovg3.emsign.com/RootOVG3.html", + "https://testovg3r.emsign.com/RootOVG3MR.html"); + default -> throw new RuntimeException("No test setup found for: " + alias); }; } diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/EmSignRootG2CA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/EmSignRootG2CA.java new file mode 100644 index 0000000000000..8f5df9cce755b --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/EmSignRootG2CA.java @@ -0,0 +1,179 @@ +/* + * 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 8319187 + * @summary Interoperability tests with eMudhra emSign Root CA G2 CS root + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath EmSignRootG2CA OCSP + * @run main/othervm -Djava.security.debug=certpath EmSignRootG2CA CRL + */ + +public class EmSignRootG2CA { + + // Owner: CN=emSign CS CA - G2, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN + // Issuer: CN=emSign Root CA - G2, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN + // Serial number: c084e666596139a1fa9b + // Valid from: Sun Feb 18 10:30:00 PST 2018 until: Fri Feb 18 10:30:00 PST 2033 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGeDCCBGCgAwIBAgILAMCE5mZZYTmh+pswDQYJKoZIhvcNAQEMBQAwZzELMAkG\n" + + "A1UEBhMCSU4xEzARBgNVBAsTCmVtU2l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yzGqTA9tSzQ4nmA9aXBCAAxrABlY/hk10ImeBa1SPjocRb/vuCaGp74T\n" + + "n8oADP42XudDnp8wlOKWxFJulhNi960Rev+5vZOPF/LGfS78GI6yzBjR49VJGhOP\n" + + "EJK8NSNmK3FNblQfOyFM7VE0uOGHOUwpMGVM2A==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=test, OU=test, O=test, L=test, ST=test, C=IN + // Issuer: CN=emSign CS CA - G2, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN + // Serial number: 7c9ade672c0ad1b6 + // Valid from: Wed Aug 30 05:39:25 PDT 2023 until: Sat Aug 30 05:39:25 PDT 2025 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIGNjCCBB6gAwIBAgIIfJreZywK0bYwDQYJKoZIhvcNAQEMBQAwZTELMAkGA1UE\n" + + "BhMCSU4xEzARBgNVBAsTCmVtU2lnbiBQS0kxJTAjBgNVBAoTHGVNdWRocmEgVGVj\n" + + "aG5vbG9naWVzIExpbWl0ZWQxGjAYBgNVBAMTEWVtU2lnbiBDUyBDQSAtIEcyMB4X\n" + + "DTIzMDgzMDEyMzkyNVoXDTI1MDgzMDEyMzkyNVowWDELMAkGA1UEBhMCSU4xDTAL\n" + + "BgNVBAgTBHRlc3QxDTALBgNVBAcTBHRlc3QxDTALBgNVBAoMBHRlc3QxDTALBgNV\n" + + "BAsTBHRlc3QxDTALBgNVBAMTBHRlc3QwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAw\n" + + "ggGKAoIBgQC04pOiSFbl7Bd4wFYXzzyukKh+EmwIq8xRGQDkuYH+C6Zao36VAV+k\n" + + "xGw7lmM3rf4YUcArgZYHfrxgPJNBbGrCi/YnEPYQTNwSrBAePUx1tt13LVBxHfNu\n" + + "cQQT+kqE7064WsYfmfr/uzJZemqVH7lG82DN23+8E/235AIh3lz/pn7T9ByLj7TV\n" + + "zWP40oT0UfQXQvWUpFevPONu/RksRP+NiKV3ji6/wYpvrfodzkrG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"99Waf4Bp6p3lvBArK2BbabTs8+16xvmkHEK3d3l3Bu6qTEbQRgUI5XsVXmXXn8Pg\n" + + "IANliTEsbsN9CMWrJ56ciEujU7w2L+IBfvKhl10N1AQNHwpQzwfFyz2BUbACN75o\n" + + "feIUBarM3ssNzpnt7idgkCTwWVrdEL1NHyW967aEMWyVwaRrtkjFOW/0xuSr2rEI\n" + + "jBpPj5RPdP6ZEaqnmg5PIgSrJ8FBjx6JmvVgZH/XEl5MZ7PsvJFfIMun6RxXtGn7\n" + + "QP0+ipkRrI6USNFS84H53Q0WJhQWZUgd3cdm37wpFGvxOVEskIgJNW9SbOgiT9sB\n" + + "zTIy3ceOK2onmUkDM2Q2+Hbc7A4BmNIlW4fpYXvZlM7IXSl9U3Voks92Hi45azgz\n" + + "StWZv9+Ronmmp+b7JKCe7MZXIBHfj0JhAVNJiYTZ9BqkY2VRvuQPVUdKxske9fQ6\n" + + "ciFJ5a6RDOhce6pFloaQu39ci2XCY1N4mIR3vFzpmBNkttlEXviK07XNTv9cnQt6\n" + + "3CW5aMAsfTbmOw==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=test, OU=test, O=test, L=test, ST=test, C=IN + // Issuer: CN=emSign CS CA - G2, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN + // Serial number: cf02dedd03d2f509 + // Valid from: Thu Oct 05 22:38:51 PDT 2023 until: Sun Oct 05 22:38:51 PDT 2025 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGNzCCBB+gAwIBAgIJAM8C3t0D0vUJMA0GCSqGSIb3DQEBDAUAMGUxCzAJBgNV\n" + + "BAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVkaHJhIFRl\n" + + "Y2hub2xvZ2llcyBMaW1pdGVkMRowGAYDVQQDExFlbVNpZ24gQ1MgQ0EgLSBHMjAe\n" + + "Fw0yMzEwMDYwNTM4NTFaFw0yNTEwMDYwNTM4NTFaMFgxCzAJBg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9zaXRvcnku\n" + + "ZW1TaWduLmNvbTAIBgZngQwBBAEwcwYIKwYBBQUHAQEEZzBlMCIGCCsGAQUFBzAB\n" + + "hhZodHRwOi8vb2NzcC5lbVNpZ24uY29tMD8GCCsGAQUFBzAChjNodHRwOi8vcmVw\n" + + "b3NpdG9yeS5lbXNpZ24uY29tL2NlcnRzL2VtU2lnbkNTQ0FHMi5jcnQwDAYDVR0T\n" + + "AQH/BAIwADANBgkqhkiG9w0BAQwFAAOCAgEAGa2XSoRkoIkHHHGXrdzTBCf/+KgK\n" + + "FlHhqlBOk5rwLDX1sfNlmsaz10I69phE90Ac8Coa/xCrBaFrTYqRvmkY9gU19jkn\n" + + "FdVcwQEHNku7Ro/Z/mbyi+aTBzHMTy0Vl4HqVnQInjV891n64SerUuAB7wNVOOho\n" + + "GoBfpf6lzDzzuEmetFokHYv1tWGQqPF/dHLARQraUlQpWjsnOx0QcZ5cM79REONE\n" + + "y6uzXT2vaatT3ns8Mtx8zooq+t8pnZlXJqlrwNTcnPad9gSsVu6vfsnWhLhz0VLG\n" + + "sYPXcWIssLbBQW3v5z0l1Isj7vy2UFfbn8AmZ0PanPo3v3C2sk19DK+Zlc9xBAXc\n" + + "KKwc4m8le6QkP/EB2wUA7ey5Cf29hjNDJpZznquEaWl9aKbBRdJDKsK88IBJjzK0\n" + + "Gbpw9fYJ3txuGA7Q27gyaZAeGAIrFvOtRY0XFbr20qSh2GBBYN57+lBPh4UKqgy8\n" + + "Z2Kk/2jK9k+nm41JYCmwVZHg3Va9RRfW8FkeE95gAUFPDWjeV+GvcimCbcB3DwaZ\n" + + "9fy1qfV4xsduhC3ei6f7Ask8LbAEWaEIXmgK10YbIfhzomCyCzlA+E+gwkq/bmkv\n" + + "B8hh27KWA6IRt7URI51MZlh0e8fULyXlOZcoJA/IPX9RdePa2RHFuPSypBHjoN7z\n" + + "6bCML1XZ2xnHIAg=\n" + + "-----END CERTIFICATE-----"; + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Thu Oct 05 22:51:36 PDT 2023", System.out); + } +} diff --git a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java index 53a981591163f..80e5931b2b21e 100644 --- a/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java +++ b/test/jdk/sun/security/lib/cacerts/VerifyCACerts.java @@ -28,7 +28,7 @@ * 8209452 8209506 8210432 8195793 8216577 8222089 8222133 8222137 8222136 * 8223499 8225392 8232019 8234245 8233223 8225068 8225069 8243321 8243320 * 8243559 8225072 8258630 8259312 8256421 8225081 8225082 8225083 8245654 - * 8305975 8304760 8307134 8295894 8314960 8317373 8317374 8318759 + * 8305975 8304760 8307134 8295894 8314960 8317373 8317374 8318759 8319187 * @summary Check root CA entries in cacerts file */ import java.io.ByteArrayInputStream; @@ -47,12 +47,13 @@ public class VerifyCACerts { + File.separator + "security" + File.separator + "cacerts"; // The numbers of certs now. - private static final int COUNT = 103; + private static final int COUNT = 106; // SHA-256 of cacerts, can be generated with // shasum -a 256 cacerts | sed -e 's/../&:/g' | tr '[:lower:]' '[:upper:]' | cut -c1-95 private static final String CHECKSUM - = "A6:73:50:DD:6B:49:E6:F0:E7:E7:7B:F9:F9:11:9F:83:2D:FD:95:97:69:03:54:54:9C:B7:DF:46:A4:05:7A:15"; + = "61:5F:6D:C5:9C:A3:8A:65:3F:CB:F9:F5:26:04:23:F4:53:A6:8C:B3:8B:2B:0A:F0:66:7D:9E:67:B9:4D:AC:B7"; + // Hex formatter to upper case with ":" delimiter private static final HexFormat HEX = HexFormat.ofDelimiter(":").withUpperCase(); @@ -266,6 +267,12 @@ public class VerifyCACerts { "D4:8D:3D:23:EE:DB:50:A4:59:E5:51:97:60:1C:27:77:4B:9D:7B:18:C9:4D:5A:05:95:11:A1:02:50:B9:31:68"); put("teliarootcav2 [jdk]", "24:2B:69:74:2F:CB:1E:5B:2A:BF:98:89:8B:94:57:21:87:54:4E:5B:4D:99:11:78:65:73:62:1F:6A:74:B8:2C"); + put("emsignrootcag1 [jdk]", + "40:F6:AF:03:46:A9:9A:A1:CD:1D:55:5A:4E:9C:CE:62:C7:F9:63:46:03:EE:40:66:15:83:3D:C8:C8:D0:03:67"); + put("emsigneccrootcag3 [jdk]", + "86:A1:EC:BA:08:9C:4A:8D:3B:BE:27:34:C6:12:BA:34:1D:81:3E:04:3C:F9:E8:A8:62:CD:5C:57:A3:6B:BE:6B"); + put("emsignrootcag2 [jdk]", + "1A:A0:C2:70:9E:83:1B:D6:E3:B5:12:9A:00:BA:41:F7:EE:EF:02:08:72:F1:E6:50:4B:F0:F6:C3:F2:4F:3A:F3"); } }; From cd52f996db02a4074fb04c4690856d639d709206 Mon Sep 17 00:00:00 2001 From: Sonia Zaldana Calles Date: Tue, 28 Nov 2023 14:29:42 +0000 Subject: [PATCH 339/341] 8275509: ModuleDescriptor.hashCode isn't reproducible across builds Backport-of: 396132ff1e56463ad195cac5c9ac8e2eac5a16e8 --- .../java/lang/module/ModuleDescriptor.java | 20 ++++- .../module/ModuleDescriptorHashCodeTest.java | 76 +++++++++++++++++++ 2 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 test/jdk/java/lang/module/ModuleDescriptorHashCodeTest.java diff --git a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java index 93ac7365624e6..39f68ac953b36 100644 --- a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java +++ b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java @@ -327,7 +327,7 @@ public boolean equals(Object ob) { */ @Override public int hashCode() { - int hash = name.hashCode() * 43 + mods.hashCode(); + int hash = name.hashCode() * 43 + modsHashCode(mods); if (compiledVersion != null) hash = hash * 43 + compiledVersion.hashCode(); if (rawCompiledVersion != null) @@ -505,7 +505,7 @@ public int compareTo(Exports that) { */ @Override public int hashCode() { - int hash = mods.hashCode(); + int hash = modsHashCode(mods); hash = hash * 43 + source.hashCode(); return hash * 43 + targets.hashCode(); } @@ -708,7 +708,7 @@ public int compareTo(Opens that) { */ @Override public int hashCode() { - int hash = mods.hashCode(); + int hash = modsHashCode(mods); hash = hash * 43 + source.hashCode(); return hash * 43 + targets.hashCode(); } @@ -2261,7 +2261,7 @@ public int hashCode() { int hc = hash; if (hc == 0) { hc = name.hashCode(); - hc = hc * 43 + Objects.hashCode(modifiers); + hc = hc * 43 + modsHashCode(modifiers); hc = hc * 43 + requires.hashCode(); hc = hc * 43 + Objects.hashCode(packages); hc = hc * 43 + exports.hashCode(); @@ -2546,6 +2546,18 @@ private static String toString(Set mods, String what) { .collect(Collectors.joining(" ")); } + /** + * Generates and returns a hashcode for the enum instances. The returned hashcode + * is a value based on the {@link Enum#name() name} of each enum instance. + */ + private static int modsHashCode(Iterable> enums) { + int h = 0; + for (Enum e : enums) { + h = h * 43 + Objects.hashCode(e.name()); + } + return h; + } + private static > int compare(T obj1, T obj2) { if (obj1 != null) { diff --git a/test/jdk/java/lang/module/ModuleDescriptorHashCodeTest.java b/test/jdk/java/lang/module/ModuleDescriptorHashCodeTest.java new file mode 100644 index 0000000000000..78b124d870101 --- /dev/null +++ b/test/jdk/java/lang/module/ModuleDescriptorHashCodeTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import org.testng.annotations.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.module.ModuleDescriptor; +import java.util.Set; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotSame; + +/** + * @test + * @bug 8275509 + * @run testng ModuleDescriptorHashCodeTest + * @run testng/othervm -Xshare:off ModuleDescriptorHashCodeTest + * @summary Tests the ModuleDescriptor.hashCode() for boot layer modules + */ +public class ModuleDescriptorHashCodeTest { + + /** + * Verifies that the ModuleDescriptor.hashCode() returned by a boot layer module is + * the same as that returned by a ModuleDescriptor constructed from the ModuleDescriptor.Builder + * for the same module. + */ + @Test + public void testBootModuleDescriptor() throws Exception { + Set bootModules = ModuleLayer.boot().modules(); + for (Module bootModule : bootModules) { + System.out.println("Testing module descriptor of boot module " + bootModule); + ModuleDescriptor bootMD = bootModule.getDescriptor(); + ModuleDescriptor mdFromBuilder = fromModuleInfoClass(bootModule); + // verify that this object is indeed a different object instance than the boot module descriptor + // to prevent any artificial passing of the test + assertNotSame(mdFromBuilder, bootMD, "ModuleDescriptor loaded from boot layer and " + + "one created from module-info.class unexpectedly returned the same instance"); + assertEquals(mdFromBuilder.hashCode(), bootMD.hashCode(), + "Unexpected ModuleDescriptor.hashCode() for " + mdFromBuilder); + assertEquals(mdFromBuilder.compareTo(bootMD), 0, + "Unexpected ModuleDescriptor.compareTo() for " + mdFromBuilder); + } + } + + // Returns a ModuleDescriptor parsed out of the module-info.class of the passed Module + private static ModuleDescriptor fromModuleInfoClass(Module module) throws IOException { + try (InputStream moduleInfo = module.getResourceAsStream("module-info.class")) { + if (moduleInfo == null) { + throw new RuntimeException("Could not locate module-info.class in " + module); + } + // internally calls ModuleDescriptor.Builder + return ModuleDescriptor.read(moduleInfo); + } + } +} From 9165f777f86fd333d4c17702b7e6289bfdbb5e1e Mon Sep 17 00:00:00 2001 From: Martin Balao Date: Tue, 28 Nov 2023 15:44:32 +0000 Subject: [PATCH 340/341] 8271566: DSA signature length value is not accurate in P11Signature Reviewed-by: adinn Backport-of: ea8d3c92c69c393cdbc6c62398f1e9c6adc708d3 --- .../classes/sun/security/pkcs11/P11Key.java | 735 +++++++++++------- .../sun/security/pkcs11/P11Signature.java | 35 +- .../pkcs11/Signature/LargeDSAKey.java | 98 +++ 3 files changed, 568 insertions(+), 300 deletions(-) create mode 100644 test/jdk/sun/security/pkcs11/Signature/LargeDSAKey.java 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 0736ce997e406..39bd783dd258a 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 @@ -117,7 +117,7 @@ abstract class P11Key implements Key, Length { } P11Key(String type, Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { + int keyLength, CK_ATTRIBUTE[] attrs) { this.type = type; this.token = session.token; this.algorithm = algorithm; @@ -125,15 +125,15 @@ abstract class P11Key implements Key, Length { boolean tokenObject = false; boolean sensitive = false; boolean extractable = true; - int n = (attributes == null) ? 0 : attributes.length; - for (int i = 0; i < n; i++) { - CK_ATTRIBUTE attr = attributes[i]; - if (attr.type == CKA_TOKEN) { - tokenObject = attr.getBoolean(); - } else if (attr.type == CKA_SENSITIVE) { - sensitive = attr.getBoolean(); - } else if (attr.type == CKA_EXTRACTABLE) { - extractable = attr.getBoolean(); + if (attrs != null) { + for (CK_ATTRIBUTE attr : attrs) { + if (attr.type == CKA_TOKEN) { + tokenObject = attr.getBoolean(); + } else if (attr.type == CKA_SENSITIVE) { + sensitive = attr.getBoolean(); + } else if (attr.type == CKA_EXTRACTABLE) { + extractable = attr.getBoolean(); + } } } this.tokenObject = tokenObject; @@ -250,7 +250,7 @@ protected Object writeReplace() throws ObjectStreamException { public String toString() { token.ensureValid(); String s1 = token.provider.getName() + " " + algorithm + " " + type - + " key, " + keyLength + " bits"; + + " key, " + keyLength + " bits "; s1 += (tokenObject ? "token" : "session") + " object"; if (isPublic()) { s1 += ")"; @@ -281,19 +281,31 @@ boolean isSecret() { return type == SECRET; } - void fetchAttributes(CK_ATTRIBUTE[] attributes) { + CK_ATTRIBUTE[] fetchAttributes(CK_ATTRIBUTE[] attrs) { + Objects.requireNonNull(attrs, "attrs must be non-null"); Session tempSession = null; long keyID = this.getKeyID(); try { tempSession = token.getOpSession(); token.p11.C_GetAttributeValue(tempSession.id(), keyID, - attributes); + attrs); } catch (PKCS11Exception e) { throw new ProviderException(e); } finally { this.releaseKeyID(); token.releaseSession(tempSession); } + return attrs; + } + + // convenience method which returns the attribute values as BigInteger[] + BigInteger[] fetchAttributesAsInts(CK_ATTRIBUTE[] attrs) { + attrs = fetchAttributes(attrs); + BigInteger[] res = new BigInteger[attrs.length]; + for (int i = 0; i < attrs.length; i++) { + res[i] = attrs[i].getBigInteger(); + } + return res; } private static final CK_ATTRIBUTE[] A0 = new CK_ATTRIBUTE[0]; @@ -332,44 +344,43 @@ private static CK_ATTRIBUTE[] getAttributes(Session session, long keyID, } static SecretKey secretKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - attributes = getAttributes(session, keyID, attributes, new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_TOKEN), - new CK_ATTRIBUTE(CKA_SENSITIVE), - new CK_ATTRIBUTE(CKA_EXTRACTABLE), + int keyLength, CK_ATTRIBUTE[] attrs) { + attrs = getAttributes(session, keyID, attrs, new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_TOKEN), + new CK_ATTRIBUTE(CKA_SENSITIVE), + new CK_ATTRIBUTE(CKA_EXTRACTABLE), }); - return new P11SecretKey(session, keyID, algorithm, keyLength, - attributes); + return new P11SecretKey(session, keyID, algorithm, keyLength, attrs); } - static SecretKey masterSecretKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes, int major, int minor) { - attributes = getAttributes(session, keyID, attributes, new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_TOKEN), - new CK_ATTRIBUTE(CKA_SENSITIVE), - new CK_ATTRIBUTE(CKA_EXTRACTABLE), + static SecretKey masterSecretKey(Session session, long keyID, + String algorithm, int keyLength, CK_ATTRIBUTE[] attrs, + int major, int minor) { + attrs = getAttributes(session, keyID, attrs, new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_TOKEN), + new CK_ATTRIBUTE(CKA_SENSITIVE), + new CK_ATTRIBUTE(CKA_EXTRACTABLE), }); - return new P11TlsMasterSecretKey( - session, keyID, algorithm, keyLength, attributes, major, - minor); + return new P11TlsMasterSecretKey(session, keyID, algorithm, keyLength, + attrs, major, minor); } // we assume that all components of public keys are always accessible static PublicKey publicKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { + int keyLength, CK_ATTRIBUTE[] attrs) { switch (algorithm) { case "RSA": return new P11RSAPublicKey(session, keyID, algorithm, - keyLength, attributes); + keyLength, attrs); case "DSA": return new P11DSAPublicKey(session, keyID, algorithm, - keyLength, attributes); + keyLength, attrs); case "DH": return new P11DHPublicKey(session, keyID, algorithm, - keyLength, attributes); + keyLength, attrs); case "EC": return new P11ECPublicKey(session, keyID, algorithm, - keyLength, attributes); + keyLength, attrs); default: throw new ProviderException ("Unknown public key algorithm " + algorithm); @@ -377,73 +388,45 @@ static PublicKey publicKey(Session session, long keyID, String algorithm, } static PrivateKey privateKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - attributes = getAttributes(session, keyID, attributes, new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_TOKEN), - new CK_ATTRIBUTE(CKA_SENSITIVE), - new CK_ATTRIBUTE(CKA_EXTRACTABLE), + int keyLength, CK_ATTRIBUTE[] attrs) { + attrs = getAttributes(session, keyID, attrs, new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_TOKEN), + new CK_ATTRIBUTE(CKA_SENSITIVE), + new CK_ATTRIBUTE(CKA_EXTRACTABLE), }); - if (attributes[1].getBoolean() || (attributes[2].getBoolean() == false)) { - return new P11PrivateKey - (session, keyID, algorithm, keyLength, attributes); - } else { - switch (algorithm) { - case "RSA": - // In order to decide if this is RSA CRT key, we first query - // and see if all extra CRT attributes are available. - CK_ATTRIBUTE[] attrs2 = new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_PUBLIC_EXPONENT), - new CK_ATTRIBUTE(CKA_PRIME_1), - new CK_ATTRIBUTE(CKA_PRIME_2), - new CK_ATTRIBUTE(CKA_EXPONENT_1), - new CK_ATTRIBUTE(CKA_EXPONENT_2), - new CK_ATTRIBUTE(CKA_COEFFICIENT), - }; - boolean crtKey; - try { - session.token.p11.C_GetAttributeValue - (session.id(), keyID, attrs2); - crtKey = ((attrs2[0].pValue instanceof byte[]) && - (attrs2[1].pValue instanceof byte[]) && - (attrs2[2].pValue instanceof byte[]) && - (attrs2[3].pValue instanceof byte[]) && - (attrs2[4].pValue instanceof byte[]) && - (attrs2[5].pValue instanceof byte[])) ; - } catch (PKCS11Exception e) { - // ignore, assume not available - crtKey = false; - } - if (crtKey) { - return new P11RSAPrivateKey(session, keyID, algorithm, - keyLength, attributes, attrs2); - } else { - return new P11RSAPrivateNonCRTKey(session, keyID, - algorithm, keyLength, attributes); - } - case "DSA": - return new P11DSAPrivateKey(session, keyID, algorithm, - keyLength, attributes); - case "DH": - return new P11DHPrivateKey(session, keyID, algorithm, - keyLength, attributes); - case "EC": - return new P11ECPrivateKey(session, keyID, algorithm, - keyLength, attributes); - default: - throw new ProviderException - ("Unknown private key algorithm " + algorithm); - } + + boolean keySensitive = (attrs[0].getBoolean() || + attrs[1].getBoolean() || !attrs[2].getBoolean()); + + switch (algorithm) { + case "RSA": + return P11RSAPrivateKeyInternal.of(session, keyID, algorithm, + keyLength, attrs, keySensitive); + case "DSA": + return P11DSAPrivateKeyInternal.of(session, keyID, algorithm, + keyLength, attrs, keySensitive); + case "DH": + return P11DHPrivateKeyInternal.of(session, keyID, algorithm, + keyLength, attrs, keySensitive); + case "EC": + return P11ECPrivateKeyInternal.of(session, keyID, algorithm, + keyLength, attrs, keySensitive); + default: + throw new ProviderException + ("Unknown private key algorithm " + algorithm); } } - // class for sensitive and unextractable private keys - private static final class P11PrivateKey extends P11Key - implements PrivateKey { + // base class for all PKCS11 private keys + private static abstract class P11PrivateKey extends P11Key implements + PrivateKey { private static final long serialVersionUID = -2138581185214187615L; + protected byte[] encoded; // guard by synchronized + P11PrivateKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - super(PRIVATE, session, keyID, algorithm, keyLength, attributes); + int keyLength, CK_ATTRIBUTE[] attrs) { + super(PRIVATE, session, keyID, algorithm, keyLength, attrs); } // XXX temporary encoding for serialization purposes public String getFormat() { @@ -458,11 +441,14 @@ byte[] getEncodedInternal() { private static class P11SecretKey extends P11Key implements SecretKey { private static final long serialVersionUID = -7828241727014329084L; - private volatile byte[] encoded; + + private volatile byte[] encoded; // guard by double-checked locking + P11SecretKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - super(SECRET, session, keyID, algorithm, keyLength, attributes); + int keyLength, CK_ATTRIBUTE[] attrs) { + super(SECRET, session, keyID, algorithm, keyLength, attrs); } + public String getFormat() { token.ensureValid(); if (sensitive || !extractable || (isNSS && tokenObject)) { @@ -471,32 +457,21 @@ public String getFormat() { return "RAW"; } } + byte[] getEncodedInternal() { token.ensureValid(); if (getFormat() == null) { return null; } + byte[] b = encoded; if (b == null) { synchronized (this) { b = encoded; if (b == null) { - Session tempSession = null; - long keyID = this.getKeyID(); - try { - tempSession = token.getOpSession(); - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { + b = fetchAttributes(new CK_ATTRIBUTE[] { new CK_ATTRIBUTE(CKA_VALUE), - }; - token.p11.C_GetAttributeValue - (tempSession.id(), keyID, attributes); - b = attributes[0].getByteArray(); - } catch (PKCS11Exception e) { - throw new ProviderException(e); - } finally { - this.releaseKeyID(); - token.releaseSession(tempSession); - } + })[0].getByteArray(); encoded = b; } } @@ -505,6 +480,19 @@ byte[] getEncodedInternal() { } } + // base class for all PKCS11 public keys + private static abstract class P11PublicKey extends P11Key implements + PublicKey { + private static final long serialVersionUID = 1L; + + protected byte[] encoded; // guard by synchronized + + P11PublicKey(Session session, long keyID, String algorithm, + int keyLength, CK_ATTRIBUTE[] attrs) { + super(PUBLIC, session, keyID, algorithm, keyLength, attrs); + } + } + @SuppressWarnings("deprecation") private static class P11TlsMasterSecretKey extends P11SecretKey implements TlsMasterSecret { @@ -512,8 +500,8 @@ private static class P11TlsMasterSecretKey extends P11SecretKey private final int majorVersion, minorVersion; P11TlsMasterSecretKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes, int major, int minor) { - super(session, keyID, algorithm, keyLength, attributes); + int keyLength, CK_ATTRIBUTE[] attrs, int major, int minor) { + super(session, keyID, algorithm, keyLength, attrs); this.majorVersion = major; this.minorVersion = minor; } @@ -526,17 +514,92 @@ public int getMinorVersion() { } } + // impl class for sensitive/unextractable RSA private keys + static class P11RSAPrivateKeyInternal extends P11PrivateKey { + private static final long serialVersionUID = -2138581185214187615L; + + static P11RSAPrivateKeyInternal of(Session session, long keyID, + String algorithm, int keyLength, CK_ATTRIBUTE[] attrs, + boolean keySensitive) { + if (keySensitive) { + return new P11RSAPrivateKeyInternal(session, keyID, algorithm, + keyLength, attrs); + } else { + CK_ATTRIBUTE[] rsaAttrs = new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_MODULUS), + new CK_ATTRIBUTE(CKA_PRIVATE_EXPONENT), + new CK_ATTRIBUTE(CKA_PUBLIC_EXPONENT), + new CK_ATTRIBUTE(CKA_PRIME_1), + new CK_ATTRIBUTE(CKA_PRIME_2), + new CK_ATTRIBUTE(CKA_EXPONENT_1), + new CK_ATTRIBUTE(CKA_EXPONENT_2), + new CK_ATTRIBUTE(CKA_COEFFICIENT), + }; + boolean isCRT = true; + Session tempSession = null; + try { + tempSession = session.token.getOpSession(); + session.token.p11.C_GetAttributeValue(tempSession.id(), + keyID, rsaAttrs); + for (CK_ATTRIBUTE attr : rsaAttrs) { + isCRT &= (attr.pValue instanceof byte[]); + if (!isCRT) break; + } + } catch (PKCS11Exception e) { + // ignore, assume not available + isCRT = false; + } finally { + session.token.releaseSession(tempSession); + } + BigInteger n = rsaAttrs[0].getBigInteger(); + BigInteger d = rsaAttrs[1].getBigInteger(); + if (isCRT) { + return new P11RSAPrivateKey(session, keyID, algorithm, + keyLength, attrs, n, d, + Arrays.copyOfRange(rsaAttrs, 2, rsaAttrs.length)); + } else { + return new P11RSAPrivateNonCRTKey(session, keyID, + algorithm, keyLength, attrs, n, d); + } + } + } + + protected transient BigInteger n; + + private P11RSAPrivateKeyInternal(Session session, long keyID, + String algorithm, int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); + } + + private synchronized void fetchValues() { + token.ensureValid(); + if (n != null) return; + + n = fetchAttributesAsInts(new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_MODULUS) + })[0]; + } + + public BigInteger getModulus() { + fetchValues(); + return n; + } + } + // RSA CRT private key - private static final class P11RSAPrivateKey extends P11Key - implements RSAPrivateCrtKey { + private static final class P11RSAPrivateKey extends P11RSAPrivateKeyInternal + implements RSAPrivateCrtKey { private static final long serialVersionUID = 9215872438913515220L; - private BigInteger n, e, d, p, q, pe, qe, coeff; - private byte[] encoded; - P11RSAPrivateKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attrs, CK_ATTRIBUTE[] crtAttrs) { - super(PRIVATE, session, keyID, algorithm, keyLength, attrs); + private transient BigInteger e, d, p, q, pe, qe, coeff; + + private P11RSAPrivateKey(Session session, long keyID, String algorithm, + int keyLength, CK_ATTRIBUTE[] attrs, BigInteger n, BigInteger d, + CK_ATTRIBUTE[] crtAttrs) { + super(session, keyID, algorithm, keyLength, attrs); + this.n = n; + this.d = d; for (CK_ATTRIBUTE a : crtAttrs) { if (a.type == CKA_PUBLIC_EXPONENT) { e = a.getBigInteger(); @@ -553,28 +616,15 @@ private static final class P11RSAPrivateKey extends P11Key } } } - private synchronized void fetchValues() { - token.ensureValid(); - if (n != null) { - return; - } - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_MODULUS), - new CK_ATTRIBUTE(CKA_PRIVATE_EXPONENT), - }; - fetchAttributes(attributes); - n = attributes[0].getBigInteger(); - d = attributes[1].getBigInteger(); - } public String getFormat() { token.ensureValid(); return "PKCS#8"; } + synchronized byte[] getEncodedInternal() { token.ensureValid(); if (encoded == null) { - fetchValues(); try { Key newKey = RSAPrivateCrtKeyImpl.newKey (KeyType.RSA, null, n, e, d, p, q, pe, qe, coeff); @@ -585,15 +635,15 @@ synchronized byte[] getEncodedInternal() { } return encoded; } + + @Override public BigInteger getModulus() { - fetchValues(); return n; } public BigInteger getPublicExponent() { return e; } public BigInteger getPrivateExponent() { - fetchValues(); return d; } public BigInteger getPrimeP() { @@ -614,37 +664,28 @@ public BigInteger getCrtCoefficient() { } // RSA non-CRT private key - private static final class P11RSAPrivateNonCRTKey extends P11Key - implements RSAPrivateKey { + private static final class P11RSAPrivateNonCRTKey extends + P11RSAPrivateKeyInternal implements RSAPrivateKey { private static final long serialVersionUID = 1137764983777411481L; - private BigInteger n, d; - private byte[] encoded; + private transient BigInteger d; + P11RSAPrivateNonCRTKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - super(PRIVATE, session, keyID, algorithm, keyLength, attributes); - } - private synchronized void fetchValues() { - token.ensureValid(); - if (n != null) { - return; - } - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_MODULUS), - new CK_ATTRIBUTE(CKA_PRIVATE_EXPONENT), - }; - fetchAttributes(attributes); - n = attributes[0].getBigInteger(); - d = attributes[1].getBigInteger(); + int keyLength, CK_ATTRIBUTE[] attrs, BigInteger n, + BigInteger d) { + super(session, keyID, algorithm, keyLength, attrs); + this.n = n; + this.d = d; } + public String getFormat() { token.ensureValid(); return "PKCS#8"; } + synchronized byte[] getEncodedInternal() { token.ensureValid(); if (encoded == null) { - fetchValues(); try { // XXX make constructor in SunRsaSign provider public // and call it directly @@ -658,42 +699,43 @@ synchronized byte[] getEncodedInternal() { } return encoded; } + + @Override public BigInteger getModulus() { - fetchValues(); return n; } public BigInteger getPrivateExponent() { - fetchValues(); return d; } } - private static final class P11RSAPublicKey extends P11Key + private static final class P11RSAPublicKey extends P11PublicKey implements RSAPublicKey { private static final long serialVersionUID = -826726289023854455L; - private BigInteger n, e; - private byte[] encoded; + private transient BigInteger n, e; + P11RSAPublicKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - super(PUBLIC, session, keyID, algorithm, keyLength, attributes); + int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); } + private synchronized void fetchValues() { token.ensureValid(); - if (n != null) { - return; - } - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { + if (n != null) return; + + BigInteger[] res = fetchAttributesAsInts(new CK_ATTRIBUTE[] { new CK_ATTRIBUTE(CKA_MODULUS), - new CK_ATTRIBUTE(CKA_PUBLIC_EXPONENT), - }; - fetchAttributes(attributes); - n = attributes[0].getBigInteger(); - e = attributes[1].getBigInteger(); + new CK_ATTRIBUTE(CKA_PUBLIC_EXPONENT) + }); + n = res[0]; + e = res[1]; } + public String getFormat() { token.ensureValid(); return "X.509"; } + synchronized byte[] getEncodedInternal() { token.ensureValid(); if (encoded == null) { @@ -707,6 +749,7 @@ synchronized byte[] getEncodedInternal() { } return encoded; } + public BigInteger getModulus() { fetchValues(); return n; @@ -722,40 +765,37 @@ public String toString() { } } - private static final class P11DSAPublicKey extends P11Key + private static final class P11DSAPublicKey extends P11PublicKey implements DSAPublicKey { private static final long serialVersionUID = 5989753793316396637L; - private BigInteger y; - private DSAParams params; - private byte[] encoded; + private transient BigInteger y; + private transient DSAParams params; + P11DSAPublicKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - super(PUBLIC, session, keyID, algorithm, keyLength, attributes); + int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); } + private synchronized void fetchValues() { token.ensureValid(); - if (y != null) { - return; - } - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { + if (y != null) return; + + BigInteger[] res = fetchAttributesAsInts(new CK_ATTRIBUTE[] { new CK_ATTRIBUTE(CKA_VALUE), new CK_ATTRIBUTE(CKA_PRIME), new CK_ATTRIBUTE(CKA_SUBPRIME), - new CK_ATTRIBUTE(CKA_BASE), - }; - fetchAttributes(attributes); - y = attributes[0].getBigInteger(); - params = new DSAParameterSpec( - attributes[1].getBigInteger(), - attributes[2].getBigInteger(), - attributes[3].getBigInteger() - ); + new CK_ATTRIBUTE(CKA_BASE) + }); + y = res[0]; + params = new DSAParameterSpec(res[1], res[2], res[3]); } + public String getFormat() { token.ensureValid(); return "X.509"; } + synchronized byte[] getEncodedInternal() { token.ensureValid(); if (encoded == null) { @@ -785,40 +825,76 @@ public String toString() { } } - private static final class P11DSAPrivateKey extends P11Key - implements DSAPrivateKey { + static class P11DSAPrivateKeyInternal extends P11PrivateKey { private static final long serialVersionUID = 3119629997181999389L; - private BigInteger x; - private DSAParams params; - private byte[] encoded; + protected transient DSAParams params; + + static P11DSAPrivateKeyInternal of(Session session, long keyID, + String algorithm, int keyLength, CK_ATTRIBUTE[] attrs, + boolean keySensitive) { + if (keySensitive) { + return new P11DSAPrivateKeyInternal(session, keyID, algorithm, + keyLength, attrs); + } else { + return new P11DSAPrivateKey(session, keyID, algorithm, + keyLength, attrs); + } + } + + private P11DSAPrivateKeyInternal(Session session, long keyID, + String algorithm, int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); + } + + private synchronized void fetchValues() { + token.ensureValid(); + if (params != null) return; + + BigInteger[] res = fetchAttributesAsInts(new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_PRIME), + new CK_ATTRIBUTE(CKA_SUBPRIME), + new CK_ATTRIBUTE(CKA_BASE), + }); + params = new DSAParameterSpec(res[0], res[1], res[2]); + } + + protected DSAParams getParams() { + fetchValues(); + return params; + } + } + + private static final class P11DSAPrivateKey extends P11DSAPrivateKeyInternal + implements DSAPrivateKey { + private static final long serialVersionUID = 3119629997181999389L; + + private transient BigInteger x; // params inside P11DSAPrivateKeyInternal + P11DSAPrivateKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - super(PRIVATE, session, keyID, algorithm, keyLength, attributes); + int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); } + private synchronized void fetchValues() { token.ensureValid(); - if (x != null) { - return; - } - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_VALUE), - new CK_ATTRIBUTE(CKA_PRIME), - new CK_ATTRIBUTE(CKA_SUBPRIME), - new CK_ATTRIBUTE(CKA_BASE), - }; - fetchAttributes(attributes); - x = attributes[0].getBigInteger(); - params = new DSAParameterSpec( - attributes[1].getBigInteger(), - attributes[2].getBigInteger(), - attributes[3].getBigInteger() - ); + if (x != null) return; + + BigInteger[] res = fetchAttributesAsInts(new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_VALUE), + new CK_ATTRIBUTE(CKA_PRIME), + new CK_ATTRIBUTE(CKA_SUBPRIME), + new CK_ATTRIBUTE(CKA_BASE), + }); + x = res[0]; + params = new DSAParameterSpec(res[1], res[2], res[3]); } + public String getFormat() { token.ensureValid(); return "PKCS#8"; } + synchronized byte[] getEncodedInternal() { token.ensureValid(); if (encoded == null) { @@ -829,48 +905,87 @@ synchronized byte[] getEncodedInternal() { } return encoded; } + public BigInteger getX() { fetchValues(); return x; } + + @Override public DSAParams getParams() { fetchValues(); return params; } } - private static final class P11DHPrivateKey extends P11Key + static class P11DHPrivateKeyInternal extends P11PrivateKey { + private static final long serialVersionUID = 1L; + + protected transient DHParameterSpec params; + + static P11DHPrivateKeyInternal of(Session session, long keyID, + String algorithm, int keyLength, CK_ATTRIBUTE[] attrs, + boolean keySensitive) { + if (keySensitive) { + return new P11DHPrivateKeyInternal(session, keyID, algorithm, + keyLength, attrs); + } else { + return new P11DHPrivateKey(session, keyID, algorithm, + keyLength, attrs); + } + } + + private P11DHPrivateKeyInternal(Session session, long keyID, + String algorithm, int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); + } + + private synchronized void fetchValues() { + token.ensureValid(); + if (params != null) return; + + BigInteger[] res = fetchAttributesAsInts(new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_PRIME), + new CK_ATTRIBUTE(CKA_BASE), + }); + params = new DHParameterSpec(res[0], res[1]); + } + + public DHParameterSpec getParams() { + fetchValues(); + return params; + } + } + + private static final class P11DHPrivateKey extends P11DHPrivateKeyInternal implements DHPrivateKey { private static final long serialVersionUID = -1698576167364928838L; - private BigInteger x; - private DHParameterSpec params; - private byte[] encoded; + private transient BigInteger x; // params in P11DHPrivateKeyInternal + P11DHPrivateKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - super(PRIVATE, session, keyID, algorithm, keyLength, attributes); + int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); } + private synchronized void fetchValues() { token.ensureValid(); - if (x != null) { - return; - } - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_VALUE), - new CK_ATTRIBUTE(CKA_PRIME), - new CK_ATTRIBUTE(CKA_BASE), - }; - fetchAttributes(attributes); - x = attributes[0].getBigInteger(); - params = new DHParameterSpec( - attributes[1].getBigInteger(), - attributes[2].getBigInteger() - ); + if (x != null) return; + + BigInteger[] res = fetchAttributesAsInts(new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_VALUE), + new CK_ATTRIBUTE(CKA_PRIME), + new CK_ATTRIBUTE(CKA_BASE), + }); + x = res[0]; + params = new DHParameterSpec(res[1], res[2]); } + public String getFormat() { token.ensureValid(); return "PKCS#8"; } + synchronized byte[] getEncodedInternal() { token.ensureValid(); if (encoded == null) { @@ -897,10 +1012,10 @@ public DHParameterSpec getParams() { return params; } public int hashCode() { + fetchValues(); if (!token.isValid()) { return 0; } - fetchValues(); return Objects.hash(x, params.getP(), params.getG()); } public boolean equals(Object obj) { @@ -921,38 +1036,36 @@ public boolean equals(Object obj) { } } - private static final class P11DHPublicKey extends P11Key + private static final class P11DHPublicKey extends P11PublicKey implements DHPublicKey { static final long serialVersionUID = -598383872153843657L; - private BigInteger y; - private DHParameterSpec params; - private byte[] encoded; + private transient BigInteger y; + private transient DHParameterSpec params; + P11DHPublicKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - super(PUBLIC, session, keyID, algorithm, keyLength, attributes); + int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); } + private synchronized void fetchValues() { token.ensureValid(); - if (y != null) { - return; - } - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { - new CK_ATTRIBUTE(CKA_VALUE), - new CK_ATTRIBUTE(CKA_PRIME), - new CK_ATTRIBUTE(CKA_BASE), - }; - fetchAttributes(attributes); - y = attributes[0].getBigInteger(); - params = new DHParameterSpec( - attributes[1].getBigInteger(), - attributes[2].getBigInteger() - ); + if (y != null) return; + + BigInteger[] res = fetchAttributesAsInts(new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_VALUE), + new CK_ATTRIBUTE(CKA_PRIME), + new CK_ATTRIBUTE(CKA_BASE), + }); + y = res[0]; + params = new DHParameterSpec(res[1], res[2]); } + public String getFormat() { token.ensureValid(); return "X.509"; } + synchronized byte[] getEncodedInternal() { token.ensureValid(); if (encoded == null) { @@ -1008,44 +1121,88 @@ public boolean equals(Object obj) { } } - private static final class P11ECPrivateKey extends P11Key + static class P11ECPrivateKeyInternal extends P11PrivateKey { + + private static final long serialVersionUID = 1L; + + protected transient ECParameterSpec params; + + static P11ECPrivateKeyInternal of(Session session, long keyID, + String algorithm, int keyLength, CK_ATTRIBUTE[] attrs, + boolean keySensitive) { + if (keySensitive) { + return new P11ECPrivateKeyInternal(session, keyID, algorithm, + keyLength, attrs); + } else { + return new P11ECPrivateKey(session, keyID, algorithm, + keyLength, attrs); + } + } + + private P11ECPrivateKeyInternal(Session session, long keyID, + String algorithm, int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); + } + + private synchronized void fetchValues() { + token.ensureValid(); + if (params != null) return; + + try { + byte[] paramBytes = fetchAttributes(new CK_ATTRIBUTE[] { + new CK_ATTRIBUTE(CKA_EC_PARAMS) + })[0].getByteArray(); + + params = P11ECKeyFactory.decodeParameters(paramBytes); + } catch (Exception e) { + throw new RuntimeException("Could not parse key values", e); + } + } + + protected ECParameterSpec getParams() { + fetchValues(); + return params; + } + } + + private static final class P11ECPrivateKey extends P11ECPrivateKeyInternal implements ECPrivateKey { private static final long serialVersionUID = -7786054399510515515L; - private BigInteger s; - private ECParameterSpec params; - private byte[] encoded; + private transient BigInteger s; // params in P11ECPrivateKeyInternal + P11ECPrivateKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - super(PRIVATE, session, keyID, algorithm, keyLength, attributes); + int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); } + private synchronized void fetchValues() { token.ensureValid(); - if (s != null) { - return; - } - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { + if (s != null) return; + + CK_ATTRIBUTE[] attrs = fetchAttributes(new CK_ATTRIBUTE[] { new CK_ATTRIBUTE(CKA_VALUE), - new CK_ATTRIBUTE(CKA_EC_PARAMS, params), - }; - fetchAttributes(attributes); - s = attributes[0].getBigInteger(); + new CK_ATTRIBUTE(CKA_EC_PARAMS), + }); + + s = attrs[0].getBigInteger(); try { params = P11ECKeyFactory.decodeParameters - (attributes[1].getByteArray()); + (attrs[1].getByteArray()); } catch (Exception e) { throw new RuntimeException("Could not parse key values", e); } } + public String getFormat() { token.ensureValid(); return "PKCS#8"; } + synchronized byte[] getEncodedInternal() { - token.ensureValid(); if (encoded == null) { - fetchValues(); try { + fetchValues(); Key key = ECUtil.generateECPrivateKey(s, params); encoded = key.getEncoded(); } catch (InvalidKeySpecException e) { @@ -1054,42 +1211,43 @@ synchronized byte[] getEncodedInternal() { } return encoded; } + public BigInteger getS() { fetchValues(); return s; } + public ECParameterSpec getParams() { fetchValues(); return params; } } - private static final class P11ECPublicKey extends P11Key + private static final class P11ECPublicKey extends P11PublicKey implements ECPublicKey { private static final long serialVersionUID = -6371481375154806089L; - private ECPoint w; - private ECParameterSpec params; - private byte[] encoded; + private transient ECPoint w; + private transient ECParameterSpec params; + P11ECPublicKey(Session session, long keyID, String algorithm, - int keyLength, CK_ATTRIBUTE[] attributes) { - super(PUBLIC, session, keyID, algorithm, keyLength, attributes); + int keyLength, CK_ATTRIBUTE[] attrs) { + super(session, keyID, algorithm, keyLength, attrs); } + private synchronized void fetchValues() { token.ensureValid(); - if (w != null) { - return; - } - CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { + if (w != null) return; + + CK_ATTRIBUTE[] attrs = fetchAttributes(new CK_ATTRIBUTE[] { new CK_ATTRIBUTE(CKA_EC_POINT), new CK_ATTRIBUTE(CKA_EC_PARAMS), - }; - fetchAttributes(attributes); + }); try { params = P11ECKeyFactory.decodeParameters - (attributes[1].getByteArray()); - byte[] ecKey = attributes[0].getByteArray(); + (attrs[1].getByteArray()); + byte[] ecKey = attrs[0].getByteArray(); // Check whether the X9.63 encoding of an EC point is wrapped // in an ASN.1 OCTET STRING @@ -1111,10 +1269,12 @@ private synchronized void fetchValues() { throw new RuntimeException("Could not parse key values", e); } } + public String getFormat() { token.ensureValid(); return "X.509"; } + synchronized byte[] getEncodedInternal() { token.ensureValid(); if (encoded == null) { @@ -1413,3 +1573,4 @@ void dispose() { this.clear(); } } + diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java index 091020380f038..54206ee0a066c 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java @@ -119,6 +119,9 @@ final class P11Signature extends SignatureSpi { // key instance used, if init*() was called private P11Key p11Key; + // signature length expected or 0 for unknown + private int sigLen; + // message digest, if we do the digesting ourselves private final MessageDigest md; @@ -285,7 +288,7 @@ private void cancelOperation() { try { if (mode == M_SIGN) { if (type == T_UPDATE) { - token.p11.C_SignFinal(session.id(), 0); + token.p11.C_SignFinal(session.id(), sigLen); } else { byte[] digest; if (type == T_DIGEST) { @@ -296,12 +299,7 @@ private void cancelOperation() { token.p11.C_Sign(session.id(), digest); } } else { // M_VERIFY - byte[] signature; - if (mechanism == CKM_DSA) { - signature = new byte[64]; // assume N = 256 - } else { - signature = new byte[(p11Key.length() + 7) >> 3]; - } + byte[] signature = new byte[sigLen]; if (type == T_UPDATE) { token.p11.C_VerifyFinal(session.id(), signature); } else { @@ -373,6 +371,15 @@ private void initialize() { md.reset(); } } + sigLen = 0; + if ("DSA".equals(p11Key.getAlgorithm())) { + if (p11Key instanceof P11Key.P11DSAPrivateKeyInternal) { + sigLen = ((P11Key.P11DSAPrivateKeyInternal)p11Key).getParams() + .getQ().bitLength() >> 2; + } else if (p11Key instanceof DSAKey) { + sigLen = ((DSAKey)p11Key).getParams().getQ().bitLength() >> 2; + } + } initialized = true; } @@ -618,7 +625,7 @@ protected byte[] engineSign() throws SignatureException { try { byte[] signature; if (type == T_UPDATE) { - signature = token.p11.C_SignFinal(session.id(), 0); + signature = token.p11.C_SignFinal(session.id(), sigLen); } else { byte[] digest; if (type == T_DIGEST) { @@ -685,7 +692,7 @@ protected boolean engineVerify(byte[] signature) throws SignatureException { try { if (!p1363Format) { if (keyAlgorithm.equals("DSA")) { - signature = asn1ToDSA(signature); + signature = asn1ToDSA(signature, sigLen); } else if (keyAlgorithm.equals("EC")) { signature = asn1ToECDSA(signature); } @@ -809,7 +816,8 @@ private static byte[] dsaToASN1(byte[] signature) { } } - private static byte[] asn1ToDSA(byte[] sig) throws SignatureException { + private static byte[] asn1ToDSA(byte[] sig, int sigLen) + throws SignatureException { try { // Enforce strict DER checking for signatures DerInputStream in = new DerInputStream(sig, 0, sig.length, false); @@ -824,8 +832,8 @@ private static byte[] asn1ToDSA(byte[] sig) throws SignatureException { BigInteger r = values[0].getPositiveBigInteger(); BigInteger s = values[1].getPositiveBigInteger(); - byte[] br = toByteArray(r, 20); - byte[] bs = toByteArray(s, 20); + byte[] br = toByteArray(r, sigLen/2); + byte[] bs = toByteArray(s, sigLen/2); if ((br == null) || (bs == null)) { throw new SignatureException("Out of range value for R or S"); } @@ -837,7 +845,7 @@ private static byte[] asn1ToDSA(byte[] sig) throws SignatureException { } } - private byte[] asn1ToECDSA(byte[] sig) throws SignatureException { + private static byte[] asn1ToECDSA(byte[] sig) throws SignatureException { try { // Enforce strict DER checking for signatures DerInputStream in = new DerInputStream(sig, 0, sig.length, false); @@ -917,3 +925,4 @@ protected AlgorithmParameters engineGetParameters() { return null; } } + diff --git a/test/jdk/sun/security/pkcs11/Signature/LargeDSAKey.java b/test/jdk/sun/security/pkcs11/Signature/LargeDSAKey.java new file mode 100644 index 0000000000000..a45a5ca47f544 --- /dev/null +++ b/test/jdk/sun/security/pkcs11/Signature/LargeDSAKey.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2021, 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. + */ + +import java.security.AlgorithmParameterGenerator; +import java.security.AlgorithmParameters; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.PrivateKey; +import java.security.Provider; +import java.security.PublicKey; +import java.security.SecureRandom; +import java.security.Signature; +import java.security.spec.DSAGenParameterSpec; +import java.security.spec.DSAParameterSpec; + +/* + * @test + * @bug 8271566 + * @library /test/lib .. + * @modules jdk.crypto.cryptoki + * @run main/othervm/timeout=30 LargeDSAKey + */ + +public final class LargeDSAKey extends PKCS11Test { + + private static final boolean enableDebug = false; + + private static final String knownText = + "Known text known text known text"; + + @Override + public void main(Provider p) throws Exception { + KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA", p); + AlgorithmParameterGenerator dsaParGen = + AlgorithmParameterGenerator.getInstance("DSA"); + DSAGenParameterSpec dsaParGenSpec = + new DSAGenParameterSpec(2048, 256); + dsaParGen.init(dsaParGenSpec, new SecureRandom()); + AlgorithmParameters params = dsaParGen.generateParameters(); + DSAParameterSpec dsaParams = + params.getParameterSpec(DSAParameterSpec.class); + kpg.initialize(dsaParams); + KeyPair kp = kpg.generateKeyPair(); + doTestSignature(kp, p); + } + + private static void doTestSignature(KeyPair kp, Provider p) + throws Exception { + byte[] knownTextSig = null; + Signature s = Signature.getInstance("SHA1withDSA", p); + PrivateKey privKey = kp.getPrivate(); + PublicKey pubKey = kp.getPublic(); + if (enableDebug) { + System.out.println("Signature algorithm: " + s.getAlgorithm()); + System.out.println("Signature Provider: " + s.getProvider()); + System.out.println("Private key for signature: " + privKey); + System.out.println("Public key for signature: " + pubKey); + } + s.initSign(privKey); + s.update(knownText.getBytes()); + knownTextSig = s.sign(); + s.initVerify(pubKey); + s.update(knownText.getBytes()); + if (s.verify(knownTextSig) == false) { + throw new Exception("Could not verify signature"); + } + if (enableDebug) { + System.out.println("Signature verified"); + } + } + + public static void main(String[] args) throws Throwable { + main(new LargeDSAKey()); + System.out.println("TEST PASS - OK"); + } + +} From b78a848cc7ae5787d9ec9ea0ce843cd63b06efec Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Thu, 30 Nov 2023 17:54:56 +0000 Subject: [PATCH 341/341] 8320601: ProblemList java/lang/invoke/lambda/LambdaFileEncodingSerialization.java on linux-all Backport-of: ab7380e2d9d3c340120bf9c41029c334c809291e --- test/jdk/ProblemList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 05bf219cb54d9..21edb81981ef5 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -532,7 +532,7 @@ java/lang/StringCoding/CheckEncodings.sh 7008363 generic- java/lang/ProcessHandle/InfoTest.java 8211847 aix-ppc64 java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java 8151492 generic-all java/lang/invoke/LFCaching/LFGarbageCollectedTest.java 8078602 generic-all -java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-x64 +java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-all ############################################################################