diff --git a/jdk/.hgtags b/jdk/.hgtags index db3016620bf..4f2107c4212 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -334,3 +334,4 @@ e8a66c0b05d786a282a7ff1d7eb4989afa30c891 jdk9-b86 0d0a63b325592607974612f9cfb48590975aa2d6 jdk9-b89 b433e4dfb830fea60e5187e4580791b62cc362d2 jdk9-b90 97624df5026a2fb191793697dbd2c604c4d5c66e jdk9-b91 +6a5c99506f44538b879d8635a3979849ed587130 jdk9-b92 diff --git a/jdk/make/gensrc/Gensrc-java.base.gmk b/jdk/make/gensrc/Gensrc-java.base.gmk index 134edea72b0..e176d88ea7e 100644 --- a/jdk/make/gensrc/Gensrc-java.base.gmk +++ b/jdk/make/gensrc/Gensrc-java.base.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -38,15 +38,15 @@ include GensrcExceptions.gmk include GensrcProperties.gmk -$(eval $(call SetupCompileProperties,LIST_RESOURCE_BUNDLE, \ - $(filter %.properties, \ - $(call CacheFind, $(JDK_TOPDIR)/src/java.base/share/classes/sun/launcher/resources)), \ - ListResourceBundle)) +$(eval $(call SetupCompileProperties, LIST_RESOURCE_BUNDLE, \ + SRC_DIRS := $(JDK_TOPDIR)/src/java.base/share/classes/sun/launcher/resources, \ + CLASS := ListResourceBundle, \ +)) -$(eval $(call SetupCompileProperties,SUN_UTIL, \ - $(filter %.properties, \ - $(call CacheFind, $(JDK_TOPDIR)/src/java.base/share/classes/sun/util/resources)), \ - sun.util.resources.LocaleNamesBundle)) +$(eval $(call SetupCompileProperties, SUN_UTIL, \ + SRC_DIRS := $(JDK_TOPDIR)/src/java.base/share/classes/sun/util/resources, \ + CLASS := sun.util.resources.LocaleNamesBundle, \ +)) GENSRC_JAVA_BASE += $(LIST_RESOURCE_BUNDLE) $(SUN_UTIL) diff --git a/jdk/make/gensrc/Gensrc-java.desktop.gmk b/jdk/make/gensrc/Gensrc-java.desktop.gmk index d2269150336..05e93c66e3f 100644 --- a/jdk/make/gensrc/Gensrc-java.desktop.gmk +++ b/jdk/make/gensrc/Gensrc-java.desktop.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -66,11 +66,11 @@ else PROP_SRC_DIRS += $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/resources endif -PROP_SRC_FILES := $(filter-out %cursors.properties, \ - $(filter %.properties, $(call CacheFind, $(PROP_SRC_DIRS)))) - -$(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, \ - $(PROP_SRC_FILES), ListResourceBundle)) +$(eval $(call SetupCompileProperties, COMPILE_PROPERTIES, \ + SRC_DIRS := $(PROP_SRC_DIRS), \ + EXCLUDE := %cursors.properties, \ + CLASS := ListResourceBundle, \ +)) GENSRC_JAVA_DESKTOP += $(COMPILE_PROPERTIES) diff --git a/jdk/make/gensrc/Gensrc-java.logging.gmk b/jdk/make/gensrc/Gensrc-java.logging.gmk index 18ad984f859..ea44f5701a6 100644 --- a/jdk/make/gensrc/Gensrc-java.logging.gmk +++ b/jdk/make/gensrc/Gensrc-java.logging.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 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 @@ -29,10 +29,10 @@ include GensrcCommon.gmk include GensrcProperties.gmk -$(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, \ - $(filter %.properties, \ - $(call CacheFind, $(JDK_TOPDIR)/src/java.logging/share/classes/sun/util/logging/resources)), \ - ListResourceBundle)) +$(eval $(call SetupCompileProperties, COMPILE_PROPERTIES, \ + SRC_DIRS := $(JDK_TOPDIR)/src/java.logging/share/classes/sun/util/logging/resources, \ + CLASS := ListResourceBundle, \ +)) TARGETS += $(COMPILE_PROPERTIES) diff --git a/jdk/make/gensrc/Gensrc-java.management.gmk b/jdk/make/gensrc/Gensrc-java.management.gmk index b0a3751631e..771392466fd 100644 --- a/jdk/make/gensrc/Gensrc-java.management.gmk +++ b/jdk/make/gensrc/Gensrc-java.management.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -32,10 +32,10 @@ $(eval $(call IncludeCustomExtension, jdk, gensrc/Gensrc-java.management.gmk)) include GensrcProperties.gmk -$(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, \ - $(filter %.properties, \ - $(call CacheFind, $(JDK_TOPDIR)/src/java.management/share/classes/sun/management/resources)), \ - ListResourceBundle)) +$(eval $(call SetupCompileProperties, COMPILE_PROPERTIES, \ + SRC_DIRS := $(JDK_TOPDIR)/src/java.management/share/classes/sun/management/resources, \ + CLASS := ListResourceBundle, \ +)) TARGETS += $(COMPILE_PROPERTIES) diff --git a/jdk/make/gensrc/Gensrc-jdk.dev.gmk b/jdk/make/gensrc/Gensrc-jdk.dev.gmk index b8f57aa529e..4316c485883 100644 --- a/jdk/make/gensrc/Gensrc-jdk.dev.gmk +++ b/jdk/make/gensrc/Gensrc-jdk.dev.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 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 @@ -29,11 +29,10 @@ include GensrcCommon.gmk include GensrcProperties.gmk -$(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, \ - $(filter %.properties, \ - $(call CacheFind, \ - $(JDK_TOPDIR)/src/jdk.dev/share/classes/jdk/tools/jimage/resources)), \ - ListResourceBundle)) +$(eval $(call SetupCompileProperties, COMPILE_PROPERTIES, \ + SRC_DIRS := $(JDK_TOPDIR)/src/jdk.dev/share/classes/jdk/tools/jimage/resources, \ + CLASS := ListResourceBundle, \ +)) TARGETS += $(COMPILE_PROPERTIES) diff --git a/jdk/make/gensrc/Gensrc-jdk.jartool.gmk b/jdk/make/gensrc/Gensrc-jdk.jartool.gmk index 0fb8eabc621..8cb04f33f7f 100644 --- a/jdk/make/gensrc/Gensrc-jdk.jartool.gmk +++ b/jdk/make/gensrc/Gensrc-jdk.jartool.gmk @@ -29,11 +29,10 @@ include GensrcCommon.gmk include GensrcProperties.gmk -$(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, \ - $(filter %.properties, \ - $(call CacheFind, \ - $(JDK_TOPDIR)/src/jdk.jartool/share/classes/sun/tools/jar/resources)), \ - ListResourceBundle)) +$(eval $(call SetupCompileProperties, COMPILE_PROPERTIES, \ + SRC_DIRS := $(JDK_TOPDIR)/src/jdk.jartool/share/classes/sun/tools/jar/resources, \ + CLASS := ListResourceBundle, \ +)) TARGETS += $(COMPILE_PROPERTIES) diff --git a/jdk/make/gensrc/Gensrc-jdk.jdi.gmk b/jdk/make/gensrc/Gensrc-jdk.jdi.gmk index 7c36f4e6999..416ec40852b 100644 --- a/jdk/make/gensrc/Gensrc-jdk.jdi.gmk +++ b/jdk/make/gensrc/Gensrc-jdk.jdi.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -34,7 +34,7 @@ HEADER_FILE := $(SUPPORT_OUTPUTDIR)/headers/jdk.jdwp.agent/JDWPCommands.h JAVA_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/com/sun/tools/jdi/JDWP.java # Both the header and java file are created using the same recipe. By declaring -# this rule and adding header file to dependencies for java file, both are +# this rule and adding header file to dependencies for java file, both are # rebuilt if either is missing $(HEADER_FILE): $(JDWP_SPEC_FILE) $(BUILD_TOOLS_JDK) @@ -90,10 +90,10 @@ endif include GensrcProperties.gmk -$(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, \ - $(filter %.properties, \ - $(call CacheFind, $(JDK_TOPDIR)/src/jdk.jdi/share/classes/com/sun/tools/jdi/resources)), \ - ListResourceBundle)) +$(eval $(call SetupCompileProperties, COMPILE_PROPERTIES, \ + SRC_DIRS := $(JDK_TOPDIR)/src/jdk.jdi/share/classes/com/sun/tools/jdi/resources, \ + CLASS := ListResourceBundle, \ +)) GENSRC_JDK_JDI += $(COMPILE_PROPERTIES) diff --git a/jdk/make/gensrc/Gensrc-jdk.localedata.gmk b/jdk/make/gensrc/Gensrc-jdk.localedata.gmk index 5759cb6093d..5bbe512dc18 100644 --- a/jdk/make/gensrc/Gensrc-jdk.localedata.gmk +++ b/jdk/make/gensrc/Gensrc-jdk.localedata.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 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 @@ -35,10 +35,10 @@ include GensrcCLDR.gmk include GensrcProperties.gmk -$(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, \ - $(filter %.properties, \ - $(call CacheFind, $(JDK_TOPDIR)/src/jdk.localedata/share/classes/sun/util/resources)), \ - sun.util.resources.LocaleNamesBundle)) +$(eval $(call SetupCompileProperties, COMPILE_PROPERTIES, \ + SRC_DIRS := $(JDK_TOPDIR)/src/jdk.localedata/share/classes/sun/util/resources, \ + CLASS := sun.util.resources.LocaleNamesBundle, \ +)) # Skip generating zh_HK from zh_TW for this module. GENSRC_JDK_LOCALEDATA += $(filter-out %_zh_HK.java, $(COMPILE_PROPERTIES)) diff --git a/jdk/make/gensrc/GensrcProperties.gmk b/jdk/make/gensrc/GensrcProperties.gmk index 220b8509904..7293a19bbeb 100644 --- a/jdk/make/gensrc/GensrcProperties.gmk +++ b/jdk/make/gensrc/GensrcProperties.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -49,30 +49,40 @@ define SetupCopy-zh_HK endef ################################################################################ -# Creates a rule that runs CompileProperties on a set of properties files. -# Param 1 - Variable to add targets to, must not contain space -# Param 2 - Properties files to process -# Param 3 - The super class for the generated classes -# Param 4 - Module path root, defaults to $(JDK_TOPDIR)/src -define SetupCompileProperties - $1_SRCS := $2 - $1_CLASS := $3 - $1_MODULE_PATH_ROOT := $4 - +# Setup make rules that runs CompileProperties on a set of properties files. +# +# Parameter 1 is the name of the rule. This name is used as variable prefix, +# and the targets generated are listed in a variable by that name. +# +# Remaining parameters are named arguments. These include: +# SRC_DIRS Directories containing properties files to process. +# EXCLUDE Exclude files matching this pattern. +# CLASS The super class for the generated classes. +# MODULE_PATH_ROOT Module path root, defaults to $(JDK_TOPDIR)/src. +SetupCompileProperties = $(NamedParamsMacroTemplate) +define SetupCompilePropertiesBody + # Set default value unless overridden ifeq ($$($1_MODULE_PATH_ROOT), ) $1_MODULE_PATH_ROOT := $(JDK_TOPDIR)/src endif + # Locate all properties files in the given source dirs. + $1_SRC_FILES := $$(filter %.properties, $$(call CacheFind, $$($1_SRC_DIRS))) + + ifneq ($$($1_EXCLUDE), ) + $1_SRC_FILES := $$(filter-out $$($1_EXCLUDE), $$($1_SRC_FILES)) + endif + # Convert .../src//share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties # to .../support/gensrc//com/sun/tools/javac/resources/javac_zh_CN.java - # Strip away prefix and suffix, leaving for example only: + # Strip away prefix and suffix, leaving for example only: # "/share/classes/com/sun/tools/javac/resources/javac_zh_CN" $1_JAVAS := $$(patsubst $$($1_MODULE_PATH_ROOT)/%, \ $(SUPPORT_OUTPUTDIR)/gensrc/%, \ $$(patsubst %.properties, %.java, \ $$(subst /$(OPENJDK_TARGET_OS)/classes,, \ $$(subst /$(OPENJDK_TARGET_OS_TYPE)/classes,, \ - $$(subst /share/classes,, $$($1_SRCS)))))) + $$(subst /share/classes,, $$($1_SRC_FILES)))))) # Generate the package dirs for the to be generated java files. Sort to remove # duplicates. @@ -82,22 +92,22 @@ define SetupCompileProperties # "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle" # suitable to be fed into the CompileProperties command. $1_CMDLINE := $$(subst _SPACE_, $(SPACE), \ - $$(join $$(addprefix -compile_SPACE_, $$($1_SRCS)), \ + $$(join $$(addprefix -compile_SPACE_, $$($1_SRC_FILES)), \ $$(addsuffix _SPACE_$$($1_CLASS), \ $$(addprefix _SPACE_, $$($1_JAVAS))))) - $1_TARGET := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.done + $1_TARGET := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.marker $1_CMDLINE_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.cmdline # Now setup the rule for the generation of the resource bundles. - $$($1_TARGET): $$($1_SRCS) $$($1_JAVAS) $(BUILD_TOOLS_JDK) + $$($1_TARGET): $$($1_SRC_FILES) $$($1_JAVAS) $(BUILD_TOOLS_JDK) $(MKDIR) -p $$(@D) $$($1_DIRS) - $(ECHO) Compiling $$(words $$($1_SRCS)) properties into resource bundles for $(MODULE) + $(ECHO) Compiling $$(words $$($1_SRC_FILES)) properties into resource bundles for $(MODULE) $$(eval $$(call ListPathsSafely, $1_CMDLINE, $$($1_CMDLINE_FILE))) $(TOOL_COMPILEPROPERTIES) -quiet @$$($1_CMDLINE_FILE) $(TOUCH) $$@ - $$($1_JAVAS): $$($1_SRCS) + $$($1_JAVAS): $$($1_SRC_FILES) # Create zh_HK versions of all zh_TW files created above $$(eval $$(call SetupCopy-zh_HK,$1_HK,$$(filter %_zh_TW.java, $$($1_JAVAS)))) diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index ad60e8a8146..21e61c5c679 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -476,7 +476,7 @@ endif ifeq ($(USE_EXTERNAL_LIBJPEG), true) LIBJPEG_LIBS := -ljpeg BUILD_LIBJAVAJPEG_INCLUDE_FILES := \ - imageIOJPEG.c \ + imageioJPEG.c \ jpegdecoder.c BUILD_LIBJAVAJPEG_HEADERS := else diff --git a/jdk/make/src/classes/build/tools/x11wrappergen/WrapperGenerator.java b/jdk/make/src/classes/build/tools/x11wrappergen/WrapperGenerator.java index e3a68c42afb..60888904b89 100644 --- a/jdk/make/src/classes/build/tools/x11wrappergen/WrapperGenerator.java +++ b/jdk/make/src/classes/build/tools/x11wrappergen/WrapperGenerator.java @@ -841,7 +841,7 @@ public class WrapperGenerator { pw.println("// This file is an automatically generated file, please do not edit this file, modify the WrapperGenerator.java file instead !\n" ); pw.println("package "+package_name+";\n"); - pw.println("import sun.misc.*;\n"); + pw.println("import jdk.internal.misc.Unsafe;\n"); pw.println("import sun.util.logging.PlatformLogger;"); String baseClass = stp.getBaseClass(); if (baseClass == null) { @@ -941,7 +941,7 @@ public class WrapperGenerator { pw.println("// This file is an automatically generated file, please do not edit this file, modify the WrapperGenerator.java file instead !\n" ); pw.println("package "+package_name+";\n"); - pw.println("import sun.misc.Unsafe;\n"); + pw.println("import jdk.internal.misc.Unsafe;\n"); pw.println("class " + ft.getName() + " {"); pw.println("\tprivate static Unsafe unsafe = XlibWrapper.unsafe;"); pw.println("\tprivate boolean __executed = false;"); diff --git a/jdk/src/java.base/aix/classes/sun/nio/ch/AixPollPort.java b/jdk/src/java.base/aix/classes/sun/nio/ch/AixPollPort.java index a7a954597e5..9cb294f67f0 100644 --- a/jdk/src/java.base/aix/classes/sun/nio/ch/AixPollPort.java +++ b/jdk/src/java.base/aix/classes/sun/nio/ch/AixPollPort.java @@ -34,7 +34,7 @@ import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * AsynchronousChannelGroup implementation based on the AIX pollset framework. diff --git a/jdk/src/java.base/linux/classes/sun/nio/ch/EPoll.java b/jdk/src/java.base/linux/classes/sun/nio/ch/EPoll.java index bb2b9e5171f..72fe9950621 100644 --- a/jdk/src/java.base/linux/classes/sun/nio/ch/EPoll.java +++ b/jdk/src/java.base/linux/classes/sun/nio/ch/EPoll.java @@ -26,7 +26,7 @@ package sun.nio.ch; import java.io.IOException; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Provides access to the Linux epoll facility. diff --git a/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxDosFileAttributeView.java b/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxDosFileAttributeView.java index 11a40a0e862..dba638e8da9 100644 --- a/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxDosFileAttributeView.java +++ b/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxDosFileAttributeView.java @@ -29,7 +29,7 @@ import java.nio.file.attribute.*; import java.util.Map; import java.util.Set; import java.io.IOException; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static sun.nio.fs.UnixNativeDispatcher.*; import static sun.nio.fs.UnixConstants.*; diff --git a/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxUserDefinedFileAttributeView.java b/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxUserDefinedFileAttributeView.java index d3960b27701..18b880c550f 100644 --- a/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxUserDefinedFileAttributeView.java +++ b/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxUserDefinedFileAttributeView.java @@ -29,7 +29,7 @@ import java.nio.file.*; import java.nio.ByteBuffer; import java.io.IOException; import java.util.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static sun.nio.fs.UnixConstants.*; import static sun.nio.fs.LinuxNativeDispatcher.*; diff --git a/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java b/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java index 19079d72878..02af6a539d6 100644 --- a/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java +++ b/jdk/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java @@ -30,7 +30,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.*; import java.io.IOException; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static sun.nio.fs.UnixNativeDispatcher.*; import static sun.nio.fs.UnixConstants.*; diff --git a/jdk/src/java.base/macosx/classes/sun/nio/ch/KQueue.java b/jdk/src/java.base/macosx/classes/sun/nio/ch/KQueue.java index b98dacdfc53..f2be5339a76 100644 --- a/jdk/src/java.base/macosx/classes/sun/nio/ch/KQueue.java +++ b/jdk/src/java.base/macosx/classes/sun/nio/ch/KQueue.java @@ -26,7 +26,7 @@ package sun.nio.ch; import java.io.IOException; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Provides access to the BSD kqueue facility. diff --git a/jdk/src/java.base/share/classes/java/io/File.java b/jdk/src/java.base/share/classes/java/io/File.java index 63e6d571ed2..6137d0acd29 100644 --- a/jdk/src/java.base/share/classes/java/io/File.java +++ b/jdk/src/java.base/share/classes/java/io/File.java @@ -2184,10 +2184,10 @@ public class File private static final long PATH_OFFSET; private static final long PREFIX_LENGTH_OFFSET; - private static final sun.misc.Unsafe UNSAFE; + private static final jdk.internal.misc.Unsafe UNSAFE; static { try { - sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe(); + jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); PATH_OFFSET = unsafe.objectFieldOffset( File.class.getDeclaredField("path")); PREFIX_LENGTH_OFFSET = unsafe.objectFieldOffset( diff --git a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java index f2bf5f01795..779257e87c0 100644 --- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java +++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java @@ -40,7 +40,7 @@ import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import static java.io.ObjectStreamClass.processQueue; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import sun.reflect.misc.ReflectUtil; /** diff --git a/jdk/src/java.base/share/classes/java/io/ObjectStreamClass.java b/jdk/src/java.base/share/classes/java/io/ObjectStreamClass.java index aa516a15d67..762706c1e88 100644 --- a/jdk/src/java.base/share/classes/java/io/ObjectStreamClass.java +++ b/jdk/src/java.base/share/classes/java/io/ObjectStreamClass.java @@ -48,7 +48,7 @@ import java.util.HashSet; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import sun.reflect.CallerSensitive; import sun.reflect.Reflection; import sun.reflect.ReflectionFactory; diff --git a/jdk/src/java.base/share/classes/java/lang/Class.java b/jdk/src/java.base/share/classes/java/lang/Class.java index fc1e6b9f0f3..77913c3187d 100644 --- a/jdk/src/java.base/share/classes/java/lang/Class.java +++ b/jdk/src/java.base/share/classes/java/lang/Class.java @@ -55,7 +55,7 @@ import java.util.Map; import java.util.HashMap; import java.util.Objects; import java.util.StringJoiner; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import jdk.internal.HotSpotIntrinsicCandidate; import sun.reflect.CallerSensitive; import sun.reflect.ConstantPool; diff --git a/jdk/src/java.base/share/classes/java/lang/Process.java b/jdk/src/java.base/share/classes/java/lang/Process.java index e5077f9dcc0..b537bb416d3 100644 --- a/jdk/src/java.base/share/classes/java/lang/Process.java +++ b/jdk/src/java.base/share/classes/java/lang/Process.java @@ -83,7 +83,7 @@ import java.util.stream.Stream; * {@link #getPid() process id}, * {@link #info() information about the process}, * {@link #children() direct children}, and - * {@link #allChildren() direct and indirect children} of the process. + * {@link #descendants() direct children plus descendants of those children} of the process. * Delegating to the underlying Process or ProcessHandle is typically * easiest and most efficient. * @@ -351,7 +351,7 @@ public abstract class Process { * The {@link java.util.concurrent.CompletableFuture} provides the ability * to trigger dependent functions or actions that may be run synchronously * or asynchronously upon process termination. - * When the process terminates the CompletableFuture is + * When the process has terminated the CompletableFuture is * {@link java.util.concurrent.CompletableFuture#complete completed} regardless * of the exit status of the process. *

