changeset 14912:c3569076f6c6

Merge
author andrew
date Thu, 07 Jan 2021 17:25:21 +0000
parents c1d3b72824ea (current diff) cf0f3b64a18f (diff)
children 7432d3558458
files test/javax/sound/midi/MidiSystem/testdata/lib/conf/sound.properties test/javax/sound/sampled/AudioSystem/testdata/lib/conf/sound.properties
diffstat 20 files changed, 303 insertions(+), 124 deletions(-) [+]
line wrap: on
line diff
--- a/src/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java	Mon May 18 17:16:29 2020 -0700
+++ b/src/linux/classes/jdk/internal/platform/cgroupv1/Metrics.java	Thu Jan 07 17:25:21 2021 +0000
@@ -220,6 +220,8 @@
                 MemorySubSystem memorySubSystem = (MemorySubSystem)subsystem;
                 boolean isHierarchial = getHierarchical(memorySubSystem);
                 memorySubSystem.setHierarchical(isHierarchial);
+                boolean isSwapEnabled = getSwapEnabled(memorySubSystem);
+                memorySubSystem.setSwapEnabled(isSwapEnabled);
             }
             metric.setActiveSubSystems();
         }
@@ -231,6 +233,11 @@
         return hierarchical > 0;
     }
 
+    private static boolean getSwapEnabled(MemorySubSystem subsystem) {
+        long retval = SubSystem.getLongValue(subsystem, "memory.memsw.limit_in_bytes");
+        return retval > 0;
+    }
+
     private void setActiveSubSystems() {
         activeSubSystems = true;
     }
