From 1bca05eace5c4622a1fd596f4ed196495a8801e4 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Wed, 10 May 2023 14:40:56 +0000 Subject: [PATCH 001/502] 8307799: Newly added java/awt/dnd/MozillaDnDTest.java has invalid jtreg `@requires` clause Reviewed-by: rriggs, azvegint --- test/jdk/java/awt/dnd/MozillaDnDTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/java/awt/dnd/MozillaDnDTest.java b/test/jdk/java/awt/dnd/MozillaDnDTest.java index 37fce051eb1e4..f442d0825ae72 100644 --- a/test/jdk/java/awt/dnd/MozillaDnDTest.java +++ b/test/jdk/java/awt/dnd/MozillaDnDTest.java @@ -64,7 +64,7 @@ @test @bug 4746177 @summary tests that data types exported by Netscape 6.2 are supported - @requires(os != "windows") + @requires (os.family != "windows") @key headful @run main MozillaDnDTest */ From 0198afca3ac1a7c421b0669ae2180eee3e4f1482 Mon Sep 17 00:00:00 2001 From: Archie Cobbs Date: Wed, 10 May 2023 16:24:00 +0000 Subject: [PATCH 002/502] 8305748: Clarify reentrant behavior of close() in FileInputStream, FileOutputStream, and RandomAccessFile Reviewed-by: alanb, bpb --- src/java.base/share/classes/java/io/FileInputStream.java | 5 +++++ src/java.base/share/classes/java/io/FileOutputStream.java | 5 +++++ src/java.base/share/classes/java/io/RandomAccessFile.java | 5 +++++ .../share/classes/java/nio/channels/FileChannel.java | 3 ++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/io/FileInputStream.java b/src/java.base/share/classes/java/io/FileInputStream.java index a1797cf12466e..2c4e8812b1802 100644 --- a/src/java.base/share/classes/java/io/FileInputStream.java +++ b/src/java.base/share/classes/java/io/FileInputStream.java @@ -493,6 +493,11 @@ public int available() throws IOException { * Subclasses requiring that resource cleanup take place after a stream becomes * unreachable should use the {@link java.lang.ref.Cleaner} mechanism. * + *

+ * If this stream has an associated channel then this method will close the + * channel, which in turn will close this stream. Subclasses that override + * this method should be prepared to handle possible reentrant invocation. + * * @throws IOException {@inheritDoc} * * @revised 1.4 diff --git a/src/java.base/share/classes/java/io/FileOutputStream.java b/src/java.base/share/classes/java/io/FileOutputStream.java index 9aadf1f38beed..c596d98b3cedb 100644 --- a/src/java.base/share/classes/java/io/FileOutputStream.java +++ b/src/java.base/share/classes/java/io/FileOutputStream.java @@ -386,6 +386,11 @@ public void write(byte[] b, int off, int len) throws IOException { * Subclasses requiring that resource cleanup take place after a stream becomes * unreachable should use the {@link java.lang.ref.Cleaner} mechanism. * + *

+ * If this stream has an associated channel then this method will close the + * channel, which in turn will close this stream. Subclasses that override + * this method should be prepared to handle possible reentrant invocation. + * * @throws IOException if an I/O error occurs. * * @revised 1.4 diff --git a/src/java.base/share/classes/java/io/RandomAccessFile.java b/src/java.base/share/classes/java/io/RandomAccessFile.java index 71f9956b15b67..57f984ad9c436 100644 --- a/src/java.base/share/classes/java/io/RandomAccessFile.java +++ b/src/java.base/share/classes/java/io/RandomAccessFile.java @@ -697,6 +697,11 @@ public void setLength(long newLength) throws IOException { *

If this file has an associated channel then the channel is closed * as well. * + * @apiNote + * If this stream has an associated channel then this method will close the + * channel, which in turn will close this stream. Subclasses that override + * this method should be prepared to handle possible reentrant invocation. + * * @throws IOException if an I/O error occurs. * * @revised 1.4 diff --git a/src/java.base/share/classes/java/nio/channels/FileChannel.java b/src/java.base/share/classes/java/nio/channels/FileChannel.java index c193f209cd2e3..c55024cd0fae9 100644 --- a/src/java.base/share/classes/java/nio/channels/FileChannel.java +++ b/src/java.base/share/classes/java/nio/channels/FileChannel.java @@ -122,7 +122,8 @@ * the originating object, and vice versa. Changing the file's length via the * file channel will change the length seen via the originating object, and vice * versa. Changing the file's content by writing bytes will change the content - * seen by the originating object, and vice versa. + * seen by the originating object, and vice versa. Closing the channel will + * close the originating object. * *

At various points this class specifies that an * instance that is "open for reading," "open for writing," or "open for From 8a95020ab6c61f25954a56e1965529bb2f6f58af Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Wed, 10 May 2023 16:29:34 +0000 Subject: [PATCH 003/502] 8151531: Add notes to BaseStream.spliterator/iterator docs regarding them being escape hatches Reviewed-by: psandoz --- .../share/classes/java/util/stream/BaseStream.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/util/stream/BaseStream.java b/src/java.base/share/classes/java/util/stream/BaseStream.java index 0328b25cafd63..28e0541efdb5d 100644 --- a/src/java.base/share/classes/java/util/stream/BaseStream.java +++ b/src/java.base/share/classes/java/util/stream/BaseStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -69,6 +69,11 @@ public interface BaseStream> *

This is a terminal * operation. * + * @apiNote + * This operation is provided as an "escape hatch" to enable + * arbitrary client-controlled pipeline traversals in the event that the + * existing operations are not sufficient to the task. + * * @return the element iterator for this stream */ Iterator iterator(); @@ -79,6 +84,11 @@ public interface BaseStream> *

This is a terminal * operation. * + * @apiNote + * This operation is provided as an "escape hatch" to enable + * arbitrary client-controlled pipeline traversals in the event that the + * existing operations are not sufficient to the task. + * *

* The returned spliterator should report the set of characteristics derived * from the stream pipeline (namely the characteristics derived from the From 9af1787ebe842bcfbf4a03a9deefe19bbd1ee87d Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Wed, 10 May 2023 16:44:49 +0000 Subject: [PATCH 004/502] 8307244: Remove redundant class RMIIIOPServerImpl Reviewed-by: sspitsyn, dfuchs, alanb --- .../management/remote/rmi/RMIConnector.java | 2 +- .../remote/rmi/RMIIIOPServerImpl.java | 96 ------------------- 2 files changed, 1 insertion(+), 97 deletions(-) delete mode 100644 src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIIIOPServerImpl.java diff --git a/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java b/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java index 251bc6ffb405e..626c921f2da72 100644 --- a/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java +++ b/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java @@ -185,7 +185,7 @@ private RMIConnector(RMIServer rmiServer, JMXServiceURL address, * syntaxes, for example:

* *
-     * service:jmx:iiop://[host[:port]]/stub/encoded-stub
+     * service:jmx:myprotocolname://[host[:port]]/stub/encoded-stub
      * 
* * @param url the address of the RMI connector server. diff --git a/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIIIOPServerImpl.java b/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIIIOPServerImpl.java deleted file mode 100644 index 00b25b71d9e9f..0000000000000 --- a/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIIIOPServerImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2003, 2015, 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. - */ - -package javax.management.remote.rmi; - -import java.io.IOException; -import java.rmi.Remote; -import java.util.Map; -import javax.security.auth.Subject; - -/** - *

An {@link RMIServerImpl} that is exported through IIOP and that - * creates client connections as RMI objects exported through IIOP. - * User code does not usually reference this class directly.

- * - * @see RMIServerImpl - * - * @since 1.5 - * @deprecated This transport is no longer supported. - */ -@Deprecated -public class RMIIIOPServerImpl extends RMIServerImpl { - /** - * Throws {@linkplain UnsupportedOperationException} - * - * @param env the environment containing attributes for the new - * RMIServerImpl. Can be null, which is equivalent - * to an empty Map. - * - * @throws IOException if the RMI object cannot be created. - */ - public RMIIIOPServerImpl(Map env) - throws IOException { - super(env); - - throw new UnsupportedOperationException(); - } - - @Override - protected void export() throws IOException { - throw new UnsupportedOperationException("Method not supported. JMX RMI-IIOP is deprecated"); - } - - @Override - protected String getProtocol() { - return "iiop"; - } - - @Override - public Remote toStub() throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - protected RMIConnection makeClient(String connectionId, Subject subject) - throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - protected void closeClient(RMIConnection client) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - protected void closeServer() throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - RMIConnection doNewClient(final Object credentials) throws IOException { - throw new UnsupportedOperationException(); - } -} From 1964954da9ac1d020e0b5ba35893f475d86ec909 Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Wed, 10 May 2023 17:26:02 +0000 Subject: [PATCH 005/502] 8307194: Add make target for optionally building a complete set of all JDK and hotspot libjvm static libraries Reviewed-by: erikj, sgehwolf --- make/GraalBuilderImage.gmk | 4 +- make/Main.gmk | 28 +++++- make/StaticLibsImage.gmk | 28 +++++- make/autoconf/spec.gmk.in | 4 + make/common/NativeCompilation.gmk | 86 +++++++++++-------- make/hotspot/lib/CompileJvm.gmk | 8 ++ make/modules/java.base/lib/CoreLibraries.gmk | 19 ++-- .../java.desktop/lib/Awt2dLibraries.gmk | 18 ++++ 8 files changed, 144 insertions(+), 51 deletions(-) diff --git a/make/GraalBuilderImage.gmk b/make/GraalBuilderImage.gmk index 19c84c3118118..8c4d66aa9d5c7 100644 --- a/make/GraalBuilderImage.gmk +++ b/make/GraalBuilderImage.gmk @@ -43,10 +43,10 @@ $(eval $(call SetupCopyFiles, COPY_JDK_IMG, \ TARGETS += $(COPY_JDK_IMG) $(eval $(call SetupCopyFiles, COPY_STATIC_LIBS, \ - SRC := $(STATIC_LIBS_IMAGE_DIR)/lib, \ + SRC := $(STATIC_LIBS_GRAAL_IMAGE_DIR)/lib, \ DEST := $(GRAAL_BUILDER_IMAGE_DIR)/lib, \ FILES := $(filter %$(STATIC_LIBRARY_SUFFIX), \ - $(call FindFiles, $(STATIC_LIBS_IMAGE_DIR)/lib)), \ + $(call FindFiles, $(STATIC_LIBS_GRAAL_IMAGE_DIR)/lib)), \ )) TARGETS += $(COPY_STATIC_LIBS) diff --git a/make/Main.gmk b/make/Main.gmk index 5f647c963b078..e13e6f47386ba 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -233,6 +233,7 @@ ALL_TARGETS += $(LAUNCHER_TARGETS) HOTSPOT_VARIANT_TARGETS := $(addprefix hotspot-, $(JVM_VARIANTS)) HOTSPOT_VARIANT_GENSRC_TARGETS := $(addsuffix -gensrc, $(HOTSPOT_VARIANT_TARGETS)) HOTSPOT_VARIANT_LIBS_TARGETS := $(addsuffix -libs, $(HOTSPOT_VARIANT_TARGETS)) +HOTSPOT_VARIANT_STATIC_LIBS_TARGETS := $(addsuffix -static-libs, $(HOTSPOT_VARIANT_TARGETS)) define DeclareHotspotGensrcRecipe hotspot-$1-gensrc: @@ -251,6 +252,14 @@ endef $(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotLibsRecipe,$v))) +define DeclareHotspotStaticLibsRecipe + hotspot-$1-static-libs: + +($(CD) $(TOPDIR)/make/hotspot && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibraries.gmk \ + JVM_VARIANT=$1 STATIC_LIBS=true) +endef + +$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotStaticLibsRecipe,$v))) + $(eval $(call SetupTarget, hotspot-ide-project, \ MAKEFILE := ide/visualstudio/hotspot/CreateVSProject, \ DEPS := hotspot exploded-image, \ @@ -298,7 +307,7 @@ $(eval $(call SetupTarget, eclipse-shared-mixed-env, \ )) ALL_TARGETS += $(HOTSPOT_VARIANT_TARGETS) $(HOTSPOT_VARIANT_GENSRC_TARGETS) \ - $(HOTSPOT_VARIANT_LIBS_TARGETS) + $(HOTSPOT_VARIANT_LIBS_TARGETS) $(HOTSPOT_VARIANT_STATIC_LIBS_TARGETS) ################################################################################ # Help and user support @@ -462,6 +471,12 @@ $(eval $(call SetupTarget, symbols-image, \ $(eval $(call SetupTarget, static-libs-image, \ MAKEFILE := StaticLibsImage, \ + TARGET := static-libs-image, \ +)) + +$(eval $(call SetupTarget, static-libs-graal-image, \ + MAKEFILE := StaticLibsImage, \ + TARGET := static-libs-graal-image, \ )) $(eval $(call SetupTarget, mac-jdk-bundle, \ @@ -489,7 +504,7 @@ $(eval $(call SetupTarget, exploded-image-optimize, \ $(eval $(call SetupTarget, graal-builder-image, \ MAKEFILE := GraalBuilderImage, \ - DEPS := jdk-image static-libs-image, \ + DEPS := jdk-image static-libs-graal-image, \ )) ifeq ($(JCOV_ENABLED), true) @@ -889,6 +904,7 @@ else $(foreach v, $(JVM_VARIANTS), \ $(eval hotspot-$v-gensrc: java.base-copy buildtools-hotspot) \ $(eval hotspot-$v-libs: hotspot-$v-gensrc java.base-copy) \ + $(eval hotspot-$v-static-libs: hotspot-$v-gensrc java.base-copy) \ ) # If not already set, set the JVM variant target so that the JVM will be built. @@ -1047,7 +1063,9 @@ else symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS) - static-libs-image: $(STATIC_LIBS_TARGETS) + static-libs-image: hotspot-static-libs $(STATIC_LIBS_TARGETS) + + static-libs-graal-image: $(STATIC_LIBS_TARGETS) bootcycle-images: jdk-image @@ -1097,6 +1115,7 @@ hotspot: $(HOTSPOT_VARIANT_TARGETS) $(foreach v, $(JVM_VARIANTS), \ $(eval hotspot-libs: hotspot-$v-libs) \ $(eval hotspot-gensrc: hotspot-$v-gensrc) \ + $(eval hotspot-static-libs: hotspot-$v-static-libs) \ ) gensrc: $(GENSRC_TARGETS) @@ -1259,7 +1278,8 @@ all-images: product-images test-image all-docs-images # all-bundles packages all our deliverables as tar.gz bundles. all-bundles: product-bundles test-bundles docs-bundles static-libs-bundles -ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-gensrc gensrc gendata \ +ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-static-libs \ + hotspot-gensrc gensrc gendata \ copy java libs static-libs launchers jmods \ jdk.jdwp.agent-gensrc $(ALL_MODULES) demos \ exploded-image-base exploded-image runnable-buildjdk \ diff --git a/make/StaticLibsImage.gmk b/make/StaticLibsImage.gmk index 21c4608f4dd6a..44a4ba5678242 100644 --- a/make/StaticLibsImage.gmk +++ b/make/StaticLibsImage.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2019, 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 @@ -38,19 +38,43 @@ ALL_MODULES = $(call FindAllModules) TARGETS := +ifneq ($(filter static-libs-image, $(MAKECMDGOALS)), ) + IMAGE_DEST_DIR=$(STATIC_LIBS_IMAGE_DIR)/lib +else ifneq ($(filter static-libs-graal-image, $(MAKECMDGOALS)), ) + IMAGE_DEST_DIR=$(STATIC_LIBS_GRAAL_IMAGE_DIR)/lib +endif + +# Copy JDK static libs to the image. $(foreach m, $(ALL_MODULES), \ $(eval $(call SetupCopyFiles, COPY_STATIC_LIBS_$m, \ FLATTEN := true, \ SRC := $(SUPPORT_OUTPUTDIR)/native/$m, \ - DEST := $(STATIC_LIBS_IMAGE_DIR)/lib, \ + DEST := $(IMAGE_DEST_DIR), \ FILES := $(filter %$(STATIC_LIBRARY_SUFFIX), \ $(call FindFiles, $(SUPPORT_OUTPUTDIR)/native/$m/*/static)), \ )) \ $(eval TARGETS += $$(COPY_STATIC_LIBS_$m)) \ + $(eval STATIC_LIBS_TARGETS += $$(COPY_STATIC_LIBS_$m)) \ ) +ifneq ($(filter static-libs-image, $(MAKECMDGOALS)), ) + # Copy libjvm static library to the image. + $(foreach v, $(JVM_VARIANTS), \ + $(eval $(call SetupCopyFiles, COPY_STATIC_LIBS_$v, \ + SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/objs/static, \ + DEST := $(IMAGE_DEST_DIR)/$v, \ + FILES := $(wildcard $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/objs/static/*$(STATIC_LIBRARY_SUFFIX)), \ + )) \ + $(eval TARGETS += $$(COPY_STATIC_LIBS_$v)) \ + $(eval HOTSPOT_VARIANT_STATIC_LIBS_TARGETS += $$(COPY_STATIC_LIBS_$v)) \ + ) +endif + ################################################################################ +static-libs-image: $(HOTSPOT_VARIANT_STATIC_LIBS_TARGETS) $(STATIC_LIBS_TARGETS) +static-libs-graal-image: $(STATIC_LIBS_TARGETS) + all: $(TARGETS) .PHONY: all diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index 0f85917814e69..35f45e57df58d 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -928,6 +928,10 @@ DOCS_OUTPUTDIR := $(DOCS_JDK_IMAGE_DIR) STATIC_LIBS_IMAGE_SUBDIR := static-libs STATIC_LIBS_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(STATIC_LIBS_IMAGE_SUBDIR) +# Graal static libs image +STATIC_LIBS_GRAAL_IMAGE_SUBDIR := static-libs-graal +STATIC_LIBS_GRAAL_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(STATIC_LIBS_GRAAL_IMAGE_SUBDIR) + # Graal builder image GRAAL_BUILDER_IMAGE_SUBDIR := graal-builder-jdk GRAAL_BUILDER_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(GRAAL_BUILDER_IMAGE_SUBDIR) diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index 0d7ab6a7ef339..5eba6d08d6a07 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -548,6 +548,7 @@ endef # PRECOMPILED_HEADER Header file to use as precompiled header # PRECOMPILED_HEADER_EXCLUDE List of source files that should not use PCH # BUILD_INFO_LOG_MACRO Overrides log level of the build info log message, default LogWarn +# STATIC_LIB_EXCLUDE_OBJS exclude objects that matches from static library # # After being called, some variables are exported from this macro, all prefixed # with parameter 1 followed by a '_': @@ -726,6 +727,12 @@ define SetupNativeCompilationBody endif # Sort to remove duplicates and provide a reproducible order on the input files to the linker. $1_ALL_OBJS := $$(sort $$($1_EXPECTED_OBJS) $$($1_EXTRA_OBJECT_FILES)) + ifeq ($(STATIC_LIBS), true) + # Exclude the object files that match with $1_STATIC_LIB_EXCLUDE_OBJS. + ifneq ($$($1_STATIC_LIB_EXCLUDE_OBJS), ) + $1_ALL_OBJS := $$(call not-containing, $$($1_STATIC_LIB_EXCLUDE_OBJS), $$($1_ALL_OBJS)) + endif + endif # Pickup extra OPENJDK_TARGET_OS_TYPE, OPENJDK_TARGET_OS, TOOLCHAIN_TYPE and # OPENJDK_TARGET_OS plus OPENJDK_TARGET_CPU pair dependent variables for CFLAGS. @@ -1130,6 +1137,40 @@ define SetupNativeCompilationBody endif endif + $1_LD_OBJ_ARG := $$($1_ALL_OBJS) + + # If there are many object files, use an @-file... + ifneq ($$(word 17, $$($1_ALL_OBJS)), ) + $1_OBJ_FILE_LIST := $$($1_OBJECT_DIR)/_$1_objectfilenames.txt + ifneq ($(COMPILER_COMMAND_FILE_FLAG), ) + $1_LD_OBJ_ARG := $(COMPILER_COMMAND_FILE_FLAG)$$($1_OBJ_FILE_LIST) + else + # ...except for toolchains which don't support them. + $1_LD_OBJ_ARG := `cat $$($1_OBJ_FILE_LIST)` + endif + endif + + # Unfortunately the @-file trick does not work reliably when using clang. + # Clang does not propagate the @-file parameter to the ld sub process, but + # instead puts the full content on the command line. At least the llvm ld + # does not even support an @-file. + # + # When linking a large amount of object files, we risk hitting the limit + # of the command line length even on posix systems if the path length of + # the output dir is very long due to our use of absolute paths. To + # mitigate this, use paths relative to the output dir when linking over + # 500 files with clang and the output dir path is deep. + ifneq ($$(word 500, $$($1_ALL_OBJS)), ) + ifeq ($$(TOOLCHAIN_TYPE), clang) + # There is no strlen function in make, but checking path depth is a + # reasonable approximation. + ifneq ($$(word 10, $$(subst /, ,$$(OUTPUTDIR))), ) + $1_LINK_OBJS_RELATIVE := true + $1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS)) + endif + endif + endif + ifeq ($$($1_TYPE), STATIC_LIBRARY) $1_VARDEPS := $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) $$($1_LIBS) \ $$($1_EXTRA_LIBS) @@ -1146,10 +1187,17 @@ define SetupNativeCompilationBody $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP) $$($1_TARGET): $$($1_TARGET_DEPS) + ifneq ($$($1_OBJ_FILE_LIST), ) + ifeq ($$($1_LINK_OBJS_RELATIVE), true) + $$(eval $$(call ListPathsSafely, $1_ALL_OBJS_RELATIVE, $$($1_OBJ_FILE_LIST))) + else + $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST))) + endif + endif $$(call LogInfo, Building static library $$($1_BASENAME)) $$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR)) $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ - $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \ + $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) \ $$($1_RES)) ifeq ($(STATIC_BUILD), true) ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true) @@ -1201,40 +1249,6 @@ define SetupNativeCompilationBody $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) - $1_LD_OBJ_ARG := $$($1_ALL_OBJS) - - # If there are many object files, use an @-file... - ifneq ($$(word 17, $$($1_ALL_OBJS)), ) - $1_OBJ_FILE_LIST := $$($1_OBJECT_DIR)/_$1_objectfilenames.txt - ifneq ($(COMPILER_COMMAND_FILE_FLAG), ) - $1_LD_OBJ_ARG := $(COMPILER_COMMAND_FILE_FLAG)$$($1_OBJ_FILE_LIST) - else - # ...except for toolchains which don't support them. - $1_LD_OBJ_ARG := `cat $$($1_OBJ_FILE_LIST)` - endif - endif - - # Unfortunately the @-file trick does not work reliably when using clang. - # Clang does not propagate the @-file parameter to the ld sub process, but - # instead puts the full content on the command line. At least the llvm ld - # does not even support an @-file. - # - # When linking a large amount of object files, we risk hitting the limit - # of the command line length even on posix systems if the path length of - # the output dir is very long due to our use of absolute paths. To - # mitigate this, use paths relative to the output dir when linking over - # 500 files with clang and the output dir path is deep. - ifneq ($$(word 500, $$($1_ALL_OBJS)), ) - ifeq ($$(TOOLCHAIN_TYPE), clang) - # There is no strlen function in make, but checking path depth is a - # reasonable approximation. - ifneq ($$(word 10, $$(subst /, ,$$(OUTPUTDIR))), ) - $1_LINK_OBJS_RELATIVE := true - $1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS)) - endif - endif - endif - $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \ $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE) diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index e73d8702c28a2..f0abfc2524886 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -139,6 +139,13 @@ JVM_STRIPFLAGS ?= $(STRIPFLAGS) # This source set is reused so save in cache. $(call FillFindCache, $(JVM_SRC_DIRS)) +# The global operator new functions defined in operator_new.cpp are intended +# to detect and prevent the VM code from calling them. See more details in +# operator_new.cpp. Exclude operator_new.o when statically linking the VM +# code with JDK natives, as the JDK natives might need to call the global +# operator new. +LIBJVM_STATIC_EXCLUDE_OBJS := operator_new.o + ################################################################################ # Now set up the actual compilation of the main hotspot native library @@ -186,6 +193,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \ RC_FILEDESC := $(HOTSPOT_VM_DISTRO) $(OPENJDK_TARGET_CPU_BITS)-Bit $(JVM_VARIANT) VM, \ PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \ PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \ + STATIC_LIB_EXCLUDE_OBJS := $(LIBJVM_STATIC_EXCLUDE_OBJS), \ )) # Always recompile abstract_vm_version.cpp if libjvm needs to be relinked. This ensures diff --git a/make/modules/java.base/lib/CoreLibraries.gmk b/make/modules/java.base/lib/CoreLibraries.gmk index 25b35d1d7ff87..03ef2d2c6b5a8 100644 --- a/make/modules/java.base/lib/CoreLibraries.gmk +++ b/make/modules/java.base/lib/CoreLibraries.gmk @@ -153,15 +153,19 @@ endif LIBJLI_CFLAGS += $(LIBZ_CFLAGS) ifneq ($(USE_EXTERNAL_LIBZ), true) + # Extra files from the zlib. + LIBJLI_EXTRA_FILE_LIST := inflate.c inftrees.c inffast.c zadler32.c zcrc32.c zutil.c + LIBJLI_EXTRA_FILES += \ $(addprefix $(TOPDIR)/src/java.base/share/native/libzip/zlib/, \ - inflate.c \ - inftrees.c \ - inffast.c \ - zadler32.c \ - zcrc32.c \ - zutil.c \ - ) + $(LIBJLI_EXTRA_FILE_LIST)) + + # Do not include these libz objects in the static libjli library. + # When statically linking the java launcher with all JDK and VM + # static libraries, we use the --whole-archive linker option. + # The duplicate objects in different static libraries cause linking + # errors due to duplicate symbols. + LIBJLI_STATIC_EXCLUDE_OBJS := $(subst .c,$(OBJ_SUFFIX),$(LIBJLI_EXTRA_FILE_LIST)) endif $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \ @@ -180,6 +184,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \ LIBS_aix := $(LIBDL),\ LIBS_macosx := -framework Cocoa -framework Security -framework ApplicationServices, \ LIBS_windows := advapi32.lib comctl32.lib user32.lib, \ + STATIC_LIB_EXCLUDE_OBJS := $(LIBJLI_STATIC_EXCLUDE_OBJS), \ )) TARGETS += $(BUILD_LIBJLI) diff --git a/make/modules/java.desktop/lib/Awt2dLibraries.gmk b/make/modules/java.desktop/lib/Awt2dLibraries.gmk index c3b756423fdc4..fb004ee9b7410 100644 --- a/make/modules/java.desktop/lib/Awt2dLibraries.gmk +++ b/make/modules/java.desktop/lib/Awt2dLibraries.gmk @@ -218,6 +218,14 @@ ifeq ($(call isTargetOs, windows macosx), false) LIBAWT_XAWT_LIBS += -lpthread endif + # These are the object files provided by the awt native + # library. Do not include these external (non-awt_xawt library) + # objects in the static library. When statically linking the java + # launcher with all JDK and VM static libraries, we use the + # --whole-archive linker option. The duplicate objects in different + # static libraries cause linking errors due to duplicate symbols. + LIBAWT_XAWT_STATIC_EXCLUDE_OBJS := systemScale.o + $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_XAWT, \ NAME := awt_xawt, \ EXTRA_SRC := $(LIBAWT_XAWT_EXTRA_SRC), \ @@ -244,6 +252,7 @@ ifeq ($(call isTargetOs, windows macosx), false) $(call SET_SHARED_LIBRARY_ORIGIN) \ -L$(INSTALL_LIBRARIES_HERE), \ LIBS := $(X_LIBS) $(LIBAWT_XAWT_LIBS), \ + STATIC_LIB_EXCLUDE_OBJS := $(LIBAWT_XAWT_STATIC_EXCLUDE_OBJS), \ )) $(BUILD_LIBAWT_XAWT): $(call FindLib, java.base, java) @@ -367,6 +376,14 @@ ifeq ($(call isTargetOs, windows macosx), false) LIBAWT_HEADLESS_CFLAGS := $(CUPS_CFLAGS) $(FONTCONFIG_CFLAGS) $(X_CFLAGS) \ -DHEADLESS=true + # These are the object files provided by the awt native + # library. Do not include these external (non-awt_headless library) + # objects in the static library. When statically linking the java + # launcher with all JDK and VM static libraries, we use the + # --whole-archive linker option. The duplicate objects in different + # static libraries cause linking errors due to duplicate symbols. + LIBAWT_HEADLESS_STATIC_EXCLUDE_OBJS := systemScale.o + $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_HEADLESS, \ NAME := awt_headless, \ EXTRA_SRC := $(LIBAWT_HEADLESS_EXTRA_SRC), \ @@ -382,6 +399,7 @@ ifeq ($(call isTargetOs, windows macosx), false) LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \ LIBS_unix := -lawt -ljvm -ljava, \ LIBS_linux := $(LIBM) $(LIBDL), \ + STATIC_LIB_EXCLUDE_OBJS := $(LIBAWT_HEADLESS_STATIC_EXCLUDE_OBJS), \ )) $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT) From 268836482d0688bd1952bf634ceee4463dfca66f Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Wed, 10 May 2023 19:09:24 +0000 Subject: [PATCH 006/502] 8306758: com/sun/jdi/ConnectedVMs.java fails with "Non-zero debuggee exitValue: 143" Reviewed-by: amenkov, sspitsyn --- test/jdk/com/sun/jdi/ConnectedVMs.java | 28 ++++++++++++++++++++++---- test/jdk/com/sun/jdi/InstTarg.java | 12 ++++++++++- test/jdk/com/sun/jdi/TestScaffold.java | 15 +++++++++----- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/test/jdk/com/sun/jdi/ConnectedVMs.java b/test/jdk/com/sun/jdi/ConnectedVMs.java index 9bf0267c0cd67..0b3ac6a1e71cc 100644 --- a/test/jdk/com/sun/jdi/ConnectedVMs.java +++ b/test/jdk/com/sun/jdi/ConnectedVMs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,6 +28,7 @@ * VirtualMachineManager.connectedVirtualMachines() * @author Robert Field * + * @library /test/lib * @run build TestScaffold VMConnection TargetListener TargetAdapter * @run compile -g InstTarg.java * @run driver ConnectedVMs Kill @@ -40,6 +41,8 @@ import com.sun.jdi.request.*; import java.util.List; +import jdk.test.lib.Platform; + public class ConnectedVMs extends TestScaffold { static int failCount = 0;; static String passName; @@ -62,6 +65,23 @@ public static void main(String args[]) throws Exception { System.out.println("create " + passName); } + @Override + protected boolean allowedExitValue(int exitValue) { + if (passName.equals("Kill")) { + // 143 is SIGTERM, which we expect to get when doing a Process.destroy(), + // unless we are on Windows, which will exit with a 1. + if (!Platform.isWindows()) { + return exitValue == 143; + } else { + return exitValue == 1; + } + } else if (passName.equals("exit()")) { + // This version of the test does an exit(1), so that's what we expect. + return exitValue == 1; + } + return super.allowedExitValue(exitValue); + } + void vms(int expected) { List vms = Bootstrap.virtualMachineManager(). connectedVirtualMachines(); @@ -76,9 +96,9 @@ void vms(int expected) { protected void runTests() throws Exception { System.out.println("Testing " + passName); vms(0); - startToMain("InstTarg"); - ThreadReference thread = waitForVMStart(); - StepEvent stepEvent = stepIntoLine(thread); + BreakpointEvent bp = startToMain("InstTarg"); + waitForVMStart(); + StepEvent stepEvent = stepIntoLine(bp.thread()); vms(1); // pick a way to die based on the input arg. diff --git a/test/jdk/com/sun/jdi/InstTarg.java b/test/jdk/com/sun/jdi/InstTarg.java index cd13579d19ecb..c75f5540e7f8b 100644 --- a/test/jdk/com/sun/jdi/InstTarg.java +++ b/test/jdk/com/sun/jdi/InstTarg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -29,6 +29,16 @@ public class InstTarg { public static void main(String args[]) { start(); + // Sleep before exiting to allow disconnect efforts done on the JDI side to complete. + // Note that not sleeping long enough is for the most part harmless, but might render + // the testing insufficient because the debuggee will quickly exit naturally + // once the debuggee does the vm.resume(), rather than waiting for disconnect + // efforts to complete first. + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } } static void start() { diff --git a/test/jdk/com/sun/jdi/TestScaffold.java b/test/jdk/com/sun/jdi/TestScaffold.java index a39e3ddf8d6e5..251e553b404c3 100644 --- a/test/jdk/com/sun/jdi/TestScaffold.java +++ b/test/jdk/com/sun/jdi/TestScaffold.java @@ -722,6 +722,13 @@ public synchronized ThreadReference waitForVMStart() { return vmStartThread; } + /* + * Tests that expect an exitValue other than 0 or 1 will need to override this method. + */ + protected boolean allowedExitValue(int exitValue) { + return exitValue == 0 || exitValue == 1; + } + public synchronized void waitForVMDisconnect() { traceln("TS: waitForVMDisconnect"); while (!vmDisconnected) { @@ -738,11 +745,9 @@ public synchronized void waitForVMDisconnect() { } catch (InterruptedException e) { throw new RuntimeException(e); } - int res = p.exitValue(); - // Some tests purposefully exit with an exception, which produces exitValue - // 1, so we have to allow it also. - if (res != 0 && res != 1) { - throw new RuntimeException("Non-zero debuggee exitValue: " + res); + int exitValue = p.exitValue(); + if (!allowedExitValue(exitValue)) { + throw new RuntimeException("Invalid debuggee exitValue: " + exitValue); } traceln("TS: waitForVMDisconnect: done"); From df90df298e4183f5328b88ff0af91ba96fb2510d Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Wed, 10 May 2023 19:38:24 +0000 Subject: [PATCH 007/502] 8307857: validate-source fails after JDK-8306758 Reviewed-by: rriggs, cjplummer --- test/jdk/com/sun/jdi/InstTarg.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/com/sun/jdi/InstTarg.java b/test/jdk/com/sun/jdi/InstTarg.java index c75f5540e7f8b..39c3fc4034b85 100644 --- a/test/jdk/com/sun/jdi/InstTarg.java +++ b/test/jdk/com/sun/jdi/InstTarg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 From edc4adb77e755b8076c0ab85acab313384397428 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Wed, 10 May 2023 21:08:28 +0000 Subject: [PATCH 008/502] 8307860: [BACKOUT] JDK-8307194 Add make target for optionally building a complete set of all JDK and hotspot libjvm static libraries Reviewed-by: erikj --- make/GraalBuilderImage.gmk | 4 +- make/Main.gmk | 28 +----- make/StaticLibsImage.gmk | 28 +----- make/autoconf/spec.gmk.in | 4 - make/common/NativeCompilation.gmk | 86 ++++++++----------- make/hotspot/lib/CompileJvm.gmk | 8 -- make/modules/java.base/lib/CoreLibraries.gmk | 19 ++-- .../java.desktop/lib/Awt2dLibraries.gmk | 18 ---- 8 files changed, 51 insertions(+), 144 deletions(-) diff --git a/make/GraalBuilderImage.gmk b/make/GraalBuilderImage.gmk index 8c4d66aa9d5c7..19c84c3118118 100644 --- a/make/GraalBuilderImage.gmk +++ b/make/GraalBuilderImage.gmk @@ -43,10 +43,10 @@ $(eval $(call SetupCopyFiles, COPY_JDK_IMG, \ TARGETS += $(COPY_JDK_IMG) $(eval $(call SetupCopyFiles, COPY_STATIC_LIBS, \ - SRC := $(STATIC_LIBS_GRAAL_IMAGE_DIR)/lib, \ + SRC := $(STATIC_LIBS_IMAGE_DIR)/lib, \ DEST := $(GRAAL_BUILDER_IMAGE_DIR)/lib, \ FILES := $(filter %$(STATIC_LIBRARY_SUFFIX), \ - $(call FindFiles, $(STATIC_LIBS_GRAAL_IMAGE_DIR)/lib)), \ + $(call FindFiles, $(STATIC_LIBS_IMAGE_DIR)/lib)), \ )) TARGETS += $(COPY_STATIC_LIBS) diff --git a/make/Main.gmk b/make/Main.gmk index e13e6f47386ba..5f647c963b078 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -233,7 +233,6 @@ ALL_TARGETS += $(LAUNCHER_TARGETS) HOTSPOT_VARIANT_TARGETS := $(addprefix hotspot-, $(JVM_VARIANTS)) HOTSPOT_VARIANT_GENSRC_TARGETS := $(addsuffix -gensrc, $(HOTSPOT_VARIANT_TARGETS)) HOTSPOT_VARIANT_LIBS_TARGETS := $(addsuffix -libs, $(HOTSPOT_VARIANT_TARGETS)) -HOTSPOT_VARIANT_STATIC_LIBS_TARGETS := $(addsuffix -static-libs, $(HOTSPOT_VARIANT_TARGETS)) define DeclareHotspotGensrcRecipe hotspot-$1-gensrc: @@ -252,14 +251,6 @@ endef $(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotLibsRecipe,$v))) -define DeclareHotspotStaticLibsRecipe - hotspot-$1-static-libs: - +($(CD) $(TOPDIR)/make/hotspot && $(MAKE) $(MAKE_ARGS) -f lib/CompileLibraries.gmk \ - JVM_VARIANT=$1 STATIC_LIBS=true) -endef - -$(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotStaticLibsRecipe,$v))) - $(eval $(call SetupTarget, hotspot-ide-project, \ MAKEFILE := ide/visualstudio/hotspot/CreateVSProject, \ DEPS := hotspot exploded-image, \ @@ -307,7 +298,7 @@ $(eval $(call SetupTarget, eclipse-shared-mixed-env, \ )) ALL_TARGETS += $(HOTSPOT_VARIANT_TARGETS) $(HOTSPOT_VARIANT_GENSRC_TARGETS) \ - $(HOTSPOT_VARIANT_LIBS_TARGETS) $(HOTSPOT_VARIANT_STATIC_LIBS_TARGETS) + $(HOTSPOT_VARIANT_LIBS_TARGETS) ################################################################################ # Help and user support @@ -471,12 +462,6 @@ $(eval $(call SetupTarget, symbols-image, \ $(eval $(call SetupTarget, static-libs-image, \ MAKEFILE := StaticLibsImage, \ - TARGET := static-libs-image, \ -)) - -$(eval $(call SetupTarget, static-libs-graal-image, \ - MAKEFILE := StaticLibsImage, \ - TARGET := static-libs-graal-image, \ )) $(eval $(call SetupTarget, mac-jdk-bundle, \ @@ -504,7 +489,7 @@ $(eval $(call SetupTarget, exploded-image-optimize, \ $(eval $(call SetupTarget, graal-builder-image, \ MAKEFILE := GraalBuilderImage, \ - DEPS := jdk-image static-libs-graal-image, \ + DEPS := jdk-image static-libs-image, \ )) ifeq ($(JCOV_ENABLED), true) @@ -904,7 +889,6 @@ else $(foreach v, $(JVM_VARIANTS), \ $(eval hotspot-$v-gensrc: java.base-copy buildtools-hotspot) \ $(eval hotspot-$v-libs: hotspot-$v-gensrc java.base-copy) \ - $(eval hotspot-$v-static-libs: hotspot-$v-gensrc java.base-copy) \ ) # If not already set, set the JVM variant target so that the JVM will be built. @@ -1063,9 +1047,7 @@ else symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS) - static-libs-image: hotspot-static-libs $(STATIC_LIBS_TARGETS) - - static-libs-graal-image: $(STATIC_LIBS_TARGETS) + static-libs-image: $(STATIC_LIBS_TARGETS) bootcycle-images: jdk-image @@ -1115,7 +1097,6 @@ hotspot: $(HOTSPOT_VARIANT_TARGETS) $(foreach v, $(JVM_VARIANTS), \ $(eval hotspot-libs: hotspot-$v-libs) \ $(eval hotspot-gensrc: hotspot-$v-gensrc) \ - $(eval hotspot-static-libs: hotspot-$v-static-libs) \ ) gensrc: $(GENSRC_TARGETS) @@ -1278,8 +1259,7 @@ all-images: product-images test-image all-docs-images # all-bundles packages all our deliverables as tar.gz bundles. all-bundles: product-bundles test-bundles docs-bundles static-libs-bundles -ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-static-libs \ - hotspot-gensrc gensrc gendata \ +ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-gensrc gensrc gendata \ copy java libs static-libs launchers jmods \ jdk.jdwp.agent-gensrc $(ALL_MODULES) demos \ exploded-image-base exploded-image runnable-buildjdk \ diff --git a/make/StaticLibsImage.gmk b/make/StaticLibsImage.gmk index 44a4ba5678242..21c4608f4dd6a 100644 --- a/make/StaticLibsImage.gmk +++ b/make/StaticLibsImage.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2019, 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 @@ -38,43 +38,19 @@ ALL_MODULES = $(call FindAllModules) TARGETS := -ifneq ($(filter static-libs-image, $(MAKECMDGOALS)), ) - IMAGE_DEST_DIR=$(STATIC_LIBS_IMAGE_DIR)/lib -else ifneq ($(filter static-libs-graal-image, $(MAKECMDGOALS)), ) - IMAGE_DEST_DIR=$(STATIC_LIBS_GRAAL_IMAGE_DIR)/lib -endif - -# Copy JDK static libs to the image. $(foreach m, $(ALL_MODULES), \ $(eval $(call SetupCopyFiles, COPY_STATIC_LIBS_$m, \ FLATTEN := true, \ SRC := $(SUPPORT_OUTPUTDIR)/native/$m, \ - DEST := $(IMAGE_DEST_DIR), \ + DEST := $(STATIC_LIBS_IMAGE_DIR)/lib, \ FILES := $(filter %$(STATIC_LIBRARY_SUFFIX), \ $(call FindFiles, $(SUPPORT_OUTPUTDIR)/native/$m/*/static)), \ )) \ $(eval TARGETS += $$(COPY_STATIC_LIBS_$m)) \ - $(eval STATIC_LIBS_TARGETS += $$(COPY_STATIC_LIBS_$m)) \ ) -ifneq ($(filter static-libs-image, $(MAKECMDGOALS)), ) - # Copy libjvm static library to the image. - $(foreach v, $(JVM_VARIANTS), \ - $(eval $(call SetupCopyFiles, COPY_STATIC_LIBS_$v, \ - SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/objs/static, \ - DEST := $(IMAGE_DEST_DIR)/$v, \ - FILES := $(wildcard $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/objs/static/*$(STATIC_LIBRARY_SUFFIX)), \ - )) \ - $(eval TARGETS += $$(COPY_STATIC_LIBS_$v)) \ - $(eval HOTSPOT_VARIANT_STATIC_LIBS_TARGETS += $$(COPY_STATIC_LIBS_$v)) \ - ) -endif - ################################################################################ -static-libs-image: $(HOTSPOT_VARIANT_STATIC_LIBS_TARGETS) $(STATIC_LIBS_TARGETS) -static-libs-graal-image: $(STATIC_LIBS_TARGETS) - all: $(TARGETS) .PHONY: all diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index 35f45e57df58d..0f85917814e69 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -928,10 +928,6 @@ DOCS_OUTPUTDIR := $(DOCS_JDK_IMAGE_DIR) STATIC_LIBS_IMAGE_SUBDIR := static-libs STATIC_LIBS_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(STATIC_LIBS_IMAGE_SUBDIR) -# Graal static libs image -STATIC_LIBS_GRAAL_IMAGE_SUBDIR := static-libs-graal -STATIC_LIBS_GRAAL_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(STATIC_LIBS_GRAAL_IMAGE_SUBDIR) - # Graal builder image GRAAL_BUILDER_IMAGE_SUBDIR := graal-builder-jdk GRAAL_BUILDER_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(GRAAL_BUILDER_IMAGE_SUBDIR) diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index 5eba6d08d6a07..0d7ab6a7ef339 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2022, 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 @@ -548,7 +548,6 @@ endef # PRECOMPILED_HEADER Header file to use as precompiled header # PRECOMPILED_HEADER_EXCLUDE List of source files that should not use PCH # BUILD_INFO_LOG_MACRO Overrides log level of the build info log message, default LogWarn -# STATIC_LIB_EXCLUDE_OBJS exclude objects that matches from static library # # After being called, some variables are exported from this macro, all prefixed # with parameter 1 followed by a '_': @@ -727,12 +726,6 @@ define SetupNativeCompilationBody endif # Sort to remove duplicates and provide a reproducible order on the input files to the linker. $1_ALL_OBJS := $$(sort $$($1_EXPECTED_OBJS) $$($1_EXTRA_OBJECT_FILES)) - ifeq ($(STATIC_LIBS), true) - # Exclude the object files that match with $1_STATIC_LIB_EXCLUDE_OBJS. - ifneq ($$($1_STATIC_LIB_EXCLUDE_OBJS), ) - $1_ALL_OBJS := $$(call not-containing, $$($1_STATIC_LIB_EXCLUDE_OBJS), $$($1_ALL_OBJS)) - endif - endif # Pickup extra OPENJDK_TARGET_OS_TYPE, OPENJDK_TARGET_OS, TOOLCHAIN_TYPE and # OPENJDK_TARGET_OS plus OPENJDK_TARGET_CPU pair dependent variables for CFLAGS. @@ -1137,40 +1130,6 @@ define SetupNativeCompilationBody endif endif - $1_LD_OBJ_ARG := $$($1_ALL_OBJS) - - # If there are many object files, use an @-file... - ifneq ($$(word 17, $$($1_ALL_OBJS)), ) - $1_OBJ_FILE_LIST := $$($1_OBJECT_DIR)/_$1_objectfilenames.txt - ifneq ($(COMPILER_COMMAND_FILE_FLAG), ) - $1_LD_OBJ_ARG := $(COMPILER_COMMAND_FILE_FLAG)$$($1_OBJ_FILE_LIST) - else - # ...except for toolchains which don't support them. - $1_LD_OBJ_ARG := `cat $$($1_OBJ_FILE_LIST)` - endif - endif - - # Unfortunately the @-file trick does not work reliably when using clang. - # Clang does not propagate the @-file parameter to the ld sub process, but - # instead puts the full content on the command line. At least the llvm ld - # does not even support an @-file. - # - # When linking a large amount of object files, we risk hitting the limit - # of the command line length even on posix systems if the path length of - # the output dir is very long due to our use of absolute paths. To - # mitigate this, use paths relative to the output dir when linking over - # 500 files with clang and the output dir path is deep. - ifneq ($$(word 500, $$($1_ALL_OBJS)), ) - ifeq ($$(TOOLCHAIN_TYPE), clang) - # There is no strlen function in make, but checking path depth is a - # reasonable approximation. - ifneq ($$(word 10, $$(subst /, ,$$(OUTPUTDIR))), ) - $1_LINK_OBJS_RELATIVE := true - $1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS)) - endif - endif - endif - ifeq ($$($1_TYPE), STATIC_LIBRARY) $1_VARDEPS := $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) $$($1_LIBS) \ $$($1_EXTRA_LIBS) @@ -1187,17 +1146,10 @@ define SetupNativeCompilationBody $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_VARDEPS_FILE) $$(STATIC_MAPFILE_DEP) $$($1_TARGET): $$($1_TARGET_DEPS) - ifneq ($$($1_OBJ_FILE_LIST), ) - ifeq ($$($1_LINK_OBJS_RELATIVE), true) - $$(eval $$(call ListPathsSafely, $1_ALL_OBJS_RELATIVE, $$($1_OBJ_FILE_LIST))) - else - $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST))) - endif - endif $$(call LogInfo, Building static library $$($1_BASENAME)) $$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR)) $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_link, \ - $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_LD_OBJ_ARG) \ + $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) $(AR_OUT_OPTION)$$($1_TARGET) $$($1_ALL_OBJS) \ $$($1_RES)) ifeq ($(STATIC_BUILD), true) ifeq ($$($1_USE_MAPFILE_FOR_SYMBOLS), true) @@ -1249,6 +1201,40 @@ define SetupNativeCompilationBody $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \ $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps) + $1_LD_OBJ_ARG := $$($1_ALL_OBJS) + + # If there are many object files, use an @-file... + ifneq ($$(word 17, $$($1_ALL_OBJS)), ) + $1_OBJ_FILE_LIST := $$($1_OBJECT_DIR)/_$1_objectfilenames.txt + ifneq ($(COMPILER_COMMAND_FILE_FLAG), ) + $1_LD_OBJ_ARG := $(COMPILER_COMMAND_FILE_FLAG)$$($1_OBJ_FILE_LIST) + else + # ...except for toolchains which don't support them. + $1_LD_OBJ_ARG := `cat $$($1_OBJ_FILE_LIST)` + endif + endif + + # Unfortunately the @-file trick does not work reliably when using clang. + # Clang does not propagate the @-file parameter to the ld sub process, but + # instead puts the full content on the command line. At least the llvm ld + # does not even support an @-file. + # + # When linking a large amount of object files, we risk hitting the limit + # of the command line length even on posix systems if the path length of + # the output dir is very long due to our use of absolute paths. To + # mitigate this, use paths relative to the output dir when linking over + # 500 files with clang and the output dir path is deep. + ifneq ($$(word 500, $$($1_ALL_OBJS)), ) + ifeq ($$(TOOLCHAIN_TYPE), clang) + # There is no strlen function in make, but checking path depth is a + # reasonable approximation. + ifneq ($$(word 10, $$(subst /, ,$$(OUTPUTDIR))), ) + $1_LINK_OBJS_RELATIVE := true + $1_ALL_OBJS_RELATIVE := $$(patsubst $$(OUTPUTDIR)/%, %, $$($1_ALL_OBJS)) + endif + endif + endif + $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \ $$($1_REAL_MAPFILE) $$($1_VARDEPS_FILE) diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index f0abfc2524886..e73d8702c28a2 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -139,13 +139,6 @@ JVM_STRIPFLAGS ?= $(STRIPFLAGS) # This source set is reused so save in cache. $(call FillFindCache, $(JVM_SRC_DIRS)) -# The global operator new functions defined in operator_new.cpp are intended -# to detect and prevent the VM code from calling them. See more details in -# operator_new.cpp. Exclude operator_new.o when statically linking the VM -# code with JDK natives, as the JDK natives might need to call the global -# operator new. -LIBJVM_STATIC_EXCLUDE_OBJS := operator_new.o - ################################################################################ # Now set up the actual compilation of the main hotspot native library @@ -193,7 +186,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \ RC_FILEDESC := $(HOTSPOT_VM_DISTRO) $(OPENJDK_TARGET_CPU_BITS)-Bit $(JVM_VARIANT) VM, \ PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \ PRECOMPILED_HEADER_EXCLUDE := $(JVM_PRECOMPILED_HEADER_EXCLUDE), \ - STATIC_LIB_EXCLUDE_OBJS := $(LIBJVM_STATIC_EXCLUDE_OBJS), \ )) # Always recompile abstract_vm_version.cpp if libjvm needs to be relinked. This ensures diff --git a/make/modules/java.base/lib/CoreLibraries.gmk b/make/modules/java.base/lib/CoreLibraries.gmk index 03ef2d2c6b5a8..25b35d1d7ff87 100644 --- a/make/modules/java.base/lib/CoreLibraries.gmk +++ b/make/modules/java.base/lib/CoreLibraries.gmk @@ -153,19 +153,15 @@ endif LIBJLI_CFLAGS += $(LIBZ_CFLAGS) ifneq ($(USE_EXTERNAL_LIBZ), true) - # Extra files from the zlib. - LIBJLI_EXTRA_FILE_LIST := inflate.c inftrees.c inffast.c zadler32.c zcrc32.c zutil.c - LIBJLI_EXTRA_FILES += \ $(addprefix $(TOPDIR)/src/java.base/share/native/libzip/zlib/, \ - $(LIBJLI_EXTRA_FILE_LIST)) - - # Do not include these libz objects in the static libjli library. - # When statically linking the java launcher with all JDK and VM - # static libraries, we use the --whole-archive linker option. - # The duplicate objects in different static libraries cause linking - # errors due to duplicate symbols. - LIBJLI_STATIC_EXCLUDE_OBJS := $(subst .c,$(OBJ_SUFFIX),$(LIBJLI_EXTRA_FILE_LIST)) + inflate.c \ + inftrees.c \ + inffast.c \ + zadler32.c \ + zcrc32.c \ + zutil.c \ + ) endif $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \ @@ -184,7 +180,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJLI, \ LIBS_aix := $(LIBDL),\ LIBS_macosx := -framework Cocoa -framework Security -framework ApplicationServices, \ LIBS_windows := advapi32.lib comctl32.lib user32.lib, \ - STATIC_LIB_EXCLUDE_OBJS := $(LIBJLI_STATIC_EXCLUDE_OBJS), \ )) TARGETS += $(BUILD_LIBJLI) diff --git a/make/modules/java.desktop/lib/Awt2dLibraries.gmk b/make/modules/java.desktop/lib/Awt2dLibraries.gmk index fb004ee9b7410..c3b756423fdc4 100644 --- a/make/modules/java.desktop/lib/Awt2dLibraries.gmk +++ b/make/modules/java.desktop/lib/Awt2dLibraries.gmk @@ -218,14 +218,6 @@ ifeq ($(call isTargetOs, windows macosx), false) LIBAWT_XAWT_LIBS += -lpthread endif - # These are the object files provided by the awt native - # library. Do not include these external (non-awt_xawt library) - # objects in the static library. When statically linking the java - # launcher with all JDK and VM static libraries, we use the - # --whole-archive linker option. The duplicate objects in different - # static libraries cause linking errors due to duplicate symbols. - LIBAWT_XAWT_STATIC_EXCLUDE_OBJS := systemScale.o - $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_XAWT, \ NAME := awt_xawt, \ EXTRA_SRC := $(LIBAWT_XAWT_EXTRA_SRC), \ @@ -252,7 +244,6 @@ ifeq ($(call isTargetOs, windows macosx), false) $(call SET_SHARED_LIBRARY_ORIGIN) \ -L$(INSTALL_LIBRARIES_HERE), \ LIBS := $(X_LIBS) $(LIBAWT_XAWT_LIBS), \ - STATIC_LIB_EXCLUDE_OBJS := $(LIBAWT_XAWT_STATIC_EXCLUDE_OBJS), \ )) $(BUILD_LIBAWT_XAWT): $(call FindLib, java.base, java) @@ -376,14 +367,6 @@ ifeq ($(call isTargetOs, windows macosx), false) LIBAWT_HEADLESS_CFLAGS := $(CUPS_CFLAGS) $(FONTCONFIG_CFLAGS) $(X_CFLAGS) \ -DHEADLESS=true - # These are the object files provided by the awt native - # library. Do not include these external (non-awt_headless library) - # objects in the static library. When statically linking the java - # launcher with all JDK and VM static libraries, we use the - # --whole-archive linker option. The duplicate objects in different - # static libraries cause linking errors due to duplicate symbols. - LIBAWT_HEADLESS_STATIC_EXCLUDE_OBJS := systemScale.o - $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_HEADLESS, \ NAME := awt_headless, \ EXTRA_SRC := $(LIBAWT_HEADLESS_EXTRA_SRC), \ @@ -399,7 +382,6 @@ ifeq ($(call isTargetOs, windows macosx), false) LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \ LIBS_unix := -lawt -ljvm -ljava, \ LIBS_linux := $(LIBM) $(LIBDL), \ - STATIC_LIB_EXCLUDE_OBJS := $(LIBAWT_HEADLESS_STATIC_EXCLUDE_OBJS), \ )) $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT) From cc9f7ad9ce33dc44d335fb7fb5483795c62ba936 Mon Sep 17 00:00:00 2001 From: Ashutosh Mehra Date: Wed, 10 May 2023 21:51:36 +0000 Subject: [PATCH 009/502] 8307765: DynamicArchiveHeader contents are missing in CDS mapfile Reviewed-by: iklam, ccheung --- src/hotspot/share/cds/dynamicArchive.cpp | 9 +++++++++ src/hotspot/share/cds/dynamicArchive.hpp | 1 + src/hotspot/share/cds/filemap.cpp | 7 +++++++ src/hotspot/share/cds/filemap.hpp | 4 +--- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/cds/dynamicArchive.cpp b/src/hotspot/share/cds/dynamicArchive.cpp index 0aa11ef8d5ba7..43e425c11c531 100644 --- a/src/hotspot/share/cds/dynamicArchive.cpp +++ b/src/hotspot/share/cds/dynamicArchive.cpp @@ -445,3 +445,12 @@ bool DynamicArchive::validate(FileMapInfo* dynamic_info) { return true; } + +void DynamicArchiveHeader::print(outputStream* st) { + ResourceMark rm; + + st->print_cr("- base_header_crc: 0x%08x", base_header_crc()); + for (int i = 0; i < NUM_CDS_REGIONS; i++) { + st->print_cr("- base_region_crc[%d]: 0x%08x", i, base_region_crc(i)); + } +} diff --git a/src/hotspot/share/cds/dynamicArchive.hpp b/src/hotspot/share/cds/dynamicArchive.hpp index 2cd03b5b4e75a..ef40d942d079b 100644 --- a/src/hotspot/share/cds/dynamicArchive.hpp +++ b/src/hotspot/share/cds/dynamicArchive.hpp @@ -54,6 +54,7 @@ class DynamicArchiveHeader : public FileMapHeader { assert(is_valid_region(i), "must be"); _base_region_crc[i] = c; } + void print(outputStream* st); }; class DynamicArchive : AllStatic { diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 8e2a5b29ee8ff..999b18d70f805 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -2394,6 +2394,13 @@ FileMapRegion* FileMapInfo::last_core_region() const { return region_at(MetaspaceShared::ro); } +void FileMapInfo::print(outputStream* st) const { + header()->print(st); + if (!is_static()) { + dynamic_header()->print(st); + } +} + void FileMapHeader::set_as_offset(char* p, size_t *offset) { *offset = ArchiveBuilder::current()->any_to_offset((address)p); } diff --git a/src/hotspot/share/cds/filemap.hpp b/src/hotspot/share/cds/filemap.hpp index dce1ad94b6203..70ccb10e8a6dc 100644 --- a/src/hotspot/share/cds/filemap.hpp +++ b/src/hotspot/share/cds/filemap.hpp @@ -530,9 +530,7 @@ class FileMapInfo : public CHeapObj { return header()->region_at(i); } - void print(outputStream* st) { - header()->print(st); - } + void print(outputStream* st) const; const char* vm_version() { return header()->jvm_ident(); From f250ab2c2ae120c9b25da1486e919f2acf08f7d1 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 10 May 2023 22:05:58 +0000 Subject: [PATCH 010/502] 8307377: Remove use of `tagName` from TagletWriterImpl.linkSeeReferenceOutput Reviewed-by: hannesw --- .../formats/html/TagletWriterImpl.java | 21 +++++++------------ .../html/resources/standard.properties | 5 +++-- .../TestDocLintDocletMessages.java | 6 +++--- .../TestGenericTypeLink.java | 16 +++++++------- .../doclet/testInherited/TestInherited.java | 12 +++++------ .../TestLinkTagletPrimitive.java | 14 ++++++------- .../testSeeLinkAnchor/TestSeeLinkAnchor.java | 6 +++--- .../javadoc/doclet/testSeeTag/TestSeeTag.java | 8 +++---- 8 files changed, 41 insertions(+), 47 deletions(-) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java index 5481814907aea..57c2bdb76f346 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java @@ -297,14 +297,12 @@ public Content linkTagOutput(Element element, LinkTree tag) { } DocTree.Kind kind = tag.getKind(); - String tagName = ch.getTagName(tag); String refSignature = ch.getReferencedSignature(linkRef); return linkSeeReferenceOutput(element, tag, refSignature, ch.getReferencedElement(tag), - tagName, (kind == LINK_PLAIN), htmlWriter.commentTagsToContent(element, tag.getLabel(), context), (key, args) -> messages.warning(ch.getDocTreePath(tag), key, args) @@ -431,7 +429,6 @@ private Content seeTagOutput(Element element, SeeTree seeTag) { case REFERENCE -> { // @see reference label... CommentHelper ch = utils.getCommentHelper(element); - String tagName = ch.getTagName(seeTag); String refSignature = ch.getReferencedSignature(ref0); List label = ref.subList(1, ref.size()); @@ -439,7 +436,6 @@ private Content seeTagOutput(Element element, SeeTree seeTag) { seeTag, refSignature, ch.getReferencedElement(seeTag), - tagName, false, htmlWriter.commentTagsToContent(element, label, context), (key, args) -> messages.warning(ch.getDocTreePath(seeTag), key, args) @@ -466,7 +462,6 @@ private Content seeTagOutput(Element element, SeeTree seeTag) { * @param refTree the tree node containing the information, or {@code null} if not available * @param refSignature the normalized signature of the target of the reference * @param ref the target of the reference - * @param tagName the name of the tag in the source, to be used in diagnostics * @param isLinkPlain {@code true} if the link should be presented in "plain" font, * or {@code false} for "code" font * @param label the label for the link, @@ -479,7 +474,6 @@ private Content linkSeeReferenceOutput(Element holder, DocTree refTree, String refSignature, Element ref, - String tagName, boolean isLinkPlain, Content label, BiConsumer reportWarning) { @@ -535,10 +529,10 @@ private Content linkSeeReferenceOutput(Element holder, // No cross link found so print warning if (!configuration.isDocLintReferenceGroupEnabled()) { reportWarning.accept( - "doclet.see.class_or_package_not_found", - new Object[] { "@" + tagName, refSignature}); + "doclet.link.see.reference_not_found", + new Object[] { refSignature}); } - return htmlWriter.invalidTagOutput(resources.getText("doclet.tag.invalid", tagName), + return htmlWriter.invalidTagOutput(resources.getText("doclet.link.see.reference_invalid"), Optional.of(labelContent.isEmpty() ? text: labelContent)); } } @@ -586,12 +580,12 @@ private Content linkSeeReferenceOutput(Element holder, if (htmlWriter instanceof ClassWriterImpl writer) { containing = writer.getTypeElement(); } else if (!utils.isPublic(containing)) { - reportWarning.accept("doclet.see.class_or_package_not_accessible", - new Object[] { tagName, utils.getFullyQualifiedName(containing)}); + reportWarning.accept("doclet.link.see.reference_not_accessible", + new Object[] { utils.getFullyQualifiedName(containing)}); } else { if (!configuration.isDocLintReferenceGroupEnabled()) { - reportWarning.accept("doclet.see.class_or_package_not_found", - new Object[] { tagName, refSignature }); + reportWarning.accept("doclet.link.see.reference_not_found", + new Object[] { refSignature }); } } } @@ -697,7 +691,6 @@ protected Content snippetTagOutput(Element element, SnippetTree tag, StyledText null, t, e, - "link", false, // TODO: for now Text.of(sequence.toString()), (key, args) -> { /* TODO: report diagnostic */ }); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties index 643e22a0cf0e7..0e003b73c84ec 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties @@ -104,8 +104,9 @@ doclet.URL_error=Error fetching URL: {0} doclet.Resource_error=Error reading resource: {0} doclet.link.no_reference=no reference given doclet.link.see.no_label=missing reference label -doclet.see.class_or_package_not_found=Tag {0}: reference not found: {1} -doclet.see.class_or_package_not_accessible=Tag {0}: reference not accessible: {1} +doclet.link.see.reference_invalid=invalid reference +doclet.link.see.reference_not_found=reference not found: {0} +doclet.link.see.reference_not_accessible=reference not accessible: {0} doclet.see.nested_link=Tag {0}: nested link doclet.throws.reference_not_found=cannot find exception type by name doclet.throws.reference_bad_type=not an exception type: {0} diff --git a/test/langtools/jdk/javadoc/doclet/testDoclintDocletMessages/TestDocLintDocletMessages.java b/test/langtools/jdk/javadoc/doclet/testDoclintDocletMessages/TestDocLintDocletMessages.java index e0ca7d5c1f5ff..072a82ed5c8e5 100644 --- a/test/langtools/jdk/javadoc/doclet/testDoclintDocletMessages/TestDocLintDocletMessages.java +++ b/test/langtools/jdk/javadoc/doclet/testDoclintDocletMessages/TestDocLintDocletMessages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8252717 + * @bug 8252717 8307377 * @summary Integrate/merge legacy standard doclet diagnostics and doclint * @library ../../lib /tools/lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -87,7 +87,7 @@ private C() { } """); var doclintResult = new Result(Exit.ERROR, "C.java:3: error: reference not found"); - var docletResult = new Result(Exit.OK, "C.java:3: warning: Tag @see: reference not found: DoesNotExist"); + var docletResult = new Result(Exit.OK, "C.java:3: warning: reference not found: DoesNotExist"); testSingle(base, "reference", doclintResult, docletResult); } diff --git a/test/langtools/jdk/javadoc/doclet/testGenericTypeLink/TestGenericTypeLink.java b/test/langtools/jdk/javadoc/doclet/testGenericTypeLink/TestGenericTypeLink.java index 7d77b2d1e5e2d..c0b45b3491453 100644 --- a/test/langtools/jdk/javadoc/doclet/testGenericTypeLink/TestGenericTypeLink.java +++ b/test/langtools/jdk/javadoc/doclet/testGenericTypeLink/TestGenericTypeLink.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8177280 8262992 8259499 + * @bug 8177280 8262992 8259499 8307377 * @summary see and link tag syntax should allow generic types * @library ../../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool @@ -168,19 +168,19 @@ public void testInvalidLinks() { """
- invalid @link + invalid reference
java.util.Foo<String>
\s
- invalid @linkplain + invalid reference
Baz<Object>
\s
- invalid @link + invalid reference
#b(List<Integer>)
""", @@ -192,19 +192,19 @@ public void testInvalidLinks() {