Merge
diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index 0f468db..f999c59 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -273,3 +273,4 @@
 ea2f7981236f3812436958748ab3d26e80a35130 jdk9-b28
 9e6581aeda388a23fbee021fc33e6aa152a60657 jdk9-b29
 36e9bc875325813ac9c44ac0c617a463091fa9f5 jdk9-b30
+69a84c16d9c28e0e3d504b9c8766c24bafcd58f6 jdk9-b31
diff --git a/Makefile b/Makefile
index d385e0f..d4b36e4 100644
--- a/Makefile
+++ b/Makefile
@@ -70,8 +70,8 @@
   # Run the makefile with an arbitrary SPEC using -p -q (quiet dry-run and dump rules) to find
   # available PHONY targets. Use this list as valid targets to pass on to the repeated calls.
   all_phony_targets := $(sort $(filter-out $(global_targets), $(strip $(shell \
-      cd $(root_dir)/make && $(MAKE) -f Main.gmk -p -q FRC SPEC=$(firstword $(SPEC)) | \
-      grep "^.PHONY:" | head -n 1 | cut -d " " -f 2-))))
+      cd $(root_dir)/make && $(MAKE) -f Main.gmk -p -q FRC SPEC=$(firstword $(SPEC)) \
+      -I $(root_dir)/make/common | grep "^.PHONY:" | head -n 1 | cut -d " " -f 2-))))
 
   # Loop through the configurations and call the main-wrapper for each one. The wrapper
   # target will execute with a single configuration loaded.
@@ -115,12 +115,12 @@
 
     main-wrapper:
         ifneq ($(SEQUENTIAL_TARGETS), )
