Mercurial > hg > icedtea7-forest-aarch64 > jdk
changeset 8172:00cdd87c5752
Merge
author | asaha |
---|---|
date | Wed, 10 Sep 2014 15:32:50 -0700 |
parents | 9d36c3e8428a (current diff) 1326b00e10d1 (diff) |
children | d0044d2ab731 |
files | make/java/net/FILES_c.gmk make/java/net/mapfile-vers src/share/classes/java/net/DatagramSocket.java src/share/classes/java/net/DatagramSocketImpl.java src/share/classes/sun/nio/ch/DatagramChannelImpl.java |
diffstat | 84 files changed, 3663 insertions(+), 209 deletions(-) [+] |
line wrap: on
line diff
--- a/make/Makefile Thu Aug 28 15:14:04 2014 -0700 +++ b/make/Makefile Wed Sep 10 15:32:50 2014 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1995, 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 @@ -232,7 +232,7 @@ all build:: sanity-all post-sanity-all -SUBDIRS = tools java javax sun com +SUBDIRS = tools java javax jdk sun com ifeq ($(PLATFORM), macosx) SUBDIRS += apple endif
--- a/make/common/shared/Defs-javadoc.gmk Thu Aug 28 15:14:04 2014 -0700 +++ b/make/common/shared/Defs-javadoc.gmk Wed Sep 10 15:32:50 2014 -0700 @@ -43,6 +43,7 @@ TREEAPI_FIRST_COPYRIGHT_YEAR = 2005 JNLP_FIRST_COPYRIGHT_YEAR = 1998 PLUGIN2_FIRST_COPYRIGHT_YEAR = 2007 +JDKNET_FIRST_COPYRIGHT_YEAR = 2014 # Oracle name FULL_COMPANY_NAME = Oracle and/or its affiliates
--- a/make/docs/Makefile Thu Aug 28 15:14:04 2014 -0700 +++ b/make/docs/Makefile Wed Sep 10 15:32:50 2014 -0700 @@ -1,4 +1,4 @@ -# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 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 @@ -836,6 +836,56 @@ ############################################################# # +# jdk.net docs +# + +ALL_OTHER_TARGETS += jdknetdocs + +JDKNET_DOCDIR := $(JRE_API_DOCSDIR)/net/socketoptions/spec +JDKNET2COREAPI := ../../../$(JDKJRE2COREAPI) +JDKNET_DOCTITLE := jdk.net API +JDKNET_WINDOWTITLE := jdk.net API +JDKNET_HEADER := <strong>jdk.net API</strong> +JDKNET_BOTTOM := $(call CommonBottom,$(JDKNET_FIRST_COPYRIGHT_YEAR)) +# JDKNET_PKGS is located in NON_CORE_PKGS.gmk + +JDKNET_INDEX_HTML = $(JDKNET_DOCDIR)/index.html +JDKNET_OPTIONS_FILE = $(DOCSTMPDIR)/jdknet.options +JDKNET_PACKAGES_FILE = $(DOCSTMPDIR)/jdknet.packages + +jdknetdocs: $(JDKNET_INDEX_HTML) + +# Set relative location to core api document root +$(JDKNET_INDEX_HTML): GET2DOCSDIR=$(JDKNET2COREAPI)/.. + +# Run javadoc if the index file is out of date or missing +$(JDKNET_INDEX_HTML): $(JDKNET_OPTIONS_FILE) $(JDKNET_PACKAGES_FILE) + $(prep-javadoc) + $(call JavadocSummary,$(JDKNET_OPTIONS_FILE),$(JDKNET_PACKAGES_FILE)) + $(JAVADOC_CMD) $(JAVADOC_VM_MEMORY_FLAGS) -d $(@D) \ + @$(JDKNET_OPTIONS_FILE) @$(JDKNET_PACKAGES_FILE) + +# Create file with javadoc options in it +$(JDKNET_OPTIONS_FILE): + $(prep-target) + @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ + $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ + $(call OptionPair,-encoding,ascii) ; \ + $(call OptionOnly,-nodeprecatedlist) ; \ + $(call OptionPair,-doctitle,$(JDKNET_DOCTITLE)) ; \ + $(call OptionPair,-windowtitle,$(JDKNET_WINDOWTITLE) $(DRAFT_WINTITLE));\ + $(call OptionPair,-header,$(JDKNET_HEADER)$(DRAFT_HEADER)); \ + $(call OptionPair,-bottom,$(JDKNET_BOTTOM)$(DRAFT_BOTTOM)); \ + $(call OptionTrip,-linkoffline,$(JDKNET2COREAPI),$(COREAPI_DOCSDIR)/); \ + ) >> $@ + +# Create a file with the package names in it +$(JDKNET_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(JDKNET_PKGS)) + $(prep-target) + $(call PackageFilter,$(JDKNET_PKGS)) + +############################################################# +# # httpserverdocs #
--- a/make/docs/NON_CORE_PKGS.gmk Thu Aug 28 15:14:04 2014 -0700 +++ b/make/docs/NON_CORE_PKGS.gmk Wed Sep 10 15:32:50 2014 -0700 @@ -62,6 +62,8 @@ OLD_JSSE_PKGS = com.sun.net.ssl +JDKNET_PKGS = jdk.net + HTTPSERVER_PKGS = com.sun.net.httpserver \ com.sun.net.httpserver.spi @@ -99,6 +101,7 @@ NON_CORE_PKGS = $(DOMAPI_PKGS) \ $(MGMT_PKGS) \ $(JAAS_PKGS) \ + $(JDKNET_PKGS) \ $(JGSS_PKGS) \ $(NIO_PKGS) \ $(OLD_JSSE_PKGS) \
--- a/make/java/net/FILES_c.gmk Thu Aug 28 15:14:04 2014 -0700 +++ b/make/java/net/FILES_c.gmk Wed Sep 10 15:32:50 2014 -0700 @@ -26,6 +26,7 @@ FILES_c = \ AbstractPlainDatagramSocketImpl.c \ DatagramPacket.c \ + ExtendedOptionsImpl.c \ InetAddress.c \ Inet4Address.c \ Inet6Address.c \
--- a/make/java/net/mapfile-vers Thu Aug 28 15:14:04 2014 -0700 +++ b/make/java/net/mapfile-vers Wed Sep 10 15:32:50 2014 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 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 @@ -96,6 +96,10 @@ Java_sun_net_sdp_SdpSupport_create0; Java_sun_net_spi_DefaultProxySelector_init; Java_sun_net_spi_DefaultProxySelector_getSystemProxy; + Java_sun_net_ExtendedOptionsImpl_init; + Java_sun_net_ExtendedOptionsImpl_setFlowOption; + Java_sun_net_ExtendedOptionsImpl_getFlowOption; + Java_sun_net_ExtendedOptionsImpl_flowSupported; NET_AllocSockaddr; NET_SockaddrToInetAddress; NET_SockaddrEqualsInetAddress;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/jdk/Makefile Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,40 @@ +# +# 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# + +# +# Makefile for building jdk sub dir +# + +BUILDDIR = .. +PRODUCT = jdk +include $(BUILDDIR)/common/Defs.gmk + +SUBDIRS = net + +include $(BUILDDIR)/common/Subdirs.gmk + +all build clean clobber:: + $(SUBDIRS-loop) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/jdk/net/FILES_java.gmk Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,30 @@ +# +# 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# + +FILES_java = \ + jdk/net/ExtendedSocketOptions.java \ + jdk/net/NetworkPermission.java \ + jdk/net/SocketFlow.java \ + jdk/net/Sockets.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/jdk/net/Makefile Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,43 @@ +# +# 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. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# 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. +# + +# +# Makefile for building jdk.net classes +# + +BUILDDIR = ../.. +PACKAGE = jdk.net +PRODUCT = sun +include $(BUILDDIR)/common/Defs.gmk + +# +# Files to compile. +# +AUTO_FILES_JAVA_DIRS = jdk/net + +# +# Rules. +# +include $(BUILDDIR)/common/Classes.gmk
--- a/make/sun/net/FILES_java.gmk Thu Aug 28 15:14:04 2014 -0700 +++ b/make/sun/net/FILES_java.gmk Wed Sep 10 15:32:50 2014 -0700 @@ -24,6 +24,7 @@ # FILES_java = \ + sun/net/ExtendedOptionsImpl.java \ sun/net/InetAddressCachePolicy.java \ sun/net/URLCanonicalizer.java \ sun/net/NetworkClient.java \
--- a/src/share/classes/com/sun/java/swing/SwingUtilities3.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/com/sun/java/swing/SwingUtilities3.java Wed Sep 10 15:32:50 2014 -0700 @@ -27,6 +27,8 @@ import sun.awt.EventQueueDelegate; import sun.awt.AppContext; +import sun.awt.SunToolkit; + import java.util.Collections; import java.util.Map; import java.util.WeakHashMap; @@ -117,8 +119,8 @@ public static RepaintManager getDelegateRepaintManager(Component component) { RepaintManager delegate = null; - if (Boolean.TRUE == AppContext.getAppContext().get( - DELEGATE_REPAINT_MANAGER_KEY)) { + if (Boolean.TRUE == SunToolkit.targetToAppContext(component) + .get(DELEGATE_REPAINT_MANAGER_KEY)) { while (delegate == null && component != null) { while (component != null && ! (component instanceof JComponent)) {
--- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ja.properties Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ja.properties Wed Sep 10 15:32:50 2014 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic={0}\u306E\u540D\u524D\u3092\u5909\u66F4\u3067\u304D\u307E\u305B\u3093: \u6307\u5B9A\u3057\u305F\u540D\u524D\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u3059\u3067\u306B\u5B58\u5728\u3057\u307E\u3059\u3002\u5225\u306E\u30D5\u30A1\u30A4\u30EB\u540D\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002 FileChooser.acceptAllFileFilter.textAndMnemonic=\u3059\u3079\u3066\u306E\u30D5\u30A1\u30A4\u30EB FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88 -FileChooser.saveButton.textAndMnemonic=\u4FDD\u5B58(&S) -FileChooser.openButton.textAndMnemonic=\u958B\u304F(&O) +FileChooser.saveButton.textAndMnemonic=\u4FDD\u5B58 +FileChooser.openButton.textAndMnemonic=\u958B\u304F FileChooser.saveDialogTitle.textAndMnemonic=\u4FDD\u5B58 FileChooser.openDialogTitle.textAndMnemonic=\u958B\u304F FileChooser.updateButton.textAndMnemonic=\u66F4\u65B0(&U) FileChooser.helpButton.textAndMnemonic=\u30D8\u30EB\u30D7(&H) -FileChooser.directoryOpenButton.textAndMnemonic=\u958B\u304F(&O) +FileChooser.directoryOpenButton.textAndMnemonic=\u958B\u304F # File Size Units FileChooser.fileSizeKiloBytes={0} KB
--- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ko.properties Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ko.properties Wed Sep 10 15:32:50 2014 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic={0}\uC758 \uC774\uB984\uC744 \uBC14\uAFC0 \uC218 \uC5C6\uC74C: \uC9C0\uC815\uD55C \uC774\uB984\uC744 \uC0AC\uC6A9\uD558\uB294 \uD30C\uC77C\uC774 \uC874\uC7AC\uD569\uB2C8\uB2E4. \uB2E4\uB978 \uD30C\uC77C \uC774\uB984\uC744 \uC9C0\uC815\uD558\uC2ED\uC2DC\uC624. FileChooser.acceptAllFileFilter.textAndMnemonic=\uBAA8\uB4E0 \uD30C\uC77C FileChooser.cancelButton.textAndMnemonic=\uCDE8\uC18C -FileChooser.saveButton.textAndMnemonic=\uC800\uC7A5(&S) -FileChooser.openButton.textAndMnemonic=\uC5F4\uAE30(&O) +FileChooser.saveButton.textAndMnemonic=\uC800\uC7A5 +FileChooser.openButton.textAndMnemonic=\uC5F4\uAE30 FileChooser.saveDialogTitle.textAndMnemonic=\uC800\uC7A5 FileChooser.openDialogTitle.textAndMnemonic=\uC5F4\uAE30 FileChooser.updateButton.textAndMnemonic=\uC5C5\uB370\uC774\uD2B8(&U) FileChooser.helpButton.textAndMnemonic=\uB3C4\uC6C0\uB9D0(&H) -FileChooser.directoryOpenButton.textAndMnemonic=\uC5F4\uAE30(&O) +FileChooser.directoryOpenButton.textAndMnemonic=\uC5F4\uAE30 # File Size Units FileChooser.fileSizeKiloBytes={0} KB
--- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_CN.properties Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_CN.properties Wed Sep 10 15:32:50 2014 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic=\u65E0\u6CD5\u91CD\u547D\u540D{0}: \u5DF2\u5B58\u5728\u5177\u6709\u6240\u6307\u5B9A\u540D\u79F0\u7684\u6587\u4EF6\u3002\u8BF7\u6307\u5B9A\u5176\u4ED6\u6587\u4EF6\u540D\u3002 FileChooser.acceptAllFileFilter.textAndMnemonic=\u6240\u6709\u6587\u4EF6 FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88 -FileChooser.saveButton.textAndMnemonic=\u4FDD\u5B58(&S) -FileChooser.openButton.textAndMnemonic=\u6253\u5F00(&O) +FileChooser.saveButton.textAndMnemonic=\u4FDD\u5B58 +FileChooser.openButton.textAndMnemonic=\u6253\u5F00 FileChooser.saveDialogTitle.textAndMnemonic=\u4FDD\u5B58 FileChooser.openDialogTitle.textAndMnemonic=\u6253\u5F00 FileChooser.updateButton.textAndMnemonic=\u66F4\u65B0(&U) FileChooser.helpButton.textAndMnemonic=\u5E2E\u52A9(&H) -FileChooser.directoryOpenButton.textAndMnemonic=\u6253\u5F00(&O) +FileChooser.directoryOpenButton.textAndMnemonic=\u6253\u5F00 # File Size Units FileChooser.fileSizeKiloBytes={0} KB
--- a/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_TW.properties Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_TW.properties Wed Sep 10 15:32:50 2014 -0700 @@ -42,13 +42,13 @@ FileChooser.renameErrorFileExists.textAndMnemonic=\u7121\u6CD5\u91CD\u65B0\u547D\u540D {0}: \u5DF2\u7D93\u5B58\u5728\u60A8\u6240\u6307\u5B9A\u540D\u7A31\u7684\u6A94\u6848\u3002\u8ACB\u6307\u5B9A\u4E0D\u540C\u7684\u540D\u7A31\u3002 FileChooser.acceptAllFileFilter.textAndMnemonic=\u6240\u6709\u6A94\u6848 FileChooser.cancelButton.textAndMnemonic=\u53D6\u6D88 -FileChooser.saveButton.textAndMnemonic=\u5132\u5B58(&S) -FileChooser.openButton.textAndMnemonic=\u958B\u555F(&O) +FileChooser.saveButton.textAndMnemonic=\u5132\u5B58 +FileChooser.openButton.textAndMnemonic=\u958B\u555F FileChooser.saveDialogTitle.textAndMnemonic=\u5132\u5B58 FileChooser.openDialogTitle.textAndMnemonic=\u958B\u555F FileChooser.updateButton.textAndMnemonic=\u66F4\u65B0(&U) FileChooser.helpButton.textAndMnemonic=\u8AAA\u660E(&H) -FileChooser.directoryOpenButton.textAndMnemonic=\u958B\u555F(&O) +FileChooser.directoryOpenButton.textAndMnemonic=\u958B\u555F # File Size Units FileChooser.fileSizeKiloBytes={0} KB
--- a/src/share/classes/java/awt/Component.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/java/awt/Component.java Wed Sep 10 15:32:50 2014 -0700 @@ -3394,7 +3394,7 @@ (width > 0) && (height > 0)) { PaintEvent e = new PaintEvent(this, PaintEvent.UPDATE, new Rectangle(x, y, width, height)); - Toolkit.getEventQueue().postEvent(e); + SunToolkit.postEvent(SunToolkit.targetToAppContext(this), e); } } }
--- a/src/share/classes/java/io/File.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/java/io/File.java Wed Sep 10 15:32:50 2014 -0700 @@ -1891,7 +1891,7 @@ String name = prefix + Long.toString(n) + suffix; File f = new File(dir, name); - if (!name.equals(f.getName())) { + if (!name.equals(f.getName()) || f.isInvalid()) { if (System.getSecurityManager() != null) throw new IOException("Unable to create temporary file"); else @@ -1981,19 +1981,26 @@ File tmpdir = (directory != null) ? directory : TempDirectory.location(); + SecurityManager sm = System.getSecurityManager(); File f; - try { - do { - f = TempDirectory.generateFile(prefix, suffix, tmpdir); - } while (f.exists()); - if (!f.createNewFile()) - throw new IOException("Unable to create temporary file"); - } catch (SecurityException se) { - // don't reveal temporary directory location - if (directory == null) - throw new SecurityException("Unable to create temporary file"); - throw se; - } + do { + f = TempDirectory.generateFile(prefix, suffix, tmpdir); + + if (sm != null) { + try { + sm.checkWrite(f.getPath()); + } catch (SecurityException se) { + // don't reveal temporary directory location + if (directory == null) + throw new SecurityException("Unable to create temporary file"); + throw se; + } + } + } while ((fs.getBooleanAttributes(f) & FileSystem.BA_EXISTS) != 0); + + if (!fs.createFileExclusively(f.getPath())) + throw new IOException("Unable to create temporary file"); + return f; }
--- a/src/share/classes/java/lang/ConditionalSpecialCasing.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/java/lang/ConditionalSpecialCasing.java Wed Sep 10 15:32:50 2014 -0700 @@ -62,6 +62,7 @@ //# Conditional mappings //# ================================================================================ new Entry(0x03A3, new char[]{0x03C2}, new char[]{0x03A3}, null, FINAL_CASED), // # GREEK CAPITAL LETTER SIGMA + new Entry(0x0130, new char[]{0x0069, 0x0307}, new char[]{0x0130}, null, 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE //# ================================================================================ //# Locale-sensitive mappings @@ -77,8 +78,8 @@ //# ================================================================================ //# Turkish and Azeri -// new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "tr", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE -// new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "az", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE + new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "tr", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE + new Entry(0x0130, new char[]{0x0069}, new char[]{0x0130}, "az", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE new Entry(0x0307, new char[]{}, new char[]{0x0307}, "tr", AFTER_I), // # COMBINING DOT ABOVE new Entry(0x0307, new char[]{}, new char[]{0x0307}, "az", AFTER_I), // # COMBINING DOT ABOVE new Entry(0x0049, new char[]{0x0131}, new char[]{0x0049}, "tr", NOT_BEFORE_DOT), // # LATIN CAPITAL LETTER I @@ -148,21 +149,25 @@ private static char[] lookUpTable(String src, int index, Locale locale, boolean bLowerCasing) { HashSet set = (HashSet)entryTable.get(new Integer(src.codePointAt(index))); + char[] ret = null; if (set != null) { Iterator iter = set.iterator(); String currentLang = locale.getLanguage(); while (iter.hasNext()) { Entry entry = (Entry)iter.next(); - String conditionLang= entry.getLanguage(); + String conditionLang = entry.getLanguage(); if (((conditionLang == null) || (conditionLang.equals(currentLang))) && isConditionMet(src, index, locale, entry.getCondition())) { - return (bLowerCasing ? entry.getLowerCase() : entry.getUpperCase()); + ret = bLowerCasing ? entry.getLowerCase() : entry.getUpperCase(); + if (conditionLang != null) { + break; + } } } } - return null; + return ret; } private static boolean isConditionMet(String src, int index, Locale locale, int condition) {
--- a/src/share/classes/java/lang/String.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/java/lang/String.java Wed Sep 10 15:32:50 2014 -0700 @@ -2459,7 +2459,9 @@ } else { srcCount = 1; } - if (localeDependent || srcChar == '\u03A3') { // GREEK CAPITAL LETTER SIGMA + if (localeDependent || + srcChar == '\u03A3' || // GREEK CAPITAL LETTER SIGMA + srcChar == '\u0130') { // LATIN CAPITAL LETTER I WITH DOT ABOVE lowerChar = ConditionalSpecialCasing.toLowerCaseEx(this, i, locale); } else { lowerChar = Character.toLowerCase(srcChar);
--- a/src/share/classes/java/net/DatagramSocket.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/java/net/DatagramSocket.java Wed Sep 10 15:32:50 2014 -0700 @@ -340,6 +340,7 @@ } // creates a udp socket impl.create(); + impl.setDatagramSocket(this); created = true; }
--- a/src/share/classes/java/net/DatagramSocketImpl.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/java/net/DatagramSocketImpl.java Wed Sep 10 15:32:50 2014 -0700 @@ -54,6 +54,20 @@ } /** + * The DatagramSocket or MulticastSocket + * that owns this impl + */ + DatagramSocket socket; + + void setDatagramSocket(DatagramSocket socket) { + this.socket = socket; + } + + DatagramSocket getDatagramSocket() { + return socket; + } + + /** * Creates a datagram socket. * @exception SocketException if there is an error in the * underlying protocol, such as a TCP error. @@ -239,6 +253,56 @@ return localPort; } + <T> void setOption(SocketOption<T> name, T value) throws IOException { + if (name == StandardSocketOptions.SO_SNDBUF) { + setOption(SocketOptions.SO_SNDBUF, value); + } else if (name == StandardSocketOptions.SO_RCVBUF) { + setOption(SocketOptions.SO_RCVBUF, value); + } else if (name == StandardSocketOptions.SO_REUSEADDR) { + setOption(SocketOptions.SO_REUSEADDR, value); + } else if (name == StandardSocketOptions.IP_TOS) { + setOption(SocketOptions.IP_TOS, value); + } else if (name == StandardSocketOptions.IP_MULTICAST_IF && + (getDatagramSocket() instanceof MulticastSocket)) { + setOption(SocketOptions.IP_MULTICAST_IF2, value); + } else if (name == StandardSocketOptions.IP_MULTICAST_TTL && + (getDatagramSocket() instanceof MulticastSocket)) { + if (! (value instanceof Integer)) { + throw new IllegalArgumentException("not an integer"); + } + setTimeToLive((Integer)value); + } else if (name == StandardSocketOptions.IP_MULTICAST_LOOP && + (getDatagramSocket() instanceof MulticastSocket)) { + setOption(SocketOptions.IP_MULTICAST_LOOP, value); + } else { + throw new UnsupportedOperationException("unsupported option"); + } + } + + <T> T getOption(SocketOption<T> name) throws IOException { + if (name == StandardSocketOptions.SO_SNDBUF) { + return (T) getOption(SocketOptions.SO_SNDBUF); + } else if (name == StandardSocketOptions.SO_RCVBUF) { + return (T) getOption(SocketOptions.SO_RCVBUF); + } else if (name == StandardSocketOptions.SO_REUSEADDR) { + return (T) getOption(SocketOptions.SO_REUSEADDR); + } else if (name == StandardSocketOptions.IP_TOS) { + return (T) getOption(SocketOptions.IP_TOS); + } else if (name == StandardSocketOptions.IP_MULTICAST_IF && + (getDatagramSocket() instanceof MulticastSocket)) { + return (T) getOption(SocketOptions.IP_MULTICAST_IF2); + } else if (name == StandardSocketOptions.IP_MULTICAST_TTL && + (getDatagramSocket() instanceof MulticastSocket)) { + Integer ttl = getTimeToLive(); + return (T)ttl; + } else if (name == StandardSocketOptions.IP_MULTICAST_LOOP && + (getDatagramSocket() instanceof MulticastSocket)) { + return (T) getOption(SocketOptions.IP_MULTICAST_LOOP); + } else { + throw new UnsupportedOperationException("unsupported option"); + } + } + /** * Gets the datagram socket file descriptor. * @return a <tt>FileDescriptor</tt> object representing the datagram socket
--- a/src/share/classes/java/net/SocketImpl.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/java/net/SocketImpl.java Wed Sep 10 15:32:50 2014 -0700 @@ -354,4 +354,44 @@ { /* Not implemented yet */ } + + <T> void setOption(SocketOption<T> name, T value) throws IOException { + if (name == StandardSocketOptions.SO_KEEPALIVE) { + setOption(SocketOptions.SO_KEEPALIVE, value); + } else if (name == StandardSocketOptions.SO_SNDBUF) { + setOption(SocketOptions.SO_SNDBUF, value); + } else if (name == StandardSocketOptions.SO_RCVBUF) { + setOption(SocketOptions.SO_RCVBUF, value); + } else if (name == StandardSocketOptions.SO_REUSEADDR) { + setOption(SocketOptions.SO_REUSEADDR, value); + } else if (name == StandardSocketOptions.SO_LINGER) { + setOption(SocketOptions.SO_LINGER, value); + } else if (name == StandardSocketOptions.IP_TOS) { + setOption(SocketOptions.IP_TOS, value); + } else if (name == StandardSocketOptions.TCP_NODELAY) { + setOption(SocketOptions.TCP_NODELAY, value); + } else { + throw new UnsupportedOperationException("unsupported option"); + } + } + + <T> T getOption(SocketOption<T> name) throws IOException { + if (name == StandardSocketOptions.SO_KEEPALIVE) { + return (T)getOption(SocketOptions.SO_KEEPALIVE); + } else if (name == StandardSocketOptions.SO_SNDBUF) { + return (T)getOption(SocketOptions.SO_SNDBUF); + } else if (name == StandardSocketOptions.SO_RCVBUF) { + return (T)getOption(SocketOptions.SO_RCVBUF); + } else if (name == StandardSocketOptions.SO_REUSEADDR) { + return (T)getOption(SocketOptions.SO_REUSEADDR); + } else if (name == StandardSocketOptions.SO_LINGER) { + return (T)getOption(SocketOptions.SO_LINGER); + } else if (name == StandardSocketOptions.IP_TOS) { + return (T)getOption(SocketOptions.IP_TOS); + } else if (name == StandardSocketOptions.TCP_NODELAY) { + return (T)getOption(SocketOptions.TCP_NODELAY); + } else { + throw new UnsupportedOperationException("unsupported option"); + } + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/java/net/SocketSecrets.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,70 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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 java.net; + +import java.io.IOException; + +class SocketSecrets { + + /* accessed by reflection from jdk.net.Sockets */ + + /* obj must be a Socket or ServerSocket */ + + private static <T> void setOption(Object obj, SocketOption<T> name, T value) throws IOException { + SocketImpl impl; + + if (obj instanceof Socket) { + impl = ((Socket)obj).getImpl(); + } else if (obj instanceof ServerSocket) { + impl = ((ServerSocket)obj).getImpl(); + } else { + throw new IllegalArgumentException(); + } + impl.setOption(name, value); + } + + private static <T> T getOption(Object obj, SocketOption<T> name) throws IOException { + SocketImpl impl; + + if (obj instanceof Socket) { + impl = ((Socket)obj).getImpl(); + } else if (obj instanceof ServerSocket) { + impl = ((ServerSocket)obj).getImpl(); + } else { + throw new IllegalArgumentException(); + } + return impl.getOption(name); + } + + private static <T> void setOption(DatagramSocket s, SocketOption<T> name, T value) throws IOException { + s.getImpl().setOption(name, value); + } + + private static <T> T getOption(DatagramSocket s, SocketOption<T> name) throws IOException { + return s.getImpl().getOption(name); + } + +}
--- a/src/share/classes/javax/swing/JComponent.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/javax/swing/JComponent.java Wed Sep 10 15:32:50 2014 -0700 @@ -63,6 +63,7 @@ import static javax.swing.ClientPropertyKey.*; import javax.accessibility.*; +import sun.awt.SunToolkit; import sun.swing.SwingUtilities2; import sun.swing.UIClientPropertyKey; @@ -4801,7 +4802,8 @@ * @see RepaintManager#addDirtyRegion */ public void repaint(long tm, int x, int y, int width, int height) { - RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width, height); + RepaintManager.currentManager(SunToolkit.targetToAppContext(this)) + .addDirtyRegion(this, x, y, width, height); } @@ -4856,7 +4858,7 @@ // which was causing some people grief. return; } - if (SwingUtilities.isEventDispatchThread()) { + if (SunToolkit.isDispatchThreadForAppContext(this)) { invalidate(); RepaintManager.currentManager(this).addInvalidComponent(this); } @@ -4878,7 +4880,7 @@ revalidate(); } }; - SwingUtilities.invokeLater(callRevalidate); + SunToolkit.executeOnEventHandlerThread(this, callRevalidate); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/jdk/net/ExtendedSocketOptions.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,60 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.net; + +import java.net.SocketOption; + +/** + * Defines extended socket options, beyond those defined in + * {@link java.net.StandardSocketOptions}. These options may be platform + * specific. + * + */ +public final class ExtendedSocketOptions { + + private static class ExtSocketOption<T> implements SocketOption<T> { + private final String name; + private final Class<T> type; + ExtSocketOption(String name, Class<T> type) { + this.name = name; + this.type = type; + } + @Override public String name() { return name; } + @Override public Class<T> type() { return type; } + @Override public String toString() { return name; } + } + + private ExtendedSocketOptions() {} + + /** + * Service level properties. When a security manager is installed, + * setting or getting this option requires a {@link NetworkPermission} + * {@code ("setOption.SO_FLOW_SLA")} or {@code "getOption.SO_FLOW_SLA"} + * respectively. + */ + public static final SocketOption<SocketFlow> SO_FLOW_SLA = new + ExtSocketOption<SocketFlow>("SO_FLOW_SLA", SocketFlow.class); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/jdk/net/NetworkPermission.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,89 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.net; + +import java.security.BasicPermission; + +/** + * Represents permission to access the extended networking capabilities + * defined in the jdk.net package. These permissions contain a target + * name, but no actions list. Callers either possess the permission or not. + * <p> + * The following targets are defined: + * <p> + * <table border=1 cellpadding=5 summary="permission target name, + * what the target allows,and associated risks"> + * <tr> + * <th>Permission Target Name</th> + * <th>What the Permission Allows</th> + * <th>Risks of Allowing this Permission</th> + * </tr> + * <tr> + * <td>setOption.SO_FLOW_SLA</td> + * <td>set the {@link ExtendedSocketOptions#SO_FLOW_SLA SO_FLOW_SLA} option + * on any socket that supports it</td> + * <td>allows caller to set a higher priority or bandwidth allocation + * to sockets it creates, than they might otherwise be allowed.</td> + * </tr> + * <tr> + * <td>getOption.SO_FLOW_SLA</td> + * <td>retrieve the {@link ExtendedSocketOptions#SO_FLOW_SLA SO_FLOW_SLA} + * setting from any socket that supports the option</td> + * <td>allows caller access to SLA information that it might not + * otherwise have</td> + * </tr></table> + * + * @see jdk.net.ExtendedSocketOptions + * + */ + +public final class NetworkPermission extends BasicPermission { + + private static final long serialVersionUID = -2012939586906722291L; + + /** + * Creates a NetworkPermission with the given target name. + * + * @param name the permission target name + * @throws NullPointerException if {@code name} is {@code null}. + * @throws IllegalArgumentException if {@code name} is empty. + */ + public NetworkPermission(String name) { + super(name); + } + + /** + * Creates a NetworkPermission with the given target name. + * + * @param name the permission target name + * @param actions should be {@code null}. Is ignored if not. + * @throws NullPointerException if {@code name} is {@code null}. + * @throws IllegalArgumentException if {@code name} is empty. + */ + public NetworkPermission(String name, String actions) { + super(name, actions); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/jdk/net/SocketFlow.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,165 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.net; + + +/** + * Represents the service level properties for the platform specific socket + * option {@link ExtendedSocketOptions#SO_FLOW_SLA}. + * <p> + * The priority and bandwidth parameters must be set before + * setting the socket option. + * <p> + * When the {@code SO_FLOW_SLA} option is set then it may not take effect + * immediately. If the value of the socket option is obtained with + * {@code getOption()} then the status may be returned as {@code INPROGRESS} + * until it takes effect. The priority and bandwidth values are only valid when + * the status is returned as OK. + * <p> + * When a security manager is installed, a {@link NetworkPermission} + * is required to set or get this option. + * + */ + +public class SocketFlow { + + private static final int UNSET = -1; + public static final int NORMAL_PRIORITY = 1; + public static final int HIGH_PRIORITY = 2; + + private int priority = NORMAL_PRIORITY; + + private long bandwidth = UNSET; + + private Status status = Status.NO_STATUS; + + private SocketFlow() {} + + /** + * Enumeration of the return values from the SO_FLOW_SLA + * socket option. Both setting and getting the option return + * one of these statuses, which reflect the state of socket's + * flow. + * + */ + public enum Status { + /** + * Set or get socket option has not been called yet. Status + * values can only be retrieved after calling set or get. + */ + NO_STATUS, + /** + * Flow successfully created. + */ + OK, + /** + * Caller has no permission to create flow. + */ + NO_PERMISSION, + /** + * Flow can not be created because socket is not connected. + */ + NOT_CONNECTED, + /** + * Flow creation not supported for this socket. + */ + NOT_SUPPORTED, + /** + * A flow already exists with identical attributes. + */ + ALREADY_CREATED, + /** + * A flow is being created. + */ + IN_PROGRESS, + /** + * Some other unspecified error. + */ + OTHER + } + + /** + * Creates a new SocketFlow that can be used to set the SO_FLOW_SLA + * socket option and create a socket flow. + */ + public static SocketFlow create() { + return new SocketFlow(); + } + + /** + * Sets this SocketFlow's priority. Must be either NORMAL_PRIORITY + * HIGH_PRIORITY. If not set, a flow's priority is normal. + * + * @throws IllegalArgumentException if priority is not NORMAL_PRIORITY or + * HIGH_PRIORITY. + */ + public SocketFlow priority(int priority) { + if (priority != NORMAL_PRIORITY && priority != HIGH_PRIORITY) { + throw new IllegalArgumentException("invalid priority"); + } + this.priority = priority; + return this; + } + + /** + * Sets this SocketFlow's bandwidth. Must be greater than or equal to zero. + * A value of zero drops all packets for the socket. + * + * @throws IllegalArgumentException if bandwidth is less than zero. + */ + public SocketFlow bandwidth(long bandwidth) { + if (bandwidth < 0) { + throw new IllegalArgumentException("invalid bandwidth"); + } else { + this.bandwidth = bandwidth; + } + return this; + } + + /** + * Returns this SocketFlow's priority. + */ + public int priority() { + return priority; + } + + /** + * Returns this SocketFlow's bandwidth. + * + * @return this SocketFlow's bandwidth, or {@code -1} if status is not OK. + */ + public long bandwidth() { + return bandwidth; + } + + /** + * Returns the Status value of this SocketFlow. NO_STATUS is returned + * if the object was not used in a call to set or get the option. + */ + public Status status() { + return status; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/jdk/net/Sockets.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,405 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.net; + +import java.net.*; +import java.io.IOException; +import java.io.FileDescriptor; +import java.security.PrivilegedAction; +import java.security.AccessController; +import java.lang.reflect.*; +import java.util.Set; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Collections; +import sun.net.ExtendedOptionsImpl; + +/** + * Defines static methods to set and get socket options defined by the + * {@link java.net.SocketOption} interface. All of the standard options defined + * by {@link java.net.Socket}, {@link java.net.ServerSocket}, and + * {@link java.net.DatagramSocket} can be set this way, as well as additional + * or platform specific options supported by each socket type. + * <p> + * The {@link #supportedOptions(Class)} method can be called to determine + * the complete set of options available (per socket type) on the + * current system. + * <p> + * When a security manager is installed, some non-standard socket options + * may require a security permission before being set or get. + * The details are specified in {@link ExtendedSocketOptions}. No permission + * is required for {@link java.net.StandardSocketOption}s. + * + * @see java.nio.channels.NetworkChannel + */ +public class Sockets { + + private final static HashMap<Class<?>,Set<SocketOption<?>>> + options = new HashMap<>(); + + static { + initOptionSets(); + AccessController.doPrivileged( + new java.security.PrivilegedAction<Void>() { + public Void run() { + initMethods(); + return null; + } + } + ); + } + + private static Method siSetOption; + private static Method siGetOption; + private static Method dsiSetOption; + private static Method dsiGetOption; + + private static void initMethods() { + try { + Class<?> clazz = Class.forName("java.net.SocketSecrets"); + + siSetOption = clazz.getDeclaredMethod( + "setOption", Object.class, + SocketOption.class, Object.class + ); + siSetOption.setAccessible(true); + + siGetOption = clazz.getDeclaredMethod( + "getOption", Object.class, SocketOption.class + ); + siGetOption.setAccessible(true); + + dsiSetOption = clazz.getDeclaredMethod( + "setOption", DatagramSocket.class, + SocketOption.class, Object.class + ); + dsiSetOption.setAccessible(true); + + dsiGetOption = clazz.getDeclaredMethod( + "getOption", DatagramSocket.class, SocketOption.class + ); + dsiGetOption.setAccessible(true); + } catch (ReflectiveOperationException e) { + throw new Error(e); + } + } + + private static <T> void invokeSet( + Method method, Object socket, + SocketOption<T> option, T value) throws IOException + { + try { + method.invoke(null, socket, option, value); + } catch (Exception e) { + if (e instanceof InvocationTargetException) { + Throwable t = ((InvocationTargetException)e).getTargetException(); + if (t instanceof IOException) { + throw (IOException)t; + } else if (t instanceof RuntimeException) { + throw (RuntimeException)t; + } + } + throw new RuntimeException(e); + } + } + + private static <T> T invokeGet( + Method method, Object socket, SocketOption<T> option) throws IOException + { + try { + return (T)method.invoke(null, socket, option); + } catch (Exception e) { + if (e instanceof InvocationTargetException) { + Throwable t = ((InvocationTargetException)e).getTargetException(); + if (t instanceof IOException) { + throw (IOException)t; + } else if (t instanceof RuntimeException) { + throw (RuntimeException)t; + } + } + throw new RuntimeException(e); + } + } + + private Sockets() {} + + /** + * Sets the value of a socket option on a {@link java.net.Socket} + * + * @param s the socket + * @param name The socket option + * @param value The value of the socket option. May be null for some + * options. + * + * @throws UnsupportedOperationException if the socket does not support + * the option. + * + * @throws IllegalArgumentException if the value is not valid for + * the option. + * + * @throws IOException if an I/O error occurs, or socket is closed. + * + * @throws SecurityException if a security manager is set and the + * caller does not have any required permission. + * + * @throws NullPointerException if name is null + * + * @see java.net.StandardSocketOptions + */ + public static <T> void setOption(Socket s, SocketOption<T> name, T value) throws IOException + { + if (!isSupported(Socket.class, name)) { + throw new UnsupportedOperationException(name.name()); + } + invokeSet(siSetOption, s, name, value); + } + + /** + * Returns the value of a socket option from a {@link java.net.Socket} + * + * @param s the socket + * @param name The socket option + * + * @return The value of the socket option. + * + * @throws UnsupportedOperationException if the socket does not support + * the option. + * + * @throws IOException if an I/O error occurs + * + * @throws SecurityException if a security manager is set and the + * caller does not have any required permission. + * + * @throws NullPointerException if name is null + * + * @see java.net.StandardSocketOptions + */ + public static <T> T getOption(Socket s, SocketOption<T> name) throws IOException + { + if (!isSupported(Socket.class, name)) { + throw new UnsupportedOperationException(name.name()); + } + return invokeGet(siGetOption, s, name); + } + + /** + * Sets the value of a socket option on a {@link java.net.ServerSocket} + * + * @param s the socket + * @param name The socket option + * @param value The value of the socket option. + * + * @throws UnsupportedOperationException if the socket does not support + * the option. + * + * @throws IllegalArgumentException if the value is not valid for + * the option. + * + * @throws IOException if an I/O error occurs + * + * @throws NullPointerException if name is null + * + * @throws SecurityException if a security manager is set and the + * caller does not have any required permission. + * + * @see java.net.StandardSocketOptions + */ + public static <T> void setOption(ServerSocket s, SocketOption<T> name, T value) throws IOException + { + if (!isSupported(ServerSocket.class, name)) { + throw new UnsupportedOperationException(name.name()); + } + invokeSet(siSetOption, s, name, value); + } + + /** + * Returns the value of a socket option from a {@link java.net.ServerSocket} + * + * @param s the socket + * @param name The socket option + * + * @return The value of the socket option. + * + * @throws UnsupportedOperationException if the socket does not support + * the option. + * + * @throws IOException if an I/O error occurs + * + * @throws NullPointerException if name is null + * + * @throws SecurityException if a security manager is set and the + * caller does not have any required permission. + * + * @see java.net.StandardSocketOptions + */ + public static <T> T getOption(ServerSocket s, SocketOption<T> name) throws IOException + { + if (!isSupported(ServerSocket.class, name)) { + throw new UnsupportedOperationException(name.name()); + } + return invokeGet(siGetOption, s, name); + } + + /** + * Sets the value of a socket option on a {@link java.net.DatagramSocket} + * or {@link java.net.MulticastSocket} + * + * @param s the socket + * @param name The socket option + * @param value The value of the socket option. + * + * @throws UnsupportedOperationException if the socket does not support + * the option. + * + * @throws IllegalArgumentException if the value is not valid for + * the option. + * + * @throws IOException if an I/O error occurs + * + * @throws NullPointerException if name is null + * + * @throws SecurityException if a security manager is set and the + * caller does not have any required permission. + * + * @see java.net.StandardSocketOptions + */ + public static <T> void setOption(DatagramSocket s, SocketOption<T> name, T value) throws IOException + { + if (!isSupported(s.getClass(), name)) { + throw new UnsupportedOperationException(name.name()); + } + invokeSet(dsiSetOption, s, name, value); + } + + /** + * Returns the value of a socket option from a + * {@link java.net.DatagramSocket} or {@link java.net.MulticastSocket} + * + * @param s the socket + * @param name The socket option + * + * @return The value of the socket option. + * + * @throws UnsupportedOperationException if the socket does not support + * the option. + * + * @throws IOException if an I/O error occurs + * + * @throws NullPointerException if name is null + * + * @throws SecurityException if a security manager is set and the + * caller does not have any required permission. + * + * @see java.net.StandardSocketOptions + */ + public static <T> T getOption(DatagramSocket s, SocketOption<T> name) throws IOException + { + if (!isSupported(s.getClass(), name)) { + throw new UnsupportedOperationException(name.name()); + } + return invokeGet(dsiGetOption, s, name); + } + + /** + * Returns a set of {@link java.net.SocketOption}s supported by the + * given socket type. This set may include standard options and also + * non standard extended options. + * + * @param socketType the type of java.net socket + * + * @throws IllegalArgumentException if socketType is not a valid + * socket type from the java.net package. + */ + public static Set<SocketOption<?>> supportedOptions(Class<?> socketType) { + Set<SocketOption<?>> set = options.get(socketType); + if (set == null) { + throw new IllegalArgumentException("unknown socket type"); + } + return set; + } + + private static boolean isSupported(Class<?> type, SocketOption<?> option) { + Set<SocketOption<?>> options = supportedOptions(type); + return options.contains(option); + } + + private static void initOptionSets() { + boolean flowsupported = ExtendedOptionsImpl.flowSupported(); + + // Socket + + Set<SocketOption<?>> set = new HashSet<>(); + set.add(StandardSocketOptions.SO_KEEPALIVE); + set.add(StandardSocketOptions.SO_SNDBUF); + set.add(StandardSocketOptions.SO_RCVBUF); + set.add(StandardSocketOptions.SO_REUSEADDR); + set.add(StandardSocketOptions.SO_LINGER); + set.add(StandardSocketOptions.IP_TOS); + set.add(StandardSocketOptions.TCP_NODELAY); + if (flowsupported) { + set.add(ExtendedSocketOptions.SO_FLOW_SLA); + } + set = Collections.unmodifiableSet(set); + options.put(Socket.class, set); + + // ServerSocket + + set = new HashSet<>(); + set.add(StandardSocketOptions.SO_RCVBUF); + set.add(StandardSocketOptions.SO_REUSEADDR); + set = Collections.unmodifiableSet(set); + options.put(ServerSocket.class, set); + + // DatagramSocket + + set = new HashSet<>(); + set.add(StandardSocketOptions.SO_SNDBUF); + set.add(StandardSocketOptions.SO_RCVBUF); + set.add(StandardSocketOptions.SO_REUSEADDR); + set.add(StandardSocketOptions.IP_TOS); + if (flowsupported) { + set.add(ExtendedSocketOptions.SO_FLOW_SLA); + } + set = Collections.unmodifiableSet(set); + options.put(DatagramSocket.class, set); + + // MulticastSocket + + set = new HashSet<>(); + set.add(StandardSocketOptions.SO_SNDBUF); + set.add(StandardSocketOptions.SO_RCVBUF); + set.add(StandardSocketOptions.SO_REUSEADDR); + set.add(StandardSocketOptions.IP_TOS); + set.add(StandardSocketOptions.IP_MULTICAST_IF); + set.add(StandardSocketOptions.IP_MULTICAST_TTL); + set.add(StandardSocketOptions.IP_MULTICAST_LOOP); + if (flowsupported) { + set.add(ExtendedSocketOptions.SO_FLOW_SLA); + } + set = Collections.unmodifiableSet(set); + options.put(MulticastSocket.class, set); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/jdk/net/package-info.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,32 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +/** + * Platform specific socket options for the {@code java.net} and {@code java.nio.channels} + * socket classes. + * + */ + +package jdk.net;
--- a/src/share/classes/sun/java2d/opengl/OGLSurfaceDataProxy.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/sun/java2d/opengl/OGLSurfaceDataProxy.java Wed Sep 10 15:32:50 2014 -0700 @@ -65,7 +65,11 @@ int w, int h) { if (cachedData == null) { - cachedData = oglgc.createManagedSurface(w, h, transparency); + try { + cachedData = oglgc.createManagedSurface(w, h, transparency); + } catch (OutOfMemoryError er) { + return null; + } } return cachedData; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/net/ExtendedOptionsImpl.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,94 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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 sun.net; + +import java.net.*; +import jdk.net.*; +import java.io.IOException; +import java.io.FileDescriptor; +import java.security.PrivilegedAction; +import java.security.AccessController; +import java.lang.reflect.Field; +import java.util.Set; +import java.util.HashSet; +import java.util.HashMap; +import java.util.Collections; + +/** + * Contains the native implementation for extended socket options + * together with some other static utilities + */ +public class ExtendedOptionsImpl { + + static { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + @Override + public Void run() { + System.loadLibrary("net"); + return null; + }}); + init(); + } + + private ExtendedOptionsImpl() {} + + public static void checkSetOptionPermission(SocketOption<?> option) { + SecurityManager sm = System.getSecurityManager(); + if (sm == null) { + return; + } + String check = "setOption." + option.name(); + sm.checkPermission(new NetworkPermission(check)); + } + + public static void checkGetOptionPermission(SocketOption<?> option) { + SecurityManager sm = System.getSecurityManager(); + if (sm == null) { + return; + } + String check = "getOption." + option.name(); + sm.checkPermission(new NetworkPermission(check)); + } + + public static void checkValueType(Object value, Class<?> type) { + if (!type.isAssignableFrom(value.getClass())) { + String s = "Found: " + value.getClass().toString() + " Expected: " + + type.toString(); + throw new IllegalArgumentException(s); + } + } + + private static native void init(); + + /* + * Extension native implementations + * + * SO_FLOW_SLA + */ + public static native void setFlowOption(FileDescriptor fd, SocketFlow f); + public static native void getFlowOption(FileDescriptor fd, SocketFlow f); + public static native boolean flowSupported(); +}
--- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Wed Sep 10 15:32:50 2014 -0700 @@ -1092,7 +1092,7 @@ boolean expectContinue = false; String expects = requests.findValue("Expect"); - if ("100-Continue".equalsIgnoreCase(expects)) { + if ("100-Continue".equalsIgnoreCase(expects) && streaming()) { http.setIgnoreContinue(false); expectContinue = true; }
--- a/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java Wed Sep 10 15:32:50 2014 -0700 @@ -39,6 +39,7 @@ import java.util.concurrent.*; import java.util.concurrent.locks.*; import sun.net.NetHooks; +import sun.net.ExtendedOptionsImpl; /** * Base implementation of AsynchronousSocketChannel @@ -508,6 +509,9 @@ set.add(StandardSocketOptions.SO_KEEPALIVE); set.add(StandardSocketOptions.SO_REUSEADDR); set.add(StandardSocketOptions.TCP_NODELAY); + if (ExtendedOptionsImpl.flowSupported()) { + set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA); + } return Collections.unmodifiableSet(set); } }
--- a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Wed Sep 10 15:32:50 2014 -0700 @@ -33,6 +33,7 @@ import java.nio.channels.spi.*; import java.util.*; import sun.net.ResourceManager; +import sun.net.ExtendedOptionsImpl; /** @@ -194,15 +195,8 @@ synchronized (stateLock) { ensureOpen(); - if (name == StandardSocketOptions.IP_TOS) { - // IPv4 only; no-op for IPv6 - if (family == StandardProtocolFamily.INET) { - Net.setSocketOption(fd, family, name, value); - } - return this; - } - - if (name == StandardSocketOptions.IP_MULTICAST_TTL || + if (name == StandardSocketOptions.IP_TOS || + name == StandardSocketOptions.IP_MULTICAST_TTL || name == StandardSocketOptions.IP_MULTICAST_LOOP) { // options are protocol dependent @@ -255,16 +249,8 @@ synchronized (stateLock) { ensureOpen(); - if (name == StandardSocketOptions.IP_TOS) { - // IPv4 only; always return 0 on IPv6 - if (family == StandardProtocolFamily.INET) { - return (T) Net.getSocketOption(fd, family, name); - } else { - return (T) Integer.valueOf(0); - } - } - - if (name == StandardSocketOptions.IP_MULTICAST_TTL || + if (name == StandardSocketOptions.IP_TOS || + name == StandardSocketOptions.IP_MULTICAST_TTL || name == StandardSocketOptions.IP_MULTICAST_LOOP) { return (T) Net.getSocketOption(fd, family, name); @@ -317,6 +303,9 @@ set.add(StandardSocketOptions.IP_MULTICAST_IF); set.add(StandardSocketOptions.IP_MULTICAST_TTL); set.add(StandardSocketOptions.IP_MULTICAST_LOOP); + if (ExtendedOptionsImpl.flowSupported()) { + set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA); + } return Collections.unmodifiableSet(set); } }
--- a/src/share/classes/sun/nio/ch/Net.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/sun/nio/ch/Net.java Wed Sep 10 15:32:50 2014 -0700 @@ -27,11 +27,13 @@ import java.io.*; import java.net.*; +import jdk.net.*; import java.nio.channels.*; import java.util.*; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; +import sun.net.ExtendedOptionsImpl; class Net { // package-private @@ -327,6 +329,16 @@ // only simple values supported by this method Class<?> type = name.type(); + + if (type == SocketFlow.class) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new NetworkPermission("setOption.SO_FLOW_SLA")); + } + ExtendedOptionsImpl.setFlowOption(fd, (SocketFlow)value); + return; + } + if (type != Integer.class && type != Boolean.class) throw new AssertionError("Should not reach here"); @@ -370,7 +382,8 @@ } boolean mayNeedConversion = (family == UNSPEC); - setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg); + boolean isIPv6 = (family == StandardProtocolFamily.INET6); + setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg, isIPv6); } static Object getSocketOption(FileDescriptor fd, ProtocolFamily family, @@ -379,6 +392,16 @@ { Class<?> type = name.type(); + if (type == SocketFlow.class) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new NetworkPermission("getOption.SO_FLOW_SLA")); + } + SocketFlow flow = SocketFlow.create(); + ExtendedOptionsImpl.getFlowOption(fd, flow); + return flow; + } + // only simple values supported by this method if (type != Integer.class && type != Boolean.class) throw new AssertionError("Should not reach here"); @@ -507,7 +530,7 @@ throws IOException; private static native void setIntOption0(FileDescriptor fd, boolean mayNeedConversion, - int level, int opt, int arg) + int level, int opt, int arg, boolean isIPv6) throws IOException; // -- Multicast support --
--- a/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Wed Sep 10 15:32:50 2014 -0700 @@ -133,6 +133,14 @@ synchronized (stateLock) { if (!isOpen()) throw new ClosedChannelException(); + + if (name == StandardSocketOptions.IP_TOS) { + ProtocolFamily family = Net.isIPv6Available() ? + StandardProtocolFamily.INET6 : StandardProtocolFamily.INET; + Net.setSocketOption(fd, family, name, value); + return this; + } + if (name == StandardSocketOptions.SO_REUSEADDR && Net.useExclusiveBind()) { @@ -177,6 +185,7 @@ HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(2); set.add(StandardSocketOptions.SO_RCVBUF); set.add(StandardSocketOptions.SO_REUSEADDR); + set.add(StandardSocketOptions.IP_TOS); return Collections.unmodifiableSet(set); } }
--- a/src/share/classes/sun/nio/ch/SocketChannelImpl.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/sun/nio/ch/SocketChannelImpl.java Wed Sep 10 15:32:50 2014 -0700 @@ -33,6 +33,7 @@ import java.nio.channels.spi.*; import java.util.*; import sun.net.NetHooks; +import sun.net.ExtendedOptionsImpl; import sun.misc.IoTrace; /** @@ -172,14 +173,14 @@ if (!isOpen()) throw new ClosedChannelException(); - // special handling for IP_TOS: no-op when IPv6 if (name == StandardSocketOptions.IP_TOS) { - if (!Net.isIPv6Available()) - Net.setSocketOption(fd, StandardProtocolFamily.INET, name, value); + ProtocolFamily family = Net.isIPv6Available() ? + StandardProtocolFamily.INET6 : StandardProtocolFamily.INET; + Net.setSocketOption(fd, family, name, value); return this; - } else if (name == StandardSocketOptions.SO_REUSEADDR && - Net.useExclusiveBind()) - { + } + + if (name == StandardSocketOptions.SO_REUSEADDR && Net.useExclusiveBind()) { // SO_REUSEADDR emulated when using exclusive bind isReuseAddress = (Boolean)value; return this; @@ -214,8 +215,9 @@ // special handling for IP_TOS: always return 0 when IPv6 if (name == StandardSocketOptions.IP_TOS) { - return (Net.isIPv6Available()) ? (T) Integer.valueOf(0) : - (T) Net.getSocketOption(fd, StandardProtocolFamily.INET, name); + ProtocolFamily family = Net.isIPv6Available() ? + StandardProtocolFamily.INET6 : StandardProtocolFamily.INET; + return (T) Net.getSocketOption(fd, family, name); } // no options that require special handling @@ -237,6 +239,9 @@ // additional options required by socket adaptor set.add(StandardSocketOptions.IP_TOS); set.add(ExtendedSocketOption.SO_OOBINLINE); + if (ExtendedOptionsImpl.flowSupported()) { + set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA); + } return Collections.unmodifiableSet(set); } }
--- a/src/share/classes/sun/security/krb5/EncryptionKey.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/sun/security/krb5/EncryptionKey.java Wed Sep 10 15:32:50 2014 -0700 @@ -555,6 +555,12 @@ int ktype; boolean etypeFound = false; + + // When no matched kvno is found, returns tke key of the same + // etype with the highest kvno + int kvno_found = 0; + EncryptionKey key_found = null; + for (int i = 0; i < keys.length; i++) { ktype = keys[i].getEType(); if (EType.isSupported(ktype)) { @@ -563,6 +569,10 @@ etypeFound = true; if (versionMatches(kvno, kv)) { return keys[i]; + } else if (kv > kvno_found) { + // kv is not null + key_found = keys[i]; + kvno_found = kv; } } } @@ -580,12 +590,17 @@ etypeFound = true; if (versionMatches(kvno, kv)) { return new EncryptionKey(etype, keys[i].getBytes()); + } else if (kv > kvno_found) { + key_found = new EncryptionKey(etype, keys[i].getBytes()); + kvno_found = kv; } } } } if (etypeFound) { - throw new KrbException(Krb5.KRB_AP_ERR_BADKEYVER); + return key_found; + // For compatibility, will not fail here. + //throw new KrbException(Krb5.KRB_AP_ERR_BADKEYVER); } return null; }
--- a/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java Wed Sep 10 15:32:50 2014 -0700 @@ -410,8 +410,7 @@ String uidStr = null; long uid = 0; - if (osname.startsWith("SunOS") || - (osname.startsWith("Linux"))) { + if (!osname.startsWith("Windows")) { try { Class<?> c = Class.forName ("com.sun.security.auth.module.UnixSystem");
--- a/src/share/classes/sun/security/x509/CertAndKeyGen.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/classes/sun/security/x509/CertAndKeyGen.java Wed Sep 10 15:32:50 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -156,9 +156,11 @@ // publicKey's format must be X.509 otherwise // the whole CertGen part of this class is broken. - if (!"X.509".equalsIgnoreCase(publicKey.getFormat())) { - throw new IllegalArgumentException("publicKey's is not X.509, but " - + publicKey.getFormat()); + // Allow "X509" in 7u for backwards compatibility. + if (!"X.509".equalsIgnoreCase(publicKey.getFormat()) && + !"X509".equalsIgnoreCase(publicKey.getFormat())) { + throw new IllegalArgumentException("Public key format is " + + publicKey.getFormat() + ", must be X.509"); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/native/java/net/jdk_net_SocketFlow.h Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,43 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +#include <jni.h> +/* Header for class jdk_net_SocketFlow */ + +#ifndef _Included_jdk_net_SocketFlow +#define _Included_jdk_net_SocketFlow +#ifdef __cplusplus +extern "C" { +#endif +#undef jdk_net_SocketFlow_UNSET +#define jdk_net_SocketFlow_UNSET -1L +#undef jdk_net_SocketFlow_NORMAL_PRIORITY +#define jdk_net_SocketFlow_NORMAL_PRIORITY 1L +#undef jdk_net_SocketFlow_HIGH_PRIORITY +#define jdk_net_SocketFlow_HIGH_PRIORITY 2L +#ifdef __cplusplus +} +#endif +#endif
--- a/src/share/native/java/net/net_util.h Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/native/java/net/net_util.h Wed Sep 10 15:32:50 2014 -0700 @@ -40,7 +40,7 @@ #define IPv6 2 #define NET_ERROR(env, ex, msg) \ -{ if (!(*env)->ExceptionOccurred(env)) JNU_ThrowByName(env, ex, msg) } +{ if (!(*env)->ExceptionOccurred(env)) JNU_ThrowByName(env, ex, msg); } #define CHECK_NULL(x) if ((x) == NULL) return; #define CHECK_NULL_RETURN(x, y) if ((x) == NULL) return y;
--- a/src/share/native/sun/nio/ch/genSocketOptionRegistry.c Thu Aug 28 15:14:04 2014 -0700 +++ b/src/share/native/sun/nio/ch/genSocketOptionRegistry.c Wed Sep 10 15:32:50 2014 -0700 @@ -110,6 +110,7 @@ emit_inet("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IP, IP_MULTICAST_LOOP); #ifdef AF_INET6 + emit_inet6("StandardSocketOptions.IP_TOS", IPPROTO_IPV6, IPV6_TCLASS); emit_inet6("StandardSocketOptions.IP_MULTICAST_IF", IPPROTO_IPV6, IPV6_MULTICAST_IF); emit_inet6("StandardSocketOptions.IP_MULTICAST_TTL", IPPROTO_IPV6, IPV6_MULTICAST_HOPS); emit_inet6("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
--- a/src/solaris/classes/java/net/PlainDatagramSocketImpl.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/solaris/classes/java/net/PlainDatagramSocketImpl.java Wed Sep 10 15:32:50 2014 -0700 @@ -25,6 +25,11 @@ package java.net; import java.io.IOException; +import java.util.Set; +import java.util.HashSet; +import java.util.Collections; +import jdk.net.*; +import static sun.net.ExtendedOptionsImpl.*; /* * On Unix systems we simply delegate to native methods. @@ -38,6 +43,32 @@ init(); } + protected <T> void setOption(SocketOption<T> name, T value) throws IOException { + if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { + super.setOption(name, value); + } else { + if (isClosed()) { + throw new SocketException("Socket closed"); + } + checkSetOptionPermission(name); + checkValueType(value, SocketFlow.class); + setFlowOption(getFileDescriptor(), (SocketFlow)value); + } + } + + protected <T> T getOption(SocketOption<T> name) throws IOException { + if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { + return super.getOption(name); + } + if (isClosed()) { + throw new SocketException("Socket closed"); + } + checkGetOptionPermission(name); + SocketFlow flow = SocketFlow.create(); + getFlowOption(getFileDescriptor(), flow); + return (T)flow; + } + protected synchronized native void bind0(int lport, InetAddress laddr) throws SocketException;
--- a/src/solaris/classes/java/net/PlainSocketImpl.java Thu Aug 28 15:14:04 2014 -0700 +++ b/src/solaris/classes/java/net/PlainSocketImpl.java Wed Sep 10 15:32:50 2014 -0700 @@ -26,6 +26,12 @@ import java.io.IOException; import java.io.FileDescriptor; +import java.util.Set; +import java.util.HashSet; +import java.util.Collections; +import jdk.net.*; + +import static sun.net.ExtendedOptionsImpl.*; /* * On Unix systems we simply delegate to native methods. @@ -51,6 +57,32 @@ this.fd = fd; } + protected <T> void setOption(SocketOption<T> name, T value) throws IOException { + if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { + super.setOption(name, value); + } else { + if (isClosedOrPending()) { + throw new SocketException("Socket closed"); + } + checkSetOptionPermission(name); + checkValueType(value, SocketFlow.class); + setFlowOption(getFileDescriptor(), (SocketFlow)value); + } + } + + protected <T> T getOption(SocketOption<T> name) throws IOException { + if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) { + return super.getOption(name); + } + if (isClosedOrPending()) { + throw new SocketException("Socket closed"); + } + checkGetOptionPermission(name); + SocketFlow flow = SocketFlow.create(); + getFlowOption(getFileDescriptor(), flow); + return (T)flow; + } + native void socketCreate(boolean isServer) throws IOException; native void socketConnect(InetAddress address, int port, int timeout) @@ -77,5 +109,4 @@ native int socketGetOption(int opt, Object iaContainerObj) throws SocketException; native void socketSendUrgentData(int data) throws IOException; - }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solaris/native/java/net/ExtendedOptionsImpl.c Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,329 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +#include <jni.h> +#include <string.h> + +#include "net_util.h" +#include "jdk_net_SocketFlow.h" + +static jclass sf_status_class; /* Status enum type */ + +static jfieldID sf_status; +static jfieldID sf_priority; +static jfieldID sf_bandwidth; + +static jfieldID sf_fd_fdID; /* FileDescriptor.fd */ + +/* References to the literal enum values */ + +static jobject sfs_NOSTATUS; +static jobject sfs_OK; +static jobject sfs_NOPERMISSION; +static jobject sfs_NOTCONNECTED; +static jobject sfs_NOTSUPPORTED; +static jobject sfs_ALREADYCREATED; +static jobject sfs_INPROGRESS; +static jobject sfs_OTHER; + +static jobject getEnumField(JNIEnv *env, char *name); +static void setStatus(JNIEnv *env, jobject obj, int errval); + +/* OS specific code is implemented in these three functions */ + +static jboolean flowSupported0() ; + +/* + * Class: sun_net_ExtendedOptionsImpl + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_init + (JNIEnv *env, jclass UNUSED) { + + static int initialized = 0; + jclass c; + + /* Global class references */ + + if (initialized) { + return; + } + + c = (*env)->FindClass(env, "jdk/net/SocketFlow$Status"); + CHECK_NULL(c); + sf_status_class = (*env)->NewGlobalRef(env, c); + CHECK_NULL(sf_status_class); + + /* int "fd" field of java.io.FileDescriptor */ + + c = (*env)->FindClass(env, "java/io/FileDescriptor"); + CHECK_NULL(c); + sf_fd_fdID = (*env)->GetFieldID(env, c, "fd", "I"); + CHECK_NULL(sf_fd_fdID); + + + /* SocketFlow fields */ + + c = (*env)->FindClass(env, "jdk/net/SocketFlow"); + + /* status */ + + sf_status = (*env)->GetFieldID(env, c, "status", + "Ljdk/net/SocketFlow$Status;"); + CHECK_NULL(sf_status); + + /* priority */ + + sf_priority = (*env)->GetFieldID(env, c, "priority", "I"); + CHECK_NULL(sf_priority); + + /* bandwidth */ + + sf_bandwidth = (*env)->GetFieldID(env, c, "bandwidth", "J"); + CHECK_NULL(sf_bandwidth); + + /* Initialize the static enum values */ + + sfs_NOSTATUS = getEnumField(env, "NO_STATUS"); + CHECK_NULL(sfs_NOSTATUS); + sfs_OK = getEnumField(env, "OK"); + CHECK_NULL(sfs_OK); + sfs_NOPERMISSION = getEnumField(env, "NO_PERMISSION"); + CHECK_NULL(sfs_NOPERMISSION); + sfs_NOTCONNECTED = getEnumField(env, "NOT_CONNECTED"); + CHECK_NULL(sfs_NOTCONNECTED); + sfs_NOTSUPPORTED = getEnumField(env, "NOT_SUPPORTED"); + CHECK_NULL(sfs_NOTSUPPORTED); + sfs_ALREADYCREATED = getEnumField(env, "ALREADY_CREATED"); + CHECK_NULL(sfs_ALREADYCREATED); + sfs_INPROGRESS = getEnumField(env, "IN_PROGRESS"); + CHECK_NULL(sfs_INPROGRESS); + sfs_OTHER = getEnumField(env, "OTHER"); + CHECK_NULL(sfs_OTHER); + initialized = JNI_TRUE; +} + +static jobject getEnumField(JNIEnv *env, char *name) { + jobject f; + jfieldID fID = (*env)->GetStaticFieldID(env, sf_status_class, name, + "Ljdk/net/SocketFlow$Status;"); + CHECK_NULL_RETURN(fID, NULL); + + f = (*env)->GetStaticObjectField(env, sf_status_class, fID); + CHECK_NULL_RETURN(f, NULL); + f = (*env)->NewGlobalRef(env, f); + CHECK_NULL_RETURN(f, NULL); + return f; +} + +/* + * Retrieve the int file-descriptor from a public socket type object. + * Gets impl, then the FileDescriptor from the impl, and then the fd + * from that. + */ +static int getFD(JNIEnv *env, jobject fileDesc) { + return (*env)->GetIntField(env, fileDesc, sf_fd_fdID); +} + +/** + * Sets the status field of a SocketFlow to one of the + * canned enum values + */ +static void setStatus (JNIEnv *env, jobject obj, int errval) { + switch (errval) { + case 0: /* OK */ + (*env)->SetObjectField(env, obj, sf_status, sfs_OK); + break; + case EPERM: + (*env)->SetObjectField(env, obj, sf_status, sfs_NOPERMISSION); + break; + case ENOTCONN: + (*env)->SetObjectField(env, obj, sf_status, sfs_NOTCONNECTED); + break; + case EOPNOTSUPP: + (*env)->SetObjectField(env, obj, sf_status, sfs_NOTSUPPORTED); + break; + case EALREADY: + (*env)->SetObjectField(env, obj, sf_status, sfs_ALREADYCREATED); + break; + case EINPROGRESS: + (*env)->SetObjectField(env, obj, sf_status, sfs_INPROGRESS); + break; + default: + (*env)->SetObjectField(env, obj, sf_status, sfs_OTHER); + break; + } +} + +#ifdef __solaris__ + +/* + * Class: sun_net_ExtendedOptionsImpl + * Method: setFlowOption + * Signature: (Ljava/io/FileDescriptor;Ljdk/net/SocketFlow;)V + */ +JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption + (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow) { + int fd = getFD(env, fileDesc); + + if (fd < 0) { + NET_ERROR(env, JNU_JAVANETPKG "SocketException", "socket closed"); + return; + } else { + sock_flow_props_t props; + jlong bandwidth; + int rv; + + jint priority = (*env)->GetIntField(env, flow, sf_priority); + memset(&props, 0, sizeof(props)); + props.sfp_version = SOCK_FLOW_PROP_VERSION1; + + if (priority != jdk_net_SocketFlow_UNSET) { + props.sfp_mask |= SFP_PRIORITY; + props.sfp_priority = priority; + } + bandwidth = (*env)->GetLongField(env, flow, sf_bandwidth); + if (bandwidth > -1) { + props.sfp_mask |= SFP_MAXBW; + props.sfp_maxbw = (uint64_t) bandwidth; + } + rv = setsockopt(fd, SOL_SOCKET, SO_FLOW_SLA, &props, sizeof(props)); + if (rv < 0) { + if (errno == ENOPROTOOPT) { + JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", + "unsupported socket option"); + } else { + NET_ERROR(env, JNU_JAVANETPKG "SocketException", + "set option SO_FLOW_SLA failed"); + } + return; + } + setStatus(env, flow, props.sfp_status); + } +} + +/* + * Class: sun_net_ExtendedOptionsImpl + * Method: getFlowOption + * Signature: (Ljava/io/FileDescriptor;Ljdk/net/SocketFlow;)V + */ +JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption + (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow) { + int fd = getFD(env, fileDesc); + + if (fd < 0) { + NET_ERROR(env, JNU_JAVANETPKG "SocketException", "socket closed"); + return; + } else { + sock_flow_props_t props; + int status; + socklen_t sz = sizeof(props); + + int rv = getsockopt(fd, SOL_SOCKET, SO_FLOW_SLA, &props, &sz); + if (rv < 0) { + if (errno == ENOPROTOOPT) { + JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", + "unsupported socket option"); + } else { + NET_ERROR(env, JNU_JAVANETPKG "SocketException", + "set option SO_FLOW_SLA failed"); + } + return; + } + /* first check status to see if flow exists */ + status = props.sfp_status; + setStatus(env, flow, status); + if (status == 0) { /* OK */ + /* can set the other fields now */ + if (props.sfp_mask & SFP_PRIORITY) { + (*env)->SetIntField(env, flow, sf_priority, props.sfp_priority); + } + if (props.sfp_mask & SFP_MAXBW) { + (*env)->SetLongField(env, flow, sf_bandwidth, + (jlong)props.sfp_maxbw); + } + } + } +} + +static jboolean flowsupported; +static jboolean flowsupported_set = JNI_FALSE; + +static jboolean flowSupported0() { + /* Do a simple dummy call, and try to figure out from that */ + sock_flow_props_t props; + int rv, s; + if (flowsupported_set) { + return flowsupported; + } + s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + if (s < 0) { + flowsupported = JNI_FALSE; + flowsupported_set = JNI_TRUE; + return JNI_FALSE; + } + memset(&props, 0, sizeof(props)); + props.sfp_version = SOCK_FLOW_PROP_VERSION1; + props.sfp_mask |= SFP_PRIORITY; + props.sfp_priority = SFP_PRIO_NORMAL; + rv = setsockopt(s, SOL_SOCKET, SO_FLOW_SLA, &props, sizeof(props)); + if (rv != 0 && errno == ENOPROTOOPT) { + rv = JNI_FALSE; + } else { + rv = JNI_TRUE; + } + close(s); + flowsupported = rv; + flowsupported_set = JNI_TRUE; + return flowsupported; +} + +#else /* __solaris__ */ + +/* Non Solaris. Functionality is not supported. So, throw UnsupportedOpExc */ + +JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption + (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow) { + JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", + "unsupported socket option"); +} + +JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption + (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow) { + JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", + "unsupported socket option"); +} + +static jboolean flowSupported0() { + return JNI_FALSE; +} + +#endif /* __solaris__ */ + +JNIEXPORT jboolean JNICALL Java_sun_net_ExtendedOptionsImpl_flowSupported + (JNIEnv *env, jclass UNUSED) { + return flowSupported0(); +}
--- a/src/solaris/native/java/net/net_util_md.c Thu Aug 28 15:14:04 2014 -0700 +++ b/src/solaris/native/java/net/net_util_md.c Wed Sep 10 15:32:50 2014 -0700 @@ -1351,7 +1351,7 @@ * or sending UDP packet. * 2. IPv6 on Linux: By default Linux ignores flowinfo * field so enable IPV6_FLOWINFO_SEND so that flowinfo - * will be examined. + * will be examined. We also set the IPv4 TOS option in this case. * 3. IPv4: set socket option based on ToS and Precedence * fields (otherwise get invalid argument) */ @@ -1367,8 +1367,10 @@ #if defined(AF_INET6) && defined(__linux__) if (ipv6_available()) { int optval = 1; - return setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND, - (void *)&optval, sizeof(optval)); + if (setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND, + (void *)&optval, sizeof(optval)) < 0) { + return -1; + } } #endif
--- a/src/solaris/native/java/net/net_util_md.h Thu Aug 28 15:14:04 2014 -0700 +++ b/src/solaris/native/java/net/net_util_md.h Wed Sep 10 15:32:50 2014 -0700 @@ -83,7 +83,46 @@ #ifdef __solaris__ extern int net_getParam(char *driver, char *param); -#endif + +#ifndef SO_FLOW_SLA +#define SO_FLOW_SLA 0x1018 + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack(4) + #endif + +/* + * Used with the setsockopt(SO_FLOW_SLA, ...) call to set + * per socket service level properties. + * When the application uses per-socket API, we will enforce the properties + * on both outbound and inbound packets. + * + * For now, only priority and maxbw are supported in SOCK_FLOW_PROP_VERSION1. + */ +typedef struct sock_flow_props_s { + int sfp_version; + uint32_t sfp_mask; + int sfp_priority; /* flow priority */ + uint64_t sfp_maxbw; /* bandwidth limit in bps */ + int sfp_status; /* flow create status for getsockopt */ +} sock_flow_props_t; + +#define SOCK_FLOW_PROP_VERSION1 1 + +/* bit mask values for sfp_mask */ +#define SFP_MAXBW 0x00000001 /* Flow Bandwidth Limit */ +#define SFP_PRIORITY 0x00000008 /* Flow priority */ + +/* possible values for sfp_priority */ +#define SFP_PRIO_NORMAL 1 +#define SFP_PRIO_HIGH 2 + +#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 +#pragma pack() +#endif /* _LONG_LONG_ALIGNMENT */ + +#endif /* SO_FLOW_SLA */ +#endif /* __solaris__ */ /* needed from libsocket on Solaris 8 */
--- a/src/solaris/native/sun/nio/ch/Net.c Thu Aug 28 15:14:04 2014 -0700 +++ b/src/solaris/native/sun/nio/ch/Net.c Wed Sep 10 15:32:50 2014 -0700 @@ -382,7 +382,8 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_Net_setIntOption0(JNIEnv *env, jclass clazz, jobject fdo, - jboolean mayNeedConversion, jint level, jint opt, jint arg) + jboolean mayNeedConversion, jint level, + jint opt, jint arg, jboolean isIPv6) { int result; struct linger linger; @@ -425,6 +426,12 @@ JNU_JAVANETPKG "SocketException", "sun.nio.ch.Net.setIntOption"); } +#ifdef __linux__ + if (level == IPPROTO_IPV6 && opt == IPV6_TCLASS && isIPv6) { + // set the V4 option also + setsockopt(fdval(env, fdo), IPPROTO_IP, IP_TOS, parg, arglen); + } +#endif } JNIEXPORT jint JNICALL
--- a/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c Thu Aug 28 15:14:04 2014 -0700 +++ b/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c Wed Sep 10 15:32:50 2014 -0700 @@ -278,7 +278,7 @@ int res = -1; RESTARTABLE(dup((int)fd), res); - if (fd == -1) { + if (res == -1) { throwUnixException(env, errno); } return (jint)res; @@ -306,13 +306,14 @@ JNIEXPORT void JNICALL Java_sun_nio_fs_UnixNativeDispatcher_fclose(JNIEnv* env, jclass this, jlong stream) { - int res; FILE* fp = jlong_to_ptr(stream); - do { - res = fclose(fp); - } while (res == EOF && errno == EINTR); - if (res == EOF) { + /* NOTE: fclose() wrapper is only used with read-only streams. + * If it ever is used with write streams, it might be better to add + * RESTARTABLE(fflush(fp)) before closing, to make sure the stream + * is completely written even if fclose() failed. + */ + if (fclose(fp) == EOF && errno != EINTR) { throwUnixException(env, errno); } } @@ -610,11 +611,9 @@ JNIEXPORT void JNICALL Java_sun_nio_fs_UnixNativeDispatcher_closedir(JNIEnv* env, jclass this, jlong dir) { - int err; DIR* dirp = jlong_to_ptr(dir); - RESTARTABLE(closedir(dirp), err); - if (errno == -1) { + if (closedir(dirp) == -1 && errno != EINTR) { throwUnixException(env, errno); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/windows/native/java/net/ExtendedOptionsImpl.c Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,62 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ + +#include <jni.h> +#include <string.h> + +#include "net_util.h" + +/* + * Class: sun_net_ExtendedOptionsImpl + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_init + (JNIEnv *env, jclass UNUSED) +{ +} + +/* Non Solaris. Functionality is not supported. So, throw UnsupportedOpExc */ + +JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption + (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow) { + JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", + "unsupported socket option"); +} + +JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption + (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow) { + JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", + "unsupported socket option"); +} + +static jboolean flowSupported0() { + return JNI_FALSE; +} + +JNIEXPORT jboolean JNICALL Java_sun_net_ExtendedOptionsImpl_flowSupported + (JNIEnv *env, jclass UNUSED) { + return JNI_FALSE; +}
--- a/src/windows/native/java/net/NetworkInterface.c Thu Aug 28 15:14:04 2014 -0700 +++ b/src/windows/native/java/net/NetworkInterface.c Wed Sep 10 15:32:50 2014 -0700 @@ -175,7 +175,7 @@ int count; netif *netifP; DWORD i; - int lo=0, eth=0, tr=0, fddi=0, ppp=0, sl=0, net=0, wlen=0; + int lo=0, eth=0, tr=0, fddi=0, ppp=0, sl=0, wlan=0, net=0, wlen=0; /* * Ask the IP Helper library to enumerate the adapters @@ -215,15 +215,15 @@ */ switch (ifrowP->dwType) { case MIB_IF_TYPE_ETHERNET: - sprintf(dev_name, "eth%d", eth++); + _snprintf_s(dev_name, 8, _TRUNCATE, "eth%d", eth++); break; case MIB_IF_TYPE_TOKENRING: - sprintf(dev_name, "tr%d", tr++); + _snprintf_s(dev_name, 8, _TRUNCATE, "tr%d", tr++); break; case MIB_IF_TYPE_FDDI: - sprintf(dev_name, "fddi%d", fddi++); + _snprintf_s(dev_name, 8, _TRUNCATE, "fddi%d", fddi++); break; case MIB_IF_TYPE_LOOPBACK: @@ -231,20 +231,24 @@ if (lo > 0) { continue; } - strcpy(dev_name, "lo"); + strncpy_s(dev_name, 8, "lo", _TRUNCATE); lo++; break; case MIB_IF_TYPE_PPP: - sprintf(dev_name, "ppp%d", ppp++); + _snprintf_s(dev_name, 8, _TRUNCATE, "ppp%d", ppp++); break; case MIB_IF_TYPE_SLIP: - sprintf(dev_name, "sl%d", sl++); + _snprintf_s(dev_name, 8, _TRUNCATE, "sl%d", sl++); + break; + + case IF_TYPE_IEEE80211: + _snprintf_s(dev_name, 8, _TRUNCATE, "wlan%d", wlan++); break; default: - sprintf(dev_name, "net%d", net++); + _snprintf_s(dev_name, 8, _TRUNCATE, "net%d", net++); } /* @@ -409,6 +413,7 @@ case MIB_IF_TYPE_TOKENRING: case MIB_IF_TYPE_FDDI: case MIB_IF_TYPE_LOOPBACK: + case IF_TYPE_IEEE80211: /** * Contrary to what it seems to indicate, dwBCastAddr doesn't * contain the broadcast address but 0 or 1 depending on whether @@ -949,6 +954,7 @@ case MIB_IF_TYPE_ETHERNET: case MIB_IF_TYPE_TOKENRING: case MIB_IF_TYPE_FDDI: + case IF_TYPE_IEEE80211: len = ifRowP->dwPhysAddrLen; ret = (*env)->NewByteArray(env, len); if (!IS_NULL(ret)) {
--- a/src/windows/native/java/net/NetworkInterface.h Thu Aug 28 15:14:04 2014 -0700 +++ b/src/windows/native/java/net/NetworkInterface.h Wed Sep 10 15:32:50 2014 -0700 @@ -88,4 +88,9 @@ int enumInterfaces(JNIEnv *env, netif **netifPP); +// Windows Visa (and later) only..... +#ifndef IF_TYPE_IEEE80211 +#define IF_TYPE_IEEE80211 71 #endif + +#endif
--- a/src/windows/native/java/net/net_util_md.c Thu Aug 28 15:14:04 2014 -0700 +++ b/src/windows/native/java/net/net_util_md.c Wed Sep 10 15:32:50 2014 -0700 @@ -443,6 +443,13 @@ { int rv; + if (level == IPPROTO_IPV6 && optname == IPV6_TCLASS) { + int *intopt = (int *)optval; + *intopt = 0; + *optlen = sizeof(*intopt); + return 0; + } + rv = getsockopt(s, level, optname, optval, optlen);
--- a/src/windows/native/sun/nio/ch/Net.c Thu Aug 28 15:14:04 2014 -0700 +++ b/src/windows/native/sun/nio/ch/Net.c Wed Sep 10 15:32:50 2014 -0700 @@ -294,9 +294,9 @@ /** * HACK: IP_TOS is deprecated on Windows and querying the option * returns a protocol error. NET_GetSockOpt handles this and uses - * a fallback mechanism. + * a fallback mechanism. Same applies to IPV6_TCLASS */ - if (level == IPPROTO_IP && opt == IP_TOS) { + if ((level == IPPROTO_IP && opt == IP_TOS) || (level == IPPROTO_IPV6 && opt == IPV6_TCLASS)) { mayNeedConversion = JNI_TRUE; } @@ -318,7 +318,7 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_Net_setIntOption0(JNIEnv *env, jclass clazz, jobject fdo, - jboolean mayNeedConversion, jint level, jint opt, jint arg) + jboolean mayNeedConversion, jint level, jint opt, jint arg, jboolean ipv6) { struct linger linger; char *parg; @@ -339,6 +339,11 @@ arglen = sizeof(arg); } + if (level == IPPROTO_IPV6 && opt == IPV6_TCLASS) { + /* No op */ + return; + } + if (mayNeedConversion) { n = NET_SetSockOpt(fdval(env, fdo), level, opt, parg, arglen); } else {
--- a/src/windows/native/sun/windows/WPrinterJob.cpp Thu Aug 28 15:14:04 2014 -0700 +++ b/src/windows/native/sun/windows/WPrinterJob.cpp Wed Sep 10 15:32:50 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -927,14 +927,7 @@ if (type == GETJOBCOUNT) { ret = pPrinterInfo->cJobs; } else if (type == ACCEPTJOB) { - if (pPrinterInfo->Status & - (PRINTER_STATUS_ERROR | - PRINTER_STATUS_NOT_AVAILABLE | - PRINTER_STATUS_NO_TONER | - PRINTER_STATUS_OUT_OF_MEMORY | - PRINTER_STATUS_OFFLINE | - PRINTER_STATUS_USER_INTERVENTION | - PRINTER_STATUS_DOOR_OPEN)) { + if (pPrinterInfo->Status & PRINTER_STATUS_PENDING_DELETION) { ret = 0; } else {
--- a/test/Makefile Thu Aug 28 15:14:04 2014 -0700 +++ b/test/Makefile Wed Sep 10 15:32:50 2014 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1995, 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 @@ -524,7 +524,7 @@ # Stable samevm testruns (minus items from PROBLEM_LIST) JDK_ALL_TARGETS += jdk_net -jdk_net: $(call TestDirs, com/sun/net java/net sun/net com/oracle/net) +jdk_net: $(call TestDirs, com/sun/net java/net jdk/net sun/net com/oracle/net) $(call RunAgentvmBatch) # Stable samevm testruns (minus items from PROBLEM_LIST)
--- a/test/com/sun/crypto/provider/Mac/MacClone.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/com/sun/crypto/provider/Mac/MacClone.java Wed Sep 10 15:32:50 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 0000000 + * @bug 7087021 * @summary MacClone * @author Jan Luehe */ @@ -56,7 +56,7 @@ KeyGenerator kgen = KeyGenerator.getInstance("DES"); SecretKey skey = kgen.generateKey(); - mac = Mac.getInstance("HmacSHA1"); + mac = Mac.getInstance("HmacSHA1", "SunJCE"); mac.init(skey); macClone = (Mac)mac.clone(); System.out.println(macClone.getProvider().toString());
--- a/test/com/sun/net/httpserver/bugs/B6373555.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/com/sun/net/httpserver/bugs/B6373555.java Wed Sep 10 15:32:50 2014 -0700 @@ -43,14 +43,12 @@ private static int port; private static volatile boolean error = false; - private static Object lock; static HttpServer httpServer; static ExecutorService pool, execs; static int NUM = 1000; public static void main(String[] args) throws Exception { try { - lock = new Object(); if (args.length > 0) { NUM = Integer.parseInt (args[0]); } @@ -117,12 +115,6 @@ System.out.println("Doesn't match"); error = true; } - synchronized(lock) { - ++received; - if ((received % 1000) == 0) { - System.out.println("Received="+received); - } - } } catch(Exception e) { e.printStackTrace(); @@ -150,18 +142,12 @@ private static HttpServer createHttpServer(ExecutorService execs) throws Exception { InetSocketAddress inetAddress = new InetSocketAddress(0); - HttpServer testServer = HttpServer.create(inetAddress, 5); + HttpServer testServer = HttpServer.create(inetAddress, 15); testServer.setExecutor(execs); HttpContext context = testServer.createContext("/test"); context.setHandler(new HttpHandler() { public void handle(HttpExchange msg) { try { - synchronized(lock) { - ++s_received; - if ((s_received % 1000) == 0) { - System.out.println("Received="+s_received); - } - } String method = msg.getRequestMethod(); if (method.equals("POST")) { InputStream is = msg.getRequestBody(); @@ -172,12 +158,6 @@ System.out.println("****** METHOD not handled ***** "+method); System.out.println("Received="+s_received); } - synchronized(lock) { - ++sent; - if ((sent % 1000) == 0) { - System.out.println("sent="+sent); - } - } } catch(Exception e) { e.printStackTrace();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/io/File/CheckPermission.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,379 @@ +/* + * Copyright (c) 2013, 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 8017212 + * @summary Examine methods in File.java that access the file system do the + * right permission check when a security manager exists. + * @author Dan Xu + */ + +import java.io.File; +import java.io.FilenameFilter; +import java.io.FileFilter; +import java.io.IOException; +import java.security.Permission; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class CheckPermission { + + private static final String CHECK_PERMISSION_TEST = "CheckPermissionTest"; + + public enum FileOperation { + READ, WRITE, DELETE, EXEC + } + + static class Checks { + private List<Permission> permissionsChecked = new ArrayList<>(); + private Set<String> propertiesChecked = new HashSet<>(); + + private Map<FileOperation, List<String>> fileOperationChecked = + new EnumMap<>(FileOperation.class); + + List<Permission> permissionsChecked() { + return permissionsChecked; + } + + Set<String> propertiesChecked() { + return propertiesChecked; + } + + List<String> fileOperationChecked(FileOperation op) { + return fileOperationChecked.get(op); + } + + void addFileOperation(FileOperation op, String file) { + List<String> opList = fileOperationChecked.get(op); + if (opList == null) { + opList = new ArrayList<>(); + fileOperationChecked.put(op, opList); + } + opList.add(file); + } + } + + static ThreadLocal<Checks> myChecks = new ThreadLocal<>(); + + static void prepare() { + myChecks.set(new Checks()); + } + + static class LoggingSecurityManager extends SecurityManager { + static void install() { + System.setSecurityManager(new LoggingSecurityManager()); + } + + private void checkFileOperation(FileOperation op, String file) { + Checks checks = myChecks.get(); + if (checks != null) + checks.addFileOperation(op, file); + } + + @Override + public void checkRead(String file) { + checkFileOperation(FileOperation.READ, file); + } + + @Override + public void checkWrite(String file) { + checkFileOperation(FileOperation.WRITE, file); + } + + @Override + public void checkDelete(String file) { + checkFileOperation(FileOperation.DELETE, file); + } + + @Override + public void checkExec(String file) { + checkFileOperation(FileOperation.EXEC, file); + } + + @Override + public void checkPermission(Permission perm) { + Checks checks = myChecks.get(); + if (checks != null) + checks.permissionsChecked().add(perm); + } + + @Override + public void checkPropertyAccess(String key) { + Checks checks = myChecks.get(); + if (checks != null) + checks.propertiesChecked().add(key); + } + } + + static void assertCheckPermission(Class<? extends Permission> type, + String name) + { + for (Permission perm : myChecks.get().permissionsChecked()) { + if (type.isInstance(perm) && perm.getName().equals(name)) + return; + } + throw new RuntimeException(type.getName() + "(\"" + name + + "\") not checked"); + } + + static void assertCheckPropertyAccess(String key) { + if (!myChecks.get().propertiesChecked().contains(key)) + throw new RuntimeException("Property " + key + " not checked"); + } + + static void assertChecked(File file, List<String> list) { + if (list != null && !list.isEmpty()) { + for (String path : list) { + if (path.equals(file.getPath())) + return; + } + } + throw new RuntimeException("Access not checked"); + } + + static void assertNotChecked(File file, List<String> list) { + if (list != null && !list.isEmpty()) { + for (String path : list) { + if (path.equals(file.getPath())) + throw new RuntimeException("Access checked"); + } + } + } + + static void assertCheckOperation(File file, Set<FileOperation> ops) { + for (FileOperation op : ops) + assertChecked(file, myChecks.get().fileOperationChecked(op)); + } + + static void assertNotCheckOperation(File file, Set<FileOperation> ops) { + for (FileOperation op : ops) + assertNotChecked(file, myChecks.get().fileOperationChecked(op)); + } + + static void assertOnlyCheckOperation(File file, + EnumSet<FileOperation> ops) + { + assertCheckOperation(file, ops); + assertNotCheckOperation(file, EnumSet.complementOf(ops)); + } + + static File testFile, another; + + static void setup() { + testFile = new File(CHECK_PERMISSION_TEST + System.currentTimeMillis()); + if (testFile.exists()) { + testFile.delete(); + } + + another = new File(CHECK_PERMISSION_TEST + "Another" + + System.currentTimeMillis()); + if (another.exists()) { + another.delete(); + } + + LoggingSecurityManager.install(); + } + + public static void main(String[] args) throws IOException { + setup(); + + prepare(); + testFile.canRead(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.canWrite(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + prepare(); + testFile.exists(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.isDirectory(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.isFile(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.isHidden(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.lastModified(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.length(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.createNewFile(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + prepare(); + testFile.list(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.list(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return false; + } + }); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.listFiles(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return false; + } + }); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.listFiles(new FileFilter() { + @Override + public boolean accept(File file) { + return false; + } + }); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + + prepare(); + testFile.mkdir(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + if (testFile.exists()) { + prepare(); + testFile.mkdirs(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + } + + if (!another.exists()) { + prepare(); + another.mkdirs(); + assertOnlyCheckOperation(another, + EnumSet.of(FileOperation.READ, FileOperation.WRITE)); + } + + prepare(); + another.delete(); + assertOnlyCheckOperation(another, EnumSet.of(FileOperation.DELETE)); + + prepare(); + boolean renRst = testFile.renameTo(another); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + assertOnlyCheckOperation(another, EnumSet.of(FileOperation.WRITE)); + + if (renRst) { + if (testFile.exists()) + throw new RuntimeException(testFile + " is already renamed to " + + another); + testFile = another; + } + + prepare(); + testFile.setLastModified(0); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + prepare(); + testFile.setReadOnly(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + prepare(); + testFile.setWritable(true, true); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + prepare(); + testFile.setWritable(true); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + prepare(); + testFile.setReadable(true, true); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + prepare(); + testFile.setReadable(true); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + prepare(); + testFile.setExecutable(true, true); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + prepare(); + testFile.setExecutable(true); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.WRITE)); + + prepare(); + testFile.canExecute(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.EXEC)); + + prepare(); + testFile.getTotalSpace(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + assertCheckPermission(RuntimePermission.class, + "getFileSystemAttributes"); + + prepare(); + testFile.getFreeSpace(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + assertCheckPermission(RuntimePermission.class, + "getFileSystemAttributes"); + + prepare(); + testFile.getUsableSpace(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.READ)); + assertCheckPermission(RuntimePermission.class, + "getFileSystemAttributes"); + + prepare(); + File tmpFile = File.createTempFile(CHECK_PERMISSION_TEST, null); + assertOnlyCheckOperation(tmpFile, EnumSet.of(FileOperation.WRITE)); + tmpFile.delete(); + assertCheckOperation(tmpFile, EnumSet.of(FileOperation.DELETE)); + + prepare(); + tmpFile = File.createTempFile(CHECK_PERMISSION_TEST, null, null); + assertOnlyCheckOperation(tmpFile, EnumSet.of(FileOperation.WRITE)); + tmpFile.delete(); + assertCheckOperation(tmpFile, EnumSet.of(FileOperation.DELETE)); + + prepare(); + testFile.deleteOnExit(); + assertOnlyCheckOperation(testFile, EnumSet.of(FileOperation.DELETE)); + } +}
--- a/test/java/io/File/NulFile.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/java/io/File/NulFile.java Wed Sep 10 15:32:50 2014 -0700 @@ -612,8 +612,13 @@ try { File.createTempFile(prefix, suffix, directory); } catch (IOException ex) { - if (ExceptionMsg.equals(ex.getMessage())) + String err = "Unable to create temporary file"; + if (err.equals(ex.getMessage())) exceptionThrown = true; + else { + throw new RuntimeException("Get IOException with message, " + + ex.getMessage() + ", expect message, "+ err); + } } } if (!exceptionThrown) {
--- a/test/java/io/File/createTempFile/SpecialTempFile.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/java/io/File/createTempFile/SpecialTempFile.java Wed Sep 10 15:32:50 2014 -0700 @@ -23,9 +23,8 @@ /* * @test - * @bug 8013827 8011950 8025128 + * @bug 8013827 8011950 8017212 8025128 * @summary Check whether File.createTempFile can handle special parameters - * on Windows platforms * @author Dan Xu */ @@ -35,7 +34,7 @@ public class SpecialTempFile { private static void test(String name, String[] prefix, String[] suffix, - boolean expectedException) throws IOException + boolean exceptionExpected) throws IOException { if (prefix == null || suffix == null || prefix.length != suffix.length) @@ -44,14 +43,13 @@ } final String exceptionMsg = "Unable to create temporary file"; + String[] dirs = { null, "." }; for (int i = 0; i < prefix.length; i++) { boolean exceptionThrown = false; File f = null; - String[] dirs = { null, "." }; - - for (String dir : dirs ) { + for (String dir: dirs) { System.out.println("In test " + name + ", creating temp file with prefix, " + prefix[i] + ", suffix, " + suffix[i] + @@ -63,7 +61,7 @@ else f = File.createTempFile(prefix[i], suffix[i], new File(dir)); } catch (IOException e) { - if (expectedException) { + if (exceptionExpected) { if (e.getMessage().startsWith(exceptionMsg)) exceptionThrown = true; else @@ -74,13 +72,23 @@ } } - if (expectedException && (!exceptionThrown || f != null)) + if (exceptionExpected && (!exceptionThrown || f != null)) throw new RuntimeException("IOException is expected"); } } } public static void main(String[] args) throws Exception { + // Common test + final String name = "SpecialTempFile"; + File f = new File(System.getProperty("java.io.tmpdir"), name); + if (!f.exists()) { + f.createNewFile(); + } + String[] nulPre = { name + "\u0000" }; + String[] nulSuf = { ".test" }; + test("NulName", nulPre, nulSuf, true); + // Test JDK-8025128 String[] goodPre = { "///..///", "/foo" }; String[] goodSuf = { ".temp", ".tmp" }; @@ -91,6 +99,7 @@ String[] slashSuf = { "///..///..", "///..///..", "///..///.." }; test("SlashedName", slashPre, slashSuf, true); + // Windows tests if (!System.getProperty("os.name").startsWith("Windows")) return;
--- a/test/java/io/pathNames/General.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/java/io/pathNames/General.java Wed Sep 10 15:32:50 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -28,6 +28,7 @@ import java.io.*; import java.util.*; +import java.nio.file.*; public class General { @@ -38,12 +39,40 @@ private static int gensymCounter = 0; + protected static final String userDir = System.getProperty("user.dir"); + + protected static String baseDir = null; + protected static String relative = null; /* Generate a filename unique to this run */ private static String gensym() { return "x." + ++gensymCounter; } + /** + * Create files and folders in the test working directory. + * The purpose is to make sure the test will not go out of + * its user dir when walking the file tree. + * + * @param depth The number of directory levels to be created under + * the user directory. It should be the maximum value + * of the depths passed to checkNames method (including + * direct or indirect calling) in a whole test. + */ + protected static void initTestData(int depth) throws IOException { + File parent = new File(userDir); + for (int i = 0; i < depth; i++) { + File tmp = new File(parent, gensym()); + tmp.createNewFile(); + tmp = new File(parent, gensym()); + if (tmp.mkdir()) + parent = tmp; + else + throw new IOException("Fail to create directory, " + tmp); + } + baseDir = parent.getAbsolutePath(); + relative = baseDir.substring(userDir.length() + 1); + } /** * Find a file in the given subdirectory, or descend into further @@ -57,7 +86,7 @@ for (int i = 0; i < dl.length; i++) { File f = new File(subdir, dl[i]); File df = new File(dir, f.getPath()); - if (df.exists() && df.isFile()) { + if (Files.isRegularFile(df.toPath(), LinkOption.NOFOLLOW_LINKS)) { return f.getPath(); } } @@ -65,7 +94,7 @@ File f = (subdir.length() == 0) ? new File(dl[i]) : new File(subdir, dl[i]); File df = new File(dir, f.getPath()); - if (df.exists() && df.isDirectory()) { + if (Files.isDirectory(df.toPath(), LinkOption.NOFOLLOW_LINKS)) { String[] dl2 = df.list(); if (dl2 != null) { String ff = findSomeFile(dir, f.getPath(), dl2); @@ -90,7 +119,7 @@ } for (int i = 0; i < dl.length; i++) { File f = new File(dir, dl[i]); - if (f.isFile()) { + if (Files.isRegularFile(f.toPath(), LinkOption.NOFOLLOW_LINKS)) { return dl[i]; } } @@ -127,9 +156,9 @@ } for (int i = 0; i < dl.length; i++) { File f = new File(d, dl[i]); - if (f.isDirectory() && f.canRead()) { + if (Files.isDirectory(f.toPath(), LinkOption.NOFOLLOW_LINKS)) { String[] dl2 = f.list(); - if (dl2.length >= 250) { + if (dl2 == null || dl2.length >= 250) { /* Heuristic to avoid scanning huge directories */ continue; } @@ -213,7 +242,7 @@ /** Hash table of input pathnames, used to detect duplicates */ - private static Hashtable checked = new Hashtable(); + private static Hashtable<String, String> checked = new Hashtable<>(); /** * Check the given pathname. Its canonical pathname should be the given @@ -271,7 +300,7 @@ /** Check a single slash case, plus its children */ - public static void checkSlash(int depth, boolean create, + private static void checkSlash(int depth, boolean create, String ans, String ask, String slash) throws Exception { @@ -314,7 +343,7 @@ /* Normal name */ if (f.exists()) { - if (f.isDirectory() && f.canRead()) { + if (Files.isDirectory(f.toPath(), LinkOption.NOFOLLOW_LINKS) && f.list() != null) { if ((n = findSomeFile(ans, create)) != null) checkSlashes(d, create, ans + n, ask + n); if ((n = findSomeDir(ans, create)) != null)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/io/pathNames/GeneralSolaris.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2013, 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 4035924 4095767 + @summary General exhaustive test of solaris pathname handling + @author Mark Reinhold + + @build General GeneralSolaris + @run main GeneralSolaris + */ + +import java.io.*; +import java.util.*; +import java.nio.file.*; +import java.nio.file.attribute.*; + +public class GeneralSolaris extends General { + + private static void checkUnreadable() throws Exception { + Path file = Paths.get(baseDir, "unreadableFile"); + Path dir = Paths.get(baseDir, "unreadableDir"); + Set<PosixFilePermission> perms = PosixFilePermissions.fromString("---------"); + FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); + Files.createFile(file, attr); + Files.createDirectory(dir, attr); + + String unreadableFile = file.toString(); + String unreadableDir = dir.toString(); + + checkSlashes(2, false, unreadableDir, unreadableDir); + checkSlashes(2, false, unreadableFile, unreadableFile); + + Files.delete(file); + Files.delete(dir); + } + + private static void checkPaths() throws Exception { + // Make sure that an empty relative path is tested + checkNames(1, true, userDir + File.separator, ""); + checkNames(3, true, baseDir + File.separator, + relative + File.separator); + + checkSlashes(2, true, baseDir, baseDir); + } + + public static void main(String[] args) throws Exception { + if (File.separatorChar != '/') { + /* This test is only valid on Unix systems */ + return; + } + if (args.length > 0) debug = true; + + initTestData(3); + checkUnreadable(); + checkPaths(); + } +}
--- a/test/java/io/pathNames/GeneralWin32.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/java/io/pathNames/GeneralWin32.java Wed Sep 10 15:32:50 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -22,7 +22,7 @@ */ /* @test - @bug 4032066 4039597 4046914 4054511 4065189 4109131 4875229 6983520 + @bug 4032066 4039597 4046914 4054511 4065189 4109131 4875229 6983520 8009258 @summary General exhaustive test of win32 pathname handling @author Mark Reinhold @@ -31,8 +31,6 @@ */ import java.io.*; -import java.util.*; - public class GeneralWin32 extends General { @@ -50,10 +48,9 @@ private static final String NONEXISTENT_UNC_HOST = "non-existent-unc-host"; private static final String NONEXISTENT_UNC_SHARE = "bogus-share"; - /* Pathnames relative to working directory */ - private static void checkCaseLookup(String ud) throws IOException { + private static void checkCaseLookup() throws IOException { /* Use long names here to avoid 8.3 format, which Samba servers often force to lowercase */ File d = new File("XyZzY0123", "FOO_bar_BAZ"); @@ -75,7 +72,7 @@ /* Computing the canonical path of a Win32 file should expose the true case of filenames, rather than just using the input case */ - File y = new File(ud, f.getPath()); + File y = new File(userDir, f.getPath()); String ans = y.getPath(); check(ans, "XyZzY0123\\FOO_bar_BAZ\\GLORPified"); check(ans, "xyzzy0123\\foo_bar_baz\\glorpified"); @@ -91,18 +88,20 @@ throw new Exception("Wildcard path not rejected: " + f); } - private static void checkWildCards(String ud) throws Exception { - File d = new File(ud).getCanonicalFile(); + private static void checkWildCards() throws Exception { + File d = new File(userDir).getCanonicalFile(); checkWild(new File(d, "*.*")); checkWild(new File(d, "*.???")); checkWild(new File(new File(d, "*.*"), "foo")); } - private static void checkRelativePaths() throws Exception { - String ud = System.getProperty("user.dir").replace('/', '\\'); - checkCaseLookup(ud); - checkWildCards(ud); - checkNames(3, true, ud + "\\", ""); + private static void checkRelativePaths(int depth) throws Exception { + checkCaseLookup(); + checkWildCards(); + // Make sure that an empty relative path is tested + checkNames(1, true, userDir + File.separator, ""); + checkNames(depth, true, baseDir + File.separator, + relative + File.separator); } @@ -137,19 +136,19 @@ checkNames(depth, false, ans, d); } - private static void checkDrivePaths() throws Exception { - checkDrive(2, findActiveDrive(), true); - checkDrive(2, findInactiveDrive(), false); + private static void checkDrivePaths(int depth) throws Exception { + checkDrive(depth, findActiveDrive(), true); + checkDrive(depth, findInactiveDrive(), false); } /* UNC pathnames */ - private static void checkUncPaths() throws Exception { + private static void checkUncPaths(int depth) throws Exception { String s = ("\\\\" + NONEXISTENT_UNC_HOST + "\\" + NONEXISTENT_UNC_SHARE); ensureNon(s); - checkSlashes(2, false, s, s); + checkSlashes(depth, false, s, s); s = "\\\\" + EXISTENT_UNC_HOST + "\\" + EXISTENT_UNC_SHARE; if (!(new File(s)).exists()) { @@ -158,7 +157,7 @@ return; } - checkSlashes(2, false, s, s); + checkSlashes(depth, false, s, s); } @@ -168,9 +167,11 @@ return; } if (args.length > 0) debug = true; - checkRelativePaths(); - checkDrivePaths(); - checkUncPaths(); + + initTestData(3); + + checkRelativePaths(3); + checkDrivePaths(2); + checkUncPaths(2); } - }
--- a/test/java/lang/String/ToLowerCase.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/java/lang/String/ToLowerCase.java Wed Sep 10 15:32:50 2014 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -23,7 +23,7 @@ /* @test - @bug 4217441 4533872 4900935 8020037 + @bug 4217441 4533872 4900935 8020037 8041791 @summary toLowerCase should lower-case Greek Sigma correctly depending on the context (final/non-final). Also it should handle Locale specific (lt, tr, and az) lowercasings and supplementary @@ -72,8 +72,10 @@ // I-dot tests test("\u0130", turkish, "i"); test("\u0130", az, "i"); - test("\u0130", lt, "i"); - test("\u0130", Locale.US, "i"); + test("\u0130", lt, "\u0069\u0307"); + test("\u0130", Locale.US, "\u0069\u0307"); + test("\u0130", Locale.JAPAN, "\u0069\u0307"); + test("\u0130", Locale.ROOT, "\u0069\u0307"); // Remove dot_above in the sequence I + dot_above (Turkish and Azeri) test("I\u0307", turkish, "i");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JComponent/8043610/bug8043610.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,122 @@ +/* + * 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 8043610 + @summary Tests that JComponent invalidate, revalidate and repaint methods could + be called from any thread + @author Petr Pchelko +*/ + +import sun.awt.SunToolkit; + +import javax.swing.*; +import java.awt.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicReference; + +public class bug8043610 { + private static volatile JFrame frame; + private static volatile JComponent component; + + public static void main(String[] args) throws Exception { + ThreadGroup stubTG = new ThreadGroup(getRootThreadGroup(), "Stub Thread Group"); + ThreadGroup swingTG = new ThreadGroup(getRootThreadGroup(), "SwingTG"); + try { + Thread stubThread = new Thread(stubTG, new Runnable() { + @Override + public void run() { + SunToolkit.createNewAppContext(); + } + }); + stubThread.start(); + stubThread.join(); + + final CountDownLatch startSwingLatch = new CountDownLatch(1); + new Thread(swingTG, new Runnable() { + @Override + public void run() { + SunToolkit.createNewAppContext(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + frame = new JFrame(); + component = new JLabel("Test Text"); + frame.add(component); + frame.setBounds(100, 100, 100, 100); + frame.setVisible(true); + startSwingLatch.countDown(); + } + }); + } + }).start(); + startSwingLatch.await(); + + final AtomicReference<Exception> caughtException = new AtomicReference<>(); + Thread checkThread = new Thread(getRootThreadGroup(), new Runnable() { + @Override + public void run() { + try { + component.invalidate(); + component.revalidate(); + component.repaint(new Rectangle(0, 0, 0, 0)); + } catch (Exception e) { + caughtException.set(e); + } + } + }); + checkThread.start(); + checkThread.join(); + + if (caughtException.get() != null) { + throw new RuntimeException("Failed. Caught exception!", caughtException.get()); + } + } finally { + new Thread(swingTG, new Runnable() { + @Override + public void run() { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (frame != null) { + frame.dispose(); + } + } + }); + } + }).start(); + } + } + + private static ThreadGroup getRootThreadGroup() { + ThreadGroup currentTG = Thread.currentThread().getThreadGroup(); + ThreadGroup parentTG = currentTG.getParent(); + while (parentTG != null) { + currentTG = parentTG; + parentTG = currentTG.getParent(); + } + return currentTG; + } +}
--- a/test/javax/swing/JFileChooser/8046391/bug8046391.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/javax/swing/JFileChooser/8046391/bug8046391.java Wed Sep 10 15:32:50 2014 -0700 @@ -47,15 +47,18 @@ return; } - SwingUtilities.invokeAndWait(() -> { - try { - UIManager.setLookAndFeel(new WindowsLookAndFeel()); - } catch (UnsupportedLookAndFeelException e) { - e.printStackTrace(); + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + UIManager.setLookAndFeel(new WindowsLookAndFeel()); + } catch (UnsupportedLookAndFeelException e) { + e.printStackTrace(); + } + System.out.println("Creating JFileChooser..."); + JFileChooser fileChooser = new JFileChooser(); + System.out.println("Test passed: chooser = " + fileChooser); } - System.out.println("Creating JFileChooser..."); - JFileChooser fileChooser = new JFileChooser(); - System.out.println("Test passed: chooser = " + fileChooser); }); // Test fails if creating JFileChooser hangs }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/bind/marshal/8036981/Good.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,94 @@ +/* + * 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. + */ + +package testjaxbcontext; + +import org.w3c.dom.Element; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; + +/** + * <p> + * Java class for Good complex type. + * + * <p> + * The following schema fragment specifies the expected content contained within + * this class. + * + * <pre> + * <complexType name="Good"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <any processContents='skip' maxOccurs="70"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Good", propOrder = { + "any" +}) +public class Good { + + @XmlAnyElement + protected List<Element> any; + + /** + * Gets the value of the any property. + * + * <p> + * This accessor method returns a reference to the live list, not a + * snapshot. Therefore any modification you make to the returned list will + * be present inside the JAXB object. This is why there is not a + * <CODE>set</CODE> method for the any property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getAny().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link org.w3c.dom.Element } + * + * + */ + public List<Element> getAny() { + if (any == null) { + any = new ArrayList<Element>(); + } + return this.any; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/bind/marshal/8036981/Main.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,104 @@ +/* + * 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. + */ + +package testjaxbcontext; + +import javax.xml.bind.annotation.*; + +/** + * <p> + * Java class for main complex type. + * + * <p> + * The following schema fragment specifies the expected content contained within + * this class. + * + * <pre> + * <complexType name="main"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="Root" type="{}Root"/> + * <element name="Good" type="{}Good"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "main", propOrder = { + "root", + "good" +}) +@XmlRootElement +public class Main { + + @XmlElement(name = "Root", required = true) + protected Root root; + @XmlElement(name = "Good", required = true) + protected Good good; + + /** + * Gets the value of the root property. + * + * @return possible object is {@link Root } + * + */ + public Root getRoot() { + return root; + } + + /** + * Sets the value of the root property. + * + * @param value allowed object is {@link Root } + * + */ + public void setRoot(Root value) { + this.root = value; + } + + /** + * Gets the value of the good property. + * + * @return possible object is {@link Good } + * + */ + public Good getGood() { + return good; + } + + /** + * Sets the value of the good property. + * + * @param value allowed object is {@link Good } + * + */ + public void setGood(Good value) { + this.good = value; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/bind/marshal/8036981/ObjectFactory.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,74 @@ +/* + * 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. + */ + +package testjaxbcontext; + +import javax.xml.bind.annotation.XmlRegistry; + +/** + * This object contains factory methods for each Java content interface and Java + * element interface generated in the generated package. + * <p> + * An ObjectFactory allows you to programatically construct new instances of the + * Java representation for XML content. The Java representation of XML content + * can consist of schema derived interfaces and classes representing the binding + * of schema type definitions, element declarations and model groups. Factory + * methods for each of these are provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + /** + * Create a new ObjectFactory that can be used to create new instances of + * schema derived classes for package: generated + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Root } + * + */ + public Root createRoot() { + return new Root(); + } + + /** + * Create an instance of {@link Good } + * + */ + public Good createGood() { + return new Good(); + } + + /** + * Create an instance of {@link Main } + * + */ + public Main createMain() { + return new Main(); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/bind/marshal/8036981/Root.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,91 @@ +/* + * 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. + */ + +package testjaxbcontext; + +import javax.xml.bind.annotation.*; +import java.util.ArrayList; +import java.util.List; + +/** + * <p> + * Java class for Root complex type. + * + * <p> + * The following schema fragment specifies the expected content contained within + * this class. + * + * <pre> + * <complexType name="Root"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <any processContents='skip' maxOccurs="70"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Root", propOrder = { + "content" +}) +public class Root { + + @XmlMixed + @XmlAnyElement + protected List<Object> content; + + /** + * Gets the value of the content property. + * + * <p> + * This accessor method returns a reference to the live list, not a + * snapshot. Therefore any modification you make to the returned list will + * be present inside the JAXB object. This is why there is not a + * <CODE>set</CODE> method for the content property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getContent().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list {@link org.w3c.dom.Element } + * {@link String } + * + * + */ + public List<Object> getContent() { + if (content == null) { + content = new ArrayList<Object>(); + } + return this.content; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/bind/marshal/8036981/Test.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,67 @@ +/* + * 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 Test.java + * @bug 8036981 + * @summary JAXB not preserving formatting during unmarshalling/marshalling + * @compile Good.java Main.java ObjectFactory.java Root.java + * @run main/othervm Test + */ + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import java.io.File; +import java.io.StringWriter; + +/** + * Test for marshalling and unmarshalling mixed and unmixed content + */ +public class Test { + + private static final String EXPECTED = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><main><Root>\n" + + " <SomeTag>\n" + + " <AChildTag>\n" + + " <AnotherChildTag/>\n" + + " <AnotherChildTag/>\n" + + " </AChildTag>\n" + + " </SomeTag>\n" + + " </Root><Good><VeryGood><TheBest><MegaSuper/><MegaSuper/>\n" + + " </TheBest>\n" + + " </VeryGood></Good></main>"; + + public static void main(String[] args) throws Exception { + JAXBContext jc = JAXBContext.newInstance("testjaxbcontext"); + Unmarshaller u = jc.createUnmarshaller(); + Object result = u.unmarshal(new File(System.getProperty("test.src", ".") + "/test.xml")); + StringWriter sw = new StringWriter(); + Marshaller m = jc.createMarshaller(); + m.marshal(result, sw); + System.out.println("Expected:" + EXPECTED); + System.out.println("Observed:" + sw.toString()); + if (!EXPECTED.equals(sw.toString())) { + throw new Exception("Unmarshal/Marshal generates different content"); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/bind/marshal/8036981/test.xml Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<main> + <Root> + <SomeTag> + <AChildTag> + <AnotherChildTag/> + <AnotherChildTag/> + </AChildTag> + </SomeTag> + </Root> + <Good> + <VeryGood> + <TheBest> + <MegaSuper/> + <MegaSuper/> + </TheBest> + </VeryGood> + </Good> +</main>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/net/Sockets/Test.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,231 @@ +/* + * 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 8032808 + * @run main/othervm -Xcheck:jni Test + * @run main/othervm/policy=policy.fail -Xcheck:jni Test fail + * @run main/othervm/policy=policy.success -Xcheck:jni Test success + */ + +import java.net.*; +import java.nio.channels.*; +import java.util.concurrent.*; +import jdk.net.*; + +public class Test { + + static boolean security; + static boolean success; + static int udp_port; + static InetAddress loop; + static InetSocketAddress loopad; + static SocketFlow flowIn; + static SocketChannel sc; + static Socket s; + + public static void main(String[] args) throws Exception { + + // quick check to see if supportedOptions() working before + // creating any sockets and libnet loaded + + Sockets.supportedOptions(Socket.class); + + security = System.getSecurityManager() != null; + success = security && args[0].equals("success"); + + // Main thing is to check for JNI problems + // Doesn't matter if current system does not support the option + // and currently setting the option with the loopback interface + // doesn't work either + + System.out.println ("Security Manager enabled: " + security); + if (security) { + System.out.println ("Success expected: " + success); + } + + flowIn = SocketFlow.create() + .bandwidth(1000) + .priority(SocketFlow.HIGH_PRIORITY); + + ServerSocket ss = new ServerSocket(0); + int tcp_port = ss.getLocalPort(); + loop = InetAddress.getByName("127.0.0.1"); + loopad = new InetSocketAddress(loop, tcp_port); + + DatagramSocket dg = new DatagramSocket(0); + udp_port = dg.getLocalPort(); + + s = new Socket("127.0.0.1", tcp_port); + sc = SocketChannel.open(); + sc.connect (new InetSocketAddress("127.0.0.1", tcp_port)); + + // Do some standard options tests first. Since JDK 8 doesn't have java.net API + Sockets.setOption(s, StandardSocketOptions.SO_SNDBUF, 8000); + System.out.println ("Set SO_SNDBUF to 8000\ngetting returns: "); + System.out.println (Sockets.getOption(s, StandardSocketOptions.SO_SNDBUF)); + + Sockets.setOption(ss, StandardSocketOptions.SO_RCVBUF, 5000); + System.out.println ("Set SO_RCVBUF to 5000\ngetting returns: "); + System.out.println (Sockets.getOption(s, StandardSocketOptions.SO_RCVBUF)); + + try { + Sockets.setOption(ss, StandardSocketOptions.TCP_NODELAY, true); + throw new RuntimeException("TCP_NODELAY should not be supported for ServerSocket"); + } catch (UnsupportedOperationException e) {} + try { + Sockets.setOption(dg, StandardSocketOptions.IP_MULTICAST_LOOP, true); + throw new RuntimeException("IP_MULTICAST_LOOP should not be supported for DatagramSocket"); + } catch (UnsupportedOperationException e) {} + + MulticastSocket mc0 = new MulticastSocket(0); + Sockets.setOption(mc0, StandardSocketOptions.IP_MULTICAST_LOOP, true); + System.out.println ("Expect true: " + Sockets.getOption(mc0, StandardSocketOptions.IP_MULTICAST_LOOP)); + + // Now the specific tests for SO_FLOW_SLA + + doTest1(); + doTest2(); + doTest3(); + doTest4(); + doTest5(); + doTest6(); + doTest7(); + doTest8(); + } + + static void doTest1() throws Exception { + try { + Sockets.setOption(s, ExtendedSocketOptions.SO_FLOW_SLA, flowIn); + if (security && !success) { + throw new RuntimeException("Test failed"); + } + } catch (SecurityException e) { + if (success) { + throw new RuntimeException("Test failed"); + } + } catch (UnsupportedOperationException e) {} + } + + static void doTest2() throws Exception { + try { + Sockets.getOption(s, ExtendedSocketOptions.SO_FLOW_SLA); + if (security && !success) { + throw new RuntimeException("Test failed"); + } + } catch (SecurityException e) { + if (success) { + throw new RuntimeException("Test failed"); + } + } catch (UnsupportedOperationException e) {} + } + + static void doTest3() throws Exception { + try { + sc.setOption(ExtendedSocketOptions.SO_FLOW_SLA, flowIn); + if (security && !success) { + throw new RuntimeException("Test failed"); + } + } catch (SecurityException e) { + if (success) { + throw new RuntimeException("Test failed"); + } + } catch (UnsupportedOperationException e) {} + } + + static void doTest4() throws Exception { + try { + sc.getOption(ExtendedSocketOptions.SO_FLOW_SLA); + if (security && !success) { + throw new RuntimeException("Test failed"); + } + } catch (SecurityException e) { + if (success) { + throw new RuntimeException("Test failed"); + } + } catch (UnsupportedOperationException e) {} + } + + static void doTest5() throws Exception { + try { + DatagramSocket dg1 = new DatagramSocket(0); + dg1.connect(loop, udp_port); + Sockets.setOption(dg1, ExtendedSocketOptions.SO_FLOW_SLA, flowIn); + if (security && !success) { + throw new RuntimeException("Test failed"); + } + } catch (SecurityException e) { + if (success) { + throw new RuntimeException("Test failed"); + } + } catch (UnsupportedOperationException e) {} + } + + static void doTest6() throws Exception { + try { + DatagramChannel dg2 = DatagramChannel.open(); + dg2.bind(new InetSocketAddress(loop, 0)); + dg2.connect(new InetSocketAddress(loop, udp_port)); + dg2.setOption(ExtendedSocketOptions.SO_FLOW_SLA, flowIn); + if (security && !success) { + throw new RuntimeException("Test failed"); + } + } catch (SecurityException e) { + if (success) { + throw new RuntimeException("Test failed"); + } + } catch (UnsupportedOperationException e) {} + } + + static void doTest7() throws Exception { + try { + MulticastSocket mc1 = new MulticastSocket(0); + mc1.connect(loop, udp_port); + Sockets.setOption(mc1, ExtendedSocketOptions.SO_FLOW_SLA, flowIn); + if (security && !success) { + throw new RuntimeException("Test failed"); + } + } catch (SecurityException e) { + if (success) { + throw new RuntimeException("Test failed"); + } + } catch (UnsupportedOperationException e) {} + } + + static void doTest8() throws Exception { + try { + AsynchronousSocketChannel asc = AsynchronousSocketChannel.open(); + Future<Void> f = asc.connect(loopad); + f.get(); + asc.setOption(ExtendedSocketOptions.SO_FLOW_SLA, flowIn); + if (security && !success) { + throw new RuntimeException("Test failed"); + } + } catch (SecurityException e) { + if (success) { + throw new RuntimeException("Test failed"); + } + } catch (UnsupportedOperationException e) {} + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/net/Sockets/policy.fail Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,4 @@ +grant { + permission java.net.SocketPermission "127.0.0.1", "connect,accept" ; + permission java.net.SocketPermission "localhost", "listen" ; +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/net/Sockets/policy.success Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,6 @@ +grant { + permission java.net.SocketPermission "127.0.0.1", "connect,accept" ; + permission java.net.SocketPermission "localhost", "listen" ; + permission jdk.net.NetworkPermission "setOption.SO_FLOW_SLA"; + permission jdk.net.NetworkPermission "getOption.SO_FLOW_SLA"; +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/java2d/OpenGL/DrawHugeImageTest.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,108 @@ +/* + * 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 8040617 + * @summary Test verifies that an attempt to get an accelerated copy of + * a huge buffered image does not result in an OOME. + * + * @run main DrawHugeImageTest + */ + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.image.BufferedImage; +import java.awt.image.VolatileImage; + +public class DrawHugeImageTest { + // we have to render the BI source several times in order + // to get an accelerated copy to be used. + static { + System.setProperty("sun.java2d.accthreshold", "1"); + } + private static final int max_rendering_count = 5; + + private static final Color srcColor = Color.red; + private static final Color dstColor = Color.blue; + + public static void main(String[] args) { + BufferedImage src = createSrc(); + + VolatileImage dst = createDst(); + System.out.println("Dst: " + dst); + boolean status; + int count = max_rendering_count; + + do { + System.out.println("render image: " + (max_rendering_count - count)); + status = render(src, dst); + + } while (status && count-- > 0); + + if (!status || count > 0) { + throw new RuntimeException("Test failed: " + count); + } + } + + private static boolean render(BufferedImage src, VolatileImage dst) { + int cnt = 5; + do { + Graphics2D g = dst.createGraphics(); + g.setColor(dstColor); + g.fillRect(0, 0, dst.getWidth(), dst.getHeight()); + g.drawImage(src, 0, 0, null); + g.dispose(); + } while (dst.contentsLost() && (--cnt > 0)); + + if (cnt == 0) { + System.err.println("Test failed: unable to render to volatile destination"); + return false; + } + + BufferedImage s = dst.getSnapshot(); + + return s.getRGB(1,1) == srcColor.getRGB(); + } + + private static BufferedImage createSrc() { + final int w = 20000; + final int h = 5; + + BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR); + Graphics2D g = img.createGraphics(); + g.setColor(srcColor); + g.fillRect(0, 0, w, h); + g.dispose(); + + return img; + } + + private static VolatileImage createDst() { + GraphicsConfiguration gc = + GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); + + return gc.createCompatibleVolatileImage(200, 200); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/net/www/protocol/http/B8012625.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2013, 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 8012625 + * @run main B8012625 + */ + +import java.net.*; +import java.io.*; + +import java.net.*; +import java.io.*; +import java.util.concurrent.*; +import com.sun.net.httpserver.*; + +public class B8012625 implements HttpHandler { + + public static void main (String[] args) throws Exception { + B8012625 test = new B8012625(); + test.run(); + } + + public void run() throws Exception { + String u = "http://127.0.0.1:" + port + "/foo"; + URL url = new URL(u); + HttpURLConnection uc = (HttpURLConnection)url.openConnection(); + uc.setDoOutput(true); + uc.setRequestMethod("POST"); + uc.addRequestProperty("Expect", "100-Continue"); + //uc.setFixedLengthStreamingMode(256); + System.out.println ("Client: getting outputstream"); + long before = System.currentTimeMillis(); + OutputStream os = uc.getOutputStream(); + long after = System.currentTimeMillis(); + System.out.println ("Client: writing to outputstream"); + byte[] buf = new byte[256]; + os.write(buf); + System.out.println ("Client: done writing "); + int r = uc.getResponseCode(); + System.out.println ("Client: received response code " + r); + server.stop(1); + ex.shutdownNow(); + if (after - before >= 5000) { + throw new RuntimeException("Error: 5 second delay seen"); + } + } + + int port; + HttpServer server; + ExecutorService ex; + + public B8012625 () throws Exception { + server = HttpServer.create(new InetSocketAddress(0), 10); + HttpContext ctx = server.createContext("/", this); + ex = Executors.newFixedThreadPool(5); + server.setExecutor(ex); + server.start(); + port = server.getAddress().getPort(); + } + + public void handle(HttpExchange ex) throws IOException { + String s = ex.getRequestMethod(); + if (!s.equals("POST")) { + ex.getResponseHeaders().set("Allow", "POST"); + ex.sendResponseHeaders(500, -1); + ex.close(); + return; + } + System.out.println ("Server: reading request body"); + InputStream is = ex.getRequestBody(); + // read request + byte[] buf = new byte [1024]; + while (is.read(buf) != -1) ; + is.close(); + ex.sendResponseHeaders(200, -1); + ex.close(); + } +}
--- a/test/sun/security/krb5/auto/DynamicKeytab.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/sun/security/krb5/auto/DynamicKeytab.java Wed Sep 10 15:32:50 2014 -0700 @@ -110,11 +110,13 @@ throw new Exception("Should not success"); } catch (GSSException gsse) { System.out.println(gsse); - KrbException ke = (KrbException)gsse.getCause(); - if (ke.returnCode() != Krb5.KRB_AP_ERR_BADKEYVER) { - throw new Exception("Not expected failure code: " + - ke.returnCode()); - } + // Since 7197159, different kvno is accepted, this return code + // will never be thrown out again. + //KrbException ke = (KrbException)gsse.getCause(); + //if (ke.returnCode() != Krb5.KRB_AP_ERR_BADKEYVER) { + // throw new Exception("Not expected failure code: " + + // ke.returnCode()); + //} } // Test 8: an empty KDC means revoke all
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/krb5/auto/KvnoNA.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 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 7197159 + * @compile -XDignore.symbol.file KvnoNA.java + * @run main/othervm KvnoNA + * @summary accept different kvno if there no match + */ + +import org.ietf.jgss.GSSException; +import sun.security.jgss.GSSUtil; +import sun.security.krb5.KrbException; +import sun.security.krb5.PrincipalName; +import sun.security.krb5.internal.ktab.KeyTab; +import sun.security.krb5.internal.Krb5; + +public class KvnoNA { + + public static void main(String[] args) + throws Exception { + + OneKDC kdc = new OneKDC(null); + kdc.writeJAASConf(); + + // In KDC, it's 2 + char[] pass = "pass2".toCharArray(); + kdc.addPrincipal(OneKDC.SERVER, pass); + + // In ktab, kvno is 1 or 3, 3 has the same password + KeyTab ktab = KeyTab.create(OneKDC.KTAB); + PrincipalName p = new PrincipalName( + OneKDC.SERVER+"@"+OneKDC.REALM, PrincipalName.KRB_NT_SRV_HST); + ktab.addEntry(p, "pass1".toCharArray(), 1, true); + ktab.addEntry(p, "pass2".toCharArray(), 3, true); + ktab.save(); + + Context c, s; + + c = Context.fromUserPass("dummy", "bogus".toCharArray(), false); + s = Context.fromJAAS("server"); + + c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); + s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID); + + Context.handshake(c, s); + + s.dispose(); + c.dispose(); + } +}
--- a/test/sun/security/krb5/auto/MoreKvno.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/sun/security/krb5/auto/MoreKvno.java Wed Sep 10 15:32:50 2014 -0700 @@ -23,8 +23,7 @@ /* * @test - * @bug 6893158 - * @bug 6907425 + * @bug 6893158 6907425 7197159 * @run main/othervm MoreKvno * @summary AP_REQ check should use key version number */ @@ -69,11 +68,13 @@ go(OneKDC.SERVER, "com.sun.security.jgss.krb5.accept", pass); throw new Exception("This test should fail"); } catch (GSSException gsse) { - KrbException ke = (KrbException)gsse.getCause(); - if (ke.returnCode() != Krb5.KRB_AP_ERR_BADKEYVER) { - throw new Exception("Not expected failure code: " + - ke.returnCode()); - } + // Since 7197159, different kvno is accepted, this return code + // will never be thrown out again. + //KrbException ke = (KrbException)gsse.getCause(); + //if (ke.returnCode() != Krb5.KRB_AP_ERR_BADKEYVER) { + // throw new Exception("Not expected failure code: " + + // ke.returnCode()); + //} } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/krb5/ccache/DefaultFile.java Wed Sep 10 15:32:50 2014 -0700 @@ -0,0 +1,47 @@ +/* + * 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 8054817 + * @summary File ccache only recognizes Linux and Solaris defaults + */ + +import sun.security.krb5.internal.ccache.FileCredentialsCache; + +public class DefaultFile { + public static void main(String[] args) throws Exception { + // There are 2 cases where default ccache name is not + // /tmp/krb5cc_uid. + if (System.getenv("KRB5CCNAME") != null) { + return; + } + if (System.getProperty("os.name").startsWith("Windows")) { + return; + } + String name = FileCredentialsCache.getDefaultCacheName(); + if (!name.startsWith("/tmp/krb5cc_")) { + throw new Exception("default name is " + name); + } + } +}
--- a/test/sun/security/smartcardio/TestDirect.java Thu Aug 28 15:14:04 2014 -0700 +++ b/test/sun/security/smartcardio/TestDirect.java Wed Sep 10 15:32:50 2014 -0700 @@ -30,6 +30,7 @@ // This test requires special hardware. +import java.util.List; import javax.smartcardio.Card; import javax.smartcardio.CardTerminal; import javax.smartcardio.CardTerminals; @@ -38,8 +39,12 @@ public class TestDirect { public static void main(String[] args) throws Exception { TerminalFactory terminalFactory = TerminalFactory.getDefault(); - CardTerminals cardTerminals = terminalFactory.terminals(); - CardTerminal cardTerminal = cardTerminals.list().get(0); + List<CardTerminal> cardTerminals = terminalFactory.terminals().list(); + System.out.println("Terminals: " + cardTerminals); + if (cardTerminals.isEmpty()) { + throw new Exception("No card terminals available"); + } + CardTerminal cardTerminal = cardTerminals.get(0); Card card = cardTerminal.connect("DIRECT"); card.disconnect(true);