Merge
authorprr
Thu, 15 Mar 2018 11:36:11 -0700
changeset 49297 ac821c698c3a
parent 49296 16596ba0b52c (current diff)
parent 49253 26f624b33218 (diff)
child 49298 9f19db69967a
Merge
make/lib/LibosxLibraries.gmk
make/lib/NetworkingLibraries.gmk
make/lib/NioLibraries.gmk
make/lib/PlatformLibraries.gmk
make/lib/SecurityLibraries.gmk
--- a/make/UpdateX11Wrappers.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/UpdateX11Wrappers.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -78,7 +78,7 @@
     EXTRA_FILES := $(X11WRAPPERS_OUTPUT)/src/data_generator.c, \
     CFLAGS := $(X_CFLAGS) $(DATA_GENERATOR_INCLUDES) $(CFLAGS_JDKEXE), \
     LDFLAGS := $(LDFLAGS_JDKEXE), \
-    LIBS := $(X_LIBS) -lc, \
+    LIBS := $(X_LIBS), \
     OBJECT_DIR := $(X11WRAPPERS_OUTPUT)/objs, \
 ))
 
--- a/make/autoconf/libraries.m4	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/autoconf/libraries.m4	Thu Mar 15 11:36:11 2018 -0700
@@ -103,16 +103,15 @@
   LIB_SETUP_SOLARIS_STLPORT
 
   if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
-    ALWAYS_LIBS="-lc"
+    GLOBAL_LIBS="-lc"
   else
-    ALWAYS_LIBS=""
+    GLOBAL_LIBS=""
   fi
 
   BASIC_JDKLIB_LIBS=""
   if test "x$TOOLCHAIN_TYPE" != xmicrosoft; then
     BASIC_JDKLIB_LIBS="-ljava -ljvm"
   fi
-  BASIC_JDKLIB_LIBS="$BASIC_JDKLIB_LIBS $ALWAYS_LIBS"
 
   # Math library
   if test "x$OPENJDK_TARGET_OS" != xsolaris; then
@@ -150,7 +149,6 @@
         comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \
         wsock32.lib winmm.lib version.lib psapi.lib"
   fi
-  BASIC_JVM_LIBS="$BASIC_JVM_LIBS $ALWAYS_LIBS"
 
   JDKLIB_LIBS="$BASIC_JDKLIB_LIBS"
   JDKEXE_LIBS=""
@@ -163,6 +161,7 @@
   AC_SUBST(JVM_LIBS)
   AC_SUBST(OPENJDK_BUILD_JDKLIB_LIBS)
   AC_SUBST(OPENJDK_BUILD_JVM_LIBS)
+  AC_SUBST(GLOBAL_LIBS)
 ])
 
 ################################################################################
--- a/make/autoconf/spec.gmk.in	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/autoconf/spec.gmk.in	Thu Mar 15 11:36:11 2018 -0700
@@ -467,6 +467,7 @@
 # LDFLAGS used to link the jdk native libraries (C-code)
 LDFLAGS_JDKLIB:=@LDFLAGS_JDKLIB@
 JDKLIB_LIBS:=@JDKLIB_LIBS@
+GLOBAL_LIBS:=@GLOBAL_LIBS@
 
 # LDFLAGS used to link the jdk native launchers (C-code)
 LDFLAGS_JDKEXE:=@LDFLAGS_JDKEXE@
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/common/JdkNativeCompilation.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -0,0 +1,119 @@
+#
+# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+ifndef _JDK_NATIVE_COMPILATION_GMK
+_JDK_NATIVE_COMPILATION_GMK := 1
+
+ifeq ($(_MAKEBASE_GMK), )
+  $(error You must include MakeBase.gmk prior to including JdkNativeCompilation.gmk)
+endif
+
+include NativeCompilation.gmk
+
+# Setup make rules for creating a native shared library with suitable defaults
+# for the OpenJDK project.
+#
+# 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 are all passed on to
+# SetupNativeCompilation, except for 
+#   EXTRA_RC_FLAGS -- additional RC_FLAGS to append.
+SetupJdkLibrary = $(NamedParamsMacroTemplate)
+define SetupJdkLibraryBody
+  ifeq ($$($1_OUTPUT_DIR), )
+    $1_OUTPUT_DIR := $$(call FindLibDirForModule, $$(MODULE))
+  endif
+
+  ifeq ($$($1_OBJECT_DIR), )
+    $1_OBJECT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/lib$$($1_NAME)
+  endif
+
+  ifeq ($$($1_VERSIONINFO_RESOURCE), )
+    $1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
+  else ifeq ($$($1_VERSIONINFO_RESOURCE), DISABLE)
+    $1_VERSIONINFO_RESOURCE :=
+  endif
+
+  ifeq ($$($1_RC_FLAGS), )
+    $1_RC_FLAGS :=  $(RC_FLAGS) \
+        -D "JDK_FNAME=$$($1_NAME).dll" \
+        -D "JDK_INTERNAL_NAME=$$($1_NAME)" \
+        -D "JDK_FTYPE=0x2L"
+  else ifeq ($$($1_RC_FLAGS), DISABLE)
+    $1_RC_FLAGS :=
+  endif
+
+  $1_RC_FLAGS += $$($1_EXTRA_RC_FLAGS)
+
+  # Since we reuse the rule name ($1), all our arguments will pass through.
+  # We lose in transparency, but gain in brevity in this call...
+  $$(eval $$(call SetupNativeCompilation, $1, ))
+endef
+
+# Setup make rules for creating a native executable with suitable defaults for
+# the OpenJDK project.
+#
+# 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 are all passed on to
+# SetupNativeCompilation, except for 
+#   EXTRA_RC_FLAGS -- additional RC_FLAGS to append.
+SetupJdkExecutable = $(NamedParamsMacroTemplate)
+define SetupJdkExecutableBody
+  $1_TYPE := EXECUTABLE
+
+  ifeq ($$($1_OUTPUT_DIR), )
+    $1_OUTPUT_DIR := $$(call FindExecutableDirForModule, $$(MODULE))
+  endif
+
+  ifeq ($$($1_OBJECT_DIR), )
+    $1_OBJECT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/$$($1_NAME)
+  endif
+
+  ifeq ($$($1_VERSIONINFO_RESOURCE), )
+    $1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
+  else ifeq ($$($1_VERSIONINFO_RESOURCE), DISABLE)
+    $1_VERSIONINFO_RESOURCE :=
+  endif
+
+  ifeq ($$($1_RC_FLAGS), )
+    $1_RC_FLAGS :=  $(RC_FLAGS) \
+        -D "JDK_FNAME=$$($1_NAME).exe" \
+        -D "JDK_INTERNAL_NAME=$$($1_NAME)" \
+        -D "JDK_FTYPE=0x01L"
+  else ifeq ($$($1_RC_FLAGS), DISABLE)
+    $1_RC_FLAGS :=
+  endif
+
+  $1_RC_FLAGS += $$($1_EXTRA_RC_FLAGS)
+
+  # Since we reuse the rule name ($1), all our arguments will pass through.
+  # We lose in transparency, but gain in brevity in this call...
+  $$(eval $$(call SetupNativeCompilation, $1))
+endef
+
+endif # _JDK_NATIVE_COMPILATION_GMK
--- a/make/common/MakeBase.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/common/MakeBase.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -1027,6 +1027,12 @@
     $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
 
 ################################################################################
+# Find executable dir for module
+# Param 1 - module name
+FindExecutableDirForModule = \
+    $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1)
+
+################################################################################
 # Return a string suitable for use after a -classpath or --module-path option. It
 # will be correct and safe to use on all platforms. Arguments are given as space
 # separate classpath entries. Safe for multiple nested calls.
--- a/make/common/NativeCompilation.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/common/NativeCompilation.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -735,7 +735,7 @@
 		$$(call MakeDir, $$(@D) $$($1_OBJECT_DIR))
 		$$(call ExecuteWithLog, $$@, \
 		    $$($1_RC) $$($1_RC_FLAGS) $$($1_SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
-		    $$($1_VERSIONINFO_RESOURCE))
+		    $$($1_VERSIONINFO_RESOURCE) 2>&1 )
                 # Windows RC compiler does not support -showIncludes, so we mis-use CL
                 # for this. Filter out RC specific arguments that are unknown to CL.
                 # For some unknown reason, in this case CL actually outputs the show
@@ -746,7 +746,7 @@
 		        $$($1_SYSROOT_CFLAGS) -showIncludes -nologo -TC \
 		        $(CC_OUT_OPTION)$$($1_RES_DEP).obj -P -Fi$$($1_RES_DEP).pp \
 		        $$($1_VERSIONINFO_RESOURCE)) 2>&1 \
-		    | $(GREP) -v -e "^Note: including file:" \
+		    | $(TR) -d '\r' | $(GREP) -v -e "^Note: including file:" \
 		        -e "^$$(notdir $$($1_VERSIONINFO_RESOURCE))$$$$" || test "$$$$?" = "1" ; \
 		$(ECHO) $$($1_RES): \\ > $$($1_RES_DEP) ; \
 		$(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).obj.log >> $$($1_RES_DEP) ; \
@@ -870,7 +870,7 @@
     endif
 
     $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
-        $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_CREATE_DEBUGINFO_CMDS) \
+        $$(GLOBAL_LIBS) $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_CREATE_DEBUGINFO_CMDS) \
         $$($1_STRIP_CMD)
     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
         $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
@@ -924,8 +924,8 @@
                 ifeq ($(OPENJDK_TARGET_OS), windows)
 		  $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
 		      $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
-		      $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \
-		      $$($1_EXTRA_LIBS)) \
+		      $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
+		      $$($1_LIBS) $$($1_EXTRA_LIBS)) \
 		      | $(GREP) -v "^   Creating library .*\.lib and object .*\.exp" || \
 		      test "$$$$?" = "1" ; \
 		  $$($1_CREATE_DEBUGINFO_CMDS)
@@ -934,8 +934,8 @@
 		  $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \
 		      $$(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \
 		      $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
-		      $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$($1_LIBS) \
-		      $$($1_EXTRA_LIBS)) ; \
+		      $(LD_OUT_OPTION)$$@ $$($1_LD_OBJ_ARG) $$($1_RES) $$(GLOBAL_LIBS) \
+		      $$($1_LIBS) $$($1_EXTRA_LIBS)) ; \
 		  $$($1_CREATE_DEBUGINFO_CMDS)
 		  $$($1_STRIP_CMD)
                 endif
@@ -972,7 +972,7 @@
   ifeq ($$($1_TYPE), EXECUTABLE)
     # A executable binary has been specified, setup the target for it.
     $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
-        $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \
+        $$(GLOBAL_LIBS) $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \
         $$($1_CODESIGN) $$($1_CREATE_DEBUGINFO_CMDS) $$($1_MANIFEST_VERSION) \
         $$($1_STRIP_CMD)
     $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
@@ -991,7 +991,7 @@
 		    $$($1_LD) $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) $$($1_SYSROOT_LDFLAGS) \
 		        $(EXE_OUT_OPTION)$$($1_TARGET) \
 		        $$($1_ALL_OBJS) $$($1_RES) \
-		        $$($1_LIBS) $$($1_EXTRA_LIBS))
+		        $$(GLOBAL_LIBS) $$($1_LIBS) $$($1_EXTRA_LIBS))
                 ifeq ($(OPENJDK_TARGET_OS), windows)
                   ifneq ($$($1_MANIFEST), )
 		    $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1
--- a/make/common/TestFilesCompilation.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/common/TestFilesCompilation.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -44,6 +44,7 @@
 #   TYPE Must be either PROGRAM or LIBRARY.
 #   SOURCE_DIRS A list of source directories to search
 #   OUTPUT_DIR Where to put the resulting files
+#   EXCLUDE A list of filenames to exclude from compilation
 SetupTestFilesCompilation = $(NamedParamsMacroTemplate)
 define SetupTestFilesCompilationBody
 
@@ -76,20 +77,23 @@
   $1_FILE_LIST := \
       $$(shell $$(FIND) $$($1_SOURCE_DIRS) -type f -name "$$($1_PREFIX)*.c")
 
+  $1_EXCLUDE_PATTERN := $$(addprefix %/, $$($1_EXCLUDE))
+  $1_FILTERED_FILE_LIST := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_FILE_LIST))
+
   # Setup a compilation for each and every one of them
-  $$(foreach file, $$($1_FILE_LIST),\
-    $$(eval name := $$(strip $$(patsubst $$($1_PREFIX)%, %, $$(basename $$(notdir $$(file)))))) \
+  $$(foreach file, $$($1_FILTERED_FILE_LIST),\
+    $$(eval name := $$(strip $$(basename $$(notdir $$(file))))) \
+    $$(eval unprefixed_name := $$(patsubst $$($1_PREFIX)%, %, $$(name))) \
     $$(eval $$(call SetupNativeCompilation, BUILD_TEST_$$(name), \
-        NAME := $$(name), \
+        NAME := $$(unprefixed_name), \
         TYPE := $$($1_COMPILATION_TYPE), \
         SRC := $$(patsubst %/,%,$$(dir $$(file))), \
         INCLUDE_FILES := $$(notdir $$(file)), \
-        OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$($1_PREFIX)$$(name), \
+        OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$(name), \
         OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \
-        LANG := C, \
-        CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$($1_PREFIX)$$(name)), \
-        LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$($1_PREFIX)$$(name)), \
-        LIBS := $$($1_LIBS_$$($1_PREFIX)$$(name)), \
+        CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
+        LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$(name)), \
+        LIBS := $$($1_LIBS_$$(name)), \
         OPTIMIZATION := LOW, \
         COPY_DEBUG_SYMBOLS := false, \
         STRIP_SYMBOLS := false, \
--- a/make/conf/jib-profiles.js	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/conf/jib-profiles.js	Thu Mar 15 11:36:11 2018 -0700
@@ -528,6 +528,32 @@
         profiles[debugName] = concatObjects(profiles[name],
                                             common.slowdebug_profile_base);
     });
+    // Generate testmake profiles for the main profile of each build host
+    // platform. This profile only runs the makefile tests.
+    // Ant is needed to run the idea project generator test.
+    var testmakeBase = {
+        dependencies: [ "ant" ],
+        environment: {
+            "ANT_HOME": input.get("ant", "install_path") + "/apache-ant-1.7.1"
+        }
+    };
+    [ "linux-x64", "macosx-x64", "solaris-sparcv9", "solaris-x64", "windows-x64"]
+        .forEach(function (name) {
+            var maketestName = name + "-testmake";
+            profiles[maketestName] = concatObjects(profiles[name], testmakeBase);
+            profiles[maketestName].default_make_targets = [ "test-make" ];
+        });
+    // Generate cmp-baseline profiles for each main profile. This profile does
+    // a compare build run with no changes to verify that the compare script
+    // has a clean baseline
+    common.main_profile_names.forEach(function (name) {
+        var cmpBaselineName = name + "-cmp-baseline";
+        profiles[cmpBaselineName] = clone(profiles[name]);
+        // Only compare the images target. This should pressumably be expanded
+        // to include more build targets when possible.
+        profiles[cmpBaselineName].default_make_targets = [ "images" ];
+        profiles[cmpBaselineName].make_args = [ "COMPARE_BUILD=CONF=" ];
+    });
 
     // Profiles for building the zero jvm variant. These are used for verification
     // in JPRT.
@@ -913,7 +939,15 @@
             environment_name: "JIB_JAR",
             environment_value: input.get("jib", "install_path")
                 + "/jib-3.0-SNAPSHOT-distribution/lib/jib-3.0-SNAPSHOT.jar"
-       }
+        },
+
+        ant: {
+            organization: common.organization,
+            ext: "zip",
+            revision: "1.7.1+1.0",
+            configure_args: "",
+        },
+
     };
 
     // Need to add a value for the Visual Studio tools variable to make
--- a/make/hotspot/lib/CompileDtracePostJvm.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/hotspot/lib/CompileDtracePostJvm.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -175,7 +175,7 @@
         SRC := $(TOPDIR)/src/java.base/solaris/native/libjvm_dtrace, \
         CFLAGS := -m64 -G -mt -KPIC, \
         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
-        LIBS := $(LIBDL) -lc -lthread -ldoor, \
+        LIBS := $(LIBDL) -lthread -ldoor, \
         MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_dtrace/mapfile-vers, \
         OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \
     ))
@@ -191,7 +191,6 @@
         CFLAGS := -I$(JVM_VARIANT_OUTPUTDIR)/gensrc -I$(DTRACE_SUPPORT_DIR) \
             -m64 -G -mt -KPIC, \
         LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \
-        LIBS := -lc, \
         MAPFILE := $(TOPDIR)/make/mapfiles/libjvm_db/mapfile-vers, \
         OBJECT_DIR := $(LIBJVM_DB_OUTPUTDIR)/objs, \
     ))
--- a/make/launcher/Launcher-java.base.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/launcher/Launcher-java.base.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -27,8 +27,8 @@
 
 $(eval $(call IncludeCustomExtension, launcher/Launcher-java.base.gmk))
 
-JAVA_RC_FLAGS += -I $(TOPDIR)/src/java.base/windows/native/common
-JAVA_RC_FLAGS += -I $(TOPDIR)/src/java.base/windows/native/launcher/icons
+JAVA_RC_FLAGS += -I$(TOPDIR)/src/java.base/windows/native/common
+JAVA_RC_FLAGS += -I$(TOPDIR)/src/java.base/windows/native/launcher/icons
 
 ################################################################################
 
@@ -39,7 +39,7 @@
     CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \
     LDFLAGS_solaris := -R$(OPENWIN_HOME)/lib$(OPENJDK_TARGET_CPU_ISADIR), \
     LIBS_windows := user32.lib comctl32.lib, \
-    RC_FLAGS := $(JAVA_RC_FLAGS), \
+    EXTRA_RC_FLAGS := $(JAVA_RC_FLAGS), \
     VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
     OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/java_objs, \
     OPTIMIZATION := HIGH, \
