make/common/Modules.gmk
changeset 45778 630bf135e7a6
parent 45612 3368f6d8b082
child 47217 72e3ae9a25eb
--- a/make/common/Modules.gmk	Thu Jun 29 17:26:06 2017 +0000
+++ b/make/common/Modules.gmk	Thu Aug 24 16:26:06 2017 +0200
@@ -40,6 +40,7 @@
 JRE_TOOL_MODULES :=
 UPGRADEABLE_MODULES :=
 AGGREGATOR_MODULES :=
+DOCS_MODULES :=
 
 # Hook to include the corresponding custom file, if present.
 $(eval $(call IncludeCustomExtension, , common/Modules.gmk))
@@ -58,12 +59,12 @@
     java.security.sasl \
     java.xml \
     jdk.httpserver \
+    jdk.internal.vm.ci \
     jdk.management \
     jdk.management.agent \
     jdk.net \
     jdk.sctp \
     jdk.unsupported \
-    jdk.vm.ci \
     #
 
 # to be deprivileged
@@ -71,18 +72,23 @@
     jdk.naming.rmi \
     #
 
+# Modules that directly or indirectly requiring upgradeable modules
+# should carefully be considered if it should be upgradeable or not.
 UPGRADEABLE_MODULES += \
     java.activation \
+    java.compiler \
     java.corba \
     java.transaction \
     java.xml.bind \
     java.xml.ws \
     java.xml.ws.annotation \
+    jdk.internal.vm.compiler \
     #
 
-# Modules explicitly declared as not being upgradeable even though they require
-# an upgradeable module.
-NON_UPGRADEABLE_MODULES +=
+UPGRADEABLE_TOOL_MODULES += \
+    jdk.xml.bind \
+    jdk.xml.ws \
+    #
 
 AGGREGATOR_MODULES += \
     java.se \
@@ -95,8 +101,6 @@
     #
 
 PLATFORM_MODULES += \
-    java.compiler \
-    jdk.incubator.httpclient \
     java.scripting \
     java.security.jgss \
     java.smartcardio \
@@ -105,10 +109,10 @@
     java.xml.crypto \
     jdk.accessibility \
     jdk.charsets \
+    jdk.crypto.cryptoki \
     jdk.crypto.ec \
-    jdk.crypto.cryptoki \
-    jdk.desktop \
     jdk.dynalink \
+    jdk.incubator.httpclient \
     jdk.jsobject \
     jdk.localedata \
     jdk.naming.dns \
@@ -119,18 +123,65 @@
     jdk.zipfs \
     #
 
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  PLATFORM_MODULES += jdk.crypto.mscapi
+endif
+
+ifeq ($(OPENJDK_TARGET_OS), solaris)
+  PLATFORM_MODULES += jdk.crypto.ucrypto
+endif
+
 JRE_TOOL_MODULES += \
     jdk.jdwp.agent \
     jdk.pack \
     jdk.scripting.nashorn.shell \
     #
 
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  PLATFORM_MODULES += jdk.crypto.mscapi
-endif
-ifeq ($(OPENJDK_TARGET_OS), solaris)
-  PLATFORM_MODULES += jdk.crypto.ucrypto
-endif
+################################################################################
+
+# DOCS_MODULES defines the root modules for javadoc generation.
+# All of their `require transitive` modules directly and indirectly will be included.
+DOCS_MODULES += \
+    java.se.ee \
+    java.smartcardio \
+    jdk.accessibility \
+    jdk.attach \
+    jdk.charsets \
+    jdk.compiler \
+    jdk.crypto.cryptoki \
+    jdk.crypto.ec \
+    jdk.dynalink \
+    jdk.editpad \
+    jdk.hotspot.agent \
+    jdk.httpserver \
+    jdk.incubator.httpclient \
+    jdk.jartool \
+    jdk.javadoc \
+    jdk.jcmd \
+    jdk.jconsole \
+    jdk.jdeps \
+    jdk.jdi \
+    jdk.jdwp.agent \
+    jdk.jlink \
+    jdk.jsobject \
+    jdk.jshell \
+    jdk.jstatd \
+    jdk.localedata \
+    jdk.management \
+    jdk.management.agent \
+    jdk.naming.dns \
+    jdk.naming.rmi \
+    jdk.net \
+    jdk.pack \
+    jdk.policytool \
+    jdk.rmic \
+    jdk.scripting.nashorn \
+    jdk.sctp \
+    jdk.security.auth \
+    jdk.security.jgss \
+    jdk.xml.dom \
+    jdk.zipfs \
+    #
 
 # These modules are included in the interim image which is used to run profiling
 # before building the real images.
@@ -147,7 +198,7 @@
 # Filter out Graal specific modules if Graal build is disabled
 
 ifeq ($(INCLUDE_GRAAL), false)
-  MODULES_FILTER += jdk.vm.compiler
+  MODULES_FILTER += jdk.internal.vm.compiler
 endif
 
 ################################################################################
@@ -182,6 +233,8 @@
 endif
 SRC_SUBDIRS += share/classes
 
+SPEC_SUBDIRS += share/specs
+
 # Find all module-info.java files for the current build target platform and
 # configuration.
 # Param 1 - Module to find for, set to * for finding all
@@ -234,6 +287,12 @@
         $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
 
