Merge
authorjwilhelm
Wed, 30 Jan 2019 21:12:56 +0100
changeset 53578 ad3bb34fe399
parent 53574 f38270ce02cc (current diff)
parent 53577 7d19ac37d7d1 (diff)
child 53579 b5f05fe4a6f8
Merge
test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java
test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java
test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java
test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java
test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java
test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java
test/jdk/ProblemList.txt
--- a/src/java.desktop/unix/classes/sun/awt/X11/XChoicePeer.java	Wed Jan 30 14:19:24 2019 -0500
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XChoicePeer.java	Wed Jan 30 21:12:56 2019 +0100
@@ -468,6 +468,7 @@
                     if (unfurledChoice.isMouseInListArea(e)) {
                         int newIdx = helper.getSelectedIndex();
                         if (newIdx >= 0) {
+                            int currentItem = ((Choice)target).getSelectedIndex();
                             // Update the selected item in the target now that
                             // the mouse selection is complete.
                             if (newIdx != dragStartIdx) {
@@ -484,7 +485,7 @@
                             * LeftMouseButton used */
                             if (e.getButton() == MouseEvent.BUTTON1 &&
                                 (!firstPress || wasDragged ) &&
-                                ((Choice)target).getSelectedIndex() != newIdx)
+                                (newIdx != currentItem))
                             {
                                 ((Choice)target).select(newIdx);
                                 postEvent(new ItemEvent((Choice)target,
--- a/test/hotspot/jtreg/TEST.ROOT	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/hotspot/jtreg/TEST.ROOT	Wed Jan 30 21:12:56 2019 +0100
@@ -66,7 +66,8 @@
     vm.graal.enabled \
     vm.compiler1.enabled \
     vm.compiler2.enabled \
-    docker.support
+    docker.support \
+    test.vm.gc.nvdimm
 
 # Minimum jtreg version
 requiredVersion=4.2 b13
--- a/test/hotspot/jtreg/TEST.groups	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/hotspot/jtreg/TEST.groups	Wed Jan 30 21:12:56 2019 +0100
@@ -59,7 +59,8 @@
  -:hotspot_compiler \
  -:hotspot_gc \
  -:hotspot_runtime \
- -:hotspot_serviceability
+ -:hotspot_serviceability \
+ -gc/nvdimm
 
 hotspot_native_sanity = \
   native_sanity
@@ -197,7 +198,7 @@
 gc_epsilon = \
   gc/epsilon/ \
   gc/CriticalNativeArgs.java \
-  gc/stress/CriticalNativeStress.java 
+  gc/stress/CriticalNativeStress.java
 
 tier1_gc_gcold = \
   gc/stress/gcold/TestGCOldWithG1.java \
@@ -210,7 +211,7 @@
   gc/stress/gcbasher/TestGCBasherWithCMS.java \
   gc/stress/gcbasher/TestGCBasherWithSerial.java \
   gc/stress/gcbasher/TestGCBasherWithParallel.java
-  
+
 tier1_gc_shenandoah = \
   gc/shenandoah/options/ \
   gc/shenandoah/compiler/ \
--- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java	Wed Jan 30 21:12:56 2019 +0100
@@ -27,6 +27,7 @@
  * @key gc
  * @summary Test to check allocation of Java Heap with AllocateOldGenAt option
  * @requires vm.gc=="null" & os.family != "aix"
+ * @requires test.vm.gc.nvdimm
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  * @run main gc.nvdimm.TestAllocateOldGenAt
--- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java	Wed Jan 30 21:12:56 2019 +0100
@@ -27,6 +27,7 @@
  * @key gc
  * @summary Test to check correct handling of non-existent directory passed to AllocateOldGenAt option
  * @requires vm.gc=="null" & os.family != "aix"
+ * @requires test.vm.gc.nvdimm
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  * @run main gc.nvdimm.TestAllocateOldGenAtError
--- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java	Wed Jan 30 21:12:56 2019 +0100
@@ -27,6 +27,7 @@
  * @key gc
  * @summary Test to check allocation of Java Heap with AllocateOldGenAt option. Has multiple sub-tests to cover different code paths.
  * @requires vm.gc=="null" & os.family != "aix"
+ * @requires test.vm.gc.nvdimm
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  * @requires vm.bits == "64"
--- a/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java	Wed Jan 30 21:12:56 2019 +0100
@@ -28,6 +28,7 @@
  * @summary Check that humongous objects reside in nv-dimm
  * @library /test/lib /
  * @requires vm.gc=="null" & os.family != "aix"
+ * @requires test.vm.gc.nvdimm
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  * @run main gc.nvdimm.TestHumongousObjectsOnNvdimm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
--- a/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java	Wed Jan 30 21:12:56 2019 +0100
@@ -27,6 +27,7 @@
  * @test TestOldObjectsOnNvdimm
  * @summary Check that objects in old generation reside in dram.
  * @requires vm.gc=="null" & os.family != "aix"
+ * @requires test.vm.gc.nvdimm
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
--- a/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java	Wed Jan 30 21:12:56 2019 +0100
@@ -27,6 +27,7 @@
  * @test TestYoungObjectsOnDram
  * @summary Check that objects in young generation reside in dram.
  * @requires vm.gc=="null" & os.family != "aix"
+ * @requires test.vm.gc.nvdimm
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
--- a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java	Wed Jan 30 21:12:56 2019 +0100
@@ -263,6 +263,8 @@
                 "-XX:-UseCounterDecay",
                 "-XX:-ShowMessageBoxOnError",
                 "-XX:+UnlockDiagnosticVMOptions",
+                // redirect VM output to cerr so it won't collide w/ ctw output
+                "-XX:+DisplayVMOutputToStderr",
                 // define phase start
                 "-DCompileTheWorldStartAt=" + classStart,
                 "-DCompileTheWorldStopAt=" + classStop,
--- a/test/jdk/ProblemList.txt	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/jdk/ProblemList.txt	Wed Jan 30 21:12:56 2019 +0100
@@ -254,7 +254,6 @@
 java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java 7100044 macosx-all,linux-all
 java/awt/Component/CreateImage/CreateImage.java 8198334  windows-all
 java/awt/Component/GetScreenLocTest/GetScreenLocTest.java 4753654 generic-all
-java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.html 8192929 windows-all,linux-all
 java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.html 8017454 macosx-all
 java/awt/Focus/NonFocusableWindowTest/NoEventsTest.java 8000171 windows-all
 java/awt/Frame/MiscUndecorated/RepaintTest.java 8079267 windows-all,linux-all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/Choice/SelectNewItemTest/SelectNewItemTest.java	Wed Jan 30 21:12:56 2019 +0100
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+  @test
+  @bug 8215921
+  @summary Test that selecting a different item does send an ItemEvent
+  @key headful
+  @run main SelectNewItemTest
+*/
+
+import java.awt.Choice;
+import java.awt.Robot;
+import java.awt.Frame;
+import java.awt.BorderLayout;
+import java.awt.AWTException;
+import java.awt.Point;
+import java.awt.Dimension;
+import java.awt.event.InputEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.WindowListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.WindowEvent;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class SelectNewItemTest implements ItemListener, WindowListener {
+    //Declare things used in the test, like buttons and labels here
+    private Frame frame;
+    private Choice theChoice;
+    private Robot robot;
+
+    private CountDownLatch latch = new CountDownLatch(1);
+    private volatile boolean passed = false;
+
+    private void init()
+    {
+        try {
+            robot = new Robot();
+            robot.setAutoDelay(500);
+        } catch (AWTException e) {
+            throw new RuntimeException("Unable to create Robot. Test fails.");
+        }
+
+        frame = new Frame("SelectNewItemTest");
+        frame.setLayout(new BorderLayout());
+        theChoice = new Choice();
+        for (int i = 0; i < 10; i++) {
+            theChoice.add(new String("Choice Item " + i));
+        }
+        theChoice.addItemListener(this);
+        frame.add(theChoice);
+        frame.addWindowListener(this);
+
+        frame.setLocation(1,20);
+        frame.setSize(200, 50);
+        robot.mouseMove(10, 30);
+        frame.pack();
+        frame.setVisible(true);
+    }
+
+    public static void main(String... args) {
+        SelectNewItemTest test = new SelectNewItemTest();
+        test.init();
+        try {
+            test.latch.await(12000, TimeUnit.MILLISECONDS);
+        } catch (InterruptedException e) {}
+        test.robot.waitForIdle();
+
+        try {
+            if (!test.passed) {
+                throw new RuntimeException("TEST FAILED.");
+            }
+        } finally {
+            test.frame.dispose();
+        }
+    }
+
+    private void run() {
+        try {
+            Thread.sleep(1000);
+
+            Point loc = theChoice.getLocationOnScreen();
+            int selectedIndex = theChoice.getSelectedIndex();
+            Dimension size = theChoice.getSize();
+
+            robot.mouseMove(loc.x + size.width - 10, loc.y + size.height / 2);
+
+            robot.setAutoDelay(250);
+            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+
+            robot.delay(1000);
+
+            //make sure that the mouse moves to a different item, so that
+            //itemStateChanged is called.
+            robot.mouseMove(loc.x + size.width / 2, loc.y + 3 * size.height);
+            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+            robot.waitForIdle();
+
+            if (selectedIndex == theChoice.getSelectedIndex())
+                throw new RuntimeException("Test case failed - expected to select" +
+                " a different item than " + selectedIndex);
+
+            selectedIndex = theChoice.getSelectedIndex();
+            //now click on the same item and make sure that item event is
+            //not generated.
+            robot.delay(1000);
+            robot.mouseMove(loc.x + size.width - 10, loc.y + size.height / 2);
+
+            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+            //Make sure that the popup menu scrolls back to show the index from
+            //beginning, so that the second mouse click happens on the previously
+            //selected item.
+            //For example, on windows, it automatically scrolls the list to show
+            //the currently selected item just below the choice, which can
+            //throw off the test.
+            if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
+                robot.mouseWheel(-100);
+            }
+            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+
+            robot.delay(1000);
+            robot.mouseMove(loc.x + size.width / 2, loc.y + 3 * size.height);
+            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+            robot.waitForIdle();
+
+            if (selectedIndex != theChoice.getSelectedIndex())
+                throw new RuntimeException("Test failed. Expected to select the same item " +
+                "located at: " + selectedIndex + " but got an item selected at: " + theChoice.getSelectedIndex());
+        } catch(InterruptedException e) {
+            throw new RuntimeException(e.getCause());
+        } finally {
+            latch.countDown();
+        }
+    }
+
+    @Override public void itemStateChanged(ItemEvent e) {
+        if (!passed) {
+            System.out.println("ItemEvent received.  Test passes");
+            passed = true;
+        } else {
+            System.out.println("ItemEvent received for second click. Test fails");
+            passed = false;
+        }
+    }
+
+    @Override public void windowOpened(WindowEvent e) {
+        System.out.println("windowActivated()");
+        (new Thread(this::run)).start();
+    }
+
+    @Override public void windowActivated(WindowEvent e) {}
+    @Override public void windowDeactivated(WindowEvent e) {}
+    @Override public void windowClosed(WindowEvent e) {}
+    @Override public void windowClosing(WindowEvent e) {}
+    @Override public void windowIconified(WindowEvent e) {}
+    @Override public void windowDeiconified(WindowEvent e) {}
+}
--- a/test/jtreg-ext/requires/VMProps.java	Wed Jan 30 14:19:24 2019 -0500
+++ b/test/jtreg-ext/requires/VMProps.java	Wed Jan 30 21:12:56 2019 +0100
@@ -97,6 +97,7 @@
         map.put("vm.compiler2.enabled", isCompiler2Enabled());
         map.put("docker.support", dockerSupport());
         map.put("release.implementor", implementor());
+        map.put("test.vm.gc.nvdimm", isNvdimmTestEnabled());
         vmGC(map); // vm.gc.X = true/false
         vmOptFinalFlags(map);
 
@@ -469,6 +470,15 @@
         return null;
     }
 
+    private String isNvdimmTestEnabled() {
+        String isEnbled = System.getenv("TEST_VM_GC_NVDIMM");
+        if (isEnbled != null && isEnbled.toLowerCase().equals("true")) {
+            return "true";
+        }
+        return "false";
+    }
+
+
 
     /**
      * Dumps the map to the file if the file name is given as the property.