From 5b8c51f59a5f23930ee43bea30201c1ff88c44cd Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Thu, 10 Jun 2021 17:19:37 +0000 Subject: [PATCH 01/13] 8268539: several serviceability/sa tests should be run in driver mode Backport-of: 78cb6776b6d43b67457993a109719b36ee892d60 --- test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java | 4 ++-- test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java | 8 ++++---- test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java | 4 ++-- .../jtreg/serviceability/sa/ClhsdbJstackXcompStress.java | 4 ++-- .../jtreg/serviceability/sa/DeadlockDetectionTest.java | 4 ++-- .../jtreg/serviceability/sa/JhsdbThreadInfoTest.java | 4 ++-- .../serviceability/sa/TestCpoolForInvokeDynamic.java | 4 ++-- .../jtreg/serviceability/sa/TestDefaultMethods.java | 4 ++-- .../serviceability/sa/TestHeapDumpForInvokeDynamic.java | 4 ++-- .../serviceability/sa/TestJhsdbJstackLineNumbers.java | 4 ++-- .../jtreg/serviceability/sa/TestJhsdbJstackLock.java | 4 ++-- .../jtreg/serviceability/sa/TestJhsdbJstackMixed.java | 4 ++-- .../jtreg/serviceability/sa/TestObjectMonitorIterate.java | 2 +- .../serviceability/sa/TestRevPtrsForInvokeDynamic.java | 4 ++-- test/hotspot/jtreg/serviceability/sa/TestSysProps.java | 4 ++-- .../sa/jmap-hprof/JMapHProfLargeHeapTest.java | 4 ++-- .../sa/sadebugd/ClhsdbAttachToDebugServer.java | 2 +- .../sa/sadebugd/ClhsdbTestConnectArgument.java | 2 +- .../serviceability/sa/sadebugd/DebugdConnectTest.java | 2 +- .../serviceability/sa/sadebugd/DisableRegistryTest.java | 2 +- .../serviceability/sa/sadebugd/PmapOnDebugdTest.java | 2 +- .../sa/sadebugd/RunCommandOnServerTest.java | 2 +- .../jtreg/serviceability/sa/sadebugd/SADebugDTest.java | 2 +- 23 files changed, 40 insertions(+), 40 deletions(-) diff --git a/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java b/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java index 8273132963d..4fd202a18da 100644 --- a/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java +++ b/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.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,7 +27,7 @@ * @summary Test the jhsdb jmap -clstats command with CDS enabled * @requires vm.hasSA & vm.cds * @library /test/lib - * @run main/othervm/timeout=2400 CDSJMapClstats + * @run driver/timeout=2400 CDSJMapClstats */ import java.util.stream.Collectors; diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java index 801a8646e8b..aae5f1bd086 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbDumpclass.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 @@ -39,7 +39,7 @@ import jtreg.SkippedException; * @summary Test clhsdb dumpclass command * @requires vm.hasSA * @library /test/lib - * @run main/othervm ClhsdbDumpclass + * @run driver ClhsdbDumpclass */ public class ClhsdbDumpclass { @@ -70,8 +70,8 @@ public class ClhsdbDumpclass { // Run javap on the generated class file to make sure it's valid. JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("javap"); launcher.addVMArgs(Utils.getTestJavaOpts()); - launcher.addToolArg(APP_DOT_CLASSNAME); - System.out.println("> javap " + APP_DOT_CLASSNAME); + launcher.addToolArg(classFile.toString()); + System.out.println("> javap " + classFile.toString()); List cmdStringList = Arrays.asList(launcher.getCommand()); ProcessBuilder pb = new ProcessBuilder(cmdStringList); Process javap = pb.start(); diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java index 1d36795bfdf..a1acaf7c60b 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.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 @@ -37,7 +37,7 @@ import jtreg.SkippedException; * @summary Test clhsdb flags command * @requires vm.hasSA * @library /test/lib - * @run main/othervm ClhsdbFlags + * @run driver ClhsdbFlags */ public class ClhsdbFlags { diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java index da872b8dad8..bd0b2282847 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.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. * Copyright (c) 2019, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,7 +38,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @requires vm.hasSA * @requires vm.opt.DeoptimizeALot != true * @library /test/lib - * @run main/othervm ClhsdbJstackXcompStress + * @run driver ClhsdbJstackXcompStress */ public class ClhsdbJstackXcompStress { diff --git a/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java b/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java index 969c366ed3a..3f0ab21412d 100644 --- a/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java +++ b/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.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 @@ -28,7 +28,7 @@ * @library /test/lib * @modules java.base/jdk.internal.misc * @modules java.management - * @run main DeadlockDetectionTest + * @run driver DeadlockDetectionTest */ import java.util.stream.Collectors; diff --git a/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java b/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java index 7cdc39175a4..c98bbc11968 100644 --- a/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java +++ b/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.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 @@ -31,7 +31,7 @@ import jdk.test.lib.Utils; * @test * @requires vm.hasSA * @library /test/lib - * @run main JhsdbThreadInfoTest + * @run driver JhsdbThreadInfoTest */ public class JhsdbThreadInfoTest { diff --git a/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java index ac2cde28810..4753c924f1e 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.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 @@ -52,7 +52,7 @@ import jdk.test.lib.Utils; * jdk.hotspot.agent/sun.jvm.hotspot.oops * jdk.hotspot.agent/sun.jvm.hotspot.debugger * jdk.hotspot.agent/sun.jvm.hotspot.ui.classbrowser - * @run main TestCpoolForInvokeDynamic + * @run driver TestCpoolForInvokeDynamic */ public class TestCpoolForInvokeDynamic { diff --git a/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java b/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java index 94baea57cb6..f674008e2f8 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java +++ b/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.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 @@ -50,7 +50,7 @@ import jdk.test.lib.Utils; * jdk.hotspot.agent/sun.jvm.hotspot.utilities * jdk.hotspot.agent/sun.jvm.hotspot.oops * jdk.hotspot.agent/sun.jvm.hotspot.debugger - * @run main TestDefaultMethods + * @run driver TestDefaultMethods */ public class TestDefaultMethods { diff --git a/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java index 028e25fd7e4..a4c3d15750a 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.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 @@ -48,7 +48,7 @@ import jdk.test.lib.hprof.model.Snapshot; * jdk.hotspot.agent/sun.jvm.hotspot.utilities * jdk.hotspot.agent/sun.jvm.hotspot.oops * jdk.hotspot.agent/sun.jvm.hotspot.debugger - * @run main/othervm TestHeapDumpForInvokeDynamic + * @run driver TestHeapDumpForInvokeDynamic */ public class TestHeapDumpForInvokeDynamic { diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java index 31e316fc8c9..5cf9b64ca67 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLineNumbers.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 @@ -39,7 +39,7 @@ import jdk.test.lib.SA.SATestUtils; * @requires os.arch=="amd64" | os.arch=="x86_64" * @requires os.family=="windows" | os.family == "linux" | os.family == "mac" * @library /test/lib - * @run main/othervm TestJhsdbJstackLineNumbers + * @run driver TestJhsdbJstackLineNumbers */ /* diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java index def56bc693f..02a2a07f250 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.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 @@ -31,7 +31,7 @@ import jdk.test.lib.Utils; * @test * @requires vm.hasSA * @library /test/lib - * @run main/othervm TestJhsdbJstackLock + * @run driver TestJhsdbJstackLock */ public class TestJhsdbJstackLock { diff --git a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java index 149a7028be8..3a83601b579 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.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 @@ -38,7 +38,7 @@ import jdk.test.lib.process.OutputAnalyzer; * @bug 8208091 * @requires (os.family == "linux") & (vm.hasSA) * @library /test/lib - * @run main/othervm TestJhsdbJstackMixed + * @run driver TestJhsdbJstackMixed */ public class TestJhsdbJstackMixed { diff --git a/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java b/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java index 5a7f0ff58e8..5f1e6c48f5f 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java +++ b/test/hotspot/jtreg/serviceability/sa/TestObjectMonitorIterate.java @@ -41,7 +41,7 @@ import jdk.test.lib.SA.SATestUtils; * @modules jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.oops * jdk.hotspot.agent/sun.jvm.hotspot.runtime - * @run main TestObjectMonitorIterate + * @run driver TestObjectMonitorIterate */ public class TestObjectMonitorIterate { diff --git a/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java b/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java index dd91bcfb4ae..da7334503db 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java +++ b/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.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 @@ -44,7 +44,7 @@ import jdk.test.lib.Utils; * @modules java.base/jdk.internal.misc * jdk.hotspot.agent/sun.jvm.hotspot * jdk.hotspot.agent/sun.jvm.hotspot.utilities - * @run main/othervm TestRevPtrsForInvokeDynamic + * @run driver TestRevPtrsForInvokeDynamic */ public class TestRevPtrsForInvokeDynamic { diff --git a/test/hotspot/jtreg/serviceability/sa/TestSysProps.java b/test/hotspot/jtreg/serviceability/sa/TestSysProps.java index 0f8e05bb994..84b9752c912 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestSysProps.java +++ b/test/hotspot/jtreg/serviceability/sa/TestSysProps.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 @@ -38,7 +38,7 @@ import jdk.test.lib.SA.SATestUtils; * @summary Test "jhsdb jinfo --sysprops", "jinfo -sysprops", and clhsdb "sysprops" commands * @requires vm.hasSA * @library /test/lib - * @run main/othervm TestSysProps + * @run driver TestSysProps */ public class TestSysProps { diff --git a/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java b/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java index dd8b4a14a56..692fc0153e3 100644 --- a/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java +++ b/test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.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 @@ -49,7 +49,7 @@ import jdk.test.lib.SA.SATestUtils; * java.management/sun.management * jdk.internal.jvmstat/sun.jvmstat.monitor * @build JMapHProfLargeHeapProc - * @run main JMapHProfLargeHeapTest + * @run driver JMapHProfLargeHeapTest */ public class JMapHProfLargeHeapTest { diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java index 8103c395386..9bf0cbb963c 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java @@ -38,7 +38,7 @@ import jtreg.SkippedException; * @requires vm.hasSA * @requires os.family != "windows" * @library /test/lib - * @run main/othervm ClhsdbAttachToDebugServer + * @run driver ClhsdbAttachToDebugServer */ public class ClhsdbAttachToDebugServer { diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java index c20ae6ec791..11c0113dc14 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java @@ -37,7 +37,7 @@ import jtreg.SkippedException; * @requires vm.hasSA * @requires os.family != "windows" * @library /test/lib - * @run main/othervm ClhsdbTestConnectArgument + * @run driver ClhsdbTestConnectArgument */ public class ClhsdbTestConnectArgument { diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java index 083462b7b83..1a5072123a3 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java @@ -30,7 +30,7 @@ * @modules java.base/jdk.internal.misc * @library /test/lib * - * @run main/othervm DebugdConnectTest + * @run driver DebugdConnectTest */ import java.io.IOException; diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java index 0cb6e90f253..feb477d87b1 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/DisableRegistryTest.java @@ -38,7 +38,7 @@ import jtreg.SkippedException; * @requires vm.hasSA * @requires os.family != "windows" * @library /test/lib - * @run main/othervm DisableRegistryTest + * @run driver DisableRegistryTest */ public class DisableRegistryTest { diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java index 0f3b54a3fa1..82c874671f9 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/PmapOnDebugdTest.java @@ -35,7 +35,7 @@ import jtreg.SkippedException; * @requires vm.hasSA * @requires (os.family != "windows") & (os.family != "mac") * @library /test/lib - * @run main/othervm PmapOnDebugdTest + * @run driver PmapOnDebugdTest */ public class PmapOnDebugdTest { diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java index 02ac4a2edda..990a9667f3f 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/RunCommandOnServerTest.java @@ -38,7 +38,7 @@ import jtreg.SkippedException; * @requires vm.hasSA * @requires os.family != "windows" * @library /test/lib - * @run main/othervm RunCommandOnServerTest + * @run driver RunCommandOnServerTest */ public class RunCommandOnServerTest { diff --git a/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java b/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java index 44936f8881d..a0bbdbc809b 100644 --- a/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java +++ b/test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java @@ -31,7 +31,7 @@ * @modules java.base/jdk.internal.misc * @library /test/lib * - * @run main/othervm SADebugDTest + * @run driver SADebugDTest */ import java.util.concurrent.TimeUnit; From 53b6e2c85cab251362d27a1cd0cd37bc7d380360 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Thu, 10 Jun 2021 18:05:16 +0000 Subject: [PATCH 02/13] 8267448: Add "ulimit -a" to environment.html Reviewed-by: cjplummer --- test/failure_handler/src/share/conf/linux.properties | 7 ++++++- test/failure_handler/src/share/conf/mac.properties | 7 ++++++- test/failure_handler/src/share/conf/windows.properties | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/failure_handler/src/share/conf/linux.properties b/test/failure_handler/src/share/conf/linux.properties index 41aa22e98fc..69ce7799d73 100644 --- a/test/failure_handler/src/share/conf/linux.properties +++ b/test/failure_handler/src/share/conf/linux.properties @@ -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 @@ -62,6 +62,7 @@ environment=\ users.current users.logged users.last \ disk \ env \ + ulimit \ system.dmesg system.sysctl \ process.top process.ps \ memory.free memory.vmstat.default memory.vmstat.statistics \ @@ -83,6 +84,10 @@ disk.args=-h env.app=env +ulimit.app=bash +ulimit.args=-c\0ulimit -a +ulimit.args.delimiter=\0 + system.dmesg.app=dmesg system.sysctl.app=sysctl system.sysctl.args=-a diff --git a/test/failure_handler/src/share/conf/mac.properties b/test/failure_handler/src/share/conf/mac.properties index 73a8366922e..df68fc29efc 100644 --- a/test/failure_handler/src/share/conf/mac.properties +++ b/test/failure_handler/src/share/conf/mac.properties @@ -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 @@ -71,6 +71,7 @@ environment=\ users.current users.logged users.last \ disk \ env \ + ulimit \ system.dmesg system.sysctl \ process.ps process.top \ memory.vmstat \ @@ -91,6 +92,10 @@ disk.args=-h env.app=env +ulimit.app=bash +ulimit.args=-c\0ulimit -a +ulimit.args.delimiter=\0 + system.dmesg.app=dmesg system.sysctl.app=sysctl system.sysctl.args=-a diff --git a/test/failure_handler/src/share/conf/windows.properties b/test/failure_handler/src/share/conf/windows.properties index c1512128e36..6f64a5c7d0b 100644 --- a/test/failure_handler/src/share/conf/windows.properties +++ b/test/failure_handler/src/share/conf/windows.properties @@ -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 @@ -66,6 +66,7 @@ environment=\ users.current users.logged \ disk \ env \ + ulimit \ system.events.system system.events.application system.os \ process.top process.ps process.tasklist \ memory.free memory.vmstat.default memory.vmstat.statistics \ @@ -84,6 +85,10 @@ disk.args=-h env.app=env +ulimit.app=bash +ulimit.args=-c\0ulimit -a +ulimit.args.delimiter=\0 + system.events.app=powershell system.events.delimiter=\0 system.events.system.args=-NoLogo\0-Command\0Get-EventLog System -After (Get-Date).AddDays(-1) | Format-List From 7b2e7d8bab890bd655093976cc9c3b0b6d00c034 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Thu, 10 Jun 2021 22:18:38 +0000 Subject: [PATCH 03/13] 8268525: Some new memory leak after JDK-8248268 and JDK-8255557 Reviewed-by: valeriep, ascarpino --- .../com/sun/crypto/provider/CipherCore.java | 80 ++++++++-------- .../sun/crypto/provider/ConstructKeys.java | 91 +++++-------------- .../crypto/provider/GaloisCounterMode.java | 8 +- .../com/sun/crypto/provider/KWUtil.java | 1 + .../sun/crypto/provider/KeyWrapCipher.java | 19 +++- 5 files changed, 91 insertions(+), 108 deletions(-) diff --git a/src/java.base/share/classes/com/sun/crypto/provider/CipherCore.java b/src/java.base/share/classes/com/sun/crypto/provider/CipherCore.java index acef059d20a..b7231649413 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/CipherCore.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/CipherCore.java @@ -435,50 +435,54 @@ final class CipherCore { byte[] keyBytes = getKeyBytes(key); byte[] ivBytes = null; - if (params != null) { - if (params instanceof IvParameterSpec) { - ivBytes = ((IvParameterSpec) params).getIV(); - if ((ivBytes == null) || (ivBytes.length != blockSize)) { + try { + if (params != null) { + if (params instanceof IvParameterSpec) { + ivBytes = ((IvParameterSpec) params).getIV(); + if ((ivBytes == null) || (ivBytes.length != blockSize)) { + throw new InvalidAlgorithmParameterException + ("Wrong IV length: must be " + blockSize + + " bytes long"); + } + } else if (params instanceof RC2ParameterSpec) { + ivBytes = ((RC2ParameterSpec) params).getIV(); + if ((ivBytes != null) && (ivBytes.length != blockSize)) { + throw new InvalidAlgorithmParameterException + ("Wrong IV length: must be " + blockSize + + " bytes long"); + } + } else { throw new InvalidAlgorithmParameterException - ("Wrong IV length: must be " + blockSize + - " bytes long"); + ("Unsupported parameter: " + params); } - } else if (params instanceof RC2ParameterSpec) { - ivBytes = ((RC2ParameterSpec) params).getIV(); - if ((ivBytes != null) && (ivBytes.length != blockSize)) { + } + if (cipherMode == ECB_MODE) { + if (ivBytes != null) { throw new InvalidAlgorithmParameterException - ("Wrong IV length: must be " + blockSize + - " bytes long"); + ("ECB mode cannot use IV"); } - } else { - throw new InvalidAlgorithmParameterException - ("Unsupported parameter: " + params); + } else if (ivBytes == null) { + if (decrypting) { + throw new InvalidAlgorithmParameterException("Parameters " + + "missing"); + } + + if (random == null) { + random = SunJCE.getRandom(); + } + + ivBytes = new byte[blockSize]; + random.nextBytes(ivBytes); } + + buffered = 0; + diffBlocksize = blockSize; + + String algorithm = key.getAlgorithm(); + cipher.init(decrypting, algorithm, keyBytes, ivBytes); + } finally { + Arrays.fill(keyBytes, (byte)0); } - if (cipherMode == ECB_MODE) { - if (ivBytes != null) { - throw new InvalidAlgorithmParameterException - ("ECB mode cannot use IV"); - } - } else if (ivBytes == null) { - if (decrypting) { - throw new InvalidAlgorithmParameterException("Parameters " - + "missing"); - } - - if (random == null) { - random = SunJCE.getRandom(); - } - - ivBytes = new byte[blockSize]; - random.nextBytes(ivBytes); - } - - buffered = 0; - diffBlocksize = blockSize; - - String algorithm = key.getAlgorithm(); - cipher.init(decrypting, algorithm, keyBytes, ivBytes); } void init(int opmode, Key key, AlgorithmParameters params, diff --git a/src/java.base/share/classes/com/sun/crypto/provider/ConstructKeys.java b/src/java.base/share/classes/com/sun/crypto/provider/ConstructKeys.java index 9854f909eb1..68c2c830df6 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/ConstructKeys.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/ConstructKeys.java @@ -25,6 +25,8 @@ package com.sun.crypto.provider; +import jdk.internal.access.SharedSecrets; + import java.security.Key; import java.security.PublicKey; import java.security.PrivateKey; @@ -48,24 +50,18 @@ import javax.crypto.spec.SecretKeySpec; */ final class ConstructKeys { - /** - * Construct a public key from its encoding. - * - * @param encodedKey the encoding of a public key. - * - * @param encodedKeyAlgorithm the algorithm the encodedKey is for. - * - * @return a public key constructed from the encodedKey. - */ + private static final PublicKey constructPublicKey(byte[] encodedKey, - String encodedKeyAlgorithm) + int ofs, int len, String encodedKeyAlgorithm) throws InvalidKeyException, NoSuchAlgorithmException { PublicKey key = null; + byte[] keyBytes = (ofs == 0 && encodedKey.length == len) + ? encodedKey : Arrays.copyOfRange(encodedKey, ofs, ofs + len); + X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes); try { KeyFactory keyFactory = KeyFactory.getInstance(encodedKeyAlgorithm, SunJCE.getInstance()); - X509EncodedKeySpec keySpec = new X509EncodedKeySpec(encodedKey); key = keyFactory.generatePublic(keySpec); } catch (NoSuchAlgorithmException nsae) { // Try to see whether there is another @@ -73,8 +69,6 @@ final class ConstructKeys { try { KeyFactory keyFactory = KeyFactory.getInstance(encodedKeyAlgorithm); - X509EncodedKeySpec keySpec = - new X509EncodedKeySpec(encodedKey); key = keyFactory.generatePublic(keySpec); } catch (NoSuchAlgorithmException nsae2) { throw new NoSuchAlgorithmException("No installed providers " + @@ -97,25 +91,17 @@ final class ConstructKeys { return key; } - /** - * Construct a private key from its encoding. - * - * @param encodedKey the encoding of a private key. - * - * @param encodedKeyAlgorithm the algorithm the wrapped key is for. - * - * @return a private key constructed from the encodedKey. - */ private static final PrivateKey constructPrivateKey(byte[] encodedKey, - String encodedKeyAlgorithm) + int ofs, int len, String encodedKeyAlgorithm) throws InvalidKeyException, NoSuchAlgorithmException { PrivateKey key = null; - + byte[] keyBytes = (ofs == 0 && encodedKey.length == len) + ? encodedKey : Arrays.copyOfRange(encodedKey, ofs, ofs + len); + PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes); try { KeyFactory keyFactory = KeyFactory.getInstance(encodedKeyAlgorithm, SunJCE.getInstance()); - PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey); return keyFactory.generatePrivate(keySpec); } catch (NoSuchAlgorithmException nsae) { // Try to see whether there is another @@ -123,8 +109,6 @@ final class ConstructKeys { try { KeyFactory keyFactory = KeyFactory.getInstance(encodedKeyAlgorithm); - PKCS8EncodedKeySpec keySpec = - new PKCS8EncodedKeySpec(encodedKey); key = keyFactory.generatePrivate(keySpec); } catch (NoSuchAlgorithmException nsae2) { throw new NoSuchAlgorithmException("No installed providers " + @@ -142,20 +126,16 @@ final class ConstructKeys { new InvalidKeyException("Cannot construct private key"); ike.initCause(ikse); throw ike; + } finally { + SharedSecrets.getJavaSecuritySpecAccess().clearEncodedKeySpec(keySpec); + if (keyBytes != encodedKey) { + Arrays.fill(keyBytes, (byte)0); + } } return key; } - /** - * Construct a secret key from its encoding. - * - * @param encodedKey the encoding of a secret key. - * - * @param encodedKeyAlgorithm the algorithm the secret key is for. - * - * @return a secret key constructed from the encodedKey. - */ private static final SecretKey constructSecretKey(byte[] encodedKey, int ofs, int len, String encodedKeyAlgorithm) { return (new SecretKeySpec(encodedKey, ofs, len, encodedKeyAlgorithm)); @@ -170,35 +150,14 @@ final class ConstructKeys { static final Key constructKey(byte[] encoding, int ofs, int len, String keyAlgorithm, int keyType) throws InvalidKeyException, NoSuchAlgorithmException { - switch (keyType) { - case Cipher.SECRET_KEY: - try { - return ConstructKeys.constructSecretKey(encoding, ofs, len, - keyAlgorithm); - } finally { - Arrays.fill(encoding, ofs, len, (byte)0); - } - case Cipher.PRIVATE_KEY: - byte[] encoding2 = encoding; - try { - if (ofs != 0 || len != encoding.length) { - encoding2 = Arrays.copyOfRange(encoding, ofs, ofs + len); - } - return ConstructKeys.constructPrivateKey(encoding2, - keyAlgorithm); - } finally { - Arrays.fill(encoding, ofs, len, (byte)0); - if (encoding2 != encoding) { - Arrays.fill(encoding2, (byte)0); - } - } - case Cipher.PUBLIC_KEY: - if (ofs != 0 || len != encoding.length) { - encoding = Arrays.copyOfRange(encoding, ofs, ofs + len); - } - return ConstructKeys.constructPublicKey(encoding, keyAlgorithm); - default: - throw new NoSuchAlgorithmException("Unsupported key type"); - } + return switch (keyType) { + case Cipher.SECRET_KEY -> ConstructKeys.constructSecretKey( + encoding, ofs, len, keyAlgorithm); + case Cipher.PRIVATE_KEY -> ConstructKeys.constructPrivateKey( + encoding, ofs, len, keyAlgorithm); + case Cipher.PUBLIC_KEY -> ConstructKeys.constructPublicKey( + encoding, ofs, len, keyAlgorithm); + default -> throw new NoSuchAlgorithmException("Unsupported key type"); + }; } } 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 f43160eb9be..fee6082de99 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 @@ -163,7 +163,13 @@ abstract class GaloisCounterMode extends CipherSpi { reInit = false; // always encrypt mode for embedded cipher - blockCipher.init(false, key.getAlgorithm(), keyValue); + try { + blockCipher.init(false, key.getAlgorithm(), keyValue); + } finally { + if (!encryption) { + Arrays.fill(keyValue, (byte) 0); + } + } } @Override diff --git a/src/java.base/share/classes/com/sun/crypto/provider/KWUtil.java b/src/java.base/share/classes/com/sun/crypto/provider/KWUtil.java index 38cf7511eef..7892ca198a8 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/KWUtil.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/KWUtil.java @@ -124,6 +124,7 @@ class KWUtil { } } System.arraycopy(buffer, 0, icvOut, 0, SEMI_BLKSIZE); + Arrays.fill(buffer, (byte)0); return inLen - SEMI_BLKSIZE; } } diff --git a/src/java.base/share/classes/com/sun/crypto/provider/KeyWrapCipher.java b/src/java.base/share/classes/com/sun/crypto/provider/KeyWrapCipher.java index 786d8c5f440..8bec05fe15e 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/KeyWrapCipher.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/KeyWrapCipher.java @@ -472,7 +472,11 @@ abstract class KeyWrapCipher extends CipherSpi { int outLen = engineDoFinal(in, inOfs, inLen, out, 0); if (outLen < estOutLen) { - return Arrays.copyOf(out, outLen); + try { + return Arrays.copyOf(out, outLen); + } finally { + Arrays.fill(out, (byte)0); + } } else { return out; } @@ -529,6 +533,9 @@ abstract class KeyWrapCipher extends CipherSpi { return outLen; } } finally { + if (dataBuf != null) { + Arrays.fill(dataBuf, (byte)0); + } dataBuf = null; dataIdx = 0; } @@ -559,8 +566,14 @@ abstract class KeyWrapCipher extends CipherSpi { len += inLen; } - return (opmode == Cipher.ENCRYPT_MODE? - helperEncrypt(out, len) : helperDecrypt(out, len)); + try { + return (opmode == Cipher.ENCRYPT_MODE ? + helperEncrypt(out, len) : helperDecrypt(out, len)); + } finally { + if (dataBuf != null && dataBuf != out) { + Arrays.fill(dataBuf, (byte)0); + } + } } // helper routine for in-place encryption. From e3eef3b41ab22b3fb1e4ee33ce4a3d3457d35ff1 Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Fri, 11 Jun 2021 02:47:42 +0000 Subject: [PATCH 04/13] 8268576: jdk/jfr/event/gc/collection/TestSystemGc.java fails Reviewed-by: egahlin, dholmes --- .../event/gc/collection/{TestSystemGc.java => TestSystemGC.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/jdk/jdk/jfr/event/gc/collection/{TestSystemGc.java => TestSystemGC.java} (100%) diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestSystemGc.java b/test/jdk/jdk/jfr/event/gc/collection/TestSystemGC.java similarity index 100% rename from test/jdk/jdk/jfr/event/gc/collection/TestSystemGc.java rename to test/jdk/jdk/jfr/event/gc/collection/TestSystemGC.java From bd9c2fa73b61d2461fc44b6056437aee294c9082 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Fri, 11 Jun 2021 03:12:50 +0000 Subject: [PATCH 05/13] 8268565: runtime/records/RedefineRecord.java should be run in driver mode Backport-of: 94d0b0f9810bd1a8da06ec267a1c7589d6cb756b --- test/hotspot/jtreg/runtime/records/RedefineRecord.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/records/RedefineRecord.java b/test/hotspot/jtreg/runtime/records/RedefineRecord.java index 4df907cd335..a07af3fa45f 100644 --- a/test/hotspot/jtreg/runtime/records/RedefineRecord.java +++ b/test/hotspot/jtreg/runtime/records/RedefineRecord.java @@ -29,8 +29,8 @@ * @modules java.base/jdk.internal.misc * @modules java.instrument * @requires vm.jvmti - * @run main RedefineRecord buildagent - * @run main/othervm/timeout=6000 RedefineRecord runtest + * @run driver RedefineRecord buildagent + * @run driver/timeout=6000 RedefineRecord runtest */ import java.io.FileNotFoundException; From a437ce839f749dab8c42611e0190ece5bea5d255 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Fri, 11 Jun 2021 05:05:23 +0000 Subject: [PATCH 06/13] 8268580: runtime/memory/LargePages/TestLargePagesFlags.java should be run in driver mode Reviewed-by: dholmes --- .../jtreg/runtime/memory/LargePages/TestLargePagesFlags.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java b/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java index 26b8abda910..3d70740c1c2 100644 --- a/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java +++ b/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePagesFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, 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 @@ -28,7 +28,7 @@ * @library /test/lib * @modules java.base/jdk.internal.misc * java.management - * @run main TestLargePagesFlags + * @run driver TestLargePagesFlags */ import jdk.test.lib.process.OutputAnalyzer; From da043e99b830fa4fcbfdbdbed182abc394ba6fb1 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Fri, 11 Jun 2021 08:42:14 +0000 Subject: [PATCH 07/13] 8268555: Update HttpClient tests that use ITestContext to jtreg 6+1 Reviewed-by: chegar --- .../AbstractThrowingPublishers.java | 31 ++++++++++-- .../AbstractThrowingPushPromises.java | 31 ++++++++++-- .../AbstractThrowingSubscribers.java | 31 ++++++++++-- .../httpclient/AggregateRequestBodyTest.java | 39 +++++++++++++-- .../net/httpclient/CancelRequestTest.java | 31 ++++++++++-- .../net/httpclient/ForbiddenHeadTest.java | 31 ++++++++++-- .../java/net/httpclient/ISO_8859_1_Test.java | 29 ++++++++++-- .../net/httpclient/ProxySelectorTest.java | 30 +++++++++++- .../net/httpclient/Response204V2Test.java | 32 +++++++++++-- .../net/httpclient/ShortResponseBody.java | 47 ++++++++++++++++++- 10 files changed, 304 insertions(+), 28 deletions(-) diff --git a/test/jdk/java/net/httpclient/AbstractThrowingPublishers.java b/test/jdk/java/net/httpclient/AbstractThrowingPublishers.java index 5f1ddc9817c..646a5cff2a5 100644 --- a/test/jdk/java/net/httpclient/AbstractThrowingPublishers.java +++ b/test/jdk/java/net/httpclient/AbstractThrowingPublishers.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. * 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 @@ 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; @@ -50,6 +52,7 @@ import java.net.http.HttpResponse.BodyHandler; import java.net.http.HttpResponse.BodyHandlers; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.EnumSet; import java.util.List; import java.util.Set; @@ -63,6 +66,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Flow; import java.util.concurrent.SubmissionPublisher; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiPredicate; import java.util.function.Consumer; import java.util.function.Supplier; @@ -138,17 +142,37 @@ public abstract class AbstractThrowingPublishers implements HttpServerAdapters { 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) { - throw new RuntimeException("some tests failed"); + 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() { + static final void printFailedTests(ITestContext context) { out.println("\n========================="); try { + // Exceptions should already have been added to FAILURES + // var failed = context.getFailedTests().getAllResults().stream() + // .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + // FAILURES.putAll(failed); + out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -385,6 +409,7 @@ public abstract class AbstractThrowingPublishers implements HttpServerAdapters { boolean async, Set whereValues) throws Exception { + checkSkip(); out.printf("%n%s%s%n", now(), name); try { testThrowing(uri, sameClient, publishers, finisher, thrower, async, whereValues); diff --git a/test/jdk/java/net/httpclient/AbstractThrowingPushPromises.java b/test/jdk/java/net/httpclient/AbstractThrowingPushPromises.java index caa7046fe3e..2c15ec67b21 100644 --- a/test/jdk/java/net/httpclient/AbstractThrowingPushPromises.java +++ b/test/jdk/java/net/httpclient/AbstractThrowingPushPromises.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. * 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,6 +43,8 @@ import jdk.test.lib.net.SimpleSSLContext; import org.testng.ITestContext; +import org.testng.ITestResult; +import org.testng.SkipException; import org.testng.annotations.AfterTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeMethod; @@ -68,6 +70,7 @@ import java.net.http.HttpResponse.BodySubscriber; import java.net.http.HttpResponse.PushPromiseHandler; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -79,6 +82,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.Flow; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiPredicate; import java.util.function.Consumer; import java.util.function.Function; @@ -151,17 +155,37 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters 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) { - throw new RuntimeException("some tests failed"); + 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() { + static final void printFailedTests(ITestContext context) { out.println("\n========================="); try { + // Exceptions should already have been added to FAILURES + // var failed = context.getFailedTests().getAllResults().stream() + // .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + // FAILURES.putAll(failed); + out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -360,6 +384,7 @@ public abstract class AbstractThrowingPushPromises implements HttpServerAdapters Finisher finisher, Thrower thrower) throws Exception { + checkSkip(); out.printf("%n%s%s%n", now(), name); try { testThrowing(uri, sameClient, handlers, finisher, thrower); diff --git a/test/jdk/java/net/httpclient/AbstractThrowingSubscribers.java b/test/jdk/java/net/httpclient/AbstractThrowingSubscribers.java index d25aeb1b6a4..f6682b73f47 100644 --- a/test/jdk/java/net/httpclient/AbstractThrowingSubscribers.java +++ b/test/jdk/java/net/httpclient/AbstractThrowingSubscribers.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. * 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 @@ 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.AfterTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeMethod; @@ -52,6 +54,7 @@ import java.net.http.HttpResponse.BodyHandlers; import java.net.http.HttpResponse.BodySubscriber; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.EnumSet; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -62,6 +65,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.Flow; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; @@ -137,17 +141,37 @@ public abstract class AbstractThrowingSubscribers implements HttpServerAdapters 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) { - throw new RuntimeException("some tests failed"); + 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() { + static final void printFailedTests(ITestContext context) { out.println("\n========================="); try { + // Exceptions should already have been added to FAILURES + // var failed = context.getFailedTests().getAllResults().stream() + // .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + // FAILURES.putAll(failed); + out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -379,6 +403,7 @@ public abstract class AbstractThrowingSubscribers implements HttpServerAdapters boolean async, EnumSet excludes) throws Exception { + checkSkip(); out.printf("%n%s%s%n", now(), name); try { testThrowing(uri, sameClient, handlers, finisher, thrower, async, excludes); diff --git a/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java b/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java index 2ab6feb9936..05d27547a15 100644 --- a/test/jdk/java/net/httpclient/AggregateRequestBodyTest.java +++ b/test/jdk/java/net/httpclient/AggregateRequestBodyTest.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 @@ -47,6 +47,7 @@ import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import java.nio.ByteBuffer; +import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -63,6 +64,7 @@ import java.util.concurrent.Flow.Subscription; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -76,6 +78,8 @@ import com.sun.net.httpserver.HttpsServer; import jdk.test.lib.net.SimpleSSLContext; import org.testng.Assert; 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; @@ -151,17 +155,36 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { 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) { - throw new RuntimeException("some tests failed"); + 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() { + static final void printFailedTests(ITestContext context) { out.println("\n========================="); try { + var failed = context.getFailedTests().getAllResults().stream() + .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + FAILURES.putAll(failed); + out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -446,6 +469,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { @Test(dataProvider = "sparseContent") // checks that NPE is thrown public void testNullPointerException(String description, String[] content) { + checkSkip(); BodyPublisher[] publishers = publishers(content); Assert.assertThrows(NullPointerException.class, () -> BodyPublishers.concat(publishers)); } @@ -453,6 +477,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { // Verifies that an empty array creates a "noBody" publisher @Test public void testEmpty() { + checkSkip(); BodyPublisher publisher = BodyPublishers.concat(); RequestSubscriber subscriber = new RequestSubscriber(); assertEquals(publisher.contentLength(), 0); @@ -466,6 +491,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { // verifies that error emitted by upstream publishers are propagated downstream. @Test(dataProvider = "sparseContent") // nulls are replaced with error publisher public void testOnError(String description, String[] content) { + checkSkip(); final RequestSubscriber subscriber = new RequestSubscriber(); final PublishWithError errorPublisher; final BodyPublisher[] publishers; @@ -521,6 +547,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { // the length should be known. @Test(dataProvider = "sparseContent") // nulls are replaced with unknown length public void testUnknownContentLength(String description, String[] content) { + checkSkip(); if (content == null) { content = BODIES.toArray(String[]::new); description = "BODIES (known length)"; @@ -561,6 +588,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { @Test(dataProvider = "negativeRequests") public void testNegativeRequest(long n) { + checkSkip(); assert n <= 0 : "test for negative request called with n > 0 : " + n; BodyPublisher[] publishers = ContentLengthPublisher.of(List.of(1L, 2L, 3L)); BodyPublisher publisher = BodyPublishers.concat(publishers); @@ -584,6 +612,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { @Test public void testPositiveRequests() { + checkSkip(); // A composite array of publishers BodyPublisher[] publishers = Stream.of( Stream.of(ofStrings("Lorem", " ", "ipsum", " ")), @@ -626,6 +655,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { @Test(dataProvider = "contentLengths") public void testContentLength(long expected, List lengths) { + checkSkip(); BodyPublisher[] publishers = ContentLengthPublisher.of(lengths); BodyPublisher aggregate = BodyPublishers.concat(publishers); assertEquals(aggregate.contentLength(), expected, @@ -636,6 +666,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { // publishers are no longer subscribed etc... @Test public void testCancel() { + checkSkip(); BodyPublisher[] publishers = BODIES.stream() .map(BodyPublishers::ofString) .toArray(BodyPublisher[]::new); @@ -695,6 +726,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { // Verifies that cancelling the subscription is propagated downstream @Test public void testCancelSubscription() { + checkSkip(); PublishWithError upstream = new PublishWithError(BODIES, BODIES.size(), () -> new AssertionError("should not come here")); BodyPublisher publisher = BodyPublishers.concat(upstream); @@ -756,6 +788,7 @@ public class AggregateRequestBodyTest implements HttpServerAdapters { @Test(dataProvider = "variants") public void test(String uri, boolean sameClient) throws Exception { + checkSkip(); System.out.println("Request to " + uri); HttpClient client = newHttpClient(sameClient); diff --git a/test/jdk/java/net/httpclient/CancelRequestTest.java b/test/jdk/java/net/httpclient/CancelRequestTest.java index f40a95a8f7f..de48316a25b 100644 --- a/test/jdk/java/net/httpclient/CancelRequestTest.java +++ b/test/jdk/java/net/httpclient/CancelRequestTest.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 @@ -45,6 +45,8 @@ import com.sun.net.httpserver.HttpsServer; import jdk.test.lib.RandomFactory; 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; @@ -65,6 +67,7 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandler; import java.net.http.HttpResponse.BodyHandlers; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Random; @@ -77,6 +80,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -149,16 +153,34 @@ public class CancelRequestTest implements HttpServerAdapters { 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) { - throw new RuntimeException("some tests failed"); + 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() { + 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()); @@ -275,6 +297,7 @@ public class CancelRequestTest implements HttpServerAdapters { @Test(dataProvider = "asyncurls") public void testGetSendAsync(String uri, boolean sameClient, boolean mayInterruptIfRunning) throws Exception { + checkSkip(); HttpClient client = null; uri = uri + "/get"; out.printf("%n%s testGetSendAsync(%s, %b, %b)%n", now(), uri, sameClient, mayInterruptIfRunning); @@ -360,6 +383,7 @@ public class CancelRequestTest implements HttpServerAdapters { @Test(dataProvider = "asyncurls") public void testPostSendAsync(String uri, boolean sameClient, boolean mayInterruptIfRunning) throws Exception { + checkSkip(); uri = uri + "/post"; HttpClient client = null; out.printf("%n%s testPostSendAsync(%s, %b, %b)%n", now(), uri, sameClient, mayInterruptIfRunning); @@ -463,6 +487,7 @@ public class CancelRequestTest implements HttpServerAdapters { @Test(dataProvider = "urls") public void testPostInterrupt(String uri, boolean sameClient) throws Exception { + checkSkip(); HttpClient client = null; out.printf("%n%s testPostInterrupt(%s, %b)%n", now(), uri, sameClient); for (int i=0; i< ITERATION_COUNT; i++) { diff --git a/test/jdk/java/net/httpclient/ForbiddenHeadTest.java b/test/jdk/java/net/httpclient/ForbiddenHeadTest.java index aa9c8112213..950676d74c8 100644 --- a/test/jdk/java/net/httpclient/ForbiddenHeadTest.java +++ b/test/jdk/java/net/httpclient/ForbiddenHeadTest.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 @@ -49,6 +49,8 @@ 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; @@ -72,6 +74,7 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; @@ -80,6 +83,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import static java.lang.System.err; import static java.lang.System.out; @@ -148,17 +152,37 @@ public class ForbiddenHeadTest implements HttpServerAdapters { 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) { - throw new RuntimeException("some tests failed"); + 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() { + static final void printFailedTests(ITestContext context) { out.println("\n========================="); try { + // Exceptions should already have been added to FAILURES + // var failed = context.getFailedTests().getAllResults().stream() + // .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + // FAILURES.putAll(failed); + out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -219,6 +243,7 @@ public class ForbiddenHeadTest implements HttpServerAdapters { @Test(dataProvider = "all") void test(String uriString, int code, boolean async, HttpClient client) throws Throwable { + checkSkip(); var name = String.format("test(%s, %d, %s, %s)", uriString, code, async ? "async" : "sync", client.authenticator().isPresent() ? "authClient" : "noAuthClient"); out.printf("%n---- starting %s ----%n", name); diff --git a/test/jdk/java/net/httpclient/ISO_8859_1_Test.java b/test/jdk/java/net/httpclient/ISO_8859_1_Test.java index 256e42ac30f..e4585b22383 100644 --- a/test/jdk/java/net/httpclient/ISO_8859_1_Test.java +++ b/test/jdk/java/net/httpclient/ISO_8859_1_Test.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 @@ -55,6 +55,7 @@ import java.net.http.HttpResponse.BodyHandlers; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -72,6 +73,7 @@ import java.util.concurrent.Flow.Subscription; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -85,6 +87,8 @@ import com.sun.net.httpserver.HttpsServer; import jdk.test.lib.net.SimpleSSLContext; import org.testng.Assert; 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; @@ -162,17 +166,36 @@ public class ISO_8859_1_Test implements HttpServerAdapters { 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) { - throw new RuntimeException("some tests failed"); + 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() { + static final void printFailedTests(ITestContext context) { out.println("\n========================="); try { + var failed = context.getFailedTests().getAllResults().stream() + .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + FAILURES.putAll(failed); + out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; diff --git a/test/jdk/java/net/httpclient/ProxySelectorTest.java b/test/jdk/java/net/httpclient/ProxySelectorTest.java index b2a8c450ab8..7b4a3c8ed43 100644 --- a/test/jdk/java/net/httpclient/ProxySelectorTest.java +++ b/test/jdk/java/net/httpclient/ProxySelectorTest.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 @@ -50,6 +50,8 @@ 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; @@ -70,6 +72,7 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; +import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; @@ -78,6 +81,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; import static java.lang.System.err; import static java.lang.System.out; @@ -148,10 +153,25 @@ public class ProxySelectorTest implements HttpServerAdapters { 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) { - throw new RuntimeException("some tests failed"); + if (skiptests.get() == null) { + SkipException skip = new SkipException("some tests failed"); + skip.setStackTrace(new StackTraceElement[0]); + skiptests.compareAndSet(null, skip); + } } } @@ -159,6 +179,11 @@ public class ProxySelectorTest implements HttpServerAdapters { static final void printFailedTests() { out.println("\n========================="); try { + // Exceptions should already have been added to FAILURES + // var failed = context.getFailedTests().getAllResults().stream() + // .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + // FAILURES.putAll(failed); + out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -210,6 +235,7 @@ public class ProxySelectorTest implements HttpServerAdapters { void test(Schemes scheme, HttpClient.Version version, String uri, boolean async) throws Throwable { + checkSkip(); var name = String.format("test(%s, %s, %s)", scheme, version, async); out.printf("%n---- starting %s ----%n", name); diff --git a/test/jdk/java/net/httpclient/Response204V2Test.java b/test/jdk/java/net/httpclient/Response204V2Test.java index 75c82ba48f7..7711ba382ed 100644 --- a/test/jdk/java/net/httpclient/Response204V2Test.java +++ b/test/jdk/java/net/httpclient/Response204V2Test.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 @@ -48,14 +48,20 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; +import java.util.Arrays; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + 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; @@ -123,17 +129,36 @@ public class Response204V2Test implements HttpServerAdapters { 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) { - throw new RuntimeException("some tests failed"); + 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() { + static final void printFailedTests(ITestContext context) { out.println("\n========================="); try { + var failed = context.getFailedTests().getAllResults().stream() + .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + FAILURES.putAll(failed); + out.printf("%n%sCreated %d servers and %d clients%n", now(), serverCount.get(), clientCount.get()); if (FAILURES.isEmpty()) return; @@ -220,6 +245,7 @@ public class Response204V2Test implements HttpServerAdapters { @Test(dataProvider = "variants") public void test(String uri, boolean sameClient) throws Exception { + checkSkip(); System.out.println("Request to " + uri); HttpClient client = newHttpClient(sameClient); diff --git a/test/jdk/java/net/httpclient/ShortResponseBody.java b/test/jdk/java/net/httpclient/ShortResponseBody.java index dd1bb173dc3..4aac8f7071a 100644 --- a/test/jdk/java/net/httpclient/ShortResponseBody.java +++ b/test/jdk/java/net/httpclient/ShortResponseBody.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 @@ -54,9 +54,14 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; import java.util.stream.Stream; 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.BeforeMethod; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; @@ -107,10 +112,44 @@ public class ShortResponseBody { }; final ExecutorService service = Executors.newCachedThreadPool(factory); + 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 (context.getFailedTests().size() > 0) { - throw new RuntimeException("some tests failed"); + 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=========================\n"); + try { + var FAILURES = context.getFailedTests().getAllResults().stream() + .collect(Collectors.toMap(r -> name(r), ITestResult::getThrowable)); + + 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); + e.getValue().printStackTrace(); + }); + } finally { + out.println("\n=========================\n"); } } @@ -228,6 +267,7 @@ public class ShortResponseBody { void testSynchronousGET(String url, String expectedMsg, boolean sameClient) throws Exception { + checkSkip(); out.print("---\n"); HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { @@ -253,6 +293,7 @@ public class ShortResponseBody { void testAsynchronousGET(String url, String expectedMsg, boolean sameClient) throws Exception { + checkSkip(); out.print("---\n"); HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { @@ -335,6 +376,7 @@ public class ShortResponseBody { void testSynchronousPOST(String url, String expectedMsg, boolean sameClient) throws Exception { + checkSkip(); out.print("---\n"); HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { @@ -368,6 +410,7 @@ public class ShortResponseBody { void testAsynchronousPOST(String url, String expectedMsg, boolean sameClient) throws Exception { + checkSkip(); out.print("---\n"); HttpClient client = null; for (int i=0; i< ITERATION_COUNT; i++) { From cce8da2c60812873b63de4e65bc992bc6d825fe1 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Fri, 11 Jun 2021 12:40:44 +0000 Subject: [PATCH 08/13] 8268602: a couple runtime/os tests don't check exit code Reviewed-by: dholmes --- test/hotspot/jtreg/runtime/os/AvailableProcessors.java | 3 ++- test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/os/AvailableProcessors.java b/test/hotspot/jtreg/runtime/os/AvailableProcessors.java index ef258f4c87d..d666f1a2e6a 100644 --- a/test/hotspot/jtreg/runtime/os/AvailableProcessors.java +++ b/test/hotspot/jtreg/runtime/os/AvailableProcessors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, 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 @@ -87,6 +87,7 @@ public class AvailableProcessors { System.out.println("Final command line: " + ProcessTools.getCommandLine(pb)); OutputAnalyzer output = ProcessTools.executeProcess(pb); + output.shouldHaveExitValue(0); output.shouldContain(SUCCESS_STRING); } } diff --git a/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java b/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java index 546203ad913..4395a2d7cfa 100644 --- a/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java +++ b/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 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 @@ -47,6 +47,7 @@ public class TestUseCpuAllocPath { "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); output.shouldContain(SUCCESS_STRING); } } From e39346e708a06cdee2b9a096f08c1cfe2e21dfc2 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Fri, 11 Jun 2021 15:12:11 +0000 Subject: [PATCH 09/13] 8268093: Manual Testcase: "sun/security/krb5/config/native/TestDynamicStore.java" Fails with NPE Reviewed-by: mullan --- .../krb5/config/native/TestDynamicStore.java | 12 +++++++++++- .../krb5/config/native/libTestDynamicStore.m | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java b/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java index 19500899878..7e396013a71 100644 --- a/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java +++ b/test/jdk/sun/security/krb5/config/native/TestDynamicStore.java @@ -34,6 +34,13 @@ import jdk.test.lib.Asserts; import sun.security.krb5.Config; +// =================== Attention =================== +// This test calls a native method implemented in libTestDynamicStore.m +// to modify system-level Kerberos 5 settings stored in the dynamic store. +// It must be launched by a user with enough privilege or with "sudo". +// If launched with sudo, remember to remove the report and working +// directories with sudo as well after executing the test. + public class TestDynamicStore { native static int actionInternal(char what, char whom); @@ -59,7 +66,10 @@ public class TestDynamicStore { try { System.out.println("Fill in dynamic store"); - action('a', 'a'); + if (action('a', 'a') == 0) { + throw new Exception("Cannot write native Kerberos settings. " + + "Please make sure the test runs with enough privilege."); + } Asserts.assertTrue(Config.getInstance().get("libdefaults", "default_realm").equals("A.COM")); Asserts.assertTrue(Config.getInstance().exists("domain_realm")); diff --git a/test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m b/test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m index 30ed2eb113f..ddb2f11f18f 100644 --- a/test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m +++ b/test/jdk/sun/security/krb5/config/native/libTestDynamicStore.m @@ -62,7 +62,9 @@ int addMapping(SCDynamicStoreRef store) { int addAll(SCDynamicStoreRef store) { NSArray *keys = [NSArray arrayWithObjects:@"A.COM", @"B.COM", nil]; - fprintf(stderr, "%d\n", SCDynamicStoreSetValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS, keys)); + Boolean b = SCDynamicStoreSetValue(store, (CFStringRef) KERBEROS_DEFAULT_REALMS, keys); + fprintf(stderr, "%d\n", b); + if (!b) return 0; NSDictionary *k1 = [NSDictionary dictionaryWithObjectsAndKeys: @"kdc1.a.com", @"host", nil]; From 01054e6f5ab75dd1b7d3e82be0eb83f14a7add15 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Fri, 11 Jun 2021 16:08:18 +0000 Subject: [PATCH 10/13] 8268470: CDS dynamic dump asserts with JFR RecordingStream Reviewed-by: minqi, iklam --- .../classfile/systemDictionaryShared.cpp | 20 ++++- .../classfile/systemDictionaryShared.hpp | 1 + .../appcds/dynamicArchive/JFRDynamicCDS.java | 68 +++++++++++++++ .../test-classes/JFRDynamicCDSApp.java | 82 +++++++++++++++++++ 4 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/JFRDynamicCDS.java create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/JFRDynamicCDSApp.java diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 019db1d88c3..3b19790b82b 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -1354,11 +1354,29 @@ bool SystemDictionaryShared::check_for_exclusion(InstanceKlass* k, DumpTimeShare return info->is_excluded(); } +// Check if a class or any of its supertypes has been redefined. +bool SystemDictionaryShared::has_been_redefined(InstanceKlass* k) { + if (k->has_been_redefined()) { + return true; + } + if (k->java_super() != NULL && has_been_redefined(k->java_super())) { + return true; + } + Array* interfaces = k->local_interfaces(); + int len = interfaces->length(); + for (int i = 0; i < len; i++) { + if (has_been_redefined(interfaces->at(i))) { + return true; + } + } + return false; +} + bool SystemDictionaryShared::check_for_exclusion_impl(InstanceKlass* k) { if (k->is_in_error_state()) { return warn_excluded(k, "In error state"); } - if (k->has_been_redefined()) { + if (has_been_redefined(k)) { return warn_excluded(k, "Has been redefined"); } if (!k->is_hidden() && k->shared_classpath_index() < 0 && is_builtin(k)) { diff --git a/src/hotspot/share/classfile/systemDictionaryShared.hpp b/src/hotspot/share/classfile/systemDictionaryShared.hpp index 42474bbe3d3..80f3c40c16e 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.hpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.hpp @@ -232,6 +232,7 @@ private: static bool is_registered_lambda_proxy_class(InstanceKlass* ik); static bool warn_excluded(InstanceKlass* k, const char* reason); static bool check_for_exclusion_impl(InstanceKlass* k); + static bool has_been_redefined(InstanceKlass* k); static bool _dump_in_progress; DEBUG_ONLY(static bool _no_class_loading_should_happen;) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/JFRDynamicCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/JFRDynamicCDS.java new file mode 100644 index 00000000000..a89be5de0e0 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/JFRDynamicCDS.java @@ -0,0 +1,68 @@ +/* + * 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 8268470 + * @summary Test dynamic CDS with JFR recording. + * Dynamic dump should skip the class such as jdk/jfr/events/FileReadEvent + * if one of its super classes has been redefined during JFR startup. + * @requires vm.cds + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes + * @build JFRDynamicCDSApp sun.hotspot.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar jfr_dynamic_cds_app.jar JFRDynamicCDSApp JFRDynamicCDSApp$StressEvent + * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. JFRDynamicCDS + */ + +import jdk.test.lib.helpers.ClassFileInstaller; + +public class JFRDynamicCDS extends DynamicArchiveTestBase { + public static void main(String[] args) throws Exception { + runTest(JFRDynamicCDS::test); + } + + static void test() throws Exception { + String topArchiveName = getNewArchiveName(); + String appJar = ClassFileInstaller.getJarPath("jfr_dynamic_cds_app.jar"); + String mainClass = "JFRDynamicCDSApp"; + dump(topArchiveName, + "-Xlog:class+load,cds=debug", + "-cp", appJar, mainClass) + .assertNormalExit(output -> { + output.shouldHaveExitValue(0) + .shouldMatch("Skipping.jdk/jfr/events.*Has.been.redefined"); + }); + + run(topArchiveName, + "-Xlog:class+load=info", + "-cp", appJar, mainClass) + .assertNormalExit(output -> { + output.shouldHaveExitValue(0) + .shouldMatch(".class.load. jdk.jfr.events.*source:.*jrt:/jdk.jfr") + .shouldContain("[class,load] JFRDynamicCDSApp source: shared objects file (top)"); + }); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/JFRDynamicCDSApp.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/JFRDynamicCDSApp.java new file mode 100644 index 00000000000..c366c2e1bfa --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/JFRDynamicCDSApp.java @@ -0,0 +1,82 @@ +/* + * 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 java.nio.file.Paths; +import jdk.jfr.Configuration; +import jdk.jfr.Description; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordingStream; + +public class JFRDynamicCDSApp { + public static void main(String args[]) throws Exception { + RecordingStream rs = new RecordingStream(); + rs.enable("JFRDynamicCDS.StressEvent"); + rs.startAsync(); + + Recording recording = startRecording(); + loop(); + recording.stop(); + recording.close(); + + rs.close(); + } + + static Recording startRecording() throws Exception { + Configuration configuration = Configuration.getConfiguration("default"); + Recording recording = new Recording(configuration); + + recording.setName("internal"); + recording.enable(StressEvent.class); + recording.setDestination(Paths.get("JFRDynamicCDS.jfr")); + recording.start(); + return recording; + } + + + static void loop() { + for (int i=0; i<100; i++) { + StressEvent event = new StressEvent(); + event.iteration = i; + event.description = "Stressful Event, take it easy!"; + event.customClazz = StressEvent.class; + event.value = i; + event.commit(); + } + } + + + /** + * Internal StressEvent class. + */ + @Label("Stress Event") + @Description("A duration event with 4 entries") + @Name("JFRDynamicCDS.StressEvent") + public static class StressEvent extends jdk.jfr.Event { + public Class customClazz; + public String description; + public int iteration; + public double value; + } +} From 6171ae455288a74c4c3dcec6983515db04bdc360 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Fri, 11 Jun 2021 20:24:35 +0000 Subject: [PATCH 11/13] 8268630: ProblemList serviceability/jvmti/CompiledMethodLoad/Zombie.java on linux-aarch64 Reviewed-by: erikj --- test/hotspot/jtreg/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index b688da6fd0d..53b398a3026 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -110,6 +110,7 @@ serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java 8214 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-x64 +serviceability/jvmti/CompiledMethodLoad/Zombie.java 8245877 linux-aarch64 ############################################################################# From fe48ea9d7975188853bc165ce29789753f4758f2 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Mon, 14 Jun 2021 08:29:49 +0000 Subject: [PATCH 12/13] 8268342: java/foreign/channels/TestAsyncSocketChannels.java fails with "IllegalStateException: This segment is already closed" Reviewed-by: dfuchs --- .../channels/TestAsyncSocketChannels.java | 54 ++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/test/jdk/java/foreign/channels/TestAsyncSocketChannels.java b/test/jdk/java/foreign/channels/TestAsyncSocketChannels.java index 6fb0793c03f..1189600ddfe 100644 --- a/test/jdk/java/foreign/channels/TestAsyncSocketChannels.java +++ b/test/jdk/java/foreign/channels/TestAsyncSocketChannels.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; +import java.net.StandardSocketOptions; import java.nio.ByteBuffer; import java.nio.channels.AsynchronousServerSocketChannel; import java.nio.channels.AsynchronousSocketChannel; @@ -267,7 +268,7 @@ public class TestAsyncSocketChannels extends AbstractChannelsTest { } })); // give time for socket buffer to fill up. - Thread.sleep(5*1000); + awaitNoFurtherWrites(bytesWritten); assertMessage(expectThrows(ISE, () -> scope.close()), "Scope is acquired by"); assertTrue(scope.isAlive()); @@ -279,15 +280,40 @@ public class TestAsyncSocketChannels extends AbstractChannelsTest { // in turn unlock the scope and allow it to be closed. readNBytes(asc2, bytesWritten.get()); assertTrue(scope.isAlive()); - out.println("outstanding writes: " + outstandingWriteOps.get()); - while (outstandingWriteOps.get() > 0 ) { - out.println("spinning"); - Thread.onSpinWait(); - } + awaitOutstandingWrites(outstandingWriteOps); handler.await(); } } + /** Waits for outstandingWriteOps to complete (become 0). */ + static void awaitOutstandingWrites(AtomicInteger outstandingWriteOps) { + boolean initial = true; + while (outstandingWriteOps.get() > 0 ) { + if (initial) { + out.print("awaiting outstanding writes"); + initial = false; + } + out.print("."); + Thread.onSpinWait(); + } + out.println("outstanding writes: " + outstandingWriteOps.get()); + } + + /** Waits, at most 20secs, for bytesWritten to stabilize. */ + static void awaitNoFurtherWrites(AtomicLong bytesWritten) throws Exception { + int i; + long prevN = 0; + for (i=0; i<10; i++) { + long n = bytesWritten.get(); + Thread.sleep(2 * 1000); + if (bytesWritten.get() == n && prevN == n) { + break; + } + prevN = n; + } + out.println("awaitNoFurtherWrites: i=" + i +" , bytesWritten=" + bytesWritten.get()); + } + /** Completion handler that exposes conveniences to assert results. */ static class TestHandler implements CompletionHandler { volatile V result; @@ -357,11 +383,27 @@ public class TestAsyncSocketChannels extends AbstractChannelsTest { AsynchronousSocketChannel asc) throws Exception { + setBufferSized(assc, asc); assc.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0)); asc.connect(assc.getLocalAddress()).get(); return assc.accept().get(); } + /** Sets the send/receive buffer sizes in an attempt/hint to limit the + * accepted/connected socket buffer sizes. Actual buffer sizes in use will + * likely be larger due to TCP auto-tuning, but the hint typically reduces + * the overall scaled sizes. This is primarily to stabilize outstanding + * write operations. + */ + static void setBufferSized(AsynchronousServerSocketChannel assc, + AsynchronousSocketChannel asc) + throws Exception + { + assc.setOption(StandardSocketOptions.SO_RCVBUF, 32 * 1024); + asc.setOption(StandardSocketOptions.SO_SNDBUF, 32 * 1024); + asc.setOption(StandardSocketOptions.SO_RCVBUF, 32 * 1024); + } + /** Tolerate the additional level of IOException wrapping of unchecked exceptions * On Windows, when completing the completion handler with a failure. */ static Throwable tolerateIOEOnWindows(Throwable t) { From b318535452bc0dbc7f8a111a71bb0881833495e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gr=C3=B6nlund?= Date: Mon, 14 Jun 2021 13:11:33 +0000 Subject: [PATCH 13/13] 8267579: Thread::cooked_allocated_bytes() hits assert(left >= right) failed: avoid underflow Backport-of: c4207355d3fc19687c72f47edf21611ffed7efaf --- src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp | 9 +++++++++ src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp | 4 ++++ src/hotspot/share/runtime/thread.inline.hpp | 9 ++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp index 573ba400649..8bdcbec6f72 100644 --- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp +++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp @@ -31,6 +31,7 @@ #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.hpp" #include "runtime/perfData.hpp" #include "runtime/thread.inline.hpp" #include "runtime/threadSMR.hpp" @@ -473,3 +474,11 @@ size_t ThreadLocalAllocBuffer::end_reserve() { size_t reserve_size = Universe::heap()->tlab_alloc_reserve(); return MAX2(reserve_size, (size_t)_reserve_for_allocation_prefetch); } + +const HeapWord* ThreadLocalAllocBuffer::start_relaxed() const { + return Atomic::load(&_start); +} + +const HeapWord* ThreadLocalAllocBuffer::top_relaxed() const { + return Atomic::load(&_top); +} diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp index f8bb516f027..2b5c5ecca39 100644 --- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp +++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp @@ -129,6 +129,10 @@ public: size_t refill_waste_limit() const { return _refill_waste_limit; } size_t bytes_since_last_sample_point() const { return _bytes_since_last_sample_point; } + // For external inspection. + const HeapWord* start_relaxed() const; + const HeapWord* top_relaxed() const; + // Allocate size HeapWords. The memory is NOT initialized to zero. inline HeapWord* allocate(size_t size); diff --git a/src/hotspot/share/runtime/thread.inline.hpp b/src/hotspot/share/runtime/thread.inline.hpp index 7389b90546b..63101e77855 100644 --- a/src/hotspot/share/runtime/thread.inline.hpp +++ b/src/hotspot/share/runtime/thread.inline.hpp @@ -41,7 +41,14 @@ inline jlong Thread::cooked_allocated_bytes() { jlong allocated_bytes = Atomic::load_acquire(&_allocated_bytes); if (UseTLAB) { - size_t used_bytes = tlab().used_bytes(); + // These reads are unsynchronized and unordered with the thread updating its tlab pointers. + // Use only if top > start && used_bytes <= max_tlab_size_bytes. + const HeapWord* const top = tlab().top_relaxed(); + const HeapWord* const start = tlab().start_relaxed(); + if (top <= start) { + return allocated_bytes; + } + const size_t used_bytes = pointer_delta(top, start, 1); if (used_bytes <= ThreadLocalAllocBuffer::max_size_in_bytes()) { // Comparing used_bytes with the maximum allowed size will ensure // that we don't add the used bytes from a semi-initialized TLAB