OpenJDK / jdk8u / jdk8u / jdk
changeset 9253:5800e3096132
Merge
author | kvn |
---|---|
date | Tue, 25 Feb 2014 15:10:27 -0800 |
parents | 6d5ca1fe72a0 1d117e299b9b |
children | a05bd28cef7f |
files | test/ProblemList.txt |
diffstat | 12 files changed, 278 insertions(+), 159 deletions(-) [+] |
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Feb 20 16:46:32 2014 -0800 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Tue Feb 25 15:10:27 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -583,7 +583,12 @@ // setVisible could have changed the native maximized state deliverZoom(true); } else { - switch (((Frame)target).getExtendedState()) { + int frameState = ((Frame)target).getExtendedState(); + if ((frameState & Frame.ICONIFIED) != 0) { + // Treat all state bit masks with ICONIFIED bit as ICONIFIED state. + frameState = Frame.ICONIFIED; + } + switch (frameState) { case Frame.ICONIFIED: CWrapper.NSWindow.miniaturize(nsWindowPtr); break; @@ -788,6 +793,10 @@ if (prevWindowState == windowState) return; final long nsWindowPtr = getNSWindowPtr(); + if ((windowState & Frame.ICONIFIED) != 0) { + // Treat all state bit masks with ICONIFIED bit as ICONIFIED state. + windowState = Frame.ICONIFIED; + } switch (windowState) { case Frame.ICONIFIED: if (prevWindowState == Frame.MAXIMIZED_BOTH) {
--- a/src/share/classes/sun/nio/ch/FileChannelImpl.java Thu Feb 20 16:46:32 2014 -0800 +++ b/src/share/classes/sun/nio/ch/FileChannelImpl.java Tue Feb 25 15:10:27 2014 -0800 @@ -110,7 +110,7 @@ } } - nd.preClose(fd); + // signal any threads blocked on this channel threads.signalAndWait(); if (parent != null) {
--- a/src/share/classes/sun/nio/ch/NativeThreadSet.java Thu Feb 20 16:46:32 2014 -0800 +++ b/src/share/classes/sun/nio/ch/NativeThreadSet.java Tue Feb 25 15:10:27 2014 -0800 @@ -82,8 +82,9 @@ // Signals all threads in this set. // - void signalAndWait() { - synchronized (this) { + synchronized void signalAndWait() { + boolean interrupted = false; + while (used > 0) { int u = used; int n = elts.length; for (int i = 0; i < n; i++) { @@ -96,16 +97,15 @@ break; } waitingToEmpty = true; - boolean interrupted = false; - while (used > 0) { - try { - wait(); - } catch (InterruptedException e) { - interrupted = true; - } + try { + wait(50); + } catch (InterruptedException e) { + interrupted = true; + } finally { + waitingToEmpty = false; } - if (interrupted) - Thread.currentThread().interrupt(); } + if (interrupted) + Thread.currentThread().interrupt(); } }
--- a/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java Thu Feb 20 16:46:32 2014 -0800 +++ b/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java Tue Feb 25 15:10:27 2014 -0800 @@ -88,7 +88,6 @@ invalidateAllLocks(); // signal any threads blocked on this channel - nd.preClose(fdObj); threads.signalAndWait(); // wait until all async I/O operations have completely gracefully
--- a/src/solaris/native/sun/awt/gtk2_interface.c Thu Feb 20 16:46:32 2014 -0800 +++ b/src/solaris/native/sun/awt/gtk2_interface.c Tue Feb 25 15:10:27 2014 -0800 @@ -32,6 +32,7 @@ #include "java_awt_Transparency.h" #include "jvm_md.h" #include "sizecalc.h" +#include <jni_util.h> #define GTK2_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("gtk-x11-2.0", "0") #define GTK2_LIB JNI_LIB_NAME("gtk-x11-2.0") @@ -456,13 +457,19 @@ const gchar * const * schemes = NULL; jclass cls_action = (*env)->FindClass(env, "java/awt/Desktop$Action"); + CHECK_NULL(cls_action); jclass cls_xDesktopPeer = (*env)->FindClass(env, "sun/awt/X11/XDesktopPeer"); + CHECK_NULL(cls_xDesktopPeer); jfieldID fld_supportedActions = (*env)->GetStaticFieldID(env, cls_xDesktopPeer, "supportedActions", "Ljava/util/List;"); + CHECK_NULL(fld_supportedActions); jobject supportedActions = (*env)->GetStaticObjectField(env, cls_xDesktopPeer, fld_supportedActions); jclass cls_arrayList = (*env)->FindClass(env, "java/util/ArrayList"); + CHECK_NULL(cls_arrayList); jmethodID mid_arrayListAdd = (*env)->GetMethodID(env, cls_arrayList, "add", "(Ljava/lang/Object;)Z"); + CHECK_NULL(mid_arrayListAdd); jmethodID mid_arrayListClear = (*env)->GetMethodID(env, cls_arrayList, "clear", "()V"); + CHECK_NULL(mid_arrayListClear); (*env)->CallVoidMethod(env, supportedActions, mid_arrayListClear);
--- a/src/solaris/native/sun/nio/ch/NativeThread.c Thu Feb 20 16:46:32 2014 -0800 +++ b/src/solaris/native/sun/nio/ch/NativeThread.c Tue Feb 25 15:10:27 2014 -0800 @@ -32,27 +32,32 @@ #include "sun_nio_ch_NativeThread.h" #include "nio_util.h" - #ifdef __linux__ -#include <pthread.h> -#include <sys/signal.h> - -/* Also defined in src/solaris/native/java/net/linux_close.c */ -#define INTERRUPT_SIGNAL (__SIGRTMAX - 2) + #include <pthread.h> + #include <sys/signal.h> + /* Also defined in net/linux_close.c */ + #define INTERRUPT_SIGNAL (__SIGRTMAX - 2) +#elif __solaris__ + #include <thread.h> + #include <signal.h> + #define INTERRUPT_SIGNAL (SIGRTMAX - 2) +#elif _ALLBSD_SOURCE + #include <pthread.h> + #include <signal.h> + /* Also defined in net/bsd_close.c */ + #define INTERRUPT_SIGNAL SIGIO +#else + #error "missing platform-specific definition here" +#endif static void nullHandler(int sig) { } -#endif - - JNIEXPORT void JNICALL Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl) { -#ifdef __linux__ - /* Install the null handler for INTERRUPT_SIGNAL. This might overwrite the * handler previously installed by java/net/linux_close.c, but that's okay * since neither handler actually does anything. We install our own @@ -67,25 +72,27 @@ sigemptyset(&sa.sa_mask); if (sigaction(INTERRUPT_SIGNAL, &sa, &osa) < 0) JNU_ThrowIOExceptionWithLastError(env, "sigaction"); - -#endif } JNIEXPORT jlong JNICALL Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl) { -#ifdef __linux__ - return (long)pthread_self(); +#ifdef __solaris__ + return (jlong)thr_self(); #else - return -1; + return (jlong)pthread_self(); #endif } JNIEXPORT void JNICALL Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread) { -#ifdef __linux__ - if (pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL)) + int ret; +#ifdef __solaris__ + ret = thr_kill((thread_t)thread, INTERRUPT_SIGNAL); +#else + ret = pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL); +#endif + if (ret != 0) JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed"); -#endif }
--- a/test/ProblemList.txt Thu Feb 20 16:46:32 2014 -0800 +++ b/test/ProblemList.txt Tue Feb 25 15:10:27 2014 -0800 @@ -188,11 +188,6 @@ # 6963118 java/nio/channels/Selector/Wakeup.java windows-all -# 7133499, 7133497 -java/nio/channels/AsyncCloseAndInterrupt.java macosx-all -java/nio/channels/AsynchronousFileChannel/Lock.java macosx-all -java/nio/channels/FileChannel/Transfer.java macosx-all - # 7141822 java/nio/channels/DatagramChannel/ChangingAddress.java macosx-all
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java Tue Feb 25 15:10:27 2014 -0800 @@ -0,0 +1,103 @@ +/* + * 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 8032078 + @summary Frame.setExtendedState throws RuntimeException, if + windowState=ICONIFIED|MAXIMIZED_BOTH, on OS X + @author Anton Litvinov +*/ + +import java.awt.*; + +import sun.awt.SunToolkit; + +public class ExceptionOnSetExtendedStateTest { + private static final int[] frameStates = { Frame.NORMAL, Frame.ICONIFIED, Frame.MAXIMIZED_BOTH }; + private static final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit(); + + private static boolean validatePlatform() { + String osName = System.getProperty("os.name"); + if (osName == null) { + throw new RuntimeException("Name of the current OS could not be retrieved."); + } + return osName.startsWith("Mac"); + } + + private static void testStateChange(int oldState, int newState, boolean decoratedFrame) { + System.out.println(String.format( + "testStateChange: oldState='%d', newState='%d', decoratedFrame='%b'", + oldState, newState, decoratedFrame)); + + Frame frame = new Frame("ExceptionOnSetExtendedStateTest"); + frame.setSize(200, 200); + frame.setUndecorated(!decoratedFrame); + frame.setVisible(true); + toolkit.realSync(); + + frame.setExtendedState(oldState); + sleep(1000); + frame.setExtendedState(newState); + + boolean stateWasNotChanged = true; + int currentState = 0; + for (int i = 0; (i < 3) && stateWasNotChanged; i++) { + sleep(1000); + currentState = frame.getExtendedState(); + if ((currentState == newState) || + (((newState & Frame.ICONIFIED) != 0) && ((currentState & Frame.ICONIFIED) != 0))) { + stateWasNotChanged = false; + } + } + frame.dispose(); + + if (stateWasNotChanged) { + throw new RuntimeException(String.format( + "Frame state was not changed. currentState='%d'", currentState)); + } + } + + private static void sleep(int millis) { + try { + Thread.sleep(millis); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void main(String[] args) { + if (!validatePlatform()) { + System.out.println("This test is only for OS X."); + return; + } + + // Verify that changing states of decorated/undecorated frame to/from supported states + // and the state bit mask ICONIFIED | MAXIMIZED_BOTH does not raise RuntimeException. + for (int i = 0; i < frameStates.length; i++) { + testStateChange(frameStates[i], Frame.ICONIFIED | Frame.MAXIMIZED_BOTH, true); + testStateChange(frameStates[i], Frame.ICONIFIED | Frame.MAXIMIZED_BOTH, false); + testStateChange(Frame.ICONIFIED | Frame.MAXIMIZED_BOTH, frameStates[i], true); + testStateChange(Frame.ICONIFIED | Frame.MAXIMIZED_BOTH, frameStates[i], false); + } + } +}
--- a/test/java/nio/channels/Selector/ByteServer.java Thu Feb 20 16:46:32 2014 -0800 +++ b/test/java/nio/channels/Selector/ByteServer.java Tue Feb 25 15:10:27 2014 -0800 @@ -22,52 +22,54 @@ */ /** - * - * Utility class for tests. A simple server, which waits for a connection, - * writes out n bytes and waits. + * Utility class for tests. A simple "in-thread" server to accept connections + * and write bytes. * @author kladko */ import java.net.Socket; import java.net.ServerSocket; - -public class ByteServer { +import java.net.SocketAddress; +import java.net.InetSocketAddress; +import java.io.IOException; +import java.io.Closeable; - public static final String LOCALHOST = "localhost"; - private int bytecount; - private Socket socket; - private ServerSocket serversocket; - private Thread serverthread; - volatile Exception savedException; +public class ByteServer implements Closeable { - public ByteServer(int bytecount) throws Exception{ - this.bytecount = bytecount; - serversocket = new ServerSocket(0); + private final ServerSocket ss; + private Socket s; + + ByteServer() throws IOException { + this.ss = new ServerSocket(0); } - public int port() { - return serversocket.getLocalPort(); + SocketAddress address() { + return new InetSocketAddress(ss.getInetAddress(), ss.getLocalPort()); } - public void start() { - serverthread = new Thread() { - public void run() { - try { - socket = serversocket.accept(); - socket.getOutputStream().write(new byte[bytecount]); - socket.getOutputStream().flush(); - } catch (Exception e) { - System.err.println("Exception in ByteServer: " + e); - System.exit(1); - } - } - }; - serverthread.start(); + void acceptConnection() throws IOException { + if (s != null) + throw new IllegalStateException("already connected"); + this.s = ss.accept(); } - public void exit() throws Exception { - serverthread.join(); - socket.close(); - serversocket.close(); + void closeConnection() throws IOException { + Socket s = this.s; + if (s != null) { + this.s = null; + s.close(); + } + } + + void write(int count) throws IOException { + if (s == null) + throw new IllegalStateException("no connection"); + s.getOutputStream().write(new byte[count]); + } + + public void close() throws IOException { + if (s != null) + s.close(); + ss.close(); } }
--- a/test/java/nio/channels/Selector/ReadAfterConnect.java Thu Feb 20 16:46:32 2014 -0800 +++ b/test/java/nio/channels/Selector/ReadAfterConnect.java Tue Feb 25 15:10:27 2014 -0800 @@ -27,27 +27,25 @@ * @author kladko */ -import java.net.*; -import java.nio.*; -import java.nio.channels.*; +import java.nio.channels.Selector; +import java.nio.channels.SelectionKey; +import java.nio.channels.SocketChannel; public class ReadAfterConnect { + public static void main(String[] argv) throws Exception { + try (ByteServer server = new ByteServer(); + SocketChannel sc = SocketChannel.open(server.address())) { - public static void main(String[] argv) throws Exception { - ByteServer server = new ByteServer(0); // server: accept connection and do nothing - server.start(); - InetSocketAddress isa = new InetSocketAddress( - InetAddress.getByName(ByteServer.LOCALHOST), server.port()); - Selector sel = Selector.open(); - SocketChannel sc = SocketChannel.open(); - sc.connect(isa); - sc.configureBlocking(false); - sc.register(sel, SelectionKey.OP_READ); - // Previously channel would get selected here, although there is nothing to read - if (sel.selectNow() != 0) - throw new Exception("Select returned nonzero value"); - sc.close(); - server.exit(); + server.acceptConnection(); + + try (Selector sel = Selector.open()) { + sc.configureBlocking(false); + sc.register(sel, SelectionKey.OP_READ); + // Previously channel would get selected here, although there is nothing to read + if (sel.selectNow() != 0) + throw new Exception("Select returned nonzero value"); + } + } } }
--- a/test/java/nio/channels/Selector/SelectAfterRead.java Thu Feb 20 16:46:32 2014 -0800 +++ b/test/java/nio/channels/Selector/SelectAfterRead.java Tue Feb 25 15:10:27 2014 -0800 @@ -28,60 +28,62 @@ * @author kladko */ -import java.net.*; -import java.nio.*; -import java.nio.channels.*; +import java.nio.ByteBuffer; +import java.nio.channels.Selector; +import java.nio.channels.SelectionKey; +import java.nio.channels.SocketChannel; public class SelectAfterRead { - final static int TIMEOUT = 1000; + private static final int TIMEOUT = 1000; public static void main(String[] argv) throws Exception { - InetAddress lh = InetAddress.getByName(ByteServer.LOCALHOST); // server: accept connection and write one byte - ByteServer server = new ByteServer(1); - server.start(); - Selector sel = Selector.open(); - SocketChannel sc = SocketChannel.open(); - sc.connect(new InetSocketAddress(lh, server.port())); - sc.read(ByteBuffer.allocate(1)); - sc.configureBlocking(false); - sc.register(sel, SelectionKey.OP_READ); - // previously on Windows select would select channel here, although there was - // nothing to read - if (sel.selectNow() != 0) - throw new Exception("Select returned nonzero value"); - sc.close(); - sel.close(); - server.exit(); + try (ByteServer server = new ByteServer(); + SocketChannel sc = SocketChannel.open(server.address())) { + + server.acceptConnection(); + server.write(1); + + try (Selector sel = Selector.open()) { + sc.read(ByteBuffer.allocate(1)); + sc.configureBlocking(false); + sc.register(sel, SelectionKey.OP_READ); + // previously on Windows select would select channel here, although there was + // nothing to read + if (sel.selectNow() != 0) + throw new Exception("Select returned nonzero value"); + } + } // Now we will test a two reads combination // server: accept connection and write two bytes - server = new ByteServer(2); - server.start(); - sc = SocketChannel.open(); - sc.connect(new InetSocketAddress(lh, server.port())); - sc.configureBlocking(false); - sel = Selector.open(); - sc.register(sel, SelectionKey.OP_READ); - if (sel.select(TIMEOUT) != 1) - throw new Exception("One selected key expected"); - sel.selectedKeys().clear(); - // previously on Windows a channel would get selected only once - if (sel.selectNow() != 1) - throw new Exception("One selected key expected"); - // Previously on Windows two consequent reads would cause select() - // to select a channel, although there was nothing remaining to - // read in the channel - if (sc.read(ByteBuffer.allocate(1)) != 1) - throw new Exception("One byte expected"); - if (sc.read(ByteBuffer.allocate(1)) != 1) - throw new Exception("One byte expected"); - if (sel.selectNow() != 0) - throw new Exception("Select returned nonzero value"); - sc.close(); - sel.close(); - server.exit(); + try (ByteServer server = new ByteServer(); + SocketChannel sc = SocketChannel.open(server.address())) { + + server.acceptConnection(); + server.write(2); + + try (Selector sel = Selector.open()) { + sc.configureBlocking(false); + sc.register(sel, SelectionKey.OP_READ); + if (sel.select(TIMEOUT) != 1) + throw new Exception("One selected key expected"); + sel.selectedKeys().clear(); + // previously on Windows a channel would get selected only once + if (sel.selectNow() != 1) + throw new Exception("One selected key expected"); + // Previously on Windows two consequent reads would cause select() + // to select a channel, although there was nothing remaining to + // read in the channel + if (sc.read(ByteBuffer.allocate(1)) != 1) + throw new Exception("One byte expected"); + if (sc.read(ByteBuffer.allocate(1)) != 1) + throw new Exception("One byte expected"); + if (sel.selectNow() != 0) + throw new Exception("Select returned nonzero value"); + } + } } }
--- a/test/java/nio/channels/Selector/SelectWrite.java Thu Feb 20 16:46:32 2014 -0800 +++ b/test/java/nio/channels/Selector/SelectWrite.java Tue Feb 25 15:10:27 2014 -0800 @@ -22,36 +22,33 @@ */ /* @test - @bug 4645302 - @summary Socket with OP_WRITE would get selected only once - @author kladko + * @bug 4645302 + * @summary Socket with OP_WRITE would get selected only once + * @author kladko */ -import java.net.*; -import java.nio.*; -import java.nio.channels.*; - +import java.nio.channels.Selector; +import java.nio.channels.SelectionKey; +import java.nio.channels.SocketChannel; public class SelectWrite { public static void main(String[] argv) throws Exception { - ByteServer server = new ByteServer(0); - // server: accept connection and do nothing - server.start(); - InetSocketAddress isa = new InetSocketAddress( - InetAddress.getByName(ByteServer.LOCALHOST), server.port()); - Selector sel = Selector.open(); - SocketChannel sc = SocketChannel.open(); - sc.connect(isa); - sc.configureBlocking(false); - sc.register(sel, SelectionKey.OP_WRITE); - sel.select(); - sel.selectedKeys().clear(); - if (sel.select() == 0) { - throw new Exception("Select returned zero"); + try (ByteServer server = new ByteServer(); + SocketChannel sc = SocketChannel.open(server.address())) { + + server.acceptConnection(); + + try (Selector sel = Selector.open()) { + sc.configureBlocking(false); + sc.register(sel, SelectionKey.OP_WRITE); + sel.select(); + sel.selectedKeys().clear(); + if (sel.select() == 0) { + throw new Exception("Select returned zero"); + } + } } - sc.close(); - sel.close(); } }