@@ -58,7 +58,7 @@
   $(eval $(call SetupBuildLauncher, javaw, \
       CFLAGS := -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \
       LIBS_windows := user32.lib comctl32.lib, \
-      RC_FLAGS := $(JAVA_RC_FLAGS), \
+      EXTRA_RC_FLAGS := $(JAVA_RC_FLAGS), \
       VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
       WINDOWS_STATIC_LINK := true, \
       NO_JAVA_MS := true, \
@@ -72,9 +72,8 @@
 ################################################################################
 
 ifeq ($(OPENJDK_TARGET_OS), linux)
-  $(eval $(call SetupNativeCompilation, BUILD_JEXEC, \
+  $(eval $(call SetupJdkExecutable, BUILD_JEXEC, \
       NAME := jexec, \
-      TYPE := EXECUTABLE, \
       SRC := $(TOPDIR)/src/$(MODULE)/unix/native/launcher, \
       INCLUDE_FILES := jexec.c, \
       OPTIMIZATION := LOW, \
@@ -83,7 +82,6 @@
       CFLAGS_linux := -fPIC, \
       CFLAGS_solaris := -KPIC, \
       LDFLAGS := $(LDFLAGS_JDKEXE), \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/jexec_obj, \
       OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
   ))
 
@@ -93,15 +91,13 @@
 ################################################################################
 
 ifneq ($(findstring $(OPENJDK_TARGET_OS), macosx solaris aix), )
-  $(eval $(call SetupNativeCompilation, BUILD_JSPAWNHELPER, \
+  $(eval $(call SetupJdkExecutable, BUILD_JSPAWNHELPER, \
       NAME := jspawnhelper, \
-      TYPE := EXECUTABLE, \
       SRC := $(TOPDIR)/src/$(MODULE)/unix/native/jspawnhelper, \
       OPTIMIZATION := LOW, \
       CFLAGS := $(CFLAGS_JDKEXE) -I$(TOPDIR)/src/$(MODULE)/unix/native/libjava, \
       EXTRA_OBJECT_FILES := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjava/childproc.o, \
       LDFLAGS := $(LDFLAGS_JDKEXE), \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/jspawnhelper, \
       OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
   ))
 
--- a/make/launcher/Launcher-jdk.accessibility.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/launcher/Launcher-jdk.accessibility.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -33,9 +33,8 @@
   JABSWITCH_SRC := $(TOPDIR)/src/jdk.accessibility/windows/native/jabswitch
   ACCESSBRIDGE_SRC := $(TOPDIR)/src/jdk.accessibility/windows/native/common
 
-  $(eval $(call SetupNativeCompilation, BUILD_JABSWITCH, \
+  $(eval $(call SetupJdkExecutable, BUILD_JABSWITCH, \
       NAME := jabswitch, \
-      TYPE := EXECUTABLE, \
       SRC := $(JABSWITCH_SRC), \
       INCLUDE_FILES := jabswitch.cpp, \
       CFLAGS := $(filter-out -Zc:wchar_t-, $(CFLAGS_JDKEXE)) -Zc:wchar_t \
@@ -44,13 +43,7 @@
       DISABLED_WARNINGS_microsoft := 4267 4996, \
       LDFLAGS := $(LDFLAGS_JDKEXE), \
       LIBS := advapi32.lib version.lib user32.lib, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/jdk.accessibility/jabswitch, \
-      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/jdk.accessibility, \
       VERSIONINFO_RESOURCE := $(ACCESSBRIDGE_SRC)/AccessBridgeStatusWindow.RC, \
-      RC_FLAGS := $(RC_FLAGS) \
-          -D "JDK_FNAME=jabswitch.exe" \
-          -D "JDK_INTERNAL_NAME=jabswitch" \
-          -D "JDK_FTYPE=0x01L", \
       MANIFEST := $(JABSWITCH_SRC)/jabswitch.manifest, \
       MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \
   ))
@@ -70,21 +63,14 @@
   # Parameter 1 File name suffix
   # Parameter 2 ACCESSBRIDGE_ARCH_ -D suffix
 
-    $$(eval $$(call SetupNativeCompilation, BUILD_JACCESSINSPECTOR$1, \
+    $$(eval $$(call SetupJdkExecutable, BUILD_JACCESSINSPECTOR$1, \
       NAME := jaccessinspector$1, \
-      TYPE := EXECUTABLE, \
       SRC := $(TOPDIR)/jaccessinspector $(TOPDIR)/common \
           $(TOPDIR)/toolscommon $(TOPDIR)/bridge, \
       CFLAGS := $$(CFLAGS_JDKEXE) $(TOOLS_CFLAGS) -DACCESSBRIDGE_ARCH_$2 -EHsc, \
       LDFLAGS := $$(LDFLAGS_JDKEXE) -stack:655360, \
       LIBS := advapi32.lib user32.lib, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/jdk.accessibility/jaccessinspector$1, \
-      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/jdk.accessibility, \
       VERSIONINFO_RESOURCE := $(TOPDIR)/jaccessinspector/jaccessinspectorWindow.rc, \
-      RC_FLAGS := $$(RC_FLAGS) \
-          -D "JDK_FNAME=jaccessinspector$1.exe" \
-          -D "JDK_INTERNAL_NAME=jaccessinspector$1" \
-          -D "JDK_FTYPE=0x01L", \
     ))
 
     TARGETS += $$(BUILD_JACCESSINSPECTOR$1)
@@ -98,21 +84,14 @@
   # Parameter 1 File name suffix
   # Parameter 2 ACCESSBRIDGE_ARCH_ -D suffix
 
-    $$(eval $$(call SetupNativeCompilation, BUILD_JACCESSWALKER$1, \
+    $$(eval $$(call SetupJdkExecutable, BUILD_JACCESSWALKER$1, \
       NAME := jaccesswalker$1, \
-      TYPE := EXECUTABLE, \
       SRC := $(TOPDIR)/jaccesswalker $(TOPDIR)/common \
           $(TOPDIR)/toolscommon $(TOPDIR)/bridge, \
       CFLAGS := $$(CFLAGS_JDKEXE) $(TOOLS_CFLAGS) -DACCESSBRIDGE_ARCH_$2 -EHsc, \
       LDFLAGS := $$(LDFLAGS_JDKEXE) -stack:655360, \
       LIBS := advapi32.lib comctl32.lib gdi32.lib user32.lib, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/jdk.accessibility/jaccesswalker$1, \
-      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/jdk.accessibility, \
       VERSIONINFO_RESOURCE := $(TOPDIR)/jaccesswalker/jaccesswalkerWindow.rc, \
-      RC_FLAGS := $$(RC_FLAGS) \
-          -D "JDK_FNAME=jaccesswalker$1.exe" \
-          -D "JDK_INTERNAL_NAME=jaccesswalker$1" \
-          -D "JDK_FTYPE=0x01L", \
    ))
 
     TARGETS += $$(BUILD_JACCESSWALKER$1)
--- a/make/launcher/Launcher-jdk.pack.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/launcher/Launcher-jdk.pack.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -73,9 +73,8 @@
   UNPACK_MAPFILE := $(UNPACK_MAPFILE_DIR)/mapfile-vers-unpack200
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_UNPACKEXE, \
+$(eval $(call SetupJdkExecutable, BUILD_UNPACKEXE, \
     NAME := unpack200, \
-    TYPE := EXECUTABLE, \
     SRC := $(UNPACKEXE_SRC), \
     TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
     OPTIMIZATION := LOW, \
@@ -90,14 +89,7 @@
         $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LIBS := $(UNPACKEXE_LIBS) $(LIBCXX), \
-    LIBS_solaris :=  -lc, \
     OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpackexe, \
-    OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE), \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=unpack200.exe" \
-        -D "JDK_INTERNAL_NAME=unpack200" \
-        -D "JDK_FTYPE=0x1L", \
     MANIFEST := $(TOPDIR)/src/jdk.pack/windows/native/unpack200/unpack200_proto.exe.manifest, \
     MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \
 ))
--- a/make/launcher/LauncherCommon.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/launcher/LauncherCommon.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -23,7 +23,7 @@
 # questions.
 #
 
-include NativeCompilation.gmk
+include JdkNativeCompilation.gmk
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
   DISABLE_MAPFILES := true
@@ -85,14 +85,6 @@
 SetupBuildLauncher = $(NamedParamsMacroTemplate)
 define SetupBuildLauncherBody
   # Setup default values (unless overridden)
-  ifeq ($$($1_VERSION_INFO_RESOURCE), )
-    $1_VERSION_INFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE)
-  endif
-
-  ifeq ($$($1_OUTPUT_DIR), )
-    $1_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)
-  endif
-
   ifeq ($$($1_OPTIMIZATION), )
     $1_OPTIMIZATION := LOW
   endif
@@ -182,9 +174,8 @@
     endif
   endif
 
-  $$(eval $$(call SetupNativeCompilation, BUILD_LAUNCHER_$1, \
+  $$(eval $$(call SetupJdkExecutable, BUILD_LAUNCHER_$1, \
       NAME := $1, \
-      TYPE := EXECUTABLE, \
       EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \
       OPTIMIZATION := $$($1_OPTIMIZATION), \
       CFLAGS := $$($1_CFLAGS) \
@@ -206,19 +197,14 @@
       MAPFILE := $$($1_MAPFILE), \
       LIBS := $(JDKEXE_LIBS) $$($1_LIBS), \
       LIBS_unix := $$($1_LIBS_unix), \
-      LIBS_linux := -lpthread -ljli $(LIBDL) -lc, \
-      LIBS_solaris := -ljli -lthread $(LIBDL) -lc, \
+      LIBS_linux := -lpthread -ljli $(LIBDL), \
+      LIBS_solaris := -ljli -lthread $(LIBDL), \
       LIBS_windows := $$($1_WINDOWS_JLI_LIB) \
           $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib advapi32.lib \
           $$($1_LIBS_windows), \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/$1_objs, \
       OUTPUT_DIR := $$($1_OUTPUT_DIR), \
       VERSIONINFO_RESOURCE := $$($1_VERSION_INFO_RESOURCE), \
-      RC_FLAGS := $$(RC_FLAGS) \
-          -D "JDK_FNAME=$1$(EXE_SUFFIX)" \
-          -D "JDK_INTERNAL_NAME=$1" \
-          -D "JDK_FTYPE=0x1L" \
-          $$($1_RC_FLAGS), \
+      EXTRA_RC_FLAGS := $$($1_EXTRA_RC_FLAGS), \
       MANIFEST := $(JAVA_MANIFEST), \
       MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \
       CODESIGN := $$($1_CODESIGN), \
--- a/make/lib/Awt2dLibraries.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Awt2dLibraries.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -48,9 +48,8 @@
   BUILD_LIBMLIB_LDLIBS += $(LIBM) $(LIBDL)
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBMLIB_IMAGE, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBMLIB_IMAGE, \
     NAME := mlib_image, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(BUILD_LIBMLIB_SRC), \
     EXCLUDE_FILES := mlib_c_ImageBlendTable.c, \
     OPTIMIZATION := HIGHEST, \
@@ -61,13 +60,6 @@
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LIBS := $(BUILD_LIBMLIB_LDLIBS) \
         $(JDKLIB_LIBS), \
-    LIBS_solaris := -lc, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=mlib_image.dll" \
-        -D "JDK_INTERNAL_NAME=mlib_image" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libmlib_image, \
 ))
 
 $(BUILD_LIBMLIB_IMAGE): $(call FindLib, java.base, java)
@@ -107,9 +99,8 @@
 
   LIBMLIB_IMAGE_V_CFLAGS += $(filter-out -DMLIB_NO_LIBSUNMATH, $(BUILD_LIBMLIB_CFLAGS))
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBMLIB_IMAGE_V, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBMLIB_IMAGE_V, \
       NAME := mlib_image_v, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBMLIB_IMAGE_V_SRC), \
       EXCLUDE_FILES := $(BUILD_LIBMLIB_IMAGE_V_EXFILES), \
       OPTIMIZATION := HIGHEST, \
@@ -119,8 +110,7 @@
       MAPFILE := $(BUILD_LIBMLIB_IMAGE_MAPFILE), \
       LDFLAGS := $(LDFLAGS_JDKLIB) \
           $(call SET_SHARED_LIBRARY_ORIGIN), \
-      LIBS := -ljava -ljvm -lc $(BUILD_LIBMLIB_LDLIBS), \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libmlib_image_v, \
+      LIBS := -ljava -ljvm $(BUILD_LIBMLIB_LDLIBS), \
   ))
 
   $(BUILD_LIBMLIB_IMAGE_V): $(call FindLib, java.base, java)
@@ -226,9 +216,8 @@
   LIBAWT_CFLAGS += -fgcse-after-reload
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBAWT, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBAWT, \
     NAME := awt, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBAWT_DIRS), \
     EXCLUDES := $(LIBAWT_EXCLUDES), \
     EXCLUDE_FILES := $(LIBAWT_EXFILES), \
@@ -250,7 +239,7 @@
         -delayload:comctl32.dll -delayload:shlwapi.dll, \
     LIBS_unix := -ljvm -ljava $(LIBM), \
     LIBS_linux :=  $(LIBDL), \
-    LIBS_solaris := $(LIBDL) -lc, \
+    LIBS_solaris := $(LIBDL), \
     LIBS_aix := $(LIBDL),\
     LIBS_macosx := -lmlib_image \
         -framework Cocoa \
@@ -268,7 +257,6 @@
         -D "JDK_FNAME=awt.dll" \
         -D "JDK_INTERNAL_NAME=awt" \
         -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt, \
 ))
 
 $(BUILD_LIBAWT): $(call FindLib, java.base, java)
@@ -330,7 +318,7 @@
       endif
     endif
 
-    LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm -lc
+    LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm
 
     ifeq ($(OPENJDK_TARGET_OS), linux)
       LIBAWT_XAWT_LIBS += -lpthread
@@ -347,9 +335,8 @@
       BUILD_LIBAWT_XAWT_debug_mem.c_CFLAGS := -w
    endif
 
-    $(eval $(call SetupNativeCompilation, BUILD_LIBAWT_XAWT, \
+    $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_XAWT, \
         NAME := awt_xawt, \
-        OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
         SRC := $(LIBAWT_XAWT_DIRS), \
         EXCLUDES := $(LIBAWT_XAWT_EXCLUDES), \
         OPTIMIZATION := LOW, \
@@ -367,12 +354,10 @@
             $(call SET_SHARED_LIBRARY_ORIGIN) \
             -L$(INSTALL_LIBRARIES_HERE), \
         LIBS :=  $(X_LIBS) $(LIBAWT_XAWT_LIBS), \
-        VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
         RC_FLAGS := $(RC_FLAGS) \
             -D "JDK_FNAME=xawt.dll" \
             -D "JDK_INTERNAL_NAME=xawt" \
             -D "JDK_FTYPE=0x2L", \
-        OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_xawt, \
     ))
 
     $(BUILD_LIBAWT_XAWT): $(call FindLib, java.base, java)
@@ -406,9 +391,8 @@
   LIBLCMS_CPPFLAGS += $(addprefix -I, $(LIBLCMS_SRC))
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBLCMS, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBLCMS, \
     NAME := lcms, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBLCMS_SRC), \
     INCLUDE_FILES := $(BUILD_LIBLCMS_INCLUDE_FILES), \
     OPTIMIZATION := HIGHEST, \
@@ -429,15 +413,8 @@
     LIBS_unix := -lawt -ljvm -ljava $(LCMS_LIBS), \
     LIBS_linux := $(LIBM), \
     LIBS_macosx := $(LIBM), \
-    LIBS_solaris := -lc, \
     LIBS_aix := $(LIBM),\
     LIBS_windows := $(WIN_AWT_LIB) $(WIN_JAVA_LIB), \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=lcms.dll" \
-        -D "JDK_INTERNAL_NAME=lcms" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/liblcms, \
 ))
 
 TARGETS += $(BUILD_LIBLCMS)
@@ -483,9 +460,8 @@
   BUILD_LIBJAVAJPEG_HEADERS := $(addprefix -I, $(LIBJAVAJPEG_SRC))
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBJAVAJPEG, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBJAVAJPEG, \
     NAME := javajpeg, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBJAVAJPEG_SRC), \
     INCLUDE_FILES := $(BUILD_LIBJAVAJPEG_INCLUDE_FILES), \
     OPTIMIZATION := HIGHEST, \
@@ -498,13 +474,7 @@
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LIBS := $(LIBJPEG_LIBS) $(JDKLIB_LIBS), \
     LIBS_windows := $(WIN_JAVA_LIB) jvm.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=javajpeg.dll" \
-        -D "JDK_INTERNAL_NAME=javajpeg" \
-        -D "JDK_FTYPE=0x2L", \
     REORDER := $(BUILD_LIBJAVAJPEG_REORDER), \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjavajpeg, \
 ))
 
 $(BUILD_LIBJAVAJPEG): $(call FindLib, java.base, java)
@@ -547,9 +517,8 @@
     endif
   endif
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBAWT_HEADLESS, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_HEADLESS, \
       NAME := awt_headless, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBAWT_HEADLESS_DIRS), \
       EXCLUDES := $(LIBAWT_HEADLESS_EXCLUDES), \
       OPTIMIZATION := LOW, \
@@ -569,8 +538,7 @@
       REORDER := $(LIBAWT_HEADLESS_REORDER), \
       LIBS_unix := -lawt -ljvm -ljava, \
       LIBS_linux := $(LIBM) $(LIBDL), \
-      LIBS_solaris := $(LIBM) $(LIBDL) $(LIBCXX) -lc, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_headless, \
+      LIBS_solaris := $(LIBM) $(LIBDL) $(LIBCXX), \
   ))
 
   # AIX warning explanation:
@@ -598,9 +566,8 @@
     LIBFREETYPE_LIBS := -lfreetype
   endif
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBFREETYPE, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBFREETYPE, \
       NAME := freetype, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBFREETYPE_SRC)/src, \
       OPTIMIZATION := HIGHEST, \
       CFLAGS := $(CFLAGS_JDKLIB) $(BUILD_LIBFREETYPE_HEADERS) \
@@ -611,13 +578,6 @@
       DISABLED_WARNINGS_microsoft := 4267 2220 4244, \
       LDFLAGS := $(LDFLAGS_JDKLIB) \
           $(call SET_SHARED_LIBRARY_ORIGIN), \
-      LIBS_solaris := -lc, \
-      VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-      RC_FLAGS := $(RC_FLAGS) \
-          -D "JDK_FNAME=freetype.dll" \
-          -D "JDK_INTERNAL_NAME=freetype" \
-          -D "JDK_FTYPE=0x2L", \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfreetype, \
   ))
 
   TARGETS += $(BUILD_LIBFREETYPE)
@@ -697,9 +657,8 @@
   BUILD_LIBFONTMANAGER_ExtensionSubtables.cpp_CXXFLAGS := -fno-strict-aliasing
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBFONTMANAGER, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \
     NAME := fontmanager, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBFONTMANAGER_SRC), \
     EXCLUDE_FILES := $(LIBFONTMANAGER_EXCLUDE_FILES) \
         AccelGlyphCache.c, \
@@ -730,17 +689,9 @@
     LDFLAGS_macosx := -undefined dynamic_lookup, \
     LIBS := $(BUILD_LIBFONTMANAGER_FONTLIB), \
     LIBS_unix := -lawt -ljava -ljvm $(LIBM) $(LIBCXX), \
-    LIBS_linux := -lc, \
-    LIBS_solaris := -lc, \
     LIBS_aix := -lawt_headless,\
     LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib user32.lib gdi32.lib \
         $(WIN_AWT_LIB), \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=fontmanager.dll" \
-        -D "JDK_INTERNAL_NAME=fontmanager" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfontmanager, \
 ))
 
 $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT)
@@ -773,9 +724,8 @@
   ifeq ($(OPENJDK_TARGET_CPU), x86)
     KERNEL32_LIB := kernel32.lib
   endif
-  $(eval $(call SetupNativeCompilation, BUILD_LIBJAWT, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBJAWT, \
       NAME := jawt, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBJAWT_SRC), \
       INCLUDE_FILES := $(LIBJAWT_INCLUDE_FILES), \
       OPTIMIZATION := LOW, \
@@ -784,12 +734,6 @@
           $(LIBJAWT_CFLAGS), \
       LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK), \
       LIBS := $(JDKLIB_LIBS) $(KERNEL32_LIB) advapi32.lib $(WIN_AWT_LIB), \
-      VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-      RC_FLAGS := $(RC_FLAGS) \
-          -D "JDK_FNAME=jawt.dll" \
-          -D "JDK_INTERNAL_NAME=jawt" \
-          -D "JDK_FTYPE=0x2L", \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjawt, \
   ))
 
   $(BUILD_LIBJAWT): $(BUILD_LIBAWT)
@@ -833,9 +777,8 @@
     endif
   endif
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBJAWT, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBJAWT, \
       NAME := jawt, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBJAWT_SRC), \
       INCLUDE_FILES := $(JAWT_FILES), \
       OPTIMIZATION := LOW, \
@@ -851,7 +794,6 @@
       LIBS_unix := $(JAWT_LIBS) $(JDKLIB_LIBS), \
       LIBS_solaris := $(X_LIBS) -lXrender, \
       LIBS_macosx := -framework Cocoa, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjawt, \
   ))
 
   ifeq ($(ENABLE_HEADLESS_ONLY), false)
@@ -950,7 +892,6 @@
   endif
 
   ifeq ($(OPENJDK_TARGET_OS), macosx)
-    LIBSPLASHSCREEN_LDFLAGS := -L$(INSTALL_LIBRARIES_HERE)
     LIBSPLASHSCREEN_LIBS += \
         $(LIBM) -lpthread -liconv -losxapp \
         -framework ApplicationServices \
@@ -958,15 +899,13 @@
         -framework Cocoa \
         -framework JavaNativeFoundation
   else ifeq ($(OPENJDK_TARGET_OS), windows)
-    LIBSPLASHSCREEN_LDFLAGS := -delayload:user32.dll
     LIBSPLASHSCREEN_LIBS += kernel32.lib user32.lib gdi32.lib delayimp.lib $(WIN_JAVA_LIB) jvm.lib
   else
     LIBSPLASHSCREEN_LIBS += $(X_LIBS) -lX11 -lXext $(LIBM) -lpthread -ldl
   endif
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBSPLASHSCREEN, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBSPLASHSCREEN, \
       NAME := splashscreen, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBSPLASHSCREEN_DIRS), \
       EXCLUDE_FILES := imageioJPEG.c jpegdecoder.c pngtest.c, \
       EXCLUDES := $(LIBSPLASHSCREEN_EXCLUDES), \
@@ -980,17 +919,13 @@
           E_STATEMENT_NOT_REACHED, \
       DISABLED_WARNINGS_microsoft := 4018 4244 4267, \
       MAPFILE := $(TOPDIR)/make/mapfiles/libsplashscreen/mapfile-vers, \
-      LDFLAGS := $(LIBSPLASHSCREEN_LDFLAGS) $(LDFLAGS_JDKLIB) \
+      LDFLAGS := $(LDFLAGS_JDKLIB) \
           $(call SET_SHARED_LIBRARY_ORIGIN), \
+      LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \
+      LDFLAGS_windows := -delayload:user32.dll, \
       LIBS := $(JDKLIB_LIBS) $(LIBSPLASHSCREEN_LIBS) $(LIBZ_LIBS) \
           $(GIFLIB_LIBS) $(LIBJPEG_LIBS) $(PNG_LIBS), \
       LIBS_aix := -liconv, \
-      VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-      RC_FLAGS := $(RC_FLAGS) \
-          -D "JDK_FNAME=splashscreen.dll" \
-          -D "JDK_INTERNAL_NAME=splashscreen" \
-          -D "JDK_FTYPE=0x2L", \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsplashscreen, \
   ))
 
   TARGETS += $(BUILD_LIBSPLASHSCREEN)
@@ -1037,9 +972,8 @@
   LIBAWT_LWAWT_EXFILES := fontpath.c awt_Font.c X11Color.c
   LIBAWT_LWAWT_EXCLUDES := $(TOPDIR)/src/java.desktop/unix/native/common/awt/medialib
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBAWT_LWAWT, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_LWAWT, \
       NAME := awt_lwawt, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBAWT_LWAWT_DIRS), \
       INCLUDE_FILES := $(LIBAWT_LWAWT_FILES), \
       EXCLUDE_FILES := $(LIBAWT_LWAWT_EXFILES), \
@@ -1067,7 +1001,6 @@
           -framework JavaRuntimeSupport \
           -framework OpenGL \
           -framework QuartzCore -ljava, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_lwawt, \
   ))
 
   TARGETS += $(BUILD_LIBAWT_LWAWT)
@@ -1086,9 +1019,8 @@
 
 ifeq ($(OPENJDK_TARGET_OS), macosx)
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBOSXUI, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBOSXUI, \
       NAME := osxui, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(TOPDIR)/src/java.desktop/macosx/native/libosxui, \
       OPTIMIZATION := LOW, \
       CFLAGS := $(CFLAGS_JDKLIB) \
@@ -1109,7 +1041,6 @@
           -framework JavaNativeFoundation \
           -framework JavaRuntimeSupport \
           -ljava -ljvm, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libosxui, \
   ))
 
   TARGETS += $(BUILD_LIBOSXUI)
--- a/make/lib/CoreLibraries.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/CoreLibraries.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -108,9 +108,8 @@
   endif
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBVERIFY, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBVERIFY, \
     NAME := verify, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(TOPDIR)/src/java.base/share/native/libverify, \
     OPTIMIZATION := $(LIBVERIFY_OPTIMIZATION), \
     CFLAGS := $(CFLAGS_JDKLIB), \
@@ -119,15 +118,9 @@
     MAPFILE := $(TOPDIR)/make/mapfiles/libverify/mapfile-vers, \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
-    LIBS_unix := -ljvm -lc, \
+    LIBS_unix := -ljvm, \
     LIBS_windows := jvm.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=verify.dll" \
-        -D "JDK_INTERNAL_NAME=verify" \
-        -D "JDK_FTYPE=0x2L", \
     REORDER := $(BUILD_LIBVERIFY_REORDER), \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libverify, \
 ))
 
 TARGETS += $(BUILD_LIBVERIFY)
