make/CompileJavaModules.gmk
changeset 36506 17612cee3530
parent 36290 68b6b8f114b6
child 36787 402e5e40f6e5
--- a/make/CompileJavaModules.gmk	Tue Mar 15 13:48:18 2016 -0700
+++ b/make/CompileJavaModules.gmk	Thu Mar 17 19:03:53 2016 +0000
@@ -46,6 +46,9 @@
 java.base_COPY := .icu .dat .spp content-types.properties hijrah-config-islamic-umalqura.properties
 java.base_CLEAN := intrinsic.properties
 
+java.base_EXCLUDE_FILES += \
+  $(JDK_TOPDIR)/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java
+
 java.base_EXCLUDES += java/lang/doc-files
 
 # Exclude BreakIterator classes that are just used in compile process to generate
@@ -359,8 +362,8 @@
 
 ################################################################################
 
-jdk.compiler_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:-com.sun.tools.*' -XDstringConcat=inline
-jdk.compiler_COPY := javax.tools.JavaCompilerTool
+jdk.compiler_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:-com.sun.tools.*' \
+    -XDstringConcat=inline
 jdk.compiler_CLEAN_FILES := $(wildcard \
     $(patsubst %, $(JDK_TOPDIR)/src/jdk.compiler/share/classes/%/*.properties, \
         sun/tools/serialver/resources))
@@ -480,31 +483,28 @@
 # source before static source and platform specific source before shared.
 #
 GENERATED_SRC_DIRS += \
-    $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE) \
-    $(SUPPORT_OUTPUTDIR)/gensrc_no_docs/$(MODULE) \
+    $(SUPPORT_OUTPUTDIR)/gensrc \
     #
 
-OS_SRC_DIRS += $(JDK_TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS)/classes
-ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
-  OS_TYPE_SRC_DIRS += $(JDK_TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS_TYPE)/classes
-endif
-
-SHARE_SRC_DIRS += \
-    $(HOTSPOT_TOPDIR)/src/$(MODULE)/share/classes \
-    $(JDK_TOPDIR)/src/$(MODULE)/share/classes \
-    $(LANGTOOLS_TOPDIR)/src/$(MODULE)/share/classes \
-    $(CORBA_TOPDIR)/src/$(MODULE)/share/classes \
-    $(JAXP_TOPDIR)/src/$(MODULE)/share/classes \
-    $(JAXWS_TOPDIR)/src/$(MODULE)/share/classes \
-    $(NASHORN_TOPDIR)/src/$(MODULE)/share/classes \
+TOP_SRC_DIRS += \
+    $(HOTSPOT_TOPDIR)/src \
+    $(CORBA_TOPDIR)/src \
+    $(JDK_TOPDIR)/src \
+    $(LANGTOOLS_TOPDIR)/src \
+    $(JAXP_TOPDIR)/src \
+    $(JAXWS_TOPDIR)/src \
+    $(NASHORN_TOPDIR)/src \
     #
 
-ALL_SRC_DIRS = \
-    $(GENERATED_SRC_DIRS) \
-    $(OS_SRC_DIRS) \
-    $(OS_TYPE_SRC_DIRS) \
-    $(SHARE_SRC_DIRS) \
-    #
+SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes
+ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
+  SRC_SUBDIRS += $(OPENJDK_TARGET_OS_TYPE)/classes
+endif
+SRC_SUBDIRS += share/classes
+
+MODULE_SRC_DIRS := $(strip \
+    $(addsuffix /$(MODULE), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \
+    $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(MODULE)/$(sub), $(TOP_SRC_DIRS))))
 
 # The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying
 # JDK_FILTER at the make command line, only a subset of the JDK java files will
@@ -512,32 +512,41 @@
 # space separated list.
 JDK_USER_DEFINED_FILTER := $(strip $(subst $(COMMA),$(SPACE), $(JDK_FILTER)))
 
-# Create an empty directory to set the bootclasspath to.
-EMPTY_DIR := $(SUPPORT_OUTPUTDIR)/empty-dir
-$(call MakeDir, $(EMPTY_DIR))
+# Rewrite the MODULE_SRC_DIRS with a wildcard for the module so that all module
+# source dirs are available on the path.
+MODULESOURCEPATH := $(subst $(SPACE),$(PATH_SEP),$(subst $(MODULE),*,$(MODULE_SRC_DIRS)))
 
-# Find the module dependencies by parsing modules.list file
-DEPS := $(call FindDepsForModule, $(MODULE))
+# Add imported modules to the moduleclasspath
+MODULECLASSPATH := $(subst $(SPACE),$(PATH_SEP), $(IMPORT_MODULES_CLASSES))
 
-CLASSPATH := $(foreach d, $(DEPS), $(if $($d_BIN), $($d_BIN), \
-    $(JDK_OUTPUTDIR)/modules/$d))
-  # When crypto classes are prebuilt, need to look for classes already in
-  # output dir.
-  ifneq ($(BUILD_CRYPTO), true)
-  CLASSPATH += $(JDK_OUTPUTDIR)/modules/$(MODULE)
-  endif
-JAVAC_FLAGS_BOOTCLASSPATH := -bootclasspath $(EMPTY_DIR) -extdirs $(EMPTY_DIR) \
-    -endorseddirs $(EMPTY_DIR) $($(MODULE)_ADD_JAVAC_FLAGS)
+ifeq ($(MODULE), jdk.vm.ci)
+  ## WORKAROUND jdk.vm.ci source structure issue
+  JVMCI_MODULESOURCEPATH := $(MODULESOURCEPATH) \
+      $(subst /$(MODULE)/,/*/, $(filter-out %processor/src, \
+          $(wildcard $(HOTSPOT_TOPDIR)/src/jdk.vm.ci/share/classes/*/src)))
+  MODULESOURCEPATH := $(subst $(SPACE),$(PATH_SEP), $(JVMCI_MODULESOURCEPATH))
+endif
+
+# Make sure the generated source base dirs exist. Not all modules have generated
+# source in all of these directories and because of timing, all of them might not
+# exist at the time this makefile gets called. Javac will complain if there are
+# missing directories in the moduleclasspath.
+$(call MakeDir, $(GENERATED_SRC_DIRS))
 
 $(eval $(call SetupJavaCompilation, $(MODULE), \
     SETUP := $(if $($(MODULE)_SETUP), $($(MODULE)_SETUP), GENERATE_JDKBYTECODE), \
-    SRC := $(if $($(MODULE)_SRC), $($(MODULE)_SRC), $(wildcard $(ALL_SRC_DIRS))), \
-      INCLUDES := $(JDK_USER_DEFINED_FILTER),\
-    BIN := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules/$(MODULE)), \
-    HEADERS := $(SUPPORT_OUTPUTDIR)/headers/$(MODULE), \
-    CLASSPATH := $(CLASSPATH), \
-    ADD_JAVAC_FLAGS := $($(MODULE)_ADD_JAVAC_FLAGS) $(JAVAC_FLAGS_BOOTCLASSPATH) \
+    MODULE := $(MODULE), \
+    SRC := $(wildcard $(MODULE_SRC_DIRS)), \
+    INCLUDES := $(JDK_USER_DEFINED_FILTER),\
+    BIN := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules), \
+    HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \
+    ADD_JAVAC_FLAGS := \
+        $($(MODULE)_ADD_JAVAC_FLAGS) \
+        -modulesourcepath "$(MODULESOURCEPATH)" \
+        $(if $(MODULECLASSPATH), -modulepath "$(MODULECLASSPATH)") \
+        -system none, \
 ))
+
 TARGETS += $($(MODULE)) $($(MODULE)_COPY_EXTRA)
 
 # Declare dependencies between java compilations of different modules.
@@ -545,7 +554,7 @@
 # use the macro to find the correct target file to depend on.
 # Only the javac compilation actually depends on other modules so limit
 # dependency declaration to that by using the *_COMPILE_TARGET variable.
-$($(MODULE)_COMPILE_TARGET): $(foreach d, $($(MODULE)_DEPS), \
+$($(MODULE)_COMPILE_TARGET): $(foreach d, $(call FindDepsForModule, $(MODULE)), \
     $(call SetupJavaCompilationCompileTarget, $d, \
         $(if $($d_BIN), $($d_BIN), $(JDK_OUTPUTDIR)/modules/$d)))
 
@@ -569,6 +578,29 @@
 endif
 
 ################################################################################
+# If this is an imported module, copy the pre built classes and resources into
+# the modules output dir
+
+ifneq ($(wildcard $(IMPORT_MODULES_CLASSES)/$(MODULE)), )
+  $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker: \
+      $(call CacheFind, $(IMPORT_MODULES_CLASSES)/$(MODULE))
+	$(RM) -r $(@D)
+	$(MKDIR) -p $(@D)
+	$(CP) -R $(IMPORT_MODULES_CLASSES)/$(MODULE)/* $(@D)/
+	$(TOUCH) $@
+
+  TARGETS += $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker
+
+  # Add this dependency to avoid a race between compiling module-info.java and
+  # importing the classes.
+  $($(MODULE)_COMPILE_TARGET): $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker
+endif
+
+################################################################################
+
+$(eval $(call IncludeCustomExtension, , CompileJavaModules-post.gmk))
+
+################################################################################
 
 all: $(TARGETS)