diff --git a/.hgtags b/.hgtags
index 2dbce587cc6ec96e85687dd3f4df8cce544d9982..896a72c65a27e32d3b2cbd4e991d7cfb8999f89c 100644
--- a/.hgtags
+++ b/.hgtags
@@ -328,4 +328,5 @@ eaaa9a04b9fdcfa4a830b811ed209eb2c45a4a6b jdk8u25-b12
c3a855402b923d3ba819b05292a971953fc8ed0b jdk8u25-b13
2a6df63ca0f0f59bb730638b05c72d77a23f93c8 jdk8u25-b14
412d9ade90401d098f3662bd688ab393008423bd jdk8u25-b15
+f07bc5dab84c67f5d1dccbab318ee1c5485c852d jdk8u25-b16
f935349e2c065487c745bc41f81ddc7869bd2d2d jdk8u31-b00
diff --git a/src/macosx/classes/sun/lwawt/LWWindowPeer.java b/src/macosx/classes/sun/lwawt/LWWindowPeer.java
index b72ef77d876ff5661f76a1300f5726a82b69df92..4655d2bcfcaf72d220529588782c4f5324f72c2e 100644
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java
+++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java
@@ -105,6 +105,8 @@ public class LWWindowPeer
private final SecurityWarningWindow warningWindow;
+ private volatile boolean targetFocusable;
+
/**
* Current modal blocker or null.
*
@@ -240,13 +242,12 @@ public class LWWindowPeer
if (!visible && warningWindow != null) {
warningWindow.setVisible(false, false);
}
-
+ updateFocusableWindowState();
super.setVisibleImpl(visible);
// TODO: update graphicsConfig, see 4868278
platformWindow.setVisible(visible);
if (isSimpleWindow()) {
KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
-
if (visible) {
if (!getTarget().isAutoRequestFocus()) {
return;
@@ -397,6 +398,7 @@ public class LWWindowPeer
@Override
public void updateFocusableWindowState() {
+ targetFocusable = getTarget().isFocusableWindow();
platformWindow.updateFocusableWindowState();
}
@@ -1220,13 +1222,13 @@ public class LWWindowPeer
}
private boolean isFocusableWindow() {
- boolean focusable = getTarget().isFocusableWindow();
+ boolean focusable = targetFocusable;
if (isSimpleWindow()) {
LWWindowPeer ownerPeer = getOwnerFrameDialog(this);
if (ownerPeer == null) {
return false;
}
- return focusable && ownerPeer.getTarget().isFocusableWindow();
+ return focusable && ownerPeer.targetFocusable;
}
return focusable;
}
diff --git a/src/share/classes/javax/swing/JDesktopPane.java b/src/share/classes/javax/swing/JDesktopPane.java
index b5945ddc0d6c5a55146cbfbba4bcadd9f94c5789..0f05f7900d51a9f192c450bf0f7501ee9b5a7086 100644
--- a/src/share/classes/javax/swing/JDesktopPane.java
+++ b/src/share/classes/javax/swing/JDesktopPane.java
@@ -43,6 +43,7 @@ import java.io.IOException;
import java.beans.PropertyVetoException;
import java.util.Set;
import java.util.TreeSet;
+import java.util.LinkedHashSet;
/**
* A container used to create a multiple-document interface or a virtual desktop.
* You create JInternalFrame objects and add them to the
@@ -266,7 +267,7 @@ public class JDesktopPane extends JLayeredPane implements Accessible
private static Collection getAllFrames(Container parent) {
int i, count;
- Collection results = new ArrayList();
+ Collection results = new LinkedHashSet<>();
count = parent.getComponentCount();
for (i = 0; i < count; i++) {
Component next = parent.getComponent(i);
diff --git a/src/windows/native/sun/windows/awt_Component.cpp b/src/windows/native/sun/windows/awt_Component.cpp
index 66fb1284e19b5dec6b1140eb9e8b05ab6ba829fb..5ab74c7e858b42561b48daf0814d6c092f359457 100644
--- a/src/windows/native/sun/windows/awt_Component.cpp
+++ b/src/windows/native/sun/windows/awt_Component.cpp
@@ -6935,9 +6935,9 @@ Java_sun_awt_windows_WComponentPeer_nativeHandlesWheelScrolling (JNIEnv* env,
{
TRY;
- return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall(
+ return (jboolean)AwtToolkit::GetInstance().SyncCall(
(void *(*)(void *))AwtComponent::_NativeHandlesWheelScrolling,
- env->NewGlobalRef(self)));
+ env->NewGlobalRef(self));
// global ref is deleted in _NativeHandlesWheelScrolling
CATCH_BAD_ALLOC_RET(NULL);
@@ -6956,9 +6956,9 @@ Java_sun_awt_windows_WComponentPeer_isObscured(JNIEnv* env,
jobject selfGlobalRef = env->NewGlobalRef(self);
- return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall(
+ return (jboolean)AwtToolkit::GetInstance().SyncCall(
(void*(*)(void*))AwtComponent::_IsObscured,
- (void *)selfGlobalRef));
+ (void *)selfGlobalRef);
// selfGlobalRef is deleted in _IsObscured
CATCH_BAD_ALLOC_RET(NULL);
diff --git a/src/windows/native/sun/windows/awt_List.cpp b/src/windows/native/sun/windows/awt_List.cpp
index c6cec8fe08b2c3a40db761af720420d7a426e595..5188c85984fe055af99494a0982957168328e2b6 100644
--- a/src/windows/native/sun/windows/awt_List.cpp
+++ b/src/windows/native/sun/windows/awt_List.cpp
@@ -1018,8 +1018,8 @@ Java_sun_awt_windows_WListPeer_isSelected(JNIEnv *env, jobject self,
ses->list = env->NewGlobalRef(self);
ses->index = index;
- return JNI_IS_TRUE(AwtToolkit::GetInstance().SyncCall(
- (void *(*)(void *))AwtList::_IsSelected, ses));
+ return (jboolean)AwtToolkit::GetInstance().SyncCall(
+ (void *(*)(void *))AwtList::_IsSelected, ses);
// global ref and ses are deleted in _IsSelected
CATCH_BAD_ALLOC_RET(FALSE);
diff --git a/test/java/awt/Focus/WindowIsFocusableAccessByThreadsTest/WindowIsFocusableAccessByThreadsTest.java b/test/java/awt/Focus/WindowIsFocusableAccessByThreadsTest/WindowIsFocusableAccessByThreadsTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..3fe6c19cebd6f43fce445970f882a5f6fdcb1c95
--- /dev/null
+++ b/test/java/awt/Focus/WindowIsFocusableAccessByThreadsTest/WindowIsFocusableAccessByThreadsTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+
+/*
+ @test
+ @bug 8047288
+ @summary Tests method isFocusable of Window component. It should be accessed only from EDT
+ @author artem.malinko@oracle.com
+ @library ../../regtesthelpers
+ @build Util
+ @run main WindowIsFocusableAccessByThreadsTest
+*/
+
+import test.java.awt.regtesthelpers.Util;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class WindowIsFocusableAccessByThreadsTest {
+ private static AtomicBoolean testPassed = new AtomicBoolean(true);
+ private static volatile TestFrame frame;
+ private static volatile TestWindow window;
+ private static volatile Button openWindowBtn;
+
+ public static void main(String[] args) {
+ frame = new TestFrame("Test EDT access to Window components");
+ window = new TestWindow(frame);
+
+ SwingUtilities.invokeLater(WindowIsFocusableAccessByThreadsTest::init);
+
+ Util.waitTillShown(frame);
+ Robot robot = Util.createRobot();
+ Util.clickOnComp(frame, robot, 100);
+ Util.clickOnComp(openWindowBtn, robot, 100);
+
+ Util.waitTillShown(window);
+
+ if (!testPassed.get()) {
+ throw new RuntimeException("Window component methods has been accessed not " +
+ "from Event Dispatching Thread");
+ }
+ }
+
+ private static void init() {
+ frame.setSize(400, 400);
+ frame.setLayout(new FlowLayout());
+ openWindowBtn = new Button("open window");
+ openWindowBtn.addActionListener(e -> {
+ window.setSize(100, 100);
+ window.setLocation(400, 100);
+ window.setVisible(true);
+ });
+ frame.add(openWindowBtn);
+ frame.setVisible(true);
+ }
+
+ private static void testThread() {
+ if (!SwingUtilities.isEventDispatchThread()) {
+ testPassed.set(false);
+ }
+ }
+
+ private static class TestWindow extends Window {
+ public TestWindow(Frame owner) {
+ super(owner);
+ }
+
+ // isFocusable method is final and we can't add this test to it.
+ // But it invokes getFocusableWindowState and here we can check
+ // if thread is EDT.
+ @Override
+ public boolean getFocusableWindowState() {
+ testThread();
+ return super.getFocusableWindowState();
+ }
+ }
+
+ private static class TestFrame extends Frame {
+ private TestFrame(String title) throws HeadlessException {
+ super(title);
+ }
+
+ // isFocusable method is final and we can't add this test to it.
+ // But it invokes getFocusableWindowState and here we can check
+ // if thread is EDT.
+ @Override
+ public boolean getFocusableWindowState() {
+ testThread();
+ return super.getFocusableWindowState();
+ }
+ }
+}