< prev index next >

make/CompileJavaModules.gmk

Print this page
*** 1,7 ***
  #
! # Copyright (c) 2014, 2025, 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
--- 1,7 ---
  #
! # 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

*** 28,10 ***
--- 28,12 ---
  ################################################################################
  
  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)

*** 96,17 ***
  endif
  
  ################################################################################
  # Setup the main compilation
  
  $(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 := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules), \
      HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \
      CREATE_API_DIGEST := true, \
      CLEAN := $(CLEAN), \
      CLEAN_FILES := $(CLEAN_FILES), \
      COPY := $(COPY), \
--- 98,19 ---
  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), \

*** 124,10 ***
--- 128,69 ---
          --system none, \
  ))
  
  TARGETS += $($(MODULE))
  
+ ################################################################################
+ # Setup compilation for value 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 value classes
+ VALUECLASSES_STR := valueclasses
+ 
+ ifneq ($(COMPILER), bootjdk)
+   MODULE_VALUECLASS_SRC_DIRS := $(call FindModuleValueClassSrcDirs, $(MODULE))
+   MODULE_VALUECLASS_SOURCEPATH := $(call GetModuleValueClassSrcPath)
+   ifneq ($(MODULE_VALUECLASS_SRC_DIRS),)
+     # Temporarily compile valueclasses into a separate directory, and then copy
+     # into the correct "META-INF/preview" path location.
+     # We cannot compile directly into the desired directory because it's the
+     # compiler which creates the original '<module>/<classpath>/...' hierarchy.
+     TEMP_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/$(VALUECLASSES_STR)
+ 
+     $(eval $(call SetupJavaCompilation, $(MODULE)-$(VALUECLASSES_STR), \
+         SMALL_JAVA := false, \
+         MODULE := $(MODULE), \
+         SRC := $(wildcard $(MODULE_VALUECLASS_SRC_DIRS)), \
+         INCLUDES := $(JDK_USER_DEFINED_FILTER), \
+         FAIL_NO_SRC := $(FAIL_NO_SRC), \
+         BIN := $(TEMP_OUTPUTDIR)/, \
+         HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \
+         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_VALUECLASS_SOURCEPATH) \
+             --module-path $(JDK_OUTPUTDIR)/modules \
+             --system none \
+             --enable-preview -source $(JDK_SOURCE_TARGET_VERSION), \
+     ))
+ 
+     # Don't add '$($(MODULE)-$(VALUECLASSES_STR))' to TARGETS (it's transient).
+     # The 'valueclasses' target below depends on it, and that's the non-transient
+     # result we care about.
+ 
+     # Copy compiled output from "$TEMP_OUTPUTDIR/$MODULE/<classpath>/..."
+     # to "$COMPILATION_OUTPUTDIR/$MODULE/META-INF/preview/<classpath>/...".
+     MOD_SRC := $(TEMP_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).valueclasses: $($(MODULE)-$(VALUECLASSES_STR))
+ 		$(RM) -r $(@D)/META-INF/preview
+ 		$(MKDIR) -p $(@D)/META-INF/preview
+ 		$(CP) -R $(filter-out $(MOD_SRC)/_%, $(wildcard $(MOD_SRC)/*)) $(@D)/META-INF/preview
+ 		$(TOUCH) $@
+ 
+     TARGETS += $(MOD_DST)/_the.$(MODULE).valueclasses
+   endif
+ 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.
< prev index next >