# # Copyright (c) 2014, 2026, 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 MakeFileStart.gmk ################################################################################ include JavaCompilation.gmk include Modules.gmk include CopyFiles.gmk ################################################################################ # If this is an imported module that has prebuilt classes, only compile # module-info.java. ifneq ($(IMPORT_MODULES_CLASSES), ) IMPORT_MODULE_DIR := $(IMPORT_MODULES_CLASSES)/$(MODULE) ifneq ($(wildcard $(IMPORT_MODULE_DIR)), ) $(MODULE)_INCLUDE_FILES := module-info.java endif else IMPORT_MODULE_DIR := endif ################################################################################ # Setup the compilation for the module # MODULE_SRC_DIRS := $(call FindModuleSrcDirs, $(MODULE)) # 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 # be recompiled. If multiple paths are separated by comma, convert that into a # space separated list. JDK_USER_DEFINED_FILTER := $(strip $(subst $(COMMA),$(SPACE), $(JDK_FILTER))) ifeq ($(JDK_FILTER), ) FAIL_NO_SRC := true else # When using JDK_FILTER, most module java compilations will end up finding # no source files. Don't let that fail the build. FAIL_NO_SRC := false endif # Get the complete module source path. MODULESOURCEPATH := $(call GetModuleSrcPath) # Add imported modules to the modulepath MODULEPATH := $(call PathList, $(IMPORT_MODULES_CLASSES)) ################################################################################ # Copy zh_HK properties files from zh_TW (needed by some modules) $(JDK_OUTPUTDIR)/modules/%_zh_HK.properties: $(JDK_OUTPUTDIR)/modules/%_zh_TW.properties $(install-file) CreateHkTargets = \ $(call FilterExcludedTranslations, \ $(patsubst $(TOPDIR)/src/%, $(JDK_OUTPUTDIR)/modules/%, \ $(subst /share/classes,, \ $(subst _zh_TW,_zh_HK, $(filter %_zh_TW.properties, $1)) \ ) \ ), \ .properties \ ) ################################################################################ # Include module specific build settings THIS_SNIPPET := $(call GetModuleSnippetName, Java) ifneq ($(wildcard $(THIS_SNIPPET)), ) include MakeSnippetStart.gmk include $(THIS_SNIPPET) include MakeSnippetEnd.gmk endif ################################################################################ # Setup the main compilation COMPILATION_OUTPUTDIR := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules) $(eval $(call SetupJavaCompilation, $(MODULE), \ SMALL_JAVA := false, \ MODULE := $(MODULE), \ SRC := $(wildcard $(MODULE_SRC_DIRS)), \ INCLUDES := $(JDK_USER_DEFINED_FILTER), \ FAIL_NO_SRC := $(FAIL_NO_SRC), \ BIN := $(COMPILATION_OUTPUTDIR), \ HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \ CREATE_API_DIGEST := true, \ CLEAN := $(CLEAN), \ CLEAN_FILES := $(CLEAN_FILES), \ COPY := $(COPY), \ DISABLED_WARNINGS := $(DISABLED_WARNINGS_java), \ EXCLUDES := $(EXCLUDES), \ EXCLUDE_FILES := $(EXCLUDE_FILES), \ EXCLUDE_PATTERNS := -files, \ KEEP_ALL_TRANSLATIONS := $(KEEP_ALL_TRANSLATIONS), \ TARGET_RELEASE := $(TARGET_RELEASE), \ JAVAC_FLAGS := \ $(DOCLINT) \ $(JAVAC_FLAGS) \ --module-source-path $(MODULESOURCEPATH) \ --module-path $(MODULEPATH) \ --system none, \ )) TARGETS += $($(MODULE)) ################################################################################ # Setup compilation for preview classes in the module # TBD: When $(DOCLINT) was included there was an NPE in JavacTypes.getOverriddenMethods # Directory and file name suffix for jar file containing preview classes/resources. PREVIEW_CLASSES_LABEL := preview # Module relative path in which preview classes/resources are placed. PREVIEW_PATH := META-INF/preview MODULE_PREVIEW_SRC_DIRS := $(call FindModulePreviewSrcDirs, $(MODULE)) MODULE_PREVIEW_SOURCEPATH := $(call GetModulePreviewSrcPath) ifneq ($(MODULE_PREVIEW_SRC_DIRS),) # Compile preview classes into a separate directory, and then copy into the # correct output path location. We cannot compile directly into the desired # directory because it's the compiler which creates the original # '//...' hierarchy. PREVIEW_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/$(PREVIEW_CLASSES_LABEL) PATCH_COMMAND := $(MODULE)=$(call strip, $(COMPILATION_OUTPUTDIR)/$(MODULE)) $(eval $(call SetupJavaCompilation, $(MODULE)-$(PREVIEW_CLASSES_LABEL), \ SMALL_JAVA := false, \ MODULE := $(MODULE), \ SRC := $(wildcard $(MODULE_PREVIEW_SRC_DIRS)), \ INCLUDES := $(JDK_USER_DEFINED_FILTER), \ FAIL_NO_SRC := $(FAIL_NO_SRC), \ BIN := $(PREVIEW_OUTPUTDIR)/, \ DISABLED_WARNINGS := $(DISABLED_WARNINGS_java) preview, \ EXCLUDES := $(EXCLUDES), \ EXCLUDE_FILES := $(EXCLUDE_FILES), \ KEEP_ALL_TRANSLATIONS := $(KEEP_ALL_TRANSLATIONS), \ DEPENDS := $($(MODULE)), \ JAVAC_FLAGS := \ $(JAVAC_FLAGS) \ --module-source-path $(MODULE_PREVIEW_SOURCEPATH) \ --module-path $(MODULEPATH) \ --patch-module $(PATCH_COMMAND) \ --system none \ --enable-preview -source $(JDK_SOURCE_TARGET_VERSION), \ )) # Don't add '$($(MODULE)-$(PREVIEW_CLASSES_LABEL))' to TARGETS (it's transient). # The 'preview' target below depends on it, and that's the non-transient # result we care about. # Copy compiled output from "$(PREVIEW_OUTPUTDIR)/$(MODULE)//..." # to "$(COMPILATION_OUTPUTDIR)/$(MODULE)/$(PREVIEW_PATH)//...". MOD_SRC := $(PREVIEW_OUTPUTDIR)/$(MODULE) MOD_DST := $(COMPILATION_OUTPUTDIR)/$(MODULE) # NOTE: We cannot use '$(CP) -R $(MOD_SRC)/*/ ...' to select sub-directories (it # does not work on MacOS/BSD). Use 'filter-out' to explicitly exclude marker files. $(MOD_DST)/_the.$(MODULE).preview: $($(MODULE)-$(PREVIEW_CLASSES_LABEL)) $(RM) -r $(@D)/$(PREVIEW_PATH) $(MKDIR) -p $(@D)/$(PREVIEW_PATH) $(CP) -R $(filter-out $(MOD_SRC)/_%, $(wildcard $(MOD_SRC)/*)) $(@D)/$(PREVIEW_PATH) $(TOUCH) $@ TARGETS += $(MOD_DST)/_the.$(MODULE).preview endif # Declare dependencies between java compilations of different modules. # Since the other modules are declared in different invocations of this file, # 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 *_MODFILELIST variable. $($(MODULE)_MODFILELIST): $(foreach d, $(call FindDepsForModule, $(MODULE)), \ $(call SetupJavaCompilationApiTarget, $d, \ $(if $($d_BIN), $($d_BIN), $(JDK_OUTPUTDIR)/modules/$d))) ################################################################################ # If this is an imported module, copy the pre built classes and resources into # the modules output dir ifneq ($(wildcard $(IMPORT_MODULE_DIR)), ) $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker: \ $(call FindFiles, $(IMPORT_MODULE_DIR)) $(call MakeDir, $(@D)) # Do not delete marker and build meta data files $(RM) -r $(filter-out $(@D)/_%, $(wildcard $(@D)/*)) $(CP) -R $(IMPORT_MODULE_DIR)/* $(@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 ################################################################################ include MakeFileEnd.gmk