--- old/test/java/nio/channels/Selector/LotsOfUpdates.java 2017-06-01 14:24:45.000000000 +0800 +++ new/test/java/nio/channels/Selector/LotsOfUpdates.java 2017-06-01 14:24:45.000000000 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2017, 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 @@ -21,8 +21,10 @@ * questions. */ -import java.nio.channels.*; import java.io.IOException; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; public class LotsOfUpdates { public static void main(String[] args) throws IOException { --- old/test/java/nio/channels/SocketChannel/Open.java 2017-06-01 14:24:46.000000000 +0800 +++ new/test/java/nio/channels/SocketChannel/Open.java 2017-06-01 14:24:46.000000000 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, 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 @@ -21,16 +21,11 @@ * questions. */ -/* @test - * @bug 4614065 - * @summary Test SocketChannel gc after running out of fds - * @build Open - * @run shell Open.sh - */ - -import java.net.*; -import java.nio.*; -import java.nio.channels.*; +import java.net.SocketException; +import java.nio.channels.DatagramChannel; +import java.nio.channels.Pipe; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; import java.nio.channels.spi.SelectorProvider; public class Open { --- /dev/null 2017-06-01 14:24:47.000000000 +0800 +++ new/test/java/nio/channels/Selector/LotsOfUpdatesTest.java 2017-06-01 14:24:47.000000000 +0800 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017, 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 6824477 + * @summary Selector.select can fail with IOException "Invalid argument" on + * Solaris if maximum number of file descriptors is less than 10000 + * @requires (os.family != "windows") + * @library /test/lib + * @build LotsOfUpdates + * @run main LotsOfUpdatesTest + */ + +import jdk.test.lib.process.ProcessTools; + +public class LotsOfUpdatesTest { + + //hard limit needs to be less than 10000 for this bug + private static final String ULIMIT_SET_CMD = "ulimit -n 2048"; + + private static final String JAVA_CMD = ProcessTools.getCommandLine( + ProcessTools.createJavaProcessBuilder(LotsOfUpdates.class.getName())); + + public static void main(String[] args) throws Throwable { + ProcessTools.executeCommand("sh", "-c", ULIMIT_SET_CMD + " && " + JAVA_CMD) + .shouldHaveExitValue(0); + } +} --- /dev/null 2017-06-01 14:24:48.000000000 +0800 +++ new/test/java/nio/channels/SocketChannel/OpenSocketChannelTest.java 2017-06-01 14:24:48.000000000 +0800 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017, 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 4614065 + * @summary Test SocketChannel gc after running out of fds + * @requires (os.family == "solaris") + * @library /test/lib + * @build Open + * @run main OpenSocketChannelTest + */ + +import jdk.test.lib.process.ProcessTools; + +public class OpenSocketChannelTest { + + //hard limit needs to be small for this bug + private static final String ULIMIT_SET_CMD = "ulimit -n 100"; + + private static final String JAVA_CMD = ProcessTools.getCommandLine( + ProcessTools.createJavaProcessBuilder(Open.class.getName())); + + public static void main(String[] args) throws Throwable { + ProcessTools.executeCommand("sh", "-c", ULIMIT_SET_CMD + " && " + JAVA_CMD) + .shouldHaveExitValue(0); + } +} --- old/test/java/nio/channels/Selector/lots_of_updates.sh 2017-06-01 14:24:49.000000000 +0800 +++ /dev/null 2017-06-01 14:24:49.000000000 +0800 @@ -1,49 +0,0 @@ -# -# Copyright (c) 2009, 2012, 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 6824477 -# @summary Selector.select can fail with IOException "Invalid argument" on -# Solaris if maximum number of file descriptors is less than 10000 -# @build LotsOfUpdates -# @run shell lots_of_updates.sh - -OS=`uname -s` -case "$OS" in - Windows_* | CYGWIN* ) - echo "ulimit not on Windows" - exit 0 - ;; - * ) - CLASSPATH=${TESTCLASSES}:${TESTSRC} - ;; -esac -export CLASSPATH - -# hard limit needs to be less than 10000 for this bug -NOFILES=`ulimit -n -H` -if [ "$NOFILES" = "unlimited" ] || [ $NOFILES -ge 10000 ]; then - ulimit -n 2048 -fi - -${TESTJAVA}/bin/java ${TESTVMOPTS} LotsOfUpdates --- old/test/java/nio/channels/SocketChannel/Open.sh 2017-06-01 14:24:49.000000000 +0800 +++ /dev/null 2017-06-01 14:24:49.000000000 +0800 @@ -1,35 +0,0 @@ -#! /bin/sh - -# -# Copyright (c) 2002, 2012, 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. -# - -# - - OS=`uname -s` - case "$OS" in - SunOS ) - ulimit -n 100 - $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES Open ;; - * ) - echo "unrecognized system: $OS" ;; - esac