From f7ec0d23749ea4be201a494f95e41044c792a685 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 2 Nov 2023 08:03:11 +0000 Subject: [PATCH 01/16] 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 3a63408294e..a7eedd888f3 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 0fbb6b2bd00..f8899037ea5 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 6179d7bbf4b..0f207437523 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 7316f3d308733e52afd94fe71e79764a6122de58 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 2 Nov 2023 08:17:48 +0000 Subject: [PATCH 02/16] 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 8461815d771..3e5e22b53af 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 ba34e0791ee6da511b3d8fa131135d807acdb1a8 Mon Sep 17 00:00:00 2001 From: Frederic Thevenet Date: Fri, 3 Nov 2023 12:02:44 +0000 Subject: [PATCH 03/16] 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 85c6bae6399..b3afaa7fe67 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 7cac2476d14ac6063ee475db69379280d589a655 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 6 Nov 2023 06:57:17 +0000 Subject: [PATCH 04/16] 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 13882017163..dec17f01598 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 9dea3110c2b..35a949dd197 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 6a219675ad39296e3a7fe4a60222b11fbdf9cb9f Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:09:48 +0000 Subject: [PATCH 05/16] 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 339bc87be59..4ae0eaa0df3 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 57f011181dd..ef26a6bf674 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 9b584ffbd58..2de9e728666 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 b3bf6e7f291..cb4b6960cf9 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 ecd945be87f..c8b8aeba22e 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 f6e0a673f31daa9a627660ce33b15c18ea15947e Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:11:31 +0000 Subject: [PATCH 06/16] 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 3c6620b8caf..c1594462a80 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 c4bdfdf6402..5b30a52e4b7 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 cb95c3d25d8..7461cfd0b63 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 1bbb9404be78072abcdea32b7a802ec40c67809c Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:13:30 +0000 Subject: [PATCH 07/16] 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 cba4e358c4c..4bef1cce0f5 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 4b1b860492a..cc5cfccc735 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 e79bf7973b1..776cb720ae1 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 afdeeee8da380efc904fb5bec22f3af7b4e54e0e Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:15:48 +0000 Subject: [PATCH 08/16] 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 981fb332fc0..48e06159b45 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 28a4db7f264bb8e617afa962a4a04f3d67ad4bb9 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:17:51 +0000 Subject: [PATCH 09/16] 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 5c60df3a244..4d2602cdd87 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 e07743ba9fe..b7712dbdbfb 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 18eb83355498dee8a1f8012ee2b11c970d437a6d Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 6 Nov 2023 07:20:06 +0000 Subject: [PATCH 10/16] 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 5c4afc9fd03..4ee43abe774 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 bdc6fa5b73d868c77aa7cd66a52ab5bdd3ff6aee Mon Sep 17 00:00:00 2001 From: Johannes Bechberger Date: Mon, 6 Nov 2023 23:40:26 +0000 Subject: [PATCH 11/16] 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 860b5cc1903..1ea02415164 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 00000000000..d083b2a0e84 --- /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 00000000000..38253ad8875 --- /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 71b3eb28d6d..b1a1b58e458 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 ee1c0ea20cf0264eed1dabaab956dead3c490e99 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Nov 2023 10:56:45 +0000 Subject: [PATCH 12/16] 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 c1594462a80..be5acdddd75 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 4c03668cec2..8643ec35bc2 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 aab89fc2788cc21b1138ae622c8a2eeb695af033 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Nov 2023 10:59:10 +0000 Subject: [PATCH 13/16] 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 e2301138644..bea439a2eab 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 f35d6dd4e66f8762ebd2940c7692d0ad9321b110 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Nov 2023 11:10:48 +0000 Subject: [PATCH 14/16] 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 96c5dccabef..8aab97aa2bc 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 f5756bc5380c79a9b79d36373e6afd0e8ad34bb9 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Nov 2023 11:13:16 +0000 Subject: [PATCH 15/16] 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 154fa026c78..cd43a6473d1 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 43efcd5afbb..08b29fe6df1 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 d7cadbf68bdda3fe94a8b2f720f50d440e4409d3 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 7 Nov 2023 11:17:49 +0000 Subject: [PATCH 16/16] 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 a36c48ce818..f554b969f4e 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);