8168108: lib/classlist should be packaged in java.base.jmod

Reviewed-by: mchung
This commit is contained in:
Erik Joelsson 2016-11-07 13:25:18 +01:00
parent 7f285c9448
commit 38acf59c15
6 changed files with 151 additions and 53 deletions

View File

@ -788,6 +788,7 @@ SYMBOLS_IMAGE_SUBDIR:=symbols
SYMBOLS_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(SYMBOLS_IMAGE_SUBDIR)
# Interim image
INTERIM_JMODS_DIR := $(SUPPORT_OUTPUTDIR)/interim-jmods
INTERIM_IMAGE_DIR := $(SUPPORT_OUTPUTDIR)/interim-image
# Docs image

View File

@ -36,6 +36,7 @@ endif
################################################################################
JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
JMODS_TEMPDIR := $(SUPPORT_OUTPUTDIR)/jmods
LIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
$(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
@ -81,9 +82,11 @@ endif
# Add dependencies on other jmod files. Only java.base needs access to other
# jmods.
ifeq ($(MODULE), java.base)
ALL_UPGRADEABLE_MODULES = $(call FindAllUpgradeableModules)
# When creating a BUILDJDK, we don't need to add hashes to java.base
ifneq ($(CREATING_BUILDJDK), true)
# When creating interim versions of jmods, skip hashes
ifneq ($(INTERIM_JMOD), true)
ALL_UPGRADEABLE_MODULES := $(call FindAllUpgradeableModules)
DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \
$(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules)))
@ -93,6 +96,7 @@ ifeq ($(MODULE), java.base)
--hash-modules '^(?!$(EXCLUDE_PATTERN))'
endif
endif
endif
# Changes to the jmod tool itself should also trigger a rebuild of all jmods.
# The variable JMOD_CMD could contain an environment variable assignment before
@ -102,13 +106,19 @@ ifeq ($(EXTERNAL_BUILDJDK), false)
DEPS += $(call CacheFind, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod)
endif
# If creating interim versions of jmods, certain files need to be filtered out
# to avoid false incremental rebuilds.
ifeq ($(INTERIM_JMOD), true)
DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS))
endif
# TODO: What about headers?
# Create jmods in a temp dir and then move them into place to keep the
# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
$(JMODS_DIR)/$(MODULE).jmod: $(DEPS)
$(call LogWarn, Creating $(patsubst $(OUTPUT_ROOT)/%, %, $@))
$(call MakeDir, $(@D) $(SUPPORT_OUTPUTDIR)/jmods)
$(RM) $@ $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
$(call MakeDir, $(JMODS_DIR) $(JMODS_TEMPDIR))
$(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@)
$(JMOD) create \
--module-version $(VERSION_SHORT) \
--os-name $(REQUIRED_OS_NAME) \
@ -116,10 +126,10 @@ $(JMODS_DIR)/$(MODULE).jmod: $(DEPS)
--os-version $(REQUIRED_OS_VERSION) \
--module-path $(JMODS_DIR) \
--exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
$(JMOD_FLAGS) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
$(MV) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) $@
$(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@)
$(MV) $(JMODS_TEMPDIR)/$(notdir $@) $@
TARGETS += $(IMAGES_OUTPUTDIR)/jmods/$(MODULE).jmod
TARGETS += $(JMODS_DIR)/$(MODULE).jmod
################################################################################

View File

@ -0,0 +1,88 @@
#
# Copyright (c) 2016, 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.
#
################################################################################
# Generate classlist
################################################################################
default: all
include $(SPEC)
include MakeBase.gmk
include JarArchive.gmk
################################################################################
# Create a jar with our generator class. Using a jar is intentional since it
# will load more classes
$(eval $(call SetupJarArchive, CLASSLIST_JAR, \
SRCS := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
INCLUDES := build/tools/classlist, \
JAR := $(SUPPORT_OUTPUTDIR)/classlist.jar, \
))
TARGETS += $(CLASSLIST_JAR)
################################################################################
LINK_OPT_DIR := $(SUPPORT_OUTPUTDIR)/link_opt
CLASSLIST_FILE := $(LINK_OPT_DIR)/classlist
JLI_TRACE_FILE := $(LINK_OPT_DIR)/jli_trace.out
# If an external buildjdk has been supplied, we don't build a separate interim
# image, so just use the external build jdk instead.
ifeq ($(EXTERNAL_BUILDJDK), true)
INTERIM_IMAGE_DIR := $(BUILD_JDK)
endif
$(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR)
$(call MakeDir, $(LINK_OPT_DIR))
$(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%, %, $@))
$(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%, %, $(JLI_TRACE_FILE)))
$(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@ \
-Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \
-cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
build.tools.classlist.HelloClasslist \
$(LOG_DEBUG) 2>&1 > $(JLI_TRACE_FILE)
# The jli trace is created by the same recipe as classlist. By declaring these
# dependencies, make will correctly rebuild both jli trace and classlist
# incrementally using the single recpie above.
$(CLASSLIST_FILE): $(JLI_TRACE_FILE)
$(JLI_TRACE_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR)
TARGETS += $(CLASSLIST_FILE) $(JLI_TRACE_FILE)
# Copy the classlist file into java.base libs
$(eval $(call SetupCopyFiles, COPY_CLASSLIST, \
FILES := $(CLASSLIST_FILE), \
DEST := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base, \
))
TARGETS += $(COPY_CLASSLIST)
################################################################################
all: $(TARGETS)

View File

@ -113,8 +113,8 @@ JIMAGE_TARGET_FILE := bin/java$(EXE_SUFFIX)
JLINK_ORDER_RESOURCES := **module-info.class
JLINK_JLI_CLASSES :=
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
JLINK_ORDER_RESOURCES += @$(SUPPORT_OUTPUTDIR)/classlist/classlist
JLINK_JLI_CLASSES := --generate-jli-classes=@$(SUPPORT_OUTPUTDIR)/classlist/jli_trace.out
JLINK_ORDER_RESOURCES += @$(SUPPORT_OUTPUTDIR)/link_opt/classlist
JLINK_JLI_CLASSES := --generate-jli-classes=@$(SUPPORT_OUTPUTDIR)/link_opt/jli_trace.out
endif
JLINK_ORDER_RESOURCES += \
/java.base/java/** \
@ -359,25 +359,6 @@ $(JDK_IMAGE_DIR)/src.zip: $(SUPPORT_OUTPUTDIR)/src.zip
JDK_TARGETS += $(JDK_IMAGE_DIR)/src.zip
################################################################################
# classlist
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
$(eval $(call SetupCopyFiles, JDK_COPY_CLASSLIST, \
FILES := $(SUPPORT_OUTPUTDIR)/classlist/classlist, \
DEST := $(JDK_IMAGE_DIR)/lib, \
))
JDK_TARGETS += $(JDK_COPY_CLASSLIST)
$(eval $(call SetupCopyFiles, JRE_COPY_CLASSLIST, \
FILES := $(SUPPORT_OUTPUTDIR)/classlist/classlist, \
DEST := $(JRE_IMAGE_DIR)/lib, \
))
JRE_TARGETS += $(JRE_COPY_CLASSLIST)
endif
################################################################################
# /demo dir
# Avoid doing the expensive find unless called with "jdk" as target.

View File

@ -36,15 +36,15 @@ JIMAGE_TARGET_FILE := bin/java$(EXE_SUFFIX)
INTERIM_MODULES_LIST := $(call CommaList, $(INTERIM_IMAGE_MODULES))
JMODS := $(patsubst %, $(IMAGES_OUTPUTDIR)/jmods/%.jmod, $(INTERIM_IMAGE_MODULES))
JMODS := $(patsubst %, $(INTERIM_JMODS_DIR)/%.jmod, $(INTERIM_IMAGE_MODULES))
JLINK_TOOL := $(JLINK) \
--module-path $(IMAGES_OUTPUTDIR)/jmods \
--module-path $(INTERIM_JMODS_DIR) \
--endian $(OPENJDK_BUILD_CPU_ENDIAN)
$(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
$(call DependOnVariable, INTERIM_MODULES_LIST)
$(ECHO) Creating interim jimage
$(call LogWarn, Creating interim jimage)
$(RM) -r $(INTERIM_IMAGE_DIR)
$(JLINK_TOOL) \
--output $(INTERIM_IMAGE_DIR) \

View File

@ -376,15 +376,29 @@ ALL_TARGETS += create-buildjdk-copy create-buildjdk-interim-image
# The interim-image is a small jlinked image that is used to generate artifacts
# at build time for use when linking the real images.
INTERIM_JMOD_TARGETS := $(addsuffix -interim-jmod, $(INTERIM_IMAGE_MODULES))
define DeclareInterimJmodRecipe
$1-interim-jmod:
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
MODULE=$1 \
JMODS_DIR=$(INTERIM_JMODS_DIR) \
JMODS_TEMPDIR=$(INTERIM_JMODS_DIR)/temp \
INTERIM_JMOD=true \
)
endef
$(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $(call DeclareInterimJmodRecipe,$m)))
interim-image:
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f InterimImage.gmk)
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
generate-classlist:
+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f GenerateClasslist.gmk)
generate-link-opt-data:
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f GenerateLinkOptData.gmk)
endif
ALL_TARGETS += interim-image generate-classlist
ALL_TARGETS += $(INTERIM_JMOD_TARGETS) interim-image generate-link-opt-data
################################################################################
# Build tests
@ -607,13 +621,15 @@ else
# When creating a BUILDJDK, the java compilation has already been done by the
# normal build and copied in.
ifneq ($(CREATING_BUILDJDK), true)
$(foreach m, $(JAVA_MODULES), $(eval $m-jmod: $m-java))
$(foreach m, $(JAVA_MODULES), $(eval $m_JMOD_DEPS += $m-java))
endif
$(foreach m, $(GENDATA_MODULES), $(eval $m-jmod: $m-gendata))
$(foreach m, $(RMIC_MODULES), $(eval $m-jmod: $m-rmic))
$(foreach m, $(LIBS_MODULES), $(eval $m-jmod: $m-libs))
$(foreach m, $(LAUNCHER_MODULES), $(eval $m-jmod: $m-launchers))
$(foreach m, $(COPY_MODULES), $(eval $m-jmod: $m-copy))
$(foreach m, $(GENDATA_MODULES), $(eval $m_JMOD_DEPS += $m-gendata))
$(foreach m, $(RMIC_MODULES), $(eval $m_JMOD_DEPS += $m-rmic))
$(foreach m, $(LIBS_MODULES), $(eval $m_JMOD_DEPS += $m-libs))
$(foreach m, $(LAUNCHER_MODULES), $(eval $m_JMOD_DEPS += $m-launchers))
$(foreach m, $(COPY_MODULES), $(eval $m_JMOD_DEPS += $m-copy))
$(foreach m, $(ALL_MODULES), $(eval $m-jmod: $($(m)_JMOD_DEPS)))
$(foreach m, $(INTERIM_IMAGE_MODULES), $(eval $m-interim-jmod: $($(m)_JMOD_DEPS)))
# Jmods cannot be created until we have the jmod tool ready to run. During
# a normal build we run it from the exploded image, but when cross compiling
@ -636,12 +652,13 @@ else
buildtools-modules: create-buildjdk
else
# While actually creating the buildjdk, the default deps applies.
$(JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
$(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS)
endif
else
# The normal non cross compilation case uses the default deps.
# To avoid races with the optimize target, that also needs to happen first.
$(JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) exploded-image-optimize
$(JMOD_TARGETS) $(INTERIM_JMOD_TARGETS): $(DEFAULT_JMOD_DEPS) \
exploded-image-optimize
endif
zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
@ -654,16 +671,17 @@ else
ifeq ($(ENABLE_GENERATE_CLASSLIST), true)
ifeq ($(CREATE_BUILDJDK), true)
# If creating a buildjdk, the interim image needs to be based on that.
generate-classlist: create-buildjdk
generate-link-opt-data: create-buildjdk
else ifeq ($(EXTERNAL_BUILDJDK), false)
# If an external buildjdk has been provided, we skip generating an
# interim-image and just use the external buildjdk for generating
# classlist.
generate-classlist: interim-image
generate-link-opt-data: interim-image
endif
generate-classlist: buildtools-jdk
generate-link-opt-data: buildtools-jdk
jdk-image jre-image: generate-classlist
# The generated classlist needs to go into java.base-jmod.
java.base-jmod jdk-image jre-image: generate-link-opt-data
endif
jdk-image: jmods zip-source source-tips demos samples jrtfs-jar
@ -695,7 +713,7 @@ else
create-buildjdk-interim-image: create-buildjdk-copy
interim-image: $(addsuffix -jmod, $(INTERIM_IMAGE_MODULES))
interim-image: $(INTERIM_JMOD_TARGETS)
test-make: clean-test-make