@@ -362,9 +362,6 @@ public abstract class Process { * {@link java.util.concurrent.CompletableFuture#cancel(boolean) Cancelling} * the CompletableFuture does not affect the Process. *

- * If the process is {@link #isAlive not alive} the {@link CompletableFuture} - * returned has been {@link java.util.concurrent.CompletableFuture#complete completed}. - *

* Processes returned from {@link ProcessBuilder#start} override the * default implementation to provide an efficient mechanism to wait * for process exit. @@ -406,6 +403,9 @@ public abstract class Process { * return delegate.onExit().thenApply(p -> this); * } * } + * @apiNote + * The process may be observed to have terminated with {@link #isAlive} + * before the ComputableFuture is completed and dependent actions are invoked. * * @return a new {@code CompletableFuture} for the Process * @@ -464,7 +464,7 @@ public abstract class Process { * {@link java.lang.UnsupportedOperationException} and performs no other action. * Subclasses should override this method to provide a ProcessHandle for the * process. The methods {@link #getPid}, {@link #info}, {@link #children}, - * and {@link #allChildren}, unless overridden, operate on the ProcessHandle. + * and {@link #descendants}, unless overridden, operate on the ProcessHandle. * * @return Returns a ProcessHandle for the Process * @throws UnsupportedOperationException if the Process implementation @@ -481,9 +481,8 @@ public abstract class Process { /** * Returns a snapshot of information about the process. * - *

An {@link ProcessHandle.Info} instance has various accessor methods - * that return information about the process, if the process is alive and - * the information is available, otherwise {@code null} is returned. + *

A {@link ProcessHandle.Info} instance has accessor methods + * that return information about the process if it is available. * * @implSpec * This implementation returns information about the process as: @@ -524,9 +523,9 @@ public abstract class Process { } /** - * Returns a snapshot of the direct and indirect children of the process. - * An indirect child is one whose parent is either a direct child or - * another indirect child. + * Returns a snapshot of the descendants of the process. + * The descendants of a process are the children of the process + * plus the descendants of those children, recursively. * Typically, a process that is {@link #isAlive not alive} has no children. *

* Note that processes are created and terminate asynchronously. @@ -535,18 +534,18 @@ public abstract class Process { * * @implSpec * This implementation returns all children as: - * {@link #toHandle toHandle().allChildren()}. + * {@link #toHandle toHandle().descendants()}. * - * @return a sequential Stream of ProcessHandles for processes that are - * direct and indirect children of the process + * @return a sequential Stream of ProcessHandles for processes that + * are descendants of the process * @throws UnsupportedOperationException if the Process implementation * does not support this operation * @throws SecurityException if a security manager has been installed and * it denies RuntimePermission("manageProcess") * @since 1.9 */ - public Stream allChildren() { - return toHandle().allChildren(); + public Stream descendants() { + return toHandle().descendants(); } diff --git a/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java b/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java index 95d77fe68ca..a7e650fee04 100644 --- a/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/ProcessHandle.java @@ -54,7 +54,7 @@ import java.util.stream.Stream; * Each ProcessHandle identifies and allows control of a process in the native * system. ProcessHandles are returned from the factory methods {@link #current()}, * {@link #of(long)}, - * {@link #children}, {@link #allChildren}, {@link #parent()} and + * {@link #children}, {@link #descendants}, {@link #parent()} and * {@link #allProcesses()}. *

* The {@link Process} instances created by {@link ProcessBuilder} can be queried @@ -164,21 +164,21 @@ public interface ProcessHandle extends Comparable { Stream children(); /** - * Returns a snapshot of the current direct and indirect children of the process. - * An indirect child is one whose parent is either a direct child or - * another indirect child. + * Returns a snapshot of the descendants of the process. + * The descendants of a process are the children of the process + * plus the descendants of those children, recursively. * Typically, a process that is {@link #isAlive not alive} has no children. *

* Note that processes are created and terminate asynchronously. * There is no guarantee that a process is {@link #isAlive alive}. * * - * @return a sequential Stream of ProcessHandles for processes that are - * direct and indirect children of the process + * @return a sequential Stream of ProcessHandles for processes that + * are descendants of the process * @throws SecurityException if a security manager has been installed and * it denies RuntimePermission("manageProcess") */ - Stream allChildren(); + Stream descendants(); /** * Returns a snapshot of all processes visible to the current process. @@ -201,9 +201,8 @@ public interface ProcessHandle extends Comparable { /** * Returns a snapshot of information about the process. * - *

An {@code Info} instance has various accessor methods that return - * information about the process, if the process is alive and the - * information is available. + *

A {@link ProcessHandle.Info} instance has accessor methods that return + * information about the process if it is available. * * @return a snapshot of information about the process, always non-null */ @@ -288,7 +287,7 @@ public interface ProcessHandle extends Comparable { * The {@link java.util.concurrent.CompletableFuture} provides the ability * to trigger dependent functions or actions that may be run synchronously * or asynchronously upon process termination. - * When the process terminates the CompletableFuture is + * When the process has terminated the CompletableFuture is * {@link java.util.concurrent.CompletableFuture#complete completed} regardless * of the exit status of the process. * The {@code onExit} method can be called multiple times to invoke @@ -300,9 +299,9 @@ public interface ProcessHandle extends Comparable { * {@link java.util.concurrent.Future#get() wait} for it to terminate. * {@link java.util.concurrent.Future#cancel(boolean) Cancelling} * the CompleteableFuture does not affect the Process. - *

- * If the process is {@link #isAlive not alive} the {@link CompletableFuture} - * returned has been {@link java.util.concurrent.CompletableFuture#complete completed}. + * @apiNote + * The process may be observed to have terminated with {@link #isAlive} + * before the ComputableFuture is completed and dependent actions are invoked. * * @return a new {@code CompletableFuture} for the ProcessHandle * diff --git a/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java index b3d03683e4a..92b175b0957 100644 --- a/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/ProcessHandleImpl.java @@ -389,7 +389,7 @@ final class ProcessHandleImpl implements ProcessHandle { } @Override - public Stream allChildren() { + public Stream descendants() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("manageProcess")); diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java index b8f9c52d19f..f385d95c4c9 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java @@ -34,14 +34,16 @@ import java.lang.invoke.LambdaForm.NamedFunction; import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.Field; import java.util.Arrays; -import java.util.HashMap; +import java.util.function.Function; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentHashMap; +import jdk.internal.org.objectweb.asm.FieldVisitor; import sun.invoke.util.ValueConversions; import sun.invoke.util.Wrapper; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.MethodVisitor; -import jdk.internal.org.objectweb.asm.Type; /** * The flavor of method handle which emulates an invoke instruction @@ -217,7 +219,7 @@ import jdk.internal.org.objectweb.asm.Type; /*non-public*/ int fieldCount() { return 1; } - /*non-public*/ static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("L", Species_L.class); + /*non-public*/ static final SpeciesData SPECIES_DATA = new SpeciesData("L", Species_L.class); /*non-public*/ static BoundMethodHandle make(MethodType mt, LambdaForm lf, Object argL0) { return new Species_L(mt, lf, argL0); } @@ -335,7 +337,7 @@ import jdk.internal.org.objectweb.asm.Type; static final SpeciesData EMPTY = new SpeciesData("", BoundMethodHandle.class); - private SpeciesData(String types, Class clazz) { + SpeciesData(String types, Class clazz) { this.typeChars = types; this.typeCodes = basicTypes(types); this.clazz = clazz; @@ -355,26 +357,14 @@ import jdk.internal.org.objectweb.asm.Type; assert(!INIT_DONE); if (constructor() == null) { String types = typeChars; + CACHE.put(types, this); Factory.makeCtors(clazz, types, this.constructor); Factory.makeGetters(clazz, types, this.getters); Factory.makeNominalGetters(types, this.nominalGetters, this.getters); } } - private SpeciesData(String typeChars) { - // Placeholder only. - this.typeChars = typeChars; - this.typeCodes = basicTypes(typeChars); - this.clazz = null; - this.constructor = null; - this.getters = null; - this.nominalGetters = null; - this.extensions = null; - } - private boolean isPlaceholder() { return clazz == null; } - - private static final HashMap CACHE = new HashMap<>(); - static { CACHE.put("", EMPTY); } // make bootstrap predictable + private static final ConcurrentMap CACHE = new ConcurrentHashMap<>(); private static final boolean INIT_DONE; // set after finishes... SpeciesData extendWith(byte type) { @@ -390,62 +380,52 @@ import jdk.internal.org.objectweb.asm.Type; } private static SpeciesData get(String types) { - // Acquire cache lock for query. - SpeciesData d = lookupCache(types); - if (!d.isPlaceholder()) - return d; - synchronized (d) { - // Use synch. on the placeholder to prevent multiple instantiation of one species. - // Creating this class forces a recursive call to getForClass. - if (lookupCache(types).isPlaceholder()) - Factory.generateConcreteBMHClass(types); - } - // Reacquire cache lock. - d = lookupCache(types); - // Class loading must have upgraded the cache. - assert(d != null && !d.isPlaceholder()); - return d; - } - static SpeciesData getForClass(String types, Class clazz) { - // clazz is a new class which is initializing its SPECIES_DATA field - return updateCache(types, new SpeciesData(types, clazz)); - } - private static synchronized SpeciesData lookupCache(String types) { - SpeciesData d = CACHE.get(types); - if (d != null) return d; - d = new SpeciesData(types); - assert(d.isPlaceholder()); - CACHE.put(types, d); - return d; - } - private static synchronized SpeciesData updateCache(String types, SpeciesData d) { - SpeciesData d2; - assert((d2 = CACHE.get(types)) == null || d2.isPlaceholder()); - assert(!d.isPlaceholder()); - CACHE.put(types, d); - return d; + return CACHE.computeIfAbsent(types, new Function() { + @Override + public SpeciesData apply(String types) { + Class bmhcl = Factory.getConcreteBMHClass(types); + // SpeciesData instantiation may throw VirtualMachineError because of + // code cache overflow... + SpeciesData speciesData = new SpeciesData(types, bmhcl); + // CHM.computeIfAbsent ensures only one SpeciesData will be set + // successfully on the concrete BMH class if ever + Factory.setSpeciesDataToConcreteBMHClass(bmhcl, speciesData); + // the concrete BMH class is published via SpeciesData instance + // returned here only after it's SPECIES_DATA field is set + return speciesData; + } + }); } - static { - // pre-fill the BMH speciesdata cache with BMH's inner classes - final Class rootCls = BoundMethodHandle.class; + /** + * This is to be called when assertions are enabled. It checks whether SpeciesData for all of the statically + * defined species subclasses of BoundMethodHandle has been added to the SpeciesData cache. See below in the + * static initializer for + */ + static boolean speciesDataCachePopulated() { + Class rootCls = BoundMethodHandle.class; try { for (Class c : rootCls.getDeclaredClasses()) { if (rootCls.isAssignableFrom(c)) { final Class cbmh = c.asSubclass(BoundMethodHandle.class); - SpeciesData d = Factory.speciesDataFromConcreteBMHClass(cbmh); + SpeciesData d = Factory.getSpeciesDataFromConcreteBMHClass(cbmh); assert(d != null) : cbmh.getName(); assert(d.clazz == cbmh); - assert(d == lookupCache(d.typeChars)); + assert(CACHE.get(d.typeChars) == d); } } } catch (Throwable e) { throw newInternalError(e); } + return true; + } - for (SpeciesData d : CACHE.values()) { - d.initForBootstrap(); - } + static { + // Pre-fill the BMH species-data cache with EMPTY and all BMH's inner subclasses. + EMPTY.initForBootstrap(); + Species_L.SPECIES_DATA.initForBootstrap(); + // check that all static SpeciesData instances have been initialized + assert speciesDataCachePopulated(); // Note: Do not simplify this, because INIT_DONE must not be // a compile-time constant during bootstrapping. INIT_DONE = Boolean.TRUE; @@ -479,6 +459,7 @@ import jdk.internal.org.objectweb.asm.Type; static final String BMH_SIG = "L"+BMH+";"; static final String SPECIES_DATA = "java/lang/invoke/BoundMethodHandle$SpeciesData"; static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";"; + static final String STABLE_SIG = "Ljava/lang/invoke/Stable;"; static final String SPECIES_PREFIX_NAME = "Species_"; static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME; @@ -493,6 +474,26 @@ import jdk.internal.org.objectweb.asm.Type; static final String[] E_THROWABLE = new String[] { "java/lang/Throwable" }; + static final ConcurrentMap> CLASS_CACHE = new ConcurrentHashMap<>(); + + /** + * Get a concrete subclass of BMH for a given combination of bound types. + * + * @param types the type signature, wherein reference types are erased to 'L' + * @return the concrete BMH class + */ + static Class getConcreteBMHClass(String types) { + // CHM.computeIfAbsent ensures generateConcreteBMHClass is called + // only once per key. + return CLASS_CACHE.computeIfAbsent( + types, new Function>() { + @Override + public Class apply(String types) { + return generateConcreteBMHClass(types); + } + }); + } + /** * Generate a concrete subclass of BMH for a given combination of bound types. * @@ -529,7 +530,7 @@ import jdk.internal.org.objectweb.asm.Type; * } * final SpeciesData speciesData() { return SPECIES_DATA; } * final int fieldCount() { return 3; } - * static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("LLI", Species_LLI.class); + * @Stable static SpeciesData SPECIES_DATA; // injected afterwards * static BoundMethodHandle make(MethodType mt, LambdaForm lf, Object argL0, Object argL1, int argI2) { * return new Species_LLI(mt, lf, argL0, argL1, argI2); * } @@ -568,7 +569,9 @@ import jdk.internal.org.objectweb.asm.Type; cw.visitSource(sourceFile, null); // emit static types and SPECIES_DATA fields - cw.visitField(NOT_ACC_PUBLIC + ACC_STATIC, "SPECIES_DATA", SPECIES_DATA_SIG, null, null).visitEnd(); + FieldVisitor fw = cw.visitField(NOT_ACC_PUBLIC + ACC_STATIC, "SPECIES_DATA", SPECIES_DATA_SIG, null, null); + fw.visitAnnotation(STABLE_SIG, true); + fw.visitEnd(); // emit bound argument fields for (int i = 0; i < types.length(); ++i) { @@ -694,17 +697,6 @@ import jdk.internal.org.objectweb.asm.Type; mv.visitEnd(); } - // emit class initializer - mv = cw.visitMethod(NOT_ACC_PUBLIC | ACC_STATIC, "", VOID_SIG, null, null); - mv.visitCode(); - mv.visitLdcInsn(types); - mv.visitLdcInsn(Type.getObjectType(className)); - mv.visitMethodInsn(INVOKESTATIC, SPECIES_DATA, "getForClass", BMHSPECIES_DATA_GFC_SIG, false); - mv.visitFieldInsn(PUTSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG); - mv.visitInsn(RETURN); - mv.visitMaxs(0, 0); - mv.visitEnd(); - cw.visitEnd(); // load class @@ -715,7 +707,6 @@ import jdk.internal.org.objectweb.asm.Type; UNSAFE.defineClass(className, classFile, 0, classFile.length, BoundMethodHandle.class.getClassLoader(), null) .asSubclass(BoundMethodHandle.class); - UNSAFE.ensureClassInitialized(bmhClass); return bmhClass; } @@ -785,7 +776,7 @@ import jdk.internal.org.objectweb.asm.Type; // Auxiliary methods. // - static SpeciesData speciesDataFromConcreteBMHClass(Class cbmh) { + static SpeciesData getSpeciesDataFromConcreteBMHClass(Class cbmh) { try { Field F_SPECIES_DATA = cbmh.getDeclaredField("SPECIES_DATA"); return (SpeciesData) F_SPECIES_DATA.get(null); @@ -794,6 +785,16 @@ import jdk.internal.org.objectweb.asm.Type; } } + static void setSpeciesDataToConcreteBMHClass(Class cbmh, SpeciesData speciesData) { + try { + Field F_SPECIES_DATA = cbmh.getDeclaredField("SPECIES_DATA"); + assert F_SPECIES_DATA.getDeclaredAnnotation(Stable.class) != null; + F_SPECIES_DATA.set(null, speciesData); + } catch (ReflectiveOperationException ex) { + throw newInternalError(ex); + } + } + /** * Field names in concrete BMHs adhere to this pattern: * arg + type + index diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java index c70b9db3097..3c9e141461f 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java @@ -25,7 +25,7 @@ package java.lang.invoke; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.reflect.Method; import java.util.Arrays; import sun.invoke.util.VerifyAccess; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java index 5f821977c0f..9a43947d34e 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java @@ -27,7 +27,7 @@ package java.lang.invoke; import jdk.internal.org.objectweb.asm.*; import sun.invoke.util.BytecodeDescriptor; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import sun.security.action.GetPropertyAction; import java.io.FilePermission; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index bcfa877fbf1..dda16ad9eda 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -775,7 +775,7 @@ class InvokerBytecodeGenerator { // Sample classes from each package we are willing to bind to statically: java.lang.Object.class, java.util.Arrays.class, - sun.misc.Unsafe.class + jdk.internal.misc.Unsafe.class //MethodHandle.class already covered }; diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java index 1f60038e121..5f9580e17f4 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java @@ -694,8 +694,11 @@ import java.util.Objects; @Override public int hashCode() { - return Objects.hash(clazz, getReferenceKind(), name, getType()); + // Avoid autoboxing getReferenceKind(), since this is used early and will force + // early initialization of Byte$ByteCache + return Objects.hash(clazz, new Byte(getReferenceKind()), name, getType()); } + @Override public boolean equals(Object that) { return (that instanceof MemberName && this.equals((MemberName)that)); diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java index 29bd6dbf512..f983b2d792a 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java @@ -50,7 +50,7 @@ class MethodHandleNatives { static native int getMembers(Class defc, String matchName, String matchSig, int matchFlags, Class caller, int skip, MemberName[] results); - /// Field layout queries parallel to sun.misc.Unsafe: + /// Field layout queries parallel to jdk.internal.misc.Unsafe: static native long objectFieldOffset(MemberName self); // e.g., returns vmindex static native long staticFieldOffset(MemberName self); // e.g., returns vmindex static native Object staticFieldBase(MemberName self); // e.g., returns clazz diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java index aae6053acf2..c449f4cb591 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java @@ -27,7 +27,7 @@ package java.lang.invoke; import java.security.AccessController; import java.security.PrivilegedAction; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * This class consists exclusively of static names internal to the diff --git a/jdk/src/java.base/share/classes/java/math/BigDecimal.java b/jdk/src/java.base/share/classes/java/math/BigDecimal.java index 7214950c489..a126e9339f1 100644 --- a/jdk/src/java.base/share/classes/java/math/BigDecimal.java +++ b/jdk/src/java.base/share/classes/java/math/BigDecimal.java @@ -3726,12 +3726,12 @@ public class BigDecimal extends Number implements Comparable { } private static class UnsafeHolder { - private static final sun.misc.Unsafe unsafe; + private static final jdk.internal.misc.Unsafe unsafe; private static final long intCompactOffset; private static final long intValOffset; static { try { - unsafe = sun.misc.Unsafe.getUnsafe(); + unsafe = jdk.internal.misc.Unsafe.getUnsafe(); intCompactOffset = unsafe.objectFieldOffset (BigDecimal.class.getDeclaredField("intCompact")); intValOffset = unsafe.objectFieldOffset diff --git a/jdk/src/java.base/share/classes/java/math/BigInteger.java b/jdk/src/java.base/share/classes/java/math/BigInteger.java index 80330c8c4e4..4471de71198 100644 --- a/jdk/src/java.base/share/classes/java/math/BigInteger.java +++ b/jdk/src/java.base/share/classes/java/math/BigInteger.java @@ -4526,12 +4526,12 @@ public class BigInteger extends Number implements Comparable { // Support for resetting final fields while deserializing private static class UnsafeHolder { - private static final sun.misc.Unsafe unsafe; + private static final jdk.internal.misc.Unsafe unsafe; private static final long signumOffset; private static final long magOffset; static { try { - unsafe = sun.misc.Unsafe.getUnsafe(); + unsafe = jdk.internal.misc.Unsafe.getUnsafe(); signumOffset = unsafe.objectFieldOffset (BigInteger.class.getDeclaredField("signum")); magOffset = unsafe.objectFieldOffset diff --git a/jdk/src/java.base/share/classes/java/net/Inet6Address.java b/jdk/src/java.base/share/classes/java/net/Inet6Address.java index e51064fbd31..0daac2f2b03 100644 --- a/jdk/src/java.base/share/classes/java/net/Inet6Address.java +++ b/jdk/src/java.base/share/classes/java/net/Inet6Address.java @@ -576,11 +576,11 @@ class Inet6Address extends InetAddress { }; private static final long FIELDS_OFFSET; - private static final sun.misc.Unsafe UNSAFE; + private static final jdk.internal.misc.Unsafe UNSAFE; static { try { - sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe(); + jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); FIELDS_OFFSET = unsafe.objectFieldOffset( Inet6Address.class.getDeclaredField("holder6")); UNSAFE = unsafe; diff --git a/jdk/src/java.base/share/classes/java/net/InetAddress.java b/jdk/src/java.base/share/classes/java/net/InetAddress.java index a2d89b25d31..0878c57848b 100644 --- a/jdk/src/java.base/share/classes/java/net/InetAddress.java +++ b/jdk/src/java.base/share/classes/java/net/InetAddress.java @@ -29,6 +29,7 @@ import java.util.NavigableSet; import java.util.Iterator; import java.util.List; import java.util.ArrayList; +import java.util.Objects; import java.util.ServiceLoader; import java.security.AccessController; import java.io.ObjectStreamException; @@ -733,7 +734,7 @@ class InetAddress implements java.io.Serializable { */ public String toString() { String hostName = holder().getHostName(); - return ((hostName != null) ? hostName : "") + return Objects.toString(hostName, "") + "/" + getHostAddress(); } @@ -1493,11 +1494,11 @@ class InetAddress implements java.io.Serializable { } private static final long FIELDS_OFFSET; - private static final sun.misc.Unsafe UNSAFE; + private static final jdk.internal.misc.Unsafe UNSAFE; static { try { - sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe(); + jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); FIELDS_OFFSET = unsafe.objectFieldOffset( InetAddress.class.getDeclaredField("holder") ); diff --git a/jdk/src/java.base/share/classes/java/net/InetSocketAddress.java b/jdk/src/java.base/share/classes/java/net/InetSocketAddress.java index 2bdfdc25102..8e2a2fc925c 100644 --- a/jdk/src/java.base/share/classes/java/net/InetSocketAddress.java +++ b/jdk/src/java.base/share/classes/java/net/InetSocketAddress.java @@ -303,10 +303,10 @@ public class InetSocketAddress } private static final long FIELDS_OFFSET; - private static final sun.misc.Unsafe UNSAFE; + private static final jdk.internal.misc.Unsafe UNSAFE; static { try { - sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe(); + jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); FIELDS_OFFSET = unsafe.objectFieldOffset( InetSocketAddress.class.getDeclaredField("holder")); UNSAFE = unsafe; diff --git a/jdk/src/java.base/share/classes/java/net/SocketOptions.java b/jdk/src/java.base/share/classes/java/net/SocketOptions.java index 82e98e99064..c846bbb9b12 100644 --- a/jdk/src/java.base/share/classes/java/net/SocketOptions.java +++ b/jdk/src/java.base/share/classes/java/net/SocketOptions.java @@ -61,21 +61,21 @@ public interface SocketOptions { * If the requested option is binary, it can be set using this method by * a java.lang.Boolean: *

-     * s.setOption(TCP_NODELAY, new Boolean(true));
+     * s.setOption(TCP_NODELAY, Boolean.TRUE);
      *    // OK - enables TCP_NODELAY, a binary option
      * 
*
- * Any option can be disabled using this method with a Boolean(false): + * Any option can be disabled using this method with a Boolean.FALSE: *
-     * s.setOption(TCP_NODELAY, new Boolean(false));
+     * s.setOption(TCP_NODELAY, Boolean.FALSE);
      *    // OK - disables TCP_NODELAY
-     * s.setOption(SO_LINGER, new Boolean(false));
+     * s.setOption(SO_LINGER, Boolean.FALSE);
      *    // OK - disables SO_LINGER
      * 
*
* For an option that has a notion of on and off, and requires * a non-boolean parameter, setting its value to anything other than - * Boolean(false) implicitly enables it. + * Boolean.FALSE implicitly enables it. *
* Throws SocketException if the option is unrecognized, * the socket is closed, or some low-level error occurred @@ -91,8 +91,8 @@ public interface SocketOptions { /** * Fetch the value of an option. - * Binary options will return java.lang.Boolean(true) - * if enabled, java.lang.Boolean(false) if disabled, e.g.: + * Binary options will return java.lang.Boolean.TRUE + * if enabled, java.lang.Boolean.FALSE if disabled, e.g.: *
      * SocketImpl s;
      * ...
@@ -105,13 +105,13 @@ public interface SocketOptions {
      * 

* For options that take a particular type as a parameter, * getOption(int) will return the parameter's value, else - * it will return java.lang.Boolean(false): + * it will return java.lang.Boolean.FALSE: *

      * Object o = s.getOption(SO_LINGER);
      * if (o instanceof Integer) {
      *     System.out.print("Linger time is " + ((Integer)o).intValue());
      * } else {
-     *   // the true type of o is java.lang.Boolean(false);
+     *   // the true type of o is java.lang.Boolean.FALSE;
      * }
      * 
* diff --git a/jdk/src/java.base/share/classes/java/net/URLConnection.java b/jdk/src/java.base/share/classes/java/net/URLConnection.java index bdc37963d6c..544107828b9 100644 --- a/jdk/src/java.base/share/classes/java/net/URLConnection.java +++ b/jdk/src/java.base/share/classes/java/net/URLConnection.java @@ -32,6 +32,7 @@ import java.security.PrivilegedAction; import java.util.Hashtable; import java.util.Date; import java.util.Iterator; +import java.util.Objects; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; import java.util.StringTokenizer; @@ -1250,7 +1251,7 @@ public abstract class URLConnection { if (handler != null) { ContentHandler h = handlers.putIfAbsent(contentType, handler); - return h != null ? h : handler; + return Objects.requireNonNullElse(h, handler); } try { @@ -1263,7 +1264,7 @@ public abstract class URLConnection { assert handler != null; ContentHandler h = handlers.putIfAbsent(contentType, handler); - return h != null ? h : handler; + return Objects.requireNonNullElse(h, handler); } /* diff --git a/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java b/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java index 953a78b8206..a9c6005d28c 100644 --- a/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java +++ b/jdk/src/java.base/share/classes/java/nio/MappedByteBuffer.java @@ -26,7 +26,7 @@ package java.nio; import java.io.FileDescriptor; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** diff --git a/jdk/src/java.base/share/classes/java/nio/charset/Charset.java b/jdk/src/java.base/share/classes/java/nio/charset/Charset.java index 6766cb53c3d..498ed365213 100644 --- a/jdk/src/java.base/share/classes/java/nio/charset/Charset.java +++ b/jdk/src/java.base/share/classes/java/nio/charset/Charset.java @@ -37,6 +37,7 @@ import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Objects; import java.util.Set; import java.util.ServiceLoader; import java.util.ServiceConfigurationError; @@ -625,6 +626,7 @@ public abstract class Charset private final String name; // tickles a bug in oldjavac private final String[] aliases; // tickles a bug in oldjavac + private final String[] zeroAliases = new String[0]; private Set aliasSet = null; /** @@ -642,7 +644,7 @@ public abstract class Charset */ protected Charset(String canonicalName, String[] aliases) { checkName(canonicalName); - String[] as = (aliases == null) ? new String[0] : aliases; + String[] as = Objects.requireNonNullElse(aliases, zeroAliases); for (int i = 0; i < as.length; i++) checkName(as[i]); this.name = canonicalName; diff --git a/jdk/src/java.base/share/classes/java/security/SecureRandom.java b/jdk/src/java.base/share/classes/java/security/SecureRandom.java index 2f8d734ac00..a2a246f4a14 100644 --- a/jdk/src/java.base/share/classes/java/security/SecureRandom.java +++ b/jdk/src/java.base/share/classes/java/security/SecureRandom.java @@ -419,7 +419,7 @@ public class SecureRandom extends java.util.Random { * @since 1.5 */ public String getAlgorithm() { - return (algorithm != null) ? algorithm : "unknown"; + return Objects.toString(algorithm, "unknown"); } /** diff --git a/jdk/src/java.base/share/classes/java/time/Duration.java b/jdk/src/java.base/share/classes/java/time/Duration.java index d5a49956e90..9bf25ba8c27 100644 --- a/jdk/src/java.base/share/classes/java/time/Duration.java +++ b/jdk/src/java.base/share/classes/java/time/Duration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -359,8 +359,8 @@ public final class Duration * there must be at least one section after the "T". * The number part of each section must consist of one or more ASCII digits. * The number may be prefixed by the ASCII negative or positive symbol. - * The number of days, hours and minutes must parse to an {@code long}. - * The number of seconds must parse to an {@code long} with optional fraction. + * The number of days, hours and minutes must parse to a {@code long}. + * The number of seconds must parse to a {@code long} with optional fraction. * The decimal point may be either a dot or a comma. * The fractional part may have from zero to 9 digits. *

@@ -374,9 +374,9 @@ public final class Duration * "PT10H" -- parses as "10 hours" (where an hour is 3600 seconds) * "P2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds) * "P2DT3H4M" -- parses as "2 days, 3 hours and 4 minutes" - * "P-6H3M" -- parses as "-6 hours and +3 minutes" - * "-P6H3M" -- parses as "-6 hours and -3 minutes" - * "-P-6H+3M" -- parses as "+6 hours and -3 minutes" + * "PT-6H3M" -- parses as "-6 hours and +3 minutes" + * "-PT6H3M" -- parses as "-6 hours and -3 minutes" + * "-PT-6H+3M" -- parses as "+6 hours and -3 minutes" *

* * @param text the text to parse, not null @@ -402,7 +402,8 @@ public final class Duration long hoursAsSecs = parseNumber(text, hourStart, hourEnd, SECONDS_PER_HOUR, "hours"); long minsAsSecs = parseNumber(text, minuteStart, minuteEnd, SECONDS_PER_MINUTE, "minutes"); long seconds = parseNumber(text, secondStart, secondEnd, 1, "seconds"); - int nanos = parseFraction(text, fractionStart, fractionEnd, seconds < 0 ? -1 : 1); + boolean negativeSecs = secondStart >= 0 && text.charAt(secondStart) == '-'; + int nanos = parseFraction(text, fractionStart, fractionEnd, negativeSecs ? -1 : 1); try { return create(negate, daysAsSecs, hoursAsSecs, minsAsSecs, seconds, nanos); } catch (ArithmeticException ex) { diff --git a/jdk/src/java.base/share/classes/java/time/ZoneId.java b/jdk/src/java.base/share/classes/java/time/ZoneId.java index dd282d4a4c4..bae99f601cc 100644 --- a/jdk/src/java.base/share/classes/java/time/ZoneId.java +++ b/jdk/src/java.base/share/classes/java/time/ZoneId.java @@ -310,8 +310,7 @@ public abstract class ZoneId implements Serializable { public static ZoneId of(String zoneId, Map aliasMap) { Objects.requireNonNull(zoneId, "zoneId"); Objects.requireNonNull(aliasMap, "aliasMap"); - String id = aliasMap.get(zoneId); - id = (id != null ? id : zoneId); + String id = Objects.requireNonNullElse(aliasMap.get(zoneId), zoneId); return of(id); } diff --git a/jdk/src/java.base/share/classes/java/time/chrono/Chronology.java b/jdk/src/java.base/share/classes/java/time/chrono/Chronology.java index fbcdcec3472..5783f93ddf1 100644 --- a/jdk/src/java.base/share/classes/java/time/chrono/Chronology.java +++ b/jdk/src/java.base/share/classes/java/time/chrono/Chronology.java @@ -177,7 +177,7 @@ public interface Chronology extends Comparable { static Chronology from(TemporalAccessor temporal) { Objects.requireNonNull(temporal, "temporal"); Chronology obj = temporal.query(TemporalQueries.chronology()); - return (obj != null ? obj : IsoChronology.INSTANCE); + return Objects.requireNonNullElse(obj, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- diff --git a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java index 90c6108c244..441ac711110 100644 --- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java +++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java @@ -2892,7 +2892,8 @@ public final class DateTimeFormatterBuilder { @Override public String toString() { - return "ReducedValue(" + field + "," + minWidth + "," + maxWidth + "," + (baseDate != null ? baseDate : baseValue) + ")"; + return "ReducedValue(" + field + "," + minWidth + "," + maxWidth + + "," + Objects.requireNonNullElse(baseDate, baseValue) + ")"; } } @@ -3851,6 +3852,10 @@ public final class DateTimeFormatterBuilder { return parseOffsetBased(context, text, position, position + 2, OffsetIdPrinterParser.INSTANCE_ID_ZERO); } else if (context.charEquals(nextChar, 'G') && length >= position + 3 && context.charEquals(nextNextChar, 'M') && context.charEquals(text.charAt(position + 2), 'T')) { + if (length >= position + 4 && context.charEquals(text.charAt(position + 3), '0')) { + context.setParsed(ZoneId.of("GMT0")); + return position + 4; + } return parseOffsetBased(context, text, position, position + 3, OffsetIdPrinterParser.INSTANCE_ID_ZERO); } } @@ -4328,7 +4333,7 @@ public final class DateTimeFormatterBuilder { private String getChronologyName(Chronology chrono, Locale locale) { String key = "calendarname." + chrono.getCalendarType(); String name = DateTimeTextProvider.getLocalizedResource(key, locale); - return name != null ? name : chrono.getId(); + return Objects.requireNonNullElseGet(name, () -> chrono.getId()); } } diff --git a/jdk/src/java.base/share/classes/java/time/format/DateTimePrintContext.java b/jdk/src/java.base/share/classes/java/time/format/DateTimePrintContext.java index 543a317e92e..310f6598fc9 100644 --- a/jdk/src/java.base/share/classes/java/time/format/DateTimePrintContext.java +++ b/jdk/src/java.base/share/classes/java/time/format/DateTimePrintContext.java @@ -146,7 +146,7 @@ final class DateTimePrintContext { if (overrideZone != null) { // if have zone and instant, calculation is simple, defaulting chrono if necessary if (temporal.isSupported(INSTANT_SECONDS)) { - Chronology chrono = (effectiveChrono != null ? effectiveChrono : IsoChronology.INSTANCE); + Chronology chrono = Objects.requireNonNullElse(effectiveChrono, IsoChronology.INSTANCE); return chrono.zonedDateTime(Instant.from(temporal), overrideZone); } // block changing zone on OffsetTime, and similar problem cases diff --git a/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java b/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java index 76528c4e7dd..73ebdf40abf 100644 --- a/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java +++ b/jdk/src/java.base/share/classes/java/time/temporal/IsoFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -102,7 +102,7 @@ import sun.util.locale.provider.LocaleResources; * The complete date is expressed using three fields: *
    *
  • {@link #DAY_OF_QUARTER DAY_OF_QUARTER} - the day within the quarter, from 1 to 90, 91 or 92 - *
  • {@link #QUARTER_OF_YEAR QUARTER_OF_YEAR} - the week within the week-based-year + *
  • {@link #QUARTER_OF_YEAR QUARTER_OF_YEAR} - the quarter within the year, from 1 to 4 *
  • {@link ChronoField#YEAR YEAR} - the standard ISO year *
* @@ -571,9 +571,6 @@ public final class IsoFields { //------------------------------------------------------------------------- private static final int[] QUARTER_DAYS = {0, 90, 181, 273, 0, 91, 182, 274}; - private static boolean isIso(TemporalAccessor temporal) { - return Chronology.from(temporal).equals(IsoChronology.INSTANCE); - } private static void ensureIso(TemporalAccessor temporal) { if (isIso(temporal) == false) { @@ -681,7 +678,7 @@ public final class IsoFields { @Override public boolean isSupportedBy(Temporal temporal) { - return temporal.isSupported(EPOCH_DAY); + return temporal.isSupported(EPOCH_DAY) && isIso(temporal); } @SuppressWarnings("unchecked") @@ -721,4 +718,8 @@ public final class IsoFields { return name; } } + + static boolean isIso(TemporalAccessor temporal) { + return Chronology.from(temporal).equals(IsoChronology.INSTANCE); + } } diff --git a/jdk/src/java.base/share/classes/java/util/Collections.java b/jdk/src/java.base/share/classes/java/util/Collections.java index fec21c29079..5dcc7e8c6b0 100644 --- a/jdk/src/java.base/share/classes/java/util/Collections.java +++ b/jdk/src/java.base/share/classes/java/util/Collections.java @@ -2090,7 +2090,8 @@ public class Collections { * through the returned set.

* * It is imperative that the user manually synchronize on the returned - * set when iterating over it: + * collection when traversing it via {@link Iterator}, {@link Spliterator} + * or {@link Stream}: *

      *  Set s = Collections.synchronizedSet(new HashSet());
      *      ...
@@ -2149,8 +2150,9 @@ public class Collections {
      * through the returned sorted set (or its views).

* * It is imperative that the user manually synchronize on the returned - * sorted set when iterating over it or any of its {@code subSet}, - * {@code headSet}, or {@code tailSet} views. + * sorted set when traversing it or any of its {@code subSet}, + * {@code headSet}, or {@code tailSet} views via {@link Iterator}, + * {@link Spliterator} or {@link Stream}: *

      *  SortedSet s = Collections.synchronizedSortedSet(new TreeSet());
      *      ...
@@ -2240,8 +2242,9 @@ public class Collections {
      * accomplished through the returned navigable set (or its views).

* * It is imperative that the user manually synchronize on the returned - * navigable set when iterating over it or any of its {@code subSet}, - * {@code headSet}, or {@code tailSet} views. + * navigable set when traversing it, or any of its {@code subSet}, + * {@code headSet}, or {@code tailSet} views, via {@link Iterator}, + * {@link Spliterator} or {@link Stream}: *

      *  NavigableSet s = Collections.synchronizedNavigableSet(new TreeSet());
      *      ...
@@ -2355,7 +2358,8 @@ public class Collections {
      * through the returned list.

* * It is imperative that the user manually synchronize on the returned - * list when iterating over it: + * list when traversing it via {@link Iterator}, {@link Spliterator} + * or {@link Stream}: *

      *  List list = Collections.synchronizedList(new ArrayList());
      *      ...
@@ -2523,7 +2527,8 @@ public class Collections {
      * through the returned map.

* * It is imperative that the user manually synchronize on the returned - * map when iterating over any of its collection views: + * map when traversing any of its collection views via {@link Iterator}, + * {@link Spliterator} or {@link Stream}: *

      *  Map m = Collections.synchronizedMap(new HashMap());
      *      ...
@@ -2700,9 +2705,10 @@ public class Collections {
      * through the returned sorted map (or its views).

* * It is imperative that the user manually synchronize on the returned - * sorted map when iterating over any of its collection views, or the + * sorted map when traversing any of its collection views, or the * collections views of any of its {@code subMap}, {@code headMap} or - * {@code tailMap} views. + * {@code tailMap} views, via {@link Iterator}, {@link Spliterator} or + * {@link Stream}: *

      *  SortedMap m = Collections.synchronizedSortedMap(new TreeMap());
      *      ...
@@ -2797,9 +2803,10 @@ public class Collections {
      * accomplished through the returned navigable map (or its views).

* * It is imperative that the user manually synchronize on the returned - * navigable map when iterating over any of its collection views, or the + * navigable map when traversing any of its collection views, or the * collections views of any of its {@code subMap}, {@code headMap} or - * {@code tailMap} views. + * {@code tailMap} views, via {@link Iterator}, {@link Spliterator} or + * {@link Stream}: *

      *  NavigableMap m = Collections.synchronizedNavigableMap(new TreeMap());
      *      ...
diff --git a/jdk/src/java.base/share/classes/java/util/Formatter.java b/jdk/src/java.base/share/classes/java/util/Formatter.java
index d8fc7e60ecd..0a3b50b6a13 100644
--- a/jdk/src/java.base/share/classes/java/util/Formatter.java
+++ b/jdk/src/java.base/share/classes/java/util/Formatter.java
@@ -49,6 +49,7 @@ import java.text.DecimalFormatSymbols;
 import java.text.NumberFormat;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.Objects;
 
 import java.time.DateTimeException;
 import java.time.Instant;
@@ -3860,7 +3861,7 @@ public final class Formatter implements Closeable, Flushable {
                     ampm = dfs.getAmPmStrings();
                 }
                 String s = ampm[t.get(Calendar.AM_PM)];
-                sb.append(s.toLowerCase(l != null ? l : Locale.US));
+                sb.append(s.toLowerCase(Objects.requireNonNullElse(l, Locale.US)));
                 break;
             }
             case DateTime.SECONDS_SINCE_EPOCH: { // 's' (0 - 99...?)
@@ -3893,7 +3894,7 @@ public final class Formatter implements Closeable, Flushable {
                 TimeZone tz = t.getTimeZone();
                 sb.append(tz.getDisplayName((t.get(Calendar.DST_OFFSET) != 0),
                                            TimeZone.SHORT,
-                                            (l == null) ? Locale.US : l));
+                                           Objects.requireNonNullElse(l, Locale.US)));
                 break;
             }
 
@@ -3901,7 +3902,7 @@ public final class Formatter implements Closeable, Flushable {
             case DateTime.NAME_OF_DAY_ABBREV:     // 'a'
             case DateTime.NAME_OF_DAY:          { // 'A'
                 int i = t.get(Calendar.DAY_OF_WEEK);
-                Locale lt = ((l == null) ? Locale.US : l);
+                Locale lt = Objects.requireNonNullElse(l, Locale.US);
                 DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt);
                 if (c == DateTime.NAME_OF_DAY)
                     sb.append(dfs.getWeekdays()[i]);
@@ -3913,7 +3914,7 @@ public final class Formatter implements Closeable, Flushable {
             case DateTime.NAME_OF_MONTH_ABBREV_X: // 'h' -- same b
             case DateTime.NAME_OF_MONTH:        { // 'B'
                 int i = t.get(Calendar.MONTH);
-                Locale lt = ((l == null) ? Locale.US : l);
+                Locale lt = Objects.requireNonNullElse(l, Locale.US);
                 DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt);
                 if (c == DateTime.NAME_OF_MONTH)
                     sb.append(dfs.getMonths()[i]);
@@ -3984,7 +3985,7 @@ public final class Formatter implements Closeable, Flushable {
                 StringBuilder tsb = new StringBuilder();
                 print(tsb, t, DateTime.AM_PM, l);
 
-                sb.append(tsb.toString().toUpperCase(l != null ? l : Locale.US));
+                sb.append(tsb.toString().toUpperCase(Objects.requireNonNullElse(l, Locale.US)));
                 break;
             }
             case DateTime.DATE_TIME:    { // 'c' (Sat Nov 04 12:02:33 EST 1999)
@@ -4092,7 +4093,7 @@ public final class Formatter implements Closeable, Flushable {
                         ampm = dfs.getAmPmStrings();
                     }
                     String s = ampm[t.get(ChronoField.AMPM_OF_DAY)];
-                    sb.append(s.toLowerCase(l != null ? l : Locale.US));
+                    sb.append(s.toLowerCase(Objects.requireNonNullElse(l, Locale.US)));
                     break;
                 }
                 case DateTime.SECONDS_SINCE_EPOCH: { // 's' (0 - 99...?)
@@ -4131,7 +4132,7 @@ public final class Formatter implements Closeable, Flushable {
                         sb.append(TimeZone.getTimeZone(zid.getId())
                                           .getDisplayName(zid.getRules().isDaylightSavings(instant),
                                                           TimeZone.SHORT,
-                                                          (l == null) ? Locale.US : l));
+                                                          Objects.requireNonNullElse(l, Locale.US)));
                         break;
                     }
                     sb.append(zid.getId());
@@ -4141,7 +4142,7 @@ public final class Formatter implements Closeable, Flushable {
                 case DateTime.NAME_OF_DAY_ABBREV:     // 'a'
                 case DateTime.NAME_OF_DAY:          { // 'A'
                     int i = t.get(ChronoField.DAY_OF_WEEK) % 7 + 1;
-                    Locale lt = ((l == null) ? Locale.US : l);
+                    Locale lt = Objects.requireNonNullElse(l, Locale.US);
                     DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt);
                     if (c == DateTime.NAME_OF_DAY)
                         sb.append(dfs.getWeekdays()[i]);
@@ -4153,7 +4154,7 @@ public final class Formatter implements Closeable, Flushable {
                 case DateTime.NAME_OF_MONTH_ABBREV_X: // 'h' -- same b
                 case DateTime.NAME_OF_MONTH:        { // 'B'
                     int i = t.get(ChronoField.MONTH_OF_YEAR) - 1;
-                    Locale lt = ((l == null) ? Locale.US : l);
+                    Locale lt = Objects.requireNonNullElse(l, Locale.US);
                     DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt);
                     if (c == DateTime.NAME_OF_MONTH)
                         sb.append(dfs.getMonths()[i]);
@@ -4223,7 +4224,7 @@ public final class Formatter implements Closeable, Flushable {
                     // this may be in wrong place for some locales
                     StringBuilder tsb = new StringBuilder();
                     print(tsb, t, DateTime.AM_PM, l);
-                    sb.append(tsb.toString().toUpperCase(l != null ? l : Locale.US));
+                    sb.append(tsb.toString().toUpperCase(Objects.requireNonNullElse(l, Locale.US)));
                     break;
                 }
                 case DateTime.DATE_TIME:    { // 'c' (Sat Nov 04 12:02:33 EST 1999)
diff --git a/jdk/src/java.base/share/classes/java/util/Objects.java b/jdk/src/java.base/share/classes/java/util/Objects.java
index 65089553b87..4bd77d7c265 100644
--- a/jdk/src/java.base/share/classes/java/util/Objects.java
+++ b/jdk/src/java.base/share/classes/java/util/Objects.java
@@ -295,7 +295,7 @@ public final class Objects {
      *        {@code defaultObj} is {@code null}
      * @since 9
      */
-    public static  T nonNullElse(T obj, T defaultObj) {
+    public static  T requireNonNullElse(T obj, T defaultObj) {
         return (obj != null) ? obj : requireNonNull(defaultObj, "defaultObj");
     }
 
@@ -314,8 +314,9 @@ public final class Objects {
      *        the {@code supplier.get()} value is {@code null}
      * @since 9
      */
-    public static  T nonNullElseGet(T obj, Supplier supplier) {
-        return (obj != null) ? obj : requireNonNull(requireNonNull(supplier, "supplier").get(), "supplier.get()");
+    public static  T requireNonNullElseGet(T obj, Supplier supplier) {
+        return (obj != null) ? obj
+                : requireNonNull(requireNonNull(supplier, "supplier").get(), "supplier.get()");
     }
 
     /**
diff --git a/jdk/src/java.base/share/classes/java/util/Random.java b/jdk/src/java.base/share/classes/java/util/Random.java
index f22dca758f7..78e4953bfe8 100644
--- a/jdk/src/java.base/share/classes/java/util/Random.java
+++ b/jdk/src/java.base/share/classes/java/util/Random.java
@@ -34,7 +34,7 @@ import java.util.stream.IntStream;
 import java.util.stream.LongStream;
 import java.util.stream.StreamSupport;
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * An instance of this class is used to generate a stream of
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java
index ee553e8f261..45389ac9109 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java
@@ -2775,7 +2775,7 @@ public class CompletableFuture implements Future, CompletionStage {
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long RESULT;
     private static final long STACK;
     private static final long NEXT;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
index 4c1180dc11b..b2c2d2aa701 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
@@ -297,7 +297,7 @@ public class ConcurrentHashMap extends AbstractMap
      * Table accesses require volatile/atomic reads, writes, and
      * CASes.  Because there is no other way to arrange this without
      * adding further indirections, we use intrinsics
-     * (sun.misc.Unsafe) operations.
+     * (jdk.internal.misc.Unsafe) operations.
      *
      * We use the top (sign) bit of Node hash fields for control
      * purposes -- it is available anyway because of addressing
@@ -3287,7 +3287,7 @@ public class ConcurrentHashMap extends AbstractMap
             return true;
         }
 
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long LOCKSTATE;
         static {
             try {
@@ -6330,7 +6330,7 @@ public class ConcurrentHashMap extends AbstractMap
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long SIZECTL;
     private static final long TRANSFERINDEX;
     private static final long BASECOUNT;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java
index 0991efc9e28..4f8fdd92c49 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java
@@ -326,7 +326,7 @@ public class ConcurrentLinkedDeque
 
         // Unsafe mechanics
 
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long PREV;
         private static final long ITEM;
         private static final long NEXT;
@@ -1608,7 +1608,7 @@ public class ConcurrentLinkedDeque
 
     // Unsafe mechanics
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long HEAD;
     private static final long TAIL;
     static {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
index 6e68ed0d333..d302b6f55b8 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java
@@ -929,7 +929,7 @@ public class ConcurrentLinkedQueue extends AbstractQueue
 
     // Unsafe mechanics
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long HEAD;
     private static final long TAIL;
     private static final long ITEM;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
index 60d3c42e8bb..745de306bc1 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
@@ -534,7 +534,7 @@ public class ConcurrentSkipListMap extends AbstractMap
 
         // Unsafe mechanics
 
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long VALUE;
         private static final long NEXT;
 
@@ -614,7 +614,7 @@ public class ConcurrentSkipListMap extends AbstractMap
         }
 
         // Unsafe mechanics
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long RIGHT;
         static {
             try {
@@ -3596,7 +3596,7 @@ public class ConcurrentSkipListMap extends AbstractMap
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long HEAD;
     static {
         try {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
index 96dff4f8989..2ecacf8e185 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
@@ -510,7 +510,7 @@ public class ConcurrentSkipListSet
         U.putObjectVolatile(this, MAP, map);
     }
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long MAP;
     static {
         try {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java b/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
index 771d8b44fa9..65baf7c87c8 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
@@ -1545,7 +1545,7 @@ public class CopyOnWriteArrayList
     private void resetLock() {
         U.putObjectVolatile(this, LOCK, new Object());
     }
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long LOCK;
     static {
         try {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java b/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java
index eebc700f932..24c154e2f05 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/CountedCompleter.java
@@ -754,7 +754,7 @@ public abstract class CountedCompleter extends ForkJoinTask {
     protected void setRawResult(T t) { }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long PENDING;
     static {
         try {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Exchanger.java b/jdk/src/java.base/share/classes/java/util/concurrent/Exchanger.java
index 4c03c25d03d..503d2500578 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/Exchanger.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/Exchanger.java
@@ -625,7 +625,7 @@ public class Exchanger {
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long BOUND;
     private static final long SLOT;
     private static final long MATCH;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
index d2490854abf..e4e91a1a187 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
@@ -1337,7 +1337,7 @@ public class ForkJoinPool extends AbstractExecutorService {
         }
 
         // Unsafe mechanics. Note that some are (and must be) the same as in FJP
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long QLOCK;
         private static final int ABASE;
         private static final int ASHIFT;
@@ -3452,7 +3452,7 @@ public class ForkJoinPool extends AbstractExecutorService {
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long CTL;
     private static final long RUNSTATE;
     private static final int ABASE;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java
index 6a373367d0e..2b714dff9b4 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java
@@ -1517,7 +1517,7 @@ public abstract class ForkJoinTask implements Future, Serializable {
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long STATUS;
 
     static {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
index e98ba993c30..54d8931de4f 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
@@ -185,7 +185,7 @@ public class ForkJoinWorkerThread extends Thread {
     }
 
     // Set up to allow setting thread fields in constructor
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long THREADLOCALS;
     private static final long INHERITABLETHREADLOCALS;
     private static final long INHERITEDACCESSCONTROLCONTEXT;
@@ -248,7 +248,7 @@ public class ForkJoinWorkerThread extends Thread {
          */
         private static ThreadGroup createThreadGroup() {
             try {
-                sun.misc.Unsafe u = sun.misc.Unsafe.getUnsafe();
+                jdk.internal.misc.Unsafe u = jdk.internal.misc.Unsafe.getUnsafe();
                 long tg = u.objectFieldOffset
                     (Thread.class.getDeclaredField("group"));
                 long gp = u.objectFieldOffset
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java b/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java
index 62c2bfcb291..27943fd7cb6 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java
@@ -484,7 +484,7 @@ public class FutureTask implements RunnableFuture {
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long STATE;
     private static final long RUNNER;
     private static final long WAITERS;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java
index 8127fe3a34f..02ffd871b7a 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java
@@ -538,7 +538,7 @@ public class LinkedTransferQueue extends AbstractQueue
         private static final long serialVersionUID = -3375979862319811754L;
 
         // Unsafe mechanics
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long ITEM;
         private static final long NEXT;
         private static final long WAITER;
@@ -1564,7 +1564,7 @@ public class LinkedTransferQueue extends AbstractQueue
 
     // Unsafe mechanics
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long HEAD;
     private static final long TAIL;
     private static final long SWEEPVOTES;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java b/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java
index 9ef99361f45..e8d91e557c0 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/Phaser.java
@@ -1137,7 +1137,7 @@ public class Phaser {
 
     // Unsafe mechanics
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long STATE;
     static {
         try {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java
index 7432529305e..652fd6958cf 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java
@@ -1010,7 +1010,7 @@ public class PriorityBlockingQueue extends AbstractQueue
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long ALLOCATIONSPINLOCK;
     static {
         try {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java
index 0d6e66bf516..03462ac1ef4 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java
@@ -1596,7 +1596,7 @@ public class SubmissionPublisher implements Flow.Publisher,
         }
 
         // Unsafe mechanics
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long CTL;
         private static final long TAIL;
         private static final long HEAD;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java b/jdk/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java
index 029aa9c895c..069d0a6b851 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java
@@ -283,7 +283,7 @@ public class SynchronousQueue extends AbstractQueue
             }
 
             // Unsafe mechanics
-            private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+            private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
             private static final long MATCH;
             private static final long NEXT;
 
@@ -509,7 +509,7 @@ public class SynchronousQueue extends AbstractQueue
         }
 
         // Unsafe mechanics
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long HEAD;
         static {
             try {
@@ -575,7 +575,7 @@ public class SynchronousQueue extends AbstractQueue
             }
 
             // Unsafe mechanics
-            private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+            private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
             private static final long ITEM;
             private static final long NEXT;
 
@@ -817,7 +817,7 @@ public class SynchronousQueue extends AbstractQueue
             }
         }
 
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long HEAD;
         private static final long TAIL;
         private static final long CLEANME;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java
index f9542d504d7..f4bf5a4fef2 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java
@@ -1050,7 +1050,7 @@ public class ThreadLocalRandom extends Random {
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long SEED;
     private static final long PROBE;
     private static final long SECONDARY;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java
index b2a23903c22..01fc1c2c0d7 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java
@@ -49,7 +49,7 @@ package java.util.concurrent.atomic;
 public class AtomicBoolean implements java.io.Serializable {
     private static final long serialVersionUID = 4654671469794556979L;
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long VALUE;
 
     static {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
index 19b341819b9..96e13f60ed8 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
@@ -54,7 +54,7 @@ import java.util.function.IntUnaryOperator;
 public class AtomicInteger extends Number implements java.io.Serializable {
     private static final long serialVersionUID = 6214790243416807050L;
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long VALUE;
 
     static {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
index 2ea9a272008..f3a262b65b4 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
@@ -49,7 +49,7 @@ import java.util.function.IntUnaryOperator;
 public class AtomicIntegerArray implements java.io.Serializable {
     private static final long serialVersionUID = 2862133569453604235L;
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final int ABASE;
     private static final int ASHIFT;
     private final int[] array;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
index 06e517d1a2b..1ec99ccc42f 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
@@ -367,7 +367,7 @@ public abstract class AtomicIntegerFieldUpdater {
      */
     private static class AtomicIntegerFieldUpdaterImpl
             extends AtomicIntegerFieldUpdater {
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private final long offset;
         private final Class tclass;
         private final Class cclass;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
index b919f1e3c7a..2af5d1dd07f 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
@@ -54,7 +54,7 @@ import java.util.function.LongUnaryOperator;
 public class AtomicLong extends Number implements java.io.Serializable {
     private static final long serialVersionUID = 1927816293512124184L;
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long VALUE;
 
     /**
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
index d1af039aa61..58aa1875b19 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
@@ -48,7 +48,7 @@ import java.util.function.LongUnaryOperator;
 public class AtomicLongArray implements java.io.Serializable {
     private static final long serialVersionUID = -2308431214976778248L;
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final int ABASE;
     private static final int ASHIFT;
     private final long[] array;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
index 5cb20197126..870a311aebf 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
@@ -366,7 +366,7 @@ public abstract class AtomicLongFieldUpdater {
     }
 
     private static class CASUpdater extends AtomicLongFieldUpdater {
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private final long offset;
         private final Class tclass;
         private final Class cclass;
@@ -490,7 +490,7 @@ public abstract class AtomicLongFieldUpdater {
 
 
     private static class LockedUpdater extends AtomicLongFieldUpdater {
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private final long offset;
         private final Class tclass;
         private final Class cclass;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java
index b49118b1c60..8204c3fcc61 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicMarkableReference.java
@@ -190,7 +190,7 @@ public class AtomicMarkableReference {
 
     // Unsafe mechanics
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long PAIR;
     static {
         try {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java
index dbc668582f7..9d4d2a385c7 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java
@@ -49,7 +49,7 @@ import java.util.function.UnaryOperator;
 public class AtomicReference implements java.io.Serializable {
     private static final long serialVersionUID = -1848883965231344442L;
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long VALUE;
 
     static {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
index cce148e6f0e..03f950d43e0 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
@@ -52,7 +52,7 @@ import java.util.function.UnaryOperator;
 public class AtomicReferenceArray implements java.io.Serializable {
     private static final long serialVersionUID = -6209656149925076980L;
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long ARRAY;
     private static final int ABASE;
     private static final int ASHIFT;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
index f33498c8f9f..aa89aead91b 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
@@ -284,7 +284,7 @@ public abstract class AtomicReferenceFieldUpdater {
 
     private static final class AtomicReferenceFieldUpdaterImpl
         extends AtomicReferenceFieldUpdater {
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private final long offset;
         private final Class tclass;
         private final Class vclass;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java
index 40ceeb2650f..fd520d7d889 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java
@@ -190,7 +190,7 @@ public class AtomicStampedReference {
 
     // Unsafe mechanics
 
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long PAIR;
     static {
         try {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java
index 18d720fa391..153a3adc378 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java
@@ -133,7 +133,7 @@ abstract class Striped64 extends Number {
         }
 
         // Unsafe mechanics
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long VALUE;
         static {
             try {
@@ -372,7 +372,7 @@ abstract class Striped64 extends Number {
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long BASE;
     private static final long CELLSBUSY;
     private static final long PROBE;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
index 7f6de8971ce..06f50846234 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
@@ -1821,7 +1821,7 @@ public abstract class AbstractQueuedLongSynchronizer
      * are at it, we do the same for other CASable fields (which could
      * otherwise be done with atomic field updaters).
      */
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long STATE;
     private static final long HEAD;
     private static final long TAIL;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
index 1f36435bb4c..3d604a63214 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
@@ -524,7 +524,7 @@ public abstract class AbstractQueuedSynchronizer
             return U.compareAndSwapObject(this, NEXT, expect, update);
         }
 
-        private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+        private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
         private static final long NEXT;
         static final long PREV;
         private static final long THREAD;
@@ -2285,7 +2285,7 @@ public abstract class AbstractQueuedSynchronizer
      * are at it, we do the same for other CASable fields (which could
      * otherwise be done with atomic field updaters).
      */
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long STATE;
     private static final long HEAD;
     private static final long TAIL;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java
index 297de583436..a82d2d9f736 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java
@@ -394,7 +394,7 @@ public class LockSupport {
     }
 
     // Hotspot implementation via intrinsics API
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long PARKBLOCKER;
     private static final long SECONDARY;
     static {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
index c41b4285a67..a2c627aed3b 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
@@ -1501,7 +1501,7 @@ public class ReentrantReadWriteLock
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long TID;
     static {
         try {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java
index d6895996d91..0e8252587b5 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java
@@ -1398,7 +1398,7 @@ public class StampedLock implements java.io.Serializable {
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe U = sun.misc.Unsafe.getUnsafe();
+    private static final jdk.internal.misc.Unsafe U = jdk.internal.misc.Unsafe.getUnsafe();
     private static final long STATE;
     private static final long WHEAD;
     private static final long WTAIL;
diff --git a/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java b/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java
index c40886fafa6..2d82625780e 100644
--- a/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java
+++ b/jdk/src/java.base/share/classes/java/util/zip/CRC32C.java
@@ -28,7 +28,7 @@ import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import sun.nio.ch.DirectBuffer;
 
 /**
diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java
index 39bbbc625a1..1d74a0da741 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java
@@ -30,7 +30,7 @@ import java.io.Console;
 import java.io.FileDescriptor;
 import java.security.ProtectionDomain;
 import java.security.AccessController;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /** A repository of "shared secrets", which are a mechanism for
     calling implementation-private methods in another package without
diff --git a/jdk/src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java b/jdk/src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java
index 60544e25f38..6c5cb3f5563 100644
--- a/jdk/src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java
+++ b/jdk/src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java
@@ -78,7 +78,7 @@ public class AnonymousClassLoader {
         this.hostClass = hostClass;
     }
 
-    public static AnonymousClassLoader make(sun.misc.Unsafe unsafe, Class hostClass) {
+    public static AnonymousClassLoader make(jdk.internal.misc.Unsafe unsafe, Class hostClass) {
         if (unsafe == null)  throw new NullPointerException();
         return new AnonymousClassLoader(hostClass);
     }
@@ -189,13 +189,13 @@ public class AnonymousClassLoader {
     private static int fakeNameCounter = 99999;
 
     // ignore two warnings on this line:
-    private static sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe();
+    private static jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe();
     // preceding line requires that this class be on the boot class path
 
     private static final Method defineAnonymousClass;
     static {
         Method dac = null;
-        Class unsafeClass = unsafe.getClass();
+        Class unsafeClass = unsafe.getClass();
         try {
             dac = unsafeClass.getMethod("defineAnonymousClass",
                                         Class.class,
diff --git a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java
index e69330b6846..ef27a08c132 100644
--- a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java
@@ -27,18 +27,19 @@ package sun.invoke.util;
 
 public enum Wrapper {
     //        wrapperType    primitiveType  char            zero         emptyArray          format
-    BOOLEAN(  Boolean.class, boolean.class, 'Z',      (Boolean)false, new boolean[0], Format.unsigned( 1)),
+    BOOLEAN(  Boolean.class, boolean.class, 'Z',          Boolean.FALSE, new boolean[0], Format.unsigned( 1)),
     // These must be in the order defined for widening primitive conversions in JLS 5.1.2
-    BYTE   (     Byte.class,    byte.class, 'B',       (Byte)(byte)0, new    byte[0], Format.signed(   8)),
-    SHORT  (    Short.class,   short.class, 'S',     (Short)(short)0, new   short[0], Format.signed(  16)),
-    CHAR   (Character.class,    char.class, 'C',  (Character)(char)0, new    char[0], Format.unsigned(16)),
-    INT    (  Integer.class,     int.class, 'I', (Integer)/*(int)*/0, new     int[0], Format.signed(  32)),
-    LONG   (     Long.class,    long.class, 'J',       (Long)(long)0, new    long[0], Format.signed(  64)),
-    FLOAT  (    Float.class,   float.class, 'F',     (Float)(float)0, new   float[0], Format.floating(32)),
-    DOUBLE (   Double.class,  double.class, 'D',   (Double)(double)0, new  double[0], Format.floating(64)),
-    OBJECT (   Object.class,  Object.class, 'L',                null, new  Object[0], Format.other(    1)),
+    // Avoid boxing integral types here to defer initialization of internal caches
+    BYTE   (     Byte.class,    byte.class, 'B',      new Byte((byte)0), new    byte[0], Format.signed(   8)),
+    SHORT  (    Short.class,   short.class, 'S',    new Short((short)0), new   short[0], Format.signed(  16)),
+    CHAR   (Character.class,    char.class, 'C', new Character((char)0), new    char[0], Format.unsigned(16)),
+    INT    (  Integer.class,     int.class, 'I',         new Integer(0), new     int[0], Format.signed(  32)),
+    LONG   (     Long.class,    long.class, 'J',            new Long(0), new    long[0], Format.signed(  64)),
+    FLOAT  (    Float.class,   float.class, 'F',        (Float)(float)0, new   float[0], Format.floating(32)),
+    DOUBLE (   Double.class,  double.class, 'D',      (Double)(double)0, new  double[0], Format.floating(64)),
+    OBJECT (   Object.class,  Object.class, 'L',                   null, new  Object[0], Format.other(    1)),
     // VOID must be the last type, since it is "assignable" from any other type:
-    VOID   (     Void.class,    void.class, 'V',                null,           null, Format.other(    0)),
+    VOID   (     Void.class,    void.class, 'V',                   null,           null, Format.other(    0)),
     ;
 
     private final Class wrapperType;
diff --git a/jdk/src/java.base/share/classes/sun/misc/InnocuousThread.java b/jdk/src/java.base/share/classes/sun/misc/InnocuousThread.java
index 78a0a185f0a..a9c129cd79e 100644
--- a/jdk/src/java.base/share/classes/sun/misc/InnocuousThread.java
+++ b/jdk/src/java.base/share/classes/sun/misc/InnocuousThread.java
@@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicInteger;
  * ThreadGroup and supports the ability to erase ThreadLocals.
  */
 public final class InnocuousThread extends ManagedLocalsThread {
-    private static final Unsafe UNSAFE;
+    private static final jdk.internal.misc.Unsafe UNSAFE;
     private static final ThreadGroup INNOCUOUSTHREADGROUP;
     private static final AccessControlContext ACC;
     private static final long INHERITEDACCESSCONTROLCONTEXT;
@@ -92,7 +92,7 @@ public final class InnocuousThread extends ManagedLocalsThread {
             });
 
             // Find and use topmost ThreadGroup as parent of new group
-            UNSAFE = Unsafe.getUnsafe();
+            UNSAFE = jdk.internal.misc.Unsafe.getUnsafe();
             Class tk = Thread.class;
             Class gk = ThreadGroup.class;
 
diff --git a/jdk/src/java.base/share/classes/sun/misc/ManagedLocalsThread.java b/jdk/src/java.base/share/classes/sun/misc/ManagedLocalsThread.java
index f520ca384b6..58d9013c261 100644
--- a/jdk/src/java.base/share/classes/sun/misc/ManagedLocalsThread.java
+++ b/jdk/src/java.base/share/classes/sun/misc/ManagedLocalsThread.java
@@ -30,7 +30,7 @@ package sun.misc;
  * locals erased on construction.
  */
 public class ManagedLocalsThread extends Thread {
-    private static final Unsafe UNSAFE;
+    private static final jdk.internal.misc.Unsafe UNSAFE;
     private static final long THREAD_LOCALS;
     private static final long INHERITABLE_THREAD_LOCALS;
 
@@ -77,7 +77,7 @@ public class ManagedLocalsThread extends Thread {
     }
 
     static {
-        UNSAFE = Unsafe.getUnsafe();
+        UNSAFE = jdk.internal.misc.Unsafe.getUnsafe();
         Class t = Thread.class;
         try {
             THREAD_LOCALS = UNSAFE.objectFieldOffset
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/NativeObject.java b/jdk/src/java.base/share/classes/sun/nio/ch/NativeObject.java
index e4e4366289a..839b64df8ad 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/NativeObject.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/NativeObject.java
@@ -29,7 +29,7 @@
 package sun.nio.ch;                                     // Formerly in sun.misc
 
 import java.nio.ByteOrder;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 
 // ## In the fullness of time, this class will be eliminated
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/Util.java b/jdk/src/java.base/share/classes/sun/nio/ch/Util.java
index 614850577e0..fd428149999 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/Util.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/Util.java
@@ -35,7 +35,7 @@ import java.nio.channels.*;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import sun.misc.Cleaner;
 import sun.security.action.GetPropertyAction;
 
diff --git a/jdk/src/java.base/share/classes/sun/nio/fs/Cancellable.java b/jdk/src/java.base/share/classes/sun/nio/fs/Cancellable.java
index 648d4089ce8..4e283a5f157 100644
--- a/jdk/src/java.base/share/classes/sun/nio/fs/Cancellable.java
+++ b/jdk/src/java.base/share/classes/sun/nio/fs/Cancellable.java
@@ -26,7 +26,7 @@
 package sun.nio.fs;
 
 import sun.misc.ManagedLocalsThread;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import java.util.concurrent.ExecutionException;
 
 /**
diff --git a/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java b/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java
index 1009bda5de9..8acc0c198a1 100644
--- a/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java
+++ b/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffer.java
@@ -25,7 +25,7 @@
 
 package sun.nio.fs;
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 import sun.misc.Cleaner;
 
 /**
diff --git a/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffers.java b/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffers.java
index 41ae7ea8835..728d96eb2b3 100644
--- a/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffers.java
+++ b/jdk/src/java.base/share/classes/sun/nio/fs/NativeBuffers.java
@@ -25,7 +25,7 @@
 
 package sun.nio.fs;
 
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /**
  * Factory for native buffers.
diff --git a/jdk/src/java.base/share/classes/sun/reflect/AccessorGenerator.java b/jdk/src/java.base/share/classes/sun/reflect/AccessorGenerator.java
index 96f64ec1847..3b06f550f0f 100644
--- a/jdk/src/java.base/share/classes/sun/reflect/AccessorGenerator.java
+++ b/jdk/src/java.base/share/classes/sun/reflect/AccessorGenerator.java
@@ -26,7 +26,7 @@
 package sun.reflect;
 
 import java.lang.reflect.*;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /** Shared functionality for all accessor generators */
 
diff --git a/jdk/src/java.base/share/classes/sun/reflect/ClassDefiner.java b/jdk/src/java.base/share/classes/sun/reflect/ClassDefiner.java
index 6b1b43c841b..b4d50095939 100644
--- a/jdk/src/java.base/share/classes/sun/reflect/ClassDefiner.java
+++ b/jdk/src/java.base/share/classes/sun/reflect/ClassDefiner.java
@@ -27,7 +27,7 @@ package sun.reflect;
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import sun.misc.Unsafe;
+import jdk.internal.misc.Unsafe;
 
 /** Utility class which assists in calling Unsafe.defineClass() by
     creating a new class loader which delegates to the one needed in
diff --git a/jdk/src/java.base/share/classes/sun/reflect/FieldInfo.java b/jdk/src/java.base/share/classes/sun/reflect/FieldInfo.java
index 6972155fb10..72abd07b861 100644
--- a/jdk/src/java.base/share/classes/sun/reflect/FieldInfo.java
+++ b/jdk/src/java.base/share/classes/sun/reflect/FieldInfo.java
@@ -38,7 +38,7 @@ public class FieldInfo {
     private String signature;
     private int    modifiers;
     // This is compatible with the old reflection implementation's
-    // "slot" value to allow sun.misc.Unsafe to work
+    // "slot" value to allow jdk.internal.misc.Unsafe to work
     private int    slot;
 
     // Not really necessary to provide a constructor since the VM
diff --git a/jdk/src/java.base/share/classes/sun/reflect/MagicAccessorImpl.java b/jdk/src/java.base/share/classes/sun/reflect/MagicAccessorImpl.java
index 59624366141..af1382f6a5e 100644
--- a/jdk/src/java.base/share/classes/sun/reflect/MagicAccessorImpl.java
+++ b/jdk/src/java.base/share/classes/sun/reflect/MagicAccessorImpl.java
@@ -32,7 +32,7 @@ package sun.reflect;
     fields and methods of other classes. It is used to hold the code
     for dynamically-generated FieldAccessorImpl and MethodAccessorImpl
     subclasses. (Use of the word "unsafe" was avoided in this class's
-    name to avoid confusion with {@link sun.misc.Unsafe}.) 

+ name to avoid confusion with {@link jdk.internal.misc.Unsafe}.)

The bug fix for 4486457 also necessitated disabling verification for this class and all subclasses, as opposed to just diff --git a/jdk/src/java.base/share/classes/sun/reflect/ReflectionFactory.java b/jdk/src/java.base/share/classes/sun/reflect/ReflectionFactory.java index 35445331168..24aa225b89e 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/ReflectionFactory.java +++ b/jdk/src/java.base/share/classes/sun/reflect/ReflectionFactory.java @@ -44,7 +44,7 @@ import sun.reflect.misc.ReflectUtil; subversion of both the language and the verifier. For this reason, they are all instance methods, and access to the constructor of this factory is guarded by a security check, in similar style to - {@link sun.misc.Unsafe}.

+ {@link jdk.internal.misc.Unsafe}.

*/ public class ReflectionFactory { diff --git a/jdk/src/java.base/share/classes/sun/reflect/UnsafeFieldAccessorImpl.java b/jdk/src/java.base/share/classes/sun/reflect/UnsafeFieldAccessorImpl.java index 8e830999f13..d54c7f8a6f6 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeFieldAccessorImpl.java +++ b/jdk/src/java.base/share/classes/sun/reflect/UnsafeFieldAccessorImpl.java @@ -27,9 +27,9 @@ package sun.reflect; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; -/** Base class for sun.misc.Unsafe-based FieldAccessors. The +/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors. The observation is that there are only nine types of fields from the standpoint of reflection code: the eight primitive types and Object. Using class Unsafe instead of generated bytecodes saves diff --git a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedFieldAccessorImpl.java b/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedFieldAccessorImpl.java index a40ca950881..5cf6c5ee5c7 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedFieldAccessorImpl.java +++ b/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedFieldAccessorImpl.java @@ -27,10 +27,10 @@ package sun.reflect; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** - * Base class for sun.misc.Unsafe-based FieldAccessors for fields with + * Base class for jdk.internal.misc.Unsafe-based FieldAccessors for fields with * final or volatile qualifiers. These differ from unqualified * versions in that (1) they check for read-only status (2) they use * the volatile forms of Unsafe get/put methods. (When accessed via diff --git a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticFieldAccessorImpl.java b/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticFieldAccessorImpl.java index 04219f1f49c..74b40571eab 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticFieldAccessorImpl.java +++ b/jdk/src/java.base/share/classes/sun/reflect/UnsafeQualifiedStaticFieldAccessorImpl.java @@ -28,9 +28,9 @@ package sun.reflect; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.security.AccessController; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; -/** Base class for sun.misc.Unsafe-based FieldAccessors for final or +/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors for final or static volatile fields. */ abstract class UnsafeQualifiedStaticFieldAccessorImpl diff --git a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticFieldAccessorImpl.java b/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticFieldAccessorImpl.java index f07a17cdd5b..e87ba31b543 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticFieldAccessorImpl.java +++ b/jdk/src/java.base/share/classes/sun/reflect/UnsafeStaticFieldAccessorImpl.java @@ -28,9 +28,9 @@ package sun.reflect; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.security.AccessController; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; -/** Base class for sun.misc.Unsafe-based FieldAccessors for static +/** Base class for jdk.internal.misc.Unsafe-based FieldAccessors for static fields. The observation is that there are only nine types of fields from the standpoint of reflection code: the eight primitive types and Object. Using class Unsafe instead of generated diff --git a/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java b/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java index cee12a029ea..c90a630e2fa 100644 --- a/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java +++ b/jdk/src/java.base/share/classes/sun/reflect/misc/ReflectUtil.java @@ -337,7 +337,7 @@ public final class ReflectUtil { /** * Checks if {@code Class cls} is a VM-anonymous class - * as defined by {@link sun.misc.Unsafe#defineAnonymousClass} + * as defined by {@link jdk.internal.misc.Unsafe#defineAnonymousClass} * (not to be confused with a Java Language anonymous inner class). */ public static boolean isVMAnonymousClass(Class cls) { diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java index db36c0e4a44..0ad5387b324 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java @@ -36,9 +36,7 @@ import java.util.Date; import sun.security.util.Debug; import sun.security.util.DerInputStream; -import sun.security.util.DerOutputStream; import sun.security.x509.SerialNumber; -import sun.security.x509.KeyIdentifier; import sun.security.x509.AuthorityKeyIdentifierExtension; /** @@ -131,13 +129,7 @@ class AdaptableX509CertSelector extends X509CertSelector { serial = null; if (ext != null) { - KeyIdentifier akid = (KeyIdentifier)ext.get( - AuthorityKeyIdentifierExtension.KEY_ID); - if (akid != null) { - DerOutputStream derout = new DerOutputStream(); - derout.putOctetString(akid.getIdentifier()); - ski = derout.toByteArray(); - } + ski = ext.getEncodedKeyIdentifier(); SerialNumber asn = (SerialNumber)ext.get( AuthorityKeyIdentifierExtension.SERIAL_NUMBER); if (asn != null) { diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java index 0285cc02e4e..95ef350a9d3 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java @@ -33,7 +33,6 @@ import javax.security.auth.x500.X500Principal; import java.util.*; import sun.security.util.Debug; -import sun.security.util.DerOutputStream; import static sun.security.x509.PKIXExtensions.*; import sun.security.x509.*; @@ -607,12 +606,9 @@ public class DistributionPointFetcher { AuthorityKeyIdentifierExtension akidext = crlImpl.getAuthKeyIdExtension(); if (akidext != null) { - KeyIdentifier akid = (KeyIdentifier)akidext.get( - AuthorityKeyIdentifierExtension.KEY_ID); - if (akid != null) { - DerOutputStream derout = new DerOutputStream(); - derout.putOctetString(akid.getIdentifier()); - certSel.setSubjectKeyIdentifier(derout.toByteArray()); + byte[] kid = akidext.getEncodedKeyIdentifier(); + if (kid != null) { + certSel.setSubjectKeyIdentifier(kid); } SerialNumber asn = (SerialNumber)akidext.get( diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/ForwardBuilder.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/ForwardBuilder.java index 12c32cae1bc..3c86d6206ff 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/ForwardBuilder.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/ForwardBuilder.java @@ -46,9 +46,10 @@ import sun.security.provider.certpath.PKIX.BuilderParams; import sun.security.util.Debug; import sun.security.x509.AccessDescription; import sun.security.x509.AuthorityInfoAccessExtension; +import sun.security.x509.AuthorityKeyIdentifierExtension; import static sun.security.x509.PKIXExtensions.*; import sun.security.x509.X500Name; -import sun.security.x509.AuthorityKeyIdentifierExtension; +import sun.security.x509.X509CertImpl; /** * This class represents a forward builder, which is able to retrieve @@ -69,7 +70,6 @@ class ForwardBuilder extends Builder { private AdaptableX509CertSelector caSelector; private X509CertSelector caTargetSelector; TrustAnchor trustAnchor; - private Comparator comparator; private boolean searchAllCertStores = true; /** @@ -93,7 +93,6 @@ class ForwardBuilder extends Builder { trustedSubjectDNs.add(anchor.getCA()); } } - comparator = new PKIXCertComparator(trustedSubjectDNs); this.searchAllCertStores = searchAllCertStores; } @@ -122,6 +121,8 @@ class ForwardBuilder extends Builder { * As each cert is added, it is sorted based on the PKIXCertComparator * algorithm. */ + Comparator comparator = + new PKIXCertComparator(trustedSubjectDNs, currState.cert); Set certs = new TreeSet<>(comparator); /* @@ -264,14 +265,6 @@ class ForwardBuilder extends Builder { CertPathHelper.setPathToNames (caSelector, currentState.subjectNamesTraversed); - /* - * Facilitate certification path construction with authority - * key identifier and subject key identifier. - */ - AuthorityKeyIdentifierExtension akidext = - currentState.cert.getAuthorityKeyIdentifierExtension(); - caSelector.setSkiAndSerialNumber(akidext); - /* * check the validity period */ @@ -404,41 +397,68 @@ class ForwardBuilder extends Builder { * * Preference order for current cert: * - * 1) Issuer matches a trusted subject + * 1) The key identifier of an AKID extension (if present) in the + * previous certificate matches the key identifier in the SKID extension + * + * 2) Issuer matches a trusted subject * Issuer: ou=D,ou=C,o=B,c=A * - * 2) Issuer is a descendant of a trusted subject (in order of + * 3) Issuer is a descendant of a trusted subject (in order of * number of links to the trusted subject) * a) Issuer: ou=E,ou=D,ou=C,o=B,c=A [links=1] * b) Issuer: ou=F,ou=E,ou=D,ou=C,ou=B,c=A [links=2] * - * 3) Issuer is an ancestor of a trusted subject (in order of number of + * 4) Issuer is an ancestor of a trusted subject (in order of number of * links to the trusted subject) * a) Issuer: ou=C,o=B,c=A [links=1] * b) Issuer: o=B,c=A [links=2] * - * 4) Issuer is in the same namespace as a trusted subject (in order of + * 5) Issuer is in the same namespace as a trusted subject (in order of * number of links to the trusted subject) * a) Issuer: ou=G,ou=C,o=B,c=A [links=2] * b) Issuer: ou=H,o=B,c=A [links=3] * - * 5) Issuer is an ancestor of certificate subject (in order of number + * 6) Issuer is an ancestor of certificate subject (in order of number * of links to the certificate subject) * a) Issuer: ou=K,o=J,c=A * Subject: ou=L,ou=K,o=J,c=A * b) Issuer: o=J,c=A * Subject: ou=L,ou=K,0=J,c=A * - * 6) Any other certificates + * 7) Any other certificates */ static class PKIXCertComparator implements Comparator { static final String METHOD_NME = "PKIXCertComparator.compare()"; private final Set trustedSubjectDNs; + private final X509CertSelector certSkidSelector; - PKIXCertComparator(Set trustedSubjectDNs) { + PKIXCertComparator(Set trustedSubjectDNs, + X509CertImpl previousCert) throws IOException { this.trustedSubjectDNs = trustedSubjectDNs; + this.certSkidSelector = getSelector(previousCert); + } + + /** + * Returns an X509CertSelector for matching on the authority key + * identifier, or null if not applicable. + */ + private X509CertSelector getSelector(X509CertImpl previousCert) + throws IOException { + if (previousCert != null) { + AuthorityKeyIdentifierExtension akidExt = + previousCert.getAuthorityKeyIdentifierExtension(); + if (akidExt != null) { + byte[] skid = akidExt.getEncodedKeyIdentifier(); + if (skid != null) { + X509CertSelector selector = new X509CertSelector(); + selector.setSubjectKeyIdentifier(skid); + return selector; + } + } + } + return null; } /** @@ -462,6 +482,16 @@ class ForwardBuilder extends Builder { // if certs are the same, return 0 if (oCert1.equals(oCert2)) return 0; + // If akid/skid match then it is preferable + if (certSkidSelector != null) { + if (certSkidSelector.match(oCert1)) { + return -1; + } + if (certSkidSelector.match(oCert2)) { + return 1; + } + } + X500Principal cIssuer1 = oCert1.getIssuerX500Principal(); X500Principal cIssuer2 = oCert2.getIssuerX500Principal(); X500Name cIssuer1Name = X500Name.asX500Name(cIssuer1); diff --git a/jdk/src/java.base/share/classes/sun/security/x509/AuthorityKeyIdentifierExtension.java b/jdk/src/java.base/share/classes/sun/security/x509/AuthorityKeyIdentifierExtension.java index 14754b2536c..d3fb3cd5d9f 100644 --- a/jdk/src/java.base/share/classes/sun/security/x509/AuthorityKeyIdentifierExtension.java +++ b/jdk/src/java.base/share/classes/sun/security/x509/AuthorityKeyIdentifierExtension.java @@ -310,4 +310,16 @@ implements CertAttrSet { public String getName() { return (NAME); } + + /** + * Return the encoded key identifier, or null if not specified. + */ + public byte[] getEncodedKeyIdentifier() throws IOException { + if (id != null) { + DerOutputStream derOut = new DerOutputStream(); + id.encode(derOut); + return derOut.toByteArray(); + } + return null; + } } diff --git a/jdk/src/java.base/share/native/libjimage/ImageNativeSubstrate.cpp b/jdk/src/java.base/share/native/libjimage/ImageNativeSubstrate.cpp index 2528c5850f4..32aa7d0c29f 100644 --- a/jdk/src/java.base/share/native/libjimage/ImageNativeSubstrate.cpp +++ b/jdk/src/java.base/share/native/libjimage/ImageNativeSubstrate.cpp @@ -202,6 +202,9 @@ static jlong* JIMAGE_FindAttributes(JNIEnv *env, jlong* rawAttributes, jbyte* ra if (reader == NULL) return NULL; // Convert byte array to a cstring. char* path = new char[size + 1]; + if (path == NULL) { + return NULL; + } memcpy(path, rawBytes, size); path[size] = '\0'; // Locate resource location data. diff --git a/jdk/src/java.base/share/native/libjimage/imageFile.cpp b/jdk/src/java.base/share/native/libjimage/imageFile.cpp index 1e067f2cdd4..b3dfe4e670f 100644 --- a/jdk/src/java.base/share/native/libjimage/imageFile.cpp +++ b/jdk/src/java.base/share/native/libjimage/imageFile.cpp @@ -118,7 +118,7 @@ void ImageLocation::set_data(u1* data) { // Deflate the attribute stream into an array of attributes. u1 byte; // Repeat until end header is found. - while ((byte = *data)) { + while ((data != NULL) && (byte = *data)) { // Extract kind from header byte. u1 kind = attribute_kind(byte); assert(kind < ATTRIBUTE_COUNT && "invalid image location attribute"); @@ -149,6 +149,7 @@ ImageModuleData::ImageModuleData(const ImageFileReader* image_file, if (found) { u8 data_size = location.get_attribute(ImageLocation::ATTRIBUTE_UNCOMPRESSED); _data = new u1[(size_t)data_size]; + assert(_data != NULL && "allocation failed"); _image_file->get_resource(location, _data); // Map out the header. _header = (Header*)_data; @@ -191,7 +192,7 @@ ImageModuleData::ImageModuleData(const ImageFileReader* image_file, // Release module data resource. ImageModuleData::~ImageModuleData() { if (_data) { - delete _data; + delete[] _data; } } @@ -254,6 +255,7 @@ const char** ImageModuleData::module_to_packages(const char* module_name) { // Construct an array of all the package entries. u4 count = data->package_count(_endian); const char** packages = new const char*[count + 1]; + assert(packages != NULL && "allocation failed"); s4 package_offset = data->package_offset(_endian); for (u4 i = 0; i < count; i++) { u4 package_name_offset = mtp_package(package_offset + i); @@ -271,10 +273,11 @@ const char** ImageModuleData::module_to_packages(const char* module_name) { // to share an open image. ImageFileReaderTable::ImageFileReaderTable() : _count(0), _max(_growth) { _table = new ImageFileReader*[_max]; + assert( _table != NULL && "allocation failed"); } ImageFileReaderTable::~ImageFileReaderTable() { - delete _table; + delete[] _table; } // Add a new image entry to the table. @@ -330,6 +333,7 @@ ImageFileReader* ImageFileReader::open(const char* name, bool big_endian) { // Retrieve table entry. ImageFileReader* reader = _reader_table.get(i); // If name matches, then reuse (bump up use count.) + assert(reader->name() != NULL && "reader->name must not be null"); if (strcmp(reader->name(), name) == 0) { reader->inc_use(); return reader; @@ -339,20 +343,20 @@ ImageFileReader* ImageFileReader::open(const char* name, bool big_endian) { // Need a new image reader. ImageFileReader* reader = new ImageFileReader(name, big_endian); - bool opened = reader->open(); - // If failed to open. - if (!opened) { + if (reader == NULL || !reader->open()) { + // Failed to open. delete reader; return NULL; } // Lock to update SimpleCriticalSectionLock cs(&_reader_table_lock); - // Search for an exist image file. + // Search for an existing image file. for (u4 i = 0; i < _reader_table.count(); i++) { // Retrieve table entry. ImageFileReader* existing_reader = _reader_table.get(i); // If name matches, then reuse (bump up use count.) + assert(reader->name() != NULL && "reader->name still must not be null"); if (strcmp(existing_reader->name(), name) == 0) { existing_reader->inc_use(); reader->close(); @@ -401,6 +405,7 @@ ImageFileReader::ImageFileReader(const char* name, bool big_endian) { // Copy the image file name. int len = (int) strlen(name) + 1; _name = new char[len]; + assert(_name != NULL && "allocation failed"); strncpy(_name, name, len); // Initialize for a closed file. _fd = -1; @@ -414,7 +419,7 @@ ImageFileReader::~ImageFileReader() { close(); // Free up name. if (_name) { - delete _name; + delete[] _name; _name = NULL; } } @@ -473,8 +478,8 @@ bool ImageFileReader::open() { // Initialize the module data ImageModuleData::module_data_name(buffer, _name); module_data = new ImageModuleData(this, buffer); - // Successful open. - return true; + // Successful open (if memory allocation succeeded). + return module_data != NULL; } // Close image file. @@ -655,6 +660,7 @@ void ImageFileReader::get_resource(ImageLocation& location, u1* uncompressed_dat if (!MemoryMapImage) { // Allocate buffer for compression. compressed_data = new u1[(u4)compressed_size]; + assert (compressed_data != NULL && "allocation failed"); // Read bytes from offset beyond the image index. bool is_read = read_at(compressed_data, compressed_size, _index_size + offset); assert(is_read && "error reading from image or short read"); @@ -668,7 +674,7 @@ void ImageFileReader::get_resource(ImageLocation& location, u1* uncompressed_dat &strings); // If not memory mapped then release temporary buffer. if (!MemoryMapImage) { - delete compressed_data; + delete[] compressed_data; } } else { // Read bytes from offset beyond the image index. diff --git a/jdk/src/java.base/solaris/classes/sun/nio/ch/EventPortWrapper.java b/jdk/src/java.base/solaris/classes/sun/nio/ch/EventPortWrapper.java index 5355f7f2911..30a454c070f 100644 --- a/jdk/src/java.base/solaris/classes/sun/nio/ch/EventPortWrapper.java +++ b/jdk/src/java.base/solaris/classes/sun/nio/ch/EventPortWrapper.java @@ -31,7 +31,7 @@ import java.util.BitSet; import java.util.HashMap; import java.util.Map; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import sun.security.action.GetIntegerAction; import static sun.nio.ch.SolarisEventPort.*; diff --git a/jdk/src/java.base/solaris/classes/sun/nio/ch/SolarisEventPort.java b/jdk/src/java.base/solaris/classes/sun/nio/ch/SolarisEventPort.java index f5427d6fb7a..298727dccd4 100644 --- a/jdk/src/java.base/solaris/classes/sun/nio/ch/SolarisEventPort.java +++ b/jdk/src/java.base/solaris/classes/sun/nio/ch/SolarisEventPort.java @@ -28,7 +28,7 @@ package sun.nio.ch; import java.nio.channels.spi.AsynchronousChannelProvider; import java.util.concurrent.RejectedExecutionException; import java.io.IOException; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Provides an AsynchronousChannelGroup implementation based on the Solaris 10 diff --git a/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisAclFileAttributeView.java b/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisAclFileAttributeView.java index f3ba7b3e6f0..7027bd96c2a 100644 --- a/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisAclFileAttributeView.java +++ b/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisAclFileAttributeView.java @@ -29,7 +29,7 @@ import java.nio.file.*; import java.nio.file.attribute.*; import java.util.*; import java.io.IOException; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static sun.nio.fs.UnixConstants.*; import static sun.nio.fs.SolarisConstants.*; diff --git a/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java b/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java index 0c1165ff5f4..7a31d13b3a6 100644 --- a/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java +++ b/jdk/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java @@ -30,7 +30,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.*; import java.io.IOException; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static sun.nio.fs.UnixConstants.*; diff --git a/jdk/src/java.base/windows/classes/sun/nio/ch/Iocp.java b/jdk/src/java.base/windows/classes/sun/nio/ch/Iocp.java index 699df050030..715046a0ede 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/ch/Iocp.java +++ b/jdk/src/java.base/windows/classes/sun/nio/ch/Iocp.java @@ -36,7 +36,7 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.security.AccessController; import sun.security.action.GetPropertyAction; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Windows implementation of AsynchronousChannelGroup encapsulating an I/O diff --git a/jdk/src/java.base/windows/classes/sun/nio/ch/PendingIoCache.java b/jdk/src/java.base/windows/classes/sun/nio/ch/PendingIoCache.java index 72d8d0ea9d9..b8f7cba96f3 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/ch/PendingIoCache.java +++ b/jdk/src/java.base/windows/classes/sun/nio/ch/PendingIoCache.java @@ -27,7 +27,7 @@ package sun.nio.ch; import java.nio.channels.*; import java.util.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Maintains a mapping of pending I/O requests (identified by the address of diff --git a/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java index 991944e96c7..9d5945364b9 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java +++ b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java @@ -33,7 +33,7 @@ import java.io.IOException; import java.security.AccessControlContext; import java.security.AccessController; import java.security.PrivilegedAction; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Windows implementation of AsynchronousServerSocketChannel using overlapped I/O. diff --git a/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java index 1880548f68f..3e96279de41 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java +++ b/jdk/src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java @@ -34,7 +34,7 @@ import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Windows implementation of AsynchronousSocketChannel using overlapped I/O. diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java index 208435dc97e..02226053f8d 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java +++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java @@ -28,7 +28,7 @@ package sun.nio.fs; import java.nio.file.attribute.*; import java.util.concurrent.TimeUnit; import java.security.AccessController; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import sun.security.action.GetPropertyAction; import static sun.nio.fs.WindowsNativeDispatcher.*; diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java index e86c385a622..cf0d23fea2b 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java +++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java @@ -33,7 +33,7 @@ import java.util.concurrent.ExecutorService; import java.io.*; import java.util.*; import java.security.AccessController; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import sun.nio.ch.ThreadPool; import sun.security.util.SecurityConstants; diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java index 56f996d99b3..80d4809b6a5 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java +++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java @@ -30,7 +30,7 @@ import java.io.IOException; import java.io.IOError; import java.security.AccessController; import java.security.PrivilegedAction; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static sun.nio.fs.WindowsNativeDispatcher.*; import static sun.nio.fs.WindowsConstants.*; diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java index 82a4bc3aecd..820edbfd9a8 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java +++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java @@ -27,7 +27,7 @@ package sun.nio.fs; import java.security.AccessController; import java.security.PrivilegedAction; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Win32 and library calls. diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsSecurityDescriptor.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsSecurityDescriptor.java index fb432271cc6..da3460592f4 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsSecurityDescriptor.java +++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsSecurityDescriptor.java @@ -29,7 +29,7 @@ import java.nio.file.ProviderMismatchException; import java.nio.file.attribute.*; import java.util.*; import java.io.IOException; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static sun.nio.fs.WindowsNativeDispatcher.*; import static sun.nio.fs.WindowsConstants.*; diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUserDefinedFileAttributeView.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUserDefinedFileAttributeView.java index 64ef12a9855..774d248840c 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUserDefinedFileAttributeView.java +++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUserDefinedFileAttributeView.java @@ -31,7 +31,7 @@ import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.io.IOException; import java.util.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static sun.nio.fs.WindowsNativeDispatcher.*; import static sun.nio.fs.WindowsConstants.*; diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java index 0ea288e1ecb..8e28e8471ac 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java +++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java @@ -36,7 +36,7 @@ import java.util.Map; import java.util.Set; import com.sun.nio.file.ExtendedWatchEventModifier; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static sun.nio.fs.WindowsNativeDispatcher.*; import static sun.nio.fs.WindowsConstants.*; diff --git a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java index e9afc44069e..a025ae85e5f 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java @@ -25,7 +25,7 @@ package sun.awt; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import javax.accessibility.AccessibleContext; import java.awt.*; diff --git a/jdk/src/java.desktop/share/classes/sun/font/StrikeCache.java b/jdk/src/java.desktop/share/classes/sun/font/StrikeCache.java index 99319c7d16a..094327fe124 100644 --- a/jdk/src/java.desktop/share/classes/sun/font/StrikeCache.java +++ b/jdk/src/java.desktop/share/classes/sun/font/StrikeCache.java @@ -37,7 +37,7 @@ import sun.java2d.Disposer; import sun.java2d.pipe.BufferedContext; import sun.java2d.pipe.RenderQueue; import sun.java2d.pipe.hw.AccelGraphicsConfig; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java index 5f5118a8767..57f24a4eada 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RenderBuffer.java @@ -25,7 +25,7 @@ package sun.java2d.pipe; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** diff --git a/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java b/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java index da637f0625c..66d20f2458b 100644 --- a/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java +++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java @@ -25,7 +25,7 @@ package sun.swing; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.awt.*; import javax.swing.*; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDConstants.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDConstants.java index 26e2cdbbba3..f2dbfc67abf 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDConstants.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDConstants.java @@ -31,7 +31,7 @@ import java.nio.ByteOrder; import java.util.Arrays; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Motif DnD protocol global constants and convenience routines. diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java index da80dda9ceb..a476628e7c5 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java @@ -33,7 +33,7 @@ import java.awt.dnd.InvalidDnDOperationException; import java.util.Map; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * XDragSourceProtocol implementation for Motif DnD protocol. diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java index 735bf144df2..e71236a6ff9 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java @@ -33,7 +33,7 @@ import java.awt.event.MouseEvent; import java.io.IOException; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * XDropTargetProtocol implementation for Motif DnD protocol. diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/Native.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/Native.java index f61654643f2..e4d5b23ca76 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/Native.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/Native.java @@ -25,7 +25,7 @@ package sun.awt.X11; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.util.Vector; import java.security.AccessController; import java.security.PrivilegedAction; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/UnsafeXDisposerRecord.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/UnsafeXDisposerRecord.java index 099b558eef6..6de0c0310ef 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/UnsafeXDisposerRecord.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/UnsafeXDisposerRecord.java @@ -24,7 +24,7 @@ */ package sun.awt.X11; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import sun.util.logging.PlatformLogger; class UnsafeXDisposerRecord implements sun.java2d.DisposerRecord { diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/WindowPropertyGetter.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/WindowPropertyGetter.java index 0cda6fa2fdf..00d3134eea8 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/WindowPropertyGetter.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/WindowPropertyGetter.java @@ -26,7 +26,7 @@ package sun.awt.X11; import java.util.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class WindowPropertyGetter { private static Unsafe unsafe = XlibWrapper.unsafe; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XAtom.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XAtom.java index 01d17fdad21..eeb46347b56 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XAtom.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XAtom.java @@ -55,7 +55,7 @@ package sun.awt.X11; * @since 1.5 */ -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.util.HashMap; public final class XAtom { diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDnDDragSourceProtocol.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDnDDragSourceProtocol.java index a4661e5c687..26265be30bc 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDnDDragSourceProtocol.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDnDDragSourceProtocol.java @@ -35,7 +35,7 @@ import java.util.Map; import sun.util.logging.PlatformLogger; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * XDragSourceProtocol implementation for XDnD protocol. diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDnDDropTargetProtocol.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDnDDropTargetProtocol.java index 074f37dd753..e1698a424b8 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDnDDropTargetProtocol.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDnDDropTargetProtocol.java @@ -35,7 +35,7 @@ import java.io.IOException; import sun.util.logging.PlatformLogger; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * XDropTargetProtocol implementation for XDnD protocol. diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java index 1e59ce16e82..d2a6c9f8c04 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java @@ -41,7 +41,7 @@ import sun.awt.SunToolkit; import sun.awt.dnd.SunDropTargetContextPeer; import sun.awt.dnd.SunDropTargetEvent; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * The XDropTargetContextPeer is the class responsible for handling diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedHelper.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedHelper.java index f54f4bd9e66..0c2acc44c1c 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedHelper.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedHelper.java @@ -25,7 +25,7 @@ package sun.awt.X11; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import sun.util.logging.PlatformLogger; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XKeysym.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XKeysym.java index b0b0d0728ed..e34298a13e7 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XKeysym.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XKeysym.java @@ -27,7 +27,7 @@ package sun.awt.X11; import java.util.Hashtable; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import sun.util.logging.PlatformLogger; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XQueryTree.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XQueryTree.java index dede21f6e30..7c3641d4c42 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XQueryTree.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XQueryTree.java @@ -27,7 +27,7 @@ package sun.awt.X11; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class XQueryTree { private static Unsafe unsafe = XlibWrapper.unsafe; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTranslateCoordinates.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTranslateCoordinates.java index 42a3a42844e..bc08e2077dd 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTranslateCoordinates.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTranslateCoordinates.java @@ -27,7 +27,7 @@ package sun.awt.X11; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class XTranslateCoordinates { private static Unsafe unsafe = XlibWrapper.unsafe; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java index 61d2cbc380d..9fce6afe284 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWM.java @@ -31,7 +31,7 @@ package sun.awt.X11; import sun.awt.IconInfo; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.awt.Insets; import java.awt.Frame; import java.awt.Rectangle; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XlibWrapper.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XlibWrapper.java index bc9e3667a1f..9edec019bb4 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XlibWrapper.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XlibWrapper.java @@ -27,7 +27,7 @@ package sun.awt.X11; import java.security.AccessController; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import sun.security.action.GetPropertyAction; final class XlibWrapper { diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/keysym2ucs.h b/jdk/src/java.desktop/unix/classes/sun/awt/X11/keysym2ucs.h index 09de3bee098..b0c75b313fa 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/keysym2ucs.h +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/keysym2ucs.h @@ -65,7 +65,7 @@ tojava */ tojava tojava package sun.awt.X11; tojava import java.util.Hashtable; -tojava import sun.misc.Unsafe; +tojava import jdk.internal.misc.Unsafe; tojava tojava import sun.util.logging.PlatformLogger; tojava diff --git a/jdk/src/java.management/share/classes/sun/management/BaseOperatingSystemImpl.java b/jdk/src/java.management/share/classes/sun/management/BaseOperatingSystemImpl.java index a40e0b04f93..dc165747c98 100644 --- a/jdk/src/java.management/share/classes/sun/management/BaseOperatingSystemImpl.java +++ b/jdk/src/java.management/share/classes/sun/management/BaseOperatingSystemImpl.java @@ -28,7 +28,7 @@ package sun.management; import java.lang.management.OperatingSystemMXBean; import java.lang.management.ManagementFactory; import javax.management.ObjectName; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Implementation class for the operating system. diff --git a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java index 740f483a44f..3cc0acb8ffe 100644 --- a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java +++ b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java @@ -51,7 +51,7 @@ public class ManagementFactoryHelper { static { // make sure that the management lib is loaded within // java.lang.management.ManagementFactory - sun.misc.Unsafe.getUnsafe().ensureClassInitialized(ManagementFactory.class); + jdk.internal.misc.Unsafe.getUnsafe().ensureClassInitialized(ManagementFactory.class); } private static final VMManagement jvm = new VMManagementImpl(); diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KerberosSecrets.java b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KerberosSecrets.java index 44f2f0f94aa..5d68c4ec3a8 100644 --- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KerberosSecrets.java +++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KerberosSecrets.java @@ -26,7 +26,7 @@ package sun.security.krb5; import javax.security.auth.kerberos.KeyTab; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class KerberosSecrets { private static final Unsafe unsafe = Unsafe.getUnsafe(); diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java index 4b60b1a99c2..e60507fe443 100644 --- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java +++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java @@ -187,10 +187,10 @@ public class PrincipalName implements Cloneable { } private static final long NAME_STRINGS_OFFSET; - private static final sun.misc.Unsafe UNSAFE; + private static final jdk.internal.misc.Unsafe UNSAFE; static { try { - sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe(); + jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); NAME_STRINGS_OFFSET = unsafe.objectFieldOffset( PrincipalName.class.getDeclaredField("nameStrings")); UNSAFE = unsafe; diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 87d655007f2..51ee8deb731 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -133,9 +133,6 @@ java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java generic-all # 8029891 java/lang/ClassLoader/deadlock/GetResource.java generic-all -# 8131129 -java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java windows-all - ############################################################################ # jdk_instrument diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index 72fc5e9dd06..1ec1b7d375c 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -28,7 +28,9 @@ tier1 = \ :jdk_lang \ -java/lang/ProcessHandle/TreeTest.java \ + -java/util/zip/TestLocalTime.java \ :jdk_util \ + -java/util/concurrent/Phaser/Basic.java \ sun/nio/cs/ISO8859x.java \ java/nio/Buffer \ com/sun/crypto/provider/Cipher \ @@ -36,6 +38,8 @@ tier1 = \ tier2 = \ java/lang/ProcessHandle/TreeTest.java \ + java/util/zip/TestLocalTime.java \ + java/util/concurrent/Phaser/Basic.java \ :jdk_io \ :jdk_nio \ -sun/nio/cs/ISO8859x.java \ diff --git a/jdk/test/com/sun/jndi/ldap/LdapTimeoutTest.java b/jdk/test/com/sun/jndi/ldap/LdapTimeoutTest.java index d1797145fa9..fe48073a6b3 100644 --- a/jdk/test/com/sun/jndi/ldap/LdapTimeoutTest.java +++ b/jdk/test/com/sun/jndi/ldap/LdapTimeoutTest.java @@ -47,6 +47,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeUnit; +import javax.net.ssl.SSLHandshakeException; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.NANOSECONDS; @@ -234,6 +235,12 @@ class DeadServerTimeoutSSLTest extends DeadServerTest { if (e.getCause() instanceof SocketTimeoutException) { // SSL connect will timeout via readReply using // SocketTimeoutException + e.printStackTrace(); + pass(); + } else if (e.getCause() instanceof SSLHandshakeException + && e.getCause().getCause() instanceof EOFException) { + // test seems to be failing intermittently on some + // platforms. pass(); } else { fail(e); diff --git a/jdk/test/java/lang/ProcessBuilder/Basic.java b/jdk/test/java/lang/ProcessBuilder/Basic.java index 5a39cdc454f..7be2aa6ba71 100644 --- a/jdk/test/java/lang/ProcessBuilder/Basic.java +++ b/jdk/test/java/lang/ProcessBuilder/Basic.java @@ -1248,7 +1248,7 @@ public class Basic { () -> p.toHandle(), () -> p.supportsNormalTermination(), () -> p.children(), - () -> p.allChildren()); + () -> p.descendants()); } diff --git a/jdk/test/java/lang/ProcessHandle/OnExitTest.java b/jdk/test/java/lang/ProcessHandle/OnExitTest.java index ea9dfc65e0d..9c7a5193db6 100644 --- a/jdk/test/java/lang/ProcessHandle/OnExitTest.java +++ b/jdk/test/java/lang/ProcessHandle/OnExitTest.java @@ -129,7 +129,7 @@ public class OnExitTest extends ProcessUtil { printf(" You can try to increase the timeout or%n"); printf(" you can try to use a faster VM (i.e. not a debug version).%n"); } - children = getAllChildren(procHandle); + children = getDescendants(procHandle); ConcurrentHashMap> completions = new ConcurrentHashMap<>(); diff --git a/jdk/test/java/lang/ProcessHandle/PermissionTest.java b/jdk/test/java/lang/ProcessHandle/PermissionTest.java index 863f421afd7..042b9d1e818 100644 --- a/jdk/test/java/lang/ProcessHandle/PermissionTest.java +++ b/jdk/test/java/lang/ProcessHandle/PermissionTest.java @@ -62,9 +62,9 @@ public class PermissionTest { } @Test - public void allChildrenWithPermission() { + public void descendantsWithPermission() { Policy.setPolicy(new TestPolicy(new RuntimePermission("manageProcess"))); - currentHndl.allChildren(); + currentHndl.descendants(); } @Test @@ -122,7 +122,7 @@ public class PermissionTest { @Test(groups = { "NoManageProcessPermission" }, expectedExceptions = SecurityException.class) public void noPermissionAllChildren() { - currentHndl.allChildren(); + currentHndl.descendants(); } @Test(groups = { "NoManageProcessPermission" }, expectedExceptions = SecurityException.class) diff --git a/jdk/test/java/lang/ProcessHandle/ProcessUtil.java b/jdk/test/java/lang/ProcessHandle/ProcessUtil.java index 328012f1a30..c0c6916f971 100644 --- a/jdk/test/java/lang/ProcessHandle/ProcessUtil.java +++ b/jdk/test/java/lang/ProcessHandle/ProcessUtil.java @@ -63,8 +63,8 @@ public abstract class ProcessUtil { * @param ph the Process to get children of * @return a list of child ProcessHandles */ - public static List getAllChildren(ProcessHandle ph) { - return ph.allChildren() + public static List getDescendants(ProcessHandle ph) { + return ph.descendants() .filter(ProcessUtil::isNotWindowsConsole) .collect(Collectors.toList()); } @@ -117,7 +117,7 @@ public abstract class ProcessUtil { // ignore } } - subprocesses = getAllChildren(ph); + subprocesses = getDescendants(ph); count = subprocesses.size(); System.out.printf(" waiting for subprocesses of %s to start," + " expected: %d, current: %d%n", ph, nchildren, count); @@ -133,7 +133,7 @@ public abstract class ProcessUtil { * @return the ProcessHandle */ public static ProcessHandle destroyProcessTree(ProcessHandle p) { - Stream children = p.allChildren().filter(ProcessUtil::isNotWindowsConsole); + Stream children = p.descendants().filter(ProcessUtil::isNotWindowsConsole); children.forEach(ph -> { System.out.printf("destroyProcessTree destroyForcibly%n"); printProcess(ph); diff --git a/jdk/test/java/lang/ProcessHandle/TreeTest.java b/jdk/test/java/lang/ProcessHandle/TreeTest.java index ea12d3f361f..39b00b088b0 100644 --- a/jdk/test/java/lang/ProcessHandle/TreeTest.java +++ b/jdk/test/java/lang/ProcessHandle/TreeTest.java @@ -193,21 +193,21 @@ public class TreeTest extends ProcessUtil { } // show the complete list of children (for debug) - List allChildren = getAllChildren(p1Handle); - printf(" allChildren: %s%n", - allChildren.stream().map(p -> p.getPid()) - .collect(Collectors.toList())); + List descendants = getDescendants(p1Handle); + printf(" descendants: %s%n", + descendants.stream().map(p -> p.getPid()) + .collect(Collectors.toList())); - // Verify that all spawned children show up in the allChildren List + // Verify that all spawned children show up in the descendants List processes.forEach((p, parent) -> { Assert.assertEquals(p.isAlive(), true, "Child should be alive: " + p); - Assert.assertTrue(allChildren.contains(p), "Spawned child should be listed in allChildren: " + p); + Assert.assertTrue(descendants.contains(p), "Spawned child should be listed in descendants: " + p); }); // Closing JavaChild's InputStream will cause all children to exit p1.getOutputStream().close(); - for (ProcessHandle p : allChildren) { + for (ProcessHandle p : descendants) { try { p.onExit().get(); // wait for the child to exit } catch (ExecutionException e) { @@ -228,9 +228,9 @@ public class TreeTest extends ProcessUtil { /** * Test destroy of processes. * A JavaChild is started and it starts three children. - * Each one is then checked to be alive and listed by allChildren + * Each one is then checked to be alive and listed by descendants * and forcibly destroyed. - * After they exit they should no longer be listed by allChildren. + * After they exit they should no longer be listed by descendants. */ @Test public static void test3() { @@ -263,24 +263,24 @@ public class TreeTest extends ProcessUtil { Assert.assertTrue(spawnCount.await(Utils.adjustTimeout(30L), TimeUnit.SECONDS), "Timeout waiting for processes to start"); - // Debugging; list allChildren that are not expected in processes - List allChildren = ProcessUtil.getAllChildren(p1Handle); - long count = allChildren.stream() + // Debugging; list descendants that are not expected in processes + List descendants = ProcessUtil.getDescendants(p1Handle); + long count = descendants.stream() .filter(ph -> !processes.containsKey(ph)) .count(); if (count > 0) { - allChildren.stream() + descendants.stream() .filter(ph -> !processes.containsKey(ph)) .forEach(ph1 -> ProcessUtil.printProcess(ph1, "Extra process: ")); ProcessUtil.logTaskList(); - Assert.assertEquals(0, count, "Extra processes in allChildren"); + Assert.assertEquals(0, count, "Extra processes in descendants"); } - // Verify that all spawned children are alive, show up in the allChildren list + // Verify that all spawned children are alive, show up in the descendants list // then destroy them processes.forEach((p, parent) -> { Assert.assertEquals(p.isAlive(), true, "Child should be alive: " + p); - Assert.assertTrue(allChildren.contains(p), "Spawned child should be listed in allChildren: " + p); + Assert.assertTrue(descendants.contains(p), "Spawned child should be listed in descendants: " + p); p.destroyForcibly(); }); Assert.assertEquals(processes.size(), newChildren, "Wrong number of children"); @@ -305,8 +305,8 @@ public class TreeTest extends ProcessUtil { p1.destroyForcibly(); p1.waitFor(); - // Verify that none of the spawned children are still listed by allChildren - List remaining = getAllChildren(self); + // Verify that none of the spawned children are still listed by descendants + List remaining = getDescendants(self); Assert.assertFalse(remaining.remove(p1Handle), "Child p1 should have exited"); remaining = remaining.stream().filter(processes::containsKey).collect(Collectors.toList()); Assert.assertEquals(remaining.size(), 0, "Subprocess(es) should have exited: " + remaining); @@ -415,28 +415,28 @@ public class TreeTest extends ProcessUtil { Assert.assertTrue(spawnCount.await(Utils.adjustTimeout(30L), TimeUnit.SECONDS), "Timeout waiting for processes to start"); - // Debugging; list allChildren that are not expected in processes - List allChildren = ProcessUtil.getAllChildren(p1Handle); - long count = allChildren.stream() + // Debugging; list descendants that are not expected in processes + List descendants = ProcessUtil.getDescendants(p1Handle); + long count = descendants.stream() .filter(ph -> !processes.containsKey(ph)) .count(); if (count > 0) { - allChildren.stream() + descendants.stream() .filter(ph -> !processes.containsKey(ph)) .forEach(ph1 -> ProcessUtil.printProcess(ph1, "Extra process: ")); ProcessUtil.logTaskList(); - Assert.assertEquals(0, count, "Extra processes in allChildren"); + Assert.assertEquals(0, count, "Extra processes in descendants"); } Assert.assertEquals(getChildren(p1Handle).size(), factor, "expected direct children"); - count = getAllChildren(p1Handle).size(); + count = getDescendants(p1Handle).size(); long totalChildren = factor * factor * factor + factor * factor + factor; Assert.assertTrue(count >= totalChildren, "expected at least " + totalChildren + ", actual: " + count); - List subprocesses = getAllChildren(p1Handle); - printf(" allChildren: %s%n", + List subprocesses = getDescendants(p1Handle); + printf(" descendants: %s%n", subprocesses.stream().map(p -> p.getPid()) .collect(Collectors.toList())); diff --git a/jdk/test/java/security/SecureRandom/DefaultProvider.java b/jdk/test/java/security/SecureRandom/DefaultProvider.java new file mode 100644 index 00000000000..50b4719acc6 --- /dev/null +++ b/jdk/test/java/security/SecureRandom/DefaultProvider.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 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 + * 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 static java.lang.System.out; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; + +/** + * @test + * @bug 8048356 + * @summary Assert default provider used on all OS for SecureRandom + */ +public class DefaultProvider { + + private static final String OS_NAME = System.getProperty("os.name"); + private static final String SUNOS = "SunOS"; + private static final String WINDOWS = "Windows"; + + public static void main(String[] args) throws NoSuchAlgorithmException { + out.println("Operating System: " + OS_NAME); + + /* Test default provider used with constructor */ + out.println("TEST: Default provider with constructor"); + SecureRandom secureRandom = new SecureRandom(); + String provider = secureRandom.getProvider().getName(); + if (OS_NAME.startsWith(SUNOS)) { + if (!provider.startsWith("SunPKCS11-")) { + throw new RuntimeException("Unexpected provider name: " + + provider); + } + } else if (!provider.equals("SUN")) { + throw new RuntimeException("Unexpected provider name: " + + provider); + } + out.println("Passed, default provider with constructor: " + provider); + + /* Test default provider with getInstance(String algorithm) */ + out.println("TEST: SHA1PRNG supported on all platforms by SUN provider"); + String algorithm = "SHA1PRNG"; + provider = "SUN"; + + SecureRandom instance = SecureRandom.getInstance(algorithm); + assertInstance(instance, algorithm, provider); + out.println("Passed."); + + if (!OS_NAME.startsWith(WINDOWS)) { + out.println("TEST: NativePRNG supported on all platforms" + + "(except Windows), by SUN provider"); + algorithm = "NativePRNG"; + provider = "SUN"; + } else { + out.println( + "TEST: Windows-PRNG supported on windows by SunMSCAPI provider"); + algorithm = "Windows-PRNG"; + provider = "SunMSCAPI"; + } + instance = SecureRandom.getInstance(algorithm); + assertInstance(instance, algorithm, provider); + out.println("Passed."); + + if (OS_NAME.startsWith(SUNOS)) { + out.println( + "TEST: PKCS11 is supported on Solaris by SunPKCS11 provider"); + algorithm = "PKCS11"; + provider = "SunPKCS11-Solaris"; + instance = SecureRandom.getInstance(algorithm); + assertInstance(instance, algorithm, provider); + out.println("Passed."); + } + } + + private static void assertInstance(SecureRandom instance, + String expectedAlgorithm, + String expectedProvider) { + if (instance != null) { + if (!expectedAlgorithm.equalsIgnoreCase(instance.getAlgorithm())) { + throw new RuntimeException("Expected algorithm:" + + expectedAlgorithm + " actual: " + instance.getAlgorithm()); + } + + if (!expectedProvider.equalsIgnoreCase(instance.getProvider().getName())) { + throw new RuntimeException("Expected provider: " + + expectedProvider + " actual: " + + instance.getProvider().getName()); + } + } else { + throw new RuntimeException("Secure instance is not created"); + } + } +} diff --git a/jdk/test/java/time/tck/java/time/TCKDuration.java b/jdk/test/java/time/tck/java/time/TCKDuration.java index c12e914b91f..fe6a9f98088 100644 --- a/jdk/test/java/time/tck/java/time/TCKDuration.java +++ b/jdk/test/java/time/tck/java/time/TCKDuration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -521,6 +521,8 @@ public class TCKDuration extends AbstractTCKTest { {"PT-123456789S", -123456789, 0}, {"PT" + Long.MIN_VALUE + "S", Long.MIN_VALUE, 0}, + + {"PT0.1S", 0, 100000000}, {"PT1.1S", 1, 100000000}, {"PT1.12S", 1, 120000000}, {"PT1.123S", 1, 123000000}, @@ -531,6 +533,7 @@ public class TCKDuration extends AbstractTCKTest { {"PT1.12345678S", 1, 123456780}, {"PT1.123456789S", 1, 123456789}, + {"PT-0.1S", -1, 1000000000 - 100000000}, {"PT-1.1S", -2, 1000000000 - 100000000}, {"PT-1.12S", -2, 1000000000 - 120000000}, {"PT-1.123S", -2, 1000000000 - 123000000}, @@ -544,6 +547,24 @@ public class TCKDuration extends AbstractTCKTest { {"PT" + Long.MAX_VALUE + ".123456789S", Long.MAX_VALUE, 123456789}, {"PT" + Long.MIN_VALUE + ".000000000S", Long.MIN_VALUE, 0}, + {"PT12M", 12 * 60, 0}, + {"PT12M0.35S", 12 * 60, 350000000}, + {"PT12M1.35S", 12 * 60 + 1, 350000000}, + {"PT12M-0.35S", 12 * 60 - 1, 1000000000 - 350000000}, + {"PT12M-1.35S", 12 * 60 - 2, 1000000000 - 350000000}, + + {"PT12H", 12 * 3600, 0}, + {"PT12H0.35S", 12 * 3600, 350000000}, + {"PT12H1.35S", 12 * 3600 + 1, 350000000}, + {"PT12H-0.35S", 12 * 3600 - 1, 1000000000 - 350000000}, + {"PT12H-1.35S", 12 * 3600 - 2, 1000000000 - 350000000}, + + {"P12D", 12 * 24 * 3600, 0}, + {"P12DT0.35S", 12 * 24 * 3600, 350000000}, + {"P12DT1.35S", 12 * 24 * 3600 + 1, 350000000}, + {"P12DT-0.35S", 12 * 24 * 3600 - 1, 1000000000 - 350000000}, + {"P12DT-1.35S", 12 * 24 * 3600 - 2, 1000000000 - 350000000}, + {"PT01S", 1, 0}, {"PT001S", 1, 0}, {"PT000S", 0, 0}, diff --git a/jdk/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java b/jdk/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java index 11e2dcd9620..c1656885c07 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java +++ b/jdk/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java @@ -156,6 +156,7 @@ public class TCKZoneIdPrinterParser { {"UTC", 3, -1, ZoneId.of("UTC"), false}, {"UT", 2, -1, ZoneId.of("UT"), false}, {"GMT", 3, -1, ZoneId.of("GMT"), false}, + {"GMT0", 4, -1, ZoneId.of("GMT0"), false}, {"+00:00", 6, -1, ZoneOffset.UTC, true}, {"UTC+00:00", 9, -1, ZoneId.of("UTC"), false}, diff --git a/jdk/test/java/time/test/java/time/temporal/TestIsoWeekFields.java b/jdk/test/java/time/test/java/time/temporal/TestIsoWeekFields.java index d79d13f89a3..672295e4def 100644 --- a/jdk/test/java/time/test/java/time/temporal/TestIsoWeekFields.java +++ b/jdk/test/java/time/test/java/time/temporal/TestIsoWeekFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014,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 @@ -121,6 +121,14 @@ public class TestIsoWeekFields { assertEquals(IsoFields.WEEK_BASED_YEAR.isSupportedBy(ThaiBuddhistDate.now()), false); } + @Test + public void test_Unit_isSupportedBy_ISO() { + assertEquals(IsoFields.WEEK_BASED_YEARS.isSupportedBy(LocalDate.now()),true); + assertEquals(IsoFields.WEEK_BASED_YEARS.isSupportedBy(ThaiBuddhistDate.now()),false); + assertEquals(IsoFields.QUARTER_YEARS.isSupportedBy(LocalDate.now()),true); + assertEquals(IsoFields.QUARTER_YEARS.isSupportedBy(ThaiBuddhistDate.now()),false); + } + @Test(dataProvider = "fields") public void test_WBY_range(TemporalField weekField, TemporalField yearField) { assertEquals(yearField.range(), ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE)); diff --git a/jdk/test/java/util/Objects/BasicObjectsTest.java b/jdk/test/java/util/Objects/BasicObjectsTest.java index 878bb825019..a7636ef11d5 100644 --- a/jdk/test/java/util/Objects/BasicObjectsTest.java +++ b/jdk/test/java/util/Objects/BasicObjectsTest.java @@ -241,12 +241,12 @@ public class BasicObjectsTest { String nonNullString = "non-null"; // Confirm the compile time return type matches - String result = Objects.nonNullElse(nullString, defString); + String result = Objects.requireNonNullElse(nullString, defString); errors += (result == defString) ? 0 : 1; - errors += (Objects.nonNullElse(nonNullString, defString) == nonNullString) ? 0 : 1; - errors += (Objects.nonNullElse(nonNullString, null) == nonNullString) ? 0 : 1; + errors += (Objects.requireNonNullElse(nonNullString, defString) == nonNullString) ? 0 : 1; + errors += (Objects.requireNonNullElse(nonNullString, null) == nonNullString) ? 0 : 1; try { - Objects.nonNullElse(null, null); + Objects.requireNonNullElse(null, null); errors += 1; } catch (NullPointerException npe) { // expected @@ -254,20 +254,20 @@ public class BasicObjectsTest { } - // Test nonNullElseGet with a supplier - errors += (Objects.nonNullElseGet(nullString, () -> defString) == defString) ? 0 : 1; - errors += (Objects.nonNullElseGet(nonNullString, () -> defString) == nonNullString) ? 0 : 1; - errors += (Objects.nonNullElseGet(nonNullString, () -> null) == nonNullString) ? 0 : 1; + // Test requireNonNullElseGet with a supplier + errors += (Objects.requireNonNullElseGet(nullString, () -> defString) == defString) ? 0 : 1; + errors += (Objects.requireNonNullElseGet(nonNullString, () -> defString) == nonNullString) ? 0 : 1; + errors += (Objects.requireNonNullElseGet(nonNullString, () -> null) == nonNullString) ? 0 : 1; try { - Objects.nonNullElseGet(null, () -> null); + Objects.requireNonNullElseGet(null, () -> null); errors += 1; } catch (NullPointerException npe) { // expected errors += npe.getMessage().equals("supplier.get()") ? 0 : 1; } try { // supplier is null - Objects.nonNullElseGet(null, null); + Objects.requireNonNullElseGet(null, null); errors += 1; } catch (NullPointerException npe) { // expected diff --git a/jdk/test/java/util/concurrent/Phaser/Basic.java b/jdk/test/java/util/concurrent/Phaser/Basic.java index 401b983e189..c516a969b39 100644 --- a/jdk/test/java/util/concurrent/Phaser/Basic.java +++ b/jdk/test/java/util/concurrent/Phaser/Basic.java @@ -34,6 +34,7 @@ /* * @test * @bug 6445158 + * @key intermittent * @summary Basic tests for Phaser * @author Chris Hegarty */ diff --git a/jdk/test/java/util/zip/TestLocalTime.java b/jdk/test/java/util/zip/TestLocalTime.java index 47d3e81d226..d1909afba54 100644 --- a/jdk/test/java/util/zip/TestLocalTime.java +++ b/jdk/test/java/util/zip/TestLocalTime.java @@ -21,9 +21,10 @@ * questions. */ -/** +/* * @test * @bug 8075526 + * @key intermittent * @summary Test timestamp via ZipEntry.get/setTimeLocal() */ diff --git a/jdk/test/sun/security/jca/PreferredProviderNegativeTest.java b/jdk/test/sun/security/jca/PreferredProviderNegativeTest.java new file mode 100644 index 00000000000..5d69d998eb9 --- /dev/null +++ b/jdk/test/sun/security/jca/PreferredProviderNegativeTest.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 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 + * 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 8076359 8133151 + * @summary Test for jdk.security.provider.preferred security property + * @requires os.name == "SunOS" + * @run main/othervm PreferredProviderNegativeTest preJCESet AES:OracleUcrypto false + * @run main/othervm PreferredProviderNegativeTest preJCESet AES:SunNegative true + * @run main/othervm PreferredProviderNegativeTest afterJCESet AES:SunJGSS + * @run main/othervm PreferredProviderNegativeTest afterJCESet AES:SunECNegative + * @run main/othervm PreferredProviderNegativeTest invalidAlg AESNegative:SunJCE + */ + +import java.security.Security; +import java.security.NoSuchAlgorithmException; +import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; + +public class PreferredProviderNegativeTest { + + /* + * Test security property could be set by valid and invalid provider + * before JCE was loaded + */ + public static void preJCESet(String value, boolean negativeProvider) + throws NoSuchAlgorithmException, NoSuchPaddingException { + Security.setProperty("jdk.security.provider.preferred", value); + + if (!Security.getProperty("jdk.security.provider.preferred") + .equals(value)) { + throw new RuntimeException( + "Test Failed:The property wasn't set"); + } + + String[] arrays = value.split(":"); + Cipher cipher = Cipher.getInstance(arrays[0]); + + if (negativeProvider) { + if (cipher.getProvider().getName().equals(arrays[1])) { + throw new RuntimeException( + "Test Failed:The provider shouldn't be set"); + } + } else { + if (!cipher.getProvider().getName().equals(arrays[1])) { + throw new RuntimeException( + "Test Faild:The provider could be set " + + "by valid provider "); + } + } + System.out.println("Test Pass"); + } + + /* + * Test that the setting of the security property after Cipher.getInstance() + * does not influence previously loaded instances + */ + public static void afterJCESet(String value) + throws NoSuchAlgorithmException, NoSuchPaddingException { + String[] arrays = value.split(":"); + Cipher cipher = Cipher.getInstance(arrays[0]); + + Security.setProperty("jdk.security.provider.preferred", value); + if (!cipher.getProvider().getName().equals("SunJCE")) { + throw new RuntimeException( + "Test Failed:The security property can't be updated after JCE load."); + } + System.out.println("Test Pass"); + } + + /* Test the security property with negative algorithm */ + public static void invalidAlg(String value) throws NoSuchPaddingException { + String[] arrays = value.split(":"); + + try { + Security.setProperty("jdk.security.provider.preferred", value); + Cipher.getInstance(arrays[0]); + } catch (NoSuchAlgorithmException e) { + System.out.println("Test Pass:Got NoSuchAlgorithmException as expired"); + return; + } + throw new RuntimeException( + "Test Failed:Expected NoSuchAlgorithmException was not thrown"); + } + + public static void main(String[] args) + throws NoSuchAlgorithmException, NoSuchPaddingException { + boolean negativeProvider; + + if (args.length >= 2) { + switch (args[0]) { + case "preJCESet": + negativeProvider = Boolean.valueOf(args[2]); + PreferredProviderNegativeTest.preJCESet(args[1], negativeProvider); + break; + case "afterJCESet": + PreferredProviderNegativeTest.afterJCESet(args[1]); + break; + case "invalidAlg": + PreferredProviderNegativeTest.invalidAlg(args[1]); + break; + } + } else { + throw new RuntimeException( + "Test Failed:Please pass the correct args"); + } + } +} + diff --git a/jdk/test/sun/security/jca/PreferredProviderTest.java b/jdk/test/sun/security/jca/PreferredProviderTest.java new file mode 100644 index 00000000000..7120817a1b5 --- /dev/null +++ b/jdk/test/sun/security/jca/PreferredProviderTest.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 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 + * 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 8076359 8133151 + * @summary Test the value for new jdk.security.provider.preferred security property + * @requires os.name == "SunOS" + */ + +import java.security.KeyFactory; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.Security; +import java.util.Arrays; +import java.util.List; +import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; + +public class PreferredProviderTest { + + private static final List SPARC_DATA = Arrays.asList( + new DataTuple("SHA-256", "SUN"), new DataTuple("SHA-384", "SUN"), + new DataTuple("SHA-512", "SUN")); + private static final List X86_DATA = Arrays + .asList(new DataTuple("RSA", "SunRsaSign")); + + public void RunTest(String type) + throws NoSuchAlgorithmException, NoSuchPaddingException { + String preferredProvider = Security + .getProperty("jdk.security.provider.preferred"); + String actualProvider = null; + if (type.equals("sparcv9")) { + if (!preferredProvider.equals( + "AES:SunJCE, SHA-256:SUN, SHA-384:SUN, SHA-512:SUN")) { + throw new RuntimeException( + "Test Failed: wrong jdk.security.provider.preferred " + + "value on solaris-sparcv9"); + } + for (DataTuple dataTuple : SPARC_DATA) { + MessageDigest md = MessageDigest + .getInstance(dataTuple.algorithm); + actualProvider = md.getProvider().getName(); + if (!actualProvider.equals(dataTuple.provider)) { + throw new RuntimeException(String.format( + "Test Failed:Got wrong " + + "provider from Solaris-sparcv9 platform," + + "Expected Provider: %s, Returned Provider: %s", + dataTuple.provider, actualProvider)); + } + } + } else if (type.equals("amd64")) { + if (!preferredProvider.equals("AES:SunJCE, RSA:SunRsaSign")) { + throw new RuntimeException( + "Test Failed: wrong jdk.security.provider.preferred " + + "value on solaris-x86"); + } + for (DataTuple dataTuple : X86_DATA) { + KeyFactory keyFactory = KeyFactory + .getInstance(dataTuple.algorithm); + actualProvider = keyFactory.getProvider().getName(); + if (!actualProvider.equals(dataTuple.provider)) { + throw new RuntimeException(String.format( + "Test Failed:Got wrong " + + "provider from Solaris-x86 platform," + + "Expected Provider: %s, Returned Provider: %s", + dataTuple.provider, actualProvider)); + } + } + } else { + throw new RuntimeException("Test Failed: wrong platform value"); + } + + Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); + actualProvider = cipher.getProvider().getName(); + if (!actualProvider.equals("SunJCE")) { + throw new RuntimeException(String.format( + "Test Failed:Got wrong provider from Solaris-%s platform, " + + "Expected Provider: SunJCE, Returned Provider: %s", + type, actualProvider)); + } + + MessageDigest md = MessageDigest.getInstance("MD5"); + actualProvider = md.getProvider().getName(); + if (!actualProvider.equals("OracleUcrypto")) { + throw new RuntimeException(String.format( + "Test Failed:Got wrong provider from Solaris-%s platform," + + "Expected Provider: OracleUcrypto, Returned Provider: %s", + type, actualProvider)); + } + } + + private static class DataTuple { + private final String provider; + private final String algorithm; + + private DataTuple(String algorithm, String provider) { + this.algorithm = algorithm; + this.provider = provider; + } + } + + public static void main(String[] args) + throws NoSuchAlgorithmException, NoSuchPaddingException { + + String arch = System.getProperty("os.arch"); + PreferredProviderTest pp = new PreferredProviderTest(); + pp.RunTest(arch); + } +} +