From d7fd5a02689c8e5f295d5132af4760cf2c78c6f3 Mon Sep 17 00:00:00 2001 From: duke Date: Mon, 16 Jun 2025 17:25:46 +0000 Subject: [PATCH 1/2] Backport f5ab7dff402a3152f5d5736cc6521b4be617eccf --- test/jdk/java/util/zip/EntryCount64k.java | 2 +- .../jdk/test/lib/process/OutputAnalyzer.java | 22 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/test/jdk/java/util/zip/EntryCount64k.java b/test/jdk/java/util/zip/EntryCount64k.java index 2dac7643de2..d8c46d22364 100644 --- a/test/jdk/java/util/zip/EntryCount64k.java +++ b/test/jdk/java/util/zip/EntryCount64k.java @@ -163,6 +163,6 @@ static void checkCanRead(File zipFile, int entryCount) throws Throwable { OutputAnalyzer a = ProcessTools.executeTestJava("-jar", zipFile.getName()); a.shouldHaveExitValue(0); a.stdoutShouldMatch("\\AMain\\Z"); - a.stderrShouldMatch("\\A\\Z"); + a.stderrShouldMatchIgnoreDeprecatedWarnings("\\A\\Z"); } } diff --git a/test/lib/jdk/test/lib/process/OutputAnalyzer.java b/test/lib/jdk/test/lib/process/OutputAnalyzer.java index 8f9ebde2426..5ea90a1c6db 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, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -641,7 +641,7 @@ public OutputAnalyzer shouldBeEmptyIgnoreVMWarnings() { /** * Verify that the stderr contents of output buffer matches the pattern, - * after filtering out the Hotespot warning messages + * after filtering out the Hotspot warning messages * * @param pattern * @throws RuntimeException If the pattern was not found @@ -657,6 +657,24 @@ public OutputAnalyzer stderrShouldMatchIgnoreVMWarnings(String pattern) { return this; } + /** + * Verify that the stderr contents of output buffer matches the pattern, + * after filtering out the Hotspot deprecation warning messages + * + * @param pattern + * @throws RuntimeException If the pattern was not found + */ + public OutputAnalyzer stderrShouldMatchIgnoreDeprecatedWarnings(String pattern) { + String stderr = getStderr().replaceAll(deprecatedmsg + "\\R", ""); + Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr); + if (!matcher.find()) { + reportDiagnosticSummary(); + throw new RuntimeException("'" + pattern + + "' missing from stderr"); + } + return this; + } + /** * Returns the contents of the output buffer (stdout and stderr), without those * JVM warning msgs, as list of strings. Output is split by newlines. From 137b9aef5b5ff6addfc7cebc0a0058686496fcf0 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 16 Jun 2025 19:37:20 +0200 Subject: [PATCH 2/2] Backport 24c5ff7ba58cb7cf93df07f81484cd8fae60e31e --- test/jdk/java/util/zip/EntryCount64k.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/util/zip/EntryCount64k.java b/test/jdk/java/util/zip/EntryCount64k.java index d8c46d22364..8830a87ea64 100644 --- a/test/jdk/java/util/zip/EntryCount64k.java +++ b/test/jdk/java/util/zip/EntryCount64k.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2013 Google Inc. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,9 +48,12 @@ import jdk.test.lib.process.ProcessTools; public class EntryCount64k { + + private static final String MAIN_CLASS_MSG = "foo bar hello world Main"; + public static class Main { public static void main(String[] args) { - System.out.print("Main"); + System.out.println(MAIN_CLASS_MSG); } } @@ -162,7 +166,10 @@ static void checkCanRead(File zipFile, int entryCount) throws Throwable { // Check java -jar OutputAnalyzer a = ProcessTools.executeTestJava("-jar", zipFile.getName()); a.shouldHaveExitValue(0); - a.stdoutShouldMatch("\\AMain\\Z"); + // expect the message from the application on stdout + a.stdoutContains(MAIN_CLASS_MSG); + // nothing is expected on stderr (apart from any probable deprecation + // warnings from the launcher/JVM) a.stderrShouldMatchIgnoreDeprecatedWarnings("\\A\\Z"); } }