@@ -156,9 +149,8 @@
   endif
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBJAVA, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBJAVA, \
     NAME := java, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBJAVA_SRC_DIRS), \
     OPTIMIZATION := HIGH, \
     CFLAGS := $(CFLAGS_JDKLIB) \
@@ -177,7 +169,7 @@
         -export:getErrorString -delayload:shell32.dll, \
     LIBS_unix := -ljvm -lverify, \
     LIBS_linux := $(LIBDL) $(BUILD_LIBFDLIBM), \
-    LIBS_solaris := -lsocket -lnsl -lscf $(LIBDL) $(BUILD_LIBFDLIBM) -lc, \
+    LIBS_solaris := -lsocket -lnsl -lscf $(LIBDL) $(BUILD_LIBFDLIBM), \
     LIBS_aix := $(LIBDL) $(BUILD_LIBFDLIBM) $(LIBM),\
     LIBS_macosx := -lfdlibm \
         -framework CoreFoundation \
@@ -186,13 +178,7 @@
     LIBS_windows := jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \
         shell32.lib delayimp.lib \
         advapi32.lib version.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=java.dll" \
-        -D "JDK_INTERNAL_NAME=java" \
-        -D "JDK_FTYPE=0x2L", \
     REORDER := $(LIBJAVA_REORDER), \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjava, \
 ))
 
 TARGETS += $(BUILD_LIBJAVA)
@@ -219,9 +205,8 @@
   BUILD_LIBZIP_MMAP := -DUSE_MMAP
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBZIP, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBZIP, \
     NAME := zip, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     OPTIMIZATION := LOW, \
     SRC := $(TOPDIR)/src/java.base/share/native/libzip, \
     EXCLUDES := $(LIBZIP_EXCLUDES), \
@@ -240,14 +225,7 @@
         -export:ZIP_ReadEntry -export:ZIP_GetNextEntry \
         -export:ZIP_InflateFully -export:ZIP_CRC32 -export:ZIP_FreeEntry, \
     LIBS_unix := -ljvm -ljava $(LIBZ_LIBS), \
-    LIBS_solaris := -lc, \
     LIBS_windows := jvm.lib $(WIN_JAVA_LIB), \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=zip.dll" \
-        -D "JDK_INTERNAL_NAME=zip" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libzip, \
 ))
 
 $(BUILD_LIBZIP): $(BUILD_LIBJAVA)
@@ -263,10 +241,9 @@
     -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
     #
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBJIMAGE, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBJIMAGE, \
     NAME := jimage, \
     TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     OPTIMIZATION := LOW, \
     SRC := $(TOPDIR)/src/java.base/share/native/libjimage \
         $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjimage, \
@@ -283,15 +260,8 @@
         -export:JIMAGE_FindResource -export:JIMAGE_GetResource \
         -export:JIMAGE_ResourceIterator -export:JIMAGE_ResourcePath, \
     LIBS_unix := -ljvm -ldl $(LIBCXX), \
-    LIBS_solaris := -lc, \
     LIBS_macosx := -lc++, \
     LIBS_windows := jvm.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=jimage.dll" \
-        -D "JDK_INTERNAL_NAME=jimage" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjimage, \
 ))
 
 $(BUILD_LIBJIMAGE): $(BUILD_LIBJAVA)
@@ -359,7 +329,7 @@
       )
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBJLI, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \
     NAME := jli, \
     OUTPUT_DIR := $(LIBJLI_OUTPUT_DIR), \
     SRC := $(LIBJLI_SRC_DIRS), \
@@ -397,17 +367,11 @@
         -export:JLI_AddArgsFromEnvVar \
         -export:JLI_GetAppArgIndex, \
     LIBS_unix := $(LIBZ_LIBS), \
-    LIBS_linux := $(LIBDL) -lc -lpthread, \
-    LIBS_solaris := $(LIBDL) -lc, \
+    LIBS_linux := $(LIBDL) -lpthread, \
+    LIBS_solaris := $(LIBDL), \
     LIBS_aix := $(LIBDL),\
     LIBS_macosx := -framework Cocoa -framework Security -framework ApplicationServices, \
     LIBS_windows := advapi32.lib comctl32.lib user32.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=jli.dll" \
-        -D "JDK_INTERNAL_NAME=jli" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli, \
 ))
 
 TARGETS += $(BUILD_LIBJLI)
--- a/make/lib/Lib-java.base.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-java.base.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,10 +33,145 @@
 
 $(eval $(call FillCacheFind, $(wildcard $(LIB_java.base_SRC_DIRS))))
 
+################################################################################
+# Create all the core libraries
+
 include CoreLibraries.gmk
-include NetworkingLibraries.gmk
-include NioLibraries.gmk
-include SecurityLibraries.gmk
+
+################################################################################
+# Create the network library
+
+LIBNET_SRC_DIRS := $(call FindSrcDirsForLib, java.base, net)
+
+$(eval $(call SetupJdkLibrary, BUILD_LIBNET, \
+    NAME := net, \
+    SRC := $(LIBNET_SRC_DIRS), \
+    OPTIMIZATION := LOW, \
+    CFLAGS := $(CFLAGS_JDKLIB) -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
+        $(LIBJAVA_HEADER_FLAGS) $(addprefix -I, $(LIBNET_SRC_DIRS)), \
+    DISABLED_WARNINGS_gcc := format-nonliteral, \
+    DISABLED_WARNINGS_clang := parentheses-equality constant-logical-operand, \
+    DISABLED_WARNINGS_microsoft := 4244 4047 4133 4996, \
+    DISABLED_WARNINGS_solstudio := E_ARG_INCOMPATIBLE_WITH_ARG_L, \
+    MAPFILE := $(TOPDIR)/make/mapfiles/libnet/mapfile-vers, \
+    LDFLAGS := $(LDFLAGS_JDKLIB) \
+        $(call SET_SHARED_LIBRARY_ORIGIN), \
+    LDFLAGS_windows := -delayload:secur32.dll -delayload:iphlpapi.dll, \
+    LIBS_unix := -ljvm -ljava, \
+    LIBS_linux := $(LIBDL) -lpthread, \
+    LIBS_solaris := -lnsl -lsocket $(LIBDL), \
+    LIBS_aix := $(LIBDL),\
+    LIBS_windows := ws2_32.lib jvm.lib secur32.lib iphlpapi.lib winhttp.lib \
+        delayimp.lib $(WIN_JAVA_LIB) advapi32.lib, \
+    LIBS_macosx := -framework CoreFoundation -framework CoreServices, \
+))
+
+$(BUILD_LIBNET): $(BUILD_LIBJAVA)
+
+TARGETS += $(BUILD_LIBNET)
+
+################################################################################
+# Create the nio library
+
+BUILD_LIBNIO_SRC := \
+    $(TOPDIR)/src/java.base/share/native/libnio \
+    $(TOPDIR)/src/java.base/share/native/libnio/ch \
+    $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio \
+    $(sort $(wildcard \
+      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio/ch \
+      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio/fs \
+      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libnio/ch \
+      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libnio/fs)) \
+    #
+
+BUILD_LIBNIO_CFLAGS := \
+    $(addprefix -I, $(BUILD_LIBNIO_SRC)) \
+    -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
+    $(LIBJAVA_HEADER_FLAGS) \
+    $(addprefix -I, $(BUILD_LIBNET_SRC))
+
+ifeq ($(OPENJDK_TARGET_OS), linux)
+  BUILD_LIBNIO_MAPFILE := $(TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+  BUILD_LIBNIO_MAPFILE := $(TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+  BUILD_LIBNIO_MAPFILE := $(TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), aix)
+  BUILD_LIBNIO_MAPFILE := $(TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
+endif
+
+$(eval $(call SetupJdkLibrary, BUILD_LIBNIO, \
+    NAME := nio, \
+    SRC := $(BUILD_LIBNIO_SRC), \
+    EXCLUDE_FILES := $(BUILD_LIBNIO_EXFILES), \
+    OPTIMIZATION := HIGH, \
+    WARNINGS_AS_ERRORS_xlc := false, \
+    CFLAGS := $(CFLAGS_JDKLIB) \
+        $(BUILD_LIBNIO_CFLAGS), \
+    MAPFILE := $(BUILD_LIBNIO_MAPFILE), \
+    LDFLAGS := $(LDFLAGS_JDKLIB) \
+        $(call SET_SHARED_LIBRARY_ORIGIN), \
+    LIBS_unix := -ljava -lnet, \
+    LIBS_linux := -lpthread $(LIBDL), \
+    LIBS_solaris := -ljvm -lsocket -lposix4 $(LIBDL) \
+        -lsendfile, \
+    LIBS_aix := $(LIBDL), \
+    LIBS_macosx := \
+        -framework CoreFoundation -framework CoreServices, \
+    LIBS_windows := jvm.lib ws2_32.lib $(WIN_JAVA_LIB) \
+        $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libnet/net.lib \
+        advapi32.lib, \
+))
+
+TARGETS += $(BUILD_LIBNIO)
+
+$(BUILD_LIBNIO): $(BUILD_LIBNET)
+
+################################################################################
+# Create the macosx security library
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+  # JavaNativeFoundation framework not supported in static builds
+  ifneq ($(STATIC_BUILD), true)
+
+    LIBOSXSECURITY_DIRS := $(TOPDIR)/src/java.base/macosx/native/libosxsecurity
+    LIBOSXSECURITY_CFLAGS := -I$(LIBOSXSECURITY_DIRS) \
+        $(LIBJAVA_HEADER_FLAGS) \
+        -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
+
+    $(eval $(call SetupJdkLibrary, BUILD_LIBOSXSECURITY, \
+        NAME := osxsecurity, \
+        SRC := $(LIBOSXSECURITY_DIRS), \
+        OPTIMIZATION := LOW, \
+        CFLAGS := $(CFLAGS_JDKLIB) \
+            $(LIBOSXSECURITY_CFLAGS), \
+        DISABLED_WARNINGS_clang := deprecated-declarations, \
+        LDFLAGS := $(LDFLAGS_JDKLIB) \
+            -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base \
+            $(call SET_SHARED_LIBRARY_ORIGIN) \
+            -fobjc-link-runtime, \
+        LIBS := \
+            -framework JavaNativeFoundation \
+            -framework CoreServices \
+            -framework Security \
+            $(JDKLIB_LIBS), \
+    ))
+
+    $(BUILD_LIBOSXSECURITY): $(BUILD_LIBJAVA)
+
+    TARGETS += $(BUILD_LIBOSXSECURITY)
+
+  endif
+endif
+
+################################################################################
+# Create the symbols file for static builds.
 
 ifeq ($(STATIC_BUILD), true)
   JAVA_BASE_EXPORT_SYMBOLS_SRC := \
--- a/make/lib/Lib-java.desktop.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-java.desktop.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,79 @@
 
 $(eval $(call FillCacheFind, $(wildcard $(LIB_java.desktop_SRC_DIRS))))
 
-include LibosxLibraries.gmk
-include PlatformLibraries.gmk
+################################################################################
+# Create the AWT/2D and sound libraries
+
 include Awt2dLibraries.gmk
 include SoundLibraries.gmk
+
+################################################################################
+# Create the macosx specific osxapp and osx libraries
+
+ifeq ($(OPENJDK_TARGET_OS), macosx)
+  LIBOSXAPP_SRC := $(TOPDIR)/src/java.desktop/macosx/native/libosxapp
+
+  $(eval $(call SetupJdkLibrary, BUILD_LIBOSXAPP, \
+      NAME := osxapp, \
+      SRC := $(LIBOSXAPP_SRC), \
+      OPTIMIZATION := LOW, \
+      CFLAGS := $(CFLAGS_JDKLIB) \
+          $(addprefix -I, $(LIBOSXAPP_SRC)) \
+          -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop, \
+      DISABLED_WARNINGS_clang := objc-method-access objc-root-class, \
+      LDFLAGS := $(LDFLAGS_JDKLIB) \
+          $(call SET_SHARED_LIBRARY_ORIGIN), \
+      LIBS := \
+          -framework Accelerate \
+          -framework ApplicationServices \
+          -framework AudioToolbox \
+          -framework Carbon \
+          -framework Cocoa \
+          -framework Security \
+          -framework ExceptionHandling \
+          -framework JavaNativeFoundation \
+          -framework JavaRuntimeSupport \
+          -framework OpenGL \
+          -framework IOSurface \
+          -framework QuartzCore, \
+  ))
+
+  TARGETS += $(BUILD_LIBOSXAPP)
+
+  ##############################################################################
+
+  LIBOSX_DIRS := $(TOPDIR)/src/java.desktop/macosx/native/libosx
+  LIBOSX_CFLAGS := -I$(LIBOSX_DIRS) \
+      -I$(TOPDIR)/src/java.desktop/macosx/native/libosxapp \
+      $(LIBJAVA_HEADER_FLAGS) \
+      -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop \
+      #
+
+  $(eval $(call SetupJdkLibrary, BUILD_LIBOSX, \
+      NAME := osx, \
+      SRC := $(LIBOSX_DIRS), \
+      OPTIMIZATION := LOW, \
+      CFLAGS := $(CFLAGS_JDKLIB) \
+          $(LIBOSX_CFLAGS), \
+      DISABLED_WARNINGS_clang := deprecated-declarations, \
+      LDFLAGS := $(LDFLAGS_JDKLIB) \
+          -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.desktop \
+          $(call SET_SHARED_LIBRARY_ORIGIN), \
+      LIBS := \
+          -losxapp \
+          -framework Cocoa \
+          -framework ApplicationServices \
+          -framework JavaNativeFoundation \
+          -framework JavaRuntimeSupport \
+          -framework SystemConfiguration \
+          $(JDKLIB_LIBS), \
+  ))
+
+  TARGETS += $(BUILD_LIBOSX)
+
+  $(BUILD_LIBOSX): $(call FindLib, java.desktop, osxapp)
+
+  $(BUILD_LIBOSX): $(call FindLib, java.base, java)
+
+endif
+
--- a/make/lib/Lib-java.instrument.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-java.instrument.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -49,9 +49,8 @@
   LIBINSTRUMENT_CFLAGS += -Dstrcasecmp=stricmp
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBINSTRUMENT, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBINSTRUMENT, \
     NAME := instrument, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBINSTRUMENT_SRC), \
     OPTIMIZATION := LOW, \
     CFLAGS := $(LIBINSTRUMENT_CFLAGS), \
@@ -77,12 +76,6 @@
         $(SUPPORT_OUTPUTDIR)/native/java.base/libjli_static.a, \
     LIBS_windows := jvm.lib $(WIN_JAVA_LIB) advapi32.lib \
         $(SUPPORT_OUTPUTDIR)/native/java.base/jli_static.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=instrument.dll" \
-        -D "JDK_INTERNAL_NAME=instrument" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libinstrument, \
 ))
 
 ifneq (, $(findstring $(OPENJDK_TARGET_OS), macosx windows aix))
--- a/make/lib/Lib-java.management.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-java.management.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -44,9 +44,8 @@
   endif
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBMANAGEMENT, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBMANAGEMENT, \
     NAME := management, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBMANAGEMENT_SRC), \
     OPTIMIZATION := $(LIBMANAGEMENT_OPTIMIZATION), \
     CFLAGS := $(CFLAGS_JDKLIB) $(LIBMANAGEMENT_CFLAGS), \
@@ -57,12 +56,6 @@
     LIBS_solaris := -lkstat, \
     LIBS_aix := -lperfstat,\
     LIBS_windows := jvm.lib psapi.lib $(WIN_JAVA_LIB) advapi32.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=management.dll" \
-        -D "JDK_INTERNAL_NAME=management" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libmanagement, \
 ))
 
 $(BUILD_LIBMANAGEMENT): $(call FindLib, java.base, java)
--- a/make/lib/Lib-java.prefs.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-java.prefs.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -33,9 +33,8 @@
   LIBPREF_SRC_DIRS := $(TOPDIR)/src/java.prefs/$(OPENJDK_TARGET_OS_TYPE)/native/libprefs
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBPREFS, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBPREFS, \
     NAME := prefs, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBPREF_SRC_DIRS), \
     OPTIMIZATION := HIGH, \
     CFLAGS := $(CFLAGS_JDKLIB) $(addprefix -I, $(LIBPREF_SRC_DIRS)) \
@@ -45,16 +44,10 @@
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LIBS_unix := -ljvm, \
     LIBS_linux := -ljava, \
-    LIBS_solaris := -ljava -lc, \
+    LIBS_solaris := -ljava, \
     LIBS_aix := -ljava, \
     LIBS_macosx := -framework CoreFoundation -framework Foundation, \
     LIBS_windows := advapi32.lib jvm.lib $(WIN_JAVA_LIB), \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=prefs.dll" \
-        -D "JDK_INTERNAL_NAME=prefs" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libprefs, \
 ))
 
 $(BUILD_LIBPREFS): $(call FindLib, java.base, java)
--- a/make/lib/Lib-java.rmi.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-java.rmi.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -27,9 +27,8 @@
 
 ################################################################################
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBRMI, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBRMI, \
     NAME := rmi, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(TOPDIR)/src/java.rmi/share/native/librmi, \
     OPTIMIZATION := LOW, \
     CFLAGS := $(CFLAGS_JDKLIB) -I$(SUPPORT_OUTPUTDIR)/headers/java.rmi, \
@@ -38,12 +37,6 @@
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LIBS_unix := -ljvm, \
     LIBS_windows := jvm.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-         -D "JDK_FNAME=rmi.dll" \
-         -D "JDK_INTERNAL_NAME=rmi" \
-         -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/librmi, \
 ))
 
 $(BUILD_LIBRMI): $(call FindLib, java.base, java)
--- a/make/lib/Lib-java.security.jgss.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-java.security.jgss.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -32,9 +32,8 @@
       $(TOPDIR)/src/java.security.jgss/$(OPENJDK_TARGET_OS_TYPE)/native/libj2gss \
       #
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBJ2GSS, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBJ2GSS, \
       NAME := j2gss, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBJ2GSS_SRC), \
       OPTIMIZATION := LOW, \
       CFLAGS := $(CFLAGS_JDKLIB) $(addprefix -I, $(LIBJ2GSS_SRC)) \
@@ -44,8 +43,6 @@
       LDFLAGS := $(LDFLAGS_JDKLIB) \
           $(call SET_SHARED_LIBRARY_ORIGIN), \
       LIBS := $(LIBDL), \
-      LIBS_solaris := -lc, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libj2gss, \
   ))
 
   TARGETS += $(BUILD_LIBJ2GSS)
@@ -54,47 +51,47 @@
 ################################################################################
 
 ifneq ($(BUILD_CRYPTO), false)
-  BUILD_LIBKRB5_NAME :=
+
   ifeq ($(OPENJDK_TARGET_OS), windows)
-    BUILD_LIBKRB5_NAME := w2k_lsa_auth
-    BUILD_LIBKRB5_SRC := $(TOPDIR)/src/java.security.jgss/$(OPENJDK_TARGET_OS_TYPE)/native/libw2k_lsa_auth
-    BUILD_LIBKRB5_LIBS := advapi32.lib Secur32.lib netapi32.lib kernel32.lib user32.lib \
-        gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib \
-        ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib
-  else ifeq ($(OPENJDK_TARGET_OS), macosx)
-    BUILD_LIBKRB5_NAME := osxkrb5
-    BUILD_LIBKRB5_SRC := $(TOPDIR)/src/java.security.jgss/macosx/native/libosxkrb5
-    BUILD_LIBKRB5_LIBS := \
-        -framework JavaNativeFoundation \
-        -framework Cocoa \
-        -framework SystemConfiguration \
-        -framework Kerberos
+    BUILD_LIBW2K_LSA_AUTH_SRC := $(call FindSrcDirsForLib, $(MODULE), w2k_lsa_auth)
+
+    $(eval $(call SetupJdkLibrary, BUILD_LIBW2K_LSA_AUTH, \
+        NAME := w2k_lsa_auth, \
+        SRC := $(BUILD_LIBW2K_LSA_AUTH_SRC), \
+        OPTIMIZATION := LOW, \
+        CFLAGS := $(CFLAGS_JDKLIB) \
+            $(addprefix -I, $(BUILD_LIBW2K_LSA_AUTH_SRC)) \
+            -I$(SUPPORT_OUTPUTDIR)/headers/java.security.jgss, \
+        LDFLAGS := $(LDFLAGS_JDKLIB) \
+            $(call SET_SHARED_LIBRARY_ORIGIN), \
+        LIBS := advapi32.lib Secur32.lib netapi32.lib kernel32.lib user32.lib \
+            gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib \
+            ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib, \
+    ))
+
+    TARGETS += $(BUILD_LIBW2K_LSA_AUTH)
   endif
 
-  ifneq ($(BUILD_LIBKRB5_NAME), )
+  ifeq ($(OPENJDK_TARGET_OS), macosx)
+    BUILD_LIBOSXKRB5_SRC := $(call FindSrcDirsForLib, $(MODULE), osxkrb5)
+
     # libosxkrb5 needs to call deprecated krb5 APIs so that java
     # can use the native credentials cache.
-    $(eval $(call SetupNativeCompilation, BUILD_LIBKRB5, \
-        NAME := $(BUILD_LIBKRB5_NAME), \
-        OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-        SRC := $(BUILD_LIBKRB5_SRC), \
+    $(eval $(call SetupJdkLibrary, BUILD_LIBOSXKRB5, \
+        NAME := osxkrb5, \
+        SRC := $(BUILD_LIBOSXKRB5_SRC), \
         OPTIMIZATION := LOW, \
         CFLAGS := $(CFLAGS_JDKLIB) \
-            $(addprefix -I, $(BUILD_LIBKRB5_SRC)) \
+            $(addprefix -I, $(BUILD_LIBOSXKRB5_SRC)) \
             -I$(SUPPORT_OUTPUTDIR)/headers/java.security.jgss, \
         DISABLED_WARNINGS_clang := deprecated-declarations, \
         LDFLAGS := $(LDFLAGS_JDKLIB) \
             $(call SET_SHARED_LIBRARY_ORIGIN), \
-        LIBS := $(BUILD_LIBKRB5_LIBS), \
-        VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-        RC_FLAGS := $(RC_FLAGS) \
-            -D "JDK_FNAME=$(BUILD_LIBKRB5_NAME).dll" \
-            -D "JDK_INTERNAL_NAME=$(BUILD_LIBKRB5_NAME)" \
-            -D "JDK_FTYPE=0x2L", \
-        OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libkrb5, \
+        LIBS := -framework JavaNativeFoundation -framework Cocoa \
+            -framework SystemConfiguration -framework Kerberos, \
     ))
 
-    TARGETS += $(BUILD_LIBKRB5)
+    TARGETS += $(BUILD_LIBOSXKRB5)
   endif
 endif
 
--- a/make/lib/Lib-java.smartcardio.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-java.smartcardio.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -33,9 +33,8 @@
     -I$(TOPDIR)/src/java.smartcardio/$(OPENJDK_TARGET_OS_TYPE)/native/libj2pcsc/MUSCLE \
     -I$(SUPPORT_OUTPUTDIR)/headers/java.smartcardio
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBJ2PCSC, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBJ2PCSC, \
     NAME := j2pcsc, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBJ2PCSC_SRC), \
     CFLAGS_unix := -D__sun_jdk, \
     OPTIMIZATION := LOW, \
@@ -44,14 +43,7 @@
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LIBS_unix := $(LIBDL), \
-    LIBS_solaris := -lc, \
     LIBS_windows := winscard.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=j2pcsc.dll" \
-        -D "JDK_INTERNAL_NAME=j2pcsc" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libj2pcsc, \
 ))
 
 TARGETS += $(BUILD_LIBJ2PCSC)
--- a/make/lib/Lib-jdk.accessibility.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.accessibility.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -41,26 +41,20 @@
     # Parameter 1 Suffix
     # Parameter 2 ACCESSBRIDGE_ARCH_ suffix
 
-    $(call SetupNativeCompilation, BUILD_JAVAACCESSBRIDGE$1, \
+    $(call SetupJdkLibrary, BUILD_JAVAACCESSBRIDGE$1, \
         NAME := javaaccessbridge$1, \
-        OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
         SRC := $(JAVA_AB_SRCDIR), \
         OPTIMIZATION := LOW, \
         CFLAGS := $(CFLAGS_JDKLIB) $(ACCESSBRIDGE_CFLAGS) \
             $(addprefix -I,$(JAVA_AB_SRCDIR)) \
             -I$(ROOT_SRCDIR)/include/bridge \
             -DACCESSBRIDGE_ARCH_$2, \
-        LDFLAGS := $(LDFLAGS_JDKLIB) -subsystem:windows, \
+        LDFLAGS := $(LDFLAGS_JDKLIB), \
         LIBS := kernel32.lib user32.lib gdi32.lib \
             winspool.lib comdlg32.lib advapi32.lib shell32.lib \
             $(SUPPORT_OUTPUTDIR)/native/java.desktop/libjawt/jawt.lib \
             ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib, \
         VERSIONINFO_RESOURCE := $(ROOT_SRCDIR)/common/AccessBridgeStatusWindow.rc, \
-        RC_FLAGS := $(RC_FLAGS) \
-            -D "JDK_FNAME=javaaccessbridge$1.dll" \
-            -D "JDK_INTERNAL_NAME=javaaccessbridge$1" \
-            -D "JDK_FTYPE=0x02L", \
-        OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjavaaccessbridge$1, \
     )
 
     $$(BUILD_JAVAACCESSBRIDGE$1): $(SUPPORT_OUTPUTDIR)/native/java.desktop/libjawt/jawt.lib
@@ -71,26 +65,20 @@
   define SetupWinDLL
     # Parameter 1 Suffix
     # Parameter 2 ACCESSBRIDGE_ARCH_ suffix
-    $(call SetupNativeCompilation, BUILD_WINDOWSACCESSBRIDGE$1, \
+    $(call SetupJdkLibrary, BUILD_WINDOWSACCESSBRIDGE$1, \
         NAME := windowsaccessbridge$1, \
-        OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
         SRC := $(WIN_AB_SRCDIR), \
         OPTIMIZATION := LOW, \
         CFLAGS := $(filter-out -MD, $(CFLAGS_JDKLIB)) -MT $(ACCESSBRIDGE_CFLAGS) \
             $(addprefix -I,$(WIN_AB_SRCDIR)) \
             -I$(ROOT_SRCDIR)/include/bridge \
             -DACCESSBRIDGE_ARCH_$2, \
-        LDFLAGS := $(LDFLAGS_JDKLIB) -subsystem:windows \
+        LDFLAGS := $(LDFLAGS_JDKLIB) \
             -def:$(ROOT_SRCDIR)/libwindowsaccessbridge/WinAccessBridge.DEF, \
         LIBS := kernel32.lib user32.lib gdi32.lib \
             winspool.lib comdlg32.lib advapi32.lib shell32.lib \
             ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib, \
         VERSIONINFO_RESOURCE := $(ROOT_SRCDIR)/common/AccessBridgeStatusWindow.rc, \
-        RC_FLAGS := $(RC_FLAGS) \
-            -D "JDK_FNAME=windowsaccessbridge$1.dll" \
-            -D "JDK_INTERNAL_NAME=windowsaccessbridge$1" \
-            -D "JDK_FTYPE=0x02L", \
-        OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libwindowsaccessbridge$1, \
     )
 
     TARGETS += $$(BUILD_WINDOWSACCESSBRIDGE$1)
@@ -99,20 +87,13 @@
 
   define SetupAccessBridgeSysInfo
 
-    $(call SetupNativeCompilation, BUILD_ACCESSBRIDGESYSINFO, \
+    $(call SetupJdkLibrary, BUILD_ACCESSBRIDGESYSINFO, \
         NAME := jabsysinfo, \
-        OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
         SRC := $(SYSINFO_SRCDIR), \
         OPTIMIZATION := LOW, \
         CFLAGS := $(CFLAGS_JDKLIB) $(ACCESSBRIDGE_CFLAGS), \
-        LDFLAGS := $(LDFLAGS_JDKLIB) \
-            -subsystem:windows -machine:I386, \
+        LDFLAGS := $(LDFLAGS_JDKLIB), \
         VERSIONINFO_RESOURCE := $(ROOT_SRCDIR)/common/AccessBridgeStatusWindow.rc, \
-        RC_FLAGS := $(RC_FLAGS) \
-            -D "JDK_FNAME=jabsysinfo.dll" \
-            -D "JDK_INTERNAL_NAME=jabsysinfo" \
-            -D "JDK_FTYPE=0x02L", \
-        OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/lib/libjabsysinfo, \
     )
 
     TARGETS += $$(BUILD_ACCESSBRIDGESYSINFO)
--- a/make/lib/Lib-jdk.attach.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.attach.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -34,9 +34,8 @@
   LIBATTACH_CFLAGS := -DPSAPI_VERSION=1
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBATTACH, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBATTACH, \
     NAME := attach, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(call FindSrcDirsForLib, jdk.attach, attach), \
     OPTIMIZATION := LOW, \
     CFLAGS := $(CFLAGS_JDKLIB) \
@@ -44,18 +43,12 @@
         $(LIBJAVA_HEADER_FLAGS) $(LIBATTACH_CFLAGS), \
     CFLAGS_windows := /Gy, \
     MAPFILE := $(TOPDIR)/make/mapfiles/libattach/mapfile-$(OPENJDK_TARGET_OS), \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=attach.dll" \
-        -D "JDK_INTERNAL_NAME=attach" \
-        -D "JDK_FTYPE=0x2L", \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LDFLAGS_windows := -order:@$(TOPDIR)/make/mapfiles/libattach/reorder-windows-$(OPENJDK_TARGET_CPU), \
     LIBS := $(JDKLIB_LIBS), \
     LIBS_solaris := -ldoor, \
     LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib psapi.lib, \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libattach, \
 ))
 
 $(BUILD_LIBATTACH): $(call FindLib, java.base, java)
--- a/make/lib/Lib-jdk.crypto.cryptoki.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.crypto.cryptoki.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -30,9 +30,8 @@
 LIBJ2PKCS11_SRC := $(TOPDIR)/src/jdk.crypto.cryptoki/share/native/libj2pkcs11 \
     $(TOPDIR)/src/jdk.crypto.cryptoki/$(OPENJDK_TARGET_OS_TYPE)/native/libj2pkcs11
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBJ2PKCS11, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBJ2PKCS11, \
     NAME := j2pkcs11, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBJ2PKCS11_SRC), \
     OPTIMIZATION := LOW, \
     CFLAGS := $(CFLAGS_JDKLIB) $(addprefix -I, $(LIBJ2PKCS11_SRC)) \
@@ -42,13 +41,6 @@
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LIBS_unix := $(LIBDL), \
-    LIBS_solaris := -lc, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=j2pkcs11.dll" \
-        -D "JDK_INTERNAL_NAME=j2pkcs11" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libj2pkcs11, \
 ))
 
 TARGETS += $(BUILD_LIBJ2PKCS11)
--- a/make/lib/Lib-jdk.crypto.ec.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.crypto.ec.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -43,9 +43,8 @@
     ECC_JNI_SOLSPARC_FILTER := -xregs=no%appl
   endif
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBSUNEC, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBSUNEC, \
       NAME := sunec, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBSUNEC_SRC), \
       TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
       OPTIMIZATION := LOW, \
@@ -60,14 +59,6 @@
       LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK), \
       LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN), \
       LIBS := $(LIBCXX), \
-      LIBS_linux := -lc, \
-      LIBS_solaris := -lc, \
-      VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-      RC_FLAGS := $(RC_FLAGS) \
-          -D "JDK_FNAME=sunec.dll" \
-          -D "JDK_INTERNAL_NAME=sunec" \
-          -D "JDK_FTYPE=0x2L", \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsunec, \
   ))
 
   TARGETS += $(BUILD_LIBSUNEC)
--- a/make/lib/Lib-jdk.crypto.mscapi.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.crypto.mscapi.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -31,9 +31,8 @@
 
   LIBSUNMSCAPI_SRC := $(TOPDIR)/src/jdk.crypto.mscapi/$(OPENJDK_TARGET_OS_TYPE)/native/libsunmscapi
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBSUNMSCAPI, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBSUNMSCAPI, \
       NAME := sunmscapi, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBSUNMSCAPI_SRC), \
       OPTIMIZATION := LOW, \
       CFLAGS := $(CFLAGS_JDKLIB) \
@@ -41,12 +40,6 @@
       LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
           $(call SET_SHARED_LIBRARY_ORIGIN), \
       LIBS := crypt32.lib advapi32.lib, \
-      VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-      RC_FLAGS := $(RC_FLAGS) \
-          -D "JDK_FNAME=sunmscapi.dll" \
-          -D "JDK_INTERNAL_NAME=sunmscapi" \
-          -D "JDK_FTYPE=0x2L", \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsunmscapi, \
   ))
 
   TARGETS += $(BUILD_LIBSUNMSCAPI)
--- a/make/lib/Lib-jdk.crypto.ucrypto.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.crypto.ucrypto.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -31,9 +31,8 @@
 
   LIBJ2UCRYPTO_SRC := $(TOPDIR)/src/jdk.crypto.ucrypto/solaris/native/libj2ucrypto
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBJ2UCRYPTO, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBJ2UCRYPTO, \
       NAME := j2ucrypto, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBJ2UCRYPTO_SRC), \
       OPTIMIZATION := LOW, \
       CFLAGS := $(CFLAGS_JDKLIB) \
@@ -41,8 +40,6 @@
       MAPFILE := $(TOPDIR)/make/mapfiles/libj2ucrypto/mapfile-vers, \
       LDFLAGS := $(LDFLAGS_JDKLIB), \
       LIBS := $(LIBDL), \
-      LIBS_solaris := -lc, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libj2ucrypto, \
   ))
 
   $(BUILD_LIBJ2UCRYPTO): $(BUILD_LIBJAVA)
--- a/make/lib/Lib-jdk.hotspot.agent.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.hotspot.agent.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -23,7 +23,7 @@
 # questions.
 #
 
-include NativeCompilation.gmk
+include LibCommon.gmk
 
 $(eval $(call IncludeCustomExtension, hotspot/lib/Lib-jdk.hotspot.agent.gmk))
 
@@ -46,33 +46,26 @@
     -I$(TOPDIR)/src/hotspot/os/$(OPENJDK_TARGET_OS) \
     #
 
-ifeq ($(OPENJDK_TARGET_CPU), x86_64)
-  SA_MACHINE_FLAG_windows := -machine:AMD64
-else ifeq ($(OPENJDK_TARGET_CPU), x86)
-  SA_MACHINE_FLAG_linux := -march=i586
-  SA_MACHINE_FLAG_windows := -machine:I386
-endif
+ifeq ($(OPENJDK_TARGET_OS), linux)
+  SA_CFLAGS := $(CFLAGS_JDKLIB) -D_FILE_OFFSET_BITS=64
+  ifeq ($(OPENJDK_TARGET_CPU), x86)
+    SA_LDFLAGS := -march=i586
+  endif
 
-ifeq ($(OPENJDK_TARGET_OS), linux)
-  SA_CFLAGS := $(CFLAGS_JDKLIB) -D_FILE_OFFSET_BITS=64 \
-      $(SA_MACHINE_FLAG_linux)
-  SA_LDFLAGS := $(LDFLAGS_JDKLIB) $(SA_MACHINE_FLAG_linux)
   SA_LIBS := -lthread_db $(LIBDL)
 
 else ifeq ($(OPENJDK_TARGET_OS), solaris)
   SA_TOOLCHAIN := TOOLCHAIN_LINK_CXX
   SA_CFLAGS := $(CFLAGS_JDKLIB)
   SA_CXXFLAGS := $(CXXFLAGS_JDKLIB)
-  SA_LDFLAGS := $(subst -Wl$(COMMA)-z$(COMMA)defs,, $(LDFLAGS_JDKLIB)) \
-      -mt $(LDFLAGS_CXX_JDK)
-  SA_LIBS := -ldl -ldemangle -lthread -lc
+  SA_LDFLAGS := -mt $(LDFLAGS_CXX_JDK)
+  SA_LIBS := -ldl -ldemangle -lthread -lproc
 
 else ifeq ($(OPENJDK_TARGET_OS), macosx)
   SA_EXCLUDE_FILES := BsdDebuggerLocal.c ps_proc.c salibelf.c StubDebuggerLocal.c
   SA_CFLAGS := $(CFLAGS_JDKLIB) \
       -Damd64 -D_GNU_SOURCE -mno-omit-leaf-frame-pointer \
       -mstack-alignment=16 -fPIC
-  SA_LDFLAGS := $(LDFLAGS_JDKLIB)
   SA_LIBS := -framework Foundation -framework JavaNativeFoundation \
       -framework JavaRuntimeSupport -framework Security -framework CoreFoundation
 
@@ -83,36 +76,31 @@
       $(COMMON_CFLAGS)
   SA_CXXFLAGS := $(subst -DWIN32_LEAN_AND_MEAN,, $(CXXFLAGS_JDKLIB)) \
       $(COMMON_CFLAGS)
-  SA_LDFLAGS := $(LDFLAGS_JDKLIB) \
-      $(SA_MACHINE_FLAG_windows) -manifest \
-      -subsystem:console -map
+  SA_LDFLAGS := -manifest
   SA_LIBS := dbgeng.lib
   ifeq ($(OPENJDK_TARGET_CPU), x86_64)
     SA_CXXFLAGS += -DWIN64
   else
     SA_CXXFLAGS += -RTC1
-    SA_LDFLAGS += -SAFESEH
   endif
 endif
 
 ################################################################################
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBSA, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBSA, \
     NAME := $(SA_NAME), \
     TOOLCHAIN := $(SA_TOOLCHAIN), \
     OPTIMIZATION := NONE, \
     DISABLED_WARNINGS_microsoft := 4267, \
     DISABLED_WARNINGS_gcc := sign-compare, \
     DISABLED_WARNINGS_CXX_solstudio := truncwarn unknownpragma, \
-    OUTPUT_DIR := $(call FindLibDirForModule, $(MODULE)), \
     SRC := $(SA_SRC), \
     EXCLUDE_FILES := test.c saproc_audit.cpp $(SA_EXCLUDE_FILES), \
     CFLAGS := $(SA_INCLUDES) $(SA_CFLAGS) $(SA_CUSTOM_CFLAGS), \
     CXXFLAGS := $(SA_INCLUDES) $(SA_CXXFLAGS) $(SA_CUSTOM_CXXFLAGS), \
-    LDFLAGS := $(SA_LDFLAGS) $(SA_CUSTOM_LDFLAGS), \
+    LDFLAGS := $(LDFLAGS_JDKLIB) $(SA_LDFLAGS), \
     LIBS := $(SA_LIBS), \
     MAPFILE := $(SA_MAPFILE), \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsa, \
 ))
 
 TARGETS += $(BUILD_LIBSA)
--- a/make/lib/Lib-jdk.internal.le.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.internal.le.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -36,21 +36,14 @@
       -I$(SUPPORT_OUTPUTDIR)/headers/jdk.internal.le \
       #
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBLE, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBLE, \
       NAME := le, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBLE_SRC), \
       OPTIMIZATION := LOW, \
       CFLAGS := $(CFLAGS_JDKLIB) $(LIBJAVA_HEADER_FLAGS)\
           $(LIBLE_CPPFLAGS), \
       LDFLAGS := $(LDFLAGS_JDKLIB), \
       LIBS := $(JDKLIB_LIBS) user32.lib, \
-      VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-      RC_FLAGS := $(RC_FLAGS) \
-          -D "JDK_FNAME=le.dll" \
-          -D "JDK_INTERNAL_NAME=le" \
-          -D "JDK_FTYPE=0x2L", \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/lible, \
   ))
 
   TARGETS += $(BUILD_LIBLE)
--- a/make/lib/Lib-jdk.jdi.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.jdi.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -39,9 +39,8 @@
       -I$(SUPPORT_OUTPUTDIR)/headers/jdk.jdi \
       #
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBDT_SHMEM, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBDT_SHMEM, \
       NAME := dt_shmem, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBDT_SHMEM_SRC), \
       OPTIMIZATION := LOW, \
       CFLAGS := $(CFLAGS_JDKLIB) -DUSE_MMAP \
@@ -49,12 +48,6 @@
       LDFLAGS := $(LDFLAGS_JDKLIB), \
       LDFLAGS_windows := -export:jdwpTransport_OnLoad, \
       LIBS := $(JDKLIB_LIBS), \
-      VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-      RC_FLAGS := $(RC_FLAGS) \
-          -D "JDK_FNAME=dt_shmem.dll" \
-          -D "JDK_INTERNAL_NAME=dt_shmem" \
-          -D "JDK_FTYPE=0x2L", \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libdt_shmem, \
   ))
 
   TARGETS += $(BUILD_LIBDT_SHMEM)
--- a/make/lib/Lib-jdk.jdwp.agent.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.jdwp.agent.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -36,9 +36,8 @@
     -I$(TOPDIR)/src/jdk.jdwp.agent/share/native/include \
     #
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBDT_SOCKET, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBDT_SOCKET, \
     NAME := dt_socket, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBDT_SOCKET_SRC), \
     OPTIMIZATION := LOW, \
     CFLAGS := $(CFLAGS_JDKLIB) -DUSE_MMAP \
@@ -48,14 +47,8 @@
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LDFLAGS_windows := -export:jdwpTransport_OnLoad, \
     LIBS_linux := -lpthread, \
-    LIBS_solaris := -lnsl -lsocket -lc, \
+    LIBS_solaris := -lnsl -lsocket, \
     LIBS_windows := $(JDKLIB_LIBS) ws2_32.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=dt_socket.dll" \
-        -D "JDK_INTERNAL_NAME=dt_socket" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libdt_socket, \
 ))
 
 $(BUILD_LIBDT_SOCKET): $(call FindLib, java.base, java)
@@ -73,9 +66,8 @@
     $(addprefix -I, $(LIBJDWP_SRC))
 
 # JDWP_LOGGING causes log messages to be compiled into the library.
-$(eval $(call SetupNativeCompilation, BUILD_LIBJDWP, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBJDWP, \
     NAME := jdwp, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBJDWP_SRC), \
     OPTIMIZATION := LOW, \
     CFLAGS := $(CFLAGS_JDKLIB) -DJDWP_LOGGING \
@@ -89,12 +81,6 @@
     LIBS_solaris := $(LIBDL), \
     LIBS_macosx := -liconv, \
     LIBS_aix := -liconv, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=jdwp.dll" \
-        -D "JDK_INTERNAL_NAME=jdwp" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjdwp, \
 ))
 
 $(BUILD_LIBJDWP): $(call FindLib, java.base, java)
--- a/make/lib/Lib-jdk.management.agent.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.management.agent.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -33,9 +33,8 @@
     $(LIBJAVA_HEADER_FLAGS) \
     #
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBMANAGEMENT_AGENT, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBMANAGEMENT_AGENT, \
     NAME := management_agent, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBMANAGEMENT_AGENT_SRC), \
     OPTIMIZATION := LOW, \
     CFLAGS := $(CFLAGS_JDKLIB) $(LIBMANAGEMENT_AGENT_CFLAGS), \
@@ -44,12 +43,6 @@
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LIBS := $(JDKLIB_LIBS), \
     LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=management_agent.dll" \
-        -D "JDK_INTERNAL_NAME=management_agent" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libmanagement_agent, \
 ))
 
 $(BUILD_LIBMANAGEMENT_AGENT): $(call FindLib, java.base, java)
--- a/make/lib/Lib-jdk.management.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.management.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -53,9 +53,8 @@
   endif
 endif
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBMANAGEMENT_EXT, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBMANAGEMENT_EXT, \
     NAME := management_ext, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBMANAGEMENT_EXT_SRC), \
     LANG := C, \
     OPTIMIZATION := $(LIBMANAGEMENT_EXT_OPTIMIZATION), \
@@ -67,12 +66,6 @@
     LIBS_solaris := -lkstat, \
     LIBS_aix := -lperfstat,\
     LIBS_windows := jvm.lib psapi.lib $(WIN_JAVA_LIB) advapi32.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=management_ext.dll" \
-        -D "JDK_INTERNAL_NAME=management_ext" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libmanagement_ext, \
 ))
 
 $(BUILD_LIBMANAGEMENT_EXT): $(call FindLib, java.base, java)
--- a/make/lib/Lib-jdk.net.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.net.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -27,19 +27,19 @@
 
 ################################################################################
 
-ifeq ($(OPENJDK_TARGET_OS), solaris)
+ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux), )
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBEXTNET, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBEXTNET, \
       NAME := extnet, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-      SRC := $(TOPDIR)/src/jdk.net/solaris/native/libextnet, \
+      SRC := $(TOPDIR)/src/jdk.net/$(OPENJDK_TARGET_OS)/native/libextnet, \
       OPTIMIZATION := LOW, \
       CFLAGS := $(CFLAGS_JDKLIB) -I$(SUPPORT_OUTPUTDIR)/headers/jdk.net, \
-      MAPFILE := $(TOPDIR)/make/mapfiles/libextnet/mapfile-solaris, \
+      MAPFILE := $(TOPDIR)/make/mapfiles/libextnet/mapfile-$(OPENJDK_TARGET_OS), \
       LDFLAGS := $(LDFLAGS_JDKLIB) \
           $(call SET_SHARED_LIBRARY_ORIGIN), \
-      LIBS := -lsocket -lc -ljava, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libextnet, \
+      LIBS := -ljava, \
+      LIBS_solaris := -lsocket, \
+      LIBS_linux := -ljvm, \
   ))
 
   $(BUILD_LIBEXTNET): $(call FindLib, java.base, java)
@@ -47,26 +47,4 @@
   TARGETS += $(BUILD_LIBEXTNET)
 endif
 
-
-ifeq ($(OPENJDK_TARGET_OS), linux)
-
-  $(eval $(call SetupNativeCompilation, BUILD_LIBEXTNET, \
-      NAME := extnet, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-      SRC := $(TOPDIR)/src/jdk.net/linux/native/libextnet, \
-      OPTIMIZATION := LOW, \
-      CFLAGS := $(CFLAGS_JDKLIB) -I$(SUPPORT_OUTPUTDIR)/headers/jdk.net, \
-      MAPFILE := $(TOPDIR)/make/mapfiles/libextnet/mapfile-linux, \
-      LDFLAGS := $(LDFLAGS_JDKLIB) \
-          $(call SET_SHARED_LIBRARY_ORIGIN), \
-      LIBS := -ljvm -ljava -lc, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libextnet, \
-  ))
-
-  $(BUILD_LIBEXTNET): $(call FindLib, java.base, java)
-
-  TARGETS += $(BUILD_LIBEXTNET)
-endif
-
-
 ################################################################################
--- a/make/lib/Lib-jdk.pack.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.pack.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -27,9 +27,8 @@
 
 ################################################################################
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBUNPACK, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBUNPACK, \
     NAME := unpack, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(TOPDIR)/src/jdk.pack/share/native/libunpack \
         $(TOPDIR)/src/jdk.pack/share/native/common-unpack, \
     TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
@@ -45,14 +44,8 @@
     LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LDFLAGS_windows := -map:$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpack.map -debug, \
-    LIBS_unix := -ljvm $(LIBCXX) -ljava -lc, \
+    LIBS_unix := -ljvm $(LIBCXX) -ljava, \
     LIBS_windows := jvm.lib $(WIN_JAVA_LIB), \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libunpack, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=unpack.dll" \
-        -D "JDK_INTERNAL_NAME=unpack" \
-        -D "JDK_FTYPE=0x2L", \
 ))
 
 $(BUILD_LIBUNPACK): $(call FindLib, java.base, java)
--- a/make/lib/Lib-jdk.sctp.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.sctp.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -30,9 +30,8 @@
 ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
 
   ifeq (, $(filter $(OPENJDK_TARGET_OS), macosx aix))
-    $(eval $(call SetupNativeCompilation, BUILD_LIBSCTP, \
+    $(eval $(call SetupJdkLibrary, BUILD_LIBSCTP, \
         NAME := sctp, \
-        OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
         SRC := $(TOPDIR)/src/jdk.sctp/$(OPENJDK_TARGET_OS_TYPE)/native/libsctp, \
         OPTIMIZATION := LOW, \
         CFLAGS := $(CFLAGS_JDKLIB) \
@@ -47,8 +46,7 @@
             $(call SET_SHARED_LIBRARY_ORIGIN), \
         LIBS_unix := -lnio -lnet -ljava -ljvm, \
         LIBS_linux := -lpthread $(LIBDL), \
-        LIBS_solaris := -lsocket -lc, \
-        OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsctp, \
+        LIBS_solaris := -lsocket, \
     ))
 
     TARGETS += $(BUILD_LIBSCTP)
--- a/make/lib/Lib-jdk.security.auth.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/Lib-jdk.security.auth.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -33,28 +33,15 @@
   LIBJAAS_MAPFILE := $(TOPDIR)/make/mapfiles/libjaas/mapfile-vers
 endif
 
-LIBJAAS_NAME := jaas_unix
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  LIBJAAS_NAME := jaas_nt
-endif
-
-$(eval $(call SetupNativeCompilation, BUILD_LIBJAAS, \
-    NAME := $(LIBJAAS_NAME), \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
+$(eval $(call SetupJdkLibrary, BUILD_LIBJAAS, \
+    NAME := jaas, \
     SRC := $(call FindSrcDirsForLib, jdk.security.auth, jaas), \
     OPTIMIZATION := LOW, \
     CFLAGS := $(CFLAGS_JDKLIB) -I$(SUPPORT_OUTPUTDIR)/headers/jdk.security.auth, \
     MAPFILE := $(LIBJAAS_MAPFILE), \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
-    LIBS_solaris := -lc, \
     LIBS_windows := netapi32.lib user32.lib mpr.lib advapi32.lib $(JDKLIB_LIBS), \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=$(LIBJAAS_NAME).dll" \
-        -D "JDK_INTERNAL_NAME=$(LIBJAAS_NAME)" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjaas, \
 ))
 
 $(BUILD_LIBJAAS): $(call FindLib, java.base, java)
--- a/make/lib/LibCommon.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/LibCommon.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 # questions.
 #
 
-include NativeCompilation.gmk
+include JdkNativeCompilation.gmk
 
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, lib/LibCommon.gmk))
@@ -32,7 +32,7 @@
 
 GLOBAL_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/common/version.rc
 
-# Absolute paths to lib files on windows for use in LDFLAGS. Should figure out a more
+# Absolute paths to lib files on windows for use in LIBS. Should figure out a more
 # elegant solution to this.
 WIN_JAVA_LIB := $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib
 
--- a/make/lib/LibosxLibraries.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-#
-# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-
-  ################################################################################
-
-  LIBOSX_DIRS := $(TOPDIR)/src/java.desktop/macosx/native/libosx
-  LIBOSX_CFLAGS := -I$(LIBOSX_DIRS) \
-      -I$(TOPDIR)/src/java.desktop/macosx/native/libosxapp \
-      $(LIBJAVA_HEADER_FLAGS) \
-      -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop \
-      #
-
-  $(eval $(call SetupNativeCompilation, BUILD_LIBOSX, \
-      NAME := osx, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-      SRC := $(LIBOSX_DIRS), \
-      OPTIMIZATION := LOW, \
-      CFLAGS := $(CFLAGS_JDKLIB) \
-          $(LIBOSX_CFLAGS), \
-      DISABLED_WARNINGS_clang := deprecated-declarations, \
-      LDFLAGS := $(LDFLAGS_JDKLIB) \
-          -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.desktop \
-          $(call SET_SHARED_LIBRARY_ORIGIN), \
-      LIBS := \
-          -losxapp \
-          -framework Cocoa \
-          -framework ApplicationServices \
-          -framework JavaNativeFoundation \
-          -framework JavaRuntimeSupport \
-          -framework SystemConfiguration \
-          $(JDKLIB_LIBS), \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libosx, \
-  ))
-
-  TARGETS += $(BUILD_LIBOSX)
-
-  $(BUILD_LIBOSX): $(call FindLib, java.desktop, osxapp)
-
-  $(BUILD_LIBOSX): $(call FindLib, java.base, java)
-
-  ################################################################################
-
-endif
--- a/make/lib/NetworkingLibraries.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-#
-# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-LIBNET_SRC_DIRS := $(call FindSrcDirsForLib, java.base, net)
-
-$(eval $(call SetupNativeCompilation, BUILD_LIBNET, \
-    NAME := net, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-    SRC := $(LIBNET_SRC_DIRS), \
-    OPTIMIZATION := LOW, \
-    CFLAGS := $(CFLAGS_JDKLIB) -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
-        $(LIBJAVA_HEADER_FLAGS) $(addprefix -I, $(LIBNET_SRC_DIRS)), \
-    DISABLED_WARNINGS_gcc := format-nonliteral, \
-    DISABLED_WARNINGS_clang := parentheses-equality constant-logical-operand, \
-    DISABLED_WARNINGS_microsoft := 4244 4047 4133 4996, \
-    DISABLED_WARNINGS_solstudio := E_ARG_INCOMPATIBLE_WITH_ARG_L, \
-    MAPFILE := $(TOPDIR)/make/mapfiles/libnet/mapfile-vers, \
-    LDFLAGS := $(LDFLAGS_JDKLIB) \
-        $(call SET_SHARED_LIBRARY_ORIGIN), \
-    LDFLAGS_windows := -delayload:secur32.dll -delayload:iphlpapi.dll, \
-    LIBS_unix := -ljvm -ljava, \
-    LIBS_linux := $(LIBDL) -lpthread, \
-    LIBS_solaris := -lnsl -lsocket $(LIBDL) -lc, \
-    LIBS_aix := $(LIBDL),\
-    LIBS_windows := ws2_32.lib jvm.lib secur32.lib iphlpapi.lib winhttp.lib \
-        delayimp.lib $(WIN_JAVA_LIB) advapi32.lib, \
-    LIBS_macosx := -framework CoreFoundation -framework CoreServices, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=net.dll" \
-        -D "JDK_INTERNAL_NAME=net" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libnet, \
-))
-
-$(BUILD_LIBNET): $(BUILD_LIBJAVA)
-
-TARGETS += $(BUILD_LIBNET)
--- a/make/lib/NioLibraries.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-#
-# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-BUILD_LIBNIO_SRC := \
-    $(TOPDIR)/src/java.base/share/native/libnio \
-    $(TOPDIR)/src/java.base/share/native/libnio/ch \
-    $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio \
-    $(sort $(wildcard \
-      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio/ch \
-      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libnio/fs \
-      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libnio/ch \
-      $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libnio/fs)) \
-    #
-
-BUILD_LIBNIO_CFLAGS := \
-    $(addprefix -I, $(BUILD_LIBNIO_SRC)) \
-    -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
-    $(LIBJAVA_HEADER_FLAGS) \
-    $(addprefix -I, $(BUILD_LIBNET_SRC))
-
-ifeq ($(OPENJDK_TARGET_OS), linux)
-  BUILD_LIBNIO_MAPFILE := $(TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
-endif
-
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-  BUILD_LIBNIO_MAPFILE := $(TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
-endif
-
-ifeq ($(OPENJDK_TARGET_OS), solaris)
-  BUILD_LIBNIO_MAPFILE := $(TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
-endif
-
-ifeq ($(OPENJDK_TARGET_OS), aix)
-  BUILD_LIBNIO_MAPFILE := $(TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
-endif
-
-$(eval $(call SetupNativeCompilation, BUILD_LIBNIO, \
-    NAME := nio, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-    SRC := $(BUILD_LIBNIO_SRC), \
-    EXCLUDE_FILES := $(BUILD_LIBNIO_EXFILES), \
-    OPTIMIZATION := HIGH, \
-    WARNINGS_AS_ERRORS_xlc := false, \
-    CFLAGS := $(CFLAGS_JDKLIB) \
-        $(BUILD_LIBNIO_CFLAGS), \
-    MAPFILE := $(BUILD_LIBNIO_MAPFILE), \
-    LDFLAGS := $(LDFLAGS_JDKLIB) \
-        $(call SET_SHARED_LIBRARY_ORIGIN), \
-    LIBS_unix := -ljava -lnet, \
-    LIBS_linux := -lpthread $(LIBDL), \
-    LIBS_solaris := -ljvm -lsocket -lposix4 $(LIBDL) \
-        -lsendfile -lc, \
-    LIBS_aix := $(LIBDL), \
-    LIBS_macosx := \
-        -framework CoreFoundation -framework CoreServices, \
-    LIBS_windows := jvm.lib ws2_32.lib $(WIN_JAVA_LIB) \
-        $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libnet/net.lib \
-        advapi32.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=nio.dll" \
-        -D "JDK_INTERNAL_NAME=nio" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libnio, \
-))
-
-TARGETS += $(BUILD_LIBNIO)
-
-$(BUILD_LIBNIO): $(BUILD_LIBNET)
--- a/make/lib/PlatformLibraries.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#
-# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-################################################################################
-
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-
-  LIBOSXAPP_SRC := $(TOPDIR)/src/java.desktop/macosx/native/libosxapp
-
-  $(eval $(call SetupNativeCompilation, BUILD_LIBOSXAPP, \
-      NAME := osxapp, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-      SRC := $(LIBOSXAPP_SRC), \
-      OPTIMIZATION := LOW, \
-      CFLAGS := $(CFLAGS_JDKLIB) \
-          $(addprefix -I, $(LIBOSXAPP_SRC)) \
-          -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop, \
-      DISABLED_WARNINGS_clang := objc-method-access objc-root-class, \
-      LDFLAGS := $(LDFLAGS_JDKLIB) \
-          $(call SET_SHARED_LIBRARY_ORIGIN), \
-      LIBS := \
-          -framework Accelerate \
-          -framework ApplicationServices \
-          -framework AudioToolbox \
-          -framework Carbon \
-          -framework Cocoa \
-          -framework Security \
-          -framework ExceptionHandling \
-          -framework JavaNativeFoundation \
-          -framework JavaRuntimeSupport \
-          -framework OpenGL \
-          -framework IOSurface \
-          -framework QuartzCore, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libosxapp, \
-  ))
-
-  TARGETS += $(BUILD_LIBOSXAPP)
-
-endif
--- a/make/lib/SecurityLibraries.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-#
-# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.  Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-include LibCommon.gmk
-
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-  # JavaNativeFoundation framework not supported in static builds
-  ifneq ($(STATIC_BUILD), true)
-
-  ################################################################################
-
-    LIBOSXSECURITY_DIRS := $(TOPDIR)/src/java.base/macosx/native/libosxsecurity
-    LIBOSXSECURITY_CFLAGS := -I$(LIBOSXSECURITY_DIRS) \
-        $(LIBJAVA_HEADER_FLAGS) \
-        -I$(SUPPORT_OUTPUTDIR)/headers/java.base \
-
-    $(eval $(call SetupNativeCompilation, BUILD_LIBOSXSECURITY, \
-        NAME := osxsecurity, \
-        OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-        SRC := $(LIBOSXSECURITY_DIRS), \
-        OPTIMIZATION := LOW, \
-        CFLAGS := $(CFLAGS_JDKLIB) \
-            $(LIBOSXSECURITY_CFLAGS), \
-        DISABLED_WARNINGS_clang := deprecated-declarations, \
-        LDFLAGS := $(LDFLAGS_JDKLIB) \
-            -L$(SUPPORT_OUTPUTDIR)/modules_libs/java.base \
-            $(call SET_SHARED_LIBRARY_ORIGIN) \
-            -fobjc-link-runtime, \
-        LIBS := \
-            -framework JavaNativeFoundation \
-            -framework CoreServices \
-            -framework Security \
-            $(JDKLIB_LIBS), \
-        OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libosxsecurity, \
-    ))
-
-    $(BUILD_LIBOSXSECURITY): $(BUILD_LIBJAVA)
-
-    TARGETS += $(BUILD_LIBOSXSECURITY)
-
-  ################################################################################
-
-  endif
-endif
--- a/make/lib/SoundLibraries.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/lib/SoundLibraries.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -114,9 +114,8 @@
 
 LIBJSOUND_CFLAGS += -DEXTRA_SOUND_JNI_LIBS='"$(EXTRA_SOUND_JNI_LIBS)"'
 
-$(eval $(call SetupNativeCompilation, BUILD_LIBJSOUND, \
+$(eval $(call SetupJdkLibrary, BUILD_LIBJSOUND, \
     NAME := jsound, \
-    OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
     SRC := $(LIBJSOUND_SRC_DIRS), \
     INCLUDE_FILES := $(LIBJSOUND_SRC_FILES), \
     TOOLCHAIN := $(LIBJSOUND_TOOLCHAIN), \
@@ -128,17 +127,10 @@
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
     LIBS_unix := -ljava -ljvm, \
-    LIBS_solaris := -lc, \
     LIBS_macosx := -framework CoreAudio -framework CoreFoundation \
         -framework CoreServices -framework AudioUnit $(LIBCXX) \
         -framework CoreMIDI -framework AudioToolbox, \
     LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib winmm.lib, \
-    VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-    RC_FLAGS := $(RC_FLAGS) \
-        -D "JDK_FNAME=jsound.dll" \
-        -D "JDK_INTERNAL_NAME=jsound" \
-        -D "JDK_FTYPE=0x2L", \
-    OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjsound, \
 ))
 
 $(BUILD_LIBJSOUND): $(BUILD_LIBJAVA)
@@ -149,9 +141,8 @@
 
 ifneq ($(filter jsoundalsa, $(EXTRA_SOUND_JNI_LIBS)), )
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBJSOUNDALSA, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBJSOUNDALSA, \
       NAME := jsoundalsa, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBJSOUND_SRC_DIRS), \
       INCLUDE_FILES := Utilities.c $(LIBJSOUND_MIDIFILES) $(LIBJSOUND_PORTFILES) \
           $(LIBJSOUND_DAUDIOFILES) \
@@ -173,7 +164,6 @@
       LDFLAGS := $(LDFLAGS_JDKLIB) \
           $(call SET_SHARED_LIBRARY_ORIGIN), \
       LIBS := $(ALSA_LIBS) -ljava -ljvm, \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjsoundalsa, \
   ))
 
   $(BUILD_LIBJSOUNDALSA): $(BUILD_LIBJAVA)
@@ -186,9 +176,8 @@
 
 ifneq ($(filter jsoundds, $(EXTRA_SOUND_JNI_LIBS)), )
 
-  $(eval $(call SetupNativeCompilation, BUILD_LIBJSOUNDDS, \
+  $(eval $(call SetupJdkLibrary, BUILD_LIBJSOUNDDS, \
       NAME := jsoundds, \
-      OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
       SRC := $(LIBJSOUND_SRC_DIRS), \
       INCLUDE_FILES := Utilities.c $(LIBJSOUND_DAUDIOFILES) \
           PLATFORM_API_WinOS_Charset_Util.cpp \
@@ -200,12 +189,6 @@
       LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
           $(call SET_SHARED_LIBRARY_ORIGIN), \
       LIBS := $(JDKLIB_LIBS) dsound.lib winmm.lib user32.lib ole32.lib, \
-      VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
-      RC_FLAGS := $(RC_FLAGS) \
-          -D "JDK_FNAME=jsoundds.dll" \
-          -D "JDK_INTERNAL_NAME=jsoundds" \
-          -D "JDK_FTYPE=0x2L", \
-      OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjsoundds, \
   ))
 
   $(BUILD_LIBJSOUNDDS): $(BUILD_LIBJAVA)
--- a/make/test/JtregNativeHotspot.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/test/JtregNativeHotspot.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -41,113 +41,45 @@
 # Targets for building the native tests themselves.
 ################################################################################
 
-# Add more directories here when needed.
-BUILD_HOTSPOT_JTREG_NATIVE_SRC += \
-    $(TOPDIR)/test/hotspot/jtreg/gc/g1/TestJNIWeakG1 \
-    $(TOPDIR)/test/hotspot/jtreg/gc/stress/TestJNIBlockFullGC \
-    $(TOPDIR)/test/hotspot/jtreg/gc/stress/gclocker \
-    $(TOPDIR)/test/hotspot/jtreg/gc/cslocker \
-    $(TOPDIR)/test/hotspot/jtreg/native_sanity \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/8025979 \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/8033445 \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/checked \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/FindClass \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/PrivateInterfaceMethods \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/ToStringInInterfaceTest \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/CalleeSavedRegisters \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/CallWithJNIWeak \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jni/ReturnJNIWeak \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/modules/getModuleJNI \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/SameObject \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/BoolReturn \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/noClassDefFoundMsg \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/handshake \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/RedefineTests \
-    $(TOPDIR)/test/hotspot/jtreg/compiler/floatingpoint/ \
-    $(TOPDIR)/test/hotspot/jtreg/compiler/calls \
-    $(TOPDIR)/test/hotspot/jtreg/compiler/runtime/criticalnatives/lookup \
-    $(TOPDIR)/test/hotspot/jtreg/compiler/runtime/criticalnatives/argumentcorruption \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/CanGenerateAllClassHook \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorStackDepthInfo \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetNamedModule \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/IsModifiableModule \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/AddModuleReads \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/AddModuleExportsAndOpens \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/AddModuleUsesAndProvides \
-    $(TOPDIR)/test/hotspot/jtreg/testlibrary/jvmti \
-    $(TOPDIR)/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/GetModulesInfo \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/ModuleAwareAgents/ClassFileLoadHook \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/ModuleAwareAgents/ClassLoadPrepare \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/ModuleAwareAgents/ThreadStart \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/jvmti/StartPhase/AllowedFunctions \
-    $(TOPDIR)/test/hotspot/jtreg/serviceability/dcmd/jvmti/AttachFailed \
-    #
+# This might have been added to by a custom extension.
+BUILD_HOTSPOT_JTREG_NATIVE_SRC += $(TOPDIR)/test/hotspot/jtreg
+
+BUILD_HOTSPOT_JTREG_OUTPUT_DIR := $(OUTPUTDIR)/support/test/hotspot/jtreg/native
 
-# Add conditional directories here when needed.
-ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc)
-BUILD_HOTSPOT_JTREG_NATIVE_SRC += \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/libadimalloc.solaris.sparc \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/ThreadSignalMask
-endif
-
-ifeq ($(OPENJDK_TARGET_OS), linux)
-BUILD_HOTSPOT_JTREG_NATIVE_SRC += \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/execstack \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/jsig \
-    $(TOPDIR)/test/hotspot/jtreg/runtime/StackGuardPages
-endif
+BUILD_HOTSPOT_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/hotspot/jtreg
 
-ifeq ($(TOOLCHAIN_TYPE), solstudio)
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_liboverflow := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libSimpleClassFileLoadHook := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libCanGenerateAllClassHook := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetOwnedMonitorInfoTest := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetOwnedMonitorStackDepthInfoTest := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libGetNamedModuleTest := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libIsModifiableModuleTest := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleReadsTest := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleExportsAndOpensTest := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libAddModuleUsesAndProvidesTest := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libMAAClassFileLoadHook := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libMAAClassLoadPrepare := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libMAAThreadStart := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libAllowedFunctions := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libRedefineDoubleDelete := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libHandshakeTransitionTest := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libHasNoEntryPoint := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libReturnError := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libCNLookUp := -lc
-    BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libTestCheckedEnsureLocalCapacity := -lc
+# Platform specific setup
+ifneq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc)
+  BUILD_HOTSPOT_JTREG_EXCLUDE += liboverflow.c exeThreadSignalMask.c
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), linux)
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libtest-rw := -z noexecstack
     BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libtest-rwx := -z execstack
     BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exeinvoke := -ljvm -lpthread
-    BUILD_TEST_invoke_exeinvoke.c_OPTIMIZATION := NONE
+    BUILD_TEST_exeinvoke_exeinvoke.c_OPTIMIZATION := NONE
     BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exeFPRegs := -ldl
+else
+  BUILD_HOTSPOT_JTREG_EXCLUDE += libtest-rw.c libtest-rwx.c libTestJNI.c \
+      exeinvoke.c
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), windows)
     BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT
 endif
 
-BUILD_HOTSPOT_JTREG_OUTPUT_DIR := $(OUTPUTDIR)/support/test/hotspot/jtreg/native
-
-BUILD_HOTSPOT_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/hotspot/jtreg
-
 $(eval $(call SetupTestFilesCompilation, BUILD_HOTSPOT_JTREG_LIBRARIES, \
     TYPE := LIBRARY, \
     SOURCE_DIRS := $(BUILD_HOTSPOT_JTREG_NATIVE_SRC), \
     OUTPUT_DIR := $(BUILD_HOTSPOT_JTREG_OUTPUT_DIR), \
+    EXCLUDE := $(BUILD_HOTSPOT_JTREG_EXCLUDE), \
 ))
 
 $(eval $(call SetupTestFilesCompilation, BUILD_HOTSPOT_JTREG_EXECUTABLES, \
     TYPE := PROGRAM, \
     SOURCE_DIRS := $(BUILD_HOTSPOT_JTREG_NATIVE_SRC), \
     OUTPUT_DIR := $(BUILD_HOTSPOT_JTREG_OUTPUT_DIR), \
+    EXCLUDE := $(BUILD_HOTSPOT_JTREG_EXCLUDE), \
 ))
 
 build-test-hotspot-jtreg-native: $(BUILD_HOTSPOT_JTREG_LIBRARIES) $(BUILD_HOTSPOT_JTREG_EXECUTABLES)
--- a/make/test/JtregNativeJdk.gmk	Thu Mar 15 19:33:51 2018 +0530
+++ b/make/test/JtregNativeJdk.gmk	Thu Mar 15 11:36:11 2018 -0700
@@ -41,53 +41,45 @@
 # Targets for building the native tests themselves.
 ################################################################################
 
-# Add more directories here when needed.
-BUILD_JDK_JTREG_NATIVE_SRC += \
-    $(TOPDIR)/test/jdk/native_sanity \
-    $(TOPDIR)/test/jdk/java/lang/ClassLoader/nativeLibrary \
-    $(TOPDIR)/test/jdk/java/lang/String/nativeEncoding \
-    #
-
-ifneq ($(OPENJDK_TARGET_OS), windows)
-    BUILD_JDK_JTREG_NATIVE_SRC += $(TOPDIR)/test/jdk/java/nio/channels/FileChannel/directio
-    BUILD_JDK_JTREG_NATIVE_SRC += $(TOPDIR)/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel
-endif
+# This might have been added to by a custom extension.
+BUILD_JDK_JTREG_NATIVE_SRC += $(TOPDIR)/test/jdk
 
 BUILD_JDK_JTREG_OUTPUT_DIR := $(OUTPUTDIR)/support/test/jdk/jtreg/native
 
 BUILD_JDK_JTREG_IMAGE_DIR := $(TEST_IMAGE_DIR)/jdk/jtreg
 
+# Platform specific setup
 ifeq ($(OPENJDK_TARGET_OS), windows)
-    WIN_LIB_JAVA := $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib
-    BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := $(WIN_LIB_JAVA)
-else ifeq ($(OPENJDK_TARGET_OS), linux)
-    BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava
-    BUILD_JDK_JTREG_LIBRARIES_LIBS_libDirectIO := -ljava
+  BUILD_JDK_JTREG_EXCLUDE += libDirectIO.c libInheritedChannel.c
+
+  WIN_LIB_JAVA := $(SUPPORT_OUTPUTDIR)/native/java.base/libjava/java.lib
+  BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := $(WIN_LIB_JAVA)
+else
+  BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava
+  BUILD_JDK_JTREG_LIBRARIES_LIBS_libDirectIO := -ljava
+  ifeq ($(OPENJDK_TARGET_OS), linux)
     BUILD_JDK_JTREG_LIBRARIES_LIBS_libInheritedChannel := -ljava
-else ifeq ($(OPENJDK_TARGET_OS), solaris)
-    BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava -lc
-    BUILD_JDK_JTREG_LIBRARIES_LIBS_libDirectIO := -ljava -lc
-    BUILD_JDK_JTREG_LIBRARIES_LIBS_libInheritedChannel := -ljava -lc
-else
-    BUILD_JDK_JTREG_LIBRARIES_LIBS_libstringPlatformChars := -ljava
-    BUILD_JDK_JTREG_LIBRARIES_LIBS_libDirectIO := -ljava
+  else ifeq ($(OPENJDK_TARGET_OS), solaris)
+    BUILD_JDK_JTREG_LIBRARIES_LIBS_libInheritedChannel := -ljava
+  endif
 endif
 
 $(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_LIBRARIES, \
     TYPE := LIBRARY, \
     SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
     OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
+    EXCLUDE := $(BUILD_JDK_JTREG_EXCLUDE), \
 ))
 
 $(eval $(call SetupTestFilesCompilation, BUILD_JDK_JTREG_EXECUTABLES, \
     TYPE := PROGRAM, \
     SOURCE_DIRS := $(BUILD_JDK_JTREG_NATIVE_SRC), \
     OUTPUT_DIR := $(BUILD_JDK_JTREG_OUTPUT_DIR), \
+    EXCLUDE := $(BUILD_JDK_JTREG_EXCLUDE), \
 ))
 
 build-test-jdk-jtreg-native: $(BUILD_JDK_JTREG_LIBRARIES) $(BUILD_JDK_JTREG_EXECUTABLES)
 
-
 ################################################################################
 # Targets for building test-image.
 ################################################################################
--- a/src/java.base/linux/classes/sun/nio/ch/EPoll.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/linux/classes/sun/nio/ch/EPoll.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,6 +59,10 @@
     static final int EPOLL_CTL_DEL  = 2;
     static final int EPOLL_CTL_MOD  = 3;
 
+    // events
+    static final int EPOLLIN   = 0x1;
+    static final int EPOLLOUT  = 0x4;
+
     // flags
     static final int EPOLLONESHOT   = (1 << 30);
 
--- a/src/java.base/linux/classes/sun/nio/ch/EPollArrayWrapper.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/linux/classes/sun/nio/ch/EPollArrayWrapper.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -93,16 +93,10 @@
     private final long pollArrayAddress;
 
     // The fd of the interrupt line going out
-    private int outgoingInterruptFD;
-
-    // The fd of the interrupt line coming in
-    private int incomingInterruptFD;
-
-    // The index of the interrupt FD
-    private int interruptedIndex;
+    private final int outgoingInterruptFD;
 
     // Number of updated pollfd entries
-    int updated;
+    private int updated;
 
     // object to synchronize fd registration changes
     private final Object updateLock = new Object();
@@ -125,7 +119,7 @@
     private final BitSet registered = new BitSet();
 
 
-    EPollArrayWrapper() throws IOException {
+    EPollArrayWrapper(int fd0, int fd1) throws IOException {
         // creates the epoll file descriptor
         epfd = epollCreate();
 
@@ -133,11 +127,8 @@
         int allocationSize = NUM_EPOLLEVENTS * SIZE_EPOLLEVENT;
         pollArray = new AllocatedNativeObject(allocationSize, true);
         pollArrayAddress = pollArray.address();
-    }
 
-    void initInterrupt(int fd0, int fd1) {
         outgoingInterruptFD = fd1;
-        incomingInterruptFD = fd0;
         epollCtl(epfd, EPOLL_CTL_ADD, fd0, EPOLLIN);
     }
 
@@ -255,22 +246,14 @@
     /**
      * Close epoll file descriptor and free poll array
      */
-    void closeEPollFD() throws IOException {
+    void close() throws IOException {
         FileDispatcherImpl.closeIntFD(epfd);
         pollArray.free();
     }
 
     int poll(long timeout) throws IOException {
         updateRegistrations();
-        updated = epollWait(pollArrayAddress, NUM_EPOLLEVENTS, timeout, epfd);
-        for (int i=0; i<updated; i++) {
-            if (getDescriptor(i) == incomingInterruptFD) {
-                interruptedIndex = i;
-                interrupted = true;
-                break;
-            }
-        }
-        return updated;
+        return epollWait(pollArrayAddress, NUM_EPOLLEVENTS, timeout, epfd);
     }
 
     /**
@@ -306,25 +289,10 @@
         }
     }
 
-    // interrupt support
-    private boolean interrupted = false;
-
     public void interrupt() {
         interrupt(outgoingInterruptFD);
     }
 
-    public int interruptedIndex() {
-        return interruptedIndex;
-    }
-
-    boolean interrupted() {
-        return interrupted;
-    }
-
-    void clearInterrupted() {
-        interrupted = false;
-    }
-
     static {
         IOUtil.load();
         init();
--- a/src/java.base/linux/classes/sun/nio/ch/EPollPort.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/linux/classes/sun/nio/ch/EPollPort.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -93,7 +93,7 @@
         try {
             socketpair(sv);
             // register one end with epoll
-            epollCtl(epfd, EPOLL_CTL_ADD, sv[0], Net.POLLIN);
+            epollCtl(epfd, EPOLL_CTL_ADD, sv[0], EPOLLIN);
         } catch (IOException x) {
             close0(epfd);
             throw x;
--- a/src/java.base/linux/classes/sun/nio/ch/EPollSelectorImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/linux/classes/sun/nio/ch/EPollSelectorImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,16 +37,15 @@
 class EPollSelectorImpl
     extends SelectorImpl
 {
-
     // File descriptors used for interrupt
-    protected int fd0;
-    protected int fd1;
+    private final int fd0;
+    private final int fd1;
 
     // The poll object
-    EPollArrayWrapper pollWrapper;
+    private final EPollArrayWrapper pollWrapper;
 
     // Maps from file descriptors to keys
-    private Map<Integer,SelectionKeyImpl> fdToKey;
+    private final Map<Integer, SelectionKeyImpl> fdToKey;
 
     // True if this Selector has been closed
     private volatile boolean closed;
@@ -65,8 +64,7 @@
         fd0 = (int) (pipeFds >>> 32);
         fd1 = (int) pipeFds;
         try {
-            pollWrapper = new EPollArrayWrapper();
-            pollWrapper.initInterrupt(fd0, fd1);
+            pollWrapper = new EPollArrayWrapper(fd0, fd1);
             fdToKey = new HashMap<>();
         } catch (Throwable t) {
             try {
@@ -83,59 +81,64 @@
         }
     }
 
-    protected int doSelect(long timeout) throws IOException {
+    private void ensureOpen() {
         if (closed)
             throw new ClosedSelectorException();
+    }
+
+    @Override
+    protected int doSelect(long timeout) throws IOException {
+        ensureOpen();
+        int numEntries;
         processDeregisterQueue();
         try {
             begin();
-            pollWrapper.poll(timeout);
+            numEntries = pollWrapper.poll(timeout);
         } finally {
             end();
         }
         processDeregisterQueue();
-        int numKeysUpdated = updateSelectedKeys();
-        if (pollWrapper.interrupted()) {
-            // Clear the wakeup pipe
-            pollWrapper.putEventOps(pollWrapper.interruptedIndex(), 0);
-            synchronized (interruptLock) {
-                pollWrapper.clearInterrupted();
-                IOUtil.drain(fd0);
-                interruptTriggered = false;
-            }
-        }
-        return numKeysUpdated;
+        return updateSelectedKeys(numEntries);
     }
 
     /**
      * Update the keys whose fd's have been selected by the epoll.
      * Add the ready keys to the ready queue.
      */
-    private int updateSelectedKeys() {
-        int entries = pollWrapper.updated;
+    private int updateSelectedKeys(int numEntries) throws IOException {
+        boolean interrupted = false;
         int numKeysUpdated = 0;
-        for (int i=0; i<entries; i++) {
+        for (int i=0; i<numEntries; i++) {
             int nextFD = pollWrapper.getDescriptor(i);
-            SelectionKeyImpl ski = fdToKey.get(Integer.valueOf(nextFD));
-            // ski is null in the case of an interrupt
-            if (ski != null) {
-                int rOps = pollWrapper.getEventOps(i);
-                if (selectedKeys.contains(ski)) {
-                    if (ski.channel.translateAndSetReadyOps(rOps, ski)) {
-                        numKeysUpdated++;
-                    }
-                } else {
-                    ski.channel.translateAndSetReadyOps(rOps, ski);
-                    if ((ski.nioReadyOps() & ski.nioInterestOps()) != 0) {
-                        selectedKeys.add(ski);
-                        numKeysUpdated++;
+            if (nextFD == fd0) {
+                interrupted = true;
+            } else {
+                SelectionKeyImpl ski = fdToKey.get(Integer.valueOf(nextFD));
+                if (ski != null) {
+                    int rOps = pollWrapper.getEventOps(i);
+                    if (selectedKeys.contains(ski)) {
+                        if (ski.channel.translateAndSetReadyOps(rOps, ski)) {
+                            numKeysUpdated++;
+                        }
+                    } else {
+                        ski.channel.translateAndSetReadyOps(rOps, ski);
+                        if ((ski.nioReadyOps() & ski.nioInterestOps()) != 0) {
+                            selectedKeys.add(ski);
+                            numKeysUpdated++;
+                        }
                     }
                 }
             }
         }
+
+        if (interrupted) {
+            clearInterrupt();
+        }
+
         return numKeysUpdated;
     }
 
+    @Override
     protected void implClose() throws IOException {
         if (closed)
             return;
@@ -146,13 +149,10 @@
             interruptTriggered = true;
         }
 
+        pollWrapper.close();
         FileDispatcherImpl.closeIntFD(fd0);
         FileDispatcherImpl.closeIntFD(fd1);
 
-        pollWrapper.closeEPollFD();
-        // it is possible
-        selectedKeys = null;
-
         // Deregister channels
         Iterator<SelectionKey> i = keys.iterator();
         while (i.hasNext()) {
@@ -163,14 +163,11 @@
                 ((SelChImpl)selch).kill();
             i.remove();
         }
-
-        fd0 = -1;
-        fd1 = -1;
     }
 
+    @Override
     protected void implRegister(SelectionKeyImpl ski) {
-        if (closed)
-            throw new ClosedSelectorException();
+        ensureOpen();
         SelChImpl ch = ski.channel;
         int fd = Integer.valueOf(ch.getFDVal());
         fdToKey.put(fd, ski);
@@ -178,6 +175,7 @@
         keys.add(ski);
     }
 
+    @Override
     protected void implDereg(SelectionKeyImpl ski) throws IOException {
         assert (ski.getIndex() >= 0);
         SelChImpl ch = ski.channel;
@@ -187,19 +185,20 @@
         ski.setIndex(-1);
         keys.remove(ski);
         selectedKeys.remove(ski);
-        deregister((AbstractSelectionKey)ski);
+        deregister(ski);
         SelectableChannel selch = ski.channel();
         if (!selch.isOpen() && !selch.isRegistered())
             ((SelChImpl)selch).kill();
     }
 
+    @Override
     public void putEventOps(SelectionKeyImpl ski, int ops) {
-        if (closed)
-            throw new ClosedSelectorException();
+        ensureOpen();
         SelChImpl ch = ski.channel;
         pollWrapper.setInterest(ch.getFDVal(), ops);
     }
 
+    @Override
     public Selector wakeup() {
         synchronized (interruptLock) {
             if (!interruptTriggered) {
@@ -209,4 +208,11 @@
         }
         return this;
     }
+
+    private void clearInterrupt() throws IOException {
+        synchronized (interruptLock) {
+            IOUtil.drain(fd0);
+            interruptTriggered = false;
+        }
+    }
 }
--- a/src/java.base/macosx/classes/sun/nio/ch/KQueue.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/macosx/classes/sun/nio/ch/KQueue.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,6 +58,7 @@
 
     // flags
     static final int EV_ADD     = 0x0001;
+    static final int EV_DELETE  = 0x0002;
     static final int EV_ONESHOT = 0x0010;
     static final int EV_CLEAR   = 0x0020;
 
--- a/src/java.base/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,20 +66,18 @@
     static final int NUM_KEVENTS = 128;
 
     // Are we in a 64-bit VM?
-    static boolean is64bit = false;
+    static boolean is64bit;
 
     // The kevent array (used for outcoming events only)
-    private AllocatedNativeObject keventArray = null;
-    private long keventArrayAddress;
+    private final AllocatedNativeObject keventArray;
+    private final long keventArrayAddress;
 
     // The kqueue fd
-    private int kq = -1;
+    private final int kq;
 
     // The fd of the interrupt line going out
-    private int outgoingInterruptFD;
+    private final int outgoingInterruptFD;
 
-    // The fd of the interrupt line coming in
-    private int incomingInterruptFD;
 
     static {
         IOUtil.load();
@@ -89,11 +87,13 @@
         is64bit = "64".equals(datamodel);
     }
 
-    KQueueArrayWrapper() {
+    KQueueArrayWrapper(int fd0, int fd1) throws IOException {
         int allocationSize = SIZEOF_KEVENT * NUM_KEVENTS;
         keventArray = new AllocatedNativeObject(allocationSize, true);
         keventArrayAddress = keventArray.address();
         kq = init();
+        register0(kq, fd0, 1, 0);
+        outgoingInterruptFD = fd1;
     }
 
     // Used to update file description registrations
@@ -108,12 +108,6 @@
 
     private LinkedList<Update> updateList = new LinkedList<Update>();
 
-    void initInterrupt(int fd0, int fd1) {
-        outgoingInterruptFD = fd1;
-        incomingInterruptFD = fd0;
-        register0(kq, fd0, 1, 0);
-    }
-
     int getReventOps(int index) {
         int result = 0;
         int offset = SIZEOF_KEVENT*index + FILTER_OFFSET;
@@ -137,11 +131,11 @@
          * to return an int. Hence read the 8 bytes but return as an int.
          */
         if (is64bit) {
-          long fd = keventArray.getLong(offset);
-          assert fd <= Integer.MAX_VALUE;
-          return (int) fd;
+            long fd = keventArray.getLong(offset);
+            assert fd <= Integer.MAX_VALUE;
+            return (int) fd;
         } else {
-          return keventArray.getInt(offset);
+            return keventArray.getInt(offset);
         }
     }
 
@@ -168,7 +162,7 @@
 
     void updateRegistrations() {
         synchronized (updateList) {
-            Update u = null;
+            Update u;
             while ((u = updateList.poll()) != null) {
                 SelChImpl ch = u.channel;
                 if (!ch.isOpen())
@@ -179,22 +173,14 @@
         }
     }
 
-
     void close() throws IOException {
-        if (keventArray != null) {
-            keventArray.free();
-            keventArray = null;
-        }
-        if (kq >= 0) {
-            FileDispatcherImpl.closeIntFD(kq);
-            kq = -1;
-        }
+        FileDispatcherImpl.closeIntFD(kq);
+        keventArray.free();
     }
 
     int poll(long timeout) {
         updateRegistrations();
-        int updated = kevent0(kq, keventArrayAddress, NUM_KEVENTS, timeout);
-        return updated;
+        return kevent0(kq, keventArrayAddress, NUM_KEVENTS, timeout);
     }
 
     void interrupt() {
--- a/src/java.base/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,39 +26,38 @@
 /*
  * KQueueSelectorImpl.java
  * Implementation of Selector using FreeBSD / Mac OS X kqueues
- * Derived from Sun's DevPollSelectorImpl
  */
 
 package sun.nio.ch;
 
 import java.io.IOException;
-import java.io.FileDescriptor;
-import java.nio.channels.*;
-import java.nio.channels.spi.*;
-import java.util.*;
+import java.nio.channels.ClosedSelectorException;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.spi.SelectorProvider;
+import java.util.HashMap;
+import java.util.Iterator;
 
 class KQueueSelectorImpl
     extends SelectorImpl
 {
     // File descriptors used for interrupt
-    protected int fd0;
-    protected int fd1;
+    private final int fd0;
+    private final int fd1;
 
     // The kqueue manipulator
-    KQueueArrayWrapper kqueueWrapper;
-
-    // Count of registered descriptors (including interrupt)
-    private int totalChannels;
+    private final KQueueArrayWrapper kqueueWrapper;
 
     // Map from a file descriptor to an entry containing the selection key
-    private HashMap<Integer,MapEntry> fdMap;
+    private final HashMap<Integer, MapEntry> fdMap;
 
     // True if this Selector has been closed
-    private boolean closed = false;
+    private boolean closed;
 
     // Lock for interrupt triggering and clearing
-    private Object interruptLock = new Object();
-    private boolean interruptTriggered = false;
+    private final Object interruptLock = new Object();
+    private boolean interruptTriggered;
 
     // used by updateSelectedKeys to handle cases where the same file
     // descriptor is polled by more than one filter
@@ -78,16 +77,14 @@
      * Package private constructor called by factory method in
      * the abstract superclass Selector.
      */
-    KQueueSelectorImpl(SelectorProvider sp) {
+    KQueueSelectorImpl(SelectorProvider sp) throws IOException {
         super(sp);
         long fds = IOUtil.makePipe(false);
         fd0 = (int)(fds >>> 32);
         fd1 = (int)fds;
         try {
-            kqueueWrapper = new KQueueArrayWrapper();
-            kqueueWrapper.initInterrupt(fd0, fd1);
+            kqueueWrapper = new KQueueArrayWrapper(fd0, fd1);
             fdMap = new HashMap<>();
-            totalChannels = 1;
         } catch (Throwable t) {
             try {
                 FileDispatcherImpl.closeIntFD(fd0);
@@ -103,22 +100,26 @@
         }
     }
 
+    private void ensureOpen() {
+        if (closed)
+            throw new ClosedSelectorException();
+    }
 
+    @Override
     protected int doSelect(long timeout)
         throws IOException
     {
-        int entries = 0;
-        if (closed)
-            throw new ClosedSelectorException();
+        ensureOpen();
+        int numEntries;
         processDeregisterQueue();
         try {
             begin();
-            entries = kqueueWrapper.poll(timeout);
+            numEntries = kqueueWrapper.poll(timeout);
         } finally {
             end();
         }
         processDeregisterQueue();
-        return updateSelectedKeys(entries);
+        return updateSelectedKeys(numEntries);
     }
 
     /**
@@ -126,7 +127,7 @@
      * Add the ready keys to the selected key set.
      * If the interrupt fd has been selected, drain it and clear the interrupt.
      */
-    private int updateSelectedKeys(int entries)
+    private int updateSelectedKeys(int numEntries)
         throws IOException
     {
         int numKeysUpdated = 0;
@@ -139,14 +140,12 @@
         // second or subsequent event.
         updateCount++;
 
-        for (int i = 0; i < entries; i++) {
+        for (int i = 0; i < numEntries; i++) {
             int nextFD = kqueueWrapper.getDescriptor(i);
             if (nextFD == fd0) {
                 interrupted = true;
             } else {
                 MapEntry me = fdMap.get(Integer.valueOf(nextFD));
-
-                // entry is null in the case of an interrupt
                 if (me != null) {
                     int rOps = kqueueWrapper.getReventOps(i);
                     SelectionKeyImpl ski = me.ski;
@@ -175,16 +174,12 @@
         }
 
         if (interrupted) {
-            // Clear the wakeup pipe
-            synchronized (interruptLock) {
-                IOUtil.drain(fd0);
-                interruptTriggered = false;
-            }
+            clearInterrupt();
         }
         return numKeysUpdated;
     }
 
-
+    @Override
     protected void implClose() throws IOException {
         if (!closed) {
             closed = true;
@@ -194,62 +189,51 @@
                 interruptTriggered = true;
             }
 
+            kqueueWrapper.close();
             FileDispatcherImpl.closeIntFD(fd0);
             FileDispatcherImpl.closeIntFD(fd1);
-            if (kqueueWrapper != null) {
-                kqueueWrapper.close();
-                kqueueWrapper = null;
-                selectedKeys = null;
 
-                // Deregister channels
-                Iterator<SelectionKey> i = keys.iterator();
-                while (i.hasNext()) {
-                    SelectionKeyImpl ski = (SelectionKeyImpl)i.next();
-                    deregister(ski);
-                    SelectableChannel selch = ski.channel();
-                    if (!selch.isOpen() && !selch.isRegistered())
-                        ((SelChImpl)selch).kill();
-                    i.remove();
-                }
-                totalChannels = 0;
+            // Deregister channels
+            Iterator<SelectionKey> i = keys.iterator();
+            while (i.hasNext()) {
+                SelectionKeyImpl ski = (SelectionKeyImpl)i.next();
+                deregister(ski);
+                SelectableChannel selch = ski.channel();
+                if (!selch.isOpen() && !selch.isRegistered())
+                    ((SelChImpl)selch).kill();
+                i.remove();
             }
-            fd0 = -1;
-            fd1 = -1;
         }
     }
 
-
+    @Override
     protected void implRegister(SelectionKeyImpl ski) {
-        if (closed)
-            throw new ClosedSelectorException();
+        ensureOpen();
         int fd = IOUtil.fdVal(ski.channel.getFD());
         fdMap.put(Integer.valueOf(fd), new MapEntry(ski));
-        totalChannels++;
         keys.add(ski);
     }
 
-
+    @Override
     protected void implDereg(SelectionKeyImpl ski) throws IOException {
         int fd = ski.channel.getFDVal();
         fdMap.remove(Integer.valueOf(fd));
         kqueueWrapper.release(ski.channel);
-        totalChannels--;
         keys.remove(ski);
         selectedKeys.remove(ski);
-        deregister((AbstractSelectionKey)ski);
+        deregister(ski);
         SelectableChannel selch = ski.channel();
         if (!selch.isOpen() && !selch.isRegistered())
             ((SelChImpl)selch).kill();
     }
 
-
+    @Override
     public void putEventOps(SelectionKeyImpl ski, int ops) {
-        if (closed)
-            throw new ClosedSelectorException();
+        ensureOpen();
         kqueueWrapper.setInterest(ski.channel, ops);
     }
 
-
+    @Override
     public Selector wakeup() {
         synchronized (interruptLock) {
             if (!interruptTriggered) {
@@ -259,4 +243,11 @@
         }
         return this;
     }
+
+    private void clearInterrupt() throws IOException {
+        synchronized (interruptLock) {
+            IOUtil.drain(fd0);
+            interruptTriggered = false;
+        }
+    }
 }
--- a/src/java.base/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
 import java.nio.channels.spi.*;
 
 public class KQueueSelectorProvider
-extends SelectorProviderImpl
+    extends SelectorProviderImpl
 {
     public AbstractSelector openSelector() throws IOException {
         return new KQueueSelectorImpl(this);
--- a/src/java.base/share/classes/java/io/InputStream.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/io/InputStream.java	Thu Mar 15 11:36:11 2018 -0700
@@ -539,29 +539,29 @@
     }
 
     /**
-     * Returns an estimate of the number of bytes that can be read (or
-     * skipped over) from this input stream without blocking by the next
-     * invocation of a method for this input stream. The next invocation
-     * might be the same thread or another thread.  A single read or skip of this
-     * many bytes will not block, but may read or skip fewer bytes.
+     * Returns an estimate of the number of bytes that can be read (or skipped
+     * over) from this input stream without blocking, which may be 0, or 0 when
+     * end of stream is detected.  The read might be on the same thread or
+     * another thread.  A single read or skip of this many bytes will not block,
+     * but may read or skip fewer bytes.
      *
-     * <p> Note that while some implementations of {@code InputStream} will return
-     * the total number of bytes in the stream, many will not.  It is
+     * <p> Note that while some implementations of {@code InputStream} will
+     * return the total number of bytes in the stream, many will not.  It is
      * never correct to use the return value of this method to allocate
      * a buffer intended to hold all data in this stream.
      *
-     * <p> A subclass' implementation of this method may choose to throw an
-     * {@link IOException} if this input stream has been closed by
-     * invoking the {@link #close()} method.
+     * <p> A subclass's implementation of this method may choose to throw an
+     * {@link IOException} if this input stream has been closed by invoking the
+     * {@link #close()} method.
      *
-     * <p> The {@code available} method for class {@code InputStream} always
-     * returns {@code 0}.
+     * <p> The {@code available} method of {@code InputStream} always returns
+     * {@code 0}.
      *
      * <p> This method should be overridden by subclasses.
      *
-     * @return     an estimate of the number of bytes that can be read (or skipped
-     *             over) from this input stream without blocking or {@code 0} when
-     *             it reaches the end of the input stream.
+     * @return     an estimate of the number of bytes that can be read (or
+     *             skipped over) from this input stream without blocking or
+     *             {@code 0} when it reaches the end of the input stream.
      * @exception  IOException if an I/O error occurs.
      */
     public int available() throws IOException {
--- a/src/java.base/share/classes/java/lang/Integer.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/lang/Integer.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1625,8 +1625,8 @@
     @HotSpotIntrinsicCandidate
     public static int numberOfLeadingZeros(int i) {
         // HD, Figure 5-6
-        if (i == 0)
-            return 32;
+        if (i <= 0)
+            return i == 0 ? 32 : 0;
         int n = 1;
         if (i >>> 16 == 0) { n += 16; i <<= 16; }
         if (i >>> 24 == 0) { n +=  8; i <<=  8; }
--- a/src/java.base/share/classes/java/lang/Long.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/lang/Long.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1771,8 +1771,8 @@
     @HotSpotIntrinsicCandidate
     public static int numberOfLeadingZeros(long i) {
         // HD, Figure 5-6
-         if (i == 0)
-            return 64;
+         if (i <= 0)
+            return i == 0 ? 64 : 0;
         int n = 1;
         int x = (int)(i >>> 32);
         if (x == 0) { n += 32; x = (int)i; }
--- a/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java	Thu Mar 15 11:36:11 2018 -0700
@@ -104,10 +104,10 @@
      *
      * @param lookup the lookup context describing the class performing the
      * operation (normally stacked by the JVM)
+     * @param name the name of the constant to return, which must exactly match
+     * an enum constant in the specified type.
      * @param type the {@code Class} object describing the enum type for which
      * a constant is to be returned
-     * @param name the name of the constant to return, which must exactly match
-     * an enum constant in the specified type.
      * @param <E> The enum type for which a constant value is to be returned
      * @return the enum constant of the specified enum type with the
      * specified name
@@ -208,20 +208,25 @@
     /**
      * Returns the result of invoking a method handle with the provided
      * arguments.
+     * <p>
+     * This method behaves as if the method handle to be invoked is the result
+     * of adapting the given method handle, via {@link MethodHandle#asType}, to
+     * adjust the return type to the desired type.
      *
      * @param lookup unused
      * @param name unused
-     * @param type the type of the value to be returned, which must be
+     * @param type the desired type of the value to be returned, which must be
      * compatible with the return type of the method handle
      * @param handle the method handle to be invoked
      * @param args the arguments to pass to the method handle, as if with
      * {@link MethodHandle#invokeWithArguments}.  Each argument may be
      * {@code null}.
      * @return the result of invoking the method handle
-     * @throws WrongMethodTypeException if the handle's return type cannot be
-     * adjusted to the desired type
-     * @throws ClassCastException if an argument cannot be converted by
-     * reference casting
+     * @throws WrongMethodTypeException if the handle's method type cannot be
+     * adjusted to take the given number of arguments, or if the handle's return
+     * type cannot be adjusted to the desired type
+     * @throws ClassCastException if an argument or the result produced by
+     * invoking the handle cannot be converted by reference casting
      * @throws Throwable anything thrown by the method handle invocation
      */
     public static Object invoke(MethodHandles.Lookup lookup, String name, Class<?> type,
--- a/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java	Thu Mar 15 11:36:11 2018 -0700
@@ -133,7 +133,7 @@
     }
 
     static byte[] generateInvokersHolderClassBytes(String className,
-            MethodType[] methodTypes) {
+            MethodType[] invokerMethodTypes, MethodType[] callSiteMethodTypes) {
 
         HashSet<MethodType> dedupSet = new HashSet<>();
         ArrayList<LambdaForm> forms = new ArrayList<>();
@@ -144,17 +144,33 @@
             MethodTypeForm.LF_GEN_LINKER,
             MethodTypeForm.LF_GEN_INVOKER
         };
-        for (int i = 0; i < methodTypes.length; i++) {
+
+        for (int i = 0; i < invokerMethodTypes.length; i++) {
             // generate methods representing invokers of the specified type
-            if (dedupSet.add(methodTypes[i])) {
+            if (dedupSet.add(invokerMethodTypes[i])) {
                 for (int type : types) {
-                    LambdaForm invokerForm = Invokers.invokeHandleForm(methodTypes[i],
+                    LambdaForm invokerForm = Invokers.invokeHandleForm(invokerMethodTypes[i],
                             /*customized*/false, type);
                     forms.add(invokerForm);
                     names.add(invokerForm.kind.defaultLambdaName);
                 }
             }
         }
+
+        dedupSet = new HashSet<>();
+        for (int i = 0; i < callSiteMethodTypes.length; i++) {
+            // generate methods representing invokers of the specified type
+            if (dedupSet.add(callSiteMethodTypes[i])) {
+                LambdaForm callSiteForm = Invokers.callSiteForm(callSiteMethodTypes[i], true);
+                forms.add(callSiteForm);
+                names.add(callSiteForm.kind.defaultLambdaName);
+
+                LambdaForm methodHandleForm = Invokers.callSiteForm(callSiteMethodTypes[i], false);
+                forms.add(methodHandleForm);
+                names.add(methodHandleForm.kind.defaultLambdaName);
+            }
+        }
+
         return generateCodeBytesForLFs(className,
                 names.toArray(new String[0]),
                 forms.toArray(new LambdaForm[0]));
--- a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Thu Mar 15 11:36:11 2018 -0700
@@ -649,6 +649,8 @@
             }
             case EXACT_INVOKER:             // fall-through
             case EXACT_LINKER:              // fall-through
+            case LINK_TO_CALL_SITE:         // fall-through
+            case LINK_TO_TARGET_METHOD:     // fall-through
             case GENERIC_INVOKER:           // fall-through
             case GENERIC_LINKER:            return resolveFrom(name, invokerType.basicType(), Invokers.Holder.class);
             case GET_OBJECT:                // fall-through
--- a/src/java.base/share/classes/java/lang/invoke/Invokers.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/lang/invoke/Invokers.java	Thu Mar 15 11:36:11 2018 -0700
@@ -523,7 +523,7 @@
     }
 
     // skipCallSite is true if we are optimizing a ConstantCallSite
-    private static LambdaForm callSiteForm(MethodType mtype, boolean skipCallSite) {
+    static LambdaForm callSiteForm(MethodType mtype, boolean skipCallSite) {
         mtype = mtype.basicType();  // normalize Z to I, String to Object, etc.
         final int which = (skipCallSite ? MethodTypeForm.LF_MH_LINKER : MethodTypeForm.LF_CS_LINKER);
         LambdaForm lform = mtype.form().cachedLambdaForm(which);
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1841,10 +1841,13 @@
 
             @Override
             public byte[] generateInvokersHolderClassBytes(final String className,
-                    MethodType[] methodTypes) {
+                    MethodType[] invokerMethodTypes,
+                    MethodType[] callSiteMethodTypes) {
                 return GenerateJLIClassesHelper
-                        .generateInvokersHolderClassBytes(className, methodTypes);
+                        .generateInvokersHolderClassBytes(className,
+                                invokerMethodTypes, callSiteMethodTypes);
             }
+
         });
     }
 
--- a/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java	Thu Mar 15 11:36:11 2018 -0700
@@ -449,7 +449,9 @@
          */
         for (Class<?> intf : interfaces) {
             for (Method m : intf.getMethods()) {
-                addProxyMethod(m, intf);
+                if (!Modifier.isStatic(m.getModifiers())) {
+                    addProxyMethod(m, intf);
+                }
             }
         }
 
--- a/src/java.base/share/classes/java/math/BigInteger.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/math/BigInteger.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3556,8 +3556,8 @@
      * Returns the number of bits in the minimal two's-complement
      * representation of this BigInteger, <em>excluding</em> a sign bit.
      * For positive BigIntegers, this is equivalent to the number of bits in
-     * the ordinary binary representation.  (Computes
-     * {@code (ceil(log2(this < 0 ? -this : this+1)))}.)
+     * the ordinary binary representation.  For zero this method returns
+     * {@code 0}.  (Computes {@code (ceil(log2(this < 0 ? -this : this+1)))}.)
      *
      * @return number of bits in the minimal two's-complement
      *         representation of this BigInteger, <em>excluding</em> a sign bit.
--- a/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -45,8 +45,7 @@
  *
  * @author  Steven B. Byrne
  */
-abstract class AbstractPlainSocketImpl extends SocketImpl
-{
+abstract class AbstractPlainSocketImpl extends SocketImpl {
     /* instance variable for SO_TIMEOUT */
     int timeout;   // timeout in millisec
     // traffic class
@@ -68,11 +67,7 @@
     protected boolean closePending = false;
 
     /* indicates connection reset state */
-    private int CONNECTION_NOT_RESET = 0;
-    private int CONNECTION_RESET_PENDING = 1;
-    private int CONNECTION_RESET = 2;
-    private int resetState;
-    private final Object resetLock = new Object();
+    private volatile boolean connectionReset;
 
    /* whether this Socket is a stream (TCP) socket or not (UDP)
     */
@@ -541,18 +536,8 @@
         int n = 0;
         try {
             n = socketAvailable();
-            if (n == 0 && isConnectionResetPending()) {
-                setConnectionReset();
-            }
         } catch (ConnectionResetException exc1) {
-            setConnectionResetPending();
-            try {
-                n = socketAvailable();
-                if (n == 0) {
-                    setConnectionReset();
-                }
-            } catch (ConnectionResetException exc2) {
-            }
+            setConnectionReset();
         }
         return n;
     }
@@ -680,31 +665,12 @@
         }
     }
 
-    public boolean isConnectionReset() {
-        synchronized (resetLock) {
-            return (resetState == CONNECTION_RESET);
-        }
-    }
-
-    public boolean isConnectionResetPending() {
-        synchronized (resetLock) {
-            return (resetState == CONNECTION_RESET_PENDING);
-        }
+    boolean isConnectionReset() {
+        return connectionReset;
     }
 
-    public void setConnectionReset() {
-        synchronized (resetLock) {
-            resetState = CONNECTION_RESET;
-        }
-    }
-
-    public void setConnectionResetPending() {
-        synchronized (resetLock) {
-            if (resetState == CONNECTION_NOT_RESET) {
-                resetState = CONNECTION_RESET_PENDING;
-            }
-        }
-
+    void setConnectionReset() {
+        connectionReset = true;
     }
 
     /*
--- a/src/java.base/share/classes/java/net/SocketInputStream.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/net/SocketInputStream.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,8 +40,7 @@
  * @author      Jonathan Payne
  * @author      Arthur van Hoff
  */
-class SocketInputStream extends FileInputStream
-{
+class SocketInputStream extends FileInputStream {
     static {
         init();
     }
@@ -163,8 +162,6 @@
                     + " off == " + off + " buffer length == " + b.length);
         }
 
-        boolean gotReset = false;
-
         // acquire file descriptor and do the read
         FileDescriptor fd = impl.acquireFD();
         try {
@@ -173,39 +170,18 @@
                 return n;
             }
         } catch (ConnectionResetException rstExc) {
-            gotReset = true;
+            impl.setConnectionReset();
         } finally {
             impl.releaseFD();
         }
 
         /*
-         * We receive a "connection reset" but there may be bytes still
-         * buffered on the socket
-         */
-        if (gotReset) {
-            impl.setConnectionResetPending();
-            impl.acquireFD();
-            try {
-                n = socketRead(fd, b, off, length, timeout);
-                if (n > 0) {
-                    return n;
-                }
-            } catch (ConnectionResetException rstExc) {
-            } finally {
-                impl.releaseFD();
-            }
-        }
-
-        /*
          * If we get here we are at EOF, the socket has been closed,
          * or the connection has been reset.
          */
         if (impl.isClosedOrPending()) {
             throw new SocketException("Socket closed");
         }
-        if (impl.isConnectionResetPending()) {
-            impl.setConnectionReset();
-        }
         if (impl.isConnectionReset()) {
             throw new SocketException("Connection reset");
         }
--- a/src/java.base/share/classes/java/net/SocketOutputStream.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/java/net/SocketOutputStream.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,8 +38,7 @@
  * @author      Jonathan Payne
  * @author      Arthur van Hoff
  */
-class SocketOutputStream extends FileOutputStream
-{
+class SocketOutputStream extends FileOutputStream {
     static {
         init();
     }
@@ -111,7 +110,7 @@
             socketWrite0(fd, b, off, len);
         } catch (SocketException se) {
             if (se instanceof sun.net.ConnectionResetException) {
-                impl.setConnectionResetPending();
+                impl.setConnectionReset();
                 se = new SocketException("Connection reset");
             }
             if (impl.isClosedOrPending()) {
--- a/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java	Thu Mar 15 11:36:11 2018 -0700
@@ -84,7 +84,7 @@
     /**
      * Returns a {@code byte[]} representation of {@code BoundMethodHandle}
      * species class implementing the signature defined by {@code types}. Used
-     * by GenerateBMHClassesPlugin to enable generation of such classes during
+     * by GenerateJLIClassesPlugin to enable generation of such classes during
      * the jlink phase. Should do some added validation since this string may be
      * user provided.
      */
@@ -99,8 +99,11 @@
 
     /**
      * Returns a {@code byte[]} representation of a class implementing
-     * the invoker forms for the set of supplied {@code methodTypes}.
+     * the invoker forms for the set of supplied {@code invokerMethodTypes}
+     * and {@code callSiteMethodTypes}.
      */
     byte[] generateInvokersHolderClassBytes(String className,
-            MethodType[] methodTypes);
+            MethodType[] invokerMethodTypes,
+            MethodType[] callSiteMethodTypes);
+
 }
--- a/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -99,7 +99,6 @@
             implCloseInterrupt();
             pollWrapper.free();
             pollWrapper = null;
-            selectedKeys = null;
             channelArray = null;
             totalChannels = 0;
         }
--- a/src/java.base/share/classes/sun/nio/ch/SelectionKeyImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/sun/nio/ch/SelectionKeyImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,11 @@
 
 package sun.nio.ch;
 
-import java.io.IOException;
-import java.nio.channels.*;
-import java.nio.channels.spi.*;
+import java.nio.channels.CancelledKeyException;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.spi.AbstractSelectionKey;
 
 
 /**
@@ -45,7 +47,7 @@
     private int index;
 
     private volatile int interestOps;
-    private int readyOps;
+    private volatile int readyOps;
 
     SelectionKeyImpl(SelChImpl ch, SelectorImpl sel) {
         channel = ch;
@@ -111,4 +113,22 @@
         return interestOps;
     }
 
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("channel=")
+          .append(channel)
+          .append(", selector=")
+          .append(selector);
+        if (isValid()) {
+            sb.append(", interestOps=")
+              .append(interestOps)
+              .append(", readyOps=")
+              .append(readyOps);
+        } else {
+            sb.append(", invalid");
+        }
+        return sb.toString();
+    }
+
 }
--- a/src/java.base/share/classes/sun/nio/ch/SelectorImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/share/classes/sun/nio/ch/SelectorImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
 import java.nio.channels.ClosedSelectorException;
 import java.nio.channels.IllegalSelectorException;
 import java.nio.channels.SelectionKey;
-import java.nio.channels.Selector;
 import java.nio.channels.spi.AbstractSelectableChannel;
 import java.nio.channels.spi.AbstractSelector;
 import java.nio.channels.spi.SelectorProvider;
@@ -47,16 +46,15 @@
 public abstract class SelectorImpl
     extends AbstractSelector
 {
+    // The set of keys registered with this Selector
+    protected final HashSet<SelectionKey> keys;
 
     // The set of keys with data ready for an operation
-    protected Set<SelectionKey> selectedKeys;
-
-    // The set of keys registered with this Selector
-    protected HashSet<SelectionKey> keys;
+    protected final Set<SelectionKey> selectedKeys;
 
     // Public views of the key sets
-    private Set<SelectionKey> publicKeys;             // Immutable
-    private Set<SelectionKey> publicSelectedKeys;     // Removal allowed, but not addition
+    private final Set<SelectionKey> publicKeys;             // Immutable
+    private final Set<SelectionKey> publicSelectedKeys;     // Removal allowed, but not addition
 
     protected SelectorImpl(SelectorProvider sp) {
         super(sp);
@@ -66,13 +64,15 @@
         publicSelectedKeys = Util.ungrowableSet(selectedKeys);
     }
 
-    public Set<SelectionKey> keys() {
+    @Override
+    public final Set<SelectionKey> keys() {
         if (!isOpen())
             throw new ClosedSelectorException();
         return publicKeys;
     }
 
-    public Set<SelectionKey> selectedKeys() {
+    @Override
+    public final Set<SelectionKey> selectedKeys() {
         if (!isOpen())
             throw new ClosedSelectorException();
         return publicSelectedKeys;
@@ -92,7 +92,8 @@
         }
     }
 
-    public int select(long timeout)
+    @Override
+    public final int select(long timeout)
         throws IOException
     {
         if (timeout < 0)
@@ -100,15 +101,18 @@
         return lockAndDoSelect((timeout == 0) ? -1 : timeout);
     }
 
-    public int select() throws IOException {
+    @Override
+    public final int select() throws IOException {
         return select(0);
     }
 
-    public int selectNow() throws IOException {
+    @Override
+    public final int selectNow() throws IOException {
         return lockAndDoSelect(0);
     }
 
-    public void implCloseSelector() throws IOException {
+    @Override
+    public final void implCloseSelector() throws IOException {
         wakeup();
         synchronized (this) {
             synchronized (publicKeys) {
@@ -121,8 +125,9 @@
 
     protected abstract void implClose() throws IOException;
 
-    public void putEventOps(SelectionKeyImpl sk, int ops) { }
+    public abstract void putEventOps(SelectionKeyImpl sk, int ops);
 
+    @Override
     protected final SelectionKey register(AbstractSelectableChannel ch,
                                           int ops,
                                           Object attachment)
@@ -140,7 +145,9 @@
 
     protected abstract void implRegister(SelectionKeyImpl ski);
 
-    void processDeregisterQueue() throws IOException {
+    protected abstract void implDereg(SelectionKeyImpl ski) throws IOException;
+
+    protected final void processDeregisterQueue() throws IOException {
         // Precondition: Synchronized on this, keys, and selectedKeys
         Set<SelectionKey> cks = cancelledKeys();
         synchronized (cks) {
@@ -159,9 +166,4 @@
             }
         }
     }
-
-    protected abstract void implDereg(SelectionKeyImpl ski) throws IOException;
-
-    public abstract Selector wakeup();
-
 }
--- a/src/java.base/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -213,7 +213,7 @@
         }
     }
 
-    void closeDevPollFD() throws IOException {
+    void close() throws IOException {
         FileDispatcherImpl.closeIntFD(wfd);
         pollArray.free();
     }
--- a/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,26 +37,25 @@
 class DevPollSelectorImpl
     extends SelectorImpl
 {
-
     // File descriptors used for interrupt
-    protected int fd0;
-    protected int fd1;
+    private final int fd0;
+    private final int fd1;
 
     // The poll object
-    DevPollArrayWrapper pollWrapper;
+    private final DevPollArrayWrapper pollWrapper;
 
     // Maps from file descriptors to keys
-    private Map<Integer,SelectionKeyImpl> fdToKey;
+    private final Map<Integer, SelectionKeyImpl> fdToKey;
 
     // True if this Selector has been closed
-    private boolean closed = false;
+    private boolean closed;
 
     // Lock for close/cleanup
-    private Object closeLock = new Object();
+    private final Object closeLock = new Object();
 
     // Lock for interrupt triggering and clearing
-    private Object interruptLock = new Object();
-    private boolean interruptTriggered = false;
+    private final Object interruptLock = new Object();
+    private boolean interruptTriggered;
 
     /**
      * Package private constructor called by factory method in
@@ -86,11 +85,16 @@
         }
     }
 
+    private void ensureOpen() {
+        if (closed)
+            throw new ClosedSelectorException();
+    }
+
+    @Override
     protected int doSelect(long timeout)
         throws IOException
     {
-        if (closed)
-            throw new ClosedSelectorException();
+        ensureOpen();
         processDeregisterQueue();
         try {
             begin();
@@ -141,6 +145,7 @@
         return numKeysUpdated;
     }
 
+    @Override
     protected void implClose() throws IOException {
         if (closed)
             return;
@@ -151,13 +156,10 @@
             interruptTriggered = true;
         }
 
+        pollWrapper.close();
         FileDispatcherImpl.closeIntFD(fd0);
         FileDispatcherImpl.closeIntFD(fd1);
 
-        pollWrapper.release(fd0);
-        pollWrapper.closeDevPollFD();
-        selectedKeys = null;
-
         // Deregister channels
         Iterator<SelectionKey> i = keys.iterator();
         while (i.hasNext()) {
@@ -168,16 +170,16 @@
                 ((SelChImpl)selch).kill();
             i.remove();
         }
-        fd0 = -1;
-        fd1 = -1;
     }
 
+    @Override
     protected void implRegister(SelectionKeyImpl ski) {
         int fd = IOUtil.fdVal(ski.channel.getFD());
         fdToKey.put(Integer.valueOf(fd), ski);
         keys.add(ski);
     }
 
+    @Override
     protected void implDereg(SelectionKeyImpl ski) throws IOException {
         int i = ski.getIndex();
         assert (i >= 0);
@@ -193,13 +195,14 @@
             ((SelChImpl)selch).kill();
     }
 
+    @Override
     public void putEventOps(SelectionKeyImpl sk, int ops) {
-        if (closed)
-            throw new ClosedSelectorException();
+        ensureOpen();
         int fd = IOUtil.fdVal(sk.channel.getFD());
         pollWrapper.setInterest(fd, ops);
     }
 
+    @Override
     public Selector wakeup() {
         synchronized (interruptLock) {
             if (!interruptTriggered) {
--- a/src/java.base/solaris/classes/sun/nio/ch/EventPortSelectorImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/solaris/classes/sun/nio/ch/EventPortSelectorImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,14 +42,14 @@
     private final EventPortWrapper pollWrapper;
 
     // Maps from file descriptors to keys
-    private Map<Integer,SelectionKeyImpl> fdToKey;
+    private final Map<Integer, SelectionKeyImpl> fdToKey;
 
     // True if this Selector has been closed
-    private boolean closed = false;
+    private boolean closed;
 
     // Lock for interrupt triggering and clearing
     private final Object interruptLock = new Object();
-    private boolean interruptTriggered = false;
+    private boolean interruptTriggered;
 
     /**
      * Package private constructor called by factory method in
@@ -61,9 +61,14 @@
         fdToKey = new HashMap<>();
     }
 
-    protected int doSelect(long timeout) throws IOException {
+    private void ensureOpen() {
         if (closed)
             throw new ClosedSelectorException();
+    }
+
+    @Override
+    protected int doSelect(long timeout) throws IOException {
+        ensureOpen();
         processDeregisterQueue();
         int entries;
         try {
@@ -105,6 +110,7 @@
         return numKeysUpdated;
     }
 
+    @Override
     protected void implClose() throws IOException {
         if (closed)
             return;
@@ -116,7 +122,6 @@
         }
 
         pollWrapper.close();
-        selectedKeys = null;
 
         // Deregister channels
         Iterator<SelectionKey> i = keys.iterator();
@@ -130,12 +135,14 @@
         }
     }
 
+    @Override
     protected void implRegister(SelectionKeyImpl ski) {
         int fd = IOUtil.fdVal(ski.channel.getFD());
         fdToKey.put(Integer.valueOf(fd), ski);
         keys.add(ski);
     }
 
+    @Override
     protected void implDereg(SelectionKeyImpl ski) throws IOException {
         int i = ski.getIndex();
         assert (i >= 0);
@@ -151,13 +158,14 @@
             ((SelChImpl)selch).kill();
     }
 
+    @Override
     public void putEventOps(SelectionKeyImpl sk, int ops) {
-        if (closed)
-            throw new ClosedSelectorException();
+        ensureOpen();
         int fd = sk.channel.getFDVal();
         pollWrapper.setInterest(fd, ops);
     }
 
+    @Override
     public Selector wakeup() {
         synchronized (interruptLock) {
             if (!interruptTriggered) {
--- a/src/java.base/windows/classes/java/net/PlainSocketImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/windows/classes/java/net/PlainSocketImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,8 +43,7 @@
  * @author Chris Hegarty
  */
 
-class PlainSocketImpl extends AbstractPlainSocketImpl
-{
+class PlainSocketImpl extends AbstractPlainSocketImpl {
     private AbstractPlainSocketImpl impl;
 
     /* java.net.preferIPv4Stack */
@@ -254,22 +253,14 @@
         impl.releaseFD();
     }
 
-    public boolean isConnectionReset() {
+    boolean isConnectionReset() {
         return impl.isConnectionReset();
     }
 
-    public boolean isConnectionResetPending() {
-        return impl.isConnectionResetPending();
-    }
-
-    public void setConnectionReset() {
+    void setConnectionReset() {
         impl.setConnectionReset();
     }
 
-    public void setConnectionResetPending() {
-        impl.setConnectionResetPending();
-    }
-
     public boolean isClosedOrPending() {
         return impl.isClosedOrPending();
     }
--- a/src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,7 @@
  * @author Mark Reinhold
  */
 
-final class WindowsSelectorImpl extends SelectorImpl {
+class WindowsSelectorImpl extends SelectorImpl {
     // Initial capacity of the poll array
     private final int INIT_CAP = 8;
     // Maximum number of sockets for select().
@@ -81,7 +81,7 @@
     private final int wakeupSourceFd, wakeupSinkFd;
 
     // Lock for close cleanup
-    private Object closeLock = new Object();
+    private final Object closeLock = new Object();
 
     // Maps file descriptors to their indices in  pollArray
     private static final class FdMap extends HashMap<Integer, MapEntry> {
@@ -135,6 +135,7 @@
         pollWrapper.addWakeupSocket(wakeupSourceFd, 0);
     }
 
+    @Override
     protected int doSelect(long timeout) throws IOException {
         if (channelArray == null)
             throw new ClosedSelectorException();
@@ -500,6 +501,7 @@
         return numKeysUpdated;
     }
 
+    @Override
     protected void implClose() throws IOException {
         synchronized (closeLock) {
             if (channelArray != null) {
@@ -520,7 +522,6 @@
                     }
                     pollWrapper.free();
                     pollWrapper = null;
-                    selectedKeys = null;
                     channelArray = null;
                     // Make all remaining helper threads exit
                     for (SelectThread t: threads)
--- a/src/jdk.accessibility/windows/native/libwindowsaccessbridge/WinAccessBridge.DEF	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/jdk.accessibility/windows/native/libwindowsaccessbridge/WinAccessBridge.DEF	Thu Mar 15 11:36:11 2018 -0700
@@ -1,5 +1,5 @@
 ;
-; Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+; Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
 ; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 ;
 ; This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 ;LIBRARY	WINDOWSACCESSBRIDGE
 
 ;DESCRIPTION 'WINDOWSACCESSBRIDGE.DLL'
-HEAPSIZE	4096
 EXPORTS
 
     addJavaEventNotification
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Thu Mar 15 11:36:11 2018 -0700
@@ -69,7 +69,9 @@
 
     private static final String DELEGATING_HOLDER = "java/lang/invoke/DelegatingMethodHandle$Holder";
     private static final String BASIC_FORMS_HOLDER = "java/lang/invoke/LambdaForm$Holder";
-    private static final String INVOKERS_HOLDER = "java/lang/invoke/Invokers$Holder";
+
+    private static final String INVOKERS_HOLDER_NAME = "java.lang.invoke.Invokers$Holder";
+    private static final String INVOKERS_HOLDER_INTERNAL_NAME = INVOKERS_HOLDER_NAME.replace('.', '/');
 
     private static final JavaLangInvokeAccess JLIA
             = SharedSecrets.getJavaLangInvokeAccess();
@@ -78,6 +80,8 @@
 
     Set<String> invokerTypes = Set.of();
 
+    Set<String> callSiteTypes = Set.of();
+
     Map<String, Set<String>> dmhMethods = Map.of();
 
     String mainArgument;
@@ -128,7 +132,7 @@
      * @return the default invoker forms to generate.
      */
     private static Set<String> defaultInvokers() {
-        return Set.of("LL_L", "LL_I", "LILL_I", "L6_L");
+        return Set.of("LL_L", "LL_I", "LLLL_L", "LLLL_I", "LLIL_L", "LLIL_I", "L6_L");
     }
 
     /**
@@ -209,6 +213,8 @@
         // ease finding methods in the generated code
         speciesTypes = new TreeSet<>(speciesTypes);
         invokerTypes = new TreeSet<>(invokerTypes);
+        callSiteTypes = new TreeSet<>(callSiteTypes);
+
         TreeMap<String, Set<String>> newDMHMethods = new TreeMap<>();
         for (Map.Entry<String, Set<String>> entry : dmhMethods.entrySet()) {
             newDMHMethods.put(entry.getKey(), new TreeSet<>(entry.getValue()));
@@ -229,8 +235,13 @@
                     case "[LF_RESOLVE]":
                         String methodType = parts[3];
                         validateMethodType(methodType);
-                        if (parts[1].contains("Invokers")) {
-                            invokerTypes.add(methodType);
+                        if (parts[1].equals(INVOKERS_HOLDER_NAME)) {
+                            if ("linkToTargetMethod".equals(parts[2]) ||
+                                    "linkToCallSite".equals(parts[2])) {
+                                callSiteTypes.add(methodType);
+                            } else {
+                                invokerTypes.add(methodType);
+                            }
                         } else if (parts[1].contains("DirectMethodHandle")) {
                             String dmh = parts[2];
                             // ignore getObject etc for now (generated
@@ -294,10 +305,11 @@
         // Copy all but DMH_ENTRY to out
         in.transformAndCopy(entry -> {
                 // filter out placeholder entries
-                if (entry.path().equals(DIRECT_METHOD_HOLDER_ENTRY) ||
-                    entry.path().equals(DELEGATING_METHOD_HOLDER_ENTRY) ||
-                    entry.path().equals(INVOKERS_HOLDER_ENTRY) ||
-                    entry.path().equals(BASIC_FORMS_HOLDER_ENTRY)) {
+                String path = entry.path();
+                if (path.equals(DIRECT_METHOD_HOLDER_ENTRY) ||
+                    path.equals(DELEGATING_METHOD_HOLDER_ENTRY) ||
+                    path.equals(INVOKERS_HOLDER_ENTRY) ||
+                    path.equals(BASIC_FORMS_HOLDER_ENTRY)) {
                     return null;
                 } else {
                     return entry;
@@ -361,23 +373,40 @@
                 index++;
             }
         }
+
+        // The invoker type to ask for is retrieved by removing the first
+        // and the last argument, which needs to be of Object.class
         MethodType[] invokerMethodTypes = new MethodType[this.invokerTypes.size()];
         int i = 0;
         for (String invokerType : invokerTypes) {
-            // The invoker type to ask for is retrieved by removing the first
-            // and the last argument, which needs to be of Object.class
             MethodType mt = asMethodType(invokerType);
             final int lastParam = mt.parameterCount() - 1;
             if (mt.parameterCount() < 2 ||
                     mt.parameterType(0) != Object.class ||
                     mt.parameterType(lastParam) != Object.class) {
                 throw new PluginException(
-                        "Invoker type parameter must start and end with L");
+                        "Invoker type parameter must start and end with Object: " + invokerType);
             }
             mt = mt.dropParameterTypes(lastParam, lastParam + 1);
             invokerMethodTypes[i] = mt.dropParameterTypes(0, 1);
             i++;
         }
+
+        // The callSite type to ask for is retrieved by removing the last
+        // argument, which needs to be of Object.class
+        MethodType[] callSiteMethodTypes = new MethodType[this.callSiteTypes.size()];
+        i = 0;
+        for (String callSiteType : callSiteTypes) {
+            MethodType mt = asMethodType(callSiteType);
+            final int lastParam = mt.parameterCount() - 1;
+            if (mt.parameterCount() < 1 ||
+                    mt.parameterType(lastParam) != Object.class) {
+                throw new PluginException(
+                        "CallSite type parameter must end with Object: " + callSiteType);
+            }
+            callSiteMethodTypes[i] = mt.dropParameterTypes(lastParam, lastParam + 1);
+            i++;
+        }
         try {
             byte[] bytes = JLIA.generateDirectMethodHandleHolderClassBytes(
                     DIRECT_HOLDER, directMethodTypes, dmhTypes);
@@ -390,8 +419,8 @@
             ndata = ResourcePoolEntry.create(DELEGATING_METHOD_HOLDER_ENTRY, bytes);
             out.add(ndata);
 
-            bytes = JLIA.generateInvokersHolderClassBytes(INVOKERS_HOLDER,
-                    invokerMethodTypes);
+            bytes = JLIA.generateInvokersHolderClassBytes(INVOKERS_HOLDER_INTERNAL_NAME,
+                    invokerMethodTypes, callSiteMethodTypes);
             ndata = ResourcePoolEntry.create(INVOKERS_HOLDER_ENTRY, bytes);
             out.add(ndata);
 
@@ -409,7 +438,7 @@
     private static final String BASIC_FORMS_HOLDER_ENTRY =
             "/java.base/" + BASIC_FORMS_HOLDER + ".class";
     private static final String INVOKERS_HOLDER_ENTRY =
-            "/java.base/" + INVOKERS_HOLDER + ".class";
+            "/java.base/" + INVOKERS_HOLDER_INTERNAL_NAME + ".class";
 
     // Convert LL -> LL, L3 -> LLL
     public static String expandSignature(String signature) {
--- a/src/jdk.security.auth/share/classes/com/sun/security/auth/module/NTSystem.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/module/NTSystem.java	Thu Mar 15 11:36:11 2018 -0700
@@ -128,6 +128,6 @@
 
 
     private void loadNative() {
-        System.loadLibrary("jaas_nt");
+        System.loadLibrary("jaas");
     }
 }
--- a/src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java	Thu Mar 15 11:36:11 2018 -0700
@@ -43,7 +43,7 @@
      * the native library to access the underlying system information.
      */
     public UnixSystem() {
-        System.loadLibrary("jaas_unix");
+        System.loadLibrary("jaas");
         getUnixInfo();
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/reflect/Proxy/ProxyClashTest.java	Thu Mar 15 11:36:11 2018 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8188240
+ * @summary This is a test to ensure that proxies do not try to intercept interface static methods.
+ *
+ * @build ProxyClashTest
+ * @run main ProxyClashTest
+ */
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Observer;
+
+public class ProxyClashTest {
+
+    public interface ClashWithRunnable {
+        static int run() { return 123; }
+
+        static void foo() {}
+    }
+
+    public static void main(String[] args) {
+        System.err.println(
+            "\nDynamic proxy API static method clash test\n");
+
+        Class<?>[] interfaces =
+            new Class<?>[] { ClashWithRunnable.class, Runnable.class, Observer.class };
+
+        ClassLoader loader = ProxyClashTest.class.getClassLoader();
+
+        /*
+         * Generate a proxy class.
+         */
+        Class<?> proxyClass = Proxy.getProxyClass(loader, interfaces);
+        System.err.println("+ generated proxy class: " + proxyClass);
+
+        for (Method method : proxyClass.getDeclaredMethods()) {
+            if (method.getName().equals("run") && method.getReturnType() == int.class) {
+                throw new RuntimeException("proxy intercept a static method");
+            }
+            if (method.getName().equals("foo")) {
+                throw new RuntimeException("proxy intercept a static method");
+            }
+        }
+
+        System.err.println("\nTEST PASSED");
+    }
+}
--- a/test/jdk/java/util/Locale/SoftKeys.java	Thu Mar 15 19:33:51 2018 +0530
+++ b/test/jdk/java/util/Locale/SoftKeys.java	Thu Mar 15 11:36:11 2018 -0700
@@ -27,6 +27,9 @@
  * @bug 8196869
  * @summary Make sure we deal with internal Key data being cleared properly
  * @run main/othervm -Xms16m -Xmx16m -esa SoftKeys
+ * @ignore This test aims to provoke NPEs, but due to the need to constrain
+ *         memory usage it fails intermittently with OOME on various systems
+ *         with no way to ignore such failures.
  */
 import java.util.*;