-	  (cd $(root_dir)/make && $(MAKE) -f Main.gmk SPEC=$(SPEC) -j 1 \
+	  (cd $(SRC_ROOT)/make && $(MAKE) -f Main.gmk SPEC=$(SPEC) -j 1 \
 	      $(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $(SEQUENTIAL_TARGETS))
         endif
         ifneq ($(PARALLEL_TARGETS), )
 	  @$(call AtMakeStart)
-	  (cd $(root_dir)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -f Main.gmk SPEC=$(SPEC) -j $(JOBS) \
+	  (cd $(SRC_ROOT)/make && $(BUILD_LOG_WRAPPER) $(MAKE) -f Main.gmk SPEC=$(SPEC) -j $(JOBS) \
 	      $(VERBOSE) VERBOSE=$(VERBOSE) LOG_LEVEL=$(LOG_LEVEL) $(PARALLEL_TARGETS) \
 	      $(if $(filter true, $(OUTPUT_SYNC_SUPPORTED)), -O$(OUTPUT_SYNC)))
 	  @$(call AtMakeEnd)
diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh
index 8ceccb5..394b8f0 100644
--- a/common/autoconf/generated-configure.sh
+++ b/common/autoconf/generated-configure.sh
@@ -4327,7 +4327,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1410377275
+DATE_WHEN_GENERATED=1410791401
 
 ###############################################################################
 #
@@ -14642,7 +14642,7 @@
       FASTDEBUG="false"
       DEBUG_CLASSFILES="true"
       BUILD_VARIANT_RELEASE="-debug"
-      HOTSPOT_DEBUG_LEVEL="jvmg"
+      HOTSPOT_DEBUG_LEVEL="debug"
       HOTSPOT_EXPORT="debug"
       ;;
     optimized )
diff --git a/common/autoconf/hotspot-spec.gmk.in b/common/autoconf/hotspot-spec.gmk.in
index 057d882..dcd2fd8 100644
--- a/common/autoconf/hotspot-spec.gmk.in
+++ b/common/autoconf/hotspot-spec.gmk.in
@@ -97,8 +97,6 @@
 endif
 
 HOTSPOT_MAKE_ARGS:=@HOTSPOT_MAKE_ARGS@ @STATIC_CXX_SETTING@
-# This is used from the libjvm build for C/C++ code.
-HOTSPOT_BUILD_JOBS:=$(JOBS)
 # Control wether Hotspot runs Queens test after building
 TEST_IN_BUILD=@TEST_IN_BUILD@
 
diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4
index f3dca31..204ba87 100644
--- a/common/autoconf/jdk-options.m4
+++ b/common/autoconf/jdk-options.m4
@@ -234,7 +234,7 @@
       FASTDEBUG="false"
       DEBUG_CLASSFILES="true"
       BUILD_VARIANT_RELEASE="-debug"
-      HOTSPOT_DEBUG_LEVEL="jvmg"
+      HOTSPOT_DEBUG_LEVEL="debug"
       HOTSPOT_EXPORT="debug"
       ;;
     optimized )
diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in
index e85c830..00e45f9 100644
--- a/common/autoconf/spec.gmk.in
+++ b/common/autoconf/spec.gmk.in
@@ -245,6 +245,7 @@
 NASHORN_OUTPUTDIR=$(BUILD_OUTPUT)/nashorn
 IMAGES_OUTPUTDIR=$(BUILD_OUTPUT)/images
 TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/testmake
+MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/make-support
 
 LANGTOOLS_DIST=$(LANGTOOLS_OUTPUTDIR)/dist
 CORBA_DIST=$(CORBA_OUTPUTDIR)/dist
diff --git a/common/bin/unshuffle_list.txt b/common/bin/unshuffle_list.txt
index 66f1fcd..2ba90cf 100644
--- a/common/bin/unshuffle_list.txt
+++ b/common/bin/unshuffle_list.txt
@@ -1216,14 +1216,13 @@
 jdk/src/java.security.acl/share/classes/sun/security/acl : jdk/src/share/classes/sun/security/acl
 jdk/src/java.security.jgss/macosx/native/libosxkrb5/nativeccache.c : jdk/src/share/native/sun/security/krb5/nativeccache.c
 jdk/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m : jdk/src/macosx/native/sun/security/krb5/SCDynamicStoreConfig.m
-jdk/src/java.security.jgss/share/classes/com/sun/security/jgss : jdk/src/share/classes/com/sun/security/jgss
-jdk/src/java.security.jgss/share/classes/com/sun/security/sasl/gsskerb : jdk/src/share/classes/com/sun/security/sasl/gsskerb
 jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos : jdk/src/share/classes/javax/security/auth/kerberos
 jdk/src/java.security.jgss/share/classes/jgss-overview.html : jdk/src/share/classes/com/sun/security/jgss/jgss-overview.html
 jdk/src/java.security.jgss/share/classes/org/ietf/jgss : jdk/src/share/classes/org/ietf/jgss
 jdk/src/java.security.jgss/share/classes/sun/net/www/protocol/http/spnego : jdk/src/share/classes/sun/net/www/protocol/http/spnego
 jdk/src/java.security.jgss/share/classes/sun/security/jgss : jdk/src/share/classes/sun/security/jgss
 jdk/src/java.security.jgss/share/classes/sun/security/krb5 : jdk/src/share/classes/sun/security/krb5
+jdk/src/java.security.jgss/windows/classes/sun/security/krb5 : jdk/src/windows/classes/sun/security/krb5
 jdk/src/java.security.jgss/share/classes/sun/security/ssl/krb5 : jdk/src/share/classes/sun/security/ssl/krb5
 jdk/src/java.security.jgss/share/native/libj2gss : jdk/src/share/native/sun/security/jgss/wrapper
 jdk/src/java.security.jgss/unix/native/libj2gss : jdk/src/solaris/native/sun/security/jgss/wrapper
@@ -1477,6 +1476,8 @@
 jdk/src/jdk.security.auth/share/classes/jaas-overview.html : jdk/src/share/classes/com/sun/security/auth/jaas-overview.html
 jdk/src/jdk.security.auth/unix/native/libjaas : jdk/src/solaris/native/com/sun/security/auth/module
 jdk/src/jdk.security.auth/windows/native/libjaas : jdk/src/windows/native/com/sun/security/auth/module
+jdk/src/jdk.security.jgss/share/classes/com/sun/security/jgss : jdk/src/share/classes/com/sun/security/jgss
+jdk/src/jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb : jdk/src/share/classes/com/sun/security/sasl/gsskerb
 jdk/src/jdk.snmp/share/classes/com/sun/jmx/snmp : jdk/src/share/classes/com/sun/jmx/snmp
 jdk/src/jdk.snmp/share/classes/sun/management/snmp : jdk/src/share/classes/sun/management/snmp
 jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs : jdk/src/share/classes/jdk/nio/zipfs
diff --git a/make/HotspotWrapper.gmk b/make/HotspotWrapper.gmk
index 51437df..0677deb 100644
--- a/make/HotspotWrapper.gmk
+++ b/make/HotspotWrapper.gmk
@@ -42,7 +42,7 @@
 # not doing it breaks builds on msys.
 $(HOTSPOT_OUTPUTDIR)/_hotspot.timestamp: $(HOTSPOT_FILES)
 	@$(MKDIR) -p $(HOTSPOT_OUTPUTDIR)
-	@($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) -j1 $(HOTSPOT_MAKE_ARGS) SPEC=$(HOTSPOT_SPEC) BASE_SPEC=$(BASE_SPEC))
+	@($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(HOTSPOT_MAKE_ARGS) SPEC=$(HOTSPOT_SPEC) BASE_SPEC=$(BASE_SPEC))
 	$(TOUCH) $@
 
 hotspot: $(HOTSPOT_OUTPUTDIR)/_hotspot.timestamp
diff --git a/make/Main.gmk b/make/Main.gmk
index 230fec4..2a4eb55 100644
--- a/make/Main.gmk
+++ b/make/Main.gmk
@@ -298,7 +298,9 @@
 # Verification targets
 
 verify-modules:
+	@$(call TargetEnter)
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CheckModules.gmk)
+	@$(call TargetExit)
 
 ALL_TARGETS += verify-modules
 
@@ -400,7 +402,7 @@
     main-jars: java.security.jgss-libs
   endif
 
-  images: jars demos samples exploded-image source-tips
+  images: jars demos samples exploded-image verify-modules source-tips
 
   bootcycle-images: images
 
@@ -476,7 +478,7 @@
 
 ################################################################################
 
-all: images docs verify-modules
+all: images docs
 default: exploded-image
 
 ALL_TARGETS += default all
@@ -491,7 +493,7 @@
 # file.
 
 CLEAN_COMPONENTS += langtools corba hotspot jdk nashorn images \
-    bootcycle-build docs docstemp test
+    bootcycle-build docs docstemp test make-support
 CLEAN_TARGETS := $(addprefix clean-, $(CLEAN_COMPONENTS))
 
 # Remove everything, except the output from configure.
diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk
index 87b03f8..248f3ab 100644
--- a/make/common/Modules.gmk
+++ b/make/common/Modules.gmk
@@ -26,6 +26,9 @@
 ifndef _MODULES_GMK
 _MODULES_GMK := 1
 
+include JavaCompilation.gmk
+include SetupJavaCompilers.gmk
+
 ################################################################################
 # Module list macros
 
@@ -50,8 +53,32 @@
           $(patsubst %,%/*/$(OPENJDK_TARGET_OS)/classes/*, $(ALL_TOP_SRC_DIRS))))))))))))
 endef
 
-MODULES_LIST_FILE := $(SRC_ROOT)/make/common/modules.list
-MODULE_DEPS_MAKEFILE := $(OUTPUT_ROOT)/module-deps.gmk
+# Find all modules with source for the target platform.
+define FindAllModules
+  $(sort $(filter-out closed demo sample, $(notdir $(patsubst %/,%, $(dir \
+      $(wildcard $(patsubst %, %/*/share, $(ALL_TOP_SRC_DIRS)) \
+      $(patsubst %, %/*/$(OPENJDK_TARGET_OS), $(ALL_TOP_SRC_DIRS)) \
+      $(patsubst %, %/*/$(OPENJDK_TARGET_OS_API_DIR), $(ALL_TOP_SRC_DIRS))))))))
+endef
+
+################################################################################
+
+$(eval $(call SetupJavaCompilation,BUILD_GENMODULESLIST, \
+    SETUP := BOOT_JAVAC, \
+    SRC := $(JDK_TOPDIR)/make/src/classes, \
+    INCLUDES := build/tools/module, \
+    BIN := $(MAKESUPPORT_OUTPUTDIR)/bt_classes_moduleslist))
+
+TOOL_GENMODULESLIST = $(JAVA_SMALL) \
+    -cp "$(MAKESUPPORT_OUTPUTDIR)/bt_classes_moduleslist" \
+    build.tools.module.GenModulesList
+
+MODULES_LIST_FILE := $(MAKESUPPORT_OUTPUTDIR)/modules.list
+MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
+
+$(MODULES_LIST_FILE): $(SRC_ROOT)/modules.xml \
+    $(BUILD_GENMODULESLIST)
+	$(TOOL_GENMODULESLIST) -o $@ $(filter %.xml, $^)
 
 $(MODULE_DEPS_MAKEFILE): $(MODULES_LIST_FILE)
 	$(CAT) $^ | $(SED) -e 's/^\([^:]*\):/DEPS_\1 :=/g' > $@
@@ -63,14 +90,6 @@
   $(DEPS_$(strip $1))
 endef
 
-# Find all modules with source for the target platform.
-define FindAllModules
-  $(sort $(filter-out closed demo sample, $(notdir $(patsubst %/,%, $(dir \
-      $(wildcard $(patsubst %, %/*/share, $(ALL_TOP_SRC_DIRS)) \
-      $(patsubst %, %/*/$(OPENJDK_TARGET_OS), $(ALL_TOP_SRC_DIRS)) \
-      $(patsubst %, %/*/$(OPENJDK_TARGET_OS_API_DIR), $(ALL_TOP_SRC_DIRS))))))))
-endef
-
 ################################################################################
 
 # Hook to include the corresponding custom file, if present.
diff --git a/make/common/SetupJavaCompilers.gmk b/make/common/SetupJavaCompilers.gmk
index 6c3cb0b1..c9aa920 100644
--- a/make/common/SetupJavaCompilers.gmk
+++ b/make/common/SetupJavaCompilers.gmk
@@ -34,6 +34,12 @@
 # make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000"
 JAVAC_WARNINGS := -Xlint:all,-deprecation -Werror
 
+# The BOOT_JAVAC setup uses the boot jdk compiler to compile the tools
+# and the interim javac, to be run by the boot jdk.
+$(eval $(call SetupJavaCompiler,BOOT_JAVAC, \
+    JAVAC := $(JAVAC), \
+    FLAGS := -XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror))
+
 # Any java code executed during a JDK build to build other parts of the JDK must be 
 # executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this 
 # purpose must be built with -target PREVIOUS for bootstrapping purposes, which 
diff --git a/make/common/modules.list b/make/common/modules.list
deleted file mode 100644
index f2a3daa..0000000
--- a/make/common/modules.list
+++ /dev/null
@@ -1,54 +0,0 @@
-java.base: 
-java.logging: java.base
-java.security.sasl: java.logging java.base
-java.naming: java.security.sasl java.base
-java.security.acl: java.base
-jdk.charsets: java.base
-java.scripting: java.base
-java.xml: java.base
-java.sql: java.xml java.logging java.base
-jdk.scripting.nashorn: java.scripting java.logging java.base
-java.rmi: java.logging java.base
-java.prefs: java.xml java.base
-java.desktop: jdk.charsets java.prefs java.xml java.logging java.base
-java.corba: java.naming java.rmi java.desktop java.logging java.base
-java.compiler: java.logging java.base
-jdk.compiler: java.compiler java.base
-jdk.javadoc: java.compiler java.xml jdk.compiler java.base
-jdk.rmic: java.corba jdk.compiler jdk.javadoc java.base
-jdk.jvmstat: java.rmi java.base
-jdk.attach: jdk.jvmstat java.base
-jdk.jcmd: jdk.jvmstat jdk.attach java.base
-jdk.jdi: jdk.attach java.base
-jdk.hotspot.agent: java.rmi java.scripting java.desktop java.base jdk.jdi
-jdk.hprof.agent: java.base
-java.management: java.naming java.rmi java.logging java.base
-jdk.jconsole: java.management jdk.jvmstat java.rmi jdk.attach java.desktop java.logging java.base
-java.activation: java.desktop java.logging java.base
-java.xml.bind: java.activation java.compiler java.xml java.desktop java.logging java.base
-jdk.xml.bind: java.activation java.compiler java.xml.bind java.xml java.desktop java.logging jdk.compiler java.base
-jdk.httpserver: java.logging java.base
-java.annotations.common: java.base
-java.xml.soap: java.activation java.xml.bind java.xml java.desktop java.logging java.base
-java.xml.ws: java.activation java.management jdk.httpserver java.rmi java.annotations.common java.xml.bind java.xml java.desktop java.logging java.xml.soap java.base
-jdk.xml.ws: jdk.xml.bind java.compiler java.rmi java.xml.ws java.xml.bind java.xml java.logging java.base
-java.sql.rowset: java.naming java.sql java.xml java.logging java.base
-java.instrument: java.base
-java.security.jgss: java.naming java.security.sasl java.logging java.base
-java.xml.crypto: java.xml java.logging java.base
-jdk.localedata: java.base
-jdk.crypto.ec: java.base
-jdk.crypto.pkcs11: jdk.crypto.ec java.base
-jdk.crypto.mscapi: java.base
-jdk.naming.rmi: java.naming java.rmi java.base
-jdk.zipfs: java.base
-jdk.naming.dns: java.naming java.base
-java.smartcardio: java.base
-jdk.dev: jdk.xml.bind jdk.xml.ws java.scripting jdk.rmic java.xml jdk.compiler java.base
-jdk.snmp: java.management java.security.acl java.logging java.base
-jdk.jdwp.agent: java.base
-jdk.security.auth: java.naming java.security.jgss java.base
-jdk.sctp: java.base
-jdk.runtime: java.desktop java.base
-jdk.jfr: java.management java.xml java.base
-jdk.deploy.osx: java.scripting java.desktop java.base
diff --git a/modules.xml b/modules.xml
index c961ec56..1287481 100644
--- a/modules.xml
+++ b/modules.xml
@@ -243,6 +243,7 @@
       <to>java.rmi</to>
       <to>java.security.jgss</to>
       <to>java.security.sasl</to>
+      <to>java.sql</to>
       <to>jdk.charsets</to>
       <to>jdk.deploy.osx</to>
       <to>jdk.dev</to>
@@ -250,6 +251,7 @@
       <to>jdk.jvmstat</to>
       <to>jdk.runtime</to>
       <to>jdk.security.auth</to>
+      <to>jdk.security.jgss</to>
     </export>
     <export>
       <name>sun.net.dns</name>
@@ -326,6 +328,7 @@
     </export>
     <export>
       <name>sun.security.internal.spec</name>
+      <to>jdk.crypto.mscapi</to>
       <to>jdk.crypto.pkcs11</to>
       <to>jdk.crypto.ucrypto</to>
     </export>
@@ -730,6 +733,10 @@
     <export>
       <name>javax.swing.undo</name>
     </export>
+    <export>
+      <name>sun.awt</name>
+      <to>oracle.accessbridge</to>
+    </export>
   </module>
   <module>
     <name>java.instrument</name>
@@ -900,12 +907,7 @@
   <module>
     <name>java.security.jgss</name>
     <depend>java.base</depend>
-    <depend>java.logging</depend>
     <depend>java.naming</depend>
-    <depend>java.security.sasl</depend>
-    <export>
-      <name>com.sun.security.jgss</name>
-    </export>
     <export>
       <name>javax.security.auth.kerberos</name>
     </export>
@@ -924,6 +926,14 @@
       <name>sun.security.krb5.internal.ktab</name>
       <to>jdk.security.auth</to>
     </export>
+    <export>
+      <name>sun.security.jgss</name>
+      <to>jdk.security.jgss</to>
+    </export>
+    <export>
+      <name>sun.security.krb5.internal</name>
+      <to>jdk.security.jgss</to>
+    </export>
   </module>
   <module>
     <name>java.security.sasl</name>
@@ -934,7 +944,7 @@
     </export>
     <export>
       <name>com.sun.security.sasl.util</name>
-      <to>java.security.jgss</to>
+      <to>jdk.security.jgss</to>
     </export>
   </module>
   <module>
@@ -1570,6 +1580,10 @@
     </export>
   </module>
   <module>
+    <name>jdk.crypto.mscapi</name>
+    <depend>java.base</depend>
+  </module>
+  <module>
     <name>jdk.crypto.pkcs11</name>
     <depend>java.base</depend>
     <depend>jdk.crypto.ec</depend>
@@ -1752,6 +1766,16 @@
     </export>
   </module>
   <module>
+    <name>jdk.security.jgss</name>
+    <depend>java.base</depend>
+    <depend>java.logging</depend>
+    <depend re-exports="true">java.security.jgss</depend>
+    <depend>java.security.sasl</depend>
+    <export>
+      <name>com.sun.security.jgss</name>
+    </export>
+  </module>
+  <module>
     <name>jdk.xml.bind</name>
     <depend>java.activation</depend>
     <depend>java.base</depend>