@@ -460,10 +467,16 @@
     }
 
     public long getMemoryAndSwapFailCount() {
+        if (!memory.isSwapEnabled()) {
+            return getMemoryFailCount();
+        }
         return SubSystem.getLongValue(memory, "memory.memsw.failcnt");
     }
 
     public long getMemoryAndSwapLimit() {
+        if (!memory.isSwapEnabled()) {
+            return getMemoryLimit();
+        }
         long retval = SubSystem.getLongValue(memory, "memory.memsw.limit_in_bytes");
         if (retval > unlimited_minimum) {
             if (memory.isHierarchical()) {
@@ -480,10 +493,16 @@
     }
 
     public long getMemoryAndSwapMaxUsage() {
+        if (!memory.isSwapEnabled()) {
+            return getMemoryMaxUsage();
+        }
         return SubSystem.getLongValue(memory, "memory.memsw.max_usage_in_bytes");
     }
 
     public long getMemoryAndSwapUsage() {
+        if (!memory.isSwapEnabled()) {
+            return getMemoryUsage();
+        }
         return SubSystem.getLongValue(memory, "memory.memsw.usage_in_bytes");
     }
 
--- a/src/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java	Mon May 18 17:16:29 2020 -0700
+++ b/src/linux/classes/jdk/internal/platform/cgroupv1/SubSystem.java	Thu Jan 07 17:25:21 2021 +0000
@@ -119,7 +119,7 @@
                                                      Function<String, Long> conversion) {
         long retval = Metrics.unlimited_minimum + 1; // default unlimited
         try {
-            List<String> lines = Files.readAllLines(Paths.get(subsystem.path(), param));
+            List<String> lines = subsystem.readMatchingLines(param);
             for (String line: lines) {
                 if (line.contains(match)) {
                     retval = conversion.apply(line);
@@ -132,6 +132,17 @@
         return retval;
     }
 
+    private List<String> readMatchingLines(String param) throws IOException {
+        try {
+            PrivilegedExceptionAction<List<String>> pea = () ->
+                    Files.readAllLines(Paths.get(path(), param));
+            return AccessController.doPrivileged(pea);
+        } catch (PrivilegedActionException e) {
+            Metrics.unwrapIOExceptionAndRethrow(e);
+            throw new InternalError(e.getCause());
+        }
+    }
+
     public static long getLongValue(SubSystem subsystem, String parm) {
         String strval = getStringValue(subsystem, parm);
         return convertStringToLong(strval);
@@ -246,6 +257,7 @@
     public static class MemorySubSystem extends SubSystem {
 
         private boolean hierarchical;
+        private boolean swapenabled;
 
         public MemorySubSystem(String root, String mountPoint) {
             super(root, mountPoint);
@@ -259,5 +271,13 @@
             this.hierarchical = hierarchical;
         }
 
+        boolean isSwapEnabled() {
+            return swapenabled;
+        }
+
+        void setSwapEnabled(boolean swapenabled) {
+            this.swapenabled = swapenabled;
+        }
+
     }
 }
--- a/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java	Mon May 18 17:16:29 2020 -0700
+++ b/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java	Thu Jan 07 17:25:21 2021 +0000
@@ -1250,8 +1250,10 @@
             g.translate(x, y);
 
             // fill interior
-            g.setColor(interiorColor);
-            g.fillRect(2,2, 9,9);
+            if (c.isOpaque()) {
+                g.setColor(interiorColor);
+                g.fillRect(2, 2, 9, 9);
+            }
 
             // draw Dark Circle (start at top, go clockwise)
             g.setColor(darkCircle);
--- a/src/windows/native/sun/bridge/WinAccessBridge.cpp	Mon May 18 17:16:29 2020 -0700
+++ b/src/windows/native/sun/bridge/WinAccessBridge.cpp	Thu Jan 07 17:25:21 2021 +0000
@@ -296,7 +296,7 @@
 
     PrintDebugString("[INFO]:   finished deleting eventHandler, messageQueue, and javaVMs");
     PrintDebugString("[INFO]: GOODBYE CRUEL WORLD...");
-
+    finalizeFileLogger();
     DestroyWindow(theDialogWindow);
 }
 
--- a/test/javax/sound/midi/MidiSystem/DefaultDevices.java	Mon May 18 17:16:29 2020 -0700
+++ b/test/javax/sound/midi/MidiSystem/DefaultDevices.java	Thu Jan 07 17:25:21 2021 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
  * @bug 4776511
  * @bug 4934509
  * @bug 4938236
- * @modules java.desktop/com.sun.media.sound
  * @run main/timeout=600 DefaultDevices
  * @summary RFE: Setting the default MixerProvider
  */
--- a/test/javax/sound/midi/MidiSystem/DefaultProperties.java	Mon May 18 17:16:29 2020 -0700
+++ b/test/javax/sound/midi/MidiSystem/DefaultProperties.java	Thu Jan 07 17:25:21 2021 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
  * @summary RFE: Setting the default MixerProvider. Test the retrieving and
  *          parsing of properties. This is a part of the test for 4776511.
  * @run main/othervm DefaultProperties
- * @modules java.desktop/com.sun.media.sound
  */
 public class DefaultProperties {
 
--- a/test/javax/sound/midi/MidiSystem/ProviderCacheing.java	Mon May 18 17:16:29 2020 -0700
+++ b/test/javax/sound/midi/MidiSystem/ProviderCacheing.java	Thu Jan 07 17:25:21 2021 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
  * @bug 4776511
  * @summary RFE: Setting the default MixerProvider. Test the cacheing of
  *          providers. This is a part of the test for 4776511.
- * @modules java.desktop/com.sun.media.sound
  */
 public class ProviderCacheing {
 
--- a/test/javax/sound/midi/MidiSystem/testdata/lib/conf/sound.properties	Mon May 18 17:16:29 2020 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-#
-# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-javax.sound.midi.Receiver=xyz#123
-javax.sound.midi.Transmitter=xyz#123
-javax.sound.midi.Sequencer=xyz#123
-javax.sound.midi.Synthesizer=xyz#123
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/sound/midi/MidiSystem/testdata/lib/sound.properties	Thu Jan 07 17:25:21 2021 +0000
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+javax.sound.midi.Receiver=xyz#123
+javax.sound.midi.Transmitter=xyz#123
+javax.sound.midi.Sequencer=xyz#123
+javax.sound.midi.Synthesizer=xyz#123
--- a/test/javax/sound/sampled/AudioSystem/DefaultMixers.java	Mon May 18 17:16:29 2020 -0700
+++ b/test/javax/sound/sampled/AudioSystem/DefaultMixers.java	Thu Jan 07 17:25:21 2021 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,6 @@
  * @bug 4776511
  * @summary RFE: Setting the default MixerProvider. Test the retrieving of lines
  *          with defaut mixer properties.
- * @modules java.desktop/com.sun.media.sound
  */
 public class DefaultMixers {
 
--- a/test/javax/sound/sampled/AudioSystem/DefaultProperties.java	Mon May 18 17:16:29 2020 -0700
+++ b/test/javax/sound/sampled/AudioSystem/DefaultProperties.java	Thu Jan 07 17:25:21 2021 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
  * @run main/othervm DefaultProperties
  * @summary RFE: Setting the default MixerProvider. Test the retrieving and
  *          parsing of properties.
- * @modules java.desktop/com.sun.media.sound
  */
 public class DefaultProperties {
 
--- a/test/javax/sound/sampled/AudioSystem/ProviderCacheing.java	Mon May 18 17:16:29 2020 -0700
+++ b/test/javax/sound/sampled/AudioSystem/ProviderCacheing.java	Thu Jan 07 17:25:21 2021 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
  * @bug 4776511
  * @summary RFE: Setting the default MixerProvider. Test the cacheing of
  *          providers.
- * @modules java.desktop/com.sun.media.sound
  */
 public class ProviderCacheing {
 
--- a/test/javax/sound/sampled/AudioSystem/testdata/lib/conf/sound.properties	Mon May 18 17:16:29 2020 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-#
-# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-javax.sound.sampled.SourceDataLine=xyz#123
-javax.sound.sampled.TargetDataLine=xyz#123
-javax.sound.sampled.Clip=xyz#123
-javax.sound.sampled.Port=xyz#123
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/sound/sampled/AudioSystem/testdata/lib/sound.properties	Thu Jan 07 17:25:21 2021 +0000
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+javax.sound.sampled.SourceDataLine=xyz#123
+javax.sound.sampled.TargetDataLine=xyz#123
+javax.sound.sampled.Clip=xyz#123
+javax.sound.sampled.Port=xyz#123
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JRadioButton/8041561/bug8041561.java	Thu Jan 07 17:25:21 2021 +0000
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.AWTException;
+import java.awt.Color;
+import java.awt.Point;
+import java.awt.Robot;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.DefaultMetalTheme;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/**
+ * @test
+ * @bug 8041561
+ * @author Alexander Scherbatiy
+ * @summary Inconsistent opacity behaviour between JCheckBox and JRadioButton
+ * @run main bug8041561
+ */
+public class bug8041561 {
+
+    private static JRadioButton radioButton;
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                try {
+                    MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
+                    UIManager.setLookAndFeel(new MetalLookAndFeel());
+                    createAndShowGUI();
+                } catch (UnsupportedLookAndFeelException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        });
+
+        new Robot().waitForIdle();
+        Thread.sleep(500);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                try {
+                    Point point = radioButton.getLocationOnScreen();
+                    int x = (int) point.getX() + radioButton.getWidth() / 2;
+                    int y = (int) point.getY() + radioButton.getHeight() / 2;
+
+                    Robot robot = new Robot();
+                    Color color = robot.getPixelColor(x, y);
+                    if (!Color.BLUE.equals(color)) {
+                        throw new RuntimeException("JRadioButton is opaque");
+                    }
+                } catch (AWTException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        });
+
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setBackground(Color.BLUE);
+        radioButton = new JRadioButton();
+        radioButton.setOpaque(false);
+        JPanel panel = new JPanel();
+        panel.setBackground(Color.BLUE);
+        panel.add(radioButton);
+        frame.getContentPane().add(panel);
+        frame.pack();
+        frame.setVisible(true);
+    }
+}
--- a/test/jdk/internal/platform/docker/MetricsMemoryTester.java	Mon May 18 17:16:29 2020 -0700
+++ b/test/jdk/internal/platform/docker/MetricsMemoryTester.java	Thu Jan 07 17:25:21 2021 +0000
@@ -61,26 +61,34 @@
     }
 
     private static void testMemoryFailCount() {
-        long count = Metrics.systemMetrics().getMemoryFailCount();
+        long memAndSwapLimit = Metrics.systemMetrics().getMemoryAndSwapLimit();
+        long memLimit = Metrics.systemMetrics().getMemoryLimit();
+
+        // We need swap to execute this test or will SEGV
+        if (memAndSwapLimit <= memLimit) {
+            System.out.println("No swap memory limits, test case skipped");
+        } else {
+            long count = Metrics.systemMetrics().getMemoryFailCount();
 
-        // Allocate 512M of data
-        byte[][] bytes = new byte[64][];
-        for (int i = 0; i < 64; i++) {
-            try {
-                bytes[i] = new byte[8 * 1024 * 1024];
-                // Break out as soon as we see an increase in failcount
-                // to avoid getting killed by the OOM killer.
-                if (Metrics.systemMetrics().getMemoryFailCount() > count) {
+            // Allocate 512M of data
+            byte[][] bytes = new byte[64][];
+            for (int i = 0; i < 64; i++) {
+                try {
+                    bytes[i] = new byte[8 * 1024 * 1024];
+                    // Break out as soon as we see an increase in failcount
+                    // to avoid getting killed by the OOM killer.
+                    if (Metrics.systemMetrics().getMemoryFailCount() > count) {
+                        break;
+                    }
+                } catch (Error e) { // OOM error
                     break;
                 }
-            } catch (Error e) { // OOM error
-                break;
             }
-        }
-        if (Metrics.systemMetrics().getMemoryFailCount() <= count) {
-            throw new RuntimeException("Memory fail count : new : ["
-                    + Metrics.systemMetrics().getMemoryFailCount() + "]"
-                    + ", old : [" + count + "]");
+            if (Metrics.systemMetrics().getMemoryFailCount() <= count) {
+                throw new RuntimeException("Memory fail count : new : ["
+                        + Metrics.systemMetrics().getMemoryFailCount() + "]"
+                        + ", old : [" + count + "]");
+            }
         }
         System.out.println("TEST PASSED!!!");
     }
@@ -111,10 +119,12 @@
     private static void testMemoryAndSwapLimit(String memory, String memAndSwap) {
         long expectedMem = getMemoryValue(memory);
         long expectedMemAndSwap = getMemoryValue(memAndSwap);
+        long actualMemAndSwap = Metrics.systemMetrics().getMemoryAndSwapLimit();
 
         if (expectedMem != Metrics.systemMetrics().getMemoryLimit()
-                || expectedMemAndSwap != Metrics.systemMetrics().getMemoryAndSwapLimit()) {
-            System.err.println("Memory and swap limit not equal, expected : ["
+                || (expectedMemAndSwap != actualMemAndSwap
+                && expectedMem != actualMemAndSwap)) {
+            throw new RuntimeException("Memory and swap limit not equal, expected : ["
                     + expectedMem + ", " + expectedMemAndSwap + "]"
                     + ", got : [" + Metrics.systemMetrics().getMemoryLimit()
                     + ", " + Metrics.systemMetrics().getMemoryAndSwapLimit() + "]");
--- a/test/jdk/internal/platform/docker/TestUseContainerSupport.java	Mon May 18 17:16:29 2020 -0700
+++ b/test/jdk/internal/platform/docker/TestUseContainerSupport.java	Thu Jan 07 17:25:21 2021 +0000
@@ -58,8 +58,7 @@
         DockerRunOptions opts =
                 new DockerRunOptions(imageName, "/jdk/bin/java", "CheckUseContainerSupport");
         opts.addClassOptions(Boolean.valueOf(useContainerSupport).toString());
-        opts.addDockerOpts("--memory", "200m")
-            .addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/");
+        opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/");
         if (useContainerSupport) {
             opts.addJavaOpts("-XX:+UseContainerSupport");
         } else {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/Container.java	Thu Jan 07 17:25:21 2021 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019, Red Hat Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.test.lib;
+
+public class Container {
+    // Use this property to specify docker location on your system.
+    // E.g.: "/usr/local/bin/docker". We define this constant here so
+    // that it can be used in VMProps as well which checks docker support
+    // via this command
+    public static final String ENGINE_COMMAND =
+        System.getProperty("jdk.test.container.command", "docker");
+}
--- a/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java	Mon May 18 17:16:29 2020 -0700
+++ b/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java	Thu Jan 07 17:25:21 2021 +0000
@@ -291,29 +291,32 @@
         }
 
         //  Memory and Swap
-        oldVal = metrics.getMemoryAndSwapFailCount();
-        newVal = getLongValueFromFile(SubSystem.MEMORY, "memory.memsw.failcnt");
-        if (!compareWithErrorMargin(oldVal, newVal)) {
-            fail(SubSystem.MEMORY, "memory.memsw.failcnt", oldVal, newVal);
-        }
+        // Skip swap tests if no swap is configured.
+        if (metrics.getMemoryAndSwapLimit() > metrics.getMemoryLimit()) {
+            oldVal = metrics.getMemoryAndSwapFailCount();
+            newVal = getLongValueFromFile(SubSystem.MEMORY, "memory.memsw.failcnt");
+            if (!compareWithErrorMargin(oldVal, newVal)) {
+                fail(SubSystem.MEMORY, "memory.memsw.failcnt", oldVal, newVal);
+            }
 
-        oldVal = metrics.getMemoryAndSwapLimit();
-        newVal = getLongValueFromFile(SubSystem.MEMORY, "memory.memsw.limit_in_bytes");
-        newVal = newVal > unlimited_minimum ? -1L : newVal;
-        if (!compareWithErrorMargin(oldVal, newVal)) {
-            fail(SubSystem.MEMORY, "memory.memsw.limit_in_bytes", oldVal, newVal);
-        }
+            oldVal = metrics.getMemoryAndSwapLimit();
+            newVal = getLongValueFromFile(SubSystem.MEMORY, "memory.memsw.limit_in_bytes");
+            newVal = newVal > unlimited_minimum ? -1L : newVal;
+            if (!compareWithErrorMargin(oldVal, newVal)) {
+                fail(SubSystem.MEMORY, "memory.memsw.limit_in_bytes", oldVal, newVal);
+            }
 
-        oldVal = metrics.getMemoryAndSwapMaxUsage();
-        newVal = getLongValueFromFile(SubSystem.MEMORY, "memory.memsw.max_usage_in_bytes");
-        if (!compareWithErrorMargin(oldVal, newVal)) {
-            fail(SubSystem.MEMORY, "memory.memsw.max_usage_in_bytes", oldVal, newVal);
-        }
+            oldVal = metrics.getMemoryAndSwapMaxUsage();
+            newVal = getLongValueFromFile(SubSystem.MEMORY, "memory.memsw.max_usage_in_bytes");
+            if (!compareWithErrorMargin(oldVal, newVal)) {
+                fail(SubSystem.MEMORY, "memory.memsw.max_usage_in_bytes", oldVal, newVal);
+            }
 
-        oldVal = metrics.getMemoryAndSwapUsage();
-        newVal = getLongValueFromFile(SubSystem.MEMORY, "memory.memsw.usage_in_bytes");
-        if (!compareWithErrorMargin(oldVal, newVal)) {
-            fail(SubSystem.MEMORY, "memory.memsw.usage_in_bytes", oldVal, newVal);
+            oldVal = metrics.getMemoryAndSwapUsage();
+            newVal = getLongValueFromFile(SubSystem.MEMORY, "memory.memsw.usage_in_bytes");
+            if (!compareWithErrorMargin(oldVal, newVal)) {
+                fail(SubSystem.MEMORY, "memory.memsw.usage_in_bytes", oldVal, newVal);
+            }
         }
 
         oldVal = metrics.getMemorySoftLimit();
@@ -531,16 +534,20 @@
         long newUsage = metrics.getCpuUsage();
         long[] newPerCpu = metrics.getPerCpuUsage();
 
-        if (newSysVal <= startSysVal) {
+        // system/user CPU usage counters may be slowly increasing.
+        // allow for equal values for a pass
+        if (newSysVal < startSysVal) {
             fail(SubSystem.CPU, "getCpuSystemUsage", newSysVal, startSysVal);
         }
 
-        if (newUserVal <= startUserVal) {
+        // system/user CPU usage counters may be slowly increasing.
+        // allow for equal values for a pass
+        if (newUserVal < startUserVal) {
             fail(SubSystem.CPU, "getCpuUserUsage", newUserVal, startUserVal);
         }
 
         if (newUsage <= startUsage) {
-            fail(SubSystem.CPU, "getCpuUserUsage", newUsage, startUsage);
+            fail(SubSystem.CPU, "getCpuUsage", newUsage, startUsage);
         }
 
         boolean success = false;
--- a/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java	Mon May 18 17:16:29 2020 -0700
+++ b/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java	Thu Jan 07 17:25:21 2021 +0000
@@ -36,6 +36,7 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import jdk.test.lib.Container;
 import jdk.test.lib.Utils;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
@@ -46,11 +47,6 @@
     private static boolean isDockerEngineAvailable = false;
     private static boolean wasDockerEngineChecked = false;
 
-    // Use this property to specify docker location on your system.
-    // E.g.: "/usr/local/bin/docker".
-    private static final String DOCKER_COMMAND =
-        System.getProperty("jdk.test.docker.command", "docker");
-
     // Set this property to true to retain image after test. By default
     // images are removed after test execution completes.
     // Retaining the image can be useful for diagnostics and image inspection.
@@ -110,7 +106,7 @@
      */
     private static boolean isDockerEngineAvailableCheck() throws Exception {
         try {
-            execute(DOCKER_COMMAND, "ps")
+            execute(Container.ENGINE_COMMAND, "ps")
                 .shouldHaveExitValue(0)
                 .shouldContain("CONTAINER")
                 .shouldContain("IMAGE");
@@ -173,9 +169,8 @@
                            DockerfileConfig.getBaseImageVersion());
 
         // Build the docker
-        execute(DOCKER_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString())
-            .shouldHaveExitValue(0)
-            .shouldContain("Successfully built");
+        execute(Container.ENGINE_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString())
+            .shouldHaveExitValue(0);
     }
 
 
@@ -190,7 +185,7 @@
     public static OutputAnalyzer dockerRunJava(DockerRunOptions opts) throws Exception {
         ArrayList<String> cmd = new ArrayList<>();
 
-        cmd.add(DOCKER_COMMAND);
+        cmd.add(Container.ENGINE_COMMAND);
         cmd.add("run");
         if (opts.tty)
             cmd.add("--tty=true");
@@ -220,7 +215,7 @@
      * @throws Exception
      */
     public static void removeDockerImage(String imageNameAndTag) throws Exception {
-            execute(DOCKER_COMMAND, "rmi", "--force", imageNameAndTag);
+            execute(Container.ENGINE_COMMAND, "rmi", "--force", imageNameAndTag);
     }