+# Find all specs dirs for a particular module
+# $1 - Module to find specs dirs for
+FindModuleSpecsDirs = \
+    $(strip $(wildcard \
+        $(foreach sub, $(SPEC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS)))))
+
 # Construct the complete module source path
 GetModuleSrcPath = \
     $(call PathList, \
@@ -241,7 +300,8 @@
         $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /*/$(sub), $(TOP_SRC_DIRS))))
 
 ################################################################################
-# Extract module dependencies from module-info.java files.
+# Extract module dependencies from module-info.java files, both normal
+# dependencies ("requires"), and indirect exports ("requires transitive").
 
 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
 
@@ -255,25 +315,39 @@
 	    ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
-	          /requires/ { sub(/;/, ""); \
-	                       sub(/requires/, ""); \
-	                       sub(/transitive/, ""); \
-	                       sub(/\/\/.*/, ""); \
-	                       sub(/\/\*.*\*\//, ""); \
-	                       gsub(/^ +\*.*/, ""); \
-	                       gsub(/ /, ""); \
-	                       printf(" %s", $$0) } \
-	          END        { printf("\n") }' $m \
+	          /^ *requires/ { sub(/;/, ""); \
+	                          sub(/requires/, ""); \
+	                          sub(/transitive/, ""); \
+	                          sub(/\/\/.*/, ""); \
+	                          sub(/\/\*.*\*\//, ""); \
+	                          gsub(/^ +\*.*/, ""); \
+	                          gsub(/ /, ""); \
+	                          printf(" %s", $$0) } \
+	          END           { printf("\n") }' $m && \
+	      $(PRINTF) "TRANSITIVE_MODULES_$(call GetModuleNameFromModuleInfo, $m) :=" && \
+	      $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
+	          BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
+	          /^ *requires  *transitive/ { \
+	                          sub(/;/, ""); \
+	                          sub(/requires/, ""); \
+	                          sub(/transitive/, ""); \
+	                          sub(/\/\/.*/, ""); \
+	                          sub(/\/\*.*\*\//, ""); \
+	                          gsub(/^ +\*.*/, ""); \
+	                          gsub(/ /, ""); \
+	                          printf(" %s", $$0) } \
+	          END           { printf("\n") }' $m \
 	    ) >> $@ $(NEWLINE))
 
 -include $(MODULE_DEPS_MAKEFILE)
 
-# Param 1: Module to find deps for
+# Find dependencies ("requires") for a given module.
+# Param 1: Module to find dependencies for.
 FindDepsForModule = \
   $(DEPS_$(strip $1))
 
-# Finds transitive dependencies in 3 levels.
-# Param 1: Module to find transitive deps for
+# Find dependencies ("requires") transitively in 3 levels for a given module.
+# Param 1: Module to find dependencies for.
 FindTransitiveDepsForModule = \
     $(sort $(call FindDepsForModule, $1) \
         $(foreach m, $(call FindDepsForModule, $1), \
@@ -281,18 +355,35 @@
             $(foreach n, $(call FindDepsForModule, $m), \
                  $(call FindDepsForModule, $n))))
 
+# Find dependencies ("requires") transitively in 3 levels for a set of modules.
+# Param 1: List of modules to find dependencies for.
+FindTransitiveDepsForModules = \
+    $(sort $(foreach m, $1, $(call FindTransitiveDepsForModule, $m)))
+
+# Find indirect exported modules ("requires transitive") for a given module .
+# Param 1: Module to find indirect exported modules for.
+FindIndirectExportsForModule = \
+  $(TRANSITIVE_MODULES_$(strip $1))
+
+# Finds indirect exported modules transitively in 3 levels for a given module.
+# Param 1: Module to find indirect exported modules for.
+FindTransitiveIndirectDepsForModule = \
+    $(sort $(call FindIndirectExportsForModule, $1) \
+        $(foreach m, $(call FindIndirectExportsForModule, $1), \
+            $(call FindIndirectExportsForModule, $m) \
+            $(foreach n, $(call FindIndirectExportsForModule, $m), \
+                 $(call FindIndirectExportsForModule, $n))))
+
+# Finds indirect exported modules transitively in 3 levels for a set of modules.
+# Param 1: List of modules to find indirect exported modules for.
+FindTransitiveIndirectDepsForModules = \
+    $(sort $(foreach m, $1, $(call FindTransitiveIndirectDepsForModule, $m)))
+
 # Upgradeable modules are those that are either defined as upgradeable or that
 # require an upradeable module.
 FindAllUpgradeableModules = \
-    $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \
-        $(sort $(UPGRADEABLE_MODULES) $(foreach m, \
-            $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \
-          $(if $(filter $(UPGRADEABLE_MODULES), \
-              $(call FindTransitiveDepsForModule, $m)), \
-            $m \
-          ) \
-        )) \
-    )
+    $(sort $(filter-out $(MODULES_FILTER), $(UPGRADEABLE_MODULES) $(UPGRADEABLE_TOOL_MODULES)))
+
 
 ################################################################################
 
@@ -329,6 +420,10 @@
       else ifeq ($$(classloader), ext)
         PLATFORM_MODULES += $1
       endif
+      ifneq ($$(include_in_docs), false)
+        # defaults to true if unspecified
+        DOCS_MODULES += $1
+      endif
     else
       # Default to include in all
       JRE_MODULES += $1