Mercurial > hg > icedtea8-forest > jdk
changeset 13792:7e316a64ae8c icedtea-3.11.0pre02
Merge jdk8u192-b12
line wrap: on
line diff
--- a/.hgtags Wed Jan 09 07:30:53 2019 +0000 +++ b/.hgtags Wed Jan 16 01:02:44 2019 +0000 @@ -990,3 +990,17 @@ 6e67500d0ed8d970fb5cd9f6deee42e38af707fb icedtea-3.10.0 6e67500d0ed8d970fb5cd9f6deee42e38af707fb icedtea-3.11.0pre00 1a1eac5703fcbaff1b5c57835530fdf91cadab51 icedtea-3.11.0pre01 +51b6cc7fbd98a87c6cdb5c70b7dbe25bb10e0dd7 jdk8u182-b00 +bead1ed7344f2911f5bed83639cf5160596561ef jdk8u192-b00 +444b4528c8ecdd39b5923820fa2ed6d583808b5e jdk8u192-b01 +e56bb18a4dff4c234c5949c750f910a1ed92fafe jdk8u192-b02 +cadea780bc765ccca4aa919522e876b368c58145 jdk8u192-b03 +b17237c1ab9c4670d939fef09a6bbecdecad824a jdk8u192-b04 +fde7fd2a2fd225c4e2d469943b14ea84d3772853 jdk8u192-b05 +4a23ff05b4f9f8a6345e8ae6c25ce0010db71249 jdk8u192-b06 +6b29c26e864aca83a6b7e481003d95d3704e928a jdk8u192-b07 +7556b6a2aa3266fb4a213c4fbbca2a403d4df306 jdk8u192-b08 +f47b81dbed2dd730d34a8dc3e3d14e2aa9f9c493 jdk8u192-b09 +621105274477152934059d58a116222f09d966a2 jdk8u192-b10 +89f64de4cebd640247fc17448f19c24fce2cc6fd jdk8u192-b25 +2cd82eb879dd0f853dbfb7ffa2441e81e2413447 jdk8u192-b11
--- a/make/CopyFiles.gmk Wed Jan 09 07:30:53 2019 +0000 +++ b/make/CopyFiles.gmk Wed Jan 16 01:02:44 2019 +0000 @@ -247,16 +247,28 @@ ########################################################################################## -# Copy msvcrXX.dll on windows +# Copy the microsoft runtime libraries on windows +ifeq ($(OPENJDK_TARGET_OS), windows) -ifeq ($(OPENJDK_TARGET_OS), windows) - MSVCR_TARGET := $(JDK_OUTPUTDIR)/bin/$(notdir $(MSVCR_DLL)) # Chmod to avoid permission issues if bundles are unpacked on unix platforms. - $(MSVCR_TARGET): $(MSVCR_DLL) - $(call install-file) + define copy-and-chmod + $(install-file) $(CHMOD) a+rx $@ + endef - COPY_FILES += $(MSVCR_TARGET) + # Use separate macro calls in case the source files are not in the same + # directory. + $(eval $(call SetupCopyFiles,COPY_MSVCR, \ + DEST := $(JDK_OUTPUTDIR)/bin, \ + FILES := $(MSVCR_DLL), \ + MACRO := copy-and-chmod)) + + $(eval $(call SetupCopyFiles,COPY_MSVCP, \ + DEST := $(JDK_OUTPUTDIR)/bin, \ + FILES := $(MSVCP_DLL), \ + MACRO := copy-and-chmod)) + + COPY_FILES += $(COPY_MSVCR) $(COPY_MSVCP) endif ##########################################################################################
--- a/make/CreateJars.gmk Wed Jan 09 07:30:53 2019 +0000 +++ b/make/CreateJars.gmk Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2018, 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 @@ -265,7 +265,10 @@ $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.rt.jar.contents: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents $(MKDIR) -p $(@D) $(RM) $@ $@.tmp - $(GREP) -e '\.class$$' $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents > $@.tmp + # Cygwin grep does not match $ as end of line if there are windows line + # endings in the input. + $(TR) -d '\r' < $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents \ + | $(GREP) -e '\.class$$' > $@.tmp ifneq ($(PROFILE), ) ifneq ($(strip $(RT_JAR_INCLUDE_TYPES)), ) # Add back classes from excluded packages (fixing the $ substitution in the process) @@ -279,9 +282,11 @@ $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.resources.jar.contents: $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents $(MKDIR) -p $(@D) $(RM) $@ $@.tmp - $(GREP) -v -e '\.class$$' \ - -e '/_the\.*' -e '^_the\.*' -e '\\_the\.*' -e 'javac_state' \ - $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents > $@.tmp + # Cygwin grep does not match $ as end of line if there are windows line + # endings in the input. + $(TR) -d '\r' < $(IMAGES_OUTPUTDIR)/lib$(PROFILE)/_the.jars.contents \ + | $(GREP) -v -e '\.class$$' \ + -e '/_the\.*' -e '^_the\.*' -e '\\_the\.*' -e 'javac_state' > $@.tmp ifneq ($(PROFILE), ) # Strip out all META-INF/services/ entries $(GREP) -v -e 'META-INF/services/' $@.tmp > $@.tmp2
--- a/make/lib/Awt2dLibraries.gmk Wed Jan 09 07:30:53 2019 +0000 +++ b/make/lib/Awt2dLibraries.gmk Wed Jan 16 01:02:44 2019 +0000 @@ -23,9 +23,6 @@ # questions. # -# Openwin is defined on Solaris. -OPENWIN_LIB := $(OPENWIN_HOME)/lib - WIN_AWT_LIB := $(JDK_OUTPUTDIR)/objs/libawt/awt.lib ########################################################################################## @@ -477,7 +474,6 @@ ASFLAGS := $(LIBAWT_ASFLAGS), \ MAPFILE := $(LIBAWT_MAPFILE), \ LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_solaris := -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \ LDFLAGS_SUFFIX_linux := -ljvm $(LIBM) $(LIBDL) -ljava, \ LDFLAGS_SUFFIX_solaris := -ljvm $(LIBM) $(LIBDL) -ljava -lc, \ LDFLAGS_SUFFIX_aix :=-ljvm $(LIBM) $(LIBDL) -ljava -lm,\ @@ -638,14 +634,7 @@ $(X_CFLAGS), \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_xawt/mapfile-vers, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ - $(X_LIBS) $(LIBAWT_XAWT_LDFLAGS), \ - LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN) \ - $(call SET_SHARED_LIBRARY_ORIGIN,/..), \ - LDFLAGS_solaris := -L$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) \ - -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) \ - -R$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) \ - -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) \ - -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \ + $(X_LIBS) $(LIBAWT_XAWT_LDFLAGS) \ $(call SET_SHARED_LIBRARY_ORIGIN) \ $(call SET_SHARED_LIBRARY_ORIGIN,/..), \ LDFLAGS_SUFFIX := $(LIBAWT_XAWT_LDFLAGS_SUFFIX), \ @@ -874,9 +863,7 @@ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \ - LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..) \ - -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \ - -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \ + LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \ LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN)., \ REORDER := $(LIBAWT_HEADLESS_REORDER), \ LDFLAGS_SUFFIX_linux := -ljvm -lawt -lm $(LIBDL) -ljava, \ @@ -944,6 +931,10 @@ BUILD_LIBFONTMANAGER_ExtensionSubtables.cpp_CXXFLAGS := -fno-strict-aliasing endif +# LDFLAGS clarification: +# Filter relevant linker flags disallowing unresolved symbols as we cannot +# build-time decide to which library to link against (libawt_headless or +# libawt_xawt). See JDK-8196516 for details. $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \ LIBRARY := fontmanager, \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ @@ -958,8 +949,9 @@ CFLAGS_windows = -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/windows \ -DCC_NOEX, \ MAPFILE := $(BUILD_LIBFONTMANAGER_MAPFILE), \ - LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_linux := -Xlinker --unresolved-symbols=ignore-all, \ + LDFLAGS := $(subst -Xlinker -z -Xlinker defs,, \ + $(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB))) $(LDFLAGS_CXX_JDK) \ + $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX := $(BUILD_LIBFONTMANAGER_FONTLIB) $(IMPROVED_FONT_RENDERING_LIBS), \ LDFLAGS_SUFFIX_linux := -lawt $(LIBM) $(LIBCXX) -ljava -ljvm -lc, \ LDFLAGS_SUFFIX_solaris := -lawt -lawt_headless -lc $(LIBM) $(LIBCXX) -ljava -ljvm, \ @@ -1111,7 +1103,7 @@ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjawt/mapfile-vers, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_solaris := -L$(OPENWIN_HOME)/sfw/lib$(OPENJDK_TARGET_CPU_ISADIR) -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \ + LDFLAGS_solaris := $(X_LIBS), \ LDFLAGS_SUFFIX_linux := $(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX), \ LDFLAGS_SUFFIX_aix := $(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX),\ LDFLAGS_SUFFIX_solaris := $(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX) -lXrender, \ @@ -1209,11 +1201,11 @@ CFLAGS := $(CFLAGS_JDKLIB) \ -I$(JDK_TOPDIR)/src/share/javavm/export \ -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \ - -I$(OPENWIN_HOME)/include, \ + $(X_CFLAGS), \ MAPFILE := $(SUNWJDGA_MAPFILE), \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_SUFFIX := -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -ldga -lX11 $(LIBDL) -lc, \ + LDFLAGS_SUFFIX := $(X_LIBS) -ldga -lX11 $(LIBDL) -lc, \ OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libsunwjdga, \ DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) @@ -1275,8 +1267,6 @@ else ifeq ($(OPENJDK_TARGET_OS), windows) LIBSPLASHSCREEN_CFLAGS += -DWITH_WIN32 - else ifeq ($(OPENJDK_TARGET_OS), solaris) - LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 -I$(OPENWIN_HOME)/include -I$(OPENWIN_HOME)/include/X11/extensions else LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 $(X_CFLAGS) endif @@ -1296,10 +1286,7 @@ -framework JavaNativeFoundation else ifeq ($(OPENJDK_TARGET_OS), windows) LIBSPLASHSCREEN_LDFLAGS_SUFFIX += kernel32.lib user32.lib gdi32.lib delayimp.lib -DELAYLOAD:user32.dll - else ifeq ($(OPENJDK_TARGET_OS), solaris) - # Solaris still uses OPENWIN_LIB .. - LIBSPLASHSCREEN_LDFLAGS_SUFFIX += -L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -lX11 -lXext $(LIBM) -lpthread - else # .. all other Unixes can use X_LIBS + else LIBSPLASHSCREEN_LDFLAGS_SUFFIX += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread endif
--- a/make/lib/CoreLibraries.gmk Wed Jan 09 07:30:53 2019 +0000 +++ b/make/lib/CoreLibraries.gmk Wed Jan 16 01:02:44 2019 +0000 @@ -390,6 +390,11 @@ cmdtoargs.c # Staticically link with c runtime on windows. LIBJLI_CFLAGS := $(filter-out -MD, $(LIBJLI_CFLAGS)) + # Supply the name of the C runtime lib. + LIBJLI_CFLAGS += -DMSVCR_DLL_NAME='"$(notdir $(MSVCR_DLL))"' + ifneq ($(MSVCP_DLL), ) + LIBJLI_CFLAGS += -DMSVCP_DLL_NAME='"$(notdir $(MSVCP_DLL))"' + endif else ifneq ($(OPENJDK_TARGET_OS), macosx) BUILD_LIBJLI_FILES += java_md_common.c
--- a/make/mapfiles/libawt/mapfile-vers Wed Jan 09 07:30:53 2019 +0000 +++ b/make/mapfiles/libawt/mapfile-vers Wed Jan 16 01:02:44 2019 +0000 @@ -94,7 +94,6 @@ Java_java_awt_Rectangle_initIDs; Java_sun_awt_image_BufImgSurfaceData_initIDs; Java_sun_awt_image_BufImgSurfaceData_initRaster; - Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; Java_sun_awt_image_BytePackedRaster_initIDs; Java_sun_awt_image_ImagingLib_lookupByteBI; Java_sun_awt_image_ImagingLib_lookupByteRaster;
--- a/make/mapfiles/libawt/mapfile-vers-linux Wed Jan 09 07:30:53 2019 +0000 +++ b/make/mapfiles/libawt/mapfile-vers-linux Wed Jan 16 01:02:44 2019 +0000 @@ -96,7 +96,6 @@ Java_sun_awt_image_BufImgSurfaceData_initIDs; Java_sun_awt_image_BufImgSurfaceData_initRaster; Java_sun_awt_image_BufImgSurfaceData_setSurfaceData; - Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; Java_sun_awt_image_BytePackedRaster_initIDs; Java_sun_awt_image_ImagingLib_lookupByteBI; Java_sun_awt_image_ImagingLib_lookupByteRaster;
--- a/make/mapfiles/libawt_xawt/mapfile-vers Wed Jan 09 07:30:53 2019 +0000 +++ b/make/mapfiles/libawt_xawt/mapfile-vers Wed Jan 16 01:02:44 2019 +0000 @@ -158,6 +158,7 @@ Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl; Java_sun_awt_X11_XRobotPeer_mouseWheelImpl; Java_sun_awt_X11_XRobotPeer_setup; + Java_sun_awt_X11_XRobotPeer_loadNativeLibraries; Java_sun_awt_X11_XToolkit_getNumberOfButtonsImpl; Java_java_awt_Component_initIDs; Java_java_awt_Container_initIDs;
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Wed Jan 16 01:02:44 2019 +0000 @@ -376,6 +376,7 @@ caretBlinkRate = Integer.valueOf(500); } } + /* If gtk-alternative-button-order is set to true, isYesLast needs to be false */ Boolean buttonOrder = Boolean.TRUE; if (Boolean.TRUE.equals(GTKEngine.INSTANCE.getSetting(
--- a/src/share/classes/com/sun/jndi/ldap/EventSupport.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/com/sun/jndi/ldap/EventSupport.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,8 @@ import java.util.Hashtable; import java.util.Vector; import java.util.EventObject; +import java.util.Iterator; +import java.util.Map; import javax.naming.*; import javax.naming.event.*; @@ -204,31 +206,35 @@ * Removes <tt>l</tt> from all notifiers in this context. */ synchronized void removeNamingListener(NamingListener l) { - if (debug) System.err.println("EventSupport removing listener"); - + if (debug) { + System.err.println("EventSupport removing listener"); + } // Go through list of notifiers, remove 'l' from each. // If 'l' is notifier's only listener, remove notifier too. - for (NamingEventNotifier notifier : notifiers.values()) { + Iterator<NamingEventNotifier> iterator = notifiers.values().iterator(); + while (iterator.hasNext()) { + NamingEventNotifier notifier = iterator.next(); if (notifier != null) { - if (debug) + if (debug) { System.err.println("EventSupport removing listener from notifier"); + } notifier.removeNamingListener(l); if (!notifier.hasNamingListeners()) { - if (debug) + if (debug) { System.err.println("EventSupport stopping notifier"); + } notifier.stop(); - notifiers.remove(notifier.info); + iterator.remove(); } } } - // Remove from list of unsolicited notifier - if (debug) System.err.println("EventSupport removing unsolicited: " + - unsolicited); + if (debug) { + System.err.println("EventSupport removing unsolicited: " + unsolicited); + } if (unsolicited != null) { unsolicited.removeElement(l); } - } synchronized boolean hasUnsolicited() {
--- a/src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java Wed Jan 16 01:02:44 2019 +0000 @@ -39,6 +39,7 @@ import com.sun.jndi.ldap.pool.PoolCleaner; import com.sun.jndi.ldap.pool.Pool; +import sun.misc.InnocuousThread; /** * Contains utilities for managing connection pools of LdapClient. @@ -163,7 +164,17 @@ if (idleTimeout > 0) { // Create cleaner to expire idle connections - new PoolCleaner(idleTimeout, pools).start(); + PrivilegedAction<Void> pa = new PrivilegedAction<Void>() { + public Void run() { + Thread t = InnocuousThread.newSystemThread( + "LDAP PoolCleaner", + new PoolCleaner(idleTimeout, pools)); + assert t.getContextClassLoader() == null; + t.setDaemon(true); + t.start(); + return null; + }}; + AccessController.doPrivileged(pa); } if (debug) {
--- a/src/share/classes/com/sun/jndi/ldap/pool/PoolCleaner.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/com/sun/jndi/ldap/pool/PoolCleaner.java Wed Jan 16 01:02:44 2019 +0000 @@ -30,7 +30,7 @@ * * @author Rosanna Lee */ -final public class PoolCleaner extends Thread { +final public class PoolCleaner implements Runnable { final private Pool[] pools; final private long period; @@ -42,9 +42,9 @@ super(); this.period = period; this.pools = pools.clone(); - setDaemon(true); } + @Override public void run() { long threshold; while (true) {
--- a/src/share/classes/com/sun/tracing/ProviderFactory.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/com/sun/tracing/ProviderFactory.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,3 +1,27 @@ +/* + * Copyright (c) 2008, 2018, 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 com.sun.tracing;
--- a/src/share/classes/java/awt/image/FilteredImageSource.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/java/awt/image/FilteredImageSource.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2018, 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 @@ -171,7 +171,7 @@ * @param ic the consumer for the filtered image * @see ImageConsumer */ - public void startProduction(ImageConsumer ic) { + public synchronized void startProduction(ImageConsumer ic) { if (proxies == null) { proxies = new Hashtable(); } @@ -198,7 +198,7 @@ * * @see ImageConsumer */ - public void requestTopDownLeftRightResend(ImageConsumer ic) { + public synchronized void requestTopDownLeftRightResend(ImageConsumer ic) { if (proxies != null) { ImageFilter imgf = (ImageFilter) proxies.get(ic); if (imgf != null) {
--- a/src/share/classes/java/security/IdentityScope.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/java/security/IdentityScope.java Wed Jan 16 01:02:44 2019 +0000 @@ -88,8 +88,8 @@ try { Class.forName(classname); } catch (ClassNotFoundException e) { - //Security.error("unable to establish a system scope from " + - // classname); + System.err.println("unable to establish a system scope from " + + classname); e.printStackTrace(); } }
--- a/src/share/classes/java/security/Signature.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/java/security/Signature.java Wed Jan 16 01:02:44 2019 +0000 @@ -1051,7 +1051,7 @@ debug.println("Further warnings of this type will " + "be suppressed"); } - new Exception("Call trace").printStackTrace(); + new Exception("Debug call trace").printStackTrace(); } } Exception lastException = null;
--- a/src/share/classes/java/time/temporal/IsoFields.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/java/time/temporal/IsoFields.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, 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 @@ -692,9 +692,8 @@ return (R) temporal.with(WEEK_BASED_YEAR, Math.addExact(temporal.get(WEEK_BASED_YEAR), amount)); case QUARTER_YEARS: - // no overflow (256 is multiple of 4) - return (R) temporal.plus(amount / 256, YEARS) - .plus((amount % 256) * 3, MONTHS); + return (R) temporal.plus(amount / 4, YEARS) + .plus((amount % 4) * 3, MONTHS); default: throw new IllegalStateException("Unreachable"); }
--- a/src/share/classes/java/util/HashMap.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/java/util/HashMap.java Wed Jan 16 01:02:44 2019 +0000 @@ -491,7 +491,7 @@ } /** - * Implements Map.putAll and Map constructor + * Implements Map.putAll and Map constructor. * * @param m the map * @param evict false when initially constructing this map, else @@ -558,7 +558,7 @@ } /** - * Implements Map.get and related methods + * Implements Map.get and related methods. * * @param hash hash for key * @param key the key @@ -613,7 +613,7 @@ } /** - * Implements Map.put and related methods + * Implements Map.put and related methods. * * @param hash hash for key * @param key the key @@ -701,7 +701,7 @@ } threshold = newThr; @SuppressWarnings({"rawtypes","unchecked"}) - Node<K,V>[] newTab = (Node<K,V>[])new Node[newCap]; + Node<K,V>[] newTab = (Node<K,V>[])new Node[newCap]; table = newTab; if (oldTab != null) { for (int j = 0; j < oldCap; ++j) { @@ -801,7 +801,7 @@ } /** - * Implements Map.remove and related methods + * Implements Map.remove and related methods. * * @param hash hash for key * @param key the key @@ -1364,8 +1364,11 @@ } /** - * Reconstitute the {@code HashMap} instance from a stream (i.e., - * deserialize it). + * Reconstitutes this map from a stream (that is, deserializes it). + * @param s the stream + * @throws ClassNotFoundException if the class of a serialized object + * could not be found + * @throws IOException if an I/O error occurs */ private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { @@ -1905,7 +1908,6 @@ /** * Forms tree of the nodes linked from this node. - * @return root of tree */ final void treeify(Node<K,V>[] tab) { TreeNode<K,V> root = null; @@ -2043,8 +2045,11 @@ return; if (root.parent != null) root = root.root(); - if (root == null || root.right == null || - (rl = root.left) == null || rl.left == null) { + if (root == null + || (movable + && (root.right == null + || (rl = root.left) == null + || rl.left == null))) { tab[index] = first.untreeify(map); // too small return; } @@ -2273,7 +2278,7 @@ static <K,V> TreeNode<K,V> balanceDeletion(TreeNode<K,V> root, TreeNode<K,V> x) { - for (TreeNode<K,V> xp, xpl, xpr;;) { + for (TreeNode<K,V> xp, xpl, xpr;;) { if (x == null || x == root) return root; else if ((xp = x.parent) == null) {
--- a/src/share/classes/javax/swing/text/html/ImageView.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/javax/swing/text/html/ImageView.java Wed Jan 16 01:02:44 2019 +0000 @@ -910,11 +910,11 @@ } synchronized(ImageView.this) { - if ((changed & 1) == 1 && (state & WIDTH_FLAG) == 0) { - width = newWidth; + if ((changed & 1) == 1 && (state & HEIGHT_FLAG) == 0) { + height = newHeight; } - if ((changed & 2) == 2 && (state & HEIGHT_FLAG) == 0) { - height = newHeight; + if ((changed & 2) == 2 && (state & WIDTH_FLAG) == 0) { + width = newWidth; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process of
--- a/src/share/classes/sun/awt/ExtendedKeyCodes.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/awt/ExtendedKeyCodes.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2009, 2018, 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.awt; import java.util.Collections;
--- a/src/share/classes/sun/awt/image/BufImgSurfaceData.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/awt/image/BufImgSurfaceData.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, 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 @@ -25,7 +25,6 @@ package sun.awt.image; -import java.awt.Color; import java.awt.Rectangle; import java.awt.GraphicsConfiguration; import java.awt.image.ColorModel; @@ -38,9 +37,6 @@ import sun.java2d.SurfaceData; import sun.java2d.SunGraphics2D; -import sun.java2d.StateTrackable; -import sun.java2d.StateTrackable.*; -import sun.java2d.StateTracker; import sun.java2d.loops.SurfaceType; import sun.java2d.loops.CompositeType; import sun.java2d.loops.RenderLoops; @@ -446,8 +442,6 @@ // their pixels are immediately retrievable anyway. } - private static native void freeNativeICMData(long pData); - /** * Returns destination Image associated with this SurfaceData. */ @@ -471,12 +465,5 @@ private ICMColorData(long pData) { this.pData = pData; } - - public void finalize() { - if (pData != 0L) { - BufImgSurfaceData.freeNativeICMData(pData); - pData = 0L; - } - } } }
--- a/src/share/classes/sun/misc/InnocuousThread.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/misc/InnocuousThread.java Wed Jan 16 01:02:44 2019 +0000 @@ -26,7 +26,10 @@ package sun.misc; import java.security.AccessControlContext; +import java.security.AccessController; import java.security.ProtectionDomain; +import java.security.PrivilegedAction; +import java.util.concurrent.atomic.AtomicInteger; /** * A thread that has no permissions, is not a member of any user-defined @@ -36,18 +39,47 @@ */ public final class InnocuousThread extends Thread { private static final Unsafe UNSAFE; - private static final ThreadGroup THREADGROUP; + private static final long THREAD_LOCALS; + private static final long INHERITABLE_THREAD_LOCALS; + private static final ThreadGroup INNOCUOUSTHREADGROUP; private static final AccessControlContext ACC; - private static final long THREADLOCALS; - private static final long INHERITABLETHREADLOCALS; private static final long INHERITEDACCESSCONTROLCONTEXT; + private static final long CONTEXTCLASSLOADER; + + private static final AtomicInteger threadNumber = new AtomicInteger(1); + private static String newName() { + return "InnocuousThread-" + threadNumber.getAndIncrement(); + } + + /** + * Returns a new InnocuousThread with an auto-generated thread name. + * Its context class loader is set to null. + */ + public static Thread newSystemThread(Runnable target) { + return newSystemThread(newName(), target); + } + + /** + * Returns a new InnocuousThread with null context class loader. + */ + public static Thread newSystemThread(String name, Runnable target) { + return new InnocuousThread(INNOCUOUSTHREADGROUP, + target, name, null); + } public InnocuousThread(Runnable target) { - super(THREADGROUP, target, "anInnocuousThread"); + super(INNOCUOUSTHREADGROUP, target, newName()); UNSAFE.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, ACC); eraseThreadLocals(); } + private InnocuousThread(ThreadGroup group, Runnable target, String name, ClassLoader tccl) { + super(group, target, name, 0L); + UNSAFE.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, ACC); + UNSAFE.putOrderedObject(this, CONTEXTCLASSLOADER, tccl); + eraseThreadLocals(); + } + @Override public ClassLoader getContextClassLoader() { // always report system class loader @@ -79,8 +111,8 @@ * Drops all thread locals (and inherited thread locals). */ public void eraseThreadLocals() { - UNSAFE.putObject(this, THREADLOCALS, null); - UNSAFE.putObject(this, INHERITABLETHREADLOCALS, null); + UNSAFE.putObject(this, THREAD_LOCALS, null); + UNSAFE.putObject(this, INHERITABLE_THREAD_LOCALS, null); } // Use Unsafe to access Thread group and ThreadGroup parent fields @@ -95,12 +127,14 @@ Class<?> tk = Thread.class; Class<?> gk = ThreadGroup.class; - THREADLOCALS = UNSAFE.objectFieldOffset + THREAD_LOCALS = UNSAFE.objectFieldOffset (tk.getDeclaredField("threadLocals")); - INHERITABLETHREADLOCALS = UNSAFE.objectFieldOffset + INHERITABLE_THREAD_LOCALS = UNSAFE.objectFieldOffset (tk.getDeclaredField("inheritableThreadLocals")); INHERITEDACCESSCONTROLCONTEXT = UNSAFE.objectFieldOffset (tk.getDeclaredField("inheritedAccessControlContext")); + CONTEXTCLASSLOADER = UNSAFE.objectFieldOffset + (tk.getDeclaredField("contextClassLoader")); long tg = UNSAFE.objectFieldOffset(tk.getDeclaredField("group")); long gp = UNSAFE.objectFieldOffset(gk.getDeclaredField("parent")); @@ -113,7 +147,14 @@ break; group = parent; } - THREADGROUP = new ThreadGroup(group, "InnocuousThreadGroup"); + final ThreadGroup root = group; + INNOCUOUSTHREADGROUP = AccessController.doPrivileged( + new PrivilegedAction<ThreadGroup>() { + @Override + public ThreadGroup run() { + return new ThreadGroup(root, "InnocuousThreadGroup"); + } + }); } catch (Exception e) { throw new Error(e); }
--- a/src/share/classes/sun/security/jca/ProviderList.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/jca/ProviderList.java Wed Jan 16 01:02:44 2019 +0000 @@ -275,7 +275,7 @@ } if (debug != null) { debug.println("Loading all providers"); - new Exception("Call trace").printStackTrace(); + new Exception("Debug Info. Call trace:").printStackTrace(); } int n = 0; for (int i = 0; i < configs.length; i++) {
--- a/src/share/classes/sun/security/pkcs/PKCS8Key.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/pkcs/PKCS8Key.java Wed Jan 16 01:02:44 2019 +0000 @@ -347,7 +347,6 @@ } } catch (IOException e) { - // e.printStackTrace (); throw new InvalidKeyException("IOException : " + e.getMessage()); }
--- a/src/share/classes/sun/security/provider/AuthPolicyFile.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/provider/AuthPolicyFile.java Wed Jan 16 01:02:44 2019 +0000 @@ -186,6 +186,7 @@ } catch (Exception e) { // ignore, treat it like we have no keystore if (debug != null) { + debug.println("Debug info only. No keystore."); e.printStackTrace(); } return null; @@ -260,7 +261,7 @@ loaded_one = true; } catch (Exception e) { if (debug != null) { - debug.println("error reading policy " + e); + debug.println("Debug info only. Error reading policy " + e); e.printStackTrace(); } // ignore that policy
--- a/src/share/classes/sun/security/provider/DSA.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/provider/DSA.java Wed Jan 16 01:02:44 2019 +0000 @@ -434,18 +434,6 @@ return printable; } - private static void debug(Exception e) { - if (debug) { - e.printStackTrace(); - } - } - - private static void debug(String s) { - if (debug) { - System.err.println(s); - } - } - /** * Standard SHA224withDSA implementation as defined in FIPS186-3. */
--- a/src/share/classes/sun/security/provider/PolicyFile.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/provider/PolicyFile.java Wed Jan 16 01:02:44 2019 +0000 @@ -563,7 +563,8 @@ loaded_policy = true; } catch (Exception e) { if (debug != null) { - debug.println("error reading policy "+e); + debug.println( + "Debug info only. Error reading policy " +e); e.printStackTrace(); } // ignore that policy @@ -616,6 +617,7 @@ } catch (Exception e) { // ignore, treat it like we have no keystore if (debug != null) { + debug.println("Debug info only. Ignoring exception."); e.printStackTrace(); } }
--- a/src/share/classes/sun/security/ssl/SSLContextImpl.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/ssl/SSLContextImpl.java Wed Jan 16 01:02:44 2019 +0000 @@ -53,6 +53,11 @@ private X509TrustManager trustManager; private SecureRandom secureRandom; + private final static Collection<CipherSuite> clientCustomizedCipherSuites = + getCustomizedCipherSuites("jdk.tls.client.cipherSuites"); + private final static Collection<CipherSuite> serverCustomizedCipherSuites = + getCustomizedCipherSuites("jdk.tls.server.cipherSuites"); + SSLContextImpl() { ephemeralKeyManager = new EphemeralKeyManager(); clientCache = new SSLSessionContextImpl(); @@ -279,19 +284,50 @@ } /* - * Return the list of all available CipherSuites with a priority of - * minPriority or above. + * Return the list of all available CipherSuites that are supported + * using currently installed providers. + */ + private static CipherSuiteList getApplicableSupportedCipherSuiteList( + ProtocolList protocols) { + + return getApplicableCipherSuiteList( + CipherSuite.allowedCipherSuites(), + protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY); + } + + /* + * Return the list of all available CipherSuites that are default enabled + * in client or server side. + */ + private static CipherSuiteList getApplicableEnabledCipherSuiteList( + ProtocolList protocols, boolean isClient) { + + if (isClient) { + if (!clientCustomizedCipherSuites.isEmpty()) { + return getApplicableCipherSuiteList( + clientCustomizedCipherSuites, + protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY); + } + } else { + if (!serverCustomizedCipherSuites.isEmpty()) { + return getApplicableCipherSuiteList( + serverCustomizedCipherSuites, + protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY); + } + } + + return getApplicableCipherSuiteList( + CipherSuite.allowedCipherSuites(), + protocols, CipherSuite.DEFAULT_SUITES_PRIORITY); + } + + /* + * Return the list of available CipherSuites which are applicable to + * the specified protocols. */ private static CipherSuiteList getApplicableCipherSuiteList( - ProtocolList protocols, boolean onlyEnabled) { - - int minPriority = CipherSuite.SUPPORTED_SUITES_PRIORITY; - if (onlyEnabled) { - minPriority = CipherSuite.DEFAULT_SUITES_PRIORITY; - } - - Collection<CipherSuite> allowedCipherSuites = - CipherSuite.allowedCipherSuites(); + Collection<CipherSuite> allowedCipherSuites, + ProtocolList protocols, int minPriority) { TreeSet<CipherSuite> suites = new TreeSet<>(); if (!(protocols.collection().isEmpty()) && @@ -335,6 +371,67 @@ return new CipherSuiteList(suites); } + /* + * Get the customized cipher suites specified by the given system property. + */ + private static Collection<CipherSuite> getCustomizedCipherSuites( + String propertyName) { + + String property = AccessController.doPrivileged( + new GetPropertyAction(propertyName)); + if (debug != null && Debug.isOn("sslctx")) { + System.out.println( + "System property " + propertyName + " is set to '" + + property + "'"); + } + if (property != null && property.length() != 0) { + // remove double quote marks from beginning/end of the property + if (property.length() > 1 && property.charAt(0) == '"' && + property.charAt(property.length() - 1) == '"') { + property = property.substring(1, property.length() - 1); + } + } + + if (property != null && property.length() != 0) { + String[] cipherSuiteNames = property.split(","); + Collection<CipherSuite> cipherSuites = + new ArrayList<>(cipherSuiteNames.length); + for (int i = 0; i < cipherSuiteNames.length; i++) { + cipherSuiteNames[i] = cipherSuiteNames[i].trim(); + if (cipherSuiteNames[i].isEmpty()) { + continue; + } + + CipherSuite suite; + try { + suite = CipherSuite.valueOf(cipherSuiteNames[i]); + } catch (IllegalArgumentException iae) { + if (debug != null && Debug.isOn("sslctx")) { + System.out.println( + "Unknown or unsupported cipher suite name: " + + cipherSuiteNames[i]); + } + + continue; + } + + if (suite.isAvailable()) { + cipherSuites.add(suite); + } else { + if (debug != null && Debug.isOn("sslctx")) { + System.out.println( + "The current installed providers do not " + + "support cipher suite: " + cipherSuiteNames[i]); + } + } + } + + return cipherSuites; + } + + return Collections.emptyList(); + } + private static String[] getAvailableProtocols( ProtocolVersion[] protocolCandidates) { @@ -429,10 +526,10 @@ })); } - supportedCipherSuiteList = getApplicableCipherSuiteList( - supportedProtocolList, false); // all supported - serverDefaultCipherSuiteList = getApplicableCipherSuiteList( - serverDefaultProtocolList, true); // enabled only + supportedCipherSuiteList = getApplicableSupportedCipherSuiteList( + supportedProtocolList); + serverDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( + serverDefaultProtocolList, false); } @Override @@ -489,8 +586,8 @@ })); } - clientDefaultCipherSuiteList = getApplicableCipherSuiteList( - clientDefaultProtocolList, true); // enabled only + clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( + clientDefaultProtocolList, true); } @Override @@ -529,8 +626,9 @@ })); } - clientDefaultCipherSuiteList = getApplicableCipherSuiteList( - clientDefaultProtocolList, true); // enabled only + clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( + clientDefaultProtocolList, true); + } @Override @@ -571,8 +669,8 @@ })); } - clientDefaultCipherSuiteList = getApplicableCipherSuiteList( - clientDefaultProtocolList, true); // enabled only + clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList( + clientDefaultProtocolList, true); } @Override @@ -703,8 +801,9 @@ clientDefaultProtocolList = new ProtocolList( getAvailableProtocols(candidates)); - clientDefaultCipherSuiteList = getApplicableCipherSuiteList( - clientDefaultProtocolList, true); // enabled only + clientDefaultCipherSuiteList = + getApplicableEnabledCipherSuiteList( + clientDefaultProtocolList, true); } else { clientDefaultProtocolList = null; // unlikely to be used clientDefaultCipherSuiteList = null; // unlikely to be used
--- a/src/share/classes/sun/security/ssl/SSLEngineImpl.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/ssl/SSLEngineImpl.java Wed Jan 16 01:02:44 2019 +0000 @@ -1927,13 +1927,21 @@ case cs_START: /* - * If we need to change the engine mode and the enabled - * protocols haven't specifically been set by the user, - * change them to the corresponding default ones. + * If we need to change the socket mode and the enabled + * protocols and cipher suites haven't specifically been + * set by the user, change them to the corresponding + * default ones. */ - if (roleIsServer != (!flag) && - sslContext.isDefaultProtocolList(enabledProtocols)) { - enabledProtocols = sslContext.getDefaultProtocolList(!flag); + if (roleIsServer != (!flag)) { + if (sslContext.isDefaultProtocolList(enabledProtocols)) { + enabledProtocols = + sslContext.getDefaultProtocolList(!flag); + } + + if (sslContext.isDefaultCipherSuiteList(enabledCipherSuites)) { + enabledCipherSuites = + sslContext.getDefaultCipherSuiteList(!flag); + } } roleIsServer = !flag;
--- a/src/share/classes/sun/security/ssl/SSLSocketImpl.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/ssl/SSLSocketImpl.java Wed Jan 16 01:02:44 2019 +0000 @@ -2399,13 +2399,22 @@ case cs_START: /* * If we need to change the socket mode and the enabled - * protocols haven't specifically been set by the user, - * change them to the corresponding default ones. + * protocols and cipher suites haven't specifically been + * set by the user, change them to the corresponding + * default ones. */ - if (roleIsServer != (!flag) && - sslContext.isDefaultProtocolList(enabledProtocols)) { - enabledProtocols = sslContext.getDefaultProtocolList(!flag); + if (roleIsServer != (!flag)) { + if (sslContext.isDefaultProtocolList(enabledProtocols)) { + enabledProtocols = + sslContext.getDefaultProtocolList(!flag); + } + + if (sslContext.isDefaultCipherSuiteList(enabledCipherSuites)) { + enabledCipherSuites = + sslContext.getDefaultCipherSuiteList(!flag); + } } + roleIsServer = !flag; break;
--- a/src/share/classes/sun/security/tools/keytool/Main.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/tools/keytool/Main.java Wed Jan 16 01:02:44 2019 +0000 @@ -2213,7 +2213,19 @@ private void doPrintEntries(PrintStream out) throws Exception { - out.println(rb.getString("Keystore.type.") + keyStore.getType()); + // Adjust displayed keystore type if needed. + String keystoreTypeToPrint = keyStore.getType(); + if ("JKS".equalsIgnoreCase(keystoreTypeToPrint)) { + if (ksfile != null && ksfile.exists()) { + String realType = keyStoreType(ksfile); + // If the magic number does not conform to JKS + // then it must be PKCS12 + if (!"JKS".equalsIgnoreCase(realType)) { + keystoreTypeToPrint = P12KEYSTORE; + } + } + } + out.println(rb.getString("Keystore.type.") + keystoreTypeToPrint); out.println(rb.getString("Keystore.provider.") + keyStore.getProvider().getName()); out.println();
--- a/src/share/classes/sun/security/util/AnchorCertificates.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/util/AnchorCertificates.java Wed Jan 16 01:02:44 2019 +0000 @@ -75,8 +75,8 @@ } catch (Exception e) { if (debug != null) { debug.println("Error parsing cacerts"); + e.printStackTrace(); } - e.printStackTrace(); } return null; }
--- a/src/share/classes/sun/security/util/SignatureFileVerifier.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/util/SignatureFileVerifier.java Wed Jan 16 01:02:44 2019 +0000 @@ -380,8 +380,9 @@ if (e.getMessage() != null) { debug.println(key + ": " + e.getMessage()); } else { - debug.println(key + ": " + algorithm + - " was disabled, no exception msg given."); + debug.println("Debug info only. " + key + ": " + + algorithm + + " was disabled, no exception msg given."); e.printStackTrace(); } }
--- a/src/share/classes/sun/security/x509/CertificateExtensions.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/x509/CertificateExtensions.java Wed Jan 16 01:02:44 2019 +0000 @@ -124,7 +124,8 @@ unparseableExtensions.put(ext.getExtensionId().toString(), new UnparseableExtension(ext, e)); if (debug != null) { - debug.println("Error parsing extension: " + ext); + debug.println("Debug info only." + + " Error parsing extension: " + ext); e.printStackTrace(); HexDumpEncoder h = new HexDumpEncoder(); System.err.println(h.encodeBuffer(ext.getExtensionValue()));
--- a/src/share/classes/sun/security/x509/X509Key.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/classes/sun/security/x509/X509Key.java Wed Jan 16 01:02:44 2019 +0000 @@ -393,7 +393,6 @@ throw new InvalidKeyException ("excess key data"); } catch (IOException e) { - // e.printStackTrace (); throw new InvalidKeyException("IOException: " + e.getMessage()); }
--- a/src/share/lib/security/BlacklistedCertsConverter.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/lib/security/BlacklistedCertsConverter.java Wed Jan 16 01:02:44 2019 +0000 @@ -4,7 +4,9 @@ * * 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. + * 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
--- a/src/share/native/sun/awt/image/BufImgSurfaceData.c Wed Jan 09 07:30:53 2019 +0000 +++ b/src/share/native/sun/awt/image/BufImgSurfaceData.c Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, 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 @@ -32,6 +32,7 @@ #include "jni_util.h" /* Define uintptr_t */ #include "gdefs.h" +#include "Disposer.h" /** * This include file contains support code for loops using the @@ -80,19 +81,6 @@ } /* - * Class: sun_java2d_SurfaceData - * Method: freeNativeICMData - * Signature: (Ljava/awt/image/IndexColorModel;)V - */ -JNIEXPORT void JNICALL -Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData - (JNIEnv *env, jclass sd, jlong pData) -{ - ColorData *cdata = (ColorData*)jlong_to_ptr(pData); - freeICMColorData(cdata); -} - -/* * Class: sun_awt_image_BufImgSurfaceData * Method: initOps * Signature: (Ljava/lang/Object;IIIII)V @@ -140,6 +128,15 @@ } /* + * Releases native structures associated with BufImgSurfaceData.ICMColorData. + */ +static void BufImg_Dispose_ICMColorData(JNIEnv *env, jlong pData) +{ + ColorData *cdata = (ColorData*)jlong_to_ptr(pData); + freeICMColorData(cdata); +} + +/* * Method for disposing native BufImgSD */ static void BufImg_Dispose(JNIEnv *env, SurfaceDataOps *ops) @@ -321,6 +318,7 @@ } (*env)->SetObjectField(env, bisdo->icm, colorDataID, colorData); + Disposer_AddRecord(env, colorData, BufImg_Dispose_ICMColorData, pData); } }
--- a/src/solaris/classes/sun/java2d/x11/XSurfaceData.java Wed Jan 09 07:30:53 2019 +0000 +++ b/src/solaris/classes/sun/java2d/x11/XSurfaceData.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2010, 2018, 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.java2d.x11; import java.awt.image.*;
--- a/src/solaris/native/java/net/Inet4AddressImpl.c Wed Jan 09 07:30:53 2019 +0000 +++ b/src/solaris/native/java/net/Inet4AddressImpl.c Wed Jan 16 01:02:44 2019 +0000 @@ -67,38 +67,36 @@ */ JNIEXPORT jstring JNICALL Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { - char hostname[NI_MAXHOST+1]; + char hostname[NI_MAXHOST + 1]; hostname[0] = '\0'; if (gethostname(hostname, NI_MAXHOST)) { - /* Something went wrong, maybe networking is not setup? */ strcpy(hostname, "localhost"); +#if defined(__solaris__) } else { - struct addrinfo hints, *res; - int error; - - memset(&hints, 0, sizeof(hints)); - hints.ai_flags = AI_CANONNAME; - hints.ai_family = AF_UNSPEC; - - error = getaddrinfo(hostname, NULL, &hints, &res); + // try to resolve hostname via nameservice + // if it is known but getnameinfo fails, hostname will still be the + // value from gethostname + struct addrinfo hints, *res; - if (error == 0) { - /* host is known to name service */ - error = getnameinfo(res->ai_addr, - res->ai_addrlen, - hostname, - NI_MAXHOST, - NULL, - 0, - NI_NAMEREQD); + // make sure string is null-terminated + hostname[NI_MAXHOST] = '\0'; + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_CANONNAME; + hints.ai_family = AF_INET; - /* if getnameinfo fails hostname is still the value - from gethostname */ - - freeaddrinfo(res); + if (getaddrinfo(hostname, NULL, &hints, &res) == 0) { + getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST, + NULL, 0, NI_NAMEREQD); + freeaddrinfo(res); } } +#else + } else { + // make sure string is null-terminated + hostname[NI_MAXHOST] = '\0'; + } +#endif return (*env)->NewStringUTF(env, hostname); }
--- a/src/solaris/native/java/net/Inet6AddressImpl.c Wed Jan 09 07:30:53 2019 +0000 +++ b/src/solaris/native/java/net/Inet6AddressImpl.c Wed Jan 16 01:02:44 2019 +0000 @@ -67,53 +67,37 @@ JNIEXPORT jstring JNICALL Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { int ret; - char hostname[NI_MAXHOST+1]; + char hostname[NI_MAXHOST + 1]; hostname[0] = '\0'; ret = gethostname(hostname, NI_MAXHOST); if (ret == -1) { - /* Something went wrong, maybe networking is not setup? */ strcpy(hostname, "localhost"); - } else { - // ensure null-terminated - hostname[NI_MAXHOST] = '\0'; - } - #if defined(__solaris__) && defined(AF_INET6) - if (ret == 0) { - /* Solaris doesn't want to give us a fully qualified domain name. - * We do a reverse lookup to try and get one. This works - * if DNS occurs before NIS in /etc/resolv.conf, but fails - * if NIS comes first (it still gets only a partial name). - * We use thread-safe system calls. - */ - struct addrinfo hints, *res; - int error; + } else { + // try to resolve hostname via nameservice + // if it is known but getnameinfo fails, hostname will still be the + // value from gethostname + struct addrinfo hints, *res; + // make sure string is null-terminated + hostname[NI_MAXHOST] = '\0'; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; hints.ai_family = AF_UNSPEC; - error = getaddrinfo(hostname, NULL, &hints, &res); - - if (error == 0) { - /* host is known to name service */ - error = getnameinfo(res->ai_addr, - res->ai_addrlen, - hostname, - NI_MAXHOST, - NULL, - 0, - NI_NAMEREQD); - - /* if getnameinfo fails hostname is still the value - from gethostname */ - + if (getaddrinfo(hostname, NULL, &hints, &res) == 0) { + getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST, + NULL, 0, NI_NAMEREQD); freeaddrinfo(res); } } +#else + } else { + // make sure string is null-terminated + hostname[NI_MAXHOST] = '\0'; + } #endif - return (*env)->NewStringUTF(env, hostname); }
--- a/src/solaris/native/sun/awt/awt_Robot.c Wed Jan 09 07:30:53 2019 +0000 +++ b/src/solaris/native/sun/awt/awt_Robot.c Wed Jan 16 01:02:44 2019 +0000 @@ -262,8 +262,8 @@ jint sheight = jheight * scale; rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen); - if (isXCompositeDisplay(awt_display, adata->awt_visInfo.screen) && - hasXCompositeOverlayExtension(awt_display)) + if (hasXCompositeOverlayExtension(awt_display) && + isXCompositeDisplay(awt_display, adata->awt_visInfo.screen)) { rootWindow = XCompositeGetOverlayWindow(awt_display, rootWindow); }
--- a/src/windows/bin/java_md.c Wed Jan 09 07:30:53 2019 +0000 +++ b/src/windows/bin/java_md.c Wed Jan 16 01:02:44 2019 +0000 @@ -266,26 +266,17 @@ * assumed to be present in the "JRE path" directory. If it is not found * there (or "JRE path" fails to resolve), skip the explicit load and let * nature take its course, which is likely to be a failure to execute. - * This is clearly completely specific to the exact compiler version - * which isn't very nice, but its hardly the only place. - * No attempt to look for compiler versions in between 2003 and 2010 - * as we aren't supporting building with those. + * The makefiles will provide the correct lib contained in quotes in the + * macro MSVCR_DLL_NAME. */ -#ifdef _MSC_VER -#if _MSC_VER < 1400 -#define CRT_DLL "msvcr71.dll" -#endif -#if _MSC_VER >= 1600 -#define CRT_DLL "msvcr100.dll" -#endif -#ifdef CRT_DLL +#ifdef MSVCR_DLL_NAME if (GetJREPath(crtpath, MAXPATHLEN)) { if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") + - JLI_StrLen(CRT_DLL) >= MAXPATHLEN) { + JLI_StrLen(MSVCR_DLL_NAME) >= MAXPATHLEN) { JLI_ReportErrorMessage(JRE_ERROR11); return JNI_FALSE; } - (void)JLI_StrCat(crtpath, "\\bin\\" CRT_DLL); /* Add crt dll */ + (void)JLI_StrCat(crtpath, "\\bin\\" MSVCR_DLL_NAME); /* Add crt dll */ JLI_TraceLauncher("CRT path is %s\n", crtpath); if (_access(crtpath, 0) == 0) { if (LoadLibrary(crtpath) == 0) { @@ -294,8 +285,24 @@ } } } -#endif /* CRT_DLL */ -#endif /* _MSC_VER */ +#endif /* MSVCR_DLL_NAME */ +#ifdef MSVCP_DLL_NAME + if (GetJREPath(crtpath, MAXPATHLEN)) { + if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") + + JLI_StrLen(MSVCP_DLL_NAME) >= MAXPATHLEN) { + JLI_ReportErrorMessage(JRE_ERROR11); + return JNI_FALSE; + } + (void)JLI_StrCat(crtpath, "\\bin\\" MSVCP_DLL_NAME); /* Add prt dll */ + JLI_TraceLauncher("PRT path is %s\n", crtpath); + if (_access(crtpath, 0) == 0) { + if (LoadLibrary(crtpath) == 0) { + JLI_ReportErrorMessage(DLL_ERROR4, crtpath); + return JNI_FALSE; + } + } + } +#endif /* MSVCP_DLL_NAME */ loaded = 1; } return JNI_TRUE;
--- a/src/windows/classes/sun/awt/windows/fontconfig.properties Wed Jan 09 07:30:53 2019 +0000 +++ b/src/windows/classes/sun/awt/windows/fontconfig.properties Wed Jan 16 01:02:44 2019 +0000 @@ -1,6 +1,6 @@ # # -# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 2018, 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 @@ -243,7 +243,7 @@ # Exclusion Ranges -exclusion.alphabetic=0700-1e9f,1f00-2017,2020-20ab,20ad-f8ff +exclusion.alphabetic=0700-1cff,1d80-1e9f,1f00-2017,2020-20ab,20ad-f8ff exclusion.chinese-gb18030=0390-03d6,2200-22ef,2701-27be exclusion.hebrew=0041-005a,0060-007a,007f-00ff,20ac-20ac
--- a/src/windows/native/sun/bridge/WinAccessBridge.cpp Wed Jan 09 07:30:53 2019 +0000 +++ b/src/windows/native/sun/bridge/WinAccessBridge.cpp Wed Jan 16 01:02:44 2019 +0000 @@ -452,7 +452,7 @@ */ BOOL WinAccessBridge::receiveAQueuedPackage() { - AccessBridgeQueueElement *element; + AccessBridgeQueueElement *element = NULL; PrintDebugString("in WinAccessBridge::receiveAQueuedPackage()"); @@ -464,15 +464,6 @@ QueueReturns result = messageQueue->remove(&element); - PrintDebugString(" 'element->buffer' contains:"); - DEBUG_CODE(PackageType *type = (PackageType *) element->buffer); - DEBUG_CODE(FocusGainedPackageTag *pkg = (FocusGainedPackageTag *) (((char *) element->buffer) + sizeof(PackageType))); - DEBUG_CODE(PrintDebugString(" PackageType = %X", *type)); -#ifdef ACCESSBRIDGE_ARCH_LEGACY // JOBJECT64 is jobject (32 bit pointer) - DEBUG_CODE(PrintDebugString(" EventPackage: vmID = %X, event = %p, source = %p", pkg->vmID, pkg->Event, pkg->AccessibleContextSource)); -#else // JOBJECT64 is jlong (64 bit) - DEBUG_CODE(PrintDebugString(" EventPackage: vmID = %X, event = %016I64X, source = %016I64X", pkg->vmID, pkg->Event, pkg->AccessibleContextSource)); -#endif switch (result) { case cQueueBroken:
--- a/src/windows/native/sun/security/mscapi/security.cpp Wed Jan 09 07:30:53 2019 +0000 +++ b/src/windows/native/sun/security/mscapi/security.cpp Wed Jan 16 01:02:44 2019 +0000 @@ -35,6 +35,7 @@ #include <BaseTsd.h> #include <wincrypt.h> #include <stdio.h> +#include <memory> #define OID_EKU_ANY "2.5.29.37.0" @@ -47,14 +48,27 @@ #define KEYSTORE_EXCEPTION "java/security/KeyStoreException" #define PROVIDER_EXCEPTION "java/security/ProviderException" #define SIGNATURE_EXCEPTION "java/security/SignatureException" +#define OUT_OF_MEMORY_ERROR "java/lang/OutOfMemoryError" extern "C" { /* + * Throws an arbitrary Java exception with the given message. + */ +void ThrowExceptionWithMessage(JNIEnv *env, const char *exceptionName, + const char *szMessage) +{ + jclass exceptionClazz = env->FindClass(exceptionName); + if (exceptionClazz != NULL) { + env->ThrowNew(exceptionClazz, szMessage); + } +} + +/* * Throws an arbitrary Java exception. * The exception message is a Windows system error message. */ -void ThrowException(JNIEnv *env, char *exceptionName, DWORD dwError) +void ThrowException(JNIEnv *env, const char *exceptionName, DWORD dwError) { char szMessage[1024]; szMessage[0] = '\0'; @@ -65,12 +79,22 @@ strcpy(szMessage, "Unknown error"); } - jclass exceptionClazz = env->FindClass(exceptionName); - if (exceptionClazz != NULL) { - env->ThrowNew(exceptionClazz, szMessage); - } + ThrowExceptionWithMessage(env, exceptionName, szMessage); } +/* + * Overloaded 'operator new[]' variant, which will raise Java's + * OutOfMemoryError in the case of a failure. + */ +void* operator new[](std::size_t size, JNIEnv *env) +{ + void* buf = ::operator new[](size, std::nothrow); + if (buf == NULL) { + ThrowExceptionWithMessage(env, OUT_OF_MEMORY_ERROR, + "Native memory allocation failed"); + } + return buf; +} /* * Maps the name of a hash algorithm to an algorithm identifier. @@ -423,7 +447,11 @@ NULL, 0)) > 1) { // Found friendly name - pszNameString = new char[cchNameString]; + pszNameString = new (env) char[cchNameString]; + if (pszNameString == NULL) { + __leave; + } + CertGetNameString(pc, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, pszNameString, cchNameString); @@ -560,7 +588,10 @@ } // Copy hash from Java to native buffer - pHashBuffer = new jbyte[jHashSize]; + pHashBuffer = new (env) jbyte[jHashSize]; + if (pHashBuffer == NULL) { + __leave; + } env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer); // Set hash value in the hash object @@ -598,7 +629,10 @@ __leave; } - pSignedHashBuffer = new jbyte[dwBufLen]; + pSignedHashBuffer = new (env) jbyte[dwBufLen]; + if (pSignedHashBuffer == NULL) { + __leave; + } if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, (BYTE*)pSignedHashBuffer, &dwBufLen) == FALSE) { ThrowException(env, SIGNATURE_EXCEPTION, GetLastError()); @@ -686,9 +720,16 @@ } // Copy hash and signedHash from Java to native buffer - pHashBuffer = new jbyte[jHashSize]; + pHashBuffer = new (env) jbyte[jHashSize]; + if (pHashBuffer == NULL) { + __leave; + } env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer); - pSignedHashBuffer = new jbyte[jSignedHashSize]; + + pSignedHashBuffer = new (env) jbyte[jSignedHashSize]; + if (pSignedHashBuffer == NULL) { + __leave; + } env->GetByteArrayRegion(jSignedHash, 0, jSignedHashSize, pSignedHashBuffer); @@ -901,7 +942,10 @@ } // Copy encoding from Java to native buffer - pbCertEncoding = new jbyte[jCertEncodingSize]; + pbCertEncoding = new (env) jbyte[jCertEncodingSize]; + if (pbCertEncoding == NULL) { + __leave; + } env->GetByteArrayRegion(jCertEncoding, 0, jCertEncodingSize, pbCertEncoding); // Create a certificate context from the encoded cert @@ -914,7 +958,10 @@ // Set the certificate's friendly name int size = env->GetStringLength(jCertAliasName); - pszCertAliasName = new WCHAR[size + 1]; + pszCertAliasName = new (env) WCHAR[size + 1]; + if (pszCertAliasName == NULL) { + __leave; + } jCertAliasChars = env->GetStringChars(jCertAliasName, NULL); memcpy(pszCertAliasName, jCertAliasChars, size * sizeof(WCHAR)); @@ -952,7 +999,10 @@ __leave; } - pszContainerName = new char[dwDataLen]; + pszContainerName = new (env) char[dwDataLen]; + if (pszContainerName == NULL) { + __leave; + } if (! ::CryptGetProvParam( (HCRYPTPROV) hCryptProv, @@ -966,7 +1016,10 @@ } // Convert to a wide char string - pwszContainerName = new WCHAR[dwDataLen]; + pwszContainerName = new (env) WCHAR[dwDataLen]; + if (pwszContainerName == NULL) { + __leave; + } if (mbstowcs(pwszContainerName, pszContainerName, dwDataLen) == 0) { ThrowException(env, KEYSTORE_EXCEPTION, GetLastError()); @@ -989,7 +1042,10 @@ __leave; } - pszProviderName = new char[dwDataLen]; + pszProviderName = new (env) char[dwDataLen]; + if (pszProviderName == NULL) { + __leave; + } if (! ::CryptGetProvParam( (HCRYPTPROV) hCryptProv, @@ -1003,7 +1059,10 @@ } // Convert to a wide char string - pwszProviderName = new WCHAR[dwDataLen]; + pwszProviderName = new (env) WCHAR[dwDataLen]; + if (pwszProviderName == NULL) { + __leave; + } if (mbstowcs(pwszProviderName, pszProviderName, dwDataLen) == 0) { ThrowException(env, KEYSTORE_EXCEPTION, GetLastError()); @@ -1143,7 +1202,10 @@ } // Copy encoding from Java to native buffer - pbCertEncoding = new jbyte[jCertEncodingSize]; + pbCertEncoding = new (env) jbyte[jCertEncodingSize]; + if (pbCertEncoding == NULL) { + __leave; + } env->GetByteArrayRegion(jCertEncoding, 0, jCertEncodingSize, pbCertEncoding); // Create a certificate context from the encoded cert @@ -1166,7 +1228,10 @@ if ((cchNameString = ::CertGetNameString(pTBDCertContext, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, NULL, 0)) > 1) { - pszNameString = new char[cchNameString]; + pszNameString = new (env) char[cchNameString]; + if (pszNameString == NULL) { + __leave; + } ::CertGetNameString(pTBDCertContext, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, pszNameString, @@ -1316,7 +1381,10 @@ continue; // not found } - pszNameString = new char[cchNameString]; + pszNameString = new (env) char[cchNameString]; + if (pszNameString == NULL) { + __leave; + } if (::CertGetNameString(pCertContext, CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, pszNameString, @@ -1492,7 +1560,10 @@ __try { // Copy data from Java buffer to native buffer - pData = new jbyte[dwBufLen]; + pData = new (env) jbyte[dwBufLen]; + if (pData == NULL) { + __leave; + } env->GetByteArrayRegion(jData, 0, dwBufLen, pData); if (doEncrypt == JNI_TRUE) { @@ -1566,7 +1637,10 @@ __leave; } - pbKeyBlob = new BYTE[dwBlobLen]; + pbKeyBlob = new (env) BYTE[dwBlobLen]; + if (pbKeyBlob == NULL) { + __leave; + } // Generate key blob if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, @@ -1620,8 +1694,12 @@ RSAPUBKEY* pRsaPubKey = (RSAPUBKEY *) (keyBlob + sizeof(PUBLICKEYSTRUC)); + int len = sizeof(pRsaPubKey->pubexp); - exponentBytes = new jbyte[len]; + exponentBytes = new (env) jbyte[len]; + if (exponentBytes == NULL) { + __leave; + } // convert from little-endian while copying from blob for (int i = 0, j = len - 1; i < len; i++, j--) { @@ -1672,9 +1750,12 @@ RSAPUBKEY* pRsaPubKey = (RSAPUBKEY *) (keyBlob + sizeof(PUBLICKEYSTRUC)); + int len = pRsaPubKey->bitlen / 8; - - modulusBytes = new jbyte[len]; + modulusBytes = new (env) jbyte[len]; + if (modulusBytes == NULL) { + __leave; + } BYTE * pbModulus = (BYTE *) (keyBlob + sizeof(PUBLICKEYSTRUC) + sizeof(RSAPUBKEY)); @@ -1795,12 +1876,16 @@ (jKeyBitLength / 8); } - jbyte* jBlobBytes = new jbyte[jBlobLength]; + jbyte* jBlobBytes = NULL; jbyte* jBlobElement; jbyteArray jBlob = NULL; jsize jElementLength; __try { + jBlobBytes = new (env) jbyte[jBlobLength]; + if (jBlobBytes == NULL) { + __leave; + } BLOBHEADER *pBlobHeader = (BLOBHEADER *) jBlobBytes; if (bGeneratePrivateKeyBlob) {
--- a/src/windows/native/sun/windows/awt_Component.cpp Wed Jan 09 07:30:53 2019 +0000 +++ b/src/windows/native/sun/windows/awt_Component.cpp Wed Jan 16 01:02:44 2019 +0000 @@ -3821,6 +3821,8 @@ MsgRouting AwtComponent::WmForwardChar(WCHAR character, LPARAM lParam, BOOL synthetic) { + deadKeyActive = FALSE; + // just post WM_CHAR with unicode key value DefWindowProc(WM_CHAR, (WPARAM)character, lParam); return mrConsume;
--- a/src/windows/native/sun/windows/awt_ScrollPane.cpp Wed Jan 09 07:30:53 2019 +0000 +++ b/src/windows/native/sun/windows/awt_ScrollPane.cpp Wed Jan 16 01:02:44 2019 +0000 @@ -196,15 +196,7 @@ // and the page size changes posAfter = GetScrollPos(orient); if (posBefore != posAfter) { - if(max==0 && posAfter==0) { - // Caller used nMin==nMax idiom to hide scrollbar. - // On the new themes (Windows XP, Vista) this would reset - // scroll position to zero ("just inside the range") (6404832). - // - PostScrollEvent(orient, SB_THUMBPOSITION, posBefore); - }else{ - PostScrollEvent(orient, SB_THUMBPOSITION, posAfter); - } + PostScrollEvent(orient, SB_THUMBPOSITION, posAfter); } } @@ -263,8 +255,11 @@ (policy == java_awt_ScrollPane_SCROLLBARS_ALWAYS)); env->DeleteLocalRef(hAdj); } else { - SetScrollInfo(SB_HORZ, 0, 0, + /* Set scroll info to imitate the behaviour and since we don't + need to display it, explicitly don't show the bar */ + SetScrollInfo(SB_HORZ, childWidth - 1, parentWidth, (policy == java_awt_ScrollPane_SCROLLBARS_ALWAYS)); + ::ShowScrollBar(GetHWnd(), SB_HORZ, false); } if (needsVert) { @@ -275,8 +270,11 @@ (policy == java_awt_ScrollPane_SCROLLBARS_ALWAYS)); env->DeleteLocalRef(vAdj); } else { - SetScrollInfo(SB_VERT, 0, 0, + /* Set scroll info to imitate the behaviour and since we don't + need to display it, explicitly don't show the bar */ + SetScrollInfo(SB_VERT, childHeight - 1, parentHeight, (policy == java_awt_ScrollPane_SCROLLBARS_ALWAYS)); + ::ShowScrollBar(GetHWnd(), SB_VERT, false); } env->DeleteLocalRef(target);
--- a/test/ProblemList.txt Wed Jan 09 07:30:53 2019 +0000 +++ b/test/ProblemList.txt Wed Jan 16 01:02:44 2019 +0000 @@ -44,7 +44,7 @@ # generic-all Problems on all platforms # generic-ARCH Where ARCH is one of: sparc, sparcv9, x64, i586, etc. # OSNAME-all Where OSNAME is one of: solaris, linux, windows, macosx, aix -# OSNAME-ARCH Specific on to one OSNAME and ARCH, e.g. solaris-amd64 +# OSNAME-ARCH Specific on to one OSNAME and ARCH, e.g. solaris-x64 # OSNAME-REV Specific on to one OSNAME and REV, e.g. solaris-5.8 # # More than one label is allowed but must be on the same line. @@ -221,7 +221,7 @@ java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java linux-i586 # 8148996 -java/nio/file/WatchService/WithSecurityManager.java linux-i586 +java/nio/file/WatchService/WithSecurityManager.java linux-all # 8173179 java/nio/file/Files/probeContentType/Basic.java solaris-x64 @@ -258,6 +258,9 @@ # 8170248 javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java linux-all +# 8205049 +sun/rmi/transport/tcp/DisableRMIOverHttp/DisableRMIOverHTTPTest.java windows-all + ############################################################################ # jdk_security @@ -283,8 +286,8 @@ # 8151225 sun/security/rsa/SpecTest.java linux-i586 -# 8173182 -sun/security/pkcs11/MessageDigest/TestCloning.java solaris-x64 +# 8043951 +sun/security/pkcs11/MessageDigest/TestCloning.java solaris-all # 8156709 sun/security/provider/SecureRandom/StrongSecureRandom.java macosx-x64 @@ -292,14 +295,25 @@ # 8163498 sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java linux-i586 +# 8203055 # 8129560 -sun/security/pkcs11/rsa/TestKeyPairGenerator.java solaris-all +sun/security/pkcs11/rsa/TestKeyPairGenerator.java linux-all,solaris-all # 8151834 sun/security/mscapi/SmallPrimeExponentP.java windows-i586 -#8176354 +#8176354 sun/security/ssl/com/sun/net/ssl/internal/ssl/X509KeyManager/PreferredKey.java generic-all + +# 8206909 +com/sun/crypto/provider/CICO/PBEFunc/CICOPBEFuncTest.java solaris-sparcv9 + +# 8206911 +javax/xml/crypto/dsig/GenerationTests.java solaris-all + +# 8206912 +sun/security/krb5/auto/ReplayCacheTestProc.java solaris-sparcv9 + ############################################################################ # jdk_sound
--- a/test/TEST.groups Wed Jan 09 07:30:53 2019 +0000 +++ b/test/TEST.groups Wed Jan 16 01:02:44 2019 +0000 @@ -397,6 +397,7 @@ javax/management/mxbean/LeakTest.java \ javax/management/mxbean/MXBeanTest.java \ javax/management/mxbean/PropertyNamesTest.java \ + javax/xml/bind/marshal/8036981/Test.java \ javax/xml/bind/marshal/8134111/UnmarshalTest.java \ javax/xml/ws/8043129 \ jdk/lambda/vm/InterfaceAccessFlagsTest.java \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/jndi/ldap/RemoveNamingListenerTest.java Wed Jan 16 01:02:44 2019 +0000 @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.net.ServerSocket; +import java.net.Socket; +import java.nio.charset.StandardCharsets; +import java.util.ConcurrentModificationException; +import java.util.Hashtable; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.naming.event.EventContext; +import javax.naming.event.NamingEvent; +import javax.naming.event.NamingExceptionEvent; +import javax.naming.event.NamingListener; +import javax.naming.event.ObjectChangeListener; + +/** + * @test + * @bug 8176192 + * @summary Incorrect usage of Iterator in Java 8 In com.sun.jndi.ldap. + * EventSupport.removeNamingListener + * @modules java.naming + * @run main RemoveNamingListenerTest + */ +public class RemoveNamingListenerTest { + + private static volatile Exception exception; + + public static void main(String args[]) throws Exception { + // start the LDAP server + TestLDAPServer server = new TestLDAPServer(); + server.start(); + + // Set up environment for creating initial context + Hashtable<String, Object> env = new Hashtable<>(3); + env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + env.put(Context.PROVIDER_URL, "ldap://localhost:" + server.getPort() + "/o=example"); + env.put("com.sun.jndi.ldap.connect.timeout", "2000"); + EventContext ctx = null; + + try { + ctx = (EventContext) (new InitialContext(env).lookup("")); + String target = "cn=Vyom Tewari"; + + // Create listeners + NamingListener oneListener = new SampleListener(); + NamingListener objListener = new SampleListener(); + NamingListener subListener = new SampleListener(); + + // Register listeners using different scopes + ctx.addNamingListener(target, EventContext.ONELEVEL_SCOPE, oneListener); + ctx.addNamingListener(target, EventContext.OBJECT_SCOPE, objListener); + ctx.addNamingListener(target, EventContext.SUBTREE_SCOPE, subListener); + + //remove a listener in different thread + Thread t = new Thread(new RemoveNamingListener(ctx, subListener)); + t.start(); + t.join(); + + if (exception != null) { + throw exception; + } + System.out.println("Test run OK!!!"); + } finally { + if (ctx != null) { + ctx.close(); + } + server.stopServer(); + } + } + + /** + * Helper thread that removes the naming listener. + */ + static class RemoveNamingListener implements Runnable { + + final EventContext ctx; + final NamingListener listener; + + RemoveNamingListener(EventContext ctx, NamingListener listener) { + this.ctx = ctx; + this.listener = listener; + } + + @Override + public void run() { + try { + ctx.removeNamingListener(listener); + } catch (NamingException | ConcurrentModificationException ex) { + exception = ex; + } + } + } + + static class SampleListener implements ObjectChangeListener { + + @Override + public void objectChanged(NamingEvent ne) { + //do nothing + } + + @Override + public void namingExceptionThrown(NamingExceptionEvent nee) { + //do nothing + } + } +} + +class TestLDAPServer extends Thread { + + private final int LDAP_PORT; + private final ServerSocket serverSocket; + private volatile boolean isRunning; + + TestLDAPServer() throws IOException { + serverSocket = new ServerSocket(0); + isRunning = true; + LDAP_PORT = serverSocket.getLocalPort(); + setDaemon(true); + } + + public int getPort() { + return LDAP_PORT; + } + + public void stopServer() { + isRunning = false; + if (serverSocket != null && !serverSocket.isClosed()) { + try { + // this will cause ServerSocket.accept() to throw SocketException. + serverSocket.close(); + } catch (IOException ignored) { + } + } + } + + @Override + public void run() { + try { + while (isRunning) { + Socket clientSocket = serverSocket.accept(); + Thread handler = new Thread(new LDAPServerHandler(clientSocket)); + handler.setDaemon(true); + handler.start(); + } + } catch (IOException iOException) { + //do not throw exception if server is not running. + if (isRunning) { + throw new RuntimeException(iOException); + } + } finally { + stopServer(); + } + } +} + +class LDAPServerHandler implements Runnable { + + private final Socket clientSocket; + + public LDAPServerHandler(final Socket clientSocket) { + this.clientSocket = clientSocket; + } + + @Override + public void run() { + BufferedInputStream in = null; + PrintWriter out = null; + byte[] bindResponse = {0x30, 0x0C, 0x02, 0x01, 0x01, 0x61, 0x07, 0x0A, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00}; + byte[] searchResponse = {0x30, 0x0C, 0x02, 0x01, 0x02, 0x65, 0x07, 0x0A, 0x01, 0x00, 0x04, 0x00, 0x04, 0x00}; + try { + in = new BufferedInputStream(clientSocket.getInputStream()); + out = new PrintWriter(new OutputStreamWriter( + clientSocket.getOutputStream(), StandardCharsets.UTF_8), true); + while (true) { + + // Read the LDAP BindRequest + while (in.read() != -1) { + in.skip(in.available()); + break; + } + + // Write an LDAP BindResponse + out.write(new String(bindResponse)); + out.flush(); + + // Read the LDAP SearchRequest + while (in.read() != -1) { + in.skip(in.available()); + break; + } + + // Write an LDAP SearchResponse + out.write(new String(searchResponse)); + out.flush(); + } + } catch (IOException iOException) { + throw new RuntimeException(iOException); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ignored) { + } + } + if (out != null) { + out.close(); + } + if (clientSocket != null) { + try { + clientSocket.close(); + } catch (IOException ignored) { + } + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/ScrollPane/ScrollPaneValidateTest.java Wed Jan 16 01:02:44 2019 +0000 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2018, 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 8195738 + * @summary scroll position in ScrollPane is reset after calling validate() + * @run main ScrollPaneValidateTest + */ + +import java.awt.ScrollPane; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.Button; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.AWTException; + +public class ScrollPaneValidateTest extends Frame { + ScrollPane pane; + + public ScrollPaneValidateTest() { + setBounds(300, 300, 300, 300); + pane = new ScrollPane(ScrollPane.SCROLLBARS_NEVER); + add(pane, BorderLayout.NORTH); + pane.add(new InnerPanel()); + } + + public static void main(String[] args) throws AWTException { + Robot robot = new Robot(); + final ScrollPaneValidateTest obj = new ScrollPaneValidateTest(); + obj.setVisible(true); + + // set to some scroll position + obj.pane.setScrollPosition(600, 200); + + // get the newly set position + Point scrollPosition = obj.pane.getScrollPosition(); + + // call validate multiple times + obj.pane.validate(); + robot.delay(1000); + obj.pane.validate(); + robot.delay(1000); + + // compare position after calling the validate function + if(!scrollPosition.equals(obj.pane.getScrollPosition())) { + obj.dispose(); + throw new RuntimeException("Scrolling position is changed in ScrollPane"); + } + + obj.dispose(); + return; + } + + class InnerPanel extends Panel { + public InnerPanel() { + this.setLayout(new GridLayout(2, 4)); + for (int i = 1; i <= 8; i++) { + this.add(new Button("Button" + i)); + } + } + + public Dimension getPreferredSize() { + return new Dimension(980, 200); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/font/PhoneticExtensions/PhoneticExtensionsGlyphTest.java Wed Jan 16 01:02:44 2019 +0000 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018, 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 8202696 + * @summary Verifies if Phonetic extensions are getting displayed. + */ + +import java.awt.Font; +import java.awt.GraphicsEnvironment; +import java.util.Locale; + +public class PhoneticExtensionsGlyphTest { + private static final String[] logicalFonts = {"dialog", "dialoginput", "serif", "sansserif", "monospaced"}; + + private static final String phoneticExtnChars = "\u1D00 \u1D01 \u1D02 \u1D03 \u1D04 \u1D05 \u1D06 \u1D07 \u1D08 \u1D09\n" + +"\u1D0A \u1D0B \u1D0C \u1D0D \u1D0E \u1D0F \u1D10 \u1D11 \u1D12 \u1D13\n" + +"\u1D14 \u1D15 \u1D16 \u1D17 \u1D18 \u1D19 \u1D1A \u1D1B \u1D1C \u1D1D\n" + +"\u1D1E \u1D1F \u1D20 \u1D21 \u1D22 \u1D23 \u1D24 \u1D25 \u1D26 \u1D27\n" + +"\u1D28 \u1D29 \u1D2A \u1D2B \u1D2C \u1D2D \u1D2E \u1D2F \u1D30 \u1D31\n" + +"\u1D32 \u1D33 \u1D34 \u1D35 \u1D36 \u1D37 \u1D38 \u1D39 \u1D3A \u1D3B\n" + +"\u1D3C \u1D3D \u1D3E \u1D3F \u1D40 \u1D41 \u1D42 \u1D43 \u1D44 \u1D45\n" + +"\u1D46 \u1D47 \u1D48 \u1D49 \u1D4A \u1D4B \u1D4C \u1D4D \u1D4E \u1D4F\n" + +"\u1D50 \u1D51 \u1D52 \u1D53 \u1D54 \u1D55 \u1D56 \u1D57 \u1D58 \u1D59\n" + +"\u1D5A \u1D5B \u1D5C \u1D5D \u1D5E \u1D5F \u1D60 \u1D61 \u1D62 \u1D63\n" + +"\u1D64 \u1D65 \u1D66 \u1D67 \u1D68 \u1D69 \u1D6A \u1D6B \u1D6C \u1D6D\n" + +"\u1D6E \u1D6F \u1D70 \u1D71 \u1D72 \u1D73 \u1D74 \u1D75 \u1D76 \u1D77\n" + +"\u1D78 \u1D79 \u1D7A \u1D7B \u1D7C \u1D7D \u1D7E \u1D7F"; + + public static void main(String[] args) throws Exception { + if (!System.getProperty("os.name").startsWith("Win")) { + return; + } + + if(!canDisplayPhoneticChars()) { + throw new RuntimeException("Phonetic extensions failed to display."); + } + } + + private static boolean isLogicalFont(Font f) { + String fontName = f.getFamily().toLowerCase(Locale.ROOT); + for (int i = 0; i < logicalFonts.length; i++) { + if (logicalFonts[i].equals(fontName)) { + return true; + } + } + return false; + } + + private static boolean canDisplayPhoneticChars() { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + Font[] fonts = ge.getAllFonts(); + boolean ret = false; + for (Font font : fonts) { + if (isLogicalFont(font) && font.canDisplayUpTo(phoneticExtnChars) == -1) { + ret = true; + break; + } + } + return ret; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/image/FilteredImageSourceTest.java Wed Jan 16 01:02:44 2019 +0000 @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2017, 2018, 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 8188083 + * @summary The test checks whether applying image filters using + * FilteredImageSource results in a NullPointerException. + * @run main FilteredImageSourceTest + */ +import java.awt.Graphics; +import java.awt.Image; +import java.awt.image.ColorModel; +import java.awt.image.FilteredImageSource; +import java.awt.image.ImageConsumer; +import java.awt.image.ImageFilter; +import java.awt.image.ImageObserver; +import java.awt.image.ImageProducer; +import java.util.Hashtable; + +/* + * An empty image consumer that will be added to the list of consumers + * interested in image data for the filtered image. + */ +class EmptyImageConsumer implements ImageConsumer { + @Override + public void setDimensions(int width, int height) { + } + + @Override + public void setProperties(Hashtable<?, ?> props) { + } + + @Override + public void setColorModel(ColorModel colorModel) { + } + + @Override + public void setHints(int hintFlags) { + } + + @Override + public void setPixels(int x, int y, int width, int height, + ColorModel colorModel, byte[] pixels, + int offset, int scanSize) { + } + + @Override + public void setPixels(int x, int y, int width, int height, + ColorModel colorModel, int[] pixels, + int offset, int scanSize) { + } + + @Override + public void imageComplete(int i) { + } +} + +/* + * An empty image producer whose sole purpose is to provide stub methods + * that will be invoked while preparing filtered image. + */ +class EmptyImageProducer implements ImageProducer { + @Override + public void addConsumer(ImageConsumer imageConsumer) { + } + + @Override + public boolean isConsumer(ImageConsumer imageConsumer) { + return false; + } + + @Override + public void removeConsumer(ImageConsumer imageConsumer) { + } + + @Override + public void startProduction(ImageConsumer imageConsumer) { + } + + @Override + public void requestTopDownLeftRightResend(ImageConsumer imageConsumer) { + } +} + +/* + * Typically, an Image object will contain an ImageProducer that prepares + * image data. FilteredImageSource will be set as image producer for images + * that require image filter applied to image data. + */ +class EmptyFilteredImage extends Image { + ImageFilter filter = null; + ImageProducer producer = null; + + public EmptyFilteredImage(ImageProducer imgSource) { + filter = new ImageFilter(); + producer = new FilteredImageSource(imgSource, filter); + } + + @Override + public int getWidth(ImageObserver observer) { + return 100; + } + + @Override + public int getHeight(ImageObserver observer) { + return 100; + } + + @Override + public ImageProducer getSource() { + return producer; + } + + @Override + public Graphics getGraphics() { + throw new UnsupportedOperationException(); + } + + @Override + public Object getProperty(String name, ImageObserver observer) { + return null; + } +} + +public final class FilteredImageSourceTest { + // Minimum test duration in ms + private static final int TEST_MIN_DURATION = 5000; + + /* + * A throwable object that will hold any exception generated while + * executing methods on FilteredImageSource. The test passes if the + * methods execute without any exception + */ + private static volatile Throwable fail = null; + + public static void main(final String[] args) + throws InterruptedException { + final ImageConsumer ic = new EmptyImageConsumer(); + final ImageProducer ip = new EmptyImageProducer(); + final Image image = new EmptyFilteredImage(ip); + + /* + * Simulate the framework's operations on FilteredImageSource by + * invoking the concerned methods in multiple threads and observe + * whether exceptions are generated. + */ + Thread t1 = new Thread(() -> { + try { + while (true) { + image.getSource().addConsumer(ic); + } + } catch (Throwable t) { + fail = t; + } + }); + t1.setDaemon(true); + + Thread t2 = new Thread(() -> { + try { + while (true) { + image.getSource().removeConsumer(ic); + } + } catch (Throwable t) { + fail = t; + } + }); + t2.setDaemon(true); + + Thread t3 = new Thread(() -> { + try { + while (true) { + image.getSource().startProduction(ic); + } + } catch (Throwable t) { + fail = t; + } + }); + t3.setDaemon(true); + + // Start the threads + t1.start(); + t2.start(); + t3.start(); + + // Wait on one of the threads for a specific duration. + t1.join(TEST_MIN_DURATION); + if (fail != null) { + throw new RuntimeException("Test failed with exception: ", fail); + } + } +}
--- a/test/java/security/Signature/SignatureLength.java Wed Jan 09 07:30:53 2019 +0000 +++ b/test/java/security/Signature/SignatureLength.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,48 +21,82 @@ * questions. */ -import java.security.*; - /* * @test - * @bug 8161571 + * @bug 8161571 8178370 * @summary Reject signatures presented for verification that contain extra * bytes. + * @modules jdk.crypto.ec * @run main SignatureLength */ + +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import java.security.Security; +import java.security.Signature; +import java.security.SignatureException; + public class SignatureLength { public static void main(String[] args) throws Exception { - main0("EC", 256, "SHA256withECDSA", "SunEC"); - main0("RSA", 2048, "SHA256withRSA", "SunRsaSign"); - main0("DSA", 2048, "SHA256withDSA", "SUN"); + for (Provider p0 : Security.getProviders()) { + for (Provider p1 : Security.getProviders()) { + for (Provider p2 : Security.getProviders()) { + // SunMSCAPI signer can only be initialized with + // a key generated with SunMSCAPI + if (!p0.getName().equals("SunMSCAPI") + && p1.getName().equals("SunMSCAPI")) continue; - if (System.getProperty("os.name").equals("SunOS")) { - main0("EC", 256, "SHA256withECDSA", null); - main0("RSA", 2048, "SHA256withRSA", null); + // SunMSCAPI generated key can only be signed + // with SunMSCAPI signer + if (p0.getName().equals("SunMSCAPI") + && !p1.getName().equals("SunMSCAPI")) continue; + + // SunMSCAPI and SunPKCS11 verifiers may return false + // instead of throwing SignatureException + boolean mayNotThrow = p2.getName().equals("SunMSCAPI") + || p2.getName().startsWith("SunPKCS11"); + + main0("EC", 256, "SHA256withECDSA", p0, p1, p2, mayNotThrow); + main0("RSA", 2048, "SHA256withRSA", p0, p1, p2, mayNotThrow); + main0("DSA", 2048, "SHA256withDSA", p0, p1, p2, mayNotThrow); + } + } } } private static void main0(String keyAlgorithm, int keysize, - String signatureAlgorithm, String provider) throws Exception { + String signatureAlgorithm, Provider generatorProvider, + Provider signerProvider, Provider verifierProvider, + boolean mayNotThrow) throws Exception { + + KeyPairGenerator generator; + Signature signer; + Signature verifier; + + try { + generator = KeyPairGenerator.getInstance(keyAlgorithm, + generatorProvider); + signer = Signature.getInstance(signatureAlgorithm, + signerProvider); + verifier = Signature.getInstance(signatureAlgorithm, + verifierProvider); + } catch (NoSuchAlgorithmException nsae) { + // ignore this set of providers + return; + } + byte[] plaintext = "aaa".getBytes("UTF-8"); // Generate - KeyPairGenerator generator = - provider == null ? - (KeyPairGenerator) KeyPairGenerator.getInstance(keyAlgorithm) : - (KeyPairGenerator) KeyPairGenerator.getInstance( - keyAlgorithm, provider); generator.initialize(keysize); System.out.println("Generating " + keyAlgorithm + " keypair using " + generator.getProvider().getName() + " JCE provider"); KeyPair keypair = generator.generateKeyPair(); // Sign - Signature signer = - provider == null ? - Signature.getInstance(signatureAlgorithm) : - Signature.getInstance(signatureAlgorithm, provider); signer.initSign(keypair.getPrivate()); signer.update(plaintext); System.out.println("Signing using " + signer.getProvider().getName() + @@ -80,19 +114,26 @@ badSignature[signature.length + 4] = 0x01; // Verify - Signature verifier = - provider == null ? - Signature.getInstance(signatureAlgorithm) : - Signature.getInstance(signatureAlgorithm, provider); verifier.initVerify(keypair.getPublic()); verifier.update(plaintext); System.out.println("Verifying using " + verifier.getProvider().getName() + " JCE provider"); try { - System.out.println("Valid? " + verifier.verify(badSignature)); - throw new Exception( - "ERROR: expected a SignatureException but none was thrown"); + boolean valid = verifier.verify(badSignature); + System.out.println("Valid? " + valid); + if (mayNotThrow) { + if (valid) { + throw new Exception( + "ERROR: expected a SignatureException but none was thrown" + + " and invalid signature was verified"); + } else { + System.out.println("OK: verification failed as expected"); + } + } else { + throw new Exception( + "ERROR: expected a SignatureException but none was thrown"); + } } catch (SignatureException e) { System.out.println("OK: caught expected exception: " + e); }
--- a/test/java/time/test/java/time/TestLocalDate.java Wed Jan 09 07:30:53 2019 +0000 +++ b/test/java/time/test/java/time/TestLocalDate.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, 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 @@ -67,6 +67,7 @@ import java.time.LocalDate; import java.time.Month; import java.time.temporal.ChronoUnit; +import java.time.temporal.IsoFields; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; @@ -444,4 +445,40 @@ } } + @DataProvider(name="quarterYearsToAdd") + Object[][] provider_quarterYearsToAdd() { + return new Object[][] { + {Long.valueOf(-1000000000)}, + {Long.valueOf(-256)}, + {Long.valueOf(-255)}, + {Long.valueOf(-1)}, + {Long.valueOf(0)}, + {Long.valueOf(1)}, + {Long.valueOf(255)}, + {Long.valueOf(256)}, + {Long.valueOf(1000000000)}, + }; + } + + @Test(dataProvider="quarterYearsToAdd") + public void test_plus_QuarterYears(long quarterYears) { + LocalDate t0 = TEST_2007_07_15 + .plus(quarterYears, IsoFields.QUARTER_YEARS); + LocalDate t1 = TEST_2007_07_15 + .plus(quarterYears, ChronoUnit.MONTHS) + .plus(quarterYears, ChronoUnit.MONTHS) + .plus(quarterYears, ChronoUnit.MONTHS); + assertEquals(t0, t1); + } + + @Test(dataProvider="quarterYearsToAdd") + public void test_minus_QuarterYears(long quarterYears) { + LocalDate t0 = TEST_2007_07_15 + .minus(quarterYears, IsoFields.QUARTER_YEARS); + LocalDate t1 = TEST_2007_07_15 + .minus(quarterYears, ChronoUnit.MONTHS) + .minus(quarterYears, ChronoUnit.MONTHS) + .minus(quarterYears, ChronoUnit.MONTHS); + assertEquals(t0, t1); + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/util/HashMap/Bug8186171Test.java Wed Jan 16 01:02:44 2019 +0000 @@ -0,0 +1,157 @@ +/* + * 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. + */ +import java.util.List; +import java.util.Map; +import java.util.HashMap; +import java.util.Iterator; +import java.util.ArrayList; +import java.util.concurrent.ThreadLocalRandom; + +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +/* + * @test + * @bug 8186171 + * @run testng Bug8186171Test + * @summary Verify the fix for scenario reported in JDK-8186171 + * @author deepak.kejriwal@oracle.com + */ +@Test +public class Bug8186171Test{ + + /** + * Tests and extends the scenario reported in + * https://bugs.openjdk.java.net/browse/JDK-8186171 + * HashMap: Entry.setValue may not work after Iterator.remove() called for previous entries + * Runs 1000 times as it is based on randomization. + */ + @Test(invocationCount = 1000) + static void testBug8186171NonDeterministic() + { + final ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + final Object v1 = rnd.nextBoolean() ? null : 1; + final Object v2 = (rnd.nextBoolean() && v1 != null) ? null : 2; + + /** If true, always lands in first bucket in hash tables. */ + final boolean poorHash = rnd.nextBoolean(); + + class Key implements Comparable<Key> { + final int i; + Key(int i) { this.i = i; } + public int hashCode() { return poorHash ? 0 : super.hashCode(); } + public int compareTo(Key x) { + return Integer.compare(this.i, x.i); + } + } + + // HashMap and ConcurrentHashMap have: + // TREEIFY_THRESHOLD = 8; UNTREEIFY_THRESHOLD = 6; + final int size = rnd.nextInt(1, 25); + + List<Key> keys = new ArrayList<>(); + for (int i = size; i-->0; ) keys.add(new Key(i)); + Key keyToFrob = keys.get(rnd.nextInt(keys.size())); + + Map<Key, Object> m = new HashMap<Key, Object>(); + + for (Key key : keys) m.put(key, v1); + + for (Iterator<Map.Entry<Key, Object>> it = m.entrySet().iterator(); + it.hasNext(); ) { + Map.Entry<Key, Object> entry = it.next(); + if (entry.getKey() == keyToFrob) + entry.setValue(v2); // does this have the expected effect? + else + it.remove(); + } + + assertFalse(m.containsValue(v1)); + assertTrue(m.containsValue(v2)); + assertTrue(m.containsKey(keyToFrob)); + assertEquals(1, m.size()); + } + + + /** + * Tests and extends the scenario reported in + * https://bugs.openjdk.java.net/browse/JDK-8186171 + * HashMap: Entry.setValue may not work after Iterator.remove() called for previous entries + * Runs single time by reproducing exact scenario for issue mentioned in 8186171 + */ + @Test() + static void testBug8186171Deterministic(){ + class Key implements Comparable<Key> + { + final int i; + Key(int i) { this.i = i; } + + @Override + public int hashCode() { return 0; } //Returning same hashcode so that all keys landup to same bucket + + @Override + public int compareTo(Key x){ + if(this.i == x.i){ + return 0; + } + else { + return Integer.compare(this.i, x.i); + } + } + @Override + public String toString() + { + return "Key_" + i; + } + } + + // HashMap have TREEIFY_THRESHOLD = 8; UNTREEIFY_THRESHOLD = 6; + final int size = 11; + List<Key> keys = new ArrayList<>(); + + for (int i = 0; i < size; i++){ + keys.add(new Key(i)); + } + + Key keyToFrob = keys.get(9); + Map<Key, Object> m = new HashMap<Key, Object>(); + for (Key key : keys) m.put(key, null); + + for (Iterator<Map.Entry<Key, Object>> it = m.entrySet().iterator(); it.hasNext(); ){ + Map.Entry<Key, Object> entry = it.next(); + if (entry.getKey() == keyToFrob){ + entry.setValue(2); + } + else{ + it.remove(); + } + } + + assertFalse(m.containsValue(null)); + assertTrue(m.containsValue(2)); + assertTrue(m.containsKey(keyToFrob)); + assertEquals(1, m.size()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JEditorPane/8195095/ImageViewTest.java Wed Jan 16 01:02:44 2019 +0000 @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2018, 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 8195095 + * @summary Tests if Images are scaled correctly in JEditorPane. + * @run main ImageViewTest + */ +import java.awt.Robot; +import java.awt.Point; +import java.awt.Color; +import java.awt.Insets; + +import javax.swing.JEditorPane; +import javax.swing.SwingUtilities; +import javax.swing.JFrame; +import javax.swing.WindowConstants; + +public class ImageViewTest { + + private static final int WIDTH = 200; + private static final int HEIGHT = 200; + private static JFrame f; + + private static JEditorPane editorPane1; + private static JEditorPane editorPane2; + private static JEditorPane editorPane3; + private static JEditorPane editorPane4; + + private static void test(Robot r, JEditorPane editorPane) throws Exception { + + SwingUtilities.invokeAndWait(() -> { + f = new JFrame(); + editorPane.setEditable(false); + f.add(editorPane); + f.setSize(220,240); + f.setLocationRelativeTo(null); + + f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + f.setVisible(true); + }); + + r.waitForIdle(); + r.delay(500); + + SwingUtilities.invokeAndWait(() -> { + Insets insets = editorPane.getInsets(); + Point loc = editorPane.getLocationOnScreen(); + + final Color blue = Color.BLUE; + final int offset = 10; + + Color center = r.getPixelColor(loc.x + insets.left + WIDTH / 2, + loc.y + insets.top + HEIGHT / 2); + Color left = r.getPixelColor(loc.x + insets.left + offset, + loc.y + insets.top + HEIGHT / 2); + Color right = r.getPixelColor(loc.x + insets.left + WIDTH - offset, + loc.y + insets.top + HEIGHT / 2); + Color bottom = r.getPixelColor(loc.x + insets.left + WIDTH / 2, + loc.y + insets.top + HEIGHT - offset); + Color top = r.getPixelColor(loc.x + insets.left + WIDTH / 2, + loc.y + insets.top + offset); + + f.dispose(); + + System.out.println("center color: " + center); + System.out.println("left color: " + left); + System.out.println("right color: " + right); + System.out.println("bottom color: " + bottom); + System.out.println("top color: " + top); + System.out.println(); + + if (!(blue.equals(center) && blue.equals(left) && blue.equals(right) && + blue.equals(top) && blue.equals(bottom))) { + throw new RuntimeException("Test failed: Image not scaled correctly"); + } + }); + + r.waitForIdle(); + } + + public static void main(String[] args) throws Exception { + + final String ABSOLUTE_FILE_PATH = ImageViewTest.class.getResource("circle.png").getPath(); + + System.out.println(ABSOLUTE_FILE_PATH); + + Robot r = new Robot(); + + SwingUtilities.invokeAndWait(() -> { + editorPane1 = new JEditorPane("text/html", + "<img height=\"200\" src=\"file:///" + ABSOLUTE_FILE_PATH + "\""); + + editorPane2 = new JEditorPane("text/html", + "<img width=\"200\" src=\"file:///" + ABSOLUTE_FILE_PATH + "\""); + + editorPane3 = new JEditorPane("text/html", + "<img width=\"200\" height=\"200\" src=\"file:///" + ABSOLUTE_FILE_PATH + "\""); + + editorPane4 = new JEditorPane("text/html", + "<img src=\"file:///" + ABSOLUTE_FILE_PATH + "\""); + + }); + + r.waitForIdle(); + + System.out.println("Test with only height set to 200"); + test(r, editorPane1); + + System.out.println("Test with only width set to 200"); + test(r, editorPane2); + + System.out.println("Test with none of them set"); + test(r, editorPane3); + + System.out.println("Test with both of them set to 200"); + test(r, editorPane4); + + System.out.println("Test Passed."); + } +}
--- a/test/javax/xml/crypto/dsig/SecurityManager/XMLDSigWithSecMgr.java Wed Jan 09 07:30:53 2019 +0000 +++ b/test/javax/xml/crypto/dsig/SecurityManager/XMLDSigWithSecMgr.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2015, 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 @@ -33,8 +33,6 @@ import java.net.*; import java.security.KeyPair; import java.security.KeyPairGenerator; -import java.security.Policy; -import java.security.URIParameter; import java.util.ArrayList; import java.util.Collections; import javax.xml.crypto.dsig.*; @@ -115,10 +113,8 @@ // the policy only grants this test SocketPermission to accept, resolve // and connect to localhost so that it can dereference 2nd reference - URI policyURI = - new File(System.getProperty("test.src", "."), "policy").toURI(); - Policy.setPolicy - (Policy.getInstance("JavaPolicy", new URIParameter(policyURI))); + System.setProperty("java.security.policy", + System.getProperty("test.src", ".") + File.separator + "policy"); System.setSecurityManager(new SecurityManager()); try {
--- a/test/sun/security/ssl/CertPathRestrictions/JSSEServer.java Wed Jan 09 07:30:53 2019 +0000 +++ b/test/sun/security/ssl/CertPathRestrictions/JSSEServer.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -36,8 +36,6 @@ private SSLServerSocket server = null; - private Exception exception = null; - public JSSEServer(SSLContext context, boolean needClientAuth) throws Exception { SSLServerSocketFactory serverFactory = context.getServerSocketFactory(); @@ -47,35 +45,28 @@ System.out.println("Server: port=" + getPort()); } - public void start() { - new Thread(new Runnable() { + public Exception start() { + System.out.println("Server: started"); + Exception exception = null; + try (SSLSocket socket = (SSLSocket) server.accept()) { + System.out.println("Server: accepted connection"); + socket.setSoTimeout(TLSRestrictions.TIMEOUT); + InputStream sslIS = socket.getInputStream(); + OutputStream sslOS = socket.getOutputStream(); + sslIS.read(); + sslOS.write('S'); + sslOS.flush(); + System.out.println("Server: finished"); + } catch (Exception e) { + exception = e; + e.printStackTrace(System.out); + System.out.println("Server: failed"); + } - @Override - public void run() { - try { - System.out.println("Server: started"); - try (SSLSocket socket = (SSLSocket) server.accept()) { - socket.setSoTimeout(TLSRestrictions.TIMEOUT); - InputStream sslIS = socket.getInputStream(); - OutputStream sslOS = socket.getOutputStream(); - sslIS.read(); - sslOS.write('S'); - sslOS.flush(); - System.out.println("Server: finished"); - } - } catch (Exception e) { - e.printStackTrace(System.out); - exception = e; - } - } - }).start(); + return exception; } public int getPort() { return server.getLocalPort(); } - - public Exception getException() { - return exception; - } }
--- a/test/sun/security/ssl/CertPathRestrictions/TLSRestrictions.java Wed Jan 09 07:30:53 2019 +0000 +++ b/test/sun/security/ssl/CertPathRestrictions/TLSRestrictions.java Wed Jan 16 01:02:44 2019 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -36,6 +36,10 @@ import java.security.cert.CertificateFactory; import java.security.spec.PKCS8EncodedKeySpec; import java.util.Base64; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import javax.net.ssl.KeyManagerFactory; @@ -210,58 +214,58 @@ needClientAuth, pass); setConstraint("Server", serverConstraint); - JSSEServer server = new JSSEServer( - createSSLContext(trustNames, certNames), - needClientAuth); - int port = server.getPort(); - server.start(); - - // Run client on another JVM so that its properties cannot be in conflict - // with server's. - OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( - "-Dcert.dir=" + CERT_DIR, - "-Djava.security.debug=certpath", - "-classpath", - TEST_CLASSES, - "JSSEClient", - port + "", - trustNameStr, - certNameStr, - clientConstraint); - int exitValue = outputAnalyzer.getExitValue(); - String clientOut = outputAnalyzer.getOutput(); + ExecutorService executor = Executors.newFixedThreadPool(1); + try { + JSSEServer server = new JSSEServer( + createSSLContext(trustNames, certNames), + needClientAuth); + int port = server.getPort(); + Future<Exception> serverFuture = executor.submit(() -> server.start()); - Exception serverException = server.getException(); - if (serverException != null) { - System.out.println("Server: failed"); - } - - System.out.println("---------- Client output start ----------"); - System.out.println(clientOut); - System.out.println("---------- Client output end ----------"); + // Run client on another JVM so that its properties cannot be in conflict + // with server's. + OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm( + "-Dcert.dir=" + CERT_DIR, + "-Djava.security.debug=certpath", + "-classpath", + TEST_CLASSES, + "JSSEClient", + port + "", + trustNameStr, + certNameStr, + clientConstraint); + int clientExitValue = outputAnalyzer.getExitValue(); + String clientOut = outputAnalyzer.getOutput(); + System.out.println("---------- Client output start ----------"); + System.out.println(clientOut); + System.out.println("---------- Client output end ----------"); - if (serverException instanceof SocketTimeoutException - || clientOut.contains("SocketTimeoutException")) { - System.out.println("The communication gets timeout and skips the test."); - return; - } - - if (pass) { - if (serverException != null || exitValue != 0) { - throw new RuntimeException( - "Unexpected failure. Operation was blocked."); - } - } else { - if (serverException == null && exitValue == 0) { - throw new RuntimeException( - "Unexpected pass. Operation was allowed."); + Exception serverException = serverFuture.get(TIMEOUT, TimeUnit.MILLISECONDS); + if (serverException instanceof SocketTimeoutException + || clientOut.contains("SocketTimeoutException")) { + System.out.println("The communication gets timeout and skips the test."); + return; } - // The test may encounter non-SSL issues, like network problem. - if (!(serverException instanceof SSLHandshakeException - || clientOut.contains("SSLHandshakeException"))) { - throw new RuntimeException("Failure with unexpected exception."); + if (pass) { + if (serverException != null || clientExitValue != 0) { + throw new RuntimeException( + "Unexpected failure. Operation was blocked."); + } + } else { + if (serverException == null && clientExitValue == 0) { + throw new RuntimeException( + "Unexpected pass. Operation was allowed."); + } + + // The test may encounter non-SSL issues, like network problem. + if (!(serverException instanceof SSLHandshakeException + || clientOut.contains("SSLHandshakeException"))) { + throw new RuntimeException("Failure with unexpected exception."); + } } + } finally { + executor.shutdown(); } } @@ -513,7 +517,6 @@ true); break; } - System.out.println("Case passed"); System.out.println("========================================"); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/ssl/SSLContextImpl/CustomizedCipherSuites.java Wed Jan 16 01:02:44 2019 +0000 @@ -0,0 +1,270 @@ +/* + * Copyright (c) 2016, 2018, 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. + */ + +// SunJSSE does not support dynamic system properties, no way to re-use +// system properties in samevm/agentvm mode. + +/* + * @test + * @bug 8162362 8208350 + * @summary Cannot enable previously default enabled cipher suites + * @run main/othervm + * CustomizedCipherSuites Default true + * TLS_RSA_WITH_AES_128_CBC_SHA + * TLS_ECDH_anon_WITH_AES_128_CBC_SHA + * @run main/othervm + * -Djdk.tls.client.cipherSuites="unknown" + * CustomizedCipherSuites Default true + * TLS_RSA_WITH_AES_128_CBC_SHA + * TLS_ECDH_anon_WITH_AES_128_CBC_SHA + * @run main/othervm + * -Djdk.tls.client.cipherSuites="" + * CustomizedCipherSuites Default true + * TLS_RSA_WITH_AES_128_CBC_SHA + * TLS_ECDH_anon_WITH_AES_128_CBC_SHA + * @run main/othervm + * -Djdk.tls.client.cipherSuites="TLS_ECDH_anon_WITH_AES_128_CBC_SHA" + * CustomizedCipherSuites Default true + * TLS_ECDH_anon_WITH_AES_128_CBC_SHA + * TLS_RSA_WITH_AES_128_CBC_SHA + * @run main/othervm + * -Djdk.tls.server.cipherSuites="TLS_ECDH_anon_WITH_AES_128_CBC_SHA" + * CustomizedCipherSuites Default false + * TLS_ECDH_anon_WITH_AES_128_CBC_SHA + * TLS_RSA_WITH_AES_128_CBC_SHA + * @run main/othervm + * -Djdk.tls.client.cipherSuites="TLS_RSA_WITH_AES_128_CBC_SHA,unknown,TLS_ECDH_anon_WITH_AES_128_CBC_SHA" + * CustomizedCipherSuites Default true + * TLS_ECDH_anon_WITH_AES_128_CBC_SHA + * "" + * @run main/othervm + * -Djdk.tls.server.cipherSuites="TLS_RSA_WITH_AES_128_CBC_SHA,unknown,TLS_ECDH_anon_WITH_AES_128_CBC_SHA" + * CustomizedCipherSuites Default false + * TLS_RSA_WITH_AES_128_CBC_SHA + * "" + * @run main/othervm + * -Djdk.tls.server.cipherSuites="TLS_ECDH_anon_WITH_AES_128_CBC_SHA" + * CustomizedCipherSuites Default true + * TLS_RSA_WITH_AES_128_CBC_SHA + * TLS_ECDH_anon_WITH_AES_128_CBC_SHA + * @run main/othervm + * -Djdk.tls.client.cipherSuites="TLS_ECDH_anon_WITH_AES_128_CBC_SHA" + * CustomizedCipherSuites Default false + * TLS_RSA_WITH_AES_128_CBC_SHA + * TLS_ECDH_anon_WITH_AES_128_CBC_SHA + */ + +import javax.net.ssl.*; + +/** + * Test the customized default cipher suites. + * + * This test is based on the behavior that TLS_ECDH_anon_WITH_AES_128_CBC_SHA is + * disabled by default, and TLS_RSA_WITH_AES_128_CBC_SHA is enabled by + * default in JDK. If the behavior is changed in the future, please + * update the test cases above accordingly. + */ +public class CustomizedCipherSuites { + + private static String contextProtocol; + private static boolean isClientMode; + + private static String enabledCipherSuite; + private static String disabledCipherSuite; + + public static void main(String[] args) throws Exception { + + contextProtocol = trimQuotes(args[0]); + isClientMode = Boolean.parseBoolean(args[1]); + enabledCipherSuite = trimQuotes(args[2]); + disabledCipherSuite = trimQuotes(args[3]); + + // + // Create instance of SSLContext with the specified protocol. + // + SSLContext context = SSLContext.getInstance(contextProtocol); + + // Default SSLContext is initialized automatically. + if (!contextProtocol.equals("Default")) { + // Use default TK, KM and random. + context.init((KeyManager[])null, (TrustManager[])null, null); + } + + // SSLContext default parameters is client mode in JDK. + if (isClientMode) { + // + // Check default parameters of the specified SSLContext protocol + // + SSLParameters parameters = context.getDefaultSSLParameters(); + System.out.println("Checking SSLContext default parameters ..."); + checkEnabledCiphers(parameters.getCipherSuites()); + } + + // + // Check supported parameters of the specified SSLContext protocol + // + SSLParameters parameters = context.getSupportedSSLParameters(); + System.out.println("Checking SSLContext suppport parameters ..."); + checkSupportedCiphers(parameters.getCipherSuites()); + + + // + // Check the default cipher suites of SSLEngine. + // + SSLEngine engine = context.createSSLEngine(); + engine.setUseClientMode(isClientMode); + + System.out.println("Checking SSLEngine default cipher suites ..."); + checkEnabledCiphers(engine.getEnabledCipherSuites()); + + // + // Check the supported cipher suites of SSLEngine. + // + System.out.println("Checking SSLEngine supported cipher suites ..."); + checkSupportedCiphers(engine.getSupportedCipherSuites()); + + if (isClientMode) { + SSLSocketFactory factory = context.getSocketFactory(); + // Use an unconnected socket. + try (SSLSocket socket = (SSLSocket)factory.createSocket()) { + // + // Check the default cipher suites of SSLSocket. + // + System.out.println( + "Checking SSLSocket default cipher suites ..."); + checkEnabledCiphers(socket.getEnabledCipherSuites()); + + // + // Check the supported cipher suites of SSLSocket. + // + System.out.println( + "Checking SSLSocket supported cipher suites ..."); + checkSupportedCiphers(socket.getSupportedCipherSuites()); + } + } else { + SSLServerSocketFactory factory = context.getServerSocketFactory(); + // Use an unbound server socket. + try (SSLServerSocket socket = + (SSLServerSocket)factory.createServerSocket()) { + // + // Check the default cipher suites of SSLServerSocket. + // + System.out.println( + "Checking SSLServerSocket default cipher suites ..."); + checkEnabledCiphers(socket.getEnabledCipherSuites()); + + // + // Check the supported cipher suites of SSLServerSocket. + // + System.out.println( + "Checking SSLServerSocket supported cipher suites ..."); + checkSupportedCiphers(socket.getSupportedCipherSuites()); + } + } + + System.out.println("\t... Success"); + } + + private static void checkEnabledCiphers( + String[] ciphers) throws Exception { + + if (ciphers.length == 0) { + throw new Exception("No default cipher suites"); + } + + boolean isMatch = false; + if (enabledCipherSuite.isEmpty()) { + // Don't check if not specify the expected cipher suite. + isMatch = true; + } + + boolean isBroken = false; + for (String cipher : ciphers) { + System.out.println("\tdefault cipher suite " + cipher); + if (!enabledCipherSuite.isEmpty() && + cipher.equals(enabledCipherSuite)) { + isMatch = true; + } + + if (!disabledCipherSuite.isEmpty() && + cipher.equals(disabledCipherSuite)) { + isBroken = true; + } + } + + if (!isMatch) { + throw new Exception( + "Cipher suite " + enabledCipherSuite + " should be enabled"); + } + + if (isBroken) { + throw new Exception( + "Cipher suite " + disabledCipherSuite + " should be disabled"); + } + } + + private static void checkSupportedCiphers( + String[] ciphers) throws Exception { + + if (ciphers.length == 0) { + throw new Exception("No supported cipher suites"); + } + + boolean hasEnabledCipherSuite = enabledCipherSuite.isEmpty(); + boolean hasDisabledCipherSuite = disabledCipherSuite.isEmpty(); + for (String cipher : ciphers) { + System.out.println("\tsupported cipher suite " + cipher); + if (!enabledCipherSuite.isEmpty() && + cipher.equals(enabledCipherSuite)) { + hasEnabledCipherSuite = true; + } + + if (!disabledCipherSuite.isEmpty() && + cipher.equals(disabledCipherSuite)) { + hasDisabledCipherSuite = true; + } + } + + if (!hasEnabledCipherSuite) { + throw new Exception( + "Cipher suite " + enabledCipherSuite + " should be supported"); + } + + if (!hasDisabledCipherSuite) { + throw new Exception( + "Cipher suite " + disabledCipherSuite + " should be supported"); + } + } + + private static String trimQuotes(String candidate) { + if (candidate != null && candidate.length() != 0) { + // Remove double quote marks from beginning/end of the string. + if (candidate.length() > 1 && candidate.charAt(0) == '"' && + candidate.charAt(candidate.length() - 1) == '"') { + return candidate.substring(1, candidate.length() - 1); + } + } + + return candidate; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/tools/keytool/ListPKCS12.java Wed Jan 16 01:02:44 2019 +0000 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018, 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 8193171 + * @summary keytool -list displays "JKS" for a PKCS12 keystore. + * @library /lib/testlibrary + * @run main/othervm ListPKCS12 + */ + +import jdk.testlibrary.SecurityTools; +import jdk.testlibrary.OutputAnalyzer; + +public class ListPKCS12 { + + public static void main(String[] args) throws Throwable { + + kt("-genkey -alias a -dname CN=A -keystore ks" + + " -storetype pkcs12 -storepass changeit") + .shouldHaveExitValue(0); + + kt("-list -keystore ks -storepass changeit") + .shouldNotContain("Keystore type: jks") + .shouldNotContain("Keystore type: JKS") + .shouldContain("Keystore type: PKCS12") + .shouldHaveExitValue(0); + } + + static OutputAnalyzer kt(String arg) throws Exception { + return SecurityTools.keytool(arg); + } +}