From 008ca2a72587f1518199e81f6f7ec7fbdc258d99 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 3 Nov 2023 16:05:40 +0000 Subject: [PATCH] 8317620: Build JDK tools with ModuleMainClass attribute Reviewed-by: erikj, alanb --- make/CreateJmods.gmk | 11 ++++++++--- make/Main.gmk | 5 +++-- make/modules/jdk.httpserver/Jmod.gmk | 26 ++++++++++++++++++++++++++ make/modules/jdk.jartool/Jmod.gmk | 26 ++++++++++++++++++++++++++ make/modules/jdk.jfr/Jmod.gmk | 26 ++++++++++++++++++++++++++ make/modules/jdk.jpackage/Jmod.gmk | 26 ++++++++++++++++++++++++++ make/modules/jdk.jshell/Jmod.gmk | 26 ++++++++++++++++++++++++++ make/modules/jdk.jstatd/Jmod.gmk | 26 ++++++++++++++++++++++++++ 8 files changed, 167 insertions(+), 5 deletions(-) create mode 100644 make/modules/jdk.httpserver/Jmod.gmk create mode 100644 make/modules/jdk.jartool/Jmod.gmk create mode 100644 make/modules/jdk.jfr/Jmod.gmk create mode 100644 make/modules/jdk.jpackage/Jmod.gmk create mode 100644 make/modules/jdk.jshell/Jmod.gmk create mode 100644 make/modules/jdk.jstatd/Jmod.gmk diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk index 6fbaef6bdf1..d1e83c8c8e0 100644 --- a/make/CreateJmods.gmk +++ b/make/CreateJmods.gmk @@ -182,9 +182,14 @@ else # not java.base endif endif -# Set main class of jdk.httpserver module -ifeq ($(MODULE), jdk.httpserver) - JMOD_FLAGS += --main-class sun.net.httpserver.simpleserver.Main +################################################################################ +# Include module specific build settings + +-include Jmod.gmk + +# Set main class +ifneq ($(JMOD_FLAGS_main_class), ) + JMOD_FLAGS += $(JMOD_FLAGS_main_class) endif # Changes to the jmod tool itself should also trigger a rebuild of all jmods. diff --git a/make/Main.gmk b/make/Main.gmk index f054a89fb95..8fdaf788c4d 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -405,8 +405,9 @@ JMOD_TARGETS := $(addsuffix -jmod, $(JMOD_MODULES)) define DeclareJmodRecipe $1-jmod: - +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \ - MODULE=$1) + +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \ + $(patsubst %,-I%/modules/$1,$(PHASE_MAKEDIRS)) \ + -f CreateJmods.gmk MODULE=$1) endef $(foreach m, $(JMOD_MODULES), $(eval $(call DeclareJmodRecipe,$m))) diff --git a/make/modules/jdk.httpserver/Jmod.gmk b/make/modules/jdk.httpserver/Jmod.gmk new file mode 100644 index 00000000000..9a216ef0958 --- /dev/null +++ b/make/modules/jdk.httpserver/Jmod.gmk @@ -0,0 +1,26 @@ +# +# Copyright (c) 2023, 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. +# + +JMOD_FLAGS_main_class := --main-class sun.net.httpserver.simpleserver.Main diff --git a/make/modules/jdk.jartool/Jmod.gmk b/make/modules/jdk.jartool/Jmod.gmk new file mode 100644 index 00000000000..8b42113ec84 --- /dev/null +++ b/make/modules/jdk.jartool/Jmod.gmk @@ -0,0 +1,26 @@ +# +# Copyright (c) 2023, 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. +# + +JMOD_FLAGS_main_class := --main-class sun.tools.jar.Main diff --git a/make/modules/jdk.jfr/Jmod.gmk b/make/modules/jdk.jfr/Jmod.gmk new file mode 100644 index 00000000000..79a6a81c730 --- /dev/null +++ b/make/modules/jdk.jfr/Jmod.gmk @@ -0,0 +1,26 @@ +# +# Copyright (c) 2023, 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. +# + +JMOD_FLAGS_main_class := --main-class jdk.jfr.internal.tool.Main diff --git a/make/modules/jdk.jpackage/Jmod.gmk b/make/modules/jdk.jpackage/Jmod.gmk new file mode 100644 index 00000000000..8e0982202a7 --- /dev/null +++ b/make/modules/jdk.jpackage/Jmod.gmk @@ -0,0 +1,26 @@ +# +# Copyright (c) 2023, 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. +# + +JMOD_FLAGS_main_class := --main-class jdk.jpackage.main.Main diff --git a/make/modules/jdk.jshell/Jmod.gmk b/make/modules/jdk.jshell/Jmod.gmk new file mode 100644 index 00000000000..12f22e9d9af --- /dev/null +++ b/make/modules/jdk.jshell/Jmod.gmk @@ -0,0 +1,26 @@ +# +# Copyright (c) 2023, 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. +# + +JMOD_FLAGS_main_class := --main-class jdk.internal.jshell.tool.JShellToolProvider diff --git a/make/modules/jdk.jstatd/Jmod.gmk b/make/modules/jdk.jstatd/Jmod.gmk new file mode 100644 index 00000000000..2c95e094cfe --- /dev/null +++ b/make/modules/jdk.jstatd/Jmod.gmk @@ -0,0 +1,26 @@ +# +# Copyright (c) 2023, 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. +# + +JMOD_FLAGS_main_class := --main-class sun.tools.jstatd.Jstatd