From 6e296a01c23de672917526801e3c231212544106 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 27 Feb 2024 20:11:43 +0000 Subject: [PATCH 001/149] 8326801: Bump update version for OpenJDK: jdk-11.0.24 Reviewed-by: shade --- .jcheck/conf | 2 +- make/autoconf/version-numbers | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.jcheck/conf b/.jcheck/conf index 2ca83defe29..be7ad6d26f5 100644 --- a/.jcheck/conf +++ b/.jcheck/conf @@ -1,7 +1,7 @@ [general] project=jdk-updates jbs=JDK -version=11.0.23 +version=11.0.24 [checks] error=author,committer,reviewers,merge,issues,executable,symlink,message,hg-tag,whitespace diff --git a/make/autoconf/version-numbers b/make/autoconf/version-numbers index 9ddd07452ff..45d037c02f2 100644 --- a/make/autoconf/version-numbers +++ b/make/autoconf/version-numbers @@ -28,12 +28,12 @@ DEFAULT_VERSION_FEATURE=11 DEFAULT_VERSION_INTERIM=0 -DEFAULT_VERSION_UPDATE=23 +DEFAULT_VERSION_UPDATE=24 DEFAULT_VERSION_PATCH=0 DEFAULT_VERSION_EXTRA1=0 DEFAULT_VERSION_EXTRA2=0 DEFAULT_VERSION_EXTRA3=0 -DEFAULT_VERSION_DATE=2024-04-16 +DEFAULT_VERSION_DATE=2024-07-16 DEFAULT_VERSION_CLASSFILE_MAJOR=55 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="10 11" From 5045b5467d29547b54b28302bfe849353c24c146 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 27 Feb 2024 20:22:59 +0000 Subject: [PATCH 002/149] 8214400: Update hotspot application/jcstress jtreg tests wrappers to use jcstress 0.5 Backport-of: bbfe9d2168932f4fc8a2184b6bfde12d92ff1c8c --- .../applications/jcstress/JcstressRunner.java | 7 ++--- .../applications/jcstress/threadlocal.java | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 test/hotspot/jtreg/applications/jcstress/threadlocal.java diff --git a/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java b/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java index c1a77ac6f4d..e5d3df3dc0f 100644 --- a/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java +++ b/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, 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 @@ -42,7 +42,7 @@ * jcstress tests wrapper */ @Artifact(organization = "org.openjdk.jcstress", name = "jcstress-tests-all", - revision = "0.3", extension = "jar", unpack = false) + revision = "0.5", extension = "jar", unpack = false) public class JcstressRunner { public static final String MAIN_CLASS = "org.openjdk.jcstress.Main"; @@ -55,7 +55,7 @@ public static Path pathToArtifact() { throw new Error("TESTBUG: Can not resolve artifacts for " + JcstressRunner.class.getName(), e); } - return artifacts.get("org.openjdk.jcstress.jcstress-tests-all-0.3") + return artifacts.get("org.openjdk.jcstress.jcstress-tests-all-0.5") .toAbsolutePath(); } @@ -115,4 +115,3 @@ private static String[] getCmd(String[] args) { return result; } } - diff --git a/test/hotspot/jtreg/applications/jcstress/threadlocal.java b/test/hotspot/jtreg/applications/jcstress/threadlocal.java new file mode 100644 index 00000000000..4abc459224f --- /dev/null +++ b/test/hotspot/jtreg/applications/jcstress/threadlocal.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, 2018, 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. + * + * 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. + */ + +/* DO NOT MODIFY THIS FILE. GENERATED BY applications.jcstress.TestGenerator */ + +/** + * @test threadlocal + * @library /test/lib / + * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.threadlocal\. + */ + From fe840ca3a2ff3b427862785e91216d11f2a66dce Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Wed, 28 Feb 2024 07:03:20 +0000 Subject: [PATCH 003/149] 8314830: runtime/ErrorHandling/ tests ignore external VM flags Reviewed-by: lucy Backport-of: 2c2b3726f934d78ea044186320ef7c67b100ab8e --- .../ErrorHandling/BadNativeStackInErrorHandlingTest.java | 3 ++- .../jtreg/runtime/ErrorHandling/ErrorFileRedirectTest.java | 3 ++- .../NestedThreadsListHandleInErrorHandlingTest.java | 3 ++- .../jtreg/runtime/ErrorHandling/ProblematicFrameTest.java | 3 ++- .../runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java | 3 ++- .../jtreg/runtime/ErrorHandling/SecondaryErrorTest.java | 3 ++- .../runtime/ErrorHandling/ShowRegistersOnAssertTest.java | 1 + .../runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java | 1 + .../runtime/ErrorHandling/TestExitOnOutOfMemoryError.java | 3 ++- .../ErrorHandling/TestHeapDumpOnOutOfMemoryError.java | 3 ++- .../jtreg/runtime/ErrorHandling/TestHeapDumpPath.java | 3 ++- test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java | 3 ++- .../jtreg/runtime/ErrorHandling/TestOnOutOfMemoryError.java | 3 ++- .../ErrorHandling/ThreadsListHandleInErrorHandlingTest.java | 3 ++- .../runtime/ErrorHandling/TimeoutInErrorHandlingTest.java | 4 +++- .../jtreg/runtime/ErrorHandling/VeryEarlyAssertTest.java | 6 +++--- 16 files changed, 32 insertions(+), 16 deletions(-) diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java index fd036a4a71a..da3a9b612ef 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -36,6 +36,7 @@ * @bug 8194652 * @summary Printing native stack shows an "error occurred during error reporting". * @modules java.base/jdk.internal.misc + * @requires vm.flagless * @library /test/lib */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileRedirectTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileRedirectTest.java index e8dfeece67f..5b510f43973 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileRedirectTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileRedirectTest.java @@ -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. * Copyright (c) 2019, SAP. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,6 +29,7 @@ * @summary Test ErrorFileToStderr and ErrorFileToStdout * @library /test/lib * @modules java.base/jdk.internal.misc + * @requires vm.flagless * @requires (vm.debug == true) */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java index 987f2e95ef6..a9fff2ecbc3 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -33,6 +33,7 @@ /* * @test + * @requires vm.flagless * @requires (vm.debug == true) * @bug 8167108 * @summary Nested ThreadsListHandle info should be in error handling output. diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java index 535c58d670a..2e00d4bca83 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ProblematicFrameTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -30,6 +30,7 @@ * java.compiler * java.management * jdk.internal.jvmstat/sun.jvmstat.monitor + * @requires vm.flagless * @run driver ProblematicFrameTest */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java index f549c37adc0..30724479733 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -37,6 +37,7 @@ * @summary SafeFetch32 and SafeFetchN do not work in error handling * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.flagless * @author Thomas Stuefe (SAP) */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java index 587f38a3d14..12023172ec8 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -27,6 +27,7 @@ * @bug 8065896 * @summary Synchronous signals during error reporting may terminate or hang VM process * @library /test/lib + * @requires vm.flagless * @author Thomas Stuefe (SAP) * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java index 732729f8ed4..e32839fe2db 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ShowRegistersOnAssertTest.java @@ -27,6 +27,7 @@ * @bug 8191101 * @summary Show Registers on assert/guarantee * @library /test/lib + * @requires vm.flagless * @requires (vm.debug == true) & (os.family == "linux") * @author Thomas Stuefe (SAP) * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java index 3ef7c868462..2b33f4ffb53 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java @@ -26,6 +26,7 @@ * @summary Test using -XX:+CrashOnOutOfMemoryError * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.flagless * @run driver TestCrashOnOutOfMemoryError * @bug 8138745 */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java index 2159442c08c..e56ed4a1b03 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -26,6 +26,7 @@ * @summary Test using -XX:ExitOnOutOfMemoryError * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.flagless * @run driver TestExitOnOutOfMemoryError * @bug 8138745 */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpOnOutOfMemoryError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpOnOutOfMemoryError.java index 3fdf5f6842b..87061e196e0 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpOnOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpOnOutOfMemoryError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -25,6 +25,7 @@ * @test TestHeapDumpOnOutOfMemoryError * @summary Test verifies that -XX:HeapDumpOnOutOfMemoryError dump heap when OutOfMemory is thrown in heap * @library /test/lib + * @requires vm.flagless * @run driver TestHeapDumpOnOutOfMemoryError run heap */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpPath.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpPath.java index b1c4dc0c357..0cc6dbc765f 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpPath.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestHeapDumpPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -25,6 +25,7 @@ * @test TestHeapDumpPath * @summary Test verifies that -XX:HeapDumpPath= supports directory as a parameter. * @library /test/lib + * @requires vm.flagless * @run driver TestHeapDumpPath */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java index a54a63fa825..0a71f99de53 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -27,6 +27,7 @@ * @summary Test using -XX:OnError= * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.flagless * @requires vm.debug * @run main TestOnError */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestOnOutOfMemoryError.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestOnOutOfMemoryError.java index f5011bab1d4..e68e241afbc 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestOnOutOfMemoryError.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestOnOutOfMemoryError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -26,6 +26,7 @@ * @summary Test using single and multiple -XX:OnOutOfMemoryError= * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.flagless * @run main TestOnOutOfMemoryError * @bug 8078470 8177522 */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java index 03ff3ede8be..fc56cc4ec15 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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,6 +38,7 @@ * @summary ThreadsListHandle info should be in error handling output. * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.flagless * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+EnableThreadSMRStatistics ThreadsListHandleInErrorHandlingTest */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TimeoutInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/TimeoutInErrorHandlingTest.java index c6ae37a64c8..8fcc6625f17 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TimeoutInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TimeoutInErrorHandlingTest.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2023, Red Hat, Inc. and/or its affiliates. - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -41,6 +41,7 @@ * @summary Hanging Error Reporting steps may lead to torn error logs * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.flagless * @requires (vm.debug == true) & (os.family != "windows") * @author Thomas Stuefe (SAP) */ @@ -51,6 +52,7 @@ * @summary Error handling step timeouts should never be blocked by OnError etc. * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.flagless * @requires (vm.debug == true) & (os.family != "windows") * @run driver TimeoutInErrorHandlingTest with-on-error */ diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/VeryEarlyAssertTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/VeryEarlyAssertTest.java index ea1d4ec5bac..1d5dea2fa81 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/VeryEarlyAssertTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/VeryEarlyAssertTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, SAP. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,6 +29,7 @@ * @summary No hs-err file if fatal error is raised during dynamic initialization. * @library /test/lib * @modules java.base/jdk.internal.misc + * @requires vm.flagless * @requires (vm.debug == true) * @requires os.family == "linux" */ @@ -48,8 +49,7 @@ public class VeryEarlyAssertTest { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-version"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-version"); Map env = pb.environment(); env.put("HOTSPOT_FATAL_ERROR_DURING_DYNAMIC_INITIALIZATION", "1"); From e5cc20c35ac591d69ba5ed364b68b8551cefdb25 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Wed, 28 Feb 2024 07:04:46 +0000 Subject: [PATCH 004/149] 8315726: Open source several AWT applet tests Reviewed-by: lucy Backport-of: 1741d13b1260253d1e299e8da9c42b5519a7ae48 --- .../jdk/java/awt/Choice/ChoiceSelectTest.java | 174 ++++++++ test/jdk/java/awt/Component/Displayable.java | 156 +++++++ .../java/awt/Focus/TestWindowsLFFocus.java | 127 ++++++ .../java/awt/geom/HitTest/PathHitTest.java | 391 ++++++++++++++++++ 4 files changed, 848 insertions(+) create mode 100644 test/jdk/java/awt/Choice/ChoiceSelectTest.java create mode 100644 test/jdk/java/awt/Component/Displayable.java create mode 100644 test/jdk/java/awt/Focus/TestWindowsLFFocus.java create mode 100644 test/jdk/java/awt/geom/HitTest/PathHitTest.java diff --git a/test/jdk/java/awt/Choice/ChoiceSelectTest.java b/test/jdk/java/awt/Choice/ChoiceSelectTest.java new file mode 100644 index 00000000000..cf5b2e6d114 --- /dev/null +++ b/test/jdk/java/awt/Choice/ChoiceSelectTest.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 1998, 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. + * + * 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. + */ + +import java.awt.Choice; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Panel; + +/* + * @test + * @bug 4115139 4128213 + * @summary Tests that the (rather bizarre) rules for handling selection + * in Choice components are implemented as documented in + * "The Java Class Libraries 2nd Edition" + * @key headful + */ + +public class ChoiceSelectTest extends Panel { + final Choice c; + + public ChoiceSelectTest() { + setLayout(new FlowLayout()); + c = new Choice(); + add(c); + } + + private void test() { + testAddition(); + testInsertion(); + testRemoval(); + testIndices(); + } + + public void testAddition() { + c.removeAll(); + + // check that after first item added selection is zero + c.addItem("zero"); + if (c.getSelectedIndex() != 0) { + throw new SelectionException("selection wrong after first add"); + } + + // check that selection doesn't change for subsequent adds + c.addItem("one"); + c.select(1); + c.addItem("two"); + if (c.getSelectedIndex() != 1) { + throw new SelectionException("selection wrong after subsequent add"); + } + } + + public void testInsertion() { + c.removeAll(); + + // check that after first item inserted selection is zero + c.insert("zero", 0); + if (c.getSelectedIndex() != 0) { + throw new SelectionException("selection wrong after first insert"); + } + + // check that if selected item shifted, selection goes to zero + c.insert("three", 1); + c.select(1); + c.insert("one", 1); + if (c.getSelectedIndex() != 0) { + throw new SelectionException("selection wrong after selected item shifted"); + } + + // check that if selected item not shifted, selection stays the same + c.select(1); + c.insert("two", 2); + if (c.getSelectedIndex() != 1) { + throw new SelectionException("selection wrong after item inserted after selection"); + } + } + + public void testRemoval() { + c.removeAll(); + + // check that if removing selected item, selection goes to 0 + c.add("zero"); + c.add("one"); + c.add("two"); + c.select(2); + c.remove(2); + if (c.getSelectedIndex() != 0) { + throw new SelectionException("selection wrong after removing selected item"); + } + + // check that if removing item before the selection + // the selected index is updated + c.add("two"); + c.add("three"); + c.select(3); + c.remove(1); + if (c.getSelectedIndex() != 2) { + throw new SelectionException("selection wrong after removing item before it"); + } + } + + public void testIndices() { + c.removeAll(); + + c.addItem("zero"); + c.addItem("one"); + c.addItem("two"); + c.addItem("three"); + c.addItem("four"); + c.addItem("five"); + + // Test selection of negative index + try { + c.select(-1); + throw new SelectionException("Negative Index Test FAILED"); + } catch (IllegalArgumentException expected) {} + + // Test selection of zero index + try { + c.select(0); + } catch (IllegalArgumentException iae) { + throw new SelectionException("Zero Index Test FAILED", iae); + } + + // Test selection of maximum index + try { + c.select(5); + } catch (IllegalArgumentException iae) { + throw new SelectionException("Maximum Index Test FAILED", iae); + } + + // Test selection of index that is too large + try { + c.select(6); + throw new SelectionException("Greater than Maximum Index Test FAILED"); + } catch (IllegalArgumentException expected) {} + } + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> new ChoiceSelectTest().test()); + } + + class SelectionException extends RuntimeException { + SelectionException(String msg, Throwable cause) { + super(msg, cause); + System.out.println( + "Selection item is '" + c.getSelectedItem() + + "' at index " + c.getSelectedIndex()); + } + + SelectionException(String msg) { + this(msg, null); + } + } +} diff --git a/test/jdk/java/awt/Component/Displayable.java b/test/jdk/java/awt/Component/Displayable.java new file mode 100644 index 00000000000..0c4969bb595 --- /dev/null +++ b/test/jdk/java/awt/Component/Displayable.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 1998, 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. + * + * 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. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Label; +import java.awt.Panel; + +/* + * @test + * @key headful + * @summary automated test for "displayable" property on Component + */ + +public class Displayable extends Panel { + Label status = new Label("Displayable Test started..."); + + public void init() { + setLayout(new BorderLayout()); + add("South", status); + + LightDisplayable light = new LightDisplayable(); + shouldNotBeDisplayable(light, "before added to container "); + + HeavyDisplayable heavy = new HeavyDisplayable(); + shouldNotBeDisplayable(heavy, "before added to container "); + + add("West", light); + add("East", heavy); + + statusMessage("Displayable test completed successfully."); + } + + protected void addImpl(Component child, Object constraints, int index) { + super.addImpl(child, constraints, index); + if (isDisplayable()) { + shouldBeDisplayable(child, "after added to displayable container "); + } else { + shouldNotBeDisplayable(child, "after added to undisplayable container "); + } + } + + public void remove(Component child) { + super.remove(child); + shouldNotBeDisplayable(child, "after removed from displayable container "); + } + + public void statusMessage(String msg) { + status.setText(msg); + status.invalidate(); + validate(); + } + + public static void shouldNotBeDisplayable(Component c, String why) { + if (c.isDisplayable()) { + throw new RuntimeException("Component is displayable "+why+c.getName()); + } + } + + public static void shouldBeDisplayable(Component c, String why) { + if (!c.isDisplayable()) { + throw new RuntimeException("Component is NOT displayable "+why+c.getName()); + } + } + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> { + Frame f = new Frame(); + try { + Displayable test = new Displayable(); + test.init(); + f.add("North", test); + f.pack(); + } finally { + f.dispose(); + } + }); + } +} + +class LightDisplayable extends Component { + + public Dimension getPreferredSize() { + return new Dimension(50,50); + } + + public void paint(Graphics g) { + Dimension size = getSize(); + g.setColor(Color.blue); + g.fillRect(0, 0, size.width, size.height); + super.paint(g); + } + + public void addNotify() { + Displayable.shouldNotBeDisplayable(this, "before addNotify "); + super.addNotify(); + Displayable.shouldBeDisplayable(this, "after addNotify "); + } + + public void removeNotify() { + Displayable.shouldBeDisplayable(this, "before removeNotify "); + super.removeNotify(); + Displayable.shouldNotBeDisplayable(this, "after removeNotify "); + } +} + +class HeavyDisplayable extends Panel { + + public Dimension getPreferredSize() { + return new Dimension(50, 50); + } + + public void paint(Graphics g) { + Dimension size = getSize(); + g.setColor(Color.black); + g.fillRect(0, 0, size.width, size.height); + super.paint(g); + } + + public void addNotify() { + Displayable.shouldNotBeDisplayable(this, "before addNotify "); + super.addNotify(); + Displayable.shouldBeDisplayable(this, "after addNotify "); + } + + public void removeNotify() { + Displayable.shouldBeDisplayable(this, "before removeNotify "); + super.removeNotify(); + Displayable.shouldNotBeDisplayable(this, "after removeNotify "); + } +} diff --git a/test/jdk/java/awt/Focus/TestWindowsLFFocus.java b/test/jdk/java/awt/Focus/TestWindowsLFFocus.java new file mode 100644 index 00000000000..8dd27f0a649 --- /dev/null +++ b/test/jdk/java/awt/Focus/TestWindowsLFFocus.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.WindowConstants; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; + +/* + * @test + * @bug 4749659 + * @summary Tests that popup menu doesn't steal focus from top-level + * @key headful + */ + +public class TestWindowsLFFocus { + static volatile boolean actionFired; + + static JFrame frame; + static JMenuBar bar; + static JMenuItem item; + static volatile Point frameLoc; + + public static void main(String[] args) throws Exception { + for (UIManager.LookAndFeelInfo lookAndFeel : UIManager.getInstalledLookAndFeels()) { + UIManager.setLookAndFeel(lookAndFeel.getClassName()); + test(); + } + + System.err.println("PASSED"); + } + + private static void test() throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + actionFired = false; + frame = new JFrame(); + bar = new JMenuBar(); + frame.setJMenuBar(bar); + JMenu menu = new JMenu("menu"); + bar.add(menu); + item = new JMenuItem("item"); + menu.add(item); + item.addActionListener(e -> actionFired = true); + + frame.getContentPane().add(new JButton("none")); + frame.setBounds(100, 100, 100, 100); + frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + frame.setVisible(true); + }); + + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(50); + + robot.waitForIdle(); + robot.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + Point location = frame.getLocationOnScreen(); + Insets insets = frame.getInsets(); + + location.translate(insets.left + 15, insets.top + bar.getHeight() / 2); + + frameLoc = location; + }); + + robot.mouseMove(frameLoc.x, frameLoc.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + Point location = new Point(frameLoc); + location.y += bar.getHeight() / 2 + item.getHeight() / 2; + + frameLoc = location; + }); + + robot.mouseMove(frameLoc.x, frameLoc.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + robot.waitForIdle(); + robot.delay(500); + + if (!actionFired) { + throw new RuntimeException("Menu closed without action"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} diff --git a/test/jdk/java/awt/geom/HitTest/PathHitTest.java b/test/jdk/java/awt/geom/HitTest/PathHitTest.java new file mode 100644 index 00000000000..1225864c4bf --- /dev/null +++ b/test/jdk/java/awt/geom/HitTest/PathHitTest.java @@ -0,0 +1,391 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.Choice; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.Polygon; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.Area; +import java.awt.geom.Ellipse2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; + +/* + * @test + * @bug 4210936 4214524 + * @summary Tests the results of the hit test methods on 3 different + * Shape objects - Polygon, Area, and GeneralPath. Both an + * automatic test for constraint compliance and a manual + * test for correctness are included in this one class. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main PathHitTest + */ + +/* + * @test + * @bug 4210936 4214524 + * @summary Tests the results of the hit test methods on 3 different + * Shape objects - Polygon, Area, and GeneralPath. Both an + * automatic test for constraint compliance and a manual + * test for correctness are included in this one class. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual PathHitTest manual + */ + +public class PathHitTest { + + public static final int BOXSIZE = 5; + public static final int BOXCENTER = 2; + public static final int TESTSIZE = 400; + public static final int NUMTESTS = (TESTSIZE + BOXSIZE - 1) / BOXSIZE; + + public static Shape[] testShapes = new Shape[5]; + public static String[] testNames = { + "Polygon", + "EvenOdd GeneralPath", + "NonZero GeneralPath", + "Area from EO GeneralPath", + "Area from NZ GeneralPath", + }; + + static { + GeneralPath gpeo = new GeneralPath(GeneralPath.WIND_EVEN_ODD); + Ellipse2D ell = new Ellipse2D.Float(); + Point2D center = new Point2D.Float(); + AffineTransform at = new AffineTransform(); + for (int i = 0; i < 360; i += 30) { + center.setLocation(100, 0); + at.setToTranslation(200, 200); + at.rotate(i * Math.PI / 180); + at.transform(center, center); + ell.setFrame(center.getX() - 50, center.getY() - 50, 100, 100); + gpeo.append(ell, false); + } + GeneralPath side = new GeneralPath(); + side.moveTo(0, 0); + side.lineTo(15, 10); + side.lineTo(30, 0); + side.lineTo(45, -10); + side.lineTo(60, 0); + append4sides(gpeo, side, 20, 20); + side.reset(); + side.moveTo(0, 0); + side.quadTo(15, 10, 30, 0); + side.quadTo(45, -10, 60, 0); + append4sides(gpeo, side, 320, 20); + side.reset(); + side.moveTo(0, 0); + side.curveTo(15, 10, 45, -10, 60, 0); + append4sides(gpeo, side, 20, 320); + + GeneralPath gpnz = new GeneralPath(GeneralPath.WIND_NON_ZERO); + gpnz.append(gpeo, false); + Polygon p = new Polygon(); + p.addPoint( 50, 50); + p.addPoint( 60, 350); + p.addPoint(250, 340); + p.addPoint(260, 150); + p.addPoint(140, 140); + p.addPoint(150, 260); + p.addPoint(340, 250); + p.addPoint(350, 60); + testShapes[0] = p; + testShapes[1] = gpeo; + testShapes[2] = gpnz; + testShapes[3] = new Area(gpeo); + testShapes[3].getPathIterator(null); + testShapes[4] = new Area(gpnz); + testShapes[4].getPathIterator(null); + } + + private static void append4sides(GeneralPath path, GeneralPath side, + double xoff, double yoff) { + AffineTransform at = new AffineTransform(); + at.setToTranslation(xoff, yoff); + for (int i = 0; i < 4; i++) { + path.append(side.getPathIterator(at), i != 0); + at.rotate(Math.toRadians(90), 30, 30); + } + } + + public static void main(String[] argv) throws Exception { + if (argv.length > 0 && argv[0].equals("manual")) { + PathHitTestManual.doManual(); + } else { + int totalerrs = 0; + for (int i = 0; i < testShapes.length; i++) { + totalerrs += testshape(testShapes[i], testNames[i]); + } + if (totalerrs != 0) { + throw new RuntimeException(totalerrs + + " constraint conditions violated!"); + } + } + } + + public static int testshape(Shape s, String name) { + int numerrs = 0; + long start = System.currentTimeMillis(); + for (int y = 0; y < TESTSIZE; y += BOXSIZE) { + for (int x = 0; x < TESTSIZE; x += BOXSIZE) { + boolean rectintersects = s.intersects(x, y, BOXSIZE, BOXSIZE); + boolean rectcontains = s.contains(x, y, BOXSIZE, BOXSIZE); + boolean pointcontains = s.contains(x + BOXCENTER, y + BOXCENTER); + if (rectcontains && !rectintersects) { + System.err.println("rect is contained " + + "but does not intersect!"); + numerrs++; + } + if (rectcontains && !pointcontains) { + System.err.println("rect is contained " + + "but center is not contained!"); + numerrs++; + } + if (pointcontains && !rectintersects) { + System.err.println("center is contained " + + "but rect does not intersect!"); + numerrs++; + } + } + } + long end = System.currentTimeMillis(); + System.out.println(name + " completed in " + + (end - start) + "ms with " + + numerrs + " errors"); + return numerrs; + } + + static class PathHitTestManual extends Panel { + private static final String INSTRUCTIONS = + "This test displays the results of hit testing 5 different Shape\n" + + "objects one at a time.\n" + + " \n" + + "You can switch between shapes using the Choice component located\n" + + "at the bottom of the window.\n" + + " \n" + + "Each square in the test represents the\n" + + "return values of the hit testing operators for that square region:\n" + + " \n" + + "yellow - not yet tested\n" + + "translucent blue overlay - the shape being tested\n" + + " \n" + + "black - all outside\n" + + "dark gray - rectangle intersects shape\n" + + "light gray - rectangle intersects and center point is inside shape\n" + + "white - rectangle is entirely contained in shape\n" + + "red - some constraint was violated, including:\n" + + "rectangle is contained, but center point is not\n" + + "rectangle is contained, but rectangle.intersects is false\n" + + "centerpoint is contained, but rectangle.intersects is false\n" + + " \n" + + "Visually inspect the results to see if they match the above table.\n" + + "Note that it is not a violation for rectangles that are entirely\n" + + "inside the path to be light gray instead of white since sometimes\n" + + "the path is complex enough to make an exact determination expensive.\n" + + "You might see this on the GeneralPath NonZero example where the\n" + + "circles that make up the path cross over the interior of the shape\n" + + "and cause the hit testing methods to guess that the rectangle is\n" + + "not guaranteed to be contained within the shape.\n"; + + PathHitTestCanvas phtc; + + public void init() { + setLayout(new BorderLayout()); + phtc = new PathHitTestCanvas(); + add("Center", phtc); + final Choice ch = new Choice(); + for (int i = 0; i < PathHitTest.testNames.length; i++) { + ch.add(PathHitTest.testNames[i]); + } + ch.addItemListener(e -> phtc.setShape(ch.getSelectedIndex())); + ch.select(0); + phtc.setShape(0); + add("South", ch); + } + + public void start() { + phtc.start(); + } + + public void stop() { + phtc.stop(); + } + + public static class PathHitTestCanvas extends Canvas implements Runnable { + public static final Color[] colors = { + /* contains? point in? intersects? */ + Color.black, /* NO NO NO */ + Color.darkGray, /* NO NO YES */ + Color.red, /* NO YES NO */ + Color.lightGray, /* NO YES YES */ + Color.red, /* YES NO NO */ + Color.red, /* YES NO YES */ + Color.red, /* YES YES NO */ + Color.white, /* YES YES YES */ + Color.yellow, /* used for untested points */ + }; + + public Dimension getPreferredSize() { + return new Dimension(TESTSIZE, TESTSIZE); + } + + public synchronized void start() { + if (!testdone) { + renderer = new Thread(this); + renderer.setPriority(Thread.MIN_PRIORITY); + renderer.start(); + } + } + + public synchronized void stop() { + renderer = null; + } + + private Thread renderer; + private int shapeIndex = 0; + private byte[] indices = new byte[NUMTESTS * NUMTESTS]; + boolean testdone = false; + + private synchronized void setShape(int index) { + shapeIndex = index; + testdone = false; + start(); + } + + public void run() { + Thread me = Thread.currentThread(); + Graphics2D g2d = (Graphics2D) getGraphics(); + byte[] indices; + Shape s = testShapes[shapeIndex]; + synchronized (this) { + if (renderer != me) { + return; + } + this.indices = new byte[NUMTESTS * NUMTESTS]; + java.util.Arrays.fill(this.indices, (byte) 8); + indices = this.indices; + } + + System.err.printf("%s %s\n", g2d, Color.yellow); + g2d.setColor(Color.yellow); + g2d.fillRect(0, 0, TESTSIZE, TESTSIZE); + int numtests = 0; + long start = System.currentTimeMillis(); + for (int y = 0; renderer == me && y < TESTSIZE; y += BOXSIZE) { + for (int x = 0; renderer == me && x < TESTSIZE; x += BOXSIZE) { + byte index = 0; + if (s.intersects(x, y, BOXSIZE, BOXSIZE)) { + index += 1; + } + if (s.contains(x + BOXCENTER, y + BOXCENTER)) { + index += 2; + } + if (s.contains(x, y, BOXSIZE, BOXSIZE)) { + index += 4; + } + numtests++; + int i = (y / BOXSIZE) * NUMTESTS + (x / BOXSIZE); + indices[i] = index; + g2d.setColor(colors[index]); + g2d.fillRect(x, y, BOXSIZE, BOXSIZE); + } + } + synchronized (this) { + if (renderer != me) { + return; + } + g2d.setColor(new Color(0, 0, 1, .2f)); + g2d.fill(s); + testdone = true; + long end = System.currentTimeMillis(); + System.out.println(numtests + " tests took " + (end - start) + "ms"); + } + } + + public void paint(Graphics g) { + g.setColor(Color.yellow); + g.fillRect(0, 0, TESTSIZE, TESTSIZE); + byte[] indices = this.indices; + if (indices != null) { + for (int y = 0; y < TESTSIZE; y += BOXSIZE) { + for (int x = 0; x < TESTSIZE; x += BOXSIZE) { + int i = (y / BOXSIZE) * NUMTESTS + (x / BOXSIZE); + g.setColor(colors[indices[i]]); + g.fillRect(x, y, BOXSIZE, BOXSIZE); + } + } + } + Graphics2D g2d = (Graphics2D) g; + g2d.setColor(new Color(0, 0, 1, .2f)); + g2d.fill(testShapes[shapeIndex]); + } + } + + static volatile PathHitTestManual pathHitTestManual; + + private static void createAndShowGUI() { + pathHitTestManual = new PathHitTestManual(); + Frame frame = new Frame("PathHitTestManual test window"); + + frame.add(pathHitTestManual); + frame.setSize(400, 450); + + PassFailJFrame.addTestWindow(frame); + PassFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL); + + frame.setVisible(true); + + pathHitTestManual.init(); + pathHitTestManual.start(); + } + + public static void doManual() throws Exception { + PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() + .title("PathHitTestManual Instructions") + .instructions(INSTRUCTIONS) + .testTimeOut(5) + .rows(30) + .columns(70) + .screenCapture() + .build(); + + EventQueue.invokeAndWait(PathHitTestManual::createAndShowGUI); + try { + passFailJFrame.awaitAndCheck(); + } finally { + pathHitTestManual.stop(); + } + } + } +} From c681c5aac4c893a8fa554d1c7af1976943d74d26 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Wed, 28 Feb 2024 07:06:39 +0000 Subject: [PATCH 005/149] 8316053: Open some swing tests 3 Backport-of: a2391a92cd09630cc3c46024f7e02924a997cc86 --- test/jdk/javax/swing/JDialog/bug4859570.java | 60 ++++++ test/jdk/javax/swing/JDialog/bug4936652.java | 47 +++++ test/jdk/javax/swing/JLabel/bug4768127.java | 125 ++++++++++++ .../swing/MultiMonitor/MultimonVImage.java | 183 ++++++++++++++++++ 4 files changed, 415 insertions(+) create mode 100644 test/jdk/javax/swing/JDialog/bug4859570.java create mode 100644 test/jdk/javax/swing/JDialog/bug4936652.java create mode 100644 test/jdk/javax/swing/JLabel/bug4768127.java create mode 100644 test/jdk/javax/swing/MultiMonitor/MultimonVImage.java diff --git a/test/jdk/javax/swing/JDialog/bug4859570.java b/test/jdk/javax/swing/JDialog/bug4859570.java new file mode 100644 index 00000000000..cc0f4f7adee --- /dev/null +++ b/test/jdk/javax/swing/JDialog/bug4859570.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4859570 + * @summary SwingUtilities.sharedOwnerFrame is never disposed + * @key headful + */ + +import java.awt.Robot; +import java.awt.Window; +import javax.swing.JDialog; +import javax.swing.SwingUtilities; + +public class bug4859570 { + static Window owner; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + JDialog dialog = new JDialog(); + dialog.setTitle("bug4859570"); + dialog.setBounds(100, 100, 100, 100); + dialog.setVisible(true); + + owner = dialog.getOwner(); + dialog.dispose(); + }); + + Robot r = new Robot(); + r.waitForIdle(); + r.delay(1000); + + SwingUtilities.invokeAndWait(() -> { + if (owner.isDisplayable()) { + throw new RuntimeException("The shared owner frame should be disposed."); + } + }); + } +} diff --git a/test/jdk/javax/swing/JDialog/bug4936652.java b/test/jdk/javax/swing/JDialog/bug4936652.java new file mode 100644 index 00000000000..989c8e4194f --- /dev/null +++ b/test/jdk/javax/swing/JDialog/bug4936652.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4936652 + * @key headful + * @summary JDialog.setVisible, JDialog.dispose works incorrectly + */ + +import javax.swing.JDialog; +import javax.swing.SwingUtilities; + +public class bug4936652 { + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + for (int i = 0 ; i < 100; i++) { + System.out.println("i: " + i); + JDialog o = new JDialog(); + o.setTitle("bug4936652"); + o.setVisible(true); + o.setVisible(false); + o.dispose(); + } + }); + } +} diff --git a/test/jdk/javax/swing/JLabel/bug4768127.java b/test/jdk/javax/swing/JLabel/bug4768127.java new file mode 100644 index 00000000000..0ccb3c7998a --- /dev/null +++ b/test/jdk/javax/swing/JLabel/bug4768127.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ + +/* + * @test + * @bug 4768127 + * @summary ToolTipManager not removed from components + * @key headful + */ + +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.MouseMotionListener; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; +import javax.swing.ToolTipManager; + +public class bug4768127 { + static JFrame fr; + static volatile Point p; + static volatile JLabel[] label = new JLabel[2]; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + fr = new JFrame("bug4768127"); + + JDesktopPane jdp = new JDesktopPane(); + JInternalFrame jif1 = new JInternalFrame("jif 1"); + JInternalFrame jif2 = new JInternalFrame("jif 2"); + label[0] = new JLabel("Label 1"); + label[1] = new JLabel("Label 2"); + + label[0].setToolTipText("tooltip 1"); + jif1.getContentPane().add(label[0]); + jif1.setBounds(0, 0, 130, 160); + jif1.setVisible(true); + jdp.add(jif1); + + label[1].setToolTipText("tooltip 2"); + jif2.getContentPane().add(label[1]); + jif2.setBounds(210, 0, 130, 220); + jif2.setVisible(true); + jdp.add(jif2); + + fr.getContentPane().add(jdp); + fr.setLocationRelativeTo(null); + + fr.setSize(400, 300); + fr.setVisible(true); + }); + + Robot robot = new Robot(); + robot.setAutoDelay(10); + robot.waitForIdle(); + robot.delay(3000); + + clickLabel(0, robot); + robot.waitForIdle(); + robot.delay(3000); + + clickLabel(1, robot); + robot.waitForIdle(); + robot.delay(3000); + + clickLabel(0, robot); + robot.waitForIdle(); + robot.delay(3000); + + clickLabel(1, robot); + robot.waitForIdle(); + robot.delay(3000); + + MouseMotionListener[] mml = label[0].getMouseMotionListeners(); + if (mml.length > 0 && mml[0] instanceof ToolTipManager) { + throw new RuntimeException("Extra MouseMotionListeners were added to the label \"Label 1\" by ToolTipManager"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (fr != null) { + fr.dispose(); + } + }); + } + } + + static void clickLabel(int i, Robot robot) throws Exception { + SwingUtilities.invokeAndWait(() -> { + p = label[i].getLocationOnScreen(); + }); + final Rectangle rect = label[i].getBounds(); + robot.mouseMove(p.x + rect.width / 2, p.y + rect.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + //Generate mouseMotionEvent + robot.mouseMove(p.x + rect.width / 2 + 3, p.y + rect.height / 2 + 3); + robot.mouseMove(p.x + rect.width / 2, p.y + rect.height / 2); + } +} diff --git a/test/jdk/javax/swing/MultiMonitor/MultimonVImage.java b/test/jdk/javax/swing/MultiMonitor/MultimonVImage.java new file mode 100644 index 00000000000..730424e306c --- /dev/null +++ b/test/jdk/javax/swing/MultiMonitor/MultimonVImage.java @@ -0,0 +1,183 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +/* + * @test + * @bug 4371134 + * @key headful + * @summary displays an animating fps (frames per second) + * counter. When the window is dragged from monitor to monitor, + * the speed of the animation should not change too greatly. + * @library /open/test/jdk/java/awt/regtesthelpers + * @run main/manual MultimonVImage + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JViewport; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class MultimonVImage { + private static final String instructionsText = + "This test should be run on any Windows platform that\n" + + "supports multiple monitors.\n" + + "You will see an animating fps (frames per second) counter at\n" + + "the bottom of the window. Drag the window into the other monitor\n" + + "and that counter should not change drastically. If the counter\n" + + "is much lower on one monitor than the other (barring situations\n" + + "described below) then the back buffer may not be accelerated\n" + + "on the second monitor and the test fails.\n" + + "Situations in which performance will differ even though there\n" + + "is acceleration on both monitors include:\n" + + " - different bit depths on each monitor. The higher the bits\n" + + " per pixel, the more data to push and the lower the fps number.\n" + + " Set the bit depths to be the same on both monitors to work\n" + + " around this issue.\n" + + " - the amount of acceleration available on each video card differs,\n" + + " so if your system uses different video cards then you should\n" + + " expect some difference between the cards. To work around this\n" + + " issue, try to use the same or similar video cards for each monitor."; + + public static void main(String[] args) throws Exception { + PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() + .title("MultimonVImage Instructions") + .instructions(instructionsText) + .testTimeOut(5) + .rows(25) + .columns(50) + .build(); + + SwingUtilities.invokeAndWait(() -> { + AnimatingFrame af = new AnimatingFrame(); + af.test(); + af.run(); + + PassFailJFrame.addTestWindow(af); + PassFailJFrame.positionTestWindow(af, + PassFailJFrame.Position.HORIZONTAL); + }); + + passFailJFrame.awaitAndCheck(); + } +} + +class FrameCounter { + + String fpsString = "Calculating..."; + long startTime, endTime; + int numFrames; + + public FrameCounter() { + startTime = System.currentTimeMillis(); + } + + public String addFrame() { + ++numFrames; + return calculateFPS(); + } + + String calculateFPS() { + endTime = System.currentTimeMillis(); + double seconds = ((double) endTime - (double) startTime) / 1000; + if (seconds > 1) { + int fps = (int) (numFrames / seconds); + fpsString = fps + " fps"; + startTime = endTime; + numFrames = 0; + } + return fpsString; + } +} + +class AnimatingComponent extends JViewport { + + FrameCounter frameCounter; + int boxX, boxY; + int boxW, boxH; + int xStep = 1; + + public AnimatingComponent() { + frameCounter = new FrameCounter(); + boxX = 0; + boxY = 0; + boxW = 100; + boxH = 100; + } + + public void paintComponent(Graphics g) { + boxX += xStep; + if (boxX <= 0 || (boxX + boxW) > getWidth()) { + xStep = -xStep; + boxX += (2 * xStep); + } + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(Color.green); + for (int i = 0; i < 100; ++i) { + g.fillRect(boxX, boxY, 100, 100); + } + g.setColor(Color.black); + g.drawString(frameCounter.addFrame(), 200, getHeight() - 30); + } +} + +class AnimatingFrame extends JFrame implements Runnable { + JViewport component; + Thread thread; + + public AnimatingFrame() { + setSize(500, 500); + setTitle("MultimonVImage Demo"); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + component = new AnimatingComponent(); + component.setPreferredSize(new Dimension(500, 500)); + setContentPane(component); + component.setVisible(true); + + setLocationRelativeTo(null); + pack(); + setVisible(true); + } + + public void test() { + thread = new Thread(this); + thread.setPriority(Thread.MIN_PRIORITY); + thread.start(); + } + + public void run() { + Thread me = Thread.currentThread(); + while (thread == me) { + component.repaint(); + } + } +} \ No newline at end of file From 2dee6fbf2e5912ae4ecae923d078dc32602e6b07 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Wed, 28 Feb 2024 07:09:17 +0000 Subject: [PATCH 006/149] 8294156: Allow PassFailJFrame.Builder to create test UI Backport-of: 42b9ac8a07b540f4d7955a778923d24a876451cc --- .../awt/regtesthelpers/PassFailJFrame.java | 481 +++++++++++++++--- 1 file changed, 404 insertions(+), 77 deletions(-) diff --git a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java index 4d8f3c6659c..d2e650b2134 100644 --- a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java +++ b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java @@ -29,19 +29,23 @@ import java.awt.GraphicsEnvironment; import java.awt.Image; import java.awt.Insets; +import java.awt.Point; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.Window; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; import java.awt.image.RenderedImage; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; +import java.util.Objects; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -63,9 +67,83 @@ import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; +import static java.util.Collections.unmodifiableList; import static javax.swing.SwingUtilities.invokeAndWait; import static javax.swing.SwingUtilities.isEventDispatchThread; +/** + * Provides a framework for manual tests to display test instructions and + * Pass/Fail buttons. + *

+ * Instructions for the user can be either plain text or HTML as supported + * by Swing. If the instructions start with {@code }, the + * instructions are displayed as HTML. + *

+ * A simple test would look like this: + *

{@code
+ * public class SampleManualTest {
+ *     private static final String INSTRUCTIONS =
+ *             "Click Pass, or click Fail if the test failed.";
+ *
+ *     public static void main(String[] args) throws Exception {
+ *         PassFailJFrame.builder()
+ *                       .instructions(INSTRUCTIONS)
+ *                       .testUI(() -> createTestUI())
+ *                       .build()
+ *                       .awaitAndCheck();
+ *     }
+ *
+ *     private static List createTestUI() {
+ *         JFrame testUI = new JFrame("Test UI");
+ *         testUI.setSize(250, 150);
+ *         return List.of(testUI);
+ *     }
+ * }
+ * }
+ *

+ * The above example uses the {@link Builder Builder} to set the parameters of + * the instruction frame. It is the recommended way. + *

+ * The framework will create instruction UI, it will call + * the provided {@code createTestUI} on the Event Dispatch Thread (EDT), + * and it will automatically position the test UI and make it visible. + *

+ * Alternatively, use one of the {@code PassFailJFrame} constructors to + * create an object, then create secondary test UI, register it + * with {@code PassFailJFrame}, position it and make it visible. + * The following sample demonstrates it: + *

{@code
+ * public class SampleOldManualTest {
+ *     private static final String INSTRUCTIONS =
+ *             "Click Pass, or click Fail if the test failed.";
+ *
+ *     public static void main(String[] args) throws Exception {
+ *         PassFailJFrame passFail = new PassFailJFrame(INSTRUCTIONS);
+ *
+ *         SwingUtilities.invokeAndWait(() -> createTestUI());
+ *
+ *         passFail.awaitAndCheck();
+ *     }
+ *
+ *     private static void createTestUI() {
+ *         JFrame testUI = new JFrame("Test UI");
+ *         testUI.setSize(250, 150);
+ *         PassFailJFrame.addTestWindow(testUI);
+ *         PassFailJFrame.positionTestWindow(testUI, PassFailJFrame.Position.HORIZONTAL);
+ *         testUI.setVisible(true);
+ *     }
+ * }
+ * }
+ *

+ * Use methods of the {@code Builder} class or constructors of the + * {@code PassFailJFrame} class to control other parameters: + *

    + *
  • the title of the instruction UI,
  • + *
  • the timeout of the test,
  • + *
  • the size of the instruction UI via rows and columns, and
  • + *
  • to enable screenshots.
  • + *
+ */ public class PassFailJFrame { private static final String TITLE = "Test Instruction Frame"; @@ -172,21 +250,67 @@ public PassFailJFrame(String title, String instructions, long testTimeOut, */ public PassFailJFrame(String title, String instructions, long testTimeOut, int rows, int columns, - boolean enableScreenCapture) throws InterruptedException, - InvocationTargetException { - if (isEventDispatchThread()) { - createUI(title, instructions, testTimeOut, rows, columns, - enableScreenCapture); - } else { - invokeAndWait(() -> createUI(title, instructions, testTimeOut, - rows, columns, enableScreenCapture)); - } + boolean enableScreenCapture) + throws InterruptedException, InvocationTargetException { + invokeOnEDT(() -> createUI(title, instructions, + testTimeOut, + rows, columns, + enableScreenCapture)); } private PassFailJFrame(Builder builder) throws InterruptedException, InvocationTargetException { this(builder.title, builder.instructions, builder.testTimeOut, - builder.rows, builder.columns, builder.screenCapture); + builder.rows, builder.columns, builder.screenCapture); + + if (builder.windowCreator != null) { + invokeOnEDT(() -> + builder.testWindows = builder.windowCreator.createTestUI()); + } + + if (builder.testWindows != null) { + addTestWindow(builder.testWindows); + builder.testWindows + .forEach(w -> w.addWindowListener(windowClosingHandler)); + + if (builder.positionWindows != null) { + positionInstructionFrame(builder.position); + invokeOnEDT(() -> { + builder.positionWindows + .positionTestWindows(unmodifiableList(builder.testWindows), + builder.instructionUIHandler); + + windowList.forEach(w -> w.setVisible(true)); + }); + } else if (builder.testWindows.size() == 1) { + Window window = builder.testWindows.get(0); + positionTestWindow(window, builder.position); + window.setVisible(true); + } else { + positionTestWindow(null, builder.position); + } + } + } + + /** + * Performs an operation on EDT. If called on EDT, invokes {@code run} + * directly, otherwise wraps into {@code invokeAndWait}. + * + * @param doRun an operation to run on EDT + * @throws InterruptedException if we're interrupted while waiting for + * the event dispatching thread to finish executing + * {@code doRun.run()} + * @throws InvocationTargetException if an exception is thrown while + * running {@code doRun} + * @see javax.swing.SwingUtilities#invokeAndWait(Runnable) + */ + private static void invokeOnEDT(Runnable doRun) + throws InterruptedException, InvocationTargetException { + if (isEventDispatchThread()) { + doRun.run(); + } else { + invokeAndWait(doRun); + } } private static void createUI(String title, String instructions, @@ -241,16 +365,7 @@ private static void createUI(String title, String instructions, buttonsPanel.add(createCapturePanel()); } - frame.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - super.windowClosing(e); - testFailedReason = FAILURE_REASON - + "User closed the instruction Frame"; - failed = true; - latch.countDown(); - } - }); + frame.addWindowListener(windowClosingHandler); frame.add(buttonsPanel, BorderLayout.SOUTH); frame.pack(); @@ -284,6 +399,101 @@ private static JTextComponent configureHTML(String instructions, return text; } + + /** + * Creates one or more windows for test UI. + */ + @FunctionalInterface + public interface WindowCreator { + /** + * Creates one or more windows for test UI. + * This method is called by the framework on the EDT. + * @return a list of windows. + */ + List createTestUI(); + } + + /** + * Positions test UI windows. + */ + @FunctionalInterface + public interface PositionWindows { + /** + * Positions test UI windows. + * This method is called by the framework on the EDT after + * the instruction UI frame was positioned on the screen. + *

+ * The list of the test windows contains the windows + * that were passed to the framework via + * {@link Builder#testUI(WindowCreator) testUI} method. + * + * @param testWindows the list of test windows + * @param instructionUI information about the instruction frame + */ + void positionTestWindows(List testWindows, + InstructionUI instructionUI); + } + + /** + * Provides information about the instruction frame. + */ + public interface InstructionUI { + /** + * {@return the location of the instruction frame} + */ + Point getLocation(); + + /** + * {@return the size of the instruction frame} + */ + Dimension getSize(); + + /** + * {@return the bounds of the instruction frame} + */ + Rectangle getBounds(); + + /** + * Allows to change the location of the instruction frame. + * + * @param location the new location of the instruction frame + */ + void setLocation(Point location); + + /** + * Allows to change the location of the instruction frame. + * + * @param x the x coordinate of the new location + * @param y the y coordinate of the new location + */ + void setLocation(int x, int y); + + /** + * Returns the specified position that was used to set + * the initial location of the instruction frame. + * + * @return the specified position + * + * @see Position + */ + Position getPosition(); + } + + + private static final class WindowClosingHandler extends WindowAdapter { + @Override + public void windowClosing(WindowEvent e) { + testFailedReason = FAILURE_REASON + + "User closed a window"; + failed = true; + latch.countDown(); + } + } + + private static final WindowListener windowClosingHandler = + new WindowClosingHandler(); + + private static JComponent createCapturePanel() { JComboBox screenShortType = new JComboBox<>(CaptureType.values()); @@ -409,13 +619,11 @@ public void awaitAndCheck() throws InterruptedException, InvocationTargetExcepti } /** - * Dispose all the window(s) i,e both the test instruction frame and - * the window(s) that is added via addTestWindow(Window testWindow) + * Disposes of all the windows. It disposes of the test instruction frame + * and all other windows added via {@link #addTestWindow(Window)}. */ private static synchronized void disposeWindows() { - for (Window win : windowList) { - win.dispose(); - } + windowList.forEach(Window::dispose); } /** @@ -450,6 +658,36 @@ private static void getFailureReason() { latch.countDown(); } + private static void positionInstructionFrame(final Position position) { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + + // Get the screen insets to position the frame by taking into + // account the location of taskbar or menu bar on screen. + GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getDefaultScreenDevice() + .getDefaultConfiguration(); + Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc); + + switch (position) { + case HORIZONTAL: + int newX = ((screenSize.width / 2) - frame.getWidth()); + frame.setLocation((newX + screenInsets.left), + (frame.getY() + screenInsets.top)); + break; + + case VERTICAL: + int newY = ((screenSize.height / 2) - frame.getHeight()); + frame.setLocation((frame.getX() + screenInsets.left), + (newY + screenInsets.top)); + break; + + case TOP_LEFT_CORNER: + frame.setLocation(screenInsets.left, screenInsets.top); + break; + } + syncLocationToWindowManager(); + } + /** * Approximately positions the instruction frame relative to the test * window as specified by the {@code position} parameter. If {@code testWindow} @@ -480,40 +718,23 @@ private static void getFailureReason() { * */ public static void positionTestWindow(Window testWindow, Position position) { - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - // Get the screen insets to position the frame by taking into - // account the location of taskbar/menubars on screen. - GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() - .getDefaultScreenDevice().getDefaultConfiguration(); - Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc); - - if (position.equals(Position.HORIZONTAL)) { - int newX = ((screenSize.width / 2) - frame.getWidth()); - frame.setLocation((newX + screenInsets.left), - (frame.getY() + screenInsets.top)); - syncLocationToWindowManager(); - if (testWindow != null) { - testWindow.setLocation((frame.getX() + frame.getWidth() + 5), - frame.getY()); - } - } else if (position.equals(Position.VERTICAL)) { - int newY = ((screenSize.height / 2) - frame.getHeight()); - frame.setLocation((frame.getX() + screenInsets.left), - (newY + screenInsets.top)); - syncLocationToWindowManager(); - if (testWindow != null) { - testWindow.setLocation(frame.getX(), - (frame.getY() + frame.getHeight() + 5)); - } - } else if (position.equals(Position.TOP_LEFT_CORNER)) { - frame.setLocation(screenInsets.left, screenInsets.top); - syncLocationToWindowManager(); - if (testWindow != null) { - testWindow.setLocation((frame.getX() + frame.getWidth() + 5), - frame.getY()); + positionInstructionFrame(position); + + if (testWindow != null) { + switch (position) { + case HORIZONTAL: + case TOP_LEFT_CORNER: + testWindow.setLocation((frame.getX() + frame.getWidth() + 5), + frame.getY()); + break; + + case VERTICAL: + testWindow.setLocation(frame.getX(), + (frame.getY() + frame.getHeight() + 5)); + break; } } + // make instruction frame visible after updating // frame & window positions frame.setVisible(true); @@ -553,13 +774,7 @@ public static Rectangle getInstructionFrameBounds() throws InterruptedException, InvocationTargetException { final Rectangle[] bounds = {null}; - if (isEventDispatchThread()) { - bounds[0] = frame != null ? frame.getBounds() : null; - } else { - invokeAndWait(() -> { - bounds[0] = frame != null ? frame.getBounds() : null; - }); - } + invokeOnEDT(() -> bounds[0] = frame != null ? frame.getBounds() : null); return bounds[0]; } @@ -574,6 +789,16 @@ public static synchronized void addTestWindow(Window testWindow) { windowList.add(testWindow); } + /** + * Adds a collection of test windows to the windowList to be disposed of + * when the test completes. + * + * @param testWindows the collection of test windows to be disposed of + */ + public static synchronized void addTestWindow(Collection testWindows) { + windowList.addAll(testWindows); + } + /** * Forcibly pass the test. *

The sample usage: @@ -607,13 +832,20 @@ public static void forceFail(String reason) { latch.countDown(); } - public static class Builder { + public static final class Builder { private String title; private String instructions; private long testTimeOut; private int rows; private int columns; - private boolean screenCapture = false; + private boolean screenCapture; + + private List testWindows; + private WindowCreator windowCreator; + private PositionWindows positionWindows; + private InstructionUI instructionUIHandler; + + private Position position; public Builder title(String title) { this.title = title; @@ -645,6 +877,51 @@ public Builder screenCapture() { return this; } + public Builder testUI(Window window) { + return testUI(List.of(window)); + } + + public Builder testUI(Window... windows) { + return testUI(List.of(windows)); + } + + public Builder testUI(List windows) { + if (windows == null) { + throw new IllegalArgumentException("The list of windows can't be null"); + } + if (windows.stream() + .anyMatch(Objects::isNull)) { + throw new IllegalArgumentException("The windows list can't contain null"); + } + + if (windowCreator != null) { + throw new IllegalStateException("windowCreator is already set"); + } + this.testWindows = windows; + return this; + } + + public Builder testUI(WindowCreator windowCreator) { + if (windowCreator == null) { + throw new IllegalArgumentException("The window creator can't be null"); + } + if (testWindows != null) { + throw new IllegalStateException("testWindows are already set"); + } + this.windowCreator = windowCreator; + return this; + } + + public Builder positionTestUI(PositionWindows positionWindows) { + this.positionWindows = positionWindows; + return this; + } + + public Builder position(Position position) { + this.position = position; + return this; + } + public PassFailJFrame build() throws InterruptedException, InvocationTargetException { validate(); @@ -652,26 +929,76 @@ public PassFailJFrame build() throws InterruptedException, } private void validate() { - if (this.title == null) { - this.title = TITLE; + if (title == null) { + title = TITLE; } - if (this.instructions == null || this.instructions.length() == 0) { - throw new RuntimeException("Please provide the test " + - "instruction for this manual test"); + if (instructions == null || instructions.isEmpty()) { + throw new IllegalStateException("Please provide the test " + + "instructions for this manual test"); } - if (this.testTimeOut == 0L) { - this.testTimeOut = TEST_TIMEOUT; + if (testTimeOut == 0L) { + testTimeOut = TEST_TIMEOUT; } - if (this.rows == 0) { - this.rows = ROWS; + if (rows == 0) { + rows = ROWS; } - if (this.columns == 0) { - this.columns = COLUMNS; + if (columns == 0) { + columns = COLUMNS; + } + + if (position == null + && (testWindows != null || windowCreator != null)) { + + position = Position.HORIZONTAL; + } + + if (positionWindows != null) { + if (testWindows == null && windowCreator == null) { + throw new IllegalStateException("To position windows, " + + "provide an a list of windows to the builder"); + } + instructionUIHandler = new InstructionUIHandler(); } } + + private final class InstructionUIHandler implements InstructionUI { + @Override + public Point getLocation() { + return frame.getLocation(); + } + + @Override + public Dimension getSize() { + return frame.getSize(); + } + + @Override + public Rectangle getBounds() { + return frame.getBounds(); + } + + @Override + public void setLocation(Point location) { + setLocation(location.x, location.y); + } + + @Override + public void setLocation(int x, int y) { + frame.setLocation(x, y); + } + + @Override + public Position getPosition() { + return position; + } + } + } + + public static Builder builder() { + return new Builder(); } } From 0e94be627d1f52c994189a844a254c8125633c56 Mon Sep 17 00:00:00 2001 From: Gui Cao Date: Wed, 28 Feb 2024 07:14:00 +0000 Subject: [PATCH 007/149] 8307955: Prefer to PTRACE_GETREGSET instead of PTRACE_GETREGS in method 'ps_proc.c::process_get_lwp_regs' Reviewed-by: fyang, gli Backport-of: 2f1c65486b1e584f9c4a2eb7af2414d032a02748 --- .../linux/native/libsaproc/ps_proc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c index de5254d859e..c22b5d1cb34 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c @@ -142,13 +142,7 @@ static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct use #define PTRACE_GETREGS_REQ PT_GETREGS #endif -#ifdef PTRACE_GETREGS_REQ - if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, user, NULL) < 0) { - print_debug("ptrace(PTRACE_GETREGS, ...) failed for lwp %d\n", pid); - return false; - } - return true; -#elif defined(PTRACE_GETREGSET) +#if defined(PTRACE_GETREGSET) struct iovec iov; iov.iov_base = user; iov.iov_len = sizeof(*user); @@ -157,6 +151,12 @@ static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct use return false; } return true; +#elif defined(PTRACE_GETREGS_REQ) + if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, user, NULL) < 0) { + print_debug("ptrace(PTRACE_GETREGS, ...) failed for lwp %d\n", pid); + return false; + } + return true; #else print_debug("ptrace(PTRACE_GETREGS, ...) not supported\n"); return false; From f2565a6c6f26e84d8e5eede39c0f3a50be5d579f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 28 Feb 2024 07:39:37 +0000 Subject: [PATCH 008/149] 8324723: GHA: Upgrade some actions to avoid deprecated Node 16 Reviewed-by: phh Backport-of: 951b5f8ecb9cd2a72b3904c110179afe487ada2b --- .github/actions/do-build/action.yml | 4 ++-- .github/actions/get-bootjdk/action.yml | 2 +- .github/actions/get-bundles/action.yml | 4 ++-- .github/actions/get-jtreg/action.yml | 2 +- .github/actions/get-msys2/action.yml | 2 +- .github/actions/upload-bundles/action.yml | 2 +- .github/workflows/build-cross-compile.yml | 2 +- .github/workflows/main.yml | 2 +- .github/workflows/test.yml | 4 ++-- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/actions/do-build/action.yml b/.github/actions/do-build/action.yml index 3deb7f4b8f8..79eddf8c70f 100644 --- a/.github/actions/do-build/action.yml +++ b/.github/actions/do-build/action.yml @@ -66,7 +66,7 @@ runs: shell: bash - name: 'Upload build logs' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: failure-logs-${{ inputs.platform }}${{ inputs.debug-suffix }} path: failure-logs @@ -74,7 +74,7 @@ runs: # This is the best way I found to abort the job with an error message - name: 'Notify about build failures' - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: core.setFailed('Build failed. See summary for details.') if: steps.check.outputs.failure == 'true' diff --git a/.github/actions/get-bootjdk/action.yml b/.github/actions/get-bootjdk/action.yml index 1e569dd47c5..25ee1d8dfa0 100644 --- a/.github/actions/get-bootjdk/action.yml +++ b/.github/actions/get-bootjdk/action.yml @@ -65,7 +65,7 @@ runs: - name: 'Check cache for BootJDK' id: get-cached-bootjdk - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: bootjdk/jdk key: boot-jdk-${{ inputs.platform }}-${{ steps.sha256.outputs.value }} diff --git a/.github/actions/get-bundles/action.yml b/.github/actions/get-bundles/action.yml index 956e1520cfb..0e52320a350 100644 --- a/.github/actions/get-bundles/action.yml +++ b/.github/actions/get-bundles/action.yml @@ -48,14 +48,14 @@ runs: steps: - name: 'Download bundles artifact' id: download-bundles - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} path: bundles continue-on-error: true - name: 'Download bundles artifact (retry)' - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} path: bundles diff --git a/.github/actions/get-jtreg/action.yml b/.github/actions/get-jtreg/action.yml index 1a6ffeb126b..ab0927919db 100644 --- a/.github/actions/get-jtreg/action.yml +++ b/.github/actions/get-jtreg/action.yml @@ -41,7 +41,7 @@ runs: - name: 'Check cache for JTReg' id: get-cached-jtreg - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: jtreg/installed key: jtreg-${{ steps.version.outputs.value }} diff --git a/.github/actions/get-msys2/action.yml b/.github/actions/get-msys2/action.yml index f6de676a327..843b77ac064 100644 --- a/.github/actions/get-msys2/action.yml +++ b/.github/actions/get-msys2/action.yml @@ -30,7 +30,7 @@ runs: using: composite steps: - name: 'Install MSYS2' - uses: msys2/setup-msys2@v2 + uses: msys2/setup-msys2@v2.22.0 with: install: 'autoconf tar unzip zip make' path-type: minimal diff --git a/.github/actions/upload-bundles/action.yml b/.github/actions/upload-bundles/action.yml index 88f7f6e8107..b35ee3a42e9 100644 --- a/.github/actions/upload-bundles/action.yml +++ b/.github/actions/upload-bundles/action.yml @@ -69,7 +69,7 @@ runs: shell: bash - name: 'Upload bundles artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} path: bundles diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 88251fded11..7697ab075b2 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -110,7 +110,7 @@ jobs: - name: 'Check cache for sysroot' id: get-cached-sysroot - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: sysroot key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('./.github/workflows/build-cross-compile.yml') }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8d011e4d39d..418dd15df87 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -338,7 +338,7 @@ jobs: # Hack to get hold of the api environment variables that are only defined for actions - name: 'Get API configuration' id: api - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: 'return { url: process.env["ACTIONS_RUNTIME_URL"], token: process.env["ACTIONS_RUNTIME_TOKEN"] }' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 351eb1f6605..95dca32440a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -191,7 +191,7 @@ jobs: if: always() - name: 'Upload test results' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: results name: ${{ steps.package.outputs.artifact-name }} @@ -199,7 +199,7 @@ jobs: # This is the best way I found to abort the job with an error message - name: 'Notify about test failures' - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: core.setFailed('${{ steps.run-tests.outputs.error-message }}') if: steps.run-tests.outputs.failure == 'true' From 61164cef029a4114d4c5d55a590488aac44c1fbd Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 28 Feb 2024 07:41:01 +0000 Subject: [PATCH 009/149] 8305962: update jcstress to 0.16 Backport-of: 292ee630ae32c3b50363b10ffa6090e57ffef1e8 --- .../applications/jcstress/JcstressRunner.java | 28 +++++++++++++++-- .../applications/jcstress/TestGenerator.java | 4 +-- .../applications/jcstress/collections.java | 31 +++++++++++++++++++ .../jtreg/applications/jcstress/mxbeans.java | 31 +++++++++++++++++++ .../jtreg/applications/jcstress/oota.java | 31 +++++++++++++++++++ 5 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 test/hotspot/jtreg/applications/jcstress/collections.java create mode 100644 test/hotspot/jtreg/applications/jcstress/mxbeans.java create mode 100644 test/hotspot/jtreg/applications/jcstress/oota.java diff --git a/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java b/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java index e5d3df3dc0f..37ce9e7df70 100644 --- a/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java +++ b/test/hotspot/jtreg/applications/jcstress/JcstressRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -42,11 +42,15 @@ * jcstress tests wrapper */ @Artifact(organization = "org.openjdk.jcstress", name = "jcstress-tests-all", - revision = "0.5", extension = "jar", unpack = false) + revision = "0.16", extension = "jar", unpack = false) public class JcstressRunner { public static final String MAIN_CLASS = "org.openjdk.jcstress.Main"; + // Allow to configure jcstress mode parameter. + // Test mode preset: sanity, quick, default, tough, stress. + public static final String MODE_PROPERTY = "jcstress.mode"; + public static Path pathToArtifact() { Map artifacts; try { @@ -55,7 +59,7 @@ public static Path pathToArtifact() { throw new Error("TESTBUG: Can not resolve artifacts for " + JcstressRunner.class.getName(), e); } - return artifacts.get("org.openjdk.jcstress.jcstress-tests-all-0.5") + return artifacts.get("org.openjdk.jcstress.jcstress-tests-all-0.16") .toAbsolutePath(); } @@ -104,11 +108,29 @@ private static String[] getCmd(String[] args) { extraFlags.add("--jvmArgs"); extraFlags.add("-Djava.io.tmpdir=" + System.getProperty("user.dir")); + + // The "default" preset might take days for some tests + // so use quick testing by default. + String mode = "quick"; for (String jvmArg : Utils.getTestJavaOpts()) { + if(jvmArg.startsWith("-D" + MODE_PROPERTY)) { + String[] pair = jvmArg.split("=", 2); + mode = pair[1]; + continue; + } extraFlags.add("--jvmArgs"); extraFlags.add(jvmArg); } + extraFlags.add("-m"); + extraFlags.add(mode); + + extraFlags.add("-sc"); + extraFlags.add("false"); + + extraFlags.add("-af"); + extraFlags.add("GLOBAL"); + String[] result = new String[extraFlags.size() + args.length]; extraFlags.toArray(result); System.arraycopy(args, 0, result, extraFlags.size(), args.length); diff --git a/test/hotspot/jtreg/applications/jcstress/TestGenerator.java b/test/hotspot/jtreg/applications/jcstress/TestGenerator.java index fc7a95f1e7c..97cd6a98fd8 100644 --- a/test/hotspot/jtreg/applications/jcstress/TestGenerator.java +++ b/test/hotspot/jtreg/applications/jcstress/TestGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -122,7 +122,7 @@ public static void main(String[] args) throws IOException { BufferedReader reader = Files.newBufferedReader(output); reader.lines() - .skip(4) // skip first 4 lines: name, -{80}, revision and empty line + .filter(s -> s.startsWith("org.openjdk.jcstress.tests")) .map(s -> s.split("\\.")[4]) // group by the package name following "org.openjdk.jcstress.tests." .distinct() .filter(s -> !s.startsWith("sample")) // skip sample test diff --git a/test/hotspot/jtreg/applications/jcstress/collections.java b/test/hotspot/jtreg/applications/jcstress/collections.java new file mode 100644 index 00000000000..176f004495b --- /dev/null +++ b/test/hotspot/jtreg/applications/jcstress/collections.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, 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. + * + * 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. + */ + +/* DO NOT MODIFY THIS FILE. GENERATED BY applications.jcstress.TestGenerator */ + +/** + * @test collections + * @library /test/lib / + * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.collections\. + */ + diff --git a/test/hotspot/jtreg/applications/jcstress/mxbeans.java b/test/hotspot/jtreg/applications/jcstress/mxbeans.java new file mode 100644 index 00000000000..64f5e760f95 --- /dev/null +++ b/test/hotspot/jtreg/applications/jcstress/mxbeans.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, 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. + * + * 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. + */ + +/* DO NOT MODIFY THIS FILE. GENERATED BY applications.jcstress.TestGenerator */ + +/** + * @test mxbeans + * @library /test/lib / + * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.mxbeans\. + */ + diff --git a/test/hotspot/jtreg/applications/jcstress/oota.java b/test/hotspot/jtreg/applications/jcstress/oota.java new file mode 100644 index 00000000000..c558006cc9d --- /dev/null +++ b/test/hotspot/jtreg/applications/jcstress/oota.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, 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. + * + * 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. + */ + +/* DO NOT MODIFY THIS FILE. GENERATED BY applications.jcstress.TestGenerator */ + +/** + * @test oota + * @library /test/lib / + * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.oota\. + */ + From 0ae93db1267ccb76176d191cc454a62d4605fd35 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 29 Feb 2024 10:24:24 +0000 Subject: [PATCH 010/149] 8323717: Introduce test keyword for tests that need external dependencies Reviewed-by: phh Backport-of: 12b89cd2eeb5c2c43a2ce425c96fc4f718e30514 --- test/hotspot/jtreg/TEST.ROOT | 3 ++- test/hotspot/jtreg/applications/jcstress/TestGenerator.java | 1 + test/hotspot/jtreg/applications/jcstress/accessAtomic.java | 3 ++- test/hotspot/jtreg/applications/jcstress/acqrel.java | 3 ++- test/hotspot/jtreg/applications/jcstress/atomicity.java | 3 ++- test/hotspot/jtreg/applications/jcstress/atomics.java | 3 ++- test/hotspot/jtreg/applications/jcstress/causality.java | 3 ++- test/hotspot/jtreg/applications/jcstress/coherence.java | 3 ++- test/hotspot/jtreg/applications/jcstress/collections.java | 3 ++- test/hotspot/jtreg/applications/jcstress/copy.java | 3 ++- test/hotspot/jtreg/applications/jcstress/countdownlatch.java | 3 ++- test/hotspot/jtreg/applications/jcstress/defaultValues.java | 3 ++- test/hotspot/jtreg/applications/jcstress/executors.java | 3 ++- test/hotspot/jtreg/applications/jcstress/fences.java | 3 ++- test/hotspot/jtreg/applications/jcstress/future.java | 3 ++- test/hotspot/jtreg/applications/jcstress/init.java | 3 ++- test/hotspot/jtreg/applications/jcstress/initClass.java | 3 ++- test/hotspot/jtreg/applications/jcstress/initLen.java | 3 ++- test/hotspot/jtreg/applications/jcstress/interrupt.java | 3 ++- test/hotspot/jtreg/applications/jcstress/locks.java | 3 ++- test/hotspot/jtreg/applications/jcstress/memeffects.java | 3 ++- test/hotspot/jtreg/applications/jcstress/mxbeans.java | 3 ++- test/hotspot/jtreg/applications/jcstress/oota.java | 3 ++- test/hotspot/jtreg/applications/jcstress/seqcst.java | 3 ++- test/hotspot/jtreg/applications/jcstress/singletons.java | 3 ++- test/hotspot/jtreg/applications/jcstress/strings.java | 3 ++- test/hotspot/jtreg/applications/jcstress/tearing.java | 3 ++- test/hotspot/jtreg/applications/jcstress/threadlocal.java | 3 ++- test/hotspot/jtreg/applications/jcstress/unsafe.java | 3 ++- test/hotspot/jtreg/applications/jcstress/varhandles.java | 3 ++- test/hotspot/jtreg/applications/jcstress/volatiles.java | 3 ++- test/hotspot/jtreg/applications/scimark/Scimark.java | 1 + 32 files changed, 62 insertions(+), 30 deletions(-) diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT index a3f7f3670e6..2c8021dd76d 100644 --- a/test/hotspot/jtreg/TEST.ROOT +++ b/test/hotspot/jtreg/TEST.ROOT @@ -29,7 +29,8 @@ # The list of keywords supported in this test suite # randomness: test uses randomness, test cases differ from run to run # cgroups: test uses cgroups -keys=cte_test jcmd nmt regression gc stress metaspace headful intermittent randomness cgroups +# external-dep: test requires external dependencies to work +keys=cte_test jcmd nmt regression gc stress metaspace headful intermittent randomness cgroups external-dep groups=TEST.groups TEST.quick-groups diff --git a/test/hotspot/jtreg/applications/jcstress/TestGenerator.java b/test/hotspot/jtreg/applications/jcstress/TestGenerator.java index 97cd6a98fd8..0f5bccfad7e 100644 --- a/test/hotspot/jtreg/applications/jcstress/TestGenerator.java +++ b/test/hotspot/jtreg/applications/jcstress/TestGenerator.java @@ -96,6 +96,7 @@ public class TestGenerator { public static String DESC_FORMAT = "\n" + "/**\n" + " * @test %1$s\n" + + " * @key external-dep\n" + " * @library /test/lib /\n" + " * @run driver/timeout=21600 " + JcstressRunner.class.getName() // verbose output diff --git a/test/hotspot/jtreg/applications/jcstress/accessAtomic.java b/test/hotspot/jtreg/applications/jcstress/accessAtomic.java index cfeb8ff0ea7..45311747023 100644 --- a/test/hotspot/jtreg/applications/jcstress/accessAtomic.java +++ b/test/hotspot/jtreg/applications/jcstress/accessAtomic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test accessAtomic + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.accessAtomic\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/acqrel.java b/test/hotspot/jtreg/applications/jcstress/acqrel.java index 0dd102221b5..8313278053e 100644 --- a/test/hotspot/jtreg/applications/jcstress/acqrel.java +++ b/test/hotspot/jtreg/applications/jcstress/acqrel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test acqrel + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.acqrel\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/atomicity.java b/test/hotspot/jtreg/applications/jcstress/atomicity.java index c6c4263aeb0..abffd4fb3dd 100644 --- a/test/hotspot/jtreg/applications/jcstress/atomicity.java +++ b/test/hotspot/jtreg/applications/jcstress/atomicity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test atomicity + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.atomicity\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/atomics.java b/test/hotspot/jtreg/applications/jcstress/atomics.java index 3527fad666d..449b051efa6 100644 --- a/test/hotspot/jtreg/applications/jcstress/atomics.java +++ b/test/hotspot/jtreg/applications/jcstress/atomics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test atomics + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.atomics\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/causality.java b/test/hotspot/jtreg/applications/jcstress/causality.java index 05ca0dc654a..8cda7d61ade 100644 --- a/test/hotspot/jtreg/applications/jcstress/causality.java +++ b/test/hotspot/jtreg/applications/jcstress/causality.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test causality + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.causality\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/coherence.java b/test/hotspot/jtreg/applications/jcstress/coherence.java index f8368834ac4..c2630c2dd66 100644 --- a/test/hotspot/jtreg/applications/jcstress/coherence.java +++ b/test/hotspot/jtreg/applications/jcstress/coherence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test coherence + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.coherence\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/collections.java b/test/hotspot/jtreg/applications/jcstress/collections.java index 176f004495b..b1363b25168 100644 --- a/test/hotspot/jtreg/applications/jcstress/collections.java +++ b/test/hotspot/jtreg/applications/jcstress/collections.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test collections + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.collections\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/copy.java b/test/hotspot/jtreg/applications/jcstress/copy.java index b291dbe7cde..a2d0d6f099f 100644 --- a/test/hotspot/jtreg/applications/jcstress/copy.java +++ b/test/hotspot/jtreg/applications/jcstress/copy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test copy + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.copy\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/countdownlatch.java b/test/hotspot/jtreg/applications/jcstress/countdownlatch.java index 290ec80cc8c..cee4f917c6f 100644 --- a/test/hotspot/jtreg/applications/jcstress/countdownlatch.java +++ b/test/hotspot/jtreg/applications/jcstress/countdownlatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test countdownlatch + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.countdownlatch\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/defaultValues.java b/test/hotspot/jtreg/applications/jcstress/defaultValues.java index c86529491b9..8fce07d8063 100644 --- a/test/hotspot/jtreg/applications/jcstress/defaultValues.java +++ b/test/hotspot/jtreg/applications/jcstress/defaultValues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test defaultValues + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.defaultValues\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/executors.java b/test/hotspot/jtreg/applications/jcstress/executors.java index b29bbb6507c..f2f50978404 100644 --- a/test/hotspot/jtreg/applications/jcstress/executors.java +++ b/test/hotspot/jtreg/applications/jcstress/executors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test executors + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.executors\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/fences.java b/test/hotspot/jtreg/applications/jcstress/fences.java index 5bca0257717..d2925a0a101 100644 --- a/test/hotspot/jtreg/applications/jcstress/fences.java +++ b/test/hotspot/jtreg/applications/jcstress/fences.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test fences + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.fences\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/future.java b/test/hotspot/jtreg/applications/jcstress/future.java index eea5b7de64c..5bc760fe2f5 100644 --- a/test/hotspot/jtreg/applications/jcstress/future.java +++ b/test/hotspot/jtreg/applications/jcstress/future.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test future + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.future\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/init.java b/test/hotspot/jtreg/applications/jcstress/init.java index 625037b8f94..087956881d3 100644 --- a/test/hotspot/jtreg/applications/jcstress/init.java +++ b/test/hotspot/jtreg/applications/jcstress/init.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test init + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.init\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/initClass.java b/test/hotspot/jtreg/applications/jcstress/initClass.java index 5a0e70f19ac..5b936ce46cd 100644 --- a/test/hotspot/jtreg/applications/jcstress/initClass.java +++ b/test/hotspot/jtreg/applications/jcstress/initClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test initClass + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.initClass\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/initLen.java b/test/hotspot/jtreg/applications/jcstress/initLen.java index 4cb040bf878..01ef04b8a13 100644 --- a/test/hotspot/jtreg/applications/jcstress/initLen.java +++ b/test/hotspot/jtreg/applications/jcstress/initLen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test initLen + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.initLen\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/interrupt.java b/test/hotspot/jtreg/applications/jcstress/interrupt.java index 8e4d2ad0fba..1a9ecc357d4 100644 --- a/test/hotspot/jtreg/applications/jcstress/interrupt.java +++ b/test/hotspot/jtreg/applications/jcstress/interrupt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test interrupt + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.interrupt\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/locks.java b/test/hotspot/jtreg/applications/jcstress/locks.java index 7450e295094..e3e11633323 100644 --- a/test/hotspot/jtreg/applications/jcstress/locks.java +++ b/test/hotspot/jtreg/applications/jcstress/locks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test locks + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.locks\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/memeffects.java b/test/hotspot/jtreg/applications/jcstress/memeffects.java index d4e1b0e26ce..6be6d180939 100644 --- a/test/hotspot/jtreg/applications/jcstress/memeffects.java +++ b/test/hotspot/jtreg/applications/jcstress/memeffects.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test memeffects + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.memeffects\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/mxbeans.java b/test/hotspot/jtreg/applications/jcstress/mxbeans.java index 64f5e760f95..4714b335bdd 100644 --- a/test/hotspot/jtreg/applications/jcstress/mxbeans.java +++ b/test/hotspot/jtreg/applications/jcstress/mxbeans.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test mxbeans + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.mxbeans\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/oota.java b/test/hotspot/jtreg/applications/jcstress/oota.java index c558006cc9d..6c21e76a7e9 100644 --- a/test/hotspot/jtreg/applications/jcstress/oota.java +++ b/test/hotspot/jtreg/applications/jcstress/oota.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test oota + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.oota\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/seqcst.java b/test/hotspot/jtreg/applications/jcstress/seqcst.java index 7b0bae61855..def96932d7e 100644 --- a/test/hotspot/jtreg/applications/jcstress/seqcst.java +++ b/test/hotspot/jtreg/applications/jcstress/seqcst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test seqcst + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.seqcst\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/singletons.java b/test/hotspot/jtreg/applications/jcstress/singletons.java index 1ddaaff4c68..9714dc0ea1d 100644 --- a/test/hotspot/jtreg/applications/jcstress/singletons.java +++ b/test/hotspot/jtreg/applications/jcstress/singletons.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test singletons + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.singletons\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/strings.java b/test/hotspot/jtreg/applications/jcstress/strings.java index 76ed85ab65f..caacea9bcc7 100644 --- a/test/hotspot/jtreg/applications/jcstress/strings.java +++ b/test/hotspot/jtreg/applications/jcstress/strings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test strings + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.strings\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/tearing.java b/test/hotspot/jtreg/applications/jcstress/tearing.java index 3b9c96351c1..a55d43964b7 100644 --- a/test/hotspot/jtreg/applications/jcstress/tearing.java +++ b/test/hotspot/jtreg/applications/jcstress/tearing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test tearing + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.tearing\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/threadlocal.java b/test/hotspot/jtreg/applications/jcstress/threadlocal.java index 4abc459224f..9103b90594a 100644 --- a/test/hotspot/jtreg/applications/jcstress/threadlocal.java +++ b/test/hotspot/jtreg/applications/jcstress/threadlocal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test threadlocal + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.threadlocal\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/unsafe.java b/test/hotspot/jtreg/applications/jcstress/unsafe.java index 2983d4e8e04..8be919b0c3b 100644 --- a/test/hotspot/jtreg/applications/jcstress/unsafe.java +++ b/test/hotspot/jtreg/applications/jcstress/unsafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test unsafe + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.unsafe\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/varhandles.java b/test/hotspot/jtreg/applications/jcstress/varhandles.java index 389714c32a8..af9b4271157 100644 --- a/test/hotspot/jtreg/applications/jcstress/varhandles.java +++ b/test/hotspot/jtreg/applications/jcstress/varhandles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test varhandles + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.varhandles\. */ diff --git a/test/hotspot/jtreg/applications/jcstress/volatiles.java b/test/hotspot/jtreg/applications/jcstress/volatiles.java index 085289fad24..2f1f015b8d5 100644 --- a/test/hotspot/jtreg/applications/jcstress/volatiles.java +++ b/test/hotspot/jtreg/applications/jcstress/volatiles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -25,6 +25,7 @@ /** * @test volatiles + * @key external-dep * @library /test/lib / * @run driver/timeout=21600 applications.jcstress.JcstressRunner -v -t org.openjdk.jcstress.tests.volatiles\. */ diff --git a/test/hotspot/jtreg/applications/scimark/Scimark.java b/test/hotspot/jtreg/applications/scimark/Scimark.java index 8aab97aa2bc..24691939dd6 100644 --- a/test/hotspot/jtreg/applications/scimark/Scimark.java +++ b/test/hotspot/jtreg/applications/scimark/Scimark.java @@ -23,6 +23,7 @@ /* * @test + * @key external-dep * @library /test/lib * @run driver Scimark */ From b183cd239933552e1af8c890628b0bdee6ba21e7 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 29 Feb 2024 10:44:14 +0000 Subject: [PATCH 011/149] 8314552: Fix javadoc tests to work with jtreg 7 Reviewed-by: phh Backport-of: e83046409d81d074cd68dc823e794a852ed93cee --- .../doclet/testSerialVersionUID/TestSerialVersionUID.java | 5 +++-- .../jdk/javadoc/doclet/testTagMisuse/TestTagMisuse.java | 5 +++-- .../jdk/javadoc/doclet/testThrowsHead/TestThrowsHead.java | 5 +++-- .../doclet/testUnnamedPackage/TestUnnamedPackage.java | 5 +++-- test/langtools/jdk/javadoc/tool/nonConstExprs/Test.java | 3 ++- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/test/langtools/jdk/javadoc/doclet/testSerialVersionUID/TestSerialVersionUID.java b/test/langtools/jdk/javadoc/doclet/testSerialVersionUID/TestSerialVersionUID.java index 6e06fce1d82..1d22b44ebdd 100644 --- a/test/langtools/jdk/javadoc/doclet/testSerialVersionUID/TestSerialVersionUID.java +++ b/test/langtools/jdk/javadoc/doclet/testSerialVersionUID/TestSerialVersionUID.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -42,7 +42,8 @@ public static void main(String... args) throws Exception { @Test void test() { - javadoc("-d", "out", + javadoc("-encoding", "UTF-8", + "-d", "out", testSrc("C.java")); checkExit(Exit.OK); diff --git a/test/langtools/jdk/javadoc/doclet/testTagMisuse/TestTagMisuse.java b/test/langtools/jdk/javadoc/doclet/testTagMisuse/TestTagMisuse.java index 473231e7de2..ca8a53f0980 100644 --- a/test/langtools/jdk/javadoc/doclet/testTagMisuse/TestTagMisuse.java +++ b/test/langtools/jdk/javadoc/doclet/testTagMisuse/TestTagMisuse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -45,7 +45,8 @@ public static void main(String... args) throws Exception { @Test void test() { - javadoc("-Xdoclint:none", + javadoc("-encoding", "UTF-8", + "-Xdoclint:none", "-d", "out", testSrc("TestTagMisuse.java")); checkExit(Exit.OK); diff --git a/test/langtools/jdk/javadoc/doclet/testThrowsHead/TestThrowsHead.java b/test/langtools/jdk/javadoc/doclet/testThrowsHead/TestThrowsHead.java index e73e6bdaa37..f3917c1c954 100644 --- a/test/langtools/jdk/javadoc/doclet/testThrowsHead/TestThrowsHead.java +++ b/test/langtools/jdk/javadoc/doclet/testThrowsHead/TestThrowsHead.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -43,7 +43,8 @@ public static void main(String... args) throws Exception { @Test void test() { - javadoc("-d", "out", + javadoc("-encoding", "UTF-8", + "-d", "out", testSrc("C.java")); checkExit(Exit.OK); diff --git a/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java b/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java index b12b7f2d7f8..35dc6ce9da2 100644 --- a/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java +++ b/test/langtools/jdk/javadoc/doclet/testUnnamedPackage/TestUnnamedPackage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -42,7 +42,8 @@ public static void main(String... args) throws Exception { @Test void test() { - javadoc("-d", "out", + javadoc("-encoding", "UTF-8", + "-d", "out", "-sourcepath", testSrc, testSrc("C.java")); checkExit(Exit.OK); diff --git a/test/langtools/jdk/javadoc/tool/nonConstExprs/Test.java b/test/langtools/jdk/javadoc/tool/nonConstExprs/Test.java index 889945b236d..f03c928849a 100644 --- a/test/langtools/jdk/javadoc/tool/nonConstExprs/Test.java +++ b/test/langtools/jdk/javadoc/tool/nonConstExprs/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -34,6 +34,7 @@ public class Test { public static void main(String... args) throws Exception { File testSrc = new File(System.getProperty("test.src")); String[] jdoc_args = { + "-encoding", "UTF-8", "-d", "out", new File(testSrc, Test.class.getSimpleName() + ".java").getPath() }; From a582e1180cd61b81407c4d9b0d64d343e716ff12 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 4 Mar 2024 08:31:15 +0000 Subject: [PATCH 012/149] 8281507: Two javac tests have bad jtreg `@clean` tags Reviewed-by: mbaesken Backport-of: 86723d4892485651bcae735ed13545ea89b9bb22 --- .../tools/javac/8074306/TestSyntheticNullChecks.java | 4 ++-- .../javac/StringConcat/TestIndyStringConcat.java | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/langtools/tools/javac/8074306/TestSyntheticNullChecks.java b/test/langtools/tools/javac/8074306/TestSyntheticNullChecks.java index 9ba6ebf529e..ddc0a4da416 100644 --- a/test/langtools/tools/javac/8074306/TestSyntheticNullChecks.java +++ b/test/langtools/tools/javac/8074306/TestSyntheticNullChecks.java @@ -27,10 +27,10 @@ * @summary NULLCHK is emitted as Object.getClass * @compile -source 6 -target 6 TestSyntheticNullChecks.java * @run main TestSyntheticNullChecks 6 - * @clean TestSyntheticNullChecks* + * @clean * * @compile -source 7 -target 7 TestSyntheticNullChecks.java * @run main TestSyntheticNullChecks 7 - * @clean TestSyntheticNullChecks* + * @clean * * @compile TestSyntheticNullChecks.java * @run main TestSyntheticNullChecks 9 */ diff --git a/test/langtools/tools/javac/StringConcat/TestIndyStringConcat.java b/test/langtools/tools/javac/StringConcat/TestIndyStringConcat.java index 4c8917bbbf9..9910bd6d2dd 100644 --- a/test/langtools/tools/javac/StringConcat/TestIndyStringConcat.java +++ b/test/langtools/tools/javac/StringConcat/TestIndyStringConcat.java @@ -34,27 +34,27 @@ * @summary Test that StringConcat is working for JDK >= 9 * @modules jdk.jdeps/com.sun.tools.classfile * - * @clean TestIndyStringConcat* + * @clean * * @compile -source 6 -target 6 TestIndyStringConcat.java * @run main TestIndyStringConcat false * - * @clean TestIndyStringConcat* + * @clean * * @compile -source 7 -target 7 TestIndyStringConcat.java * @run main TestIndyStringConcat false * - * @clean TestIndyStringConcat* + * @clean * * @compile -source 8 -target 8 TestIndyStringConcat.java * @run main TestIndyStringConcat false * - * @clean TestIndyStringConcat* + * @clean * * @compile -XDstringConcat=inline -source 9 -target 9 TestIndyStringConcat.java * @run main TestIndyStringConcat false * - * @clean TestIndyStringConcat* + * @clean * * @compile -XDstringConcat=indy -source 9 -target 9 TestIndyStringConcat.java * @run main TestIndyStringConcat true * - * @clean TestIndyStringConcat* + * @clean * * @compile -XDstringConcat=indyWithConstants -source 9 -target 9 TestIndyStringConcat.java * @run main TestIndyStringConcat true */ From f6e6eefcc10f85ee289bbcc8de9caba1c915beeb Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 4 Mar 2024 08:32:47 +0000 Subject: [PATCH 013/149] 8326938: [11u] JDK-8214908 broke two CTW tests Reviewed-by: phh --- test/hotspot/jtreg/applications/ctw/modules/jdk_jfr.java | 3 +-- .../jtreg/applications/ctw/modules/jdk_management_jfr.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/applications/ctw/modules/jdk_jfr.java b/test/hotspot/jtreg/applications/ctw/modules/jdk_jfr.java index b40af761d86..0fa9d3c8ac3 100644 --- a/test/hotspot/jtreg/applications/ctw/modules/jdk_jfr.java +++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_jfr.java @@ -26,8 +26,7 @@ * @summary run CTW for all classes from jdk.jfr module * * @library /test/lib / /testlibrary/ctw/src - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.jimage + * @modules java.base/jdk.internal.jimage * java.base/jdk.internal.misc * java.base/jdk.internal.reflect * @modules jdk.jfr diff --git a/test/hotspot/jtreg/applications/ctw/modules/jdk_management_jfr.java b/test/hotspot/jtreg/applications/ctw/modules/jdk_management_jfr.java index d24f4068118..f97131a9a56 100644 --- a/test/hotspot/jtreg/applications/ctw/modules/jdk_management_jfr.java +++ b/test/hotspot/jtreg/applications/ctw/modules/jdk_management_jfr.java @@ -26,8 +26,7 @@ * @summary run CTW for all classes from jdk.management.jfr module * * @library /test/lib / /testlibrary/ctw/src - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.jimage + * @modules java.base/jdk.internal.jimage * java.base/jdk.internal.misc * java.base/jdk.internal.reflect * @modules jdk.management.jfr From a4a5c7fe66679ce4d9022443e3cd1f9ec38059ac Mon Sep 17 00:00:00 2001 From: Jiawei Tang Date: Mon, 4 Mar 2024 14:48:13 +0000 Subject: [PATCH 014/149] 8276125: RunThese24H.java SIGSEGV in JfrThreadGroup::thread_group_id Reviewed-by: mgronlun Backport-of: a885aab696777c99c8c4c5d9a46afc5fe0a4fe47 --- .../share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp index b2ae0d7782a..9eff4c562a2 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrThreadGroup.cpp @@ -150,8 +150,12 @@ int JfrThreadGroupsHelper::populate_thread_group_hierarchy(const JavaThread* jt, assert(current != NULL, "invariant"); assert(_thread_group_hierarchy != NULL, "invariant"); + oop thread_oop = jt->threadObj(); + if (thread_oop == NULL) { + return 0; + } // immediate thread group - Handle thread_group_handle(current, java_lang_Thread::threadGroup(jt->threadObj())); + Handle thread_group_handle(current, java_lang_Thread::threadGroup(thread_oop)); if (thread_group_handle == NULL) { return 0; } From 6c0a88d905ce068045cc3ff02891b48372b4c8c7 Mon Sep 17 00:00:00 2001 From: Zhang Quan Date: Wed, 6 Mar 2024 11:50:41 +0000 Subject: [PATCH 015/149] 8271142: package help is not displayed for missing X11/extensions/Xrandr.h Reviewed-by: clanger Backport-of: b7f75c0a735f0cf40ae2288d1d0ae96a571a4155 --- make/autoconf/help.m4 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/make/autoconf/help.m4 b/make/autoconf/help.m4 index 7789a1c5bb3..bd0cb26282d 100644 --- a/make/autoconf/help.m4 +++ b/make/autoconf/help.m4 @@ -40,21 +40,21 @@ AC_DEFUN([HELP_MSG_MISSING_DEPENDENCY], PKGHANDLER_COMMAND= case $PKGHANDLER in - apt-get) + *apt-get) apt_help $MISSING_DEPENDENCY ;; - yum) + *yum) yum_help $MISSING_DEPENDENCY ;; - brew) + *brew) brew_help $MISSING_DEPENDENCY ;; - port) + *port) port_help $MISSING_DEPENDENCY ;; - pkgutil) + *pkgutil) pkgutil_help $MISSING_DEPENDENCY ;; - pkgadd) + *pkgadd) pkgadd_help $MISSING_DEPENDENCY ;; - pacman) + *pacman) pacman_help $MISSING_DEPENDENCY ;; - apk) + *apk) apk_help $MISSING_DEPENDENCY ;; esac From 4ef8db867145f24062fe7c774653aadbebc4dc84 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Thu, 7 Mar 2024 08:04:09 +0000 Subject: [PATCH 016/149] 8318580: "javax/swing/MultiMonitor/MultimonVImage.java failing with Error. Can't find library: /open/test/jdk/java/awt/regtesthelpers" after JDK-8316053 Backport-of: e4803e0cbf00da89b98c8703769edc403bb5055b --- test/jdk/javax/swing/MultiMonitor/MultimonVImage.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/jdk/javax/swing/MultiMonitor/MultimonVImage.java b/test/jdk/javax/swing/MultiMonitor/MultimonVImage.java index 730424e306c..42cb9c96da5 100644 --- a/test/jdk/javax/swing/MultiMonitor/MultimonVImage.java +++ b/test/jdk/javax/swing/MultiMonitor/MultimonVImage.java @@ -28,7 +28,8 @@ * @summary displays an animating fps (frames per second) * counter. When the window is dragged from monitor to monitor, * the speed of the animation should not change too greatly. - * @library /open/test/jdk/java/awt/regtesthelpers + * @library /java/awt/regtesthelpers + * @build PassFailJFrame * @run main/manual MultimonVImage */ @@ -180,4 +181,5 @@ public void run() { component.repaint(); } } -} \ No newline at end of file +} + From bc14b9f12e00b16194e228b315bc08a878d314d4 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Thu, 7 Mar 2024 08:06:50 +0000 Subject: [PATCH 017/149] 8326638: Crash in PhaseIdealLoop::remix_address_expressions due to unexpected Region instead of Loop Backport-of: 9f0e7da64e21237322e55ca4f0e3639fa5d1c4ed --- src/hotspot/share/opto/loopopts.cpp | 6 +- ...AddressExpressionsWithIrreducibleLoop.java | 57 +++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/loopopts/TestRemixAddressExpressionsWithIrreducibleLoop.java diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index b9db718b390..a5cb6342647 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, 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 @@ -492,8 +492,8 @@ Node *PhaseIdealLoop::remix_address_expressions( Node *n ) { } // Replace ((I1 +p V) +p I2) with ((I1 +p I2) +p V), - // but not if I2 is a constant. - if( n_op == Op_AddP ) { + // but not if I2 is a constant. Skip for irreducible loops. + if (n_op == Op_AddP && n_loop->_head->is_Loop()) { if( n2_loop == n_loop && n3_loop != n_loop ) { if( n->in(2)->Opcode() == Op_AddP && !n->in(3)->is_Con() ) { Node *n22_ctrl = get_ctrl(n->in(2)->in(2)); diff --git a/test/hotspot/jtreg/compiler/loopopts/TestRemixAddressExpressionsWithIrreducibleLoop.java b/test/hotspot/jtreg/compiler/loopopts/TestRemixAddressExpressionsWithIrreducibleLoop.java new file mode 100644 index 00000000000..ff7be96007d --- /dev/null +++ b/test/hotspot/jtreg/compiler/loopopts/TestRemixAddressExpressionsWithIrreducibleLoop.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024, 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. + * + * 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. + * + */ + +/* + * @test + * @bug 8326638 + * @summary Test handling of irreducible loops in PhaseIdealLoop::remix_address_expressions. + * @run main/othervm -XX:-TieredCompilation -Xbatch + * -XX:CompileCommand=compileonly,TestRemixAddressExpressionsWithIrreducibleLoop::test + * TestRemixAddressExpressionsWithIrreducibleLoop + */ + +public class TestRemixAddressExpressionsWithIrreducibleLoop { + + public static void main(String[] args) { + test("4"); + } + + public static void test(String arg) { + for (int i = 0; i < 100_000; ++i) { + int j = 0; + while (true) { + boolean tmp = "1\ufff0".startsWith(arg, 2 - arg.length()); + if (j++ > 100) + break; + } + loop: + while (i >= 100) { + for (int i2 = 0; i2 < 1; i2 = 1) + if (j > 300) + break loop; + j++; + } + } + } +} From b425dff6bbec035b18606be45800e621219a15df Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Thu, 7 Mar 2024 08:07:24 +0000 Subject: [PATCH 018/149] 8320303: Allow PassFailJFrame to accept single window creator Backport-of: 83ffc1ac94b8893532d8663b9058592f1714d337 --- .../awt/regtesthelpers/PassFailJFrame.java | 173 +++++++++++++++--- 1 file changed, 146 insertions(+), 27 deletions(-) diff --git a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java index d2e650b2134..94d6c2e4967 100644 --- a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java +++ b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java @@ -93,10 +93,10 @@ * .awaitAndCheck(); * } * - * private static List createTestUI() { + * private static Window createTestUI() { * JFrame testUI = new JFrame("Test UI"); * testUI.setSize(250, 150); - * return List.of(testUI); + * return testUI; * } * } * } @@ -108,6 +108,10 @@ * the provided {@code createTestUI} on the Event Dispatch Thread (EDT), * and it will automatically position the test UI and make it visible. *

+ * The {@code Builder.testUI} methods accept interfaces which create one window + * or a list of windows if the test needs multiple windows, + * or directly a single window, an array of windows or a list of windows. + *

* Alternatively, use one of the {@code PassFailJFrame} constructors to * create an object, then create secondary test UI, register it * with {@code PassFailJFrame}, position it and make it visible. @@ -144,7 +148,7 @@ *

  • to enable screenshots.
  • * */ -public class PassFailJFrame { +public final class PassFailJFrame { private static final String TITLE = "Test Instruction Frame"; private static final long TEST_TIMEOUT = 5; @@ -263,12 +267,18 @@ private PassFailJFrame(Builder builder) throws InterruptedException, this(builder.title, builder.instructions, builder.testTimeOut, builder.rows, builder.columns, builder.screenCapture); - if (builder.windowCreator != null) { + if (builder.windowListCreator != null) { invokeOnEDT(() -> - builder.testWindows = builder.windowCreator.createTestUI()); + builder.testWindows = builder.windowListCreator.createTestUI()); + if (builder.testWindows == null) { + throw new IllegalStateException("Window list creator returned null list"); + } } if (builder.testWindows != null) { + if (builder.testWindows.isEmpty()) { + throw new IllegalStateException("Window list is empty"); + } addTestWindow(builder.testWindows); builder.testWindows .forEach(w -> w.addWindowListener(windowClosingHandler)); @@ -279,17 +289,15 @@ private PassFailJFrame(Builder builder) throws InterruptedException, builder.positionWindows .positionTestWindows(unmodifiableList(builder.testWindows), builder.instructionUIHandler); - - windowList.forEach(w -> w.setVisible(true)); }); } else if (builder.testWindows.size() == 1) { Window window = builder.testWindows.get(0); positionTestWindow(window, builder.position); - window.setVisible(true); } else { positionTestWindow(null, builder.position); } } + showAllWindows(); } /** @@ -370,7 +378,7 @@ private static void createUI(String title, String instructions, frame.add(buttonsPanel, BorderLayout.SOUTH); frame.pack(); frame.setLocationRelativeTo(null); - windowList.add(frame); + addTestWindow(frame); } private static JTextComponent configurePlainText(String instructions, @@ -401,14 +409,27 @@ private static JTextComponent configureHTML(String instructions, /** - * Creates one or more windows for test UI. + * Creates a test UI window. */ @FunctionalInterface public interface WindowCreator { + /** + * Creates a window for test UI. + * This method is called by the framework on the EDT. + * @return a test UI window + */ + Window createTestUI(); + } + + /** + * Creates a list of test UI windows. + */ + @FunctionalInterface + public interface WindowListCreator { /** * Creates one or more windows for test UI. * This method is called by the framework on the EDT. - * @return a list of windows. + * @return a list of test UI windows */ List createTestUI(); } @@ -424,8 +445,13 @@ public interface PositionWindows { * the instruction UI frame was positioned on the screen. *

    * The list of the test windows contains the windows - * that were passed to the framework via - * {@link Builder#testUI(WindowCreator) testUI} method. + * that were passed to the framework via the + * {@link Builder#testUI(Window...) testUI(Window...)} method or + * that were created with {@code WindowCreator} + * or {@code WindowListCreator} which were passed via + * {@link Builder#testUI(WindowCreator) testUI(WindowCreator)} or + * {@link Builder#testUI(WindowListCreator) testUI(WindowListCreator)} + * correspondingly. * * @param testWindows the list of test windows * @param instructionUI information about the instruction frame @@ -799,6 +825,29 @@ public static synchronized void addTestWindow(Collection testW windowList.addAll(testWindows); } + /** + * Displays all the windows in {@code windowList}. + * + * @throws InterruptedException if the thread is interrupted while + * waiting for the event dispatch thread to finish running + * the {@link #showUI() showUI} + * @throws InvocationTargetException if an exception is thrown while + * the event dispatch thread executes {@code showUI} + */ + private static void showAllWindows() + throws InterruptedException, InvocationTargetException { + invokeOnEDT(PassFailJFrame::showUI); + } + + /** + * Displays all the windows in {@code windowList}; it has to be called on + * the EDT — use {@link #showAllWindows() showAllWindows} to ensure it. + */ + private static synchronized void showUI() { + windowList.forEach(w -> w.setVisible(true)); + } + + /** * Forcibly pass the test. *

    The sample usage: @@ -841,7 +890,7 @@ public static final class Builder { private boolean screenCapture; private List testWindows; - private WindowCreator windowCreator; + private WindowListCreator windowListCreator; private PositionWindows positionWindows; private InstructionUI instructionUIHandler; @@ -877,39 +926,109 @@ public Builder screenCapture() { return this; } + /** + * Adds a {@code WindowCreator} which the framework will use + * to create the test UI window. + * + * @param windowCreator a {@code WindowCreator} + * to create the test UI window + * @return this builder + * @throws IllegalArgumentException if {@code windowCreator} is {@code null} + * @throws IllegalStateException if a window creator + * or a list of test windows is already set + */ + public Builder testUI(WindowCreator windowCreator) { + if (windowCreator == null) { + throw new IllegalArgumentException("The window creator can't be null"); + } + + checkWindowsLists(); + + this.windowListCreator = () -> List.of(windowCreator.createTestUI()); + return this; + } + + /** + * Adds a {@code WindowListCreator} which the framework will use + * to create a list of test UI windows. + * + * @param windowListCreator a {@code WindowListCreator} + * to create test UI windows + * @return this builder + * @throws IllegalArgumentException if {@code windowListCreator} is {@code null} + * @throws IllegalStateException if a window creator + * or a list of test windows is already set + */ + public Builder testUI(WindowListCreator windowListCreator) { + if (windowListCreator == null) { + throw new IllegalArgumentException("The window list creator can't be null"); + } + + checkWindowsLists(); + + this.windowListCreator = windowListCreator; + return this; + } + + /** + * Adds an already created test UI window. + * The window is positioned and shown automatically. + * + * @param window a test UI window + * @return this builder + */ public Builder testUI(Window window) { return testUI(List.of(window)); } + /** + * Adds an array of already created test UI windows. + * + * @param windows an array of test UI windows + * @return this builder + */ public Builder testUI(Window... windows) { return testUI(List.of(windows)); } - public Builder testUI(List windows) { + /** + * Adds a list of already created test UI windows. + * + * @param windows a list of test UI windows + * @return this builder + * @throws IllegalArgumentException if {@code windows} is {@code null} + * or the list contains {@code null} + * @throws IllegalStateException if a window creator + * or a list of test windows is already set + */ + public Builder testUI(List windows) { if (windows == null) { throw new IllegalArgumentException("The list of windows can't be null"); } if (windows.stream() .anyMatch(Objects::isNull)) { - throw new IllegalArgumentException("The windows list can't contain null"); + throw new IllegalArgumentException("The list of windows can't contain null"); } - if (windowCreator != null) { - throw new IllegalStateException("windowCreator is already set"); - } + checkWindowsLists(); + this.testWindows = windows; return this; } - public Builder testUI(WindowCreator windowCreator) { - if (windowCreator == null) { - throw new IllegalArgumentException("The window creator can't be null"); + /** + * Verifies the state of window list and window creator. + * + * @throws IllegalStateException if a windows list creator + * or a list of test windows is already set + */ + private void checkWindowsLists() { + if (windowListCreator != null) { + throw new IllegalStateException("Window list creator is already set"); } if (testWindows != null) { - throw new IllegalStateException("testWindows are already set"); + throw new IllegalStateException("The list of test windows is already set"); } - this.windowCreator = windowCreator; - return this; } public Builder positionTestUI(PositionWindows positionWindows) { @@ -951,13 +1070,13 @@ private void validate() { } if (position == null - && (testWindows != null || windowCreator != null)) { + && (testWindows != null || windowListCreator != null)) { position = Position.HORIZONTAL; } if (positionWindows != null) { - if (testWindows == null && windowCreator == null) { + if (testWindows == null && windowListCreator == null) { throw new IllegalStateException("To position windows, " + "provide an a list of windows to the builder"); } From f3069d13d23301405b096db6d4843500a5f5fa56 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Thu, 7 Mar 2024 08:07:57 +0000 Subject: [PATCH 019/149] 8325972: Add -x to bash for building with LOG=debug Backport-of: 8668198c26bdac412f0a9d1255ca74da860761c5 --- make/common/MakeBase.gmk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index dd81ba3484c..6a300a58a33 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2024, 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 @@ -153,6 +153,10 @@ define SetupLogging endif endif + ifneq ($$(findstring $$(LOG_LEVEL), debug trace),) + SHELL := $$(SHELL) -x + endif + ifeq ($$(LOG_LEVEL), trace) SHELL_NO_RECURSE := $$(SHELL) # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make From 7b7fbdf6159baceb83640786928d00b838be1a3a Mon Sep 17 00:00:00 2001 From: Ao Qi Date: Thu, 7 Mar 2024 20:07:14 +0000 Subject: [PATCH 020/149] 8267938: (sctp) SCTP channel factory methods should check platform support Backport-of: bd31653e6f99d4337e4af1f7f138d688ec99c19d --- src/jdk.sctp/unix/native/libsctp/SctpNet.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/jdk.sctp/unix/native/libsctp/SctpNet.c b/src/jdk.sctp/unix/native/libsctp/SctpNet.c index afc06be0a27..30992f815e3 100644 --- a/src/jdk.sctp/unix/native/libsctp/SctpNet.c +++ b/src/jdk.sctp/unix/native/libsctp/SctpNet.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2021, 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 @@ -190,7 +190,13 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpNet_socket0 fd = socket(domain, (oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP); if (fd < 0) { - return handleSocketError(env, errno); + if (errno == EPROTONOSUPPORT || errno == ESOCKTNOSUPPORT) { + JNU_ThrowByNameWithLastError(env, "java/lang/UnsupportedOperationException", + "Protocol not supported"); + return IOS_THROWN; + } else { + return handleSocketError(env, errno); + } } /* Enable events */ From a26445db3b1a98f3e5bae11dcf12e2ab4a20ff74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Arias=20de=20Reyna?= Date: Mon, 11 Mar 2024 11:17:00 +0000 Subject: [PATCH 021/149] 8261404: Class.getReflectionFactory() is not thread-safe Backport-of: 905b7639424a0fa80f81f734f6fdae1b5018a14a --- src/java.base/share/classes/java/lang/Class.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index d172b9556c6..05a1848ff61 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -3506,12 +3506,13 @@ public boolean isEnum() { // Fetches the factory for reflective objects private static ReflectionFactory getReflectionFactory() { - if (reflectionFactory == null) { - reflectionFactory = - java.security.AccessController.doPrivileged - (new ReflectionFactory.GetReflectionFactoryAction()); + var factory = reflectionFactory; + if (factory != null) { + return factory; } - return reflectionFactory; + return reflectionFactory = + java.security.AccessController.doPrivileged + (new ReflectionFactory.GetReflectionFactoryAction()); } private static ReflectionFactory reflectionFactory; From fbac37b73ce517f64fd7e679f8fde09cf66ad8c3 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Mon, 11 Mar 2024 12:16:35 +0000 Subject: [PATCH 022/149] 8307083: Open source some drag and drop tests 3 Backport-of: 1b154e4fd361103936f976db72e04b73aa7b1077 --- .../jdk/java/awt/dnd/MissedDragEnterTest.java | 253 ++++++++++++++++++ .../java/awt/dnd/ModalDialogDeadlockTest.java | 212 +++++++++++++++ .../dnd/ModalDialogOnDragDeadlockTest.java | 194 ++++++++++++++ .../dnd/ModalDialogOnDropDeadlockTest.java | 236 ++++++++++++++++ 4 files changed, 895 insertions(+) create mode 100644 test/jdk/java/awt/dnd/MissedDragEnterTest.java create mode 100644 test/jdk/java/awt/dnd/ModalDialogDeadlockTest.java create mode 100644 test/jdk/java/awt/dnd/ModalDialogOnDragDeadlockTest.java create mode 100644 test/jdk/java/awt/dnd/ModalDialogOnDropDeadlockTest.java diff --git a/test/jdk/java/awt/dnd/MissedDragEnterTest.java b/test/jdk/java/awt/dnd/MissedDragEnterTest.java new file mode 100644 index 00000000000..60fc5c3b85f --- /dev/null +++ b/test/jdk/java/awt/dnd/MissedDragEnterTest.java @@ -0,0 +1,253 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +import javax.swing.JFrame; +import javax.swing.JPanel; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetContext; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +/* + @test + @bug 4388802 + @summary tests that dragEnter() is called on a DropTargetListener if its drop + target is associated with a component which initiated the drag + @key headful + @run main MissedDragEnterTest +*/ + +public class MissedDragEnterTest { + + static final int FRAME_ACTIVATION_TIMEOUT = 1000; + volatile JFrame frame; + volatile DragSourceDropTargetPanel panel; + volatile Point p; + volatile Dimension d; + + public static void main(String[] args) throws Exception { + MissedDragEnterTest test = new MissedDragEnterTest(); + EventQueue.invokeAndWait(test::init); + try { + test.start(); + } finally { + EventQueue.invokeAndWait(() -> { + if (test.frame != null) { + test.frame.dispose(); + } + }); + } + } + + public void init() { + panel = new DragSourceDropTargetPanel(); + frame = new JFrame(); + frame.setTitle("MissedDragEnterTest"); + frame.setLocation(200, 200); + frame.getContentPane().add(panel); + + frame.pack(); + frame.setVisible(true); + } + + public void start() throws Exception { + Robot robot = new Robot(); + + robot.delay(FRAME_ACTIVATION_TIMEOUT); + EventQueue.invokeAndWait(() -> { + p = panel.getLocationOnScreen(); + d = panel.getSize(); + }); + + p.translate(d.width / 2, d.height / 2); + robot.mouseMove(p.x, p.y); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.mousePress(InputEvent.BUTTON1_MASK); + for (int i = 0; i < d.width; i++) { + p.translate(1, 1); + robot.mouseMove(p.x, p.y); + robot.delay(10); + } + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.keyRelease(KeyEvent.VK_CONTROL); + + EventQueue.invokeAndWait(() -> { + if (!panel.getResult()) { + throw new RuntimeException("The test failed."); + } + }); + } +} + +class DragSourceDropTargetPanel extends JPanel implements DropTargetListener, + Serializable, + Transferable, + DragGestureListener, + DragSourceListener { + private final DataFlavor dataflavor = + new DataFlavor(JPanel.class, "panel"); + private final Dimension preferredDimension = new Dimension(200, 100); + private boolean inside = false; + private boolean passed = true; + + public DragSourceDropTargetPanel() { + setLayout(new FlowLayout()); + DragSource ds = DragSource.getDefaultDragSource(); + ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, + this); + setDropTarget(new DropTarget(this, this)); + } + + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, this, this); + } + + public void dragEnter(DragSourceDragEvent dsde) {} + + public void dragExit(DragSourceEvent dse) {} + + public void dragOver(DragSourceDragEvent dsde) {} + + public void dragDropEnd(DragSourceDropEvent dsde) {} + + public void dropActionChanged(DragSourceDragEvent dsde) {} + + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException { + + if (!isDataFlavorSupported(flavor)) { + throw new UnsupportedFlavorException(flavor); + } + + Object retObj = null; + + ByteArrayOutputStream baoStream = new ByteArrayOutputStream(); + ObjectOutputStream ooStream = new ObjectOutputStream(baoStream); + ooStream.writeObject(this); + + ByteArrayInputStream baiStream = new ByteArrayInputStream(baoStream.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(baiStream); + try { + retObj = ois.readObject(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new RuntimeException(e.toString()); + } + + return retObj; + } + + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] { dataflavor }; + } + + public boolean isDataFlavorSupported(DataFlavor dflavor) { + return dataflavor.equals(dflavor); + } + + public Dimension getPreferredSize() { + return preferredDimension; + } + + public void dragEnter(DropTargetDragEvent dtde) { + inside = true; + } + + public void dragExit(DropTargetEvent dte) { + if (!inside) { + passed = false; + inside = false; + throw new RuntimeException("dragEnter() is not called before dragExit()"); + + } + inside = false; + } + + public void dragOver(DropTargetDragEvent dtde) { + if (!inside) { + passed = false; + throw new RuntimeException("dragEnter() is not called before dragOver()"); + } + } + + public void dropActionChanged(DropTargetDragEvent dtde) { + } + + public void drop(DropTargetDropEvent dtde) { + DropTargetContext dtc = dtde.getDropTargetContext(); + + if ((dtde.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + } else { + dtde.rejectDrop(); + } + + DataFlavor[] dfs = dtde.getCurrentDataFlavors(); + Component comp = null; + + if (dfs != null && dfs.length >= 1) { + Transferable transfer = dtde.getTransferable(); + + try { + comp = (Component)transfer.getTransferData(dfs[0]); + } catch (Throwable e) { + e.printStackTrace(); + dtc.dropComplete(false); + } + } + dtc.dropComplete(true); + + add(comp); + } + + public boolean getResult() { + return passed; + } +} diff --git a/test/jdk/java/awt/dnd/ModalDialogDeadlockTest.java b/test/jdk/java/awt/dnd/ModalDialogDeadlockTest.java new file mode 100644 index 00000000000..ca72ef8710f --- /dev/null +++ b/test/jdk/java/awt/dnd/ModalDialogDeadlockTest.java @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ + +import java.awt.AWTEvent; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceAdapter; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.AWTEventListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; + +/* + @test + @bug 4633417 + @summary tests that drag operation doesn't cause hang when a modal dialog is + shown + @key headful + @run main ModalDialogDeadlockTest +*/ + +public class ModalDialogDeadlockTest implements AWTEventListener { + + volatile Frame frame; + volatile Dialog dialog; + volatile Point dstPoint; + volatile Point srcPoint; + volatile Dimension d; + + volatile DragSource dragSource; + volatile Transferable transferable; + volatile DragSourceListener dsl; + volatile DragGestureListener dgl; + volatile DragGestureRecognizer dgr; + volatile DropTarget dt; + + static final Object SYNC_LOCK = new Object(); + static final int FRAME_ACTIVATION_TIMEOUT = 2000; + static final int MOUSE_RELEASE_TIMEOUT = 1000; + + Component clickedComponent = null; + + public static void main(String[] args) throws Exception { + ModalDialogDeadlockTest test = new ModalDialogDeadlockTest(); + EventQueue.invokeAndWait(test::init); + try { + test.start(); + } finally { + EventQueue.invokeAndWait(() -> { + if (test.frame != null) { + test.frame.dispose(); + } + }); + } + } + + public void init() { + frame = new Frame("ModalDialogDeadlockTest"); + frame.setBounds(100, 100, 200, 200); + dialog = new Dialog(frame, "Dialog", true); + dialog.setBounds(350, 100, 200, 200); + + dragSource = DragSource.getDefaultDragSource(); + transferable = new StringSelection("TEXT"); + dsl = new DragSourceAdapter() { + public void dragDropEnd(DragSourceDropEvent dsde) { + synchronized (SYNC_LOCK) { + SYNC_LOCK.notifyAll(); + } + } + }; + dgl = new DragGestureListener() { + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, transferable, dsl); + } + }; + dgr = dragSource.createDefaultDragGestureRecognizer(dialog, + DnDConstants.ACTION_COPY, + dgl); + final DropTargetListener dtl = new DropTargetAdapter() { + public void drop(DropTargetDropEvent dtde) { + dtde.rejectDrop(); + dialog.dispose(); + } + }; + dt = new DropTarget(frame, dtl); + + frame.getToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK); + frame.setVisible(true); + } + + public static int sign(int n) { + return n < 0 ? -1 : n == 0 ? 0 : 1; + } + + public void start() throws Exception { + final Robot robot = new Robot(); + + robot.delay(FRAME_ACTIVATION_TIMEOUT); + + EventQueue.invokeAndWait(() -> { + dstPoint = frame.getLocationOnScreen(); + d = frame.getSize(); + }); + dstPoint.translate(d.width / 2, d.height / 2); + + if (!pointInComponent(robot, dstPoint, frame)) { + System.err.println("WARNING: Couldn't locate frame."); + return; + } + + EventQueue.invokeLater(() -> { + dialog.setVisible(true); + }); + + robot.delay(FRAME_ACTIVATION_TIMEOUT); + + EventQueue.invokeAndWait(() -> { + srcPoint = dialog.getLocationOnScreen(); + d = dialog.getSize(); + }); + srcPoint.translate(d.width / 2, d.height / 2); + + if (!pointInComponent(robot, srcPoint, dialog)) { + System.err.println("WARNING: Couldn't locate dialog."); + return; + } + + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + for (;!srcPoint.equals(dstPoint); + srcPoint.translate(sign(dstPoint.x - srcPoint.x), + sign(dstPoint.y - srcPoint.y))) { + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.delay(50); + } + synchronized (SYNC_LOCK) { + robot.mouseRelease(InputEvent.BUTTON1_MASK); + SYNC_LOCK.wait(); + } + } + + public void reset() { + clickedComponent = null; + } + + public void eventDispatched(AWTEvent e) { + if (e.getID() == MouseEvent.MOUSE_RELEASED) { + clickedComponent = (Component)e.getSource(); + synchronized (SYNC_LOCK) { + SYNC_LOCK.notifyAll(); + } + } + } + + boolean pointInComponent(Robot robot, Point p, Component comp) + throws InterruptedException { + robot.waitForIdle(); + reset(); + robot.mouseMove(p.x, p.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + synchronized (SYNC_LOCK) { + robot.mouseRelease(InputEvent.BUTTON1_MASK); + SYNC_LOCK.wait(MOUSE_RELEASE_TIMEOUT); + } + + Component c = clickedComponent; + + while (c != null && c != comp) { + c = c.getParent(); + } + + return c == comp; + } +} diff --git a/test/jdk/java/awt/dnd/ModalDialogOnDragDeadlockTest.java b/test/jdk/java/awt/dnd/ModalDialogOnDragDeadlockTest.java new file mode 100644 index 00000000000..3730aec27c9 --- /dev/null +++ b/test/jdk/java/awt/dnd/ModalDialogOnDragDeadlockTest.java @@ -0,0 +1,194 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +import java.awt.AWTEvent; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.AWTEventListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; + +/* + @test + @bug 4352221 + @summary verifies that showing a modal dialog on drag doesn't hang + @key headful + @run main ModalDialogOnDragDeadlockTest +*/ + +public class ModalDialogOnDragDeadlockTest implements AWTEventListener { + + volatile Frame frame; + volatile Dialog dialog; + volatile Point srcPoint; + volatile Dimension d; + volatile boolean finished; + + static final Object SYNC_LOCK = new Object(); + static final int FRAME_ACTIVATION_TIMEOUT = 3000; + static final int DROP_COMPLETION_TIMEOUT = 5000; + static final int MOUSE_RELEASE_TIMEOUT = 1000; + + volatile DragSource dragSource; + volatile Transferable transferable; + volatile DragGestureListener dragGestureListener; + volatile DragGestureRecognizer dragGestureRecognizer; + volatile DropTargetListener dropTargetListener; + volatile DropTarget dropTarget; + + Component clickedComponent = null; + + public static void main(String[] args) throws Exception { + ModalDialogOnDragDeadlockTest test = new ModalDialogOnDragDeadlockTest(); + EventQueue.invokeAndWait(test::init); + try { + test.start(); + } finally { + EventQueue.invokeAndWait(() -> { + if (test.frame != null) { + test.frame.dispose(); + } + }); + } + } + + public void init() { + frame = new Frame("ModalDialogOnDragDeadlockTest"); + dialog = new Dialog(frame, "Modal dialog", true); + frame.setTitle("Test frame"); + frame.setBounds(100, 100, 200, 200); + + dragSource = DragSource.getDefaultDragSource(); + transferable = new StringSelection("TEXT"); + dragGestureListener = new DragGestureListener() { + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, transferable); + } + }; + dragGestureRecognizer = + dragSource.createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, + dragGestureListener); + dropTargetListener = new DropTargetAdapter() { + public void dragOver(DropTargetDragEvent dtde) { + dialog.setBounds(200, 200, 200, 200); + dialog.setVisible(true); + } + public void drop(DropTargetDropEvent dtde) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + dtde.dropComplete(true); + } + }; + dropTarget = new DropTarget(frame, dropTargetListener); + + frame.getToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK); + frame.setVisible(true); + } + + public static int sign(int n) { + return n < 0 ? -1 : n == 0 ? 0 : 1; + } + + public void start() throws Exception { + finished = false; + Robot robot = new Robot(); + robot.waitForIdle(); + + Thread.sleep(FRAME_ACTIVATION_TIMEOUT); + EventQueue.invokeAndWait(() -> { + srcPoint = frame.getLocationOnScreen(); + d = frame.getSize(); + }); + srcPoint.translate(d.width / 2, d.height / 2); + + if (!pointInComponent(robot, srcPoint, frame)) { + System.err.println("WARNING: Couldn't locate source frame."); + return; + } + + final Point dstPoint = new Point(srcPoint); + dstPoint.translate(d.width / 4, d.height / 4); + + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + for (;!srcPoint.equals(dstPoint); + srcPoint.translate(sign(dstPoint.x - srcPoint.x), + sign(dstPoint.y - srcPoint.y))) { + robot.mouseMove(srcPoint.x, srcPoint.y); + Thread.sleep(50); + } + + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + Thread.sleep(DROP_COMPLETION_TIMEOUT); + } + + public void reset() { + clickedComponent = null; + } + + public void eventDispatched(AWTEvent e) { + if (e.getID() == MouseEvent.MOUSE_RELEASED) { + clickedComponent = (Component)e.getSource(); + synchronized (SYNC_LOCK) { + SYNC_LOCK.notifyAll(); + } + } + } + + boolean pointInComponent(Robot robot, Point p, Component comp) + throws InterruptedException { + robot.waitForIdle(); + reset(); + robot.mouseMove(p.x, p.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + synchronized (SYNC_LOCK) { + robot.mouseRelease(InputEvent.BUTTON1_MASK); + SYNC_LOCK.wait(MOUSE_RELEASE_TIMEOUT); + } + + Component c = clickedComponent; + + while (c != null && c != comp) { + c = c.getParent(); + } + + return c == comp; + } +} \ No newline at end of file diff --git a/test/jdk/java/awt/dnd/ModalDialogOnDropDeadlockTest.java b/test/jdk/java/awt/dnd/ModalDialogOnDropDeadlockTest.java new file mode 100644 index 00000000000..103cf9df12e --- /dev/null +++ b/test/jdk/java/awt/dnd/ModalDialogOnDropDeadlockTest.java @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ + +import java.awt.AWTEvent; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceAdapter; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.AWTEventListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/* + @test + @bug 4623377 + @summary verifies that showing a modal dialog on drop doesn't hang + @key headful + @run main ModalDialogOnDropDeadlockTest +*/ + +public class ModalDialogOnDropDeadlockTest implements AWTEventListener { + + volatile Frame frame; + volatile Dialog dialog; + volatile Point srcPoint; + volatile Dimension d; + volatile boolean finished = false; + + static final Object SYNC_LOCK = new Object(); + static final int FRAME_ACTIVATION_TIMEOUT = 3000; + static final int DROP_COMPLETION_TIMEOUT = 5000; + static final int MOUSE_RELEASE_TIMEOUT = 1000; + + volatile MouseListener mouseListener; + + volatile Runnable dialogLocator; + volatile DragSourceListener dragSourceListener; + volatile DragSource dragSource; + volatile Transferable transferable; + volatile DragGestureListener dragGestureListener; + volatile DragGestureRecognizer dragGestureRecognizer; + volatile DropTargetListener dropTargetListener; + volatile DropTarget dropTarget; + + Component clickedComponent = null; + + public static void main(String[] args) throws Exception { + ModalDialogOnDropDeadlockTest test = new ModalDialogOnDropDeadlockTest(); + EventQueue.invokeAndWait(test::init); + try { + test.start(); + } finally { + EventQueue.invokeAndWait(() -> { + if (test.frame != null) { + test.frame.dispose(); + } + }); + } + } + + public void init() { + frame = new Frame(); + dialog = new Dialog(frame, "Modal dialog", true); + frame.setTitle("ModalDialogOnDropDeadlockTest"); + frame.setBounds(100, 100, 200, 200); + + mouseListener = new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + dialog.dispose(); + } + }; + dialogLocator = new Runnable() { + public void run() { + try { + final Robot robot = new Robot(); + + Thread.sleep(FRAME_ACTIVATION_TIMEOUT); + + final Point srcPoint = dialog.getLocationOnScreen(); + Dimension d = dialog.getSize(); + srcPoint.translate(d.width / 2, d.height / 2); + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + } catch (Exception e) { + e.printStackTrace(); + dialog.dispose(); + } + } + }; + dragSourceListener = new DragSourceAdapter() { + public void dragDropEnd(DragSourceDropEvent dsde) { + finished = true; + } + }; + dragSource = DragSource.getDefaultDragSource(); + transferable = new StringSelection("TEXT"); + dragGestureListener = new DragGestureListener() { + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, transferable, dragSourceListener); + } + }; + dragGestureRecognizer = + dragSource.createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, + dragGestureListener); + dropTargetListener = new DropTargetAdapter() { + public void drop(DropTargetDropEvent dtde) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + dialog.addMouseListener(mouseListener); + dialog.setBounds(200, 200, 200, 200); + new Thread(dialogLocator).start(); + dialog.setVisible(true); + dtde.dropComplete(true); + } + }; + dropTarget = new DropTarget(frame, dropTargetListener); + + frame.getToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK); + frame.setVisible(true); + } + + public static int sign(int n) { + return n < 0 ? -1 : n == 0 ? 0 : 1; + } + + public void start() throws Exception { + Robot robot = new Robot(); + robot.waitForIdle(); + + Thread.sleep(FRAME_ACTIVATION_TIMEOUT); + + EventQueue.invokeAndWait(() -> { + srcPoint = frame.getLocationOnScreen(); + d = frame.getSize(); + }); + srcPoint.translate(d.width / 2, d.height / 2); + + if (!pointInComponent(robot, srcPoint, frame)) { + System.err.println("WARNING: Couldn't locate source frame."); + return; + } + + final Point dstPoint = new Point(srcPoint); + dstPoint.translate(d.width / 4, d.height / 4); + + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + for (;!srcPoint.equals(dstPoint); + srcPoint.translate(sign(dstPoint.x - srcPoint.x), + sign(dstPoint.y - srcPoint.y))) { + robot.mouseMove(srcPoint.x, srcPoint.y); + Thread.sleep(50); + } + + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + Thread.sleep(DROP_COMPLETION_TIMEOUT); + + if (!finished) { + throw new RuntimeException("DnD not finished"); + } + } + + public void reset() { + clickedComponent = null; + } + + public void eventDispatched(AWTEvent e) { + if (e.getID() == MouseEvent.MOUSE_RELEASED) { + clickedComponent = (Component)e.getSource(); + synchronized (SYNC_LOCK) { + SYNC_LOCK.notifyAll(); + } + } + } + + boolean pointInComponent(Robot robot, Point p, Component comp) + throws InterruptedException { + robot.waitForIdle(); + reset(); + robot.mouseMove(p.x, p.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + synchronized (SYNC_LOCK) { + robot.mouseRelease(InputEvent.BUTTON1_MASK); + SYNC_LOCK.wait(MOUSE_RELEASE_TIMEOUT); + } + + Component c = clickedComponent; + + while (c != null && c != comp) { + c = c.getParent(); + } + + return c == comp; + } +} From 9b4085619fffd871a74cee7f93bac67cf42b9cc0 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Mon, 11 Mar 2024 12:16:54 +0000 Subject: [PATCH 023/149] 8317287: [macos14] InterJVMGetDropSuccessTest.java: Child VM: abnormal termination Backport-of: cbfddf4e1d3ff8dddb95bcb9242b31c175b768fc --- .../InterJVMGetDropSuccessTest.java | 130 +++++++++--------- 1 file changed, 66 insertions(+), 64 deletions(-) diff --git a/test/jdk/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java b/test/jdk/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java index 3656c44246f..9548bd4fe2f 100644 --- a/test/jdk/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java +++ b/test/jdk/java/awt/dnd/InterJVMGetDropSuccessTest/InterJVMGetDropSuccessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, 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,16 +29,37 @@ @run main InterJVMGetDropSuccessTest */ -import java.awt.*; -import java.awt.datatransfer.*; -import java.awt.dnd.*; -import java.awt.event.*; -import java.io.*; +import java.awt.AWTEvent; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceAdapter; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.AWTEventListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.InputStream; public class InterJVMGetDropSuccessTest { private int returnCode = Util.CODE_NOT_RETURNED; - private boolean successCodes[] = { true, false }; + private final boolean[] successCodes = { true, false }; private int dropCount = 0; final Frame frame = new Frame("Target Frame"); @@ -68,7 +89,9 @@ public void start() { frame.setVisible(true); try { - Thread.sleep(Util.FRAME_ACTIVATION_TIMEOUT); + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(Util.FRAME_ACTIVATION_TIMEOUT); Point p = frame.getLocationOnScreen(); Dimension d = frame.getSize(); @@ -136,10 +159,9 @@ final class Util implements AWTEventListener { public static final int CODE_SECOND_SUCCESS = 0x2; public static final int CODE_FAILURE = 0x1; - public static final int FRAME_ACTIVATION_TIMEOUT = 3000; + public static final int FRAME_ACTIVATION_TIMEOUT = 1000; static final Object SYNC_LOCK = new Object(); - static final int MOUSE_RELEASE_TIMEOUT = 1000; static final Util theInstance = new Util(); @@ -158,45 +180,13 @@ public static int sign(int n) { return n < 0 ? -1 : n == 0 ? 0 : 1; } - private Component clickedComponent = null; - - private void reset() { - clickedComponent = null; - } - public void eventDispatched(AWTEvent e) { if (e.getID() == MouseEvent.MOUSE_RELEASED) { - clickedComponent = (Component)e.getSource(); synchronized (SYNC_LOCK) { SYNC_LOCK.notifyAll(); } } } - - public static boolean pointInComponent(Robot robot, Point p, Component comp) - throws InterruptedException { - return theInstance.pointInComponentImpl(robot, p, comp); - } - - private boolean pointInComponentImpl(Robot robot, Point p, Component comp) - throws InterruptedException { - robot.waitForIdle(); - reset(); - robot.mouseMove(p.x, p.y); - robot.mousePress(InputEvent.BUTTON1_MASK); - synchronized (SYNC_LOCK) { - robot.mouseRelease(InputEvent.BUTTON1_MASK); - SYNC_LOCK.wait(MOUSE_RELEASE_TIMEOUT); - } - - Component c = clickedComponent; - - while (c != null && c != comp) { - c = c.getParent(); - } - - return c == comp; - } } class Child { @@ -226,6 +216,9 @@ public void dragDropEnd(DragSourceDropEvent dsde) { } } + private volatile boolean success1 = false; + private volatile boolean success2 = false; + final Frame frame = new Frame("Source Frame"); final DragSource dragSource = DragSource.getDefaultDragSource(); final DragSourceDropListener dragSourceListener = new DragSourceDropListener(); @@ -258,53 +251,62 @@ public void run(String[] args) { frame.setBounds(300, 200, 150, 150); frame.setVisible(true); - Thread.sleep(Util.FRAME_ACTIVATION_TIMEOUT); + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(Util.FRAME_ACTIVATION_TIMEOUT); Point sourcePoint = Util.getCenterLocationOnScreen(frame); - Point targetPoint = new Point(x + w / 2, y + h / 2); - Robot robot = new Robot(); robot.mouseMove(sourcePoint.x, sourcePoint.y); - robot.mousePress(InputEvent.BUTTON1_MASK); + robot.waitForIdle(); + robot.delay(50); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); for (Point p = new Point(sourcePoint); !p.equals(targetPoint); - p.translate(Util.sign(targetPoint.x - p.x), - Util.sign(targetPoint.y - p.y))) { + p.translate(Util.sign(targetPoint.x - p.x), + Util.sign(targetPoint.y - p.y))) { robot.mouseMove(p.x, p.y); - Thread.sleep(50); + robot.delay(5); } synchronized (Util.SYNC_LOCK) { - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); Util.SYNC_LOCK.wait(Util.FRAME_ACTIVATION_TIMEOUT); } - if (!dragSourceListener.isDropFinished()) { - throw new RuntimeException("Drop not finished"); - } + EventQueue.invokeAndWait(() -> { + if (!dragSourceListener.isDropFinished()) { + throw new RuntimeException("Drop not finished"); + } + success1 = dragSourceListener.getDropSuccess(); + dragSourceListener.reset(); + }); - boolean success1 = dragSourceListener.getDropSuccess(); - dragSourceListener.reset(); robot.mouseMove(sourcePoint.x, sourcePoint.y); - robot.mousePress(InputEvent.BUTTON1_MASK); + robot.waitForIdle(); + robot.delay(50); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); for (Point p = new Point(sourcePoint); !p.equals(targetPoint); - p.translate(Util.sign(targetPoint.x - p.x), - Util.sign(targetPoint.y - p.y))) { + p.translate(Util.sign(targetPoint.x - p.x), + Util.sign(targetPoint.y - p.y))) { robot.mouseMove(p.x, p.y); - Thread.sleep(50); + robot.delay(5); } synchronized (Util.SYNC_LOCK) { - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); Util.SYNC_LOCK.wait(Util.FRAME_ACTIVATION_TIMEOUT); } - if (!dragSourceListener.isDropFinished()) { - throw new RuntimeException("Drop not finished"); - } + EventQueue.invokeAndWait(() -> { + if (!dragSourceListener.isDropFinished()) { + throw new RuntimeException("Drop not finished"); + } + success2 = dragSourceListener.getDropSuccess(); + dragSourceListener.reset(); + }); - boolean success2 = dragSourceListener.getDropSuccess(); int retCode = 0; if (success1) { From cf9aa9be1631de55da7329ce4a1cc9bddd425723 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Mon, 11 Mar 2024 12:17:08 +0000 Subject: [PATCH 024/149] 8306941: Open source several datatransfer and dnd AWT tests Backport-of: 3d3eaed9133dbe728ca8e00a626d33f7e35ba9ff --- .../awt/datatransfer/MimeFormatsTest.java | 288 ++++++++++++++ .../RemoveFlavorListenerTest.java | 50 +++ test/jdk/java/awt/dnd/AutoscrollStopTest.java | 143 +++++++ test/jdk/java/awt/dnd/ButtonReleaseTest.java | 350 ++++++++++++++++++ 4 files changed, 831 insertions(+) create mode 100644 test/jdk/java/awt/datatransfer/MimeFormatsTest.java create mode 100644 test/jdk/java/awt/datatransfer/RemoveFlavorListenerTest.java create mode 100644 test/jdk/java/awt/dnd/AutoscrollStopTest.java create mode 100644 test/jdk/java/awt/dnd/ButtonReleaseTest.java diff --git a/test/jdk/java/awt/datatransfer/MimeFormatsTest.java b/test/jdk/java/awt/datatransfer/MimeFormatsTest.java new file mode 100644 index 00000000000..a22cc47877d --- /dev/null +++ b/test/jdk/java/awt/datatransfer/MimeFormatsTest.java @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + @test + @bug 4859006 + @summary tests that MIME formats are mapped to flavors properly on X11 + @requires (os.family == "linux") + @key headful + @run main MimeFormatsTest +*/ + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.FlavorMap; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.SystemFlavorMap; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.nio.charset.StandardCharsets; + + +public class MimeFormatsTest implements ClipboardOwner { + public static final DataFlavor TEST_FLAVOR = + new DataFlavor( + "text/test;charset=UTF-8;class=java.io.InputStream", + null); + + public static class TextTransferable implements Transferable { + private final String text; + + public TextTransferable(String text) { + this.text = text; + } + + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException { + if (!isDataFlavorSupported(TEST_FLAVOR)) { + throw new UnsupportedFlavorException(flavor); + } + + return new ByteArrayInputStream( + text.getBytes(StandardCharsets.UTF_8)); + } + + public DataFlavor[] getTransferDataFlavors(){ + return new DataFlavor[] { TEST_FLAVOR }; + } + + public boolean isDataFlavorSupported(DataFlavor flavor) { + return TEST_FLAVOR.equals(flavor); + } + } + + public static final String DATA = + "\u0440\u0443\u0441\u0441\u043a\u0438\u0439"; + + private String testData = null; + + private static final Clipboard clipboard = + Toolkit.getDefaultToolkit().getSystemClipboard(); + + public void childRun() { + Transferable t = clipboard.getContents(null); + String data = ""; + try { + data = (String)t.getTransferData(DataFlavor.stringFlavor); + } catch (Exception e) { + e.printStackTrace(); + } + System.err.println("contents size=" + data.length()); + for (int i = 0; i < data.length(); i++) { + System.err.println(" char[" + i + "]=" + (int) data.charAt(i)); + } + ClipboardOwner owner = new ClipboardOwner() { + public void lostOwnership(Clipboard clipboard, + Transferable contents) { + System.err.println("%d exit".formatted( + System.currentTimeMillis())); + System.err.println("Exiting"); + System.exit(0); + } + }; + clipboard.setContents(new StringSelection(data + data), owner); + + Object lock = new Object(); + synchronized (lock) { + // Wait to let the parent retrieve the contents. + try { + System.err.println("%d wait".formatted( + System.currentTimeMillis())); + lock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + public void start() { + FlavorMap fm = SystemFlavorMap.getDefaultFlavorMap(); + if (fm instanceof SystemFlavorMap) { + SystemFlavorMap sfm = (SystemFlavorMap)fm; + String mimeNative = "text/plain;charset=UTF-8"; + sfm.setNativesForFlavor(TEST_FLAVOR, + new String[] { mimeNative }); + sfm.setFlavorsForNative(mimeNative, + new DataFlavor[] { TEST_FLAVOR }); + } else { + System.err.println("WARNING: system flavor map: " + fm); + return; + } + + clipboard.setContents(new TextTransferable(DATA), this); + + try { + String javaPath = System.getProperty("java.home", ""); + String[] command = { + javaPath + File.separator + "bin" + File.separator + "java", + "-cp", + System.getProperty("test.classes", "."), + "Child" + }; + + Process process = Runtime.getRuntime().exec(command); + ProcessResults pres = ProcessResults.doWaitFor(process); + + int returnCode = pres.exitValue; + + if (pres.stderr != null && pres.stderr.length() > 0) { + System.err.println("========= Child VM System.err ========"); + System.err.print(pres.stderr); + System.err.println("======================================"); + } + + if (pres.stdout != null && pres.stdout.length() > 0) { + System.err.println("========= Child VM System.out ========"); + System.err.print(pres.stdout); + System.err.println("======================================"); + } + + System.err.println("Child return code=" + returnCode); + } catch (Throwable e) { + e.printStackTrace(); + } + + System.err.println("Received data size=" + testData.length()); + for (int i = 0; i < testData.length(); i++) { + System.err.println(" char[" + i + "]=" + (int)testData.charAt(i)); + } + + if (!testData.equals(DATA + DATA)) { + throw new RuntimeException(); + } + } + + public void lostOwnership(Clipboard clip, Transferable contents) { + Runnable r = new Runnable() { + public void run() { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + Transferable t = clipboard.getContents(null); + try { + InputStream is = + (InputStream)t.getTransferData(TEST_FLAVOR); + Reader r = new InputStreamReader(is, + StandardCharsets.UTF_8); + StringBuffer sb = new StringBuffer(); + int ch = 0; + while ((ch = r.read()) != -1) { + System.err.println("ch=" + ch); + sb.append((char)ch); + } + testData = sb.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + clipboard.setContents(new TextTransferable(""), null); + } + }; + new Thread(r).start(); + } + + public static void main(String[] args) { + if (!System.getProperty("os.name").startsWith("Linux")) { + return; + } + + MimeFormatsTest mimeFormatsTest = new MimeFormatsTest(); + mimeFormatsTest.start(); + } +} + +class Child { + public static void main(String[] args) { + MimeFormatsTest test = new MimeFormatsTest(); + test.childRun(); + } +} + +class ProcessResults { + public int exitValue; + public String stdout; + public String stderr; + + public ProcessResults() { + exitValue = -1; + stdout = ""; + stderr = ""; + } + + /** + * Method to perform a "wait" for a process and return its exit value. + * This is a workaround for Process.waitFor() never returning. + */ + public static ProcessResults doWaitFor(Process p) { + ProcessResults pres = new ProcessResults(); + + InputStream in = null; + InputStream err = null; + + try { + in = p.getInputStream(); + err = p.getErrorStream(); + + boolean finished = false; + + while (!finished) { + try { + while (in.available() > 0) { + pres.stdout += (char)in.read(); + } + while (err.available() > 0) { + pres.stderr += (char)err.read(); + } + // Ask the process for its exitValue. If the process + // is not finished, an IllegalThreadStateException + // is thrown. If it is finished, we fall through and + // the variable finished is set to true. + pres.exitValue = p.exitValue(); + finished = true; + } + catch (IllegalThreadStateException e) { + // Process is not finished yet; + // Sleep a little to save on CPU cycles + Thread.currentThread().sleep(500); + } + } + if (in != null) in.close(); + if (err != null) err.close(); + } + catch (Throwable e) { + System.err.println("doWaitFor(): unexpected exception"); + e.printStackTrace(); + } + return pres; + } +} diff --git a/test/jdk/java/awt/datatransfer/RemoveFlavorListenerTest.java b/test/jdk/java/awt/datatransfer/RemoveFlavorListenerTest.java new file mode 100644 index 00000000000..030bf93aad6 --- /dev/null +++ b/test/jdk/java/awt/datatransfer/RemoveFlavorListenerTest.java @@ -0,0 +1,50 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +/* + @test + @bug 6194489 + @summary tests that removeFlavorListener does not throw an exception in any case. + @key headful + @run main RemoveFlavorListenerTest +*/ + +import java.awt.Toolkit; +import java.awt.datatransfer.FlavorEvent; +import java.awt.datatransfer.FlavorListener; + +public class RemoveFlavorListenerTest { + + public static void main(String[] args) { + try { + FlavorListener fl = new FlavorListener() { + public void flavorsChanged(FlavorEvent e) {} + }; + Toolkit.getDefaultToolkit() + .getSystemClipboard().removeFlavorListener(fl); + } catch (NullPointerException e) { + throw new RuntimeException("NullPointerException, test case failed", + e); + } + } +} diff --git a/test/jdk/java/awt/dnd/AutoscrollStopTest.java b/test/jdk/java/awt/dnd/AutoscrollStopTest.java new file mode 100644 index 00000000000..6b4aa0404c7 --- /dev/null +++ b/test/jdk/java/awt/dnd/AutoscrollStopTest.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2001, 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. + * + * 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. + */ + +/* + @test + @bug 4516490 + @summary verifies that autoscroll is stopped when the drop happens + @key headful + @run main AutoscrollStopTest +*/ + + +import java.awt.AWTException; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.Autoscroll; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.InputEvent; + + +public class AutoscrollStopTest extends Frame implements Autoscroll { + static volatile AutoscrollStopTest test = null; + + volatile boolean dropHappened = false; + + final DragSource dragSource = DragSource.getDefaultDragSource(); + final Transferable transferable = new StringSelection("TEXT"); + final DragGestureListener dragGestureListener = new DragGestureListener() { + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, transferable); + } + }; + final DragGestureRecognizer dragGestureRecognizer = + dragSource.createDefaultDragGestureRecognizer( + this, DnDConstants.ACTION_COPY_OR_MOVE, + dragGestureListener); + + final DropTargetListener dropTargetListener = new DropTargetAdapter() { + public void drop(DropTargetDropEvent e) { + e.rejectDrop(); + dropHappened = true; + } + }; + + final DropTarget dropTarget = new DropTarget(this, dropTargetListener); + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> { + test = new AutoscrollStopTest(); + test.createUI(); + }); + try { + test.start(); + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } + + public static int sign(int n) { + return Integer.compare(n, 0); + } + + public void createUI() { + setTitle("AutoscrollStopTest"); + setMinimumSize(new Dimension(200, 200)); + setLocationRelativeTo(null); + setVisible(true); + } + + public void start() throws AWTException { + final Robot robot = new Robot(); + try { + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(50); + robot.waitForIdle(); + robot.delay(1000); + + final Point srcPoint = this.getLocationOnScreen(); + final Dimension d = this.getSize(); + srcPoint.translate(d.width / 2, d.height / 2); + + final Point dstPoint = new Point(srcPoint); + dstPoint.translate(d.width / 4, d.height / 4); + + robot.mouseMove(srcPoint.x, srcPoint.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + + for (;!srcPoint.equals(dstPoint); + srcPoint.translate(sign(dstPoint.x - srcPoint.x), + sign(dstPoint.y - srcPoint.y))) { + robot.mouseMove(srcPoint.x, srcPoint.y); + } + } finally { + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + } + } + + public Insets getAutoscrollInsets() { + final Dimension d = this.getSize(); + return new Insets(d.height / 2, d.width / 2, + d.height / 2, d.width / 2); + } + + public void autoscroll(Point cursorLocation) { + if (dropHappened) { + throw new RuntimeException("Test failed"); + } + } +} diff --git a/test/jdk/java/awt/dnd/ButtonReleaseTest.java b/test/jdk/java/awt/dnd/ButtonReleaseTest.java new file mode 100644 index 00000000000..880aa1695ca --- /dev/null +++ b/test/jdk/java/awt/dnd/ButtonReleaseTest.java @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2001, 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. + * + * 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. + */ + +/* + @test + @bug 4215643 + @summary Tests that the drag source receives mouseReleased event + @key headful +*/ + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceDragEvent; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetContext; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + + +public class ButtonReleaseTest { + + static volatile ButtonPanelFrame buttonPanelFrame; + static final int FRAME_ACTIVATION_TIMEOUT = 1000; + static final int DROP_COMPLETION_TIMEOUT = 4000; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(20); + + try { + EventQueue.invokeAndWait(() -> { + buttonPanelFrame = new ButtonPanelFrame(); + buttonPanelFrame.pack(); + buttonPanelFrame.setVisible(true); + }); + + robot.waitForIdle(); + robot.delay(FRAME_ACTIVATION_TIMEOUT); + + Point p = buttonPanelFrame.getButtonLocation(); + Dimension d = buttonPanelFrame.getButtonSize(); + p.translate(d.width / 2, d.height / 2); + robot.mouseMove(p.x, p.y); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + for (int i = 0; i < d.width; i++) { + p.translate(0, 1); + robot.mouseMove(p.x, p.y); + } + + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + try { + Thread.sleep(DROP_COMPLETION_TIMEOUT); + } catch (InterruptedException e) { + throw new RuntimeException("The test failed."); + } + + if (!buttonPanelFrame.passed()) { + throw new RuntimeException( + "The test failed - mouse release was not received."); + } + + } finally { + EventQueue.invokeAndWait(buttonPanelFrame::dispose); + } + } +} + +class ButtonPanelFrame extends Frame { + + DnDSource dragSource; + DnDTarget dropTarget; + + ButtonPanelFrame() { + Panel mainPanel; + + setTitle("ButtonReleaseTest - ButtonPanelFrame"); + setSize(200, 200); + setLocationRelativeTo(null); + setLayout(new BorderLayout()); + + mainPanel = new Panel(); + mainPanel.setLayout(new BorderLayout()); + + mainPanel.setBackground(Color.black); + + dropTarget = new DnDTarget(Color.red, Color.yellow); + dragSource = new DnDSource("Drag ME!"); + + mainPanel.add(dragSource, "North"); + mainPanel.add(dropTarget, "Center"); + add(mainPanel, BorderLayout.CENTER); + } + + boolean passed() { + return dragSource.passed(); + } + + Point getButtonLocation() { + return dragSource.getLocationOnScreen(); + } + + Dimension getButtonSize() { + return dragSource.getSize(); + } +} + +class DnDSource extends Button implements Serializable, Transferable, + DragGestureListener, + DragSourceListener { + + private transient DataFlavor df; + private transient int dropAction; + volatile boolean released = false; + + DnDSource(String label) { + super(label); + + DragSource ds = DragSource.getDefaultDragSource(); + ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, + this); + addMouseListener(new MouseAdapter() { + public void mouseReleased(MouseEvent e) { + synchronized(this) { + released = true; + notifyAll(); + } + } + }); + setBackground(Color.yellow); + setForeground(Color.blue); + + df = new DataFlavor(DnDSource.class, "DnDSource"); + } + + public void dragGestureRecognized(DragGestureEvent dge) { + dge.startDrag(null, this, this); + } + + + public void dragEnter(DragSourceDragEvent dsde) { + dsde.getDragSourceContext().setCursor(DragSource.DefaultCopyDrop); + } + + public void dragOver(DragSourceDragEvent dsde) { + } + + public void dragGestureChanged(DragSourceDragEvent dsde) { + } + + public void dragExit(DragSourceEvent dsde) { + dsde.getDragSourceContext().setCursor(null); + } + + public void dragDropEnd(DragSourceDropEvent dsde) { + } + + public void dropActionChanged(DragSourceDragEvent dsde) { + } + + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] { df }; + } + + public boolean isDataFlavorSupported(DataFlavor sdf) { + return df.equals(sdf); + } + + public Object getTransferData(DataFlavor tdf) throws UnsupportedFlavorException , IOException { + + Object copy = null; + + if (!df.equals(tdf)) { + throw new UnsupportedFlavorException(tdf); + } + + Container parent = getParent(); + switch (dropAction) { + case DnDConstants.ACTION_COPY: + try { + copy = this.clone(); + } catch (CloneNotSupportedException e) { + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(this); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(bais); + + try { + copy = ois.readObject(); + } catch (ClassNotFoundException cnfe) { + // do nothing + } + } + return copy; + + case DnDConstants.ACTION_MOVE: + synchronized(this) { + if (parent != null) parent.remove(this); + } + return this; + + case DnDConstants.ACTION_LINK: + return this; + + default: + return this; + } + } + + boolean passed() { + return !released; + } +} + +class DnDTarget extends Panel implements DropTargetListener { + + Color bgColor; + Color htColor; + + DnDTarget(Color bgColor, Color htColor) { + super(); + this.bgColor = bgColor; + this.htColor = htColor; + setBackground(bgColor); + setDropTarget(new DropTarget(this, this)); + } + + public Dimension getPreferredSize() { + return new Dimension(200, 200); + } + + public void dragEnter(DropTargetDragEvent e) { + e.acceptDrag(DnDConstants.ACTION_COPY); + setBackground(htColor); + repaint(); + } + + public void dragOver(DropTargetDragEvent e) { + e.acceptDrag(DnDConstants.ACTION_COPY); + } + + public void dragExit(DropTargetEvent e) { + setBackground(bgColor); + repaint(); + } + + public void drop(DropTargetDropEvent dtde) { + DropTargetContext dtc = dtde.getDropTargetContext(); + + if ((dtde.getSourceActions() & DnDConstants.ACTION_COPY) != 0) { + dtde.acceptDrop(DnDConstants.ACTION_COPY); + } else { + dtde.rejectDrop(); + return; + } + + DataFlavor[] dfs = dtde.getCurrentDataFlavors(); + + if (dfs != null && dfs.length >= 1) { + Transferable transfer = dtde.getTransferable(); + Object obj = null; + + try { + obj = transfer.getTransferData(dfs[0]); + } catch (IOException | UnsupportedFlavorException e) { + System.err.println(e.getMessage()); + dtc.dropComplete(false); + return; + } + + if (obj != null) { + Button button = null; + + try { + button = (Button)obj; + } catch (Exception e) { + System.err.println(e.getMessage()); + dtc.dropComplete(false); + return; + } + add(button); + repaint(); + } + } + + setBackground(bgColor); + invalidate(); + validate(); + repaint(); + dtc.dropComplete(true); + } + + public void dragScroll(DropTargetDragEvent e) { + } + + public void dropActionChanged(DropTargetDragEvent e) { + } +} From eb5ef84294e314efb7f2b179b7f187831ddb524b Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Mon, 11 Mar 2024 12:17:55 +0000 Subject: [PATCH 025/149] 8315677: Open source few swing JFileChooser and other tests Backport-of: fe5ef5f20dcf647b4ca30963b42fa01449f0d9c0 --- .../javax/swing/JFileChooser/bug4624353.java | 87 +++++++++++++ .../javax/swing/JFileChooser/bug4673161.java | 70 ++++++++++ .../javax/swing/JFileChooser/bug4782168.java | 40 ++++++ test/jdk/javax/swing/JLabel/bug4822331.java | 120 ++++++++++++++++++ .../javax/swing/JOptionPane/bug4191835.java | 43 +++++++ 5 files changed, 360 insertions(+) create mode 100644 test/jdk/javax/swing/JFileChooser/bug4624353.java create mode 100644 test/jdk/javax/swing/JFileChooser/bug4673161.java create mode 100644 test/jdk/javax/swing/JFileChooser/bug4782168.java create mode 100644 test/jdk/javax/swing/JLabel/bug4822331.java create mode 100644 test/jdk/javax/swing/JOptionPane/bug4191835.java diff --git a/test/jdk/javax/swing/JFileChooser/bug4624353.java b/test/jdk/javax/swing/JFileChooser/bug4624353.java new file mode 100644 index 00000000000..c977cb9ed95 --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug4624353.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4624353 + * @summary Tests that Motif FileChooser is not able to show control buttons + * @key headful + * @run main bug4624353 + */ + +import java.awt.Component; +import java.awt.Container; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + +public class bug4624353 { + static volatile boolean passed = true; + static JFrame fr; + static JFileChooser fc; + + public static void main(String args[]) throws Exception { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + + try { + SwingUtilities.invokeAndWait(() -> { + fr = new JFrame("bug4624353"); + fc = new JFileChooser(); + fc.setControlButtonsAreShown(false); + fr.getContentPane().add(fc); + fr.pack(); + fr.setVisible(true); + + passAround(fc); + }); + if (!passed) { + throw new RuntimeException("Test failed"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (fr != null) { + fr.dispose(); + } + }); + } + } + + public static void passAround(Container c) { + Component[] list = c.getComponents(); + if (list.length == 0) { + return; + } + for (int i = 0; i < list.length; i++) { + if (list[i] != null) { + if ((list[i] instanceof JButton) && + "OK".equals(((JButton)list[i]).getText())) { + passed = false; + return; + } + passAround((Container)list[i]); + } + } + } +} diff --git a/test/jdk/javax/swing/JFileChooser/bug4673161.java b/test/jdk/javax/swing/JFileChooser/bug4673161.java new file mode 100644 index 00000000000..82b6a5ea69c --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug4673161.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ + +/* + * @test + * @bug 4673161 + * @requires (os.family == "windows") + * @summary Tests if JFileChooser preferred size depends on selected files + * @run main bug4673161 + */ + +import java.awt.Dimension; +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.UIManager; + +public class bug4673161 { + + public static void main(String[] args) throws Exception { + JFileChooser fc = new JFileChooser(); + Dimension d = fc.getPreferredSize(); + JFileChooser fc2 = new JFileChooser(); + File[] files = new File[50]; + for (int i = 0; i < 50; i++) { + files[i] = new File("file" + i); + } + fc2.setSelectedFiles(files); + Dimension d2 = fc2.getPreferredSize(); + if (!d.equals(d2)) { + throw new RuntimeException("Test failed: JFileChooser preferred " + + "size depends on selected files"); + } + + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + + JFileChooser fc3 = new JFileChooser(); + d = fc3.getPreferredSize(); + fc2 = new JFileChooser(); + files = new File[50]; + for (int i = 0; i < 50; i++) { + files[i] = new File("file" + i); + } + fc2.setSelectedFiles(files); + d2 = fc2.getPreferredSize(); + if (!d.equals(d2)) { + throw new RuntimeException("Test failed: JFileChooser preferred " + + "size depends on selected files"); + } + } +} diff --git a/test/jdk/javax/swing/JFileChooser/bug4782168.java b/test/jdk/javax/swing/JFileChooser/bug4782168.java new file mode 100644 index 00000000000..0bfeb46ed18 --- /dev/null +++ b/test/jdk/javax/swing/JFileChooser/bug4782168.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ + +/* + * @test + * @bug 4782168 + * @summary Tests if DefaultShellFolder.isHidden() crashes for the + root folder on Solaris + * @modules java.desktop/sun.awt.shell + * @run main bug4782168 + */ + +public class bug4782168 { + + public static void main(String args[]) throws Exception { + sun.awt.shell.ShellFolder sf = sun.awt.shell.ShellFolder. + getShellFolder(new java.io.File("/")); + sf.isHidden(); + } +} diff --git a/test/jdk/javax/swing/JLabel/bug4822331.java b/test/jdk/javax/swing/JLabel/bug4822331.java new file mode 100644 index 00000000000..5de8d88fc85 --- /dev/null +++ b/test/jdk/javax/swing/JLabel/bug4822331.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4822331 + * @summary setLaberFor does not transfer focus to the JSpinner editor + * @library /test/lib + * @key headful + * @run main bug4822331 + */ + +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; +import java.awt.FlowLayout; +import java.awt.Robot; +import javax.swing.JButton; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JSpinner; +import javax.swing.SwingUtilities; +import jdk.test.lib.Platform; + +public class bug4822331 { + + static JFrame fr; + static JButton button; + static JSpinner spinner; + static volatile boolean tfFocused = false; + static volatile boolean passed = false; + + public static void main(String []args) throws Exception { + bug4822331 test = new bug4822331(); + test.init(); + } + + public void init() throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + fr = new JFrame("Test"); + fr.getContentPane().setLayout(new FlowLayout()); + + button = new JButton("Button"); + fr.getContentPane().add(button); + + spinner = new JSpinner(); + JLabel spinnerLabel = new JLabel("spinner"); + spinnerLabel.setDisplayedMnemonic(KeyEvent.VK_S); + spinnerLabel.setLabelFor(spinner); + fr.getContentPane().add(spinnerLabel); + fr.getContentPane().add(spinner); + + JSpinner.DefaultEditor editor = + (JSpinner.DefaultEditor) spinner.getEditor(); + JFormattedTextField ftf = editor.getTextField(); + ftf.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + passed = true; + } + }); + fr.pack(); + fr.setVisible(true); + }); + start(); + if ( !passed ) { + throw new RuntimeException("The activation of spinner's " + + "mnemonic didn't focus the editor component."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (fr != null) { + fr.dispose(); + } + }); + } + } + + public void start() throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(50); + robot.delay(1000); + robot.waitForIdle(); + button.requestFocus(); + if (Platform.isOSX()) { + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyPress(KeyEvent.VK_ALT); + robot.keyPress(KeyEvent.VK_S); + robot.keyRelease(KeyEvent.VK_S); + robot.keyRelease(KeyEvent.VK_ALT); + robot.keyRelease(KeyEvent.VK_CONTROL); + } else { + robot.keyPress(KeyEvent.VK_ALT); + robot.keyPress(KeyEvent.VK_S); + robot.keyRelease(KeyEvent.VK_S); + robot.keyRelease(KeyEvent.VK_ALT); + } + } +} diff --git a/test/jdk/javax/swing/JOptionPane/bug4191835.java b/test/jdk/javax/swing/JOptionPane/bug4191835.java new file mode 100644 index 00000000000..17709e9a8b9 --- /dev/null +++ b/test/jdk/javax/swing/JOptionPane/bug4191835.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* + * @test + * @bug 4191835 + * @summary JOptionPane should allow Dialog as window owner. + * @key headful + * @run main bug4191835 + */ + +import java.awt.Dialog; +import javax.swing.JDialog; +import javax.swing.JOptionPane; + +public class bug4191835 { + + public static void main(String[] args) { + JOptionPane op = new JOptionPane(); + Dialog dlg = new Dialog(new JDialog()); + JDialog jd = op.createDialog(dlg, "Dialog"); + } +} From e6cec8f1a81e32860200ebdcaf506c37935531ba Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Mon, 11 Mar 2024 12:21:05 +0000 Subject: [PATCH 026/149] 8325137: com/sun/management/ThreadMXBean/ThreadCpuTimeArray.java can fail in Xcomp with out of expected range Backport-of: 91d8dac9cff5689abcf2fc8950b15d284f933afd --- .../com/sun/management/ThreadMXBean/ThreadCpuTimeArray.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jdk/com/sun/management/ThreadMXBean/ThreadCpuTimeArray.java b/test/jdk/com/sun/management/ThreadMXBean/ThreadCpuTimeArray.java index c7fded7399e..b3c7b064b30 100644 --- a/test/jdk/com/sun/management/ThreadMXBean/ThreadCpuTimeArray.java +++ b/test/jdk/com/sun/management/ThreadMXBean/ThreadCpuTimeArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ * @summary Basic test of ThreadMXBean.getThreadCpuTime(long[]) and * getThreadUserTime(long[]). * @author Paul Hohensee + * @requires vm.compMode != "Xcomp" */ import java.lang.management.*; From c8ca55bafa8137f48ccb184539e8fa4e609faa09 Mon Sep 17 00:00:00 2001 From: Ekaterina Vergizova Date: Mon, 11 Mar 2024 12:48:27 +0000 Subject: [PATCH 027/149] 8314220: Configurable InlineCacheBuffer size Reviewed-by: phh Backport-of: a40d8d97e84d88d1a65aba81bfc09339be95e427 --- src/hotspot/share/code/icBuffer.cpp | 2 +- src/hotspot/share/code/stubs.cpp | 2 -- src/hotspot/share/compiler/compilerDefinitions.cpp | 5 +++++ src/hotspot/share/runtime/globals.hpp | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/code/icBuffer.cpp b/src/hotspot/share/code/icBuffer.cpp index 1cc58fd6920..2f735cf36ac 100644 --- a/src/hotspot/share/code/icBuffer.cpp +++ b/src/hotspot/share/code/icBuffer.cpp @@ -111,7 +111,7 @@ void InlineCacheBuffer::init_next_stub() { void InlineCacheBuffer::initialize() { if (_buffer != NULL) return; // already initialized - _buffer = new StubQueue(new ICStubInterface, 10*K, InlineCacheBuffer_lock, "InlineCacheBuffer"); + _buffer = new StubQueue(new ICStubInterface, checked_cast(InlineCacheBufferSize), InlineCacheBuffer_lock, "InlineCacheBuffer"); assert (_buffer != NULL, "cannot allocate InlineCacheBuffer"); init_next_stub(); } diff --git a/src/hotspot/share/code/stubs.cpp b/src/hotspot/share/code/stubs.cpp index 81717b919ba..a35d74f1ad5 100644 --- a/src/hotspot/share/code/stubs.cpp +++ b/src/hotspot/share/code/stubs.cpp @@ -214,8 +214,6 @@ void StubQueue::verify() { guarantee(0 <= _queue_begin && _queue_begin < _buffer_limit, "_queue_begin out of bounds"); guarantee(0 <= _queue_end && _queue_end <= _buffer_limit, "_queue_end out of bounds"); // verify alignment - guarantee(_buffer_size % CodeEntryAlignment == 0, "_buffer_size not aligned"); - guarantee(_buffer_limit % CodeEntryAlignment == 0, "_buffer_limit not aligned"); guarantee(_queue_begin % CodeEntryAlignment == 0, "_queue_begin not aligned"); guarantee(_queue_end % CodeEntryAlignment == 0, "_queue_end not aligned"); // verify buffer limit/size relationship diff --git a/src/hotspot/share/compiler/compilerDefinitions.cpp b/src/hotspot/share/compiler/compilerDefinitions.cpp index 0a762b32a32..cd5f0827ef9 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.cpp +++ b/src/hotspot/share/compiler/compilerDefinitions.cpp @@ -313,6 +313,11 @@ bool CompilerConfig::check_args_consistency(bool status) { "Invalid NonNMethodCodeHeapSize=%dK. Must be at least %uK.\n", NonNMethodCodeHeapSize/K, min_code_cache_size/K); status = false; + } else if (InlineCacheBufferSize > NonNMethodCodeHeapSize / 2) { + jio_fprintf(defaultStream::error_stream(), + "Invalid InlineCacheBufferSize=" SIZE_FORMAT "K. Must be less than or equal to " SIZE_FORMAT "K.\n", + InlineCacheBufferSize/K, NonNMethodCodeHeapSize/2/K); + status = false; } #ifdef _LP64 diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index e4434d6610d..ad318420865 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -409,6 +409,9 @@ define_pd_global(uint64_t,MaxRAM, 1ULL*G); product(bool, UseInlineCaches, true, \ "Use Inline Caches for virtual calls ") \ \ + experimental(size_t, InlineCacheBufferSize, 10*K, \ + "InlineCacheBuffer size") \ + \ diagnostic(bool, InlineArrayCopy, true, \ "Inline arraycopy native that is known to be part of " \ "base library DLL") \ From 29f300eb2ac4c038fad7f8e09eab8a53b69526c6 Mon Sep 17 00:00:00 2001 From: Jiawei Tang Date: Mon, 11 Mar 2024 21:50:42 +0000 Subject: [PATCH 028/149] 8322511: [11u] JfrCheckpointThreadClosure::do_thread crashes when fetching thread_id Reviewed-by: phh --- src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp index 7b92b75be8f..7eb62f5d01d 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp @@ -101,7 +101,7 @@ void JfrCheckpointThreadClosure::do_thread(Thread* t) { if (t->is_Java_thread()) { JavaThread* const jt = (JavaThread*)t; _writer.write(jt->name()); - _writer.write(java_lang_Thread::thread_id(jt->threadObj())); + _writer.write(jt->threadObj() != NULL ? java_lang_Thread::thread_id(jt->threadObj()) : 0); _writer.write(JfrThreadGroup::thread_group_id(jt, _curthread)); // since we are iterating threads during a safepoint, also issue notification JfrJavaEventWriter::notify(jt); From 84ff9b3d1162b04cd4f0da8234e7755fe8568ebb Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 12 Mar 2024 02:22:56 +0000 Subject: [PATCH 029/149] 8320342: Use PassFailJFrame for TruncatedPopupMenuTest.java Backport-of: 1f2922ad8526d378ee7b616e5423ce56f20340db --- .../awt/PopupMenu/TruncatedPopupMenuTest.java | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 test/jdk/java/awt/PopupMenu/TruncatedPopupMenuTest.java diff --git a/test/jdk/java/awt/PopupMenu/TruncatedPopupMenuTest.java b/test/jdk/java/awt/PopupMenu/TruncatedPopupMenuTest.java new file mode 100644 index 00000000000..64d655aa351 --- /dev/null +++ b/test/jdk/java/awt/PopupMenu/TruncatedPopupMenuTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2004, 2024, 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. + * + * 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. + */ + +import java.awt.Frame; +import java.awt.Menu; +import java.awt.MenuItem; +import java.awt.PopupMenu; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/* + * @test + * @bug 5090643 + * @key headful + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary Menus added to the popup menu are truncated on XToolkit + * @run main/manual TruncatedPopupMenuTest + */ + +public class TruncatedPopupMenuTest { + private static final String INSTRUCTIONS = + "1. Right-click on the Test Window.\n\n" + + "2. Look at the appeared popup menu.\n\n" + + "3. It should consist of one menu item (\"First simple menu item\")\n" + + "and one submenu (\"Just simple menu for the test\").\n\n" + + "4. The submenu should not be truncated. The submenu title text should\n" + + "be followed by a triangle. On the whole, menu should be good-looking.\n\n" + + "5. Left-click on the submenu (\"Just simple menu for the test\").\n" + + "After this operation, a submenu should popup. It should consist of\n"+ + "one menu item (\"Second simple menu item \") and one submenu (\"Other Menu\").\n\n" + + "6. The submenu should not be truncated. The \"Other Menu\" text should be followed by\n" + + "a triangle.\n\n" + + "On the whole, menu should be good-looking.\n"; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(20) + .columns(55) + .testUI(TruncatedPopupMenuTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static Frame createTestUI() { + Menu subMenu = new Menu("Just simple menu for the test"); + subMenu.add(new MenuItem("Second simple menu item")); + subMenu.add(new Menu("Other Menu")); + + PopupMenu popup = new PopupMenu(); + popup.add(new MenuItem("First simple menu item")); + popup.add(subMenu); + + Frame testUI = new Frame("TruncatedPopupMenuTest"); + testUI.add(popup); + testUI.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + if (me.isPopupTrigger()) { + popup.show(me.getComponent(), me.getX(), me.getY()); + } + } + public void mouseReleased(MouseEvent me) { + if (me.isPopupTrigger()) { + popup.show(me.getComponent(), me.getX(), me.getY()); + } + } + }); + + testUI.setSize(400, 400); + return testUI; + } +} From 21b88dba7fb33da2bc975cf7ac689ad5951ac90a Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 12 Mar 2024 09:23:17 +0000 Subject: [PATCH 030/149] 8320113: [macos14] : ShapeNotSetSometimes.java fails intermittently on macOS 14 Backport-of: f1b73350c237021c04ceac2f29f1f378630bd651 --- .../ShapeNotSetSometimes.java | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java b/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java index 20ca18587ef..48a0e75ead0 100644 --- a/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java +++ b/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, 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 @@ -21,45 +21,50 @@ * questions. */ -/* - @test - @key headful - @bug 6988428 - @summary Tests whether shape is always set - @author anthony.petrov@oracle.com: area=awt.toplevel - @run main ShapeNotSetSometimes -*/ import java.awt.Color; +import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Frame; import java.awt.Graphics; import java.awt.Point; import java.awt.Rectangle; import java.awt.Robot; +import java.awt.Toolkit; import java.awt.geom.Area; import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; +/* + * @test + * @key headful + * @bug 6988428 + * @summary Tests whether shape is always set + * @run main ShapeNotSetSometimes + */ public class ShapeNotSetSometimes { private Frame backgroundFrame; private Frame window; - private static final Color BACKGROUND_COLOR = Color.GREEN; - private static final Color SHAPE_COLOR = Color.WHITE; + private Point[] pointsOutsideToCheck; private Point[] shadedPointsToCheck; private Point innerPoint; - private final Rectangle bounds = new Rectangle(220, 400, 300, 300); private static Robot robot; + private static final Color BACKGROUND_COLOR = Color.GREEN; + private static final Color SHAPE_COLOR = Color.WHITE; public ShapeNotSetSometimes() throws Exception { EventQueue.invokeAndWait(this::initializeGUI); robot.waitForIdle(); + robot.delay(1000); } private void initializeGUI() { @@ -124,7 +129,7 @@ public void paint(Graphics g) { public static void main(String[] args) throws Exception { robot = new Robot(); - for(int i = 0; i < 50; i++) { + for (int i = 1; i <= 50; i++) { System.out.println("Attempt " + i); new ShapeNotSetSometimes().doTest(); } @@ -136,7 +141,6 @@ private void doTest() throws Exception { EventQueue.invokeAndWait(window::toFront); robot.waitForIdle(); - robot.delay(500); try { @@ -173,8 +177,8 @@ private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpecte ); if (mustBeExpectedColor != expectedColor.equals(actualColor)) { + captureScreen(); System.out.printf("window.getX() = %3d, window.getY() = %3d\n", window.getX(), window.getY()); - System.err.printf( "Checking for transparency failed: point: %3d, %3d\n\tactual %s\n\texpected %s%s\n", screenX, @@ -185,4 +189,18 @@ private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpecte throw new RuntimeException("Test failed. The shape has not been applied."); } } + + private static void captureScreen() { + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + Rectangle screenBounds = new Rectangle(0, 0, screenSize.width, screenSize.height); + try { + ImageIO.write( + robot.createScreenCapture(screenBounds), + "png", + new File("Screenshot.png") + ); + } catch (IOException e) { + e.printStackTrace(); + } + } } From 069fbd7770ecde71d9137df3c5ca378ffd6c0ae7 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 12 Mar 2024 09:24:43 +0000 Subject: [PATCH 031/149] 8326891: Prefer RPATH over RUNPATH for $ORIGIN rpaths in internal JDK binaries Backport-of: 721bfee53af5bc2e2d67eebc7b82f09a642d5309 --- make/autoconf/flags-cflags.m4 | 10 ++++++++-- test/jdk/tools/launcher/RunpathTest.java | 23 +++++++++++------------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 3c5ba9cccec..df7fe5f9fef 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -28,7 +28,7 @@ # Setup flags for C/C++ compiler # -############################################################################### +################################################################################ # # How to compile shared libraries. # @@ -39,7 +39,10 @@ AC_DEFUN([FLAGS_SETUP_SHARED_LIBS], # Default works for linux, might work on other platforms as well. SHARED_LIBRARY_FLAGS='-shared' - SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1' + # --disable-new-dtags forces use of RPATH instead of RUNPATH for rpaths. + # This protects internal library dependencies within the JDK from being + # overridden using LD_LIBRARY_PATH. See JDK-8326891 for more information. + SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1 -Wl,--disable-new-dtags' SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN" SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1' SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1' @@ -59,6 +62,9 @@ AC_DEFUN([FLAGS_SETUP_SHARED_LIBS], # Default works for linux, might work on other platforms as well. SHARED_LIBRARY_FLAGS='-shared' SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1' + if test "x$OPENJDK_TARGET_OS" = xlinux; then + SET_EXECUTABLE_ORIGIN="$SET_EXECUTABLE_ORIGIN -Wl,--disable-new-dtags" + fi SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1' SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1' diff --git a/test/jdk/tools/launcher/RunpathTest.java b/test/jdk/tools/launcher/RunpathTest.java index 8f761e13bff..2246587f092 100644 --- a/test/jdk/tools/launcher/RunpathTest.java +++ b/test/jdk/tools/launcher/RunpathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, 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 @@ -24,7 +24,8 @@ /* * @test * @bug 7190813 8022719 - * @summary Check for extended RPATHs on *nixes + * @summary Check for extended RPATHs on Linux + * @requires os.family == "linux" * @compile -XDignore.symbol.file RunpathTest.java * @run main RunpathTest * @author ksrini @@ -57,25 +58,23 @@ void elfCheck(String javacmd, String expectedRpath) { final TestResult tr = doExec(elfreaderCmd, "-d", javacmd); if (!tr.matches(expectedRpath)) { System.out.println(tr); - throw new RuntimeException("FAILED: RPATH/RUNPATH strings " + + throw new RuntimeException("FAILED: RPATH strings " + expectedRpath + " not found in " + javaCmd); } - System.out.println(javacmd + " contains expected RPATHS/RUNPATH"); + System.out.println(javacmd + " contains expected RPATHS"); } void testRpath() { - String expectedRpath = ".*R(UN)?PATH.*\\$ORIGIN/../lib.*"; + String expectedRpath = ".*RPATH.*\\$ORIGIN/../lib.*"; elfCheck(javaCmd, expectedRpath); } public static void main(String... args) throws Exception { - if (isSolaris || isLinux) { - RunpathTest rp = new RunpathTest(); - if (rp.elfreaderCmd == null) { - System.err.println("Warning: test passes vacuously"); - return; - } - rp.testRpath(); + RunpathTest rp = new RunpathTest(); + if (rp.elfreaderCmd == null) { + System.err.println("Warning: test passes vacuously"); + return; } + rp.testRpath(); } } From 5cf250f14f78832d0b58de42c9c998ed49c040b8 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 12 Mar 2024 13:41:30 +0000 Subject: [PATCH 032/149] 8292716: Configure should check that jtreg is of the required version 8292763: JDK-8292716 breaks configure without jtreg Reviewed-by: phh, shade Backport-of: 9288072655a689c06a03f85c976bbd2f0744d3d5 --- make/autoconf/toolchain.m4 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4 index 1bba0eb88ea..6b28a865a09 100644 --- a/make/autoconf/toolchain.m4 +++ b/make/autoconf/toolchain.m4 @@ -61,6 +61,9 @@ TOOLCHAIN_MINIMUM_VERSION_xlc="" # Minimum supported linker versions, empty means unspecified TOOLCHAIN_MINIMUM_LD_VERSION_gcc="2.18" +# Minimum supported version +JTREG_MINIMUM_VERSION=6.1 + # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called. # Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER. # $1 - optional variable prefix for compiler and version variables (BUILD_) @@ -1144,6 +1147,24 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG], UTIL_FIXUP_EXECUTABLE(JTREGEXE) UTIL_FIXUP_PATH(JT_HOME) AC_SUBST(JT_HOME) + + # Verify jtreg version + if test "x$JT_HOME" != x; then + AC_MSG_CHECKING([jtreg version number]) + # jtreg -version looks like this: "jtreg 6.1+1-19" + # Extract actual version part ("6.1" in this case) + jtreg_version_full=`$JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2` + jtreg_version=${jtreg_version_full/%+*} + AC_MSG_RESULT([$jtreg_version]) + + # This is a simplified version of TOOLCHAIN_CHECK_COMPILER_VERSION + comparable_actual_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$jtreg_version"` + comparable_minimum_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$JTREG_MINIMUM_VERSION"` + if test $comparable_actual_version -lt $comparable_minimum_version ; then + AC_MSG_ERROR([jtreg version is too old, at least version $JTREG_MINIMUM_VERSION is required]) + fi + fi + AC_SUBST(JTREGEXE) ]) From 1b3c570c605cfdada5b3531071f0c3fd4d843f6f Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 12 Mar 2024 18:50:21 +0000 Subject: [PATCH 033/149] 8290203: ProblemList vmTestbase/nsk/jvmti/scenarios/capability/CM03/cm03t001/TestDescription.java on linux-all Backport-of: ce36f6ea855a7ede02df969e6bb599ac36ac04fe --- test/hotspot/jtreg/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 82db95efa23..73b6f649078 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -252,6 +252,7 @@ vmTestbase/nsk/jvmti/unit/heap/HeapWalkTests/TestDescription.java 8016181 generi vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/TestDescription.java 8219652 aix-ppc64 vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/TestDescription.java 8219652 aix-ppc64 vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/TestDescription.java 8219652 aix-ppc64 +vmTestbase/nsk/jvmti/scenarios/capability/CM03/cm03t001/TestDescription.java 8073470 linux-all vmTestbase/gc/lock/jni/jnilock002/TestDescription.java 8192647 generic-all From a097faa97273b31400c356866f07319bd4be3194 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Wed, 13 Mar 2024 08:22:27 +0000 Subject: [PATCH 034/149] 8320129: "top" command during jtreg failure handler does not display CPU usage on OSX Backport-of: 8be3e39220cd64521f4e370011958e17e5fdeaf3 --- test/failure_handler/src/share/conf/mac.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/failure_handler/src/share/conf/mac.properties b/test/failure_handler/src/share/conf/mac.properties index 26b2b428a49..8342ad3255a 100644 --- a/test/failure_handler/src/share/conf/mac.properties +++ b/test/failure_handler/src/share/conf/mac.properties @@ -99,7 +99,7 @@ system.sysctl.args=-a process.ps.app=ps process.ps.args=-Meo pid,pcpu,cputime,start,pmem,vsz,rss,state,wchan,user,args process.top.app=top -process.top.args=-l 1 +process.top.args=-l 2 memory.vmstat.app=vm_stat memory.vmstat.args=-c 3 3 From 7de6f3f6ac1b2fe50a466b612718ed673aa70a19 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Wed, 13 Mar 2024 08:31:03 +0000 Subject: [PATCH 035/149] 8314283: Support for NSS tests on aarch64 platforms Reviewed-by: lucy Backport-of: 2a8016096000de5836251f2ca9bc8ad6479e6942 --- .../security/pkcs11/KeyStore/ClientAuth.java | 4 ++ test/jdk/sun/security/pkcs11/PKCS11Test.java | 51 ++++++++++++------- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java b/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java index 5c609b26fd3..482624f06cb 100644 --- a/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java +++ b/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java @@ -383,6 +383,10 @@ void startClient (boolean newThread) { * Our client thread just died. */ System.err.println("Client died..."); + // if the exception is thrown before connecting to the + // server, the test will time out and the exception will + // be lost/hidden. + e.printStackTrace(System.err); clientException = e; } }); diff --git a/test/jdk/sun/security/pkcs11/PKCS11Test.java b/test/jdk/sun/security/pkcs11/PKCS11Test.java index b14daf6c6d7..9f0d9287589 100644 --- a/test/jdk/sun/security/pkcs11/PKCS11Test.java +++ b/test/jdk/sun/security/pkcs11/PKCS11Test.java @@ -80,6 +80,11 @@ public abstract class PKCS11Test { private static final String DEFAULT_POLICY = BASE + SEP + ".." + SEP + "policy"; + // Version of the NSS artifact. This coincides with the version of + // the NSS version + private static final String NSS_BUNDLE_VERSION = "3.91"; + private static final String NSSLIB = "jpg.tests.jdk.nsslib"; + // directory corresponding to BASE in the /closed hierarchy static final String CLOSED_BASE; @@ -923,18 +928,21 @@ static byte[] generateData(int length) { private static String fetchNssLib(String osId) { switch (osId) { - case "Windows-x86-32": - return fetchNssLib(WINDOWS_X86.class); - case "Windows-amd64-64": return fetchNssLib(WINDOWS_X64.class); case "MacOSX-x86_64-64": return fetchNssLib(MACOSX_X64.class); + case "MacOSX-aarch64-64": + return fetchNssLib(MACOSX_AARCH64.class); + case "Linux-amd64-64": return fetchNssLib(LINUX_X64.class); + case "Linux-aarch64-64": + return fetchNssLib(LINUX_AARCH64.class); + default: return null; } @@ -944,8 +952,8 @@ private static String fetchNssLib(Class clazz) { String path = null; try { path = ArtifactResolver.resolve(clazz).entrySet().stream() - .findAny().get().getValue() + File.separator + "nsslib" - + File.separator; + .findAny().get().getValue() + File.separator + "nss" + + File.separator + "lib" + File.separator; } catch (ArtifactResolverException e) { Throwable cause = e.getCause(); if (cause == null) { @@ -986,30 +994,39 @@ protected void copyNssCertKeyToClassesDir(Path dbPath) throws IOException { } @Artifact( - organization = "jpg.tests.jdk.nsslib", + organization = NSSLIB, name = "nsslib-windows_x64", - revision = "3.46-VS2017", + revision = NSS_BUNDLE_VERSION, extension = "zip") private static class WINDOWS_X64 { } @Artifact( - organization = "jpg.tests.jdk.nsslib", - name = "nsslib-windows_x86", - revision = "3.46-VS2017", + organization = NSSLIB, + name = "nsslib-macosx_x64", + revision = NSS_BUNDLE_VERSION, extension = "zip") - private static class WINDOWS_X86 { } + private static class MACOSX_X64 { } @Artifact( - organization = "jpg.tests.jdk.nsslib", - name = "nsslib-macosx_x64", - revision = "3.46", + organization = NSSLIB, + name = "nsslib-macosx_aarch64", + revision = NSS_BUNDLE_VERSION, extension = "zip") - private static class MACOSX_X64 { } + private static class MACOSX_AARCH64 { } @Artifact( - organization = "jpg.tests.jdk.nsslib", + organization = NSSLIB, name = "nsslib-linux_x64", - revision = "3.46", + revision = NSS_BUNDLE_VERSION, extension = "zip") private static class LINUX_X64 { } + + @Artifact( + organization = NSSLIB, + name = "nsslib-linux_aarch64", + revision = NSS_BUNDLE_VERSION, + extension = "zip" + ) + private static class LINUX_AARCH64{ + } } From 1d102e8f8afab928195550534110213ee31ace2e Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Wed, 13 Mar 2024 08:31:19 +0000 Subject: [PATCH 036/149] 8248667: Need support for building native libraries located in the test/lib directory Reviewed-by: lucy Backport-of: 1356a0f1ac06b006a20ca9fa2306ef60aef5c16e --- make/Main.gmk | 22 +++++- make/test/BuildTestLib.gmk | 6 +- make/test/BuildTestLibNative.gmk | 83 +++++++++++++++++++++ test/lib/jdk/test/lib/apps/libLingeredApp.c | 42 +++++++++++ 4 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 make/test/BuildTestLibNative.gmk create mode 100644 test/lib/jdk/test/lib/apps/libLingeredApp.c diff --git a/make/Main.gmk b/make/Main.gmk index 5a48954ca10..2c08532626a 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -554,6 +554,18 @@ test-image-jdk-jtreg-native: +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNativeJdk.gmk \ test-image-jdk-jtreg-native) +# Native files needed by the testlib +build-test-lib-native: + +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLibNative.gmk \ + build-test-lib-native) + +test-image-lib-native: + +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLibNative.gmk \ + test-image-lib-native) + +# Native files needed when testing the testlib itself +# ... build-test-libtest-jtreg-native etc not yet backported + build-test-hotspot-jtreg-graal: +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregGraalUnit.gmk \ build-test-hotspot-jtreg-graal) @@ -596,7 +608,8 @@ endif ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \ test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \ - test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \ + test-image-jdk-jtreg-native build-test-lib-native test-image-lib-native \ + build-test-lib build-test-failure-handler \ test-failure-handler test-image-failure-handler test-image-hotspot-gtest \ test-image-hotspot-jtreg-graal build-test-hotspot-jtreg-graal \ run-test exploded-run-test @@ -976,12 +989,16 @@ else build-test-jdk-jtreg-native: buildtools-jdk java.base-libs + build-test-lib-native: buildtools-jdk java.base-libs + build-test-hotspot-jtreg-graal: exploded-image-optimize test-image-hotspot-jtreg-native: build-test-hotspot-jtreg-native test-image-jdk-jtreg-native: build-test-jdk-jtreg-native + test-image-lib-native: build-test-lib-native + test-image-hotspot-jtreg-graal: build-test-hotspot-jtreg-graal test-image-hotspot-gtest: hotspot @@ -1141,7 +1158,8 @@ endif # This target builds the test image test-image: prepare-test-image \ - test-image-jdk-jtreg-native test-image-failure-handler \ + test-image-jdk-jtreg-native test-image-lib-native \ + test-image-failure-handler \ test-image-demos-jdk $(JVM_TEST_IMAGE_TARGETS) ################################################################################ diff --git a/make/test/BuildTestLib.gmk b/make/test/BuildTestLib.gmk index 7593ac74766..c10c087574a 100644 --- a/make/test/BuildTestLib.gmk +++ b/make/test/BuildTestLib.gmk @@ -45,12 +45,14 @@ $(eval $(call SetupJavaCompilation, BUILD_WB_JAR, \ TARGETS += $(BUILD_WB_JAR) -# test-lib.jar will contain only hprof classes until JDK-8081381 is resolved $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \ SETUP := GENERATE_USINGJDKBYTECODE, \ - SRC := $(TEST_LIB_SOURCE_DIR)/jdk/test/lib/hprof, \ + SRC := $(TEST_LIB_SOURCE_DIR), \ + EXCLUDES := jdk/test/lib/containers jdk/test/lib/security, \ BIN := $(TEST_LIB_SUPPORT)/test-lib_classes, \ + HEADERS := $(TEST_LIB_SUPPORT)/test-lib_headers, \ JAR := $(TEST_LIB_SUPPORT)/test-lib.jar, \ + DISABLED_WARNINGS := try deprecation rawtypes unchecked serial cast, \ )) TARGETS += $(BUILD_TEST_LIB_JAR) diff --git a/make/test/BuildTestLibNative.gmk b/make/test/BuildTestLibNative.gmk new file mode 100644 index 00000000000..00c7607913b --- /dev/null +++ b/make/test/BuildTestLibNative.gmk @@ -0,0 +1,83 @@ +# +# Copyright (c) 2020, 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. +# + +################################################################################ +# This file builds the native component of testlib. +# It also covers the test-image part, where the built files are copied to the +# test image. +################################################################################ + +default: all + +include $(SPEC) +include MakeBase.gmk +include TestFilesCompilation.gmk + +################################################################################ +# Targets for building the native tests themselves. +################################################################################ + +BUILD_LIBTEST_NATIVE_SRC := $(TOPDIR)/test/lib + +BUILD_LIBTEST_OUTPUT_DIR := $(OUTPUTDIR)/support/test/lib/native + +BUILD_LIBTEST_IMAGE_DIR := $(TEST_IMAGE_DIR)/lib + +# This evaluation is expensive and should only be done if this target was +# explicitly called. +ifneq ($(filter build-test-lib-native, $(MAKECMDGOALS)), ) + $(eval $(call SetupTestFilesCompilation, BUILD_LIBTEST_LIBRARIES, \ + TYPE := LIBRARY, \ + SOURCE_DIRS := $(BUILD_LIBTEST_NATIVE_SRC), \ + OUTPUT_DIR := $(BUILD_LIBTEST_OUTPUT_DIR), \ + )) +endif + +build-test-lib-native: $(BUILD_LIBTEST_LIBRARIES) + +################################################################################ +# Targets for building test-image. +################################################################################ + +# Copy to testlib test image. We need it in both hotspot and jdk. +$(eval $(call SetupCopyFiles, COPY_LIBTEST_NATIVE_TO_HOTSPOT, \ + SRC := $(BUILD_LIBTEST_OUTPUT_DIR), \ + DEST := $(TEST_IMAGE_DIR)/hotspot/jtreg/native, \ + FILES := $(wildcard $(addprefix $(BUILD_LIBTEST_OUTPUT_DIR), /lib/*)), \ + FLATTEN := true, \ +)) + +$(eval $(call SetupCopyFiles, COPY_LIBTEST_NATIVE_TO_JDK, \ + SRC := $(BUILD_LIBTEST_OUTPUT_DIR), \ + DEST := $(TEST_IMAGE_DIR)/jdk/jtreg/native, \ + FILES := $(wildcard $(addprefix $(BUILD_LIBTEST_OUTPUT_DIR), /lib/*)), \ + FLATTEN := true, \ +)) + +test-image-lib-native: $(COPY_LIBTEST_NATIVE_TO_HOTSPOT) $(COPY_LIBTEST_NATIVE_TO_JDK) + +all: build-test-lib-native + +.PHONY: default all build-test-lib-native test-image-lib-native diff --git a/test/lib/jdk/test/lib/apps/libLingeredApp.c b/test/lib/jdk/test/lib/apps/libLingeredApp.c new file mode 100644 index 00000000000..d02c3e7b8bb --- /dev/null +++ b/test/lib/jdk/test/lib/apps/libLingeredApp.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include + +// Borrowed from hotspot vmError.cpp. +// Returns an address which is guaranteed to generate a SIGSEGV on read, +// which is not NULL and contains bits in every word +void* get_segfault_address() { + return (void*) +#ifdef _LP64 + 0xABC0000000000ABCULL; +#else + 0x00000ABC; +#endif +} + +JNIEXPORT jint JNICALL +Java_jdk_test_lib_apps_LingeredApp_crash(JNIEnv *env, jclass clss) +{ + return *(jint *)get_segfault_address(); +} From 0f09d0ba6cf21e5b4b50e3827fb62c55be8953c7 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Thu, 14 Mar 2024 09:04:23 +0000 Subject: [PATCH 037/149] 8324238: [macOS] java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java fails with the shape has not been applied msg Backport-of: 62c9530c056dbaaf65be0f43295af3d225326a4c --- .../ShapeNotSetSometimes.java | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java b/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java index 48a0e75ead0..52a5754a9c3 100644 --- a/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java +++ b/test/jdk/java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java @@ -21,8 +21,6 @@ * questions. */ - - import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; @@ -44,7 +42,7 @@ * @key headful * @bug 6988428 * @summary Tests whether shape is always set - * @run main ShapeNotSetSometimes + * @run main/othervm -Dsun.java2d.uiScale=1 ShapeNotSetSometimes */ public class ShapeNotSetSometimes { @@ -55,22 +53,24 @@ public class ShapeNotSetSometimes { private Point[] pointsOutsideToCheck; private Point[] shadedPointsToCheck; private Point innerPoint; - private final Rectangle bounds = new Rectangle(220, 400, 300, 300); private static Robot robot; private static final Color BACKGROUND_COLOR = Color.GREEN; private static final Color SHAPE_COLOR = Color.WHITE; + private static final int DIM = 300; + private static final int DELTA = 2; public ShapeNotSetSometimes() throws Exception { EventQueue.invokeAndWait(this::initializeGUI); robot.waitForIdle(); - robot.delay(1000); + robot.delay(500); } private void initializeGUI() { backgroundFrame = new BackgroundFrame(); backgroundFrame.setUndecorated(true); - backgroundFrame.setBounds(bounds); + backgroundFrame.setSize(DIM, DIM); + backgroundFrame.setLocationRelativeTo(null); backgroundFrame.setVisible(true); Area area = new Area(); @@ -81,8 +81,10 @@ private void initializeGUI() { area.add(new Area(new Ellipse2D.Float(150, 50, 100, 100))); area.add(new Area(new Ellipse2D.Float(150, 100, 100, 100))); - + // point at the center of white ellipse innerPoint = new Point(150, 130); + + // mid points on the 4 sides - on the green background frame pointsOutsideToCheck = new Point[] { new Point(150, 20), new Point(280, 120), @@ -90,6 +92,7 @@ private void initializeGUI() { new Point(20, 120) }; + // points just outside the ellipse (opposite side of diagonal) shadedPointsToCheck = new Point[] { new Point(62, 62), new Point(240, 185) @@ -97,7 +100,8 @@ private void initializeGUI() { window = new TestFrame(); window.setUndecorated(true); - window.setBounds(bounds); + window.setSize(DIM, DIM); + window.setLocationRelativeTo(null); window.setShape(area); window.setVisible(true); } @@ -108,7 +112,7 @@ static class BackgroundFrame extends Frame { public void paint(Graphics g) { g.setColor(BACKGROUND_COLOR); - g.fillRect(0, 0, 300, 300); + g.fillRect(0, 0, DIM, DIM); super.paint(g); } @@ -120,7 +124,7 @@ class TestFrame extends Frame { public void paint(Graphics g) { g.setColor(SHAPE_COLOR); - g.fillRect(0, 0, bounds.width, bounds.height); + g.fillRect(0, 0, DIM, DIM); super.paint(g); } @@ -155,17 +159,24 @@ private void doTest() throws Exception { } } finally { EventQueue.invokeAndWait(() -> { - backgroundFrame.dispose(); - window.dispose(); + if (backgroundFrame != null) { + backgroundFrame.dispose(); + } + if (window != null) { + window.dispose(); + } }); } } private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpectedColor) { - int screenX = window.getX() + x; int screenY = window.getY() + y; + robot.mouseMove(screenX, screenY); + robot.waitForIdle(); + robot.delay(50); + Color actualColor = robot.getPixelColor(screenX, screenY); System.out.printf( @@ -176,7 +187,7 @@ private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpecte expectedColor ); - if (mustBeExpectedColor != expectedColor.equals(actualColor)) { + if (mustBeExpectedColor != colorCompare(expectedColor, actualColor)) { captureScreen(); System.out.printf("window.getX() = %3d, window.getY() = %3d\n", window.getX(), window.getY()); System.err.printf( @@ -190,6 +201,15 @@ private void colorCheck(int x, int y, Color expectedColor, boolean mustBeExpecte } } + private static boolean colorCompare(Color expected, Color actual) { + if (Math.abs(expected.getRed() - actual.getRed()) <= DELTA + && Math.abs(expected.getGreen() - actual.getGreen()) <= DELTA + && Math.abs(expected.getBlue() - actual.getBlue()) <= DELTA) { + return true; + } + return false; + } + private static void captureScreen() { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle screenBounds = new Rectangle(0, 0, screenSize.width, screenSize.height); From 2921ad6bb89c91ef7992a1eefa93e9a670512f54 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 14 Mar 2024 20:16:21 +0000 Subject: [PATCH 038/149] 8321489: Update LCMS to 2.16 Backport-of: dc7d3b182d226253ca246dd854c85c4dd964f10e --- src/java.desktop/share/legal/lcms.md | 39 +- .../share/native/liblcms/cmsalpha.c | 26 +- .../share/native/liblcms/cmscgats.c | 487 ++++++++++++++---- .../share/native/liblcms/cmscnvrt.c | 41 +- .../share/native/liblcms/cmserr.c | 7 +- .../share/native/liblcms/cmsgamma.c | 28 +- .../share/native/liblcms/cmsgmt.c | 4 +- .../share/native/liblcms/cmsio0.c | 27 +- .../share/native/liblcms/cmsio1.c | 12 +- .../share/native/liblcms/cmslut.c | 11 +- .../share/native/liblcms/cmsnamed.c | 250 ++++++++- .../share/native/liblcms/cmsopt.c | 14 +- .../share/native/liblcms/cmspack.c | 185 ++++++- .../share/native/liblcms/cmsplugin.c | 21 +- .../share/native/liblcms/cmsps2.c | 187 +++---- .../share/native/liblcms/cmssamp.c | 2 +- .../share/native/liblcms/cmstypes.c | 271 +++++++++- .../share/native/liblcms/cmsvirt.c | 137 ++++- .../share/native/liblcms/cmsxform.c | 15 +- src/java.desktop/share/native/liblcms/lcms2.h | 53 +- .../share/native/liblcms/lcms2_internal.h | 7 +- 21 files changed, 1465 insertions(+), 359 deletions(-) diff --git a/src/java.desktop/share/legal/lcms.md b/src/java.desktop/share/legal/lcms.md index da86a9c47ca..02af4fff000 100644 --- a/src/java.desktop/share/legal/lcms.md +++ b/src/java.desktop/share/legal/lcms.md @@ -1,34 +1,29 @@ -## Little Color Management System (LCMS) v2.15 +## Little Color Management System (LCMS) v2.16 ### LCMS License

    -README.1ST file information
     
    -LittleCMS core is released under MIT License
    +MIT License
     
    ----------------------------------
    -
    -Little CMS
    -Copyright (c) 1998-2023 Marti Maria Saguer
    +Copyright (C) 1998-2023 Marti Maria Saguer
     
     Permission is hereby granted, free of charge, to any person obtaining
    -a copy of this software and associated documentation files (the
    -"Software"), to deal in the Software without restriction, including
    -without limitation the rights to use, copy, modify, merge, publish,
    -distribute, sublicense, and/or sell copies of the Software, and to
    -permit persons to whom the Software is furnished to do so, subject
    -to the following conditions:
    +a copy of this software and associated documentation files (the "Software"),
    +to deal in the Software without restriction, including without limitation
    +the rights to use, copy, modify, merge, publish, distribute, sublicense,
    +and/or sell copies of the Software, and to permit persons to whom the Software
    +is furnished to do so, subject to the following conditions:
     
    -The above copyright notice and this permission notice shall be
    -included in all copies or substantial portions of the Software.
    +The above copyright notice and this permission notice shall be included in
    +all copies or substantial portions of the Software.
     
     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
    +THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     
     ---------------------------------
     The below license applies to the following files:
    @@ -47,7 +42,6 @@ Users of this code must verify correctness for their application.
     ### AUTHORS File Information
     ```
     
    -
     Main Author
     ------------
     Marti Maria
    @@ -91,6 +85,7 @@ Philipp Knechtges
     Amyspark
     Lovell Fuller
     Eli Schwartz
    +Diogo Teles Sant'Anna
     
     Special Thanks
     --------------
    diff --git a/src/java.desktop/share/native/liblcms/cmsalpha.c b/src/java.desktop/share/native/liblcms/cmsalpha.c
    index e69259e8a51..78d3ca6b671 100644
    --- a/src/java.desktop/share/native/liblcms/cmsalpha.c
    +++ b/src/java.desktop/share/native/liblcms/cmsalpha.c
    @@ -431,7 +431,7 @@ static cmsFormatterAlphaFn FormattersAlpha[6][6] = {
     
     // This function computes the distance from each component to the next one in bytes.
     static
    -void ComputeIncrementsForChunky(cmsUInt32Number Format,
    +cmsBool ComputeIncrementsForChunky(cmsUInt32Number Format,
                                     cmsUInt32Number ComponentStartingOrder[],
                                     cmsUInt32Number ComponentPointerIncrements[])
     {
    @@ -445,7 +445,7 @@ void ComputeIncrementsForChunky(cmsUInt32Number Format,
     
            // Sanity check
            if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS)
    -           return;
    +           return FALSE;
     
             memset(channels, 0, sizeof(channels));
     
    @@ -482,13 +482,15 @@ void ComputeIncrementsForChunky(cmsUInt32Number Format,
     
            for (i = 0; i < extra; i++)
                   ComponentStartingOrder[i] = channels[i + nchannels];
    +
    +       return TRUE;
     }
     
     
     
     //  On planar configurations, the distance is the stride added to any non-negative
     static
    -void ComputeIncrementsForPlanar(cmsUInt32Number Format,
    +cmsBool ComputeIncrementsForPlanar(cmsUInt32Number Format,
                                     cmsUInt32Number BytesPerPlane,
                                     cmsUInt32Number ComponentStartingOrder[],
                                     cmsUInt32Number ComponentPointerIncrements[])
    @@ -502,7 +504,7 @@ void ComputeIncrementsForPlanar(cmsUInt32Number Format,
     
            // Sanity check
            if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS)
    -           return;
    +           return FALSE;
     
            memset(channels, 0, sizeof(channels));
     
    @@ -538,29 +540,29 @@ void ComputeIncrementsForPlanar(cmsUInt32Number Format,
     
            for (i = 0; i < extra; i++)
                   ComponentStartingOrder[i] = channels[i + nchannels];
    +
    +       return TRUE;
     }
     
     
     
     // Dispatcher por chunky and planar RGB
     static
    -void  ComputeComponentIncrements(cmsUInt32Number Format,
    +cmsBool ComputeComponentIncrements(cmsUInt32Number Format,
                                      cmsUInt32Number BytesPerPlane,
                                      cmsUInt32Number ComponentStartingOrder[],
                                      cmsUInt32Number ComponentPointerIncrements[])
     {
            if (T_PLANAR(Format)) {
     
    -              ComputeIncrementsForPlanar(Format,  BytesPerPlane, ComponentStartingOrder, ComponentPointerIncrements);
    +              return ComputeIncrementsForPlanar(Format,  BytesPerPlane, ComponentStartingOrder, ComponentPointerIncrements);
            }
            else {
    -              ComputeIncrementsForChunky(Format,  ComponentStartingOrder, ComponentPointerIncrements);
    +              return ComputeIncrementsForChunky(Format,  ComponentStartingOrder, ComponentPointerIncrements);
            }
     
     }
     
    -
    -
     // Handles extra channels copying alpha if requested by the flags
     void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
                                                    void* out,
    @@ -595,8 +597,10 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
             return;
     
         // Compute the increments
    -    ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements);
    -    ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements);
    +    if (!ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements))
    +        return;
    +    if (!ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements))
    +        return;
     
         // Check for conversions 8, 16, half, float, dbl
         copyValueFn = _cmsGetFormatterAlpha(p->ContextID, p->InputFormat, p->OutputFormat);
    diff --git a/src/java.desktop/share/native/liblcms/cmscgats.c b/src/java.desktop/share/native/liblcms/cmscgats.c
    index 9d0aea27d73..57725ae4731 100644
    --- a/src/java.desktop/share/native/liblcms/cmscgats.c
    +++ b/src/java.desktop/share/native/liblcms/cmscgats.c
    @@ -87,7 +87,7 @@ typedef enum {
             SEOF,       // End of stream
             SSYNERROR,  // Syntax error found on stream
     
    -        // Keywords
    +        // IT8 symbols
     
             SBEGIN_DATA,
             SBEGIN_DATA_FORMAT,
    @@ -95,7 +95,19 @@ typedef enum {
             SEND_DATA_FORMAT,
             SKEYWORD,
             SDATA_FORMAT_ID,
    -        SINCLUDE
    +        SINCLUDE,
    +
    +        // Cube symbols
    +
    +        SDOMAIN_MAX,
    +        SDOMAIN_MIN,
    +        S_LUT1D_SIZE,
    +        S_LUT1D_INPUT_RANGE,
    +        S_LUT3D_SIZE,
    +        S_LUT3D_INPUT_RANGE,
    +        S_LUT_IN_VIDEO_RANGE,
    +        S_LUT_OUT_VIDEO_RANGE,
    +        STITLE
     
         } SYMBOL;
     
    @@ -178,6 +190,10 @@ typedef struct struct_it8 {
             cmsUInt32Number  TablesCount;                     // How many tables in this stream
             cmsUInt32Number  nTable;                          // The actual table
     
    +        // Partser type
    +        cmsBool        IsCUBE;
    +
    +        // Tables
             TABLE Tab[MAXTABLES];
     
             // Memory management
    @@ -237,8 +253,8 @@ typedef struct {
     
        } KEYWORD;
     
    -// The keyword->symbol translation table. Sorting is required.
    -static const KEYWORD TabKeys[] = {
    +// The keyword->symbol translation tables. Sorting is required.
    +static const KEYWORD TabKeysIT8[] = {
     
             {"$INCLUDE",               SINCLUDE},   // This is an extension!
             {".INCLUDE",               SINCLUDE},   // This is an extension!
    @@ -251,7 +267,25 @@ static const KEYWORD TabKeys[] = {
             {"KEYWORD",                SKEYWORD}
             };
     
    -#define NUMKEYS (sizeof(TabKeys)/sizeof(KEYWORD))
    +#define NUMKEYS_IT8 (sizeof(TabKeysIT8)/sizeof(KEYWORD))
    +
    +static const KEYWORD TabKeysCUBE[] = {
    +
    +        {"DOMAIN_MAX",             SDOMAIN_MAX },
    +        {"DOMAIN_MIN",             SDOMAIN_MIN },
    +        {"LUT_1D_SIZE",            S_LUT1D_SIZE },
    +        {"LUT_1D_INPUT_RANGE",     S_LUT1D_INPUT_RANGE },
    +        {"LUT_3D_SIZE",            S_LUT3D_SIZE },
    +        {"LUT_3D_INPUT_RANGE",     S_LUT3D_INPUT_RANGE },
    +        {"LUT_IN_VIDEO_RANGE",     S_LUT_IN_VIDEO_RANGE },
    +        {"LUT_OUT_VIDEO_RANGE",    S_LUT_OUT_VIDEO_RANGE },
    +        {"TITLE",                  STITLE }
    +
    +};
    +
    +#define NUMKEYS_CUBE (sizeof(TabKeysCUBE)/sizeof(KEYWORD))
    +
    +
     
     // Predefined properties
     
    @@ -455,7 +489,7 @@ void StringCat(string* s, const char* c)
     static
     cmsBool isseparator(int c)
     {
    -    return (c == ' ') || (c == '\t') ;
    +    return (c == ' ') || (c == '\t');
     }
     
     // Checks whatever c is a valid identifier char
    @@ -476,7 +510,7 @@ cmsBool isidchar(int c)
     static
     cmsBool isfirstidchar(int c)
     {
    -     return !isdigit(c) && ismiddle(c);
    +     return c != '-' && !isdigit(c) && ismiddle(c);
     }
     
     // Guess whether the supplied path looks like an absolute path
    @@ -515,13 +549,13 @@ cmsBool BuildAbsolutePath(const char *relPath, const char *basePath, char *buffe
         // Already absolute?
         if (isabsolutepath(relPath)) {
     
    -        strncpy(buffer, relPath, MaxLen);
    +        memcpy(buffer, relPath, MaxLen);
             buffer[MaxLen-1] = 0;
             return TRUE;
         }
     
         // No, search for last
    -    strncpy(buffer, basePath, MaxLen);
    +    memcpy(buffer, basePath, MaxLen);
         buffer[MaxLen-1] = 0;
     
         tail = strrchr(buffer, DIR_CHAR);
    @@ -603,10 +637,10 @@ void NextCh(cmsIT8* it8)
     
     // Try to see if current identifier is a keyword, if so return the referred symbol
     static
    -SYMBOL BinSrchKey(const char *id)
    +SYMBOL BinSrchKey(const char *id, int NumKeys, const KEYWORD* TabKeys)
     {
         int l = 1;
    -    int r = NUMKEYS;
    +    int r = NumKeys;
         int x, res;
     
         while (r >= l)
    @@ -776,7 +810,7 @@ cmsFloat64Number ParseFloatNumber(const char *Buffer)
     }
     
     
    -// Reads a string, special case to avoid infinite resursion on .include
    +// Reads a string, special case to avoid infinite recursion on .include
     static
     void InStringSymbol(cmsIT8* it8)
     {
    @@ -833,7 +867,9 @@ void InSymbol(cmsIT8* it8)
                 } while (isidchar(it8->ch));
     
     
    -            key = BinSrchKey(StringPtr(it8->id));
    +            key = BinSrchKey(StringPtr(it8->id),
    +                    it8->IsCUBE ? NUMKEYS_CUBE : NUMKEYS_IT8,
    +                    it8->IsCUBE ? TabKeysCUBE : TabKeysIT8);
                 if (key == SUNDEFINED) it8->sy = SIDENT;
                 else it8->sy = key;
     
    @@ -942,6 +978,7 @@ void InSymbol(cmsIT8* it8)
                             snprintf(buffer, sizeof(buffer), it8 ->DoubleFormatter, it8->dnum);
                         }
     
    +                    StringClear(it8->id);
                         StringCat(it8->id, buffer);
     
                         do {
    @@ -971,7 +1008,7 @@ void InSymbol(cmsIT8* it8)
             // Next line
             case '\r':
                 NextCh(it8);
    -            if (it8 ->ch == '\n')
    +            if (it8->ch == '\n')
                     NextCh(it8);
                 it8->sy = SEOLN;
                 it8->lineno++;
    @@ -1292,7 +1329,12 @@ KEYVALUE* AddToList(cmsIT8* it8, KEYVALUE** Head, const char *Key, const char *S
     
             // This may work for editing properties
     
    -        //     return SynError(it8, "duplicate key <%s>", Key);
    +        if (cmsstrcasecmp(Key, "NUMBER_OF_FIELDS") == 0 ||
    +            cmsstrcasecmp(Key, "NUMBER_OF_SETS") == 0) {
    +
    +            SynError(it8, "duplicate key <%s>", Key);
    +            return NULL;
    +        }
         }
         else {
     
    @@ -1413,6 +1455,8 @@ cmsHANDLE  CMSEXPORT cmsIT8Alloc(cmsContext ContextID)
         it8->MemoryBlock = NULL;
         it8->MemorySink  = NULL;
     
    +    it8->IsCUBE = FALSE;
    +
         it8 ->nTable = 0;
     
         it8->ContextID = ContextID;
    @@ -1694,7 +1738,7 @@ char* GetData(cmsIT8* it8, int nSet, int nField)
         int nSamples    = t -> nSamples;
         int nPatches    = t -> nPatches;
     
    -    if (nSet >= nPatches || nField >= nSamples)
    +    if (nSet < 0 || nSet >= nPatches || nField < 0 || nField >= nSamples)
             return NULL;
     
         if (!t->Data) return NULL;
    @@ -1879,11 +1923,14 @@ void WriteDataFormat(SAVESTREAM* fp, cmsIT8* it8)
            WriteStr(fp, " ");
            nSamples = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_FIELDS"));
     
    -       for (i = 0; i < nSamples; i++) {
    +       if (nSamples <= t->nSamples) {
     
    -              WriteStr(fp, t->DataFormat[i]);
    -              WriteStr(fp, ((i == (nSamples-1)) ? "\n" : "\t"));
    -          }
    +           for (i = 0; i < nSamples; i++) {
    +
    +               WriteStr(fp, t->DataFormat[i]);
    +               WriteStr(fp, ((i == (nSamples - 1)) ? "\n" : "\t"));
    +           }
    +       }
     
            WriteStr (fp, "END_DATA_FORMAT\n");
     }
    @@ -1893,39 +1940,42 @@ void WriteDataFormat(SAVESTREAM* fp, cmsIT8* it8)
     static
     void WriteData(SAVESTREAM* fp, cmsIT8* it8)
     {
    -       int  i, j;
    +       int  i, j, nPatches;
            TABLE* t = GetTable(it8);
     
            if (!t->Data) return;
     
            WriteStr (fp, "BEGIN_DATA\n");
     
    -       t->nPatches = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_SETS"));
    +       nPatches = satoi(cmsIT8GetProperty(it8, "NUMBER_OF_SETS"));
     
    -       for (i = 0; i < t-> nPatches; i++) {
    +       if (nPatches <= t->nPatches) {
     
    -              WriteStr(fp, " ");
    +           for (i = 0; i < nPatches; i++) {
     
    -              for (j = 0; j < t->nSamples; j++) {
    +               WriteStr(fp, " ");
     
    -                     char *ptr = t->Data[i*t->nSamples+j];
    +               for (j = 0; j < t->nSamples; j++) {
     
    -                     if (ptr == NULL) WriteStr(fp, "\"\"");
    -                     else {
    -                         // If value contains whitespace, enclose within quote
    +                   char* ptr = t->Data[i * t->nSamples + j];
     
    -                         if (strchr(ptr, ' ') != NULL) {
    +                   if (ptr == NULL) WriteStr(fp, "\"\"");
    +                   else {
    +                       // If value contains whitespace, enclose within quote
     
    -                             WriteStr(fp, "\"");
    -                             WriteStr(fp, ptr);
    -                             WriteStr(fp, "\"");
    -                         }
    -                         else
    -                            WriteStr(fp, ptr);
    -                     }
    +                       if (strchr(ptr, ' ') != NULL) {
     
    -                     WriteStr(fp, ((j == (t->nSamples-1)) ? "\n" : "\t"));
    -              }
    +                           WriteStr(fp, "\"");
    +                           WriteStr(fp, ptr);
    +                           WriteStr(fp, "\"");
    +                       }
    +                       else
    +                           WriteStr(fp, ptr);
    +                   }
    +
    +                   WriteStr(fp, ((j == (t->nSamples - 1)) ? "\n" : "\t"));
    +               }
    +           }
            }
            WriteStr (fp, "END_DATA\n");
     }
    @@ -1946,15 +1996,29 @@ cmsBool CMSEXPORT cmsIT8SaveToFile(cmsHANDLE hIT8, const char* cFileName)
     
         for (i=0; i < it8 ->TablesCount; i++) {
     
    -            cmsIT8SetTable(hIT8, i);
    -            WriteHeader(it8, &sd);
    -            WriteDataFormat(&sd, it8);
    -            WriteData(&sd, it8);
    +        TABLE* t;
    +
    +        if (cmsIT8SetTable(hIT8, i) < 0) goto Error;
    +
    +        /**
    +        * Check for wrong data
    +        */
    +        t = GetTable(it8);
    +        if (t->Data == NULL) goto Error;
    +        if (t->DataFormat == NULL) goto Error;
    +
    +        WriteHeader(it8, &sd);
    +        WriteDataFormat(&sd, it8);
    +        WriteData(&sd, it8);
         }
     
         if (fclose(sd.stream) != 0) return FALSE;
    -
         return TRUE;
    +
    +Error:
    +    fclose(sd.stream);
    +    return FALSE;
    +
     }
     
     
    @@ -2331,78 +2395,72 @@ void CookPointers(cmsIT8* it8)
         int idField, i;
         char* Fld;
         cmsUInt32Number j;
    -    cmsUInt32Number nOldTable = it8 ->nTable;
    +    cmsUInt32Number nOldTable = it8->nTable;
     
    -    for (j=0; j < it8 ->TablesCount; j++) {
    +    for (j = 0; j < it8->TablesCount; j++) {
     
    -    TABLE* t = it8 ->Tab + j;
    +        TABLE* t = it8->Tab + j;
     
    -    t -> SampleID = 0;
    -    it8 ->nTable = j;
    +        t->SampleID = 0;
    +        it8->nTable = j;
     
    -    for (idField = 0; idField < t -> nSamples; idField++)
    -    {
    -        if (t ->DataFormat == NULL){
    -            SynError(it8, "Undefined DATA_FORMAT");
    -            return;
    -        }
    +        for (idField = 0; idField < t->nSamples; idField++)
    +        {
    +            if (t->DataFormat == NULL) {
    +                SynError(it8, "Undefined DATA_FORMAT");
    +                return;
    +            }
     
    -        Fld = t->DataFormat[idField];
    -        if (!Fld) continue;
    +            Fld = t->DataFormat[idField];
    +            if (!Fld) continue;
     
     
    -        if (cmsstrcasecmp(Fld, "SAMPLE_ID") == 0) {
    +            if (cmsstrcasecmp(Fld, "SAMPLE_ID") == 0) {
     
    -            t -> SampleID = idField;
    -        }
    +                t->SampleID = idField;
    +            }
     
    -        // "LABEL" is an extension. It keeps references to forward tables
    +            // "LABEL" is an extension. It keeps references to forward tables
     
    -        if ((cmsstrcasecmp(Fld, "LABEL") == 0) || Fld[0] == '$') {
    +            if ((cmsstrcasecmp(Fld, "LABEL") == 0) || Fld[0] == '$') {
     
    -            // Search for table references...
    -            for (i = 0; i < t->nPatches; i++) {
    +                // Search for table references...
    +                for (i = 0; i < t->nPatches; i++) {
     
    -                char* Label = GetData(it8, i, idField);
    +                    char* Label = GetData(it8, i, idField);
     
    -                if (Label) {
    +                    if (Label) {
     
    -                    cmsUInt32Number k;
    +                        cmsUInt32Number k;
     
    -                    // This is the label, search for a table containing
    -                    // this property
    +                        // This is the label, search for a table containing
    +                        // this property
     
    -                    for (k = 0; k < it8->TablesCount; k++) {
    +                        for (k = 0; k < it8->TablesCount; k++) {
     
    -                        TABLE* Table = it8->Tab + k;
    -                        KEYVALUE* p;
    +                            TABLE* Table = it8->Tab + k;
    +                            KEYVALUE* p;
     
    -                        if (IsAvailableOnList(Table->HeaderList, Label, NULL, &p)) {
    +                            if (IsAvailableOnList(Table->HeaderList, Label, NULL, &p)) {
     
    -                            // Available, keep type and table
    -                            char Buffer[256];
    +                                // Available, keep type and table
    +                                char Buffer[256];
     
    -                            char* Type = p->Value;
    -                            int  nTable = (int)k;
    +                                char* Type = p->Value;
    +                                int  nTable = (int)k;
     
    -                            snprintf(Buffer, 255, "%s %d %s", Label, nTable, Type);
    +                                snprintf(Buffer, 255, "%s %d %s", Label, nTable, Type);
     
    -                            SetData(it8, i, idField, Buffer);
    +                                SetData(it8, i, idField, Buffer);
    +                            }
                             }
                         }
    -
    -
                     }
    -
                 }
    -
    -
             }
    -
    -    }
         }
     
    -    it8 ->nTable = nOldTable;
    +    it8->nTable = nOldTable;
     }
     
     // Try to infere if the file is a CGATS/IT8 file at all. Read first line
    @@ -2493,7 +2551,7 @@ cmsHANDLE  CMSEXPORT cmsIT8LoadFromMem(cmsContext ContextID, const void *Ptr, cm
         if (it8->MemoryBlock == NULL)
         {
             cmsIT8Free(hIT8);
    -        return FALSE;
    +        return NULL;
         }
     
         strncpy(it8 ->MemoryBlock, (const char*) Ptr, len);
    @@ -2505,7 +2563,7 @@ cmsHANDLE  CMSEXPORT cmsIT8LoadFromMem(cmsContext ContextID, const void *Ptr, cm
         if (!ParseIT8(it8, type-1)) {
     
             cmsIT8Free(hIT8);
    -        return FALSE;
    +        return NULL;
         }
     
         CookPointers(it8);
    @@ -2602,17 +2660,17 @@ cmsUInt32Number CMSEXPORT cmsIT8EnumProperties(cmsHANDLE hIT8, char ***PropertyN
         }
     
     
    -        Props = (char**)AllocChunk(it8, sizeof(char*) * n);
    -        if (Props != NULL) {
    -
    -                // Pass#2 - Fill pointers
    -                n = 0;
    -                for (p = t->HeaderList; p != NULL; p = p->Next) {
    -                        Props[n++] = p->Keyword;
    -                }
    +    Props = (char**)AllocChunk(it8, sizeof(char*) * n);
    +    if (Props != NULL) {
     
    +        // Pass#2 - Fill pointers
    +        n = 0;
    +        for (p = t->HeaderList; p != NULL; p = p->Next) {
    +            Props[n++] = p->Keyword;
             }
    -        *PropertyNames = Props;
    +
    +    }
    +    *PropertyNames = Props;
     
         return n;
     }
    @@ -2972,3 +3030,236 @@ void CMSEXPORT cmsIT8DefineDblFormat(cmsHANDLE hIT8, const char* Formatter)
         it8 ->DoubleFormatter[sizeof(it8 ->DoubleFormatter)-1] = 0;
     }
     
    +
    +static
    +cmsBool ReadNumbers(cmsIT8* cube, int n, cmsFloat64Number* arr)
    +{
    +    int i;
    +
    +    for (i = 0; i < n; i++) {
    +
    +        if (cube->sy == SINUM)
    +            arr[i] = cube->inum;
    +        else
    +            if (cube->sy == SDNUM)
    +                arr[i] = cube->dnum;
    +            else
    +                return SynError(cube, "Number expected");
    +
    +        InSymbol(cube);
    +    }
    +
    +    return CheckEOLN(cube);
    +}
    +
    +static
    +cmsBool ParseCube(cmsIT8* cube, cmsStage** Shaper, cmsStage** CLUT, char title[])
    +{
    +    cmsFloat64Number domain_min[3] = { 0, 0, 0 };
    +    cmsFloat64Number domain_max[3] = { 1.0, 1.0, 1.0 };
    +    cmsFloat64Number check_0_1[2] = { 0, 1.0 };
    +    int shaper_size = 0;
    +    int lut_size = 0;
    +    int i;
    +
    +    InSymbol(cube);
    +
    +    while (cube->sy != SEOF) {
    +        switch (cube->sy)
    +        {
    +        // Set profile description
    +        case STITLE:
    +            InSymbol(cube);
    +            if (!Check(cube, SSTRING, "Title string expected")) return FALSE;
    +            memcpy(title, StringPtr(cube->str), MAXSTR);
    +            title[MAXSTR - 1] = 0;
    +            InSymbol(cube);
    +            break;
    +
    +        // Define domain
    +        case SDOMAIN_MIN:
    +            InSymbol(cube);
    +            if (!ReadNumbers(cube, 3, domain_min)) return FALSE;
    +            break;
    +
    +        case SDOMAIN_MAX:
    +            InSymbol(cube);
    +            if (!ReadNumbers(cube, 3, domain_max)) return FALSE;
    +            break;
    +
    +        // Define shaper
    +        case S_LUT1D_SIZE:
    +            InSymbol(cube);
    +            if (!Check(cube, SINUM, "Shaper size expected")) return FALSE;
    +            shaper_size = cube->inum;
    +            InSymbol(cube);
    +            break;
    +
    +        // Deefine CLUT
    +        case S_LUT3D_SIZE:
    +            InSymbol(cube);
    +            if (!Check(cube, SINUM, "LUT size expected")) return FALSE;
    +            lut_size = cube->inum;
    +            InSymbol(cube);
    +            break;
    +
    +        // Range. If present, has to be 0..1.0
    +        case S_LUT1D_INPUT_RANGE:
    +        case S_LUT3D_INPUT_RANGE:
    +            InSymbol(cube);
    +            if (!ReadNumbers(cube, 2, check_0_1)) return FALSE;
    +            if (check_0_1[0] != 0 || check_0_1[1] != 1.0) {
    +                return SynError(cube, "Unsupported format");
    +            }
    +            break;
    +
    +        case SEOLN:
    +            InSymbol(cube);
    +            break;
    +
    +        default:
    +        case S_LUT_IN_VIDEO_RANGE:
    +        case S_LUT_OUT_VIDEO_RANGE:
    +            return SynError(cube, "Unsupported format");
    +
    +            // Read and create tables
    +        case SINUM:
    +        case SDNUM:
    +
    +            if (shaper_size > 0) {
    +
    +                cmsToneCurve* curves[3];
    +                cmsFloat32Number* shapers = (cmsFloat32Number*)_cmsMalloc(cube->ContextID, 3 * shaper_size * sizeof(cmsFloat32Number));
    +                if (shapers == NULL) return FALSE;
    +
    +                for (i = 0; i < shaper_size; i++) {
    +
    +                    cmsFloat64Number nums[3];
    +
    +                    if (!ReadNumbers(cube, 3, nums)) return FALSE;
    +
    +                    shapers[i + 0]               = (cmsFloat32Number) ((nums[0] - domain_min[0]) / (domain_max[0] - domain_min[0]));
    +                    shapers[i + 1 * shaper_size] = (cmsFloat32Number) ((nums[1] - domain_min[1]) / (domain_max[1] - domain_min[1]));
    +                    shapers[i + 2 * shaper_size] = (cmsFloat32Number) ((nums[2] - domain_min[2]) / (domain_max[2] - domain_min[2]));
    +                }
    +
    +                for (i = 0; i < 3; i++) {
    +
    +                    curves[i] = cmsBuildTabulatedToneCurveFloat(cube->ContextID, shaper_size,
    +                        &shapers[i * shaper_size]);
    +                    if (curves[i] == NULL) return FALSE;
    +                }
    +
    +                *Shaper = cmsStageAllocToneCurves(cube->ContextID, 3, curves);
    +
    +                cmsFreeToneCurveTriple(curves);
    +            }
    +
    +            if (lut_size > 0) {
    +
    +                int nodes = lut_size * lut_size * lut_size;
    +
    +                cmsFloat32Number* lut_table = _cmsMalloc(cube->ContextID, nodes * 3 * sizeof(cmsFloat32Number));
    +                if (lut_table == NULL) return FALSE;
    +
    +                for (i = 0; i < nodes; i++) {
    +
    +                    cmsFloat64Number nums[3];
    +
    +                    if (!ReadNumbers(cube, 3, nums)) return FALSE;
    +
    +                    lut_table[i * 3 + 2] = (cmsFloat32Number) ((nums[0] - domain_min[0]) / (domain_max[0] - domain_min[0]));
    +                    lut_table[i * 3 + 1] = (cmsFloat32Number) ((nums[1] - domain_min[1]) / (domain_max[1] - domain_min[1]));
    +                    lut_table[i * 3 + 0] = (cmsFloat32Number) ((nums[2] - domain_min[2]) / (domain_max[2] - domain_min[2]));
    +                }
    +
    +                *CLUT = cmsStageAllocCLutFloat(cube->ContextID, lut_size, 3, 3, lut_table);
    +                _cmsFree(cube->ContextID, lut_table);
    +            }
    +
    +            if (!Check(cube, SEOF, "Extra symbols found in file")) return FALSE;
    +        }
    +    }
    +
    +    return TRUE;
    +}
    +
    +// Share the parser to read .cube format and create RGB devicelink profiles
    +cmsHPROFILE CMSEXPORT cmsCreateDeviceLinkFromCubeFileTHR(cmsContext ContextID, const char* cFileName)
    +{
    +    cmsHPROFILE hProfile = NULL;
    +    cmsIT8* cube = NULL;
    +    cmsPipeline* Pipeline = NULL;
    +    cmsStage* CLUT = NULL;
    +    cmsStage* Shaper = NULL;
    +    cmsMLU* DescriptionMLU = NULL;
    +    char title[MAXSTR];
    +
    +    _cmsAssert(cFileName != NULL);
    +
    +    cube = (cmsIT8*) cmsIT8Alloc(ContextID);
    +    if (!cube) return NULL;
    +
    +    cube->IsCUBE = TRUE;
    +    cube->FileStack[0]->Stream = fopen(cFileName, "rt");
    +
    +    if (!cube->FileStack[0]->Stream) goto Done;
    +
    +    strncpy(cube->FileStack[0]->FileName, cFileName, cmsMAX_PATH - 1);
    +    cube->FileStack[0]->FileName[cmsMAX_PATH - 1] = 0;
    +
    +    if (!ParseCube(cube, &Shaper, &CLUT, title)) goto Done;
    +
    +    // Success on parsing, let's create the profile
    +    hProfile = cmsCreateProfilePlaceholder(ContextID);
    +    if (!hProfile) goto Done;
    +
    +    cmsSetProfileVersion(hProfile, 4.4);
    +
    +    cmsSetDeviceClass(hProfile, cmsSigLinkClass);
    +    cmsSetColorSpace(hProfile,  cmsSigRgbData);
    +    cmsSetPCS(hProfile,         cmsSigRgbData);
    +
    +    cmsSetHeaderRenderingIntent(hProfile, INTENT_PERCEPTUAL);
    +
    +    // Creates a Pipeline to hold CLUT and shaper
    +    Pipeline = cmsPipelineAlloc(ContextID, 3, 3);
    +    if (Pipeline == NULL) goto Done;
    +
    +    // Populates the pipeline
    +    if (Shaper != NULL) {
    +        if (!cmsPipelineInsertStage(Pipeline, cmsAT_BEGIN, Shaper))
    +            goto Done;
    +    }
    +
    +    if (CLUT != NULL) {
    +        if (!cmsPipelineInsertStage(Pipeline, cmsAT_END, CLUT))
    +            goto Done;
    +    }
    +
    +    // Propagate the description. We put no copyright because we know
    +    // nothing on the copyrighted state of the .cube
    +    DescriptionMLU = cmsMLUalloc(ContextID, 1);
    +    if (!cmsMLUsetUTF8(DescriptionMLU, cmsNoLanguage, cmsNoCountry, title)) goto Done;
    +
    +    // Flush the tags
    +    if (!cmsWriteTag(hProfile, cmsSigProfileDescriptionTag, DescriptionMLU)) goto Done;
    +    if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, (void*)Pipeline)) goto Done;
    +
    +Done:
    +
    +    if (DescriptionMLU != NULL)
    +        cmsMLUfree(DescriptionMLU);
    +
    +    if (Pipeline != NULL)
    +        cmsPipelineFree(Pipeline);
    +
    +    cmsIT8Free((cmsHANDLE) cube);
    +
    +    return hProfile;
    +}
    +
    +cmsHPROFILE CMSEXPORT cmsCreateDeviceLinkFromCubeFile(const char* cFileName)
    +{
    +    return cmsCreateDeviceLinkFromCubeFileTHR(NULL, cFileName);
    +}
    diff --git a/src/java.desktop/share/native/liblcms/cmscnvrt.c b/src/java.desktop/share/native/liblcms/cmscnvrt.c
    index b73d594f2ec..d18865b15b9 100644
    --- a/src/java.desktop/share/native/liblcms/cmscnvrt.c
    +++ b/src/java.desktop/share/native/liblcms/cmscnvrt.c
    @@ -263,7 +263,7 @@ cmsFloat64Number CHAD2Temp(const cmsMAT3* Chad)
     
     // Compute a CHAD based on a given temperature
     static
    -    void Temp2CHAD(cmsMAT3* Chad, cmsFloat64Number Temp)
    +void Temp2CHAD(cmsMAT3* Chad, cmsFloat64Number Temp)
     {
         cmsCIEXYZ White;
         cmsCIExyY ChromaticityOfWhite;
    @@ -744,6 +744,16 @@ int BlackPreservingGrayOnlySampler(CMSREGISTER const cmsUInt16Number In[], CMSRE
         return TRUE;
     }
     
    +
    +// Check whatever the profile is a CMYK->CMYK devicelink
    +static
    +cmsBool is_cmyk_devicelink(cmsHPROFILE hProfile)
    +{
    +    return cmsGetDeviceClass(hProfile) == cmsSigLinkClass &&
    +            cmsGetColorSpace(hProfile) == cmsSigCmykData &&
    +            cmsGetColorSpace(hProfile) == cmsSigCmykData;
    +}
    +
     // This is the entry for black-preserving K-only intents, which are non-ICC
     static
     cmsPipeline*  BlackPreservingKOnlyIntents(cmsContext     ContextID,
    @@ -776,14 +786,16 @@ cmsPipeline*  BlackPreservingKOnlyIntents(cmsContext     ContextID,
         lastProfilePos = nProfiles - 1;
         hLastProfile = hProfiles[lastProfilePos];
     
    -    while (lastProfilePos > 1)
    +    // Skip CMYK->CMYK devicelinks on ending
    +    while (is_cmyk_devicelink(hLastProfile))
         {
    -        hLastProfile = hProfiles[--lastProfilePos];
    -        if (cmsGetColorSpace(hLastProfile) != cmsSigCmykData ||
    -            cmsGetDeviceClass(hLastProfile) != cmsSigLinkClass)
    +        if (lastProfilePos < 2)
                 break;
    +
    +        hLastProfile = hProfiles[--lastProfilePos];
         }
     
    +
         preservationProfilesCount = lastProfilePos + 1;
     
         // Check for non-cmyk profiles
    @@ -800,7 +812,7 @@ cmsPipeline*  BlackPreservingKOnlyIntents(cmsContext     ContextID,
     
         // Create a LUT holding normal ICC transform
         bp.cmyk2cmyk = DefaultICCintents(ContextID,
    -                                     preservationProfilesCount,
    +        preservationProfilesCount,
             ICCIntents,
             hProfiles,
             BPC,
    @@ -812,7 +824,7 @@ cmsPipeline*  BlackPreservingKOnlyIntents(cmsContext     ContextID,
         // Now, compute the tone curve
         bp.KTone = _cmsBuildKToneCurve(ContextID,
             4096,
    -                                    preservationProfilesCount,
    +        preservationProfilesCount,
             ICCIntents,
             hProfiles,
             BPC,
    @@ -1002,12 +1014,13 @@ cmsPipeline* BlackPreservingKPlaneIntents(cmsContext     ContextID,
         lastProfilePos = nProfiles - 1;
         hLastProfile = hProfiles[lastProfilePos];
     
    -    while (lastProfilePos > 1)
    +    // Skip CMYK->CMYK devicelinks on ending
    +    while (is_cmyk_devicelink(hLastProfile))
         {
    -        hLastProfile = hProfiles[--lastProfilePos];
    -        if (cmsGetColorSpace(hLastProfile) != cmsSigCmykData ||
    -            cmsGetDeviceClass(hLastProfile) != cmsSigLinkClass)
    +        if (lastProfilePos < 2)
                 break;
    +
    +        hLastProfile = hProfiles[--lastProfilePos];
         }
     
         preservationProfilesCount = lastProfilePos + 1;
    @@ -1177,8 +1190,7 @@ cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID, cmsUIn
         cmsIntentsList* pt;
         cmsUInt32Number nIntents;
     
    -
    -    for (nIntents=0, pt = ctx->Intents; pt != NULL; pt = pt -> Next)
    +    for (nIntents=0, pt = DefaultIntents; pt != NULL; pt = pt -> Next)
         {
             if (nIntents < nMax) {
                 if (Codes != NULL)
    @@ -1191,7 +1203,7 @@ cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID, cmsUIn
             nIntents++;
         }
     
    -    for (nIntents=0, pt = DefaultIntents; pt != NULL; pt = pt -> Next)
    +    for (pt = ctx->Intents; pt != NULL; pt = pt -> Next)
         {
             if (nIntents < nMax) {
                 if (Codes != NULL)
    @@ -1203,6 +1215,7 @@ cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID, cmsUIn
     
             nIntents++;
         }
    +
         return nIntents;
     }
     
    diff --git a/src/java.desktop/share/native/liblcms/cmserr.c b/src/java.desktop/share/native/liblcms/cmserr.c
    index 739cc0b2c98..9fb7db89c9a 100644
    --- a/src/java.desktop/share/native/liblcms/cmserr.c
    +++ b/src/java.desktop/share/native/liblcms/cmserr.c
    @@ -101,7 +101,7 @@ long int CMSEXPORT cmsfilelength(FILE* f)
     //
     // This is the interface to low-level memory management routines. By default a simple
     // wrapping to malloc/free/realloc is provided, although there is a limit on the max
    -// amount of memoy that can be reclaimed. This is mostly as a safety feature to prevent
    +// amount of memory that can be reclaimed. This is mostly as a safety feature to prevent
     // bogus or evil code to allocate huge blocks that otherwise lcms would never need.
     
     #define MAX_MEMORY_FOR_ALLOC  ((cmsUInt32Number)(1024U*1024U*512U))
    @@ -121,7 +121,8 @@ cmsBool   _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plug
     static
     void* _cmsMallocDefaultFn(cmsContext ContextID, cmsUInt32Number size)
     {
    -    if (size > MAX_MEMORY_FOR_ALLOC) return NULL;  // Never allow over maximum
    +    // Never allow 0 or over maximum
    +    if (size == 0 || size > MAX_MEMORY_FOR_ALLOC) return NULL;
     
         return (void*) malloc(size);
     
    @@ -263,7 +264,7 @@ cmsBool  _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase *Data)
     
         // NULL forces to reset to defaults. In this special case, the defaults are stored in the context structure.
         // Remaining plug-ins does NOT have any copy in the context structure, but this is somehow special as the
    -    // context internal data should be malloce'd by using those functions.
    +    // context internal data should be malloc'ed by using those functions.
         if (Data == NULL) {
     
            struct _cmsContext_struct* ctx = ( struct _cmsContext_struct*) ContextID;
    diff --git a/src/java.desktop/share/native/liblcms/cmsgamma.c b/src/java.desktop/share/native/liblcms/cmsgamma.c
    index 08409434064..8e489a43c55 100644
    --- a/src/java.desktop/share/native/liblcms/cmsgamma.c
    +++ b/src/java.desktop/share/native/liblcms/cmsgamma.c
    @@ -329,6 +329,10 @@ cmsToneCurve* AllocateToneCurveStruct(cmsContext ContextID, cmsUInt32Number nEnt
             return p;
     
     Error:
    +    for (i=0; i < nSegments; i++) {
    +        if (p ->Segments && p ->Segments[i].SampledPoints) _cmsFree(ContextID, p ->Segments[i].SampledPoints);
    +        if (p ->SegInterp && p ->SegInterp[i]) _cmsFree(ContextID, p ->SegInterp[i]);
    +    }
         if (p -> SegInterp) _cmsFree(ContextID, p -> SegInterp);
         if (p -> Segments) _cmsFree(ContextID, p -> Segments);
         if (p -> Evals) _cmsFree(ContextID, p -> Evals);
    @@ -622,10 +626,16 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu
         case 6:
             e = Params[1]*R + Params[2];
     
    -        if (e < 0)
    -            Val = Params[3];
    -        else
    -            Val = pow(e, Params[0]) + Params[3];
    +        // On gamma 1.0, don't clamp
    +        if (Params[0] == 1.0) {
    +            Val = e + Params[3];
    +        }
    +        else {
    +            if (e < 0)
    +                Val = Params[3];
    +            else
    +                Val = pow(e, Params[0]) + Params[3];
    +        }
             break;
     
         // ((Y - c) ^1/Gamma - b) / a
    @@ -1520,13 +1530,13 @@ cmsFloat64Number CMSEXPORT cmsEstimateGamma(const cmsToneCurve* t, cmsFloat64Num
         return (sum / n);   // The mean
     }
     
    +// Retrieve segments on tone curves
     
    -// Retrieve parameters on one-segment tone curves
    -
    -cmsFloat64Number* CMSEXPORT cmsGetToneCurveParams(const cmsToneCurve* t)
    +const cmsCurveSegment* CMSEXPORT cmsGetToneCurveSegment(cmsInt32Number n, const cmsToneCurve* t)
     {
         _cmsAssert(t != NULL);
     
    -    if (t->nSegments != 1) return NULL;
    -    return t->Segments[0].Params;
    +    if (n < 0 || n >= (cmsInt32Number) t->nSegments) return NULL;
    +    return t->Segments + n;
     }
    +
    diff --git a/src/java.desktop/share/native/liblcms/cmsgmt.c b/src/java.desktop/share/native/liblcms/cmsgmt.c
    index 60a01aa5088..e9ee73b52cd 100644
    --- a/src/java.desktop/share/native/liblcms/cmsgmt.c
    +++ b/src/java.desktop/share/native/liblcms/cmsgmt.c
    @@ -248,7 +248,7 @@ int GamutSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Nu
         cmsUInt16Number Proof[cmsMAXCHANNELS], Proof2[cmsMAXCHANNELS];
         cmsFloat64Number dE1, dE2, ErrorRatio;
     
    -    // Assume in-gamut by default.
    +    // Assume in-gamut by default. NEVER READ, USED FOR DEBUG PURPOSES.
         ErrorRatio = 1.0;
     
         // Convert input to Lab
    @@ -625,7 +625,7 @@ cmsBool CMSEXPORT cmsDesaturateLab(cmsCIELab* Lab,
     // Actually, doing that "well" is quite hard, since every component may behave completely different.
     // Since the true point of this function is to detect suitable optimizations, I am imposing some requirements
     // that simplifies things: only RGB, and only profiles that can got in both directions.
    -// The algorithm obtains Y from a syntetical gray R=G=B. Then least squares fitting is used to estimate gamma.
    +// The algorithm obtains Y from a synthetical gray R=G=B. Then least squares fitting is used to estimate gamma.
     // For gamma close to 1.0, RGB is linear. On profiles not supported, -1 is returned.
     
     cmsFloat64Number CMSEXPORT cmsDetectRGBProfileGamma(cmsHPROFILE hProfile, cmsFloat64Number threshold)
    diff --git a/src/java.desktop/share/native/liblcms/cmsio0.c b/src/java.desktop/share/native/liblcms/cmsio0.c
    index fe6b3d43a5a..1b32f9f4159 100644
    --- a/src/java.desktop/share/native/liblcms/cmsio0.c
    +++ b/src/java.desktop/share/native/liblcms/cmsio0.c
    @@ -560,6 +560,20 @@ cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID)
         // Set default version
         Icc ->Version =  0x02100000;
     
    +    // Set default CMM (that's me!)
    +    Icc ->CMM = lcmsSignature;
    +
    +    // Set default creator
    +    // Created by LittleCMS (that's me!)
    +    Icc ->creator = lcmsSignature;
    +
    +    // Set default platform
    +#ifdef CMS_IS_WINDOWS_
    +    Icc ->platform = cmsSigMicrosoft;
    +#else
    +    Icc ->platform = cmsSigMacintosh;
    +#endif
    +
         // Set default device class
         Icc->DeviceClass = cmsSigDisplayClass;
     
    @@ -813,11 +827,13 @@ cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc)
         }
     
         // Adjust endianness of the used parameters
    +    Icc -> CMM             = _cmsAdjustEndianess32(Header.cmmId);
         Icc -> DeviceClass     = (cmsProfileClassSignature) _cmsAdjustEndianess32(Header.deviceClass);
         Icc -> ColorSpace      = (cmsColorSpaceSignature)   _cmsAdjustEndianess32(Header.colorSpace);
         Icc -> PCS             = (cmsColorSpaceSignature)   _cmsAdjustEndianess32(Header.pcs);
     
         Icc -> RenderingIntent = _cmsAdjustEndianess32(Header.renderingIntent);
    +    Icc -> platform        = (cmsPlatformSignature)_cmsAdjustEndianess32(Header.platform);
         Icc -> flags           = _cmsAdjustEndianess32(Header.flags);
         Icc -> manufacturer    = _cmsAdjustEndianess32(Header.manufacturer);
         Icc -> model           = _cmsAdjustEndianess32(Header.model);
    @@ -922,7 +938,7 @@ cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)
         cmsUInt32Number Count;
     
         Header.size        = _cmsAdjustEndianess32(UsedSpace);
    -    Header.cmmId       = _cmsAdjustEndianess32(lcmsSignature);
    +    Header.cmmId       = _cmsAdjustEndianess32(Icc ->CMM);
         Header.version     = _cmsAdjustEndianess32(Icc ->Version);
     
         Header.deviceClass = (cmsProfileClassSignature) _cmsAdjustEndianess32(Icc -> DeviceClass);
    @@ -934,11 +950,7 @@ cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)
     
         Header.magic       = _cmsAdjustEndianess32(cmsMagicNumber);
     
    -#ifdef CMS_IS_WINDOWS_
    -    Header.platform    = (cmsPlatformSignature) _cmsAdjustEndianess32(cmsSigMicrosoft);
    -#else
    -    Header.platform    = (cmsPlatformSignature) _cmsAdjustEndianess32(cmsSigMacintosh);
    -#endif
    +    Header.platform    = (cmsPlatformSignature) _cmsAdjustEndianess32(Icc -> platform);
     
         Header.flags        = _cmsAdjustEndianess32(Icc -> flags);
         Header.manufacturer = _cmsAdjustEndianess32(Icc -> manufacturer);
    @@ -954,8 +966,7 @@ cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)
         Header.illuminant.Y = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(cmsD50_XYZ()->Y));
         Header.illuminant.Z = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(cmsD50_XYZ()->Z));
     
    -    // Created by LittleCMS (that's me!)
    -    Header.creator      = _cmsAdjustEndianess32(lcmsSignature);
    +    Header.creator      = _cmsAdjustEndianess32(Icc ->creator);
     
         memset(&Header.reserved, 0, sizeof(Header.reserved));
     
    diff --git a/src/java.desktop/share/native/liblcms/cmsio1.c b/src/java.desktop/share/native/liblcms/cmsio1.c
    index bd8a832ac40..e42d4d38987 100644
    --- a/src/java.desktop/share/native/liblcms/cmsio1.c
    +++ b/src/java.desktop/share/native/liblcms/cmsio1.c
    @@ -607,7 +607,7 @@ cmsPipeline* _cmsReadFloatOutputTag(cmsHPROFILE hProfile, cmsTagSignature tagFlo
         return NULL;
     }
     
    -// Create an output MPE LUT from agiven profile. Version mismatches are handled here
    +// Create an output MPE LUT from a given profile. Version mismatches are handled here
     cmsPipeline* CMSEXPORT _cmsReadOutputLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent)
     {
         cmsTagTypeSignature OriginalType;
    @@ -1056,3 +1056,13 @@ cmsUInt32Number  CMSEXPORT cmsGetProfileInfoASCII(cmsHPROFILE hProfile, cmsInfoT
     
         return cmsMLUgetASCII(mlu, LanguageCode, CountryCode, Buffer, BufferSize);
     }
    +
    +cmsUInt32Number  CMSEXPORT cmsGetProfileInfoUTF8(cmsHPROFILE hProfile, cmsInfoType Info,
    +                                                          const char LanguageCode[3], const char CountryCode[3],
    +                                                          char* Buffer, cmsUInt32Number BufferSize)
    +{
    +    const cmsMLU* mlu = GetInfo(hProfile, Info);
    +    if (mlu == NULL) return 0;
    +
    +    return cmsMLUgetUTF8(mlu, LanguageCode, CountryCode, Buffer, BufferSize);
    +}
    diff --git a/src/java.desktop/share/native/liblcms/cmslut.c b/src/java.desktop/share/native/liblcms/cmslut.c
    index 24114632ad0..b544c948625 100644
    --- a/src/java.desktop/share/native/liblcms/cmslut.c
    +++ b/src/java.desktop/share/native/liblcms/cmslut.c
    @@ -504,6 +504,9 @@ cmsUInt32Number CubeSize(const cmsUInt32Number Dims[], cmsUInt32Number b)
             if (rv > UINT_MAX / dim) return 0;
         }
     
    +    // Again, prevent overflow
    +    if (rv > UINT_MAX / 15) return 0;
    +
         return rv;
     }
     
    @@ -843,7 +846,13 @@ cmsBool CMSEXPORT cmsStageSampleCLutFloat(cmsStage* mpe, cmsSAMPLERFLOAT Sampler
         cmsUInt32Number nInputs, nOutputs;
         cmsUInt32Number* nSamples;
         cmsFloat32Number In[MAX_INPUT_DIMENSIONS+1], Out[MAX_STAGE_CHANNELS];
    -    _cmsStageCLutData* clut = (_cmsStageCLutData*) mpe->Data;
    +    _cmsStageCLutData* clut;
    +
    +    if (mpe == NULL) return FALSE;
    +
    +    clut = (_cmsStageCLutData*)mpe->Data;
    +
    +    if (clut == NULL) return FALSE;
     
         nSamples = clut->Params ->nSamples;
         nInputs  = clut->Params ->nInputs;
    diff --git a/src/java.desktop/share/native/liblcms/cmsnamed.c b/src/java.desktop/share/native/liblcms/cmsnamed.c
    index 04280180230..d3cd97d4aea 100644
    --- a/src/java.desktop/share/native/liblcms/cmsnamed.c
    +++ b/src/java.desktop/share/native/liblcms/cmsnamed.c
    @@ -229,17 +229,145 @@ void strFrom16(char str[3], cmsUInt16Number n)
         str[0] = (char)(n >> 8);
         str[1] = (char)n;
         str[2] = (char)0;
    +}
    +
    +
    +// Convert from UTF8 to wchar, returns len.
    +static
    +cmsUInt32Number decodeUTF8(wchar_t* out, const char* in)
    +{
    +    cmsUInt32Number codepoint = 0;
    +    cmsUInt32Number size = 0;
    +
    +    while (*in)
    +    {
    +        cmsUInt8Number ch = (cmsUInt8Number) *in;
    +
    +        if (ch <= 0x7f)
    +        {
    +            codepoint = ch;
    +        }
    +        else if (ch <= 0xbf)
    +        {
    +            codepoint = (codepoint << 6) | (ch & 0x3f);
    +        }
    +        else if (ch <= 0xdf)
    +        {
    +            codepoint = ch & 0x1f;
    +        }
    +        else if (ch <= 0xef)
    +        {
    +            codepoint = ch & 0x0f;
    +        }
    +        else
    +        {
    +            codepoint = ch & 0x07;
    +        }
    +
    +        in++;
     
    +        if (((*in & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
    +        {
    +            if (sizeof(wchar_t) > 2)
    +            {
    +                if (out) *out++ = (wchar_t) codepoint;
    +                size++;
    +            }
    +            else
    +                if (codepoint > 0xffff)
    +                {
    +                    if (out)
    +                    {
    +                        *out++ = (wchar_t)(0xd800 + (codepoint >> 10));
    +                        *out++ = (wchar_t)(0xdc00 + (codepoint & 0x03ff));
    +                        size += 2;
    +                    }
    +                }
    +                else
    +                    if (codepoint < 0xd800 || codepoint >= 0xe000)
    +                    {
    +                        if (out) *out++ = (wchar_t) codepoint;
    +                        size++;
    +                    }
    +        }
    +    }
    +
    +    return size;
    +}
    +
    +// Convert from wchar_t to UTF8
    +static
    +cmsUInt32Number encodeUTF8(char* out, const wchar_t* in, cmsUInt32Number max_wchars, cmsUInt32Number max_chars)
    +{
    +    cmsUInt32Number codepoint = 0;
    +    cmsUInt32Number size = 0;
    +    cmsUInt32Number len_w = 0;
    +
    +    while (*in && len_w < max_wchars)
    +    {
    +        if (*in >= 0xd800 && *in <= 0xdbff)
    +            codepoint = ((*in - 0xd800) << 10) + 0x10000;
    +        else
    +        {
    +            if (*in >= 0xdc00 && *in <= 0xdfff)
    +                codepoint |= *in - 0xdc00;
    +            else
    +                codepoint = *in;
    +
    +            if (codepoint <= 0x7f)
    +            {
    +                if (out && (size + 1 < max_chars)) *out++ = (char)codepoint;
    +                size++;
    +            }
    +
    +            else if (codepoint <= 0x7ff)
    +            {
    +                if (out && (max_chars > 0) && (size + 2 < max_chars))
    +                {
    +                    *out++ = (char)(cmsUInt32Number)(0xc0 | ((codepoint >> 6) & 0x1f));
    +                    *out++ = (char)(cmsUInt32Number)(0x80 | (codepoint & 0x3f));
    +                }
    +                size += 2;
    +            }
    +            else if (codepoint <= 0xffff)
    +            {
    +                if (out && (max_chars > 0) && (size + 3 < max_chars))
    +                {
    +                    *out++ = (char)(cmsUInt32Number)(0xe0 | ((codepoint >> 12) & 0x0f));
    +                    *out++ = (char)(cmsUInt32Number)(0x80 | ((codepoint >> 6) & 0x3f));
    +                    *out++ = (char)(cmsUInt32Number)(0x80 | (codepoint & 0x3f));
    +                }
    +                size += 3;
    +            }
    +            else
    +            {
    +                if (out && (max_chars > 0) && (size + 4 < max_chars))
    +                {
    +                    *out++ = (char)(cmsUInt32Number)(0xf0 | ((codepoint >> 18) & 0x07));
    +                    *out++ = (char)(cmsUInt32Number)(0x80 | ((codepoint >> 12) & 0x3f));
    +                    *out++ = (char)(cmsUInt32Number)(0x80 | ((codepoint >> 6) & 0x3f));
    +                    *out++ = (char)(cmsUInt32Number)(0x80 | (codepoint & 0x3f));
    +                }
    +                size += 4;
    +            }
    +
    +            codepoint = 0;
    +        }
    +
    +        in++; len_w++;
    +    }
    +
    +    return size;
     }
     
     // Add an ASCII entry. Do not add any \0 termination (ICC1v43_2010-12.pdf page 61)
     // In the case the user explicitly sets an empty string, we force a \0
     cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString)
     {
    -    cmsUInt32Number i, len = (cmsUInt32Number) strlen(ASCIIString);
    +    cmsUInt32Number i, len = (cmsUInt32Number)strlen(ASCIIString);
         wchar_t* WStr;
         cmsBool  rc;
    -    cmsUInt16Number Lang  = strTo16(LanguageCode);
    +    cmsUInt16Number Lang = strTo16(LanguageCode);
         cmsUInt16Number Cntry = strTo16(CountryCode);
     
         if (mlu == NULL) return FALSE;
    @@ -247,22 +375,56 @@ cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const
         // len == 0 would prevent operation, so we set a empty string pointing to zero
         if (len == 0)
         {
    -        len = 1;
    +        wchar_t empty = 0;
    +        return AddMLUBlock(mlu, sizeof(wchar_t), &empty, Lang, Cntry);
         }
     
    -    WStr = (wchar_t*) _cmsCalloc(mlu ->ContextID, len,  sizeof(wchar_t));
    +    WStr = (wchar_t*)_cmsCalloc(mlu->ContextID, len, sizeof(wchar_t));
         if (WStr == NULL) return FALSE;
     
    -    for (i=0; i < len; i++)
    -        WStr[i] = (wchar_t) ASCIIString[i];
    +    for (i = 0; i < len; i++)
    +        WStr[i] = (wchar_t)ASCIIString[i];
     
    -    rc = AddMLUBlock(mlu, len  * sizeof(wchar_t), WStr, Lang, Cntry);
    +    rc = AddMLUBlock(mlu, len * sizeof(wchar_t), WStr, Lang, Cntry);
     
    -    _cmsFree(mlu ->ContextID, WStr);
    +    _cmsFree(mlu->ContextID, WStr);
         return rc;
     
     }
     
    +// Add an UTF8 entry. Do not add any \0 termination (ICC1v43_2010-12.pdf page 61)
    +// In the case the user explicitly sets an empty string, we force a \0
    +cmsBool CMSEXPORT cmsMLUsetUTF8(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* UTF8String)
    +{
    +    cmsUInt32Number UTF8len;
    +    wchar_t* WStr;
    +    cmsBool  rc;
    +    cmsUInt16Number Lang  = strTo16(LanguageCode);
    +    cmsUInt16Number Cntry = strTo16(CountryCode);
    +
    +    if (mlu == NULL) return FALSE;
    +
    +    if (*UTF8String == '\0')
    +    {
    +        wchar_t empty = 0;
    +        return AddMLUBlock(mlu, sizeof(wchar_t), &empty, Lang, Cntry);
    +    }
    +
    +    // Len excluding terminator 0
    +    UTF8len = decodeUTF8(NULL, UTF8String);
    +
    +    // Get space for dest
    +    WStr = (wchar_t*) _cmsCalloc(mlu ->ContextID, UTF8len,  sizeof(wchar_t));
    +    if (WStr == NULL) return FALSE;
    +
    +    decodeUTF8(WStr, UTF8String);
    +
    +    rc = AddMLUBlock(mlu, UTF8len  * sizeof(wchar_t), WStr, Lang, Cntry);
    +
    +    _cmsFree(mlu ->ContextID, WStr);
    +    return rc;
    +}
    +
     // We don't need any wcs support library
     static
     cmsUInt32Number mywcslen(const wchar_t *s)
    @@ -401,7 +563,7 @@ const wchar_t* _cmsMLUgetWide(const cmsMLU* mlu,
     
         if (v->StrW + v->Len > mlu->PoolSize) return NULL;
     
    -    return(wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v ->StrW);
    +    return (wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v ->StrW);
     }
     
     
    @@ -439,10 +601,12 @@ cmsUInt32Number CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
         // Precess each character
         for (i=0; i < ASCIIlen; i++) {
     
    -        if (Wide[i] == 0)
    -            Buffer[i] = 0;
    +        wchar_t wc = Wide[i];
    +
    +        if (wc < 0xff)
    +            Buffer[i] = (char)wc;
             else
    -            Buffer[i] = (char) Wide[i];
    +            Buffer[i] = '?';
         }
     
         // We put a termination "\0"
    @@ -450,6 +614,46 @@ cmsUInt32Number CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
         return ASCIIlen + 1;
     }
     
    +
    +// Obtain a UTF8 representation of the wide string. Setting buffer to NULL returns the len
    +cmsUInt32Number CMSEXPORT cmsMLUgetUTF8(const cmsMLU* mlu,
    +                                       const char LanguageCode[3], const char CountryCode[3],
    +                                       char* Buffer, cmsUInt32Number BufferSize)
    +{
    +    const wchar_t *Wide;
    +    cmsUInt32Number  StrLen = 0;
    +    cmsUInt32Number UTF8len;
    +
    +    cmsUInt16Number Lang  = strTo16(LanguageCode);
    +    cmsUInt16Number Cntry = strTo16(CountryCode);
    +
    +    // Sanitize
    +    if (mlu == NULL) return 0;
    +
    +    // Get WideChar
    +    Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
    +    if (Wide == NULL) return 0;
    +
    +    UTF8len = encodeUTF8(NULL, Wide, StrLen / sizeof(wchar_t), BufferSize);
    +
    +    // Maybe we want only to know the len?
    +    if (Buffer == NULL) return UTF8len + 1; // Note the zero at the end
    +
    +    // No buffer size means no data
    +    if (BufferSize <= 0) return 0;
    +
    +    // Some clipping may be required
    +    if (BufferSize < UTF8len + 1)
    +        UTF8len = BufferSize - 1;
    +
    +    // Process it
    +    encodeUTF8(Buffer, Wide, StrLen / sizeof(wchar_t), BufferSize);
    +
    +    // We put a termination "\0"
    +    Buffer[UTF8len] = 0;
    +    return UTF8len + 1;
    +}
    +
     // Obtain a wide representation of the MLU, on depending on current locale settings
     cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
                                           const char LanguageCode[3], const char CountryCode[3],
    @@ -470,12 +674,12 @@ cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
         // Maybe we want only to know the len?
         if (Buffer == NULL) return StrLen + sizeof(wchar_t);
     
    -  // No buffer size means no data
    -    if (BufferSize <= 0) return 0;
    +    // Invalid buffer size means no data
    +    if (BufferSize < sizeof(wchar_t)) return 0;
     
         // Some clipping may be required
         if (BufferSize < StrLen + sizeof(wchar_t))
    -        StrLen = BufferSize - + sizeof(wchar_t);
    +        StrLen = BufferSize - sizeof(wchar_t);
     
         memmove(Buffer, Wide, StrLen);
         Buffer[StrLen / sizeof(wchar_t)] = 0;
    @@ -843,13 +1047,19 @@ void CMSEXPORT cmsFreeProfileSequenceDescription(cmsSEQ* pseq)
     {
         cmsUInt32Number i;
     
    -    for (i=0; i < pseq ->n; i++) {
    -        if (pseq ->seq[i].Manufacturer != NULL) cmsMLUfree(pseq ->seq[i].Manufacturer);
    -        if (pseq ->seq[i].Model != NULL) cmsMLUfree(pseq ->seq[i].Model);
    -        if (pseq ->seq[i].Description != NULL) cmsMLUfree(pseq ->seq[i].Description);
    +    if (pseq == NULL)
    +        return;
    +
    +    if (pseq ->seq != NULL) {
    +        for (i=0; i < pseq ->n; i++) {
    +            if (pseq ->seq[i].Manufacturer != NULL) cmsMLUfree(pseq ->seq[i].Manufacturer);
    +            if (pseq ->seq[i].Model != NULL) cmsMLUfree(pseq ->seq[i].Model);
    +            if (pseq ->seq[i].Description != NULL) cmsMLUfree(pseq ->seq[i].Description);
    +        }
    +
    +        _cmsFree(pseq ->ContextID, pseq ->seq);
         }
     
    -    if (pseq ->seq != NULL) _cmsFree(pseq ->ContextID, pseq ->seq);
         _cmsFree(pseq -> ContextID, pseq);
     }
     
    diff --git a/src/java.desktop/share/native/liblcms/cmsopt.c b/src/java.desktop/share/native/liblcms/cmsopt.c
    index 3e81ae1df1b..421a4f4a701 100644
    --- a/src/java.desktop/share/native/liblcms/cmsopt.c
    +++ b/src/java.desktop/share/native/liblcms/cmsopt.c
    @@ -212,6 +212,7 @@ cmsBool  isFloatMatrixIdentity(const cmsMAT3* a)
     
            return TRUE;
     }
    +
     // if two adjacent matrices are found, multiply them.
     static
     cmsBool _MultiplyMatrix(cmsPipeline* Lut)
    @@ -1142,14 +1143,17 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte
     
             // Store result in curve
             for (t=0; t < OriginalLut ->InputChannels; t++)
    -            Trans[t] ->Table16[i] = _cmsQuickSaturateWord(Out[t] * 65535.0);
    +        {
    +            if (Trans[t]->Table16 != NULL)
    +                Trans[t] ->Table16[i] = _cmsQuickSaturateWord(Out[t] * 65535.0);
    +        }
         }
     
         // Slope-limit the obtained curves
         for (t = 0; t < OriginalLut ->InputChannels; t++)
             SlopeLimiting(Trans[t]);
     
    -    // Check for validity
    +    // Check for validity. lIsLinear is here for debug purposes
         lIsSuitable = TRUE;
         lIsLinear   = TRUE;
         for (t=0; (lIsSuitable && (t < OriginalLut ->InputChannels)); t++) {
    @@ -1753,6 +1757,8 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
     
                          _cmsStageMatrixData* Data = (_cmsStageMatrixData*)cmsStageData(Matrix1);
     
    +                     if (Matrix1->InputChannels != 3 || Matrix1->OutputChannels != 3) return FALSE;
    +
                          // Copy the matrix to our result
                          memcpy(&res, Data->Double, sizeof(res));
     
    @@ -1797,7 +1803,7 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
             _cmsStageToneCurvesData* mpeC2 = (_cmsStageToneCurvesData*) cmsStageData(Curve2);
     
             // In this particular optimization, cache does not help as it takes more time to deal with
    -        // the cache that with the pixel handling
    +        // the cache than with the pixel handling
             *dwFlags |= cmsFLAGS_NOCACHE;
     
             // Setup the optimizarion routines
    @@ -1954,7 +1960,7 @@ cmsBool CMSEXPORT _cmsOptimizePipeline(cmsContext ContextID,
         for (mpe = cmsPipelineGetPtrToFirstStage(*PtrLut);
             mpe != NULL;
             mpe = cmsStageNext(mpe)) {
    -        if (cmsStageType(mpe) == cmsSigNamedColorElemType) return FALSE;
    +            if (cmsStageType(mpe) == cmsSigNamedColorElemType) return FALSE;
         }
     
         // Try to get rid of identities and trivial conversions.
    diff --git a/src/java.desktop/share/native/liblcms/cmspack.c b/src/java.desktop/share/native/liblcms/cmspack.c
    index da5fc6019d3..fc875995a80 100644
    --- a/src/java.desktop/share/native/liblcms/cmspack.c
    +++ b/src/java.desktop/share/native/liblcms/cmspack.c
    @@ -2980,6 +2980,108 @@ cmsUInt8Number* PackFloatFrom16(CMSREGISTER _cmsTRANSFORM* info,
     
     // --------------------------------------------------------------------------------------------------------
     
    +static
    +cmsUInt8Number* PackBytesFromFloat(_cmsTRANSFORM* info,
    +                                    cmsFloat32Number wOut[],
    +                                    cmsUInt8Number* output,
    +                                    cmsUInt32Number Stride)
    +{
    +    cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
    +    cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
    +    cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
    +    cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
    +    cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
    +    cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
    +    cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
    +    cmsUInt8Number* swap1 = (cmsUInt8Number*)output;
    +    cmsFloat64Number v = 0;
    +    cmsUInt8Number vv = 0;
    +    cmsUInt32Number i, start = 0;
    +
    +    if (ExtraFirst)
    +        start = Extra;
    +
    +    for (i = 0; i < nChan; i++) {
    +
    +        cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
    +
    +        v = wOut[index] * 65535.0;
    +
    +        if (Reverse)
    +            v = 65535.0 - v;
    +
    +        vv =  FROM_16_TO_8(_cmsQuickSaturateWord(v));
    +
    +        if (Planar)
    +            ((cmsUInt8Number*)output)[(i + start) * Stride] = vv;
    +        else
    +            ((cmsUInt8Number*)output)[i + start] = vv;
    +    }
    +
    +
    +    if (Extra == 0 && SwapFirst) {
    +
    +        memmove(swap1 + 1, swap1, (nChan - 1) * sizeof(cmsUInt8Number));
    +        *swap1 = vv;
    +    }
    +
    +    if (T_PLANAR(info->OutputFormat))
    +        return output + sizeof(cmsUInt8Number);
    +    else
    +        return output + (nChan + Extra) * sizeof(cmsUInt8Number);
    +}
    +
    +static
    +cmsUInt8Number* PackWordsFromFloat(_cmsTRANSFORM* info,
    +                                    cmsFloat32Number wOut[],
    +                                    cmsUInt8Number* output,
    +                                    cmsUInt32Number Stride)
    +{
    +    cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
    +    cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
    +    cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
    +    cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
    +    cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
    +    cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
    +    cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
    +    cmsUInt16Number* swap1 = (cmsUInt16Number*)output;
    +    cmsFloat64Number v = 0;
    +    cmsUInt16Number vv = 0;
    +    cmsUInt32Number i, start = 0;
    +
    +    if (ExtraFirst)
    +        start = Extra;
    +
    +    for (i = 0; i < nChan; i++) {
    +
    +        cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
    +
    +        v = wOut[index] * 65535.0;
    +
    +        if (Reverse)
    +            v = 65535.0 - v;
    +
    +        vv = _cmsQuickSaturateWord(v);
    +
    +        if (Planar)
    +            ((cmsUInt16Number*)output)[(i + start) * Stride] = vv;
    +        else
    +            ((cmsUInt16Number*)output)[i + start] = vv;
    +    }
    +
    +    if (Extra == 0 && SwapFirst) {
    +
    +        memmove(swap1 + 1, swap1, (nChan - 1) * sizeof(cmsUInt16Number));
    +        *swap1 = vv;
    +    }
    +
    +    if (T_PLANAR(info->OutputFormat))
    +        return output + sizeof(cmsUInt16Number);
    +    else
    +        return output + (nChan + Extra) * sizeof(cmsUInt16Number);
    +}
    +
    +
     static
     cmsUInt8Number* PackFloatsFromFloat(_cmsTRANSFORM* info,
                                         cmsFloat32Number wOut[],
    @@ -3143,6 +3245,77 @@ cmsUInt8Number* PackLabDoubleFromFloat(_cmsTRANSFORM* Info,
     }
     
     
    +static
    +cmsUInt8Number* PackEncodedBytesLabV2FromFloat(_cmsTRANSFORM* Info,
    +                                           cmsFloat32Number wOut[],
    +                                           cmsUInt8Number* output,
    +                                           cmsUInt32Number Stride)
    +{
    +    cmsCIELab Lab;
    +    cmsUInt16Number wlab[3];
    +
    +    Lab.L = (cmsFloat64Number)(wOut[0] * 100.0);
    +    Lab.a = (cmsFloat64Number)(wOut[1] * 255.0 - 128.0);
    +    Lab.b = (cmsFloat64Number)(wOut[2] * 255.0 - 128.0);
    +
    +    cmsFloat2LabEncoded(wlab, &Lab);
    +
    +    if (T_PLANAR(Info -> OutputFormat)) {
    +
    +        Stride /= PixelSize(Info->OutputFormat);
    +
    +        output[0]        = wlab[0] >> 8;
    +        output[Stride]   = wlab[1] >> 8;
    +        output[Stride*2] = wlab[2] >> 8;
    +
    +        return output + 1;
    +    }
    +    else {
    +
    +        output[0] = wlab[0] >> 8;
    +        output[1] = wlab[1] >> 8;
    +        output[2] = wlab[2] >> 8;
    +
    +        return output + (3 + T_EXTRA(Info ->OutputFormat));
    +    }
    +}
    +
    +static
    +cmsUInt8Number* PackEncodedWordsLabV2FromFloat(_cmsTRANSFORM* Info,
    +                                           cmsFloat32Number wOut[],
    +                                           cmsUInt8Number* output,
    +                                           cmsUInt32Number Stride)
    +{
    +    cmsCIELab Lab;
    +    cmsUInt16Number wlab[3];
    +
    +    Lab.L = (cmsFloat64Number)(wOut[0] * 100.0);
    +    Lab.a = (cmsFloat64Number)(wOut[1] * 255.0 - 128.0);
    +    Lab.b = (cmsFloat64Number)(wOut[2] * 255.0 - 128.0);
    +
    +    cmsFloat2LabEncodedV2(wlab, &Lab);
    +
    +    if (T_PLANAR(Info -> OutputFormat)) {
    +
    +        Stride /= PixelSize(Info->OutputFormat);
    +
    +        ((cmsUInt16Number*) output)[0]        = wlab[0];
    +        ((cmsUInt16Number*) output)[Stride]   = wlab[1];
    +        ((cmsUInt16Number*) output)[Stride*2] = wlab[2];
    +
    +        return output + sizeof(cmsUInt16Number);
    +    }
    +    else {
    +
    +         ((cmsUInt16Number*) output)[0] = wlab[0];
    +         ((cmsUInt16Number*) output)[1] = wlab[1];
    +         ((cmsUInt16Number*) output)[2] = wlab[2];
    +
    +        return output + (3 + T_EXTRA(Info ->OutputFormat)) * sizeof(cmsUInt16Number);
    +    }
    +}
    +
    +
     // From 0..1 range to 0..MAX_ENCODEABLE_XYZ
     static
     cmsUInt8Number* PackXYZFloatFromFloat(_cmsTRANSFORM* Info,
    @@ -3676,10 +3849,20 @@ static const cmsFormattersFloat OutputFormattersFloat[] = {
         {     TYPE_Lab_DBL,                                                ANYPLANAR|ANYEXTRA,   PackLabDoubleFromFloat},
         {     TYPE_XYZ_DBL,                                                ANYPLANAR|ANYEXTRA,   PackXYZDoubleFromFloat},
     
    +    {     TYPE_LabV2_8,                                                ANYPLANAR|ANYEXTRA,   PackEncodedBytesLabV2FromFloat},
    +    {     TYPE_LabV2_16,                                               ANYPLANAR|ANYEXTRA,   PackEncodedWordsLabV2FromFloat},
    +
         {     FLOAT_SH(1)|BYTES_SH(4), ANYPLANAR|
                                  ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE,   PackFloatsFromFloat },
         {     FLOAT_SH(1)|BYTES_SH(0), ANYPLANAR|
                                  ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE,   PackDoublesFromFloat },
    +
    +    {     BYTES_SH(2), ANYPLANAR|
    +                             ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE,   PackWordsFromFloat },
    +
    +    {     BYTES_SH(1), ANYPLANAR|
    +                             ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE,   PackBytesFromFloat },
    +
     #ifndef CMS_NO_HALF_SUPPORT
         {     FLOAT_SH(1)|BYTES_SH(2),
                                  ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE,   PackHalfFromFloat },
    @@ -3890,7 +4073,7 @@ cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsU
         cmsColorSpaceSignature ColorSpace = cmsGetPCS(hProfile);
     
         cmsUInt32Number ColorSpaceBits = (cmsUInt32Number) _cmsLCMScolorSpace(ColorSpace);
    -    cmsUInt32Number nOutputChans = cmsChannelsOf(ColorSpace);
    +    cmsInt32Number  nOutputChans = cmsChannelsOfColorSpace(ColorSpace);
         cmsUInt32Number Float = lIsFloat ? 1U : 0;
     
         // Unsupported color space?
    diff --git a/src/java.desktop/share/native/liblcms/cmsplugin.c b/src/java.desktop/share/native/liblcms/cmsplugin.c
    index c2808bb9278..f84e0172c81 100644
    --- a/src/java.desktop/share/native/liblcms/cmsplugin.c
    +++ b/src/java.desktop/share/native/liblcms/cmsplugin.c
    @@ -393,12 +393,7 @@ cmsBool CMSEXPORT  _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ)
     // from Fixed point 8.8 to double
     cmsFloat64Number CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8)
     {
    -       cmsUInt8Number  msb, lsb;
    -
    -       lsb = (cmsUInt8Number) (fixed8 & 0xff);
    -       msb = (cmsUInt8Number) (((cmsUInt16Number) fixed8 >> 8) & 0xff);
    -
    -       return (cmsFloat64Number) ((cmsFloat64Number) msb + ((cmsFloat64Number) lsb / 256.0));
    +    return fixed8 / 256.0;
     }
     
     cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val)
    @@ -410,19 +405,7 @@ cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val)
     // from Fixed point 15.16 to double
     cmsFloat64Number CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32)
     {
    -    cmsFloat64Number floater, sign, mid;
    -    int Whole, FracPart;
    -
    -    sign  = (fix32 < 0 ? -1 : 1);
    -    fix32 = abs(fix32);
    -
    -    Whole     = (cmsUInt16Number)(fix32 >> 16) & 0xffff;
    -    FracPart  = (cmsUInt16Number)(fix32 & 0xffff);
    -
    -    mid     = (cmsFloat64Number) FracPart / 65536.0;
    -    floater = (cmsFloat64Number) Whole + mid;
    -
    -    return sign * floater;
    +    return fix32 / 65536.0;
     }
     
     // from double to Fixed point 15.16
    diff --git a/src/java.desktop/share/native/liblcms/cmsps2.c b/src/java.desktop/share/native/liblcms/cmsps2.c
    index 537f6854067..9a2ab464f31 100644
    --- a/src/java.desktop/share/native/liblcms/cmsps2.c
    +++ b/src/java.desktop/share/native/liblcms/cmsps2.c
    @@ -460,48 +460,46 @@ void EmitLab2XYZ(cmsIOHANDLER* m)
         _cmsIOPrintf(m, "]\n");
     }
     
    -static
    -void EmitSafeGuardBegin(cmsIOHANDLER* m, const char* name)
    -{
    -    _cmsIOPrintf(m, "%%LCMS2: Save previous definition of %s on the operand stack\n", name);
    -    _cmsIOPrintf(m, "currentdict /%s known { /%s load } { null } ifelse\n", name, name);
    -}
     
    -static
    -void EmitSafeGuardEnd(cmsIOHANDLER* m, const char* name, int depth)
    -{
    -    _cmsIOPrintf(m, "%%LCMS2: Restore previous definition of %s\n", name);
    -    if (depth > 1) {
    -        // cycle topmost items on the stack to bring the previous definition to the front
    -        _cmsIOPrintf(m, "%d -1 roll ", depth);
    -    }
    -    _cmsIOPrintf(m, "dup null eq { pop currentdict /%s undef } { /%s exch def } ifelse\n", name, name);
    -}
     
     // Outputs a table of words. It does use 16 bits
     
     static
    -void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table, const char* name)
    +void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table)
     {
         cmsUInt32Number i;
         cmsFloat64Number gamma;
     
    -    if (Table == NULL) return; // Error
    +    /**
    +    * On error, empty tables or lienar assume gamma 1.0
    +    */
    +    if (Table == NULL ||
    +        Table->nEntries <= 0 ||
    +        cmsIsToneCurveLinear(Table)) {
     
    -    if (Table ->nEntries <= 0) return;  // Empty table
    +        _cmsIOPrintf(m, "{ 1 } bind ");
    +        return;
    +    }
     
    -    // Suppress whole if identity
    -    if (cmsIsToneCurveLinear(Table)) return;
     
         // Check if is really an exponential. If so, emit "exp"
         gamma = cmsEstimateGamma(Table, 0.001);
          if (gamma > 0) {
    -            _cmsIOPrintf(m, "/%s { %g exp } bind def\n", name, gamma);
    +            _cmsIOPrintf(m, "{ %g exp } bind ", gamma);
                 return;
          }
     
    -    EmitSafeGuardBegin(m, "lcms2gammatable");
    -    _cmsIOPrintf(m, "/lcms2gammatable [");
    +    _cmsIOPrintf(m, "{ ");
    +
    +    // Bounds check
    +    EmitRangeCheck(m);
    +
    +    // Emit intepolation code
    +
    +    // PostScript code                      Stack
    +    // ===============                      ========================
    +                                            // v
    +    _cmsIOPrintf(m, " [");
     
         for (i=0; i < Table->nEntries; i++) {
         if (i % 10 == 0)
    @@ -509,20 +507,8 @@ void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table, const char* name)
             _cmsIOPrintf(m, "%d ", Table->Table16[i]);
         }
     
    -    _cmsIOPrintf(m, "] def\n");
    +    _cmsIOPrintf(m, "] ");                        // v tab
     
    -
    -    // Emit interpolation code
    -
    -    // PostScript code                            Stack
    -    // ===============                            ========================
    -                                                  // v
    -    _cmsIOPrintf(m, "/%s {\n  ", name);
    -
    -    // Bounds check
    -    EmitRangeCheck(m);
    -
    -    _cmsIOPrintf(m, "\n  //lcms2gammatable ");    // v tab
         _cmsIOPrintf(m, "dup ");                      // v tab tab
         _cmsIOPrintf(m, "length 1 sub ");             // v tab dom
         _cmsIOPrintf(m, "3 -1 roll ");                // tab dom v
    @@ -549,9 +535,7 @@ void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table, const char* name)
         _cmsIOPrintf(m, "add ");                      // y
         _cmsIOPrintf(m, "65535 div\n");               // result
     
    -    _cmsIOPrintf(m, "} bind def\n");
    -
    -    EmitSafeGuardEnd(m, "lcms2gammatable", 1);
    +    _cmsIOPrintf(m, " } bind ");
     }
     
     
    @@ -568,10 +552,10 @@ cmsBool GammaTableEquals(cmsUInt16Number* g1, cmsUInt16Number* g2, cmsUInt32Numb
     // Does write a set of gamma curves
     
     static
    -void EmitNGamma(cmsIOHANDLER* m, cmsUInt32Number n, cmsToneCurve* g[], const char* nameprefix)
    +void EmitNGamma(cmsIOHANDLER* m, cmsUInt32Number n, cmsToneCurve* g[])
     {
         cmsUInt32Number i;
    -    static char buffer[2048];
    +
     
         for( i=0; i < n; i++ )
         {
    @@ -579,12 +563,10 @@ void EmitNGamma(cmsIOHANDLER* m, cmsUInt32Number n, cmsToneCurve* g[], const cha
     
             if (i > 0 && GammaTableEquals(g[i-1]->Table16, g[i]->Table16, g[i-1]->nEntries, g[i]->nEntries)) {
     
    -            _cmsIOPrintf(m, "/%s%d /%s%d load def\n", nameprefix, i, nameprefix, i-1);
    +            _cmsIOPrintf(m, "dup ");
             }
             else {
    -            snprintf(buffer, sizeof(buffer), "%s%d", nameprefix, (int) i);
    -        buffer[sizeof(buffer)-1] = '\0';
    -            Emit1Gamma(m, g[i], buffer);
    +            Emit1Gamma(m, g[i]);
             }
         }
     
    @@ -708,18 +690,21 @@ void WriteCLUT(cmsIOHANDLER* m, cmsStage* mpe, const char* PreMaj,
         sc.FixWhite = FixWhite;
         sc.ColorSpace = ColorSpace;
     
    -    _cmsIOPrintf(m, "[");
    +    if (sc.Pipeline != NULL && sc.Pipeline->Params != NULL) {
     
    -    for (i=0; i < sc.Pipeline->Params->nInputs; i++)
    -        _cmsIOPrintf(m, " %d ", sc.Pipeline->Params->nSamples[i]);
    +        _cmsIOPrintf(m, "[");
     
    -    _cmsIOPrintf(m, " [\n");
    +        for (i = 0; i < sc.Pipeline->Params->nInputs; i++)
    +            _cmsIOPrintf(m, " %d ", sc.Pipeline->Params->nSamples[i]);
     
    -    cmsStageSampleCLut16bit(mpe, OutputValueSampler, (void*) &sc, SAMPLER_INSPECT);
    +        _cmsIOPrintf(m, " [\n");
     
    -    _cmsIOPrintf(m, PostMin);
    -    _cmsIOPrintf(m, PostMaj);
    -    _cmsIOPrintf(m, "] ");
    +        cmsStageSampleCLut16bit(mpe, OutputValueSampler, (void*)&sc, SAMPLER_INSPECT);
    +
    +        _cmsIOPrintf(m, PostMin);
    +        _cmsIOPrintf(m, PostMaj);
    +        _cmsIOPrintf(m, "] ");
    +    }
     
     }
     
    @@ -733,11 +718,11 @@ int EmitCIEBasedA(cmsIOHANDLER* m, cmsToneCurve* Curve, cmsCIEXYZ* BlackPoint)
         _cmsIOPrintf(m, "[ /CIEBasedA\n");
         _cmsIOPrintf(m, "  <<\n");
     
    -    EmitSafeGuardBegin(m, "lcms2gammaproc");
    -    Emit1Gamma(m, Curve, "lcms2gammaproc");
    +    _cmsIOPrintf(m, "/DecodeA ");
    +
    +    Emit1Gamma(m, Curve);
     
    -    _cmsIOPrintf(m, "/DecodeA /lcms2gammaproc load\n");
    -    EmitSafeGuardEnd(m, "lcms2gammaproc", 3);
    +    _cmsIOPrintf(m, " \n");
     
         _cmsIOPrintf(m, "/MatrixA [ 0.9642 1.0000 0.8249 ]\n");
         _cmsIOPrintf(m, "/RangeLMN [ 0.0 0.9642 0.0 1.0000 0.0 0.8249 ]\n");
    @@ -761,19 +746,11 @@ int EmitCIEBasedABC(cmsIOHANDLER* m, cmsFloat64Number* Matrix, cmsToneCurve** Cu
     
         _cmsIOPrintf(m, "[ /CIEBasedABC\n");
         _cmsIOPrintf(m, "<<\n");
    +    _cmsIOPrintf(m, "/DecodeABC [ ");
    +
    +    EmitNGamma(m, 3, CurveSet);
     
    -    EmitSafeGuardBegin(m, "lcms2gammaproc0");
    -    EmitSafeGuardBegin(m, "lcms2gammaproc1");
    -    EmitSafeGuardBegin(m, "lcms2gammaproc2");
    -    EmitNGamma(m, 3, CurveSet, "lcms2gammaproc");
    -    _cmsIOPrintf(m, "/DecodeABC [\n");
    -    _cmsIOPrintf(m, "   /lcms2gammaproc0 load\n");
    -    _cmsIOPrintf(m, "   /lcms2gammaproc1 load\n");
    -    _cmsIOPrintf(m, "   /lcms2gammaproc2 load\n");
         _cmsIOPrintf(m, "]\n");
    -    EmitSafeGuardEnd(m, "lcms2gammaproc2", 3);
    -    EmitSafeGuardEnd(m, "lcms2gammaproc1", 3);
    -    EmitSafeGuardEnd(m, "lcms2gammaproc0", 3);
     
         _cmsIOPrintf(m, "/MatrixABC [ " );
     
    @@ -805,10 +782,8 @@ int EmitCIEBasedDEF(cmsIOHANDLER* m, cmsPipeline* Pipeline, cmsUInt32Number Inte
     {
         const char* PreMaj;
         const char* PostMaj;
    -    const char* PreMin, * PostMin;
    +    const char* PreMin, *PostMin;
         cmsStage* mpe;
    -    int i, numchans;
    -    static char buffer[2048];
     
         mpe = Pipeline->Elements;
     
    @@ -837,34 +812,18 @@ int EmitCIEBasedDEF(cmsIOHANDLER* m, cmsPipeline* Pipeline, cmsUInt32Number Inte
     
         if (cmsStageType(mpe) == cmsSigCurveSetElemType) {
     
    -        numchans = (int) cmsStageOutputChannels(mpe);
    -        for (i = 0; i < numchans; ++i) {
    -            snprintf(buffer, sizeof(buffer), "lcms2gammaproc%d", i);
    -            buffer[sizeof(buffer) - 1] = '\0';
    -            EmitSafeGuardBegin(m, buffer);
    -        }
    -        EmitNGamma(m, cmsStageOutputChannels(mpe), _cmsStageGetPtrToCurveSet(mpe), "lcms2gammaproc");
    -        _cmsIOPrintf(m, "/DecodeDEF [\n");
    -        for (i = 0; i < numchans; ++i) {
    -            snprintf(buffer, sizeof(buffer), "  /lcms2gammaproc%d load\n", i);
    -            buffer[sizeof(buffer) - 1] = '\0';
    -            _cmsIOPrintf(m, buffer);
    -        }
    +        _cmsIOPrintf(m, "/DecodeDEF [ ");
    +        EmitNGamma(m, cmsStageOutputChannels(mpe), _cmsStageGetPtrToCurveSet(mpe));
             _cmsIOPrintf(m, "]\n");
    -        for (i = numchans - 1; i >= 0; --i) {
    -            snprintf(buffer, sizeof(buffer), "lcms2gammaproc%d", i);
    -            buffer[sizeof(buffer) - 1] = '\0';
    -            EmitSafeGuardEnd(m, buffer, 3);
    -        }
     
    -        mpe = mpe->Next;
    +        mpe = mpe ->Next;
         }
     
         if (cmsStageType(mpe) == cmsSigCLutElemType) {
     
    -        _cmsIOPrintf(m, "/Table ");
    -        WriteCLUT(m, mpe, PreMaj, PostMaj, PreMin, PostMin, FALSE, (cmsColorSpaceSignature)0);
    -        _cmsIOPrintf(m, "]\n");
    +            _cmsIOPrintf(m, "/Table ");
    +            WriteCLUT(m, mpe, PreMaj, PostMaj, PreMin, PostMin, FALSE, (cmsColorSpaceSignature) 0);
    +            _cmsIOPrintf(m, "]\n");
         }
     
         EmitLab2XYZ(m);
    @@ -1024,9 +983,9 @@ int WriteInputMatrixShaper(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsStage* Matr
                     for (j = 0; j < 3; j++)
                         Mat.v[i].n[j] *= MAX_ENCODEABLE_XYZ;
     
    -            rc = EmitCIEBasedABC(m, (cmsFloat64Number *)&Mat,
    -                _cmsStageGetPtrToCurveSet(Shaper),
    -                &BlackPointAdaptedToD50);
    +            rc = EmitCIEBasedABC(m,  (cmsFloat64Number *) &Mat,
    +                                _cmsStageGetPtrToCurveSet(Shaper),
    +                                 &BlackPointAdaptedToD50);
             }
             else {
     
    @@ -1053,10 +1012,15 @@ int WriteNamedColorCSA(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number
     
         hLab  = cmsCreateLab4ProfileTHR(m ->ContextID, NULL);
         xform = cmsCreateTransform(hNamedColor, TYPE_NAMED_COLOR_INDEX, hLab, TYPE_Lab_DBL, Intent, 0);
    +    cmsCloseProfile(hLab);
    +
         if (xform == NULL) return 0;
     
         NamedColorList = cmsGetNamedColorList(xform);
    -    if (NamedColorList == NULL) return 0;
    +    if (NamedColorList == NULL) {
    +        cmsDeleteTransform(xform);
    +        return 0;
    +    }
     
         _cmsIOPrintf(m, "<<\n");
         _cmsIOPrintf(m, "(colorlistcomment) (%s)\n", "Named color CSA");
    @@ -1065,7 +1029,6 @@ int WriteNamedColorCSA(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number
     
         nColors   = cmsNamedColorCount(NamedColorList);
     
    -
         for (i=0; i < nColors; i++) {
     
             cmsUInt16Number In[1];
    @@ -1080,12 +1043,9 @@ int WriteNamedColorCSA(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number
             _cmsIOPrintf(m, "  (%s) [ %.3f %.3f %.3f ]\n", ColorName, Lab.L, Lab.a, Lab.b);
         }
     
    -
    -
         _cmsIOPrintf(m, ">>\n");
     
         cmsDeleteTransform(xform);
    -    cmsCloseProfile(hLab);
         return 1;
     }
     
    @@ -1339,7 +1299,7 @@ int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent
         cmsUInt32Number InFrm = TYPE_Lab_16;
         cmsUInt32Number RelativeEncodingIntent;
         cmsColorSpaceSignature ColorSpace;
    -
    +    cmsStage* first;
     
         hLab = cmsCreateLab4ProfileTHR(m ->ContextID, NULL);
         if (hLab == NULL) return 0;
    @@ -1366,7 +1326,6 @@ int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent
         cmsCloseProfile(hLab);
     
         if (xform == NULL) {
    -
             cmsSignalError(m ->ContextID, cmsERROR_COLORSPACE_CHECK, "Cannot create transform Lab -> Profile in CRD creation");
             return 0;
         }
    @@ -1374,10 +1333,12 @@ int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent
         // Get a copy of the internal devicelink
         v = (_cmsTRANSFORM*) xform;
         DeviceLink = cmsPipelineDup(v ->Lut);
    -    if (DeviceLink == NULL) return 0;
    -
    +    if (DeviceLink == NULL) {
    +        cmsDeleteTransform(xform);
    +        return 0;
    +    }
     
    -    // We need a CLUT
    +     // We need a CLUT
         dwFlags |= cmsFLAGS_FORCE_CLUT;
         _cmsOptimizePipeline(m->ContextID, &DeviceLink, RelativeEncodingIntent, &InFrm, &OutputFormat, &dwFlags);
     
    @@ -1404,8 +1365,10 @@ int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent
     
         _cmsIOPrintf(m, "/RenderTable ");
     
    -
    -    WriteCLUT(m, cmsPipelineGetPtrToFirstStage(DeviceLink), "<", ">\n", "", "", lFixWhite, ColorSpace);
    +    first = cmsPipelineGetPtrToFirstStage(DeviceLink);
    +    if (first != NULL) {
    +        WriteCLUT(m, first, "<", ">\n", "", "", lFixWhite, ColorSpace);
    +    }
     
         _cmsIOPrintf(m, " %d {} bind ", nChannels);
     
    @@ -1414,7 +1377,6 @@ int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent
     
         _cmsIOPrintf(m, "]\n");
     
    -
         EmitIntent(m, Intent);
     
         _cmsIOPrintf(m, ">>\n");
    @@ -1477,7 +1439,10 @@ int WriteNamedColorCRD(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number
     
     
         NamedColorList = cmsGetNamedColorList(xform);
    -    if (NamedColorList == NULL) return 0;
    +    if (NamedColorList == NULL) {
    +        cmsDeleteTransform(xform);
    +        return 0;
    +    }
     
         _cmsIOPrintf(m, "<<\n");
         _cmsIOPrintf(m, "(colorlistcomment) (%s) \n", "Named profile");
    diff --git a/src/java.desktop/share/native/liblcms/cmssamp.c b/src/java.desktop/share/native/liblcms/cmssamp.c
    index 8a01f7ec685..74f5f4bff29 100644
    --- a/src/java.desktop/share/native/liblcms/cmssamp.c
    +++ b/src/java.desktop/share/native/liblcms/cmssamp.c
    @@ -152,7 +152,7 @@ cmsBool  BlackPointAsDarkerColorant(cmsHPROFILE    hInput,
         // Convert black to Lab
         cmsDoTransform(xform, Black, &Lab, 1);
     
    -    // Force it to be neutral, check for inconsistences
    +    // Force it to be neutral, check for inconsistencies
         Lab.a = Lab.b = 0;
         if (Lab.L > 50 || Lab.L < 0) Lab.L = 0;
     
    diff --git a/src/java.desktop/share/native/liblcms/cmstypes.c b/src/java.desktop/share/native/liblcms/cmstypes.c
    index 7b07b6b9cf4..862f393497a 100644
    --- a/src/java.desktop/share/native/liblcms/cmstypes.c
    +++ b/src/java.desktop/share/native/liblcms/cmstypes.c
    @@ -122,7 +122,7 @@ cmsBool RegisterTypesPlugin(cmsContext id, cmsPluginBase* Data, _cmsMemoryClient
         return TRUE;
     }
     
    -// Return handler for a given type or NULL if not found. Shared between normal types and MPE. It first tries the additons
    +// Return handler for a given type or NULL if not found. Shared between normal types and MPE. It first tries the additions
     // made by plug-ins and then the built-in defaults.
     static
     cmsTagTypeHandler* GetHandler(cmsTagTypeSignature sig, _cmsTagTypeLinkedList* PluginLinkedList, _cmsTagTypeLinkedList* DefaultLinkedList)
    @@ -954,6 +954,7 @@ static
     void *Type_Text_Description_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
     {
         char* Text = NULL;
    +    wchar_t* UnicodeString = NULL;
         cmsMLU* mlu = NULL;
         cmsUInt32Number  AsciiCount;
         cmsUInt32Number  i, UnicodeCode, UnicodeCount;
    @@ -973,7 +974,7 @@ void *Type_Text_Description_Read(struct _cms_typehandler_struct* self, cmsIOHAND
         if (SizeOfTag < AsciiCount) return NULL;
     
         // All seems Ok, allocate the container
    -    mlu = cmsMLUalloc(self ->ContextID, 1);
    +    mlu = cmsMLUalloc(self ->ContextID, 2);
         if (mlu == NULL) return NULL;
     
         // As many memory as size of tag
    @@ -998,15 +999,30 @@ void *Type_Text_Description_Read(struct _cms_typehandler_struct* self, cmsIOHAND
         if (!_cmsReadUInt32Number(io, &UnicodeCount)) goto Done;
         SizeOfTag -= 2* sizeof(cmsUInt32Number);
     
    -    if (SizeOfTag < UnicodeCount*sizeof(cmsUInt16Number)) goto Done;
    +    if (UnicodeCount == 0 || SizeOfTag < UnicodeCount*sizeof(cmsUInt16Number)) goto Done;
    +
    +    UnicodeString = (wchar_t*)_cmsMallocZero(self->ContextID, (UnicodeCount + 1) * sizeof(wchar_t));
    +    if (UnicodeString == NULL) goto Done;
    +
    +    if (!_cmsReadWCharArray(io, UnicodeCount, UnicodeString)) {
    +        _cmsFree(self->ContextID, (void*)UnicodeString);
    +        goto Done;
    +    }
    +
    +    UnicodeString[UnicodeCount] = 0;
     
    -    for (i=0; i < UnicodeCount; i++) {
    -        if (!io ->Read(io, &Dummy, sizeof(cmsUInt16Number), 1)) goto Done;
    +    if (!cmsMLUsetWide(mlu, cmsV2Unicode, cmsV2Unicode, UnicodeString)) {
    +        _cmsFree(self->ContextID, (void*)UnicodeString);
    +        goto Done;
         }
    +
    +    _cmsFree(self->ContextID, (void*)UnicodeString);
    +    UnicodeString = NULL;
    +
         SizeOfTag -= UnicodeCount*sizeof(cmsUInt16Number);
     
         // Skip ScriptCode code if present. Some buggy profiles does have less
    -    // data that stricttly required. We need to skip it as this type may come
    +    // data that strictly required. We need to skip it as this type may come
         // embedded in other types.
     
         if (SizeOfTag >= sizeof(cmsUInt16Number) + sizeof(cmsUInt8Number) + 67) {
    @@ -1026,6 +1042,7 @@ void *Type_Text_Description_Read(struct _cms_typehandler_struct* self, cmsIOHAND
         return mlu;
     
     Error:
    +    if (UnicodeString)  _cmsFree(self->ContextID, (void*)UnicodeString);
         if (Text) _cmsFree(self ->ContextID, (void*) Text);
         if (mlu) cmsMLUfree(mlu);
         return NULL;
    @@ -1078,7 +1095,7 @@ cmsBool  Type_Text_Description_Write(struct _cms_typehandler_struct* self, cmsIO
     
             // Get both representations.
             cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry,  Text, len * sizeof(char));
    -        cmsMLUgetWide(mlu,  cmsNoLanguage, cmsNoCountry,  Wide, len * sizeof(wchar_t));
    +        cmsMLUgetWide(mlu,  cmsV2Unicode,  cmsV2Unicode,  Wide, len * sizeof(wchar_t));
         }
     
         // Tell the real text len including the null terminator and padding
    @@ -1577,8 +1594,6 @@ void *Type_MLU_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsU
         if (SizeOfTag == 0)
         {
             Block = NULL;
    -        NumOfWchar = 0;
    -
         }
         else
         {
    @@ -1940,7 +1955,7 @@ void *Type_LUT8_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cms
     
     // We only allow a specific MPE structure: Matrix plus prelin, plus clut, plus post-lin.
     static
    -cmsBool  Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
    +cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
     {
         cmsUInt32Number j, nTabSize, i;
         cmsUInt8Number  val;
    @@ -1953,6 +1968,12 @@ cmsBool  Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
     
         // Disassemble the LUT into components.
         mpe = NewLUT -> Elements;
    +
    +    if (mpe == NULL) {  // Should never be empty. Corrupted?
    +        cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "empty LUT8 is not supported");
    +        return FALSE;
    +    }
    +
         if (mpe ->Type == cmsSigMatrixElemType) {
     
             if (mpe->InputChannels != 3 || mpe->OutputChannels != 3) return FALSE;
    @@ -2694,8 +2715,8 @@ cmsBool WriteSetOfCurves(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
             // If this is a table-based curve, use curve type even on V4
             CurrentType = Type;
     
    -        if ((Curves[i] ->nSegments == 0)||
    -            ((Curves[i]->nSegments == 2) && (Curves[i] ->Segments[1].Type == 0)) )
    +        if ((Curves[i] ->nSegments == 0) ||                                         // 16 bits tabulated
    +            ((Curves[i]->nSegments == 3) && (Curves[i] ->Segments[1].Type == 0)) )  // Floating-point tabulated
                 CurrentType = cmsSigCurveType;
             else
             if (Curves[i] ->Segments[0].Type < 0)
    @@ -4459,8 +4480,8 @@ void *Type_MPEclut_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
         if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
         if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
     
    -    if (InputChans == 0) goto Error;
    -    if (OutputChans == 0) goto Error;
    +    if (InputChans == 0 || InputChans >= cmsMAXCHANNELS) goto Error;
    +    if (OutputChans == 0 || OutputChans >= cmsMAXCHANNELS) goto Error;
     
         if (io ->Read(io, Dimensions8, sizeof(cmsUInt8Number), 16) != 16)
             goto Error;
    @@ -5250,11 +5271,13 @@ cmsBool WriteOneMLUC(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,  _c
         }
     
         Before = io ->Tell(io);
    -    e ->Offsets[i] = Before - BaseOffset;
    +    if (e->Offsets != NULL)
    +        e ->Offsets[i] = Before - BaseOffset;
     
         if (!Type_MLU_Write(self, io, (void*) mlu, 1)) return FALSE;
     
    -    e ->Sizes[i] = io ->Tell(io) - Before;
    +    if (e->Sizes != NULL)
    +        e ->Sizes[i] = io ->Tell(io) - Before;
         return TRUE;
     }
     
    @@ -5499,6 +5522,216 @@ void Type_VideoSignal_Free(struct _cms_typehandler_struct* self, void* Ptr)
         _cmsFree(self->ContextID, Ptr);
     }
     
    +
    +// ********************************************************************************
    +// Microsoft's MHC2 Type support
    +// ********************************************************************************
    +
    +static
    +void SetIdentity(cmsFloat64Number XYZ2XYZmatrix[3][4])
    +{
    +    XYZ2XYZmatrix[0][0] = 1.0; XYZ2XYZmatrix[0][1] = 0.0; XYZ2XYZmatrix[0][2] = 0.0; XYZ2XYZmatrix[0][3] = 0.0;
    +    XYZ2XYZmatrix[1][0] = 0.0; XYZ2XYZmatrix[1][1] = 1.0; XYZ2XYZmatrix[1][2] = 0.0; XYZ2XYZmatrix[1][3] = 0.0;
    +    XYZ2XYZmatrix[2][0] = 0.0; XYZ2XYZmatrix[2][1] = 0.0; XYZ2XYZmatrix[2][2] = 1.0; XYZ2XYZmatrix[2][3] = 0.0;
    +}
    +
    +static
    +cmsBool CloseEnough(cmsFloat64Number a, cmsFloat64Number b)
    +{
    +    return fabs(b - a) < (1.0 / 65535.0);
    +}
    +
    +cmsBool IsIdentity(cmsFloat64Number XYZ2XYZmatrix[3][4])
    +{
    +    cmsFloat64Number Identity[3][4];
    +    int i, j;
    +
    +    SetIdentity(Identity);
    +
    +    for (i = 0; i < 3; i++)
    +        for (j = 0; j < 4; j++)
    +            if (!CloseEnough(XYZ2XYZmatrix[i][j], Identity[i][j])) return FALSE;
    +
    +    return TRUE;
    +}
    +
    +static
    +void Type_MHC2_Free(struct _cms_typehandler_struct* self, void* Ptr)
    +{
    +    cmsMHC2Type* mhc2 = (cmsMHC2Type*)Ptr;
    +
    +    if (mhc2->RedCurve != NULL) _cmsFree(self->ContextID, mhc2->RedCurve);
    +    if (mhc2->GreenCurve != NULL) _cmsFree(self->ContextID, mhc2->GreenCurve);
    +    if (mhc2->BlueCurve != NULL) _cmsFree(self->ContextID, mhc2->BlueCurve);
    +
    +    _cmsFree(self->ContextID, Ptr);
    +}
    +
    +void* Type_MHC2_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
    +{
    +    cmsMHC2Type* mhc2 = _cmsDupMem(self->ContextID, Ptr, sizeof(cmsMHC2Type));
    +
    +    mhc2->RedCurve = _cmsDupMem(self->ContextID,   mhc2->RedCurve, mhc2->CurveEntries*sizeof(cmsFloat64Number));
    +    mhc2->GreenCurve = _cmsDupMem(self->ContextID, mhc2->GreenCurve, mhc2->CurveEntries * sizeof(cmsFloat64Number));
    +    mhc2->BlueCurve = _cmsDupMem(self->ContextID,  mhc2->BlueCurve, mhc2->CurveEntries * sizeof(cmsFloat64Number));
    +
    +    if (mhc2->RedCurve == NULL ||
    +        mhc2->GreenCurve == NULL ||
    +        mhc2->BlueCurve == NULL) {
    +
    +        Type_MHC2_Free(self, mhc2);
    +        return NULL;
    +    }
    +
    +    return mhc2;
    +
    +    cmsUNUSED_PARAMETER(n);
    +}
    +
    +
    +static
    +cmsBool WriteDoubles(cmsIOHANDLER* io, cmsUInt32Number n, cmsFloat64Number* Values)
    +{
    +    cmsUInt32Number i;
    +
    +    for (i = 0; i < n; i++) {
    +
    +        if (!_cmsWrite15Fixed16Number(io, *Values++)) return FALSE;
    +    }
    +
    +    return TRUE;
    +}
    +
    +static
    +cmsBool Type_MHC2_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
    +{
    +    cmsMHC2Type* mhc2 = (cmsMHC2Type*)Ptr;
    +    cmsUInt32Number BaseOffset = io->Tell(io) - sizeof(_cmsTagBase);
    +    cmsUInt32Number TablesOffsetPos;
    +    cmsUInt32Number MatrixOffset;
    +    cmsUInt32Number OffsetRedTable, OffsetGreenTable, OffsetBlueTable;
    +
    +    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
    +    if (!_cmsWriteUInt32Number(io, mhc2->CurveEntries)) return FALSE;
    +
    +    if (!_cmsWrite15Fixed16Number(io, mhc2->MinLuminance)) return FALSE;
    +    if (!_cmsWrite15Fixed16Number(io, mhc2->PeakLuminance)) return FALSE;
    +
    +    TablesOffsetPos = io->Tell(io);
    +
    +    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;    // Matrix
    +    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;    // Curve R
    +    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;    // Curve G
    +    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;    // Curve B
    +
    +
    +    if (IsIdentity(mhc2->XYZ2XYZmatrix))
    +    {
    +        MatrixOffset = 0;
    +    }
    +    else
    +    {
    +        MatrixOffset = io->Tell(io) - BaseOffset;
    +        if (!WriteDoubles(io, 3 * 4, &mhc2->XYZ2XYZmatrix[0][0])) return FALSE;
    +    }
    +
    +    OffsetRedTable = io->Tell(io) - BaseOffset;
    +    if (!WriteDoubles(io, mhc2->CurveEntries, mhc2->RedCurve)) return FALSE;
    +    OffsetGreenTable = io->Tell(io) - BaseOffset;
    +    if (!WriteDoubles(io, mhc2->CurveEntries, mhc2->GreenCurve)) return FALSE;
    +    OffsetBlueTable = io->Tell(io) - BaseOffset;
    +    if (!WriteDoubles(io, mhc2->CurveEntries, mhc2->BlueCurve)) return FALSE;
    +
    +    if (!io->Seek(io, TablesOffsetPos)) return FALSE;
    +
    +    if (!_cmsWriteUInt32Number(io, MatrixOffset)) return FALSE;
    +    if (!_cmsWriteUInt32Number(io, OffsetRedTable)) return FALSE;
    +    if (!_cmsWriteUInt32Number(io, OffsetGreenTable)) return FALSE;
    +    if (!_cmsWriteUInt32Number(io, OffsetBlueTable)) return FALSE;
    +
    +    return TRUE;
    +
    +    cmsUNUSED_PARAMETER(self);
    +    cmsUNUSED_PARAMETER(nItems);
    +}
    +
    +
    +static
    +cmsBool ReadDoublesAt(cmsIOHANDLER* io, cmsUInt32Number At, cmsUInt32Number n, cmsFloat64Number* Values)
    +{
    +    cmsUInt32Number CurrentPos = io->Tell(io);
    +    cmsUInt32Number i;
    +
    +    if (!io->Seek(io, At)) return FALSE;
    +
    +    for (i = 0; i < n; i++) {
    +
    +        if (!_cmsRead15Fixed16Number(io, Values++)) return FALSE;
    +    }
    +
    +    if (!io->Seek(io, CurrentPos)) return FALSE;
    +
    +    return TRUE;
    +}
    +
    +static
    +void* Type_MHC2_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
    +{
    +    cmsMHC2Type* mhc2 = NULL;
    +
    +    cmsUInt32Number BaseOffset = io->Tell(io) - sizeof(_cmsTagBase);
    +    cmsUInt32Number MatrixOffset;
    +    cmsUInt32Number OffsetRedTable, OffsetGreenTable, OffsetBlueTable;
    +
    +    if (!_cmsReadUInt32Number(io, NULL)) return NULL;
    +
    +    mhc2 = (cmsMHC2Type*)_cmsCalloc(self->ContextID, 1, sizeof(cmsMHC2Type));
    +    if (mhc2 == NULL) return NULL;
    +
    +    if (!_cmsReadUInt32Number(io,    &mhc2->CurveEntries)) goto Error;
    +
    +    if (mhc2->CurveEntries > 4096) goto Error;
    +
    +    mhc2->RedCurve = (cmsFloat64Number*)_cmsCalloc(self->ContextID, mhc2->CurveEntries, sizeof(cmsFloat64Number));
    +    mhc2->GreenCurve = (cmsFloat64Number*)_cmsCalloc(self->ContextID, mhc2->CurveEntries, sizeof(cmsFloat64Number));
    +    mhc2->BlueCurve = (cmsFloat64Number*)_cmsCalloc(self->ContextID, mhc2->CurveEntries, sizeof(cmsFloat64Number));
    +
    +    if (mhc2->RedCurve == NULL ||
    +        mhc2->GreenCurve == NULL ||
    +        mhc2->BlueCurve == NULL)  goto Error;
    +
    +    if (!_cmsRead15Fixed16Number(io, &mhc2->MinLuminance)) goto Error;
    +    if (!_cmsRead15Fixed16Number(io, &mhc2->PeakLuminance)) goto Error;
    +
    +    if (!_cmsReadUInt32Number(io, &MatrixOffset)) goto Error;
    +    if (!_cmsReadUInt32Number(io, &OffsetRedTable)) goto Error;
    +    if (!_cmsReadUInt32Number(io, &OffsetGreenTable)) goto Error;
    +    if (!_cmsReadUInt32Number(io, &OffsetBlueTable)) goto Error;
    +
    +    if (MatrixOffset == 0)
    +        SetIdentity(mhc2->XYZ2XYZmatrix);
    +    else
    +    {
    +        if (!ReadDoublesAt(io, BaseOffset + MatrixOffset, 3*4, &mhc2->XYZ2XYZmatrix[0][0])) goto Error;
    +    }
    +
    +    if (!ReadDoublesAt(io, BaseOffset + OffsetRedTable, mhc2->CurveEntries, mhc2->RedCurve)) goto Error;
    +    if (!ReadDoublesAt(io, BaseOffset + OffsetGreenTable, mhc2->CurveEntries, mhc2->GreenCurve)) goto Error;
    +    if (!ReadDoublesAt(io, BaseOffset + OffsetBlueTable, mhc2->CurveEntries, mhc2->BlueCurve)) goto Error;
    +
    +    // Success
    +    *nItems = 1;
    +    return mhc2;
    +
    +Error:
    +    Type_MHC2_Free(self, mhc2);
    +    return NULL;
    +
    +    cmsUNUSED_PARAMETER(SizeOfTag);
    +}
    +
    +
    +
     // ********************************************************************************
     // Type support main routines
     // ********************************************************************************
    @@ -5538,7 +5771,8 @@ static const _cmsTagTypeLinkedList SupportedTagTypes[] = {
     {TYPE_HANDLER(cmsSigProfileSequenceIdType,     ProfileSequenceId),  (_cmsTagTypeLinkedList*) &SupportedTagTypes[29] },
     {TYPE_HANDLER(cmsSigDictType,                  Dictionary),         (_cmsTagTypeLinkedList*) &SupportedTagTypes[30] },
     {TYPE_HANDLER(cmsSigcicpType,                  VideoSignal),        (_cmsTagTypeLinkedList*) &SupportedTagTypes[31] },
    -{TYPE_HANDLER(cmsSigVcgtType,                  vcgt),                NULL }
    +{TYPE_HANDLER(cmsSigVcgtType,                  vcgt),               (_cmsTagTypeLinkedList*) &SupportedTagTypes[32] },
    +{TYPE_HANDLER(cmsSigMHC2Type,                  MHC2),                NULL }
     };
     
     
    @@ -5734,7 +5968,8 @@ static _cmsTagLinkedList SupportedTags[] = {
         { cmsSigProfileDescriptionMLTag,{ 1, 1, { cmsSigMultiLocalizedUnicodeType}, NULL}, &SupportedTags[63]},
         { cmsSigcicpTag,                { 1, 1, { cmsSigcicpType},               NULL },   &SupportedTags[64]},
     
    -    { cmsSigArgyllArtsTag,          { 9, 1, { cmsSigS15Fixed16ArrayType},    NULL}, NULL}
    +    { cmsSigArgyllArtsTag,          { 9, 1, { cmsSigS15Fixed16ArrayType},    NULL}, &SupportedTags[65]},
    +    { cmsSigMHC2Tag,                { 1, 1, { cmsSigMHC2Type },              NULL}, NULL}
     
     };
     
    diff --git a/src/java.desktop/share/native/liblcms/cmsvirt.c b/src/java.desktop/share/native/liblcms/cmsvirt.c
    index 6ce04796174..e8d18d4ca9f 100644
    --- a/src/java.desktop/share/native/liblcms/cmsvirt.c
    +++ b/src/java.desktop/share/native/liblcms/cmsvirt.c
    @@ -435,10 +435,9 @@ cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLinkTHR(cmsContext ContextID,
     
         if (Limit < 0.0 || Limit > 400) {
     
    -        cmsSignalError(ContextID, cmsERROR_RANGE, "InkLimiting: Limit should be between 0..400");
    -        if (Limit < 0) Limit = 0;
    +        cmsSignalError(ContextID, cmsERROR_RANGE, "InkLimiting: Limit should be between 1..400");
    +        if (Limit < 1) Limit = 1;
             if (Limit > 400) Limit = 400;
    -
         }
     
         hICC = cmsCreateProfilePlaceholder(ContextID);
    @@ -701,6 +700,127 @@ cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfile(void)
         return cmsCreate_sRGBProfileTHR(NULL);
     }
     
    +/**
    +* Oklab colorspace profile (experimental)
    +*
    +* This virtual profile cannot be saved as an ICC file
    +*/
    +cmsHPROFILE cmsCreate_OkLabProfile(cmsContext ctx)
    +{
    +    cmsStage* XYZPCS = _cmsStageNormalizeFromXyzFloat(ctx);
    +    cmsStage* PCSXYZ = _cmsStageNormalizeToXyzFloat(ctx);
    +
    +    const double M_D65_D50[] =
    +    {
    +       1.047886, 0.022919, -0.050216,
    +       0.029582, 0.990484, -0.017079,
    +      -0.009252, 0.015073,  0.751678
    +    };
    +
    +    const double M_D50_D65[] =
    +    {
    +         0.955512609517083, -0.023073214184645,  0.063308961782107,
    +        -0.028324949364887,  1.009942432477107,  0.021054814890112,
    +         0.012328875695483, -0.020535835374141,  1.330713916450354
    +    };
    +
    +    cmsStage* D65toD50 = cmsStageAllocMatrix(ctx, 3, 3, M_D65_D50, NULL);
    +    cmsStage* D50toD65 = cmsStageAllocMatrix(ctx, 3, 3, M_D50_D65, NULL);
    +
    +    const double M_D65_LMS[] =
    +    {
    +        0.8189330101, 0.3618667424, -0.1288597137,
    +        0.0329845436, 0.9293118715,  0.0361456387,
    +        0.0482003018, 0.2643662691,  0.6338517070
    +    };
    +
    +    const double M_LMS_D65[] =
    +    {
    +        1.227013851103521, -0.557799980651822,  0.281256148966468,
    +       -0.040580178423281,  1.112256869616830, -0.071676678665601,
    +       -0.076381284505707, -0.421481978418013,  1.586163220440795
    +    };
    +
    +    cmsStage* D65toLMS = cmsStageAllocMatrix(ctx, 3, 3, M_D65_LMS, NULL);
    +    cmsStage* LMStoD65 = cmsStageAllocMatrix(ctx, 3, 3, M_LMS_D65, NULL);
    +
    +    cmsToneCurve* CubeRoot = cmsBuildGamma(ctx, 1.0 / 3.0);
    +    cmsToneCurve* Cube     = cmsBuildGamma(ctx,  3.0);
    +
    +    cmsToneCurve* Roots[3] = { CubeRoot, CubeRoot, CubeRoot };
    +    cmsToneCurve* Cubes[3] = { Cube, Cube, Cube };
    +
    +    cmsStage* NonLinearityFw = cmsStageAllocToneCurves(ctx, 3, Roots);
    +    cmsStage* NonLinearityRv = cmsStageAllocToneCurves(ctx, 3, Cubes);
    +
    +    const double M_LMSprime_OkLab[] =
    +    {
    +        0.2104542553,  0.7936177850, -0.0040720468,
    +        1.9779984951, -2.4285922050,  0.4505937099,
    +        0.0259040371,  0.7827717662, -0.8086757660
    +    };
    +
    +    const double M_OkLab_LMSprime[] =
    +    {
    +        0.999999998450520,  0.396337792173768,  0.215803758060759,
    +        1.000000008881761, -0.105561342323656, -0.063854174771706,
    +        1.000000054672411, -0.089484182094966, -1.291485537864092
    +    };
    +
    +    cmsStage* LMSprime_OkLab = cmsStageAllocMatrix(ctx, 3, 3, M_LMSprime_OkLab, NULL);
    +    cmsStage* OkLab_LMSprime = cmsStageAllocMatrix(ctx, 3, 3, M_OkLab_LMSprime, NULL);
    +
    +    cmsPipeline* AToB = cmsPipelineAlloc(ctx, 3, 3);
    +    cmsPipeline* BToA = cmsPipelineAlloc(ctx, 3, 3);
    +
    +    cmsHPROFILE hProfile = cmsCreateProfilePlaceholder(ctx);
    +
    +    cmsSetProfileVersion(hProfile, 4.4);
    +
    +    cmsSetDeviceClass(hProfile, cmsSigColorSpaceClass);
    +    cmsSetColorSpace(hProfile, cmsSig3colorData);
    +    cmsSetPCS(hProfile, cmsSigXYZData);
    +
    +    cmsSetHeaderRenderingIntent(hProfile, INTENT_RELATIVE_COLORIMETRIC);
    +
    +    /**
    +    * Conversion PCS (XYZ/D50) to OkLab
    +    */
    +    if (!cmsPipelineInsertStage(BToA, cmsAT_END, PCSXYZ)) goto error;
    +    if (!cmsPipelineInsertStage(BToA, cmsAT_END, D50toD65)) goto error;
    +    if (!cmsPipelineInsertStage(BToA, cmsAT_END, D65toLMS)) goto error;
    +    if (!cmsPipelineInsertStage(BToA, cmsAT_END, NonLinearityFw)) goto error;
    +    if (!cmsPipelineInsertStage(BToA, cmsAT_END, LMSprime_OkLab)) goto error;
    +
    +    if (!cmsWriteTag(hProfile, cmsSigBToA0Tag, BToA)) goto error;
    +
    +    if (!cmsPipelineInsertStage(AToB, cmsAT_END, OkLab_LMSprime)) goto error;
    +    if (!cmsPipelineInsertStage(AToB, cmsAT_END, NonLinearityRv)) goto error;
    +    if (!cmsPipelineInsertStage(AToB, cmsAT_END, LMStoD65)) goto error;
    +    if (!cmsPipelineInsertStage(AToB, cmsAT_END, D65toD50)) goto error;
    +    if (!cmsPipelineInsertStage(AToB, cmsAT_END, XYZPCS)) goto error;
    +
    +    if (!cmsWriteTag(hProfile, cmsSigAToB0Tag, AToB)) goto error;
    +
    +    cmsPipelineFree(BToA);
    +    cmsPipelineFree(AToB);
    +
    +    cmsFreeToneCurve(CubeRoot);
    +    cmsFreeToneCurve(Cube);
    +
    +    return hProfile;
    +
    +error:
    +    cmsPipelineFree(BToA);
    +    cmsPipelineFree(AToB);
    +
    +    cmsFreeToneCurve(CubeRoot);
    +    cmsFreeToneCurve(Cube);
    +    cmsCloseProfile(hProfile);
    +
    +    return NULL;
    +
    +}
     
     
     typedef struct {
    @@ -1060,7 +1180,7 @@ cmsBool CheckOne(const cmsAllowedLUT* Tab, const cmsPipeline* Lut)
     
         for (n=0, mpe = Lut ->Elements; mpe != NULL; mpe = mpe ->Next, n++) {
     
    -        if (n > Tab ->nTypes) return FALSE;
    +        if (n >= Tab ->nTypes) return FALSE;
             if (cmsStageType(mpe) != Tab ->MpeTypes[n]) return FALSE;
         }
     
    @@ -1091,9 +1211,9 @@ const cmsAllowedLUT* FindCombination(const cmsPipeline* Lut, cmsBool IsV4, cmsTa
     cmsHPROFILE CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat64Number Version, cmsUInt32Number dwFlags)
     {
         cmsHPROFILE hProfile = NULL;
    -        cmsUInt32Number FrmIn, FrmOut;
    -        cmsInt32Number ChansIn, ChansOut;
    -        int ColorSpaceBitsIn, ColorSpaceBitsOut;
    +    cmsUInt32Number FrmIn, FrmOut;
    +    cmsInt32Number ChansIn, ChansOut;
    +    int ColorSpaceBitsIn, ColorSpaceBitsOut;
         _cmsTRANSFORM* xform = (_cmsTRANSFORM*) hTransform;
         cmsPipeline* LUT = NULL;
         cmsStage* mpe;
    @@ -1104,6 +1224,9 @@ cmsHPROFILE CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat
     
         _cmsAssert(hTransform != NULL);
     
    +    // Check if the pipeline holding is valid
    +    if (xform -> Lut == NULL) return NULL;
    +
         // Get the first mpe to check for named color
         mpe = cmsPipelineGetPtrToFirstStage(xform ->Lut);
     
    diff --git a/src/java.desktop/share/native/liblcms/cmsxform.c b/src/java.desktop/share/native/liblcms/cmsxform.c
    index 3f3ad28c6c4..86afd7202fd 100644
    --- a/src/java.desktop/share/native/liblcms/cmsxform.c
    +++ b/src/java.desktop/share/native/liblcms/cmsxform.c
    @@ -943,7 +943,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
            }
     
         // Check whatever this is a true floating point transform
    -    if (_cmsFormatterIsFloat(*OutputFormat)) {
    +    if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) {
     
             // Get formatter function always return a valid union, but the contents of this union may be NULL.
             p ->FromInputFloat = _cmsGetFormatter(ContextID, *InputFormat,  cmsFormatterInput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
    @@ -1018,6 +1018,19 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
             }
         }
     
    +    /**
    +    * Check consistency for alpha channel copy
    +    */
    +    if (*dwFlags & cmsFLAGS_COPY_ALPHA)
    +    {
    +        if (T_EXTRA(*InputFormat) != T_EXTRA(*OutputFormat))
    +        {
    +            cmsSignalError(ContextID, cmsERROR_NOT_SUITABLE, "Mismatched alpha channels");
    +            cmsDeleteTransform(p);
    +            return NULL;
    +        }
    +    }
    +
         p ->InputFormat     = *InputFormat;
         p ->OutputFormat    = *OutputFormat;
         p ->dwOriginalFlags = *dwFlags;
    diff --git a/src/java.desktop/share/native/liblcms/lcms2.h b/src/java.desktop/share/native/liblcms/lcms2.h
    index d5b8c477f23..2d9a8b1248f 100644
    --- a/src/java.desktop/share/native/liblcms/lcms2.h
    +++ b/src/java.desktop/share/native/liblcms/lcms2.h
    @@ -52,7 +52,7 @@
     //
     //---------------------------------------------------------------------------------
     //
    -// Version 2.15
    +// Version 2.16
     //
     
     #ifndef _lcms2_H
    @@ -105,12 +105,15 @@
     
     #ifndef CMS_USE_CPP_API
     #   ifdef __cplusplus
    +#       if __cplusplus >= 201703L
    +#            define CMS_NO_REGISTER_KEYWORD 1
    +#       endif
     extern "C" {
     #   endif
     #endif
     
     // Version/release
    -#define LCMS_VERSION        2150
    +#define LCMS_VERSION        2160
     
     // I will give the chance of redefining basic types for compilers that are not fully C99 compliant
     #ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
    @@ -354,7 +357,8 @@ typedef enum {
         cmsSigUInt8ArrayType                    = 0x75693038,  // 'ui08'
         cmsSigVcgtType                          = 0x76636774,  // 'vcgt'
         cmsSigViewingConditionsType             = 0x76696577,  // 'view'
    -    cmsSigXYZType                           = 0x58595A20   // 'XYZ '
    +    cmsSigXYZType                           = 0x58595A20,  // 'XYZ '
    +    cmsSigMHC2Type                          = 0x4D484332   // 'MHC2'
     
     
     } cmsTagTypeSignature;
    @@ -432,7 +436,8 @@ typedef enum {
         cmsSigVcgtTag                           = 0x76636774,  // 'vcgt'
         cmsSigMetaTag                           = 0x6D657461,  // 'meta'
         cmsSigcicpTag                           = 0x63696370,  // 'cicp'
    -    cmsSigArgyllArtsTag                     = 0x61727473   // 'arts'
    +    cmsSigArgyllArtsTag                     = 0x61727473,  // 'arts'
    +    cmsSigMHC2Tag                           = 0x4D484332   // 'MHC2'
     
     } cmsTagSignature;
     
    @@ -977,6 +982,7 @@ typedef void* cmsHTRANSFORM;
     #define TYPE_RGB_DBL          (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0))
     #define TYPE_BGR_DBL          (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0)|DOSWAP_SH(1))
     #define TYPE_CMYK_DBL         (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(0))
    +#define TYPE_OKLAB_DBL        (FLOAT_SH(1)|COLORSPACE_SH(PT_MCH3)|CHANNELS_SH(3)|BYTES_SH(0))
     
     // IEEE 754-2008 "half"
     #define TYPE_GRAY_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2))
    @@ -1077,6 +1083,19 @@ typedef struct {
     
     } cmsVideoSignalType;
     
    +typedef struct {
    +    cmsUInt32Number   CurveEntries;
    +    cmsFloat64Number* RedCurve;
    +    cmsFloat64Number* GreenCurve;
    +    cmsFloat64Number* BlueCurve;
    +
    +    cmsFloat64Number  MinLuminance;         // ST.2086 min luminance in nits
    +    cmsFloat64Number  PeakLuminance;        // ST.2086 peak luminance in nits
    +
    +    cmsFloat64Number XYZ2XYZmatrix[3][4];
    +
    +} cmsMHC2Type;
    +
     
     
     // Get LittleCMS version (for shared objects) -----------------------------------------------------------------------------
    @@ -1249,7 +1268,8 @@ CMSAPI cmsBool           CMSEXPORT cmsIsToneCurveMonotonic(const cmsToneCurve* t
     CMSAPI cmsBool           CMSEXPORT cmsIsToneCurveDescending(const cmsToneCurve* t);
     CMSAPI cmsInt32Number    CMSEXPORT cmsGetToneCurveParametricType(const cmsToneCurve* t);
     CMSAPI cmsFloat64Number  CMSEXPORT cmsEstimateGamma(const cmsToneCurve* t, cmsFloat64Number Precision);
    -CMSAPI cmsFloat64Number* CMSEXPORT cmsGetToneCurveParams(const cmsToneCurve* t);
    +
    +CMSAPI const cmsCurveSegment* CMSEXPORT cmsGetToneCurveSegment(cmsInt32Number n, const cmsToneCurve* t);
     
     // Tone curve tabular estimation
     CMSAPI cmsUInt32Number         CMSEXPORT cmsGetToneCurveEstimatedTableEntries(const cmsToneCurve* t);
    @@ -1343,8 +1363,11 @@ CMSAPI cmsBool           CMSEXPORT cmsSliceSpaceFloat(cmsUInt32Number nInputs, c
     
     typedef struct _cms_MLU_struct cmsMLU;
     
    -#define  cmsNoLanguage "\0\0"
    -#define  cmsNoCountry  "\0\0"
    +#define  cmsNoLanguage    "\0\0"
    +#define  cmsNoCountry     "\0\0"
    +
    +// Special language/country to retrieve unicode field for description in V2 profiles. Use with care.
    +#define  cmsV2Unicode     "\xff\xff"
     
     CMSAPI cmsMLU*           CMSEXPORT cmsMLUalloc(cmsContext ContextID, cmsUInt32Number nItems);
     CMSAPI void              CMSEXPORT cmsMLUfree(cmsMLU* mlu);
    @@ -1356,6 +1379,9 @@ CMSAPI cmsBool           CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu,
     CMSAPI cmsBool           CMSEXPORT cmsMLUsetWide(cmsMLU* mlu,
                                                       const char LanguageCode[3], const char CountryCode[3],
                                                       const wchar_t* WideString);
    +CMSAPI cmsBool           CMSEXPORT cmsMLUsetUTF8(cmsMLU* mlu,
    +                                                  const char LanguageCode[3], const char CountryCode[3],
    +                                                  const char* UTF8String);
     
     CMSAPI cmsUInt32Number   CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
                                                       const char LanguageCode[3], const char CountryCode[3],
    @@ -1364,6 +1390,10 @@ CMSAPI cmsUInt32Number   CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
     CMSAPI cmsUInt32Number   CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
                                                      const char LanguageCode[3], const char CountryCode[3],
                                                      wchar_t* Buffer, cmsUInt32Number BufferSize);
    +CMSAPI cmsUInt32Number   CMSEXPORT cmsMLUgetUTF8(const cmsMLU* mlu,
    +                                                 const char LanguageCode[3], const char CountryCode[3],
    +                                                 char* Buffer, cmsUInt32Number BufferSize);
    +
     
     CMSAPI cmsBool           CMSEXPORT cmsMLUgetTranslation(const cmsMLU* mlu,
                                                              const char LanguageCode[3], const char CountryCode[3],
    @@ -1588,6 +1618,10 @@ CMSAPI cmsUInt32Number   CMSEXPORT cmsGetProfileInfoASCII(cmsHPROFILE hProfile,
                                                                 const char LanguageCode[3], const char CountryCode[3],
                                                                 char* Buffer, cmsUInt32Number BufferSize);
     
    +CMSAPI cmsUInt32Number  CMSEXPORT cmsGetProfileInfoUTF8(cmsHPROFILE hProfile, cmsInfoType Info,
    +                                                            const char LanguageCode[3], const char CountryCode[3],
    +                                                            char* Buffer, cmsUInt32Number BufferSize);
    +
     // IO handlers ----------------------------------------------------------------------------------------------------------
     
     typedef struct _cms_io_handler cmsIOHANDLER;
    @@ -1650,6 +1684,9 @@ CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateInkLimitingDeviceLinkTHR(cmsContext C
     
     CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateInkLimitingDeviceLink(cmsColorSpaceSignature ColorSpace, cmsFloat64Number Limit);
     
    +CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateDeviceLinkFromCubeFile(const char* cFileName);
    +
    +CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateDeviceLinkFromCubeFileTHR(cmsContext ContextID, const char* cFileName);
     
     CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateLab2ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint);
     CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateLab2Profile(const cmsCIExyY* WhitePoint);
    @@ -1662,6 +1699,8 @@ CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateXYZProfile(void);
     CMSAPI cmsHPROFILE      CMSEXPORT cmsCreate_sRGBProfileTHR(cmsContext ContextID);
     CMSAPI cmsHPROFILE      CMSEXPORT cmsCreate_sRGBProfile(void);
     
    +CMSAPI cmsHPROFILE      CMSEXPORT cmsCreate_OkLabProfile(cmsContext ctx);
    +
     CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateBCHSWabstractProfileTHR(cmsContext ContextID,
                                                                  cmsUInt32Number nLUTPoints,
                                                                  cmsFloat64Number Bright,
    diff --git a/src/java.desktop/share/native/liblcms/lcms2_internal.h b/src/java.desktop/share/native/liblcms/lcms2_internal.h
    index 4c29a6c0218..75973edad0d 100644
    --- a/src/java.desktop/share/native/liblcms/lcms2_internal.h
    +++ b/src/java.desktop/share/native/liblcms/lcms2_internal.h
    @@ -288,6 +288,7 @@ typedef CRITICAL_SECTION _cmsMutex;
     #ifdef _MSC_VER
     #    if (_MSC_VER >= 1800)
     #          pragma warning(disable : 26135)
    +#          pragma warning(disable : 4127)
     #    endif
     #endif
     
    @@ -545,7 +546,7 @@ struct _cmsContext_struct {
         struct _cmsContext_struct* Next;  // Points to next context in the new style
         _cmsSubAllocator* MemPool;        // The memory pool that stores context data
     
    -    void* chunks[MemoryClientMax];    // array of pointers to client chunks. Memory itself is hold in the suballocator.
    +    void* chunks[MemoryClientMax];    // array of pointers to client chunks. Memory itself is held in the suballocator.
                                           // If NULL, then it reverts to global Context0
     
         _cmsMemPluginChunkType DefaultMemoryManager;  // The allocators used for creating the context itself. Cannot be overridden
    @@ -839,6 +840,9 @@ typedef struct _cms_iccprofile_struct {
         // Creation time
         struct tm                Created;
     
    +    // Color management module identification
    +    cmsUInt32Number          CMM;
    +
         // Only most important items found in ICC profiles
         cmsUInt32Number          Version;
         cmsProfileClassSignature DeviceClass;
    @@ -846,6 +850,7 @@ typedef struct _cms_iccprofile_struct {
         cmsColorSpaceSignature   PCS;
         cmsUInt32Number          RenderingIntent;
     
    +    cmsPlatformSignature     platform;
         cmsUInt32Number          flags;
         cmsUInt32Number          manufacturer, model;
         cmsUInt64Number          attributes;
    
    From d1bdb255745f5818339e6e0fdd5de1b291920b36 Mon Sep 17 00:00:00 2001
    From: Goetz Lindenmaier 
    Date: Thu, 14 Mar 2024 20:18:18 +0000
    Subject: [PATCH 039/149] 8322239: [macos] a11y :
     java.lang.NullPointerException is thrown when focus is moved on the
     JTabbedPane
    
    Backport-of: 3b1062d45df69d4cf8479c6a65602bd2453ab885
    ---
     .../classes/javax/swing/JTabbedPane.java      |  17 ++-
     .../swing/JTabbedPane/TabbedPaneNPECheck.java | 102 ++++++++++++++++++
     2 files changed, 115 insertions(+), 4 deletions(-)
     create mode 100644 test/jdk/javax/swing/JTabbedPane/TabbedPaneNPECheck.java
    
    diff --git a/src/java.desktop/share/classes/javax/swing/JTabbedPane.java b/src/java.desktop/share/classes/javax/swing/JTabbedPane.java
    index b6d50b4ade4..337a12b2295 100644
    --- a/src/java.desktop/share/classes/javax/swing/JTabbedPane.java
    +++ b/src/java.desktop/share/classes/javax/swing/JTabbedPane.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2024, 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
    @@ -26,6 +26,7 @@
     
     import java.awt.*;
     import java.awt.event.*;
    +import java.awt.IllegalComponentStateException;
     import java.beans.JavaBean;
     import java.beans.BeanProperty;
     import java.beans.Transient;
    @@ -2255,15 +2256,23 @@ public boolean contains(Point p) {
             }
     
             public Point getLocationOnScreen() {
    -             Point parentLocation = parent.getLocationOnScreen();
    +             Point parentLocation;
    +             try {
    +                 parentLocation = parent.getLocationOnScreen();
    +             } catch (IllegalComponentStateException icse) {
    +                 return null;
    +             }
                  Point componentLocation = getLocation();
    +             if (parentLocation == null || componentLocation == null) {
    +                 return null;
    +             }
                  componentLocation.translate(parentLocation.x, parentLocation.y);
                  return componentLocation;
             }
     
             public Point getLocation() {
                  Rectangle r = getBounds();
    -             return new Point(r.x, r.y);
    +             return r == null ? null : new Point(r.x, r.y);
             }
     
             public void setLocation(Point p) {
    @@ -2280,7 +2289,7 @@ public void setBounds(Rectangle r) {
     
             public Dimension getSize() {
                 Rectangle r = getBounds();
    -            return new Dimension(r.width, r.height);
    +            return r == null ? null : new Dimension(r.width, r.height);
             }
     
             public void setSize(Dimension d) {
    diff --git a/test/jdk/javax/swing/JTabbedPane/TabbedPaneNPECheck.java b/test/jdk/javax/swing/JTabbedPane/TabbedPaneNPECheck.java
    new file mode 100644
    index 00000000000..57321435bc4
    --- /dev/null
    +++ b/test/jdk/javax/swing/JTabbedPane/TabbedPaneNPECheck.java
    @@ -0,0 +1,102 @@
    +/*
    + * Copyright (c) 2024, 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.
    + *
    + * 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.
    + */
    +
    +/*
    + * @test
    + * @bug 8322239
    + * @summary [macos] a11y : java.lang.NullPointerException is thrown when
    + *          focus is moved on the JTabbedPane
    + * @key headful
    + * @run main TabbedPaneNPECheck
    + */
    +
    +import java.awt.BorderLayout;
    +import java.awt.Dimension;
    +import java.awt.Point;
    +import java.awt.Rectangle;
    +import java.lang.reflect.InvocationTargetException;
    +import javax.accessibility.Accessible;
    +import javax.accessibility.AccessibleComponent;
    +import javax.accessibility.AccessibleContext;
    +import javax.swing.JFrame;
    +import javax.swing.JPanel;
    +import javax.swing.JTabbedPane;
    +import javax.swing.SwingUtilities;
    +
    +public class TabbedPaneNPECheck {
    +    JTabbedPane pane;
    +    JFrame mainFrame;
    +    public static void main(String[] args) throws InterruptedException,
    +            InvocationTargetException {
    +        TabbedPaneNPECheck me = new TabbedPaneNPECheck();
    +        SwingUtilities.invokeAndWait(me::setupGUI);
    +        try {
    +            SwingUtilities.invokeAndWait(me::test);
    +        } finally {
    +            SwingUtilities.invokeAndWait(me::shutdownGUI);
    +        }
    +    }
    +
    +    public void setupGUI() {
    +        mainFrame = new JFrame("TabbedPaneNPECheck");
    +        pane = new JTabbedPane();
    +        Dimension panelSize = new Dimension(200, 200);
    +        for (int i = 0; i < 25; i++) {
    +            JPanel p = new JPanel();
    +            p.setMinimumSize(panelSize);
    +            p.setMaximumSize(panelSize);
    +            p.setSize(panelSize);
    +            pane.addTab("Tab no." + i, p);
    +        }
    +        mainFrame.setLayout(new BorderLayout());
    +        mainFrame.add(pane, BorderLayout.CENTER);
    +        mainFrame.setLocationRelativeTo(null);
    +        mainFrame.setSize(250, 250);
    +        mainFrame.setVisible(true);
    +    }
    +
    +    public void test() {
    +        AccessibleContext context = pane.getAccessibleContext();
    +        int nChild = context.getAccessibleChildrenCount();
    +        for (int i = 0; i < nChild; i++) {
    +            Accessible accessible = context.getAccessibleChild(i);
    +            if (accessible instanceof AccessibleComponent) {
    +                try {
    +                    AccessibleComponent component = (AccessibleComponent) accessible;
    +                    Point p = component.getLocationOnScreen();
    +                    Rectangle r = component.getBounds();
    +                } catch (NullPointerException npe) {
    +                    throw new RuntimeException("Unexpected NullPointerException " +
    +                            "while getting accessible component bounds: ", npe);
    +                }
    +            }
    +        }
    +    }
    +
    +    public void shutdownGUI() {
    +        if (mainFrame != null) {
    +            mainFrame.setVisible(false);
    +            mainFrame.dispose();
    +        }
    +    }
    +}
    
    From 7ed3c3ef2c70f83fdb35561fc2d6cb5d4814a606 Mon Sep 17 00:00:00 2001
    From: Amos Shi 
    Date: Fri, 15 Mar 2024 08:25:01 +0000
    Subject: [PATCH 040/149] 8320943: Files/probeContentType/Basic.java fails on
     latest Windows 11 - content type mismatch
    
    Backport-of: 27cf2f404857aa8c3b1679d0e67f0a3a37e7604b
    ---
     .../file/Files/probeContentType/Basic.java    | 105 +++++++++++-------
     1 file changed, 62 insertions(+), 43 deletions(-)
    
    diff --git a/test/jdk/java/nio/file/Files/probeContentType/Basic.java b/test/jdk/java/nio/file/Files/probeContentType/Basic.java
    index bed8ea38c4d..db9709402a6 100644
    --- a/test/jdk/java/nio/file/Files/probeContentType/Basic.java
    +++ b/test/jdk/java/nio/file/Files/probeContentType/Basic.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2008, 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,26 +23,29 @@
     
     /* @test
      * @bug 4313887 8129632 8129633 8162624 8146215 8162745 8273655 8274171
    + * @library /test/lib
    + * @modules java.base/jdk.internal.util
      * @summary Unit test for probeContentType method
      * @library ../..
    - * @build Basic SimpleFileTypeDetector
    + * @build jdk.test.lib.OSVersion jdk.test.lib.Platform Basic SimpleFileTypeDetector
      * @run main/othervm Basic
      */
     
     import java.io.*;
     import java.nio.file.*;
    +import java.util.ArrayList;
     import java.util.List;
     import java.util.Objects;
     import java.util.stream.Stream;
     
    +import jdk.test.lib.Platform;
    +import jdk.test.lib.OSVersion;
    +
     /**
      * Uses Files.probeContentType to probe html file, custom file type, and minimal
      * set of file extension to content type mappings.
      */
     public class Basic {
    -    private static final boolean IS_UNIX =
    -        ! System.getProperty("os.name").startsWith("Windows");
    -
         static Path createHtmlFile() throws IOException {
             Path file = Files.createTempFile("foo", ".html");
             try (OutputStream out = Files.newOutputStream(file)) {
    @@ -78,7 +81,7 @@ private static int checkContentTypes(String expected, String actual) {
             assert actual != null;
     
             if (!expected.equals(actual)) {
    -            if (IS_UNIX) {
    +            if (!Platform.isWindows()) {
                     Path userMimeTypes =
                         Paths.get(System.getProperty("user.home"), ".mime.types");
                     checkMimeTypesFile(userMimeTypes);
    @@ -97,12 +100,12 @@ private static int checkContentTypes(String expected, String actual) {
             return 0;
         }
     
    -    static int checkContentTypes(ExType[] exTypes)
    +    static int checkContentTypes(List exTypes)
             throws IOException {
             int failures = 0;
    -        for (int i = 0; i < exTypes.length; i++) {
    -            String extension = exTypes[i].extension();
    -            List expectedTypes = exTypes[i].expectedTypes();
    +        for (ExType exType : exTypes) {
    +            String extension = exType.extension();
    +            List expectedTypes = exType.expectedTypes();
                 Path file = Files.createTempFile("foo", "." + extension);
                 try {
                     String type = Files.probeContentType(file);
    @@ -154,39 +157,55 @@ public static void main(String[] args) throws IOException {
             }
     
             // Verify that certain extensions are mapped to the correct type.
    -        var exTypes = new ExType[] {
    -                new ExType("adoc", List.of("text/plain")),
    -                new ExType("bz2", List.of("application/bz2", "application/x-bzip2", "application/x-bzip")),
    -                new ExType("css", List.of("text/css")),
    -                new ExType("csv", List.of("text/csv")),
    -                new ExType("doc", List.of("application/msword")),
    -                new ExType("docx", List.of("application/vnd.openxmlformats-officedocument.wordprocessingml.document")),
    -                new ExType("gz", List.of("application/gzip", "application/x-gzip")),
    -                new ExType("jar", List.of("application/java-archive", "application/x-java-archive", "application/jar")),
    -                new ExType("jpg", List.of("image/jpeg")),
    -                new ExType("js", List.of("text/javascript", "application/javascript")),
    -                new ExType("json", List.of("application/json")),
    -                new ExType("markdown", List.of("text/markdown")),
    -                new ExType("md", List.of("text/markdown", "application/x-genesis-rom")),
    -                new ExType("mp3", List.of("audio/mpeg")),
    -                new ExType("mp4", List.of("video/mp4")),
    -                new ExType("odp", List.of("application/vnd.oasis.opendocument.presentation")),
    -                new ExType("ods", List.of("application/vnd.oasis.opendocument.spreadsheet")),
    -                new ExType("odt", List.of("application/vnd.oasis.opendocument.text")),
    -                new ExType("pdf", List.of("application/pdf")),
    -                new ExType("php", List.of("text/plain", "text/php", "application/x-php")),
    -                new ExType("png", List.of("image/png")),
    -                new ExType("ppt", List.of("application/vnd.ms-powerpoint")),
    -                new ExType("pptx",List.of("application/vnd.openxmlformats-officedocument.presentationml.presentation")),
    -                new ExType("py", List.of("text/plain", "text/x-python", "text/x-python-script")),
    -                new ExType("rar", List.of("application/rar", "application/vnd.rar", "application/x-rar", "application/x-rar-compressed")),
    -                new ExType("rtf", List.of("application/rtf", "text/rtf")),
    -                new ExType("webm", List.of("video/webm")),
    -                new ExType("webp", List.of("image/webp")),
    -                new ExType("xls", List.of("application/vnd.ms-excel")),
    -                new ExType("xlsx", List.of("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")),
    -                new ExType("7z", List.of("application/x-7z-compressed")),
    -        };
    +        List exTypes = new ArrayList();
    +
    +        // extensions with consistent content type
    +        exTypes.add(new ExType("adoc", List.of("text/plain")));
    +        exTypes.add(new ExType("css", List.of("text/css")));
    +        exTypes.add(new ExType("doc", List.of("application/msword")));
    +        exTypes.add(new ExType("docx", List.of("application/vnd.openxmlformats-officedocument.wordprocessingml.document")));
    +        exTypes.add(new ExType("gz", List.of("application/gzip", "application/x-gzip")));
    +        exTypes.add(new ExType("jar", List.of("application/java-archive", "application/x-java-archive", "application/jar")));
    +        exTypes.add(new ExType("jpg", List.of("image/jpeg")));
    +        exTypes.add(new ExType("js", List.of("text/plain", "text/javascript", "application/javascript")));
    +        exTypes.add(new ExType("json", List.of("application/json")));
    +        exTypes.add(new ExType("markdown", List.of("text/markdown")));
    +        exTypes.add(new ExType("md", List.of("text/markdown", "application/x-genesis-rom")));
    +        exTypes.add(new ExType("mp3", List.of("audio/mpeg")));
    +        exTypes.add(new ExType("mp4", List.of("video/mp4")));
    +        exTypes.add(new ExType("odp", List.of("application/vnd.oasis.opendocument.presentation")));
    +        exTypes.add(new ExType("ods", List.of("application/vnd.oasis.opendocument.spreadsheet")));
    +        exTypes.add(new ExType("odt", List.of("application/vnd.oasis.opendocument.text")));
    +        exTypes.add(new ExType("pdf", List.of("application/pdf")));
    +        exTypes.add(new ExType("php", List.of("text/plain", "text/php", "application/x-php")));
    +        exTypes.add(new ExType("png", List.of("image/png")));
    +        exTypes.add(new ExType("ppt", List.of("application/vnd.ms-powerpoint")));
    +        exTypes.add(new ExType("pptx", List.of("application/vnd.openxmlformats-officedocument.presentationml.presentation")));
    +        exTypes.add(new ExType("py", List.of("text/plain", "text/x-python", "text/x-python-script")));
    +        exTypes.add(new ExType("webm", List.of("video/webm")));
    +        exTypes.add(new ExType("webp", List.of("image/webp")));
    +        exTypes.add(new ExType("xls", List.of("application/vnd.ms-excel")));
    +        exTypes.add(new ExType("xlsx", List.of("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")));
    +        // exTypes.add(new ExType("wasm", List.of("application/wasm")));  Note. "wasm" is added via JDK-8297609 (Java 20) which not exist in current java version yet
    +
    +        // extensions with content type that differs on Windows 11+
    +        if (Platform.isWindows() &&
    +            (System.getProperty("os.name").endsWith("11") ||
    +                new OSVersion(10, 0).compareTo(OSVersion.current()) > 0)) {
    +            System.out.println("Windows 11+ detected: using different types");
    +            exTypes.add(new ExType("bz2", List.of("application/bz2", "application/x-bzip2", "application/x-bzip", "application/x-compressed")));
    +            exTypes.add(new ExType("csv", List.of("text/csv", "application/vnd.ms-excel")));
    +            exTypes.add(new ExType("rar", List.of("application/rar", "application/vnd.rar", "application/x-rar", "application/x-rar-compressed", "application/x-compressed")));
    +            exTypes.add(new ExType("rtf", List.of("application/rtf", "text/rtf", "application/msword")));
    +            exTypes.add(new ExType("7z", List.of("application/x-7z-compressed", "application/x-compressed")));
    +        } else {
    +            exTypes.add(new ExType("bz2", List.of("application/bz2", "application/x-bzip2", "application/x-bzip")));
    +            exTypes.add(new ExType("csv", List.of("text/csv")));
    +            exTypes.add(new ExType("rar", List.of("application/rar", "application/vnd.rar", "application/x-rar", "application/x-rar-compressed")));
    +            exTypes.add(new ExType("rtf", List.of("application/rtf", "text/rtf")));
    +            exTypes.add(new ExType("7z", List.of("application/x-7z-compressed")));
    +        }
    +
             failures += checkContentTypes(exTypes);
     
             if (failures > 0) {
    
    From cb1b9a64878e7751c785860c4466e41ad1df276f Mon Sep 17 00:00:00 2001
    From: Goetz Lindenmaier 
    Date: Tue, 19 Mar 2024 14:10:20 +0000
    Subject: [PATCH 041/149] 8292717: Clean up checking of testing requirements in
     configure
    
    Reviewed-by: shade, mdoerr
    Backport-of: 16593cf51c3d994ba4a6d28ab97e519dfd53f37b
    ---
     make/autoconf/configure.ac   |  14 +--
     make/autoconf/jdk-options.m4 |  39 --------
     make/autoconf/lib-tests.m4   | 179 ++++++++++++++++++++++++++++++++++-
     make/autoconf/toolchain.m4   | 134 --------------------------
     4 files changed, 185 insertions(+), 181 deletions(-)
    
    diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac
    index 7d8fa96c2c8..7e5cd136b6b 100644
    --- a/make/autoconf/configure.ac
    +++ b/make/autoconf/configure.ac
    @@ -183,15 +183,14 @@ TOOLCHAIN_POST_DETECTION
     TOOLCHAIN_SETUP_BUILD_COMPILERS
     TOOLCHAIN_MISC_CHECKS
     
    -# Setup the JTReg Regression Test Harness.
    -TOOLCHAIN_SETUP_JTREG
    -
    -# Setup Jib dependency tool
    -TOOLCHAIN_SETUP_JIB
    -
     # After toolchain setup, we need to process some flags to be able to continue.
     FLAGS_POST_TOOLCHAIN
     
    +# Setup the tools needed to test the JDK (JTReg Regression Test Harness
    +# and the Jib dependency tool).
    +LIB_TESTS_SETUP_JTREG
    +LIB_TESTS_SETUP_JIB
    +
     # Now we can test some aspects on the target using configure macros.
     PLATFORM_SETUP_OPENJDK_TARGET_BITS
     PLATFORM_SETUP_OPENJDK_TARGET_ENDIANNESS
    @@ -233,7 +232,8 @@ HOTSPOT_SETUP_JVM_FEATURES
     ###############################################################################
     
     JDKOPT_DETECT_INTREE_EC
    -JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER
    +LIB_TESTS_ENABLE_DISABLE_FAILURE_HANDLER
    +
     JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST
     JDKOPT_EXCLUDE_TRANSLATIONS
     JDKOPT_ENABLE_DISABLE_MANPAGES
    diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4
    index 963b896b8d7..cc45f3c0267 100644
    --- a/make/autoconf/jdk-options.m4
    +++ b/make/autoconf/jdk-options.m4
    @@ -521,45 +521,6 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JLINK_OPTIONS],
       AC_SUBST(JLINK_KEEP_PACKAGED_MODULES)
     ])
     
    -################################################################################
    -#
    -# Check if building of the jtreg failure handler should be enabled.
    -#
    -AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER],
    -[
    -  AC_ARG_ENABLE([jtreg-failure-handler], [AS_HELP_STRING([--enable-jtreg-failure-handler],
    -    [forces build of the jtreg failure handler to be enabled, missing dependencies
    -     become fatal errors. Default is auto, where the failure handler is built if all
    -     dependencies are present and otherwise just disabled.])])
    -
    -  AC_MSG_CHECKING([if jtreg failure handler should be built])
    -
    -  if test "x$enable_jtreg_failure_handler" = "xyes"; then
    -    if test "x$JT_HOME" = "x"; then
    -      AC_MSG_ERROR([Cannot enable jtreg failure handler without jtreg.])
    -    else
    -      BUILD_FAILURE_HANDLER=true
    -      AC_MSG_RESULT([yes, forced])
    -    fi
    -  elif test "x$enable_jtreg_failure_handler" = "xno"; then
    -    BUILD_FAILURE_HANDLER=false
    -    AC_MSG_RESULT([no, forced])
    -  elif test "x$enable_jtreg_failure_handler" = "xauto" \
    -      || test "x$enable_jtreg_failure_handler" = "x"; then
    -    if test "x$JT_HOME" = "x"; then
    -      BUILD_FAILURE_HANDLER=false
    -      AC_MSG_RESULT([no, missing jtreg])
    -    else
    -      BUILD_FAILURE_HANDLER=true
    -      AC_MSG_RESULT([yes, jtreg present])
    -    fi
    -  else
    -    AC_MSG_ERROR([Invalid value for --enable-jtreg-failure-handler: $enable_jtreg_failure_handler])
    -  fi
    -
    -  AC_SUBST(BUILD_FAILURE_HANDLER)
    -])
    -
     ################################################################################
     #
     # Enable or disable generation of the classlist at build time
    diff --git a/make/autoconf/lib-tests.m4 b/make/autoconf/lib-tests.m4
    index e92d4b3c7b7..104168a14f9 100644
    --- a/make/autoconf/lib-tests.m4
    +++ b/make/autoconf/lib-tests.m4
    @@ -1,5 +1,5 @@
     #
    -# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
    +# Copyright (c) 2018, 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
    @@ -23,6 +23,13 @@
     # questions.
     #
     
    +################################################################################
    +# Setup libraries and functionalities needed to test the JDK.
    +################################################################################
    +
    +# Minimum supported version
    +JTREG_MINIMUM_VERSION=6.1
    +
     ###############################################################################
     #
     # Check for graalunit libs, needed for running graalunit tests.
    @@ -54,3 +61,173 @@ AC_DEFUN_ONCE([LIB_TESTS_SETUP_GRAALUNIT],
       UTIL_FIXUP_PATH([GRAALUNIT_LIB])
       AC_SUBST(GRAALUNIT_LIB)
     ])
    +
    +# Setup the JTReg Regression Test Harness.
    +AC_DEFUN_ONCE([LIB_TESTS_SETUP_JTREG],
    +[
    +  AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
    +      [Regression Test Harness @<:@probed@:>@])])
    +
    +  if test "x$with_jtreg" = xno; then
    +    # jtreg disabled
    +    AC_MSG_CHECKING([for jtreg test harness])
    +    AC_MSG_RESULT([no, disabled])
    +  elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then
    +    # An explicit path is specified, use it.
    +    JT_HOME="$with_jtreg"
    +    UTIL_FIXUP_PATH([JT_HOME])
    +    if test ! -d "$JT_HOME"; then
    +      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist])
    +    fi
    +
    +    if test ! -e "$JT_HOME/lib/jtreg.jar"; then
    +      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home])
    +    fi
    +
    +    JTREGEXE="$JT_HOME/bin/jtreg"
    +    if test ! -x "$JTREGEXE"; then
    +      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not contain valid jtreg executable])
    +    fi
    +
    +    AC_MSG_CHECKING([for jtreg test harness])
    +    AC_MSG_RESULT([$JT_HOME])
    +  else
    +    # Try to locate jtreg
    +    if test "x$JT_HOME" != x; then
    +      # JT_HOME set in environment, use it
    +      if test ! -d "$JT_HOME"; then
    +        AC_MSG_WARN([Ignoring JT_HOME pointing to invalid directory: $JT_HOME])
    +        JT_HOME=
    +      else
    +        if test ! -e "$JT_HOME/lib/jtreg.jar"; then
    +          AC_MSG_WARN([Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME])
    +          JT_HOME=
    +        elif test ! -x "$JT_HOME/bin/jtreg"; then
    +          AC_MSG_WARN([Ignoring JT_HOME which does not contain valid jtreg executable: $JT_HOME])
    +          JT_HOME=
    +        else
    +          JTREGEXE="$JT_HOME/bin/jtreg"
    +          AC_MSG_NOTICE([Located jtreg using JT_HOME from environment])
    +        fi
    +      fi
    +    fi
    +
    +    if test "x$JT_HOME" = x; then
    +      # JT_HOME is not set in environment, or was deemed invalid.
    +      # Try to find jtreg on path
    +      UTIL_LOOKUP_PROGS(JTREGEXE, jtreg)
    +      if test "x$JTREGEXE" != x; then
    +        # That's good, now try to derive JT_HOME
    +        JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)`
    +        if test ! -e "$JT_HOME/lib/jtreg.jar"; then
    +          AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found])
    +          JT_HOME=
    +          JTREGEXE=
    +        else
    +          AC_MSG_NOTICE([Located jtreg using jtreg executable in path])
    +        fi
    +      fi
    +    fi
    +
    +    AC_MSG_CHECKING([for jtreg test harness])
    +    if test "x$JT_HOME" != x; then
    +      AC_MSG_RESULT([$JT_HOME])
    +    else
    +      AC_MSG_RESULT([no, not found])
    +
    +      if test "x$with_jtreg" = xyes; then
    +        AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.])
    +      fi
    +    fi
    +  fi
    +
    +  UTIL_FIXUP_EXECUTABLE(JTREGEXE)
    +  UTIL_FIXUP_PATH(JT_HOME)
    +  AC_SUBST(JT_HOME)
    +
    +  # Verify jtreg version
    +  if test "x$JT_HOME" != x; then
    +    AC_MSG_CHECKING([jtreg version number])
    +    # jtreg -version looks like this: "jtreg 6.1+1-19"
    +    # Extract actual version part ("6.1" in this case)
    +    jtreg_version_full=`$JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2`
    +    jtreg_version=${jtreg_version_full/%+*}
    +    AC_MSG_RESULT([$jtreg_version])
    +
    +    # This is a simplified version of TOOLCHAIN_CHECK_COMPILER_VERSION
    +    comparable_actual_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$jtreg_version"`
    +    comparable_minimum_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$JTREG_MINIMUM_VERSION"`
    +    if test $comparable_actual_version -lt $comparable_minimum_version ; then
    +      AC_MSG_ERROR([jtreg version is too old, at least version $JTREG_MINIMUM_VERSION is required])
    +    fi
    +  fi
    +
    +  AC_SUBST(JTREGEXE)
    +])
    +
    +# Setup the JIB dependency resolver
    +AC_DEFUN_ONCE([LIB_TESTS_SETUP_JIB],
    +[
    +  AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib],
    +      [Jib dependency management tool @<:@not used@:>@])])
    +
    +  if test "x$with_jib" = xno || test "x$with_jib" = x; then
    +    # jib disabled
    +    AC_MSG_CHECKING([for jib])
    +    AC_MSG_RESULT(no)
    +  elif test "x$with_jib" = xyes; then
    +    AC_MSG_ERROR([Must supply a value to --with-jib])
    +  else
    +    JIB_HOME="${with_jib}"
    +    AC_MSG_CHECKING([for jib])
    +    AC_MSG_RESULT(${JIB_HOME})
    +    if test ! -d "${JIB_HOME}"; then
    +      AC_MSG_ERROR([--with-jib must be a directory])
    +    fi
    +    JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar)
    +    if test ! -f "${JIB_JAR}"; then
    +      AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}])
    +    fi
    +  fi
    +
    +  AC_SUBST(JIB_HOME)
    +])
    +
    +################################################################################
    +#
    +# Check if building of the jtreg failure handler should be enabled.
    +#
    +AC_DEFUN_ONCE([LIB_TESTS_ENABLE_DISABLE_FAILURE_HANDLER],
    +[
    +  AC_ARG_ENABLE([jtreg-failure-handler], [AS_HELP_STRING([--enable-jtreg-failure-handler],
    +    [forces build of the jtreg failure handler to be enabled, missing dependencies
    +     become fatal errors. Default is auto, where the failure handler is built if all
    +     dependencies are present and otherwise just disabled.])])
    +
    +  AC_MSG_CHECKING([if jtreg failure handler should be built])
    +
    +  if test "x$enable_jtreg_failure_handler" = "xyes"; then
    +    if test "x$JT_HOME" = "x"; then
    +      AC_MSG_ERROR([Cannot enable jtreg failure handler without jtreg.])
    +    else
    +      BUILD_FAILURE_HANDLER=true
    +      AC_MSG_RESULT([yes, forced])
    +    fi
    +  elif test "x$enable_jtreg_failure_handler" = "xno"; then
    +    BUILD_FAILURE_HANDLER=false
    +    AC_MSG_RESULT([no, forced])
    +  elif test "x$enable_jtreg_failure_handler" = "xauto" \
    +      || test "x$enable_jtreg_failure_handler" = "x"; then
    +    if test "x$JT_HOME" = "x"; then
    +      BUILD_FAILURE_HANDLER=false
    +      AC_MSG_RESULT([no, missing jtreg])
    +    else
    +      BUILD_FAILURE_HANDLER=true
    +      AC_MSG_RESULT([yes, jtreg present])
    +    fi
    +  else
    +    AC_MSG_ERROR([Invalid value for --enable-jtreg-failure-handler: $enable_jtreg_failure_handler])
    +  fi
    +
    +  AC_SUBST(BUILD_FAILURE_HANDLER)
    +])
    diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4
    index 6b28a865a09..24151ad49e8 100644
    --- a/make/autoconf/toolchain.m4
    +++ b/make/autoconf/toolchain.m4
    @@ -61,9 +61,6 @@ TOOLCHAIN_MINIMUM_VERSION_xlc=""
     # Minimum supported linker versions, empty means unspecified
     TOOLCHAIN_MINIMUM_LD_VERSION_gcc="2.18"
     
    -# Minimum supported version
    -JTREG_MINIMUM_VERSION=6.1
    -
     # Prepare the system so that TOOLCHAIN_CHECK_COMPILER_VERSION can be called.
     # Must have CC_VERSION_NUMBER and CXX_VERSION_NUMBER.
     # $1 - optional variable prefix for compiler and version variables (BUILD_)
    @@ -1064,134 +1061,3 @@ AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS],
       fi
       AC_SUBST(HOTSPOT_TOOLCHAIN_TYPE)
     ])
    -
    -# Setup the JTReg Regression Test Harness.
    -AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JTREG],
    -[
    -  AC_ARG_WITH(jtreg, [AS_HELP_STRING([--with-jtreg],
    -      [Regression Test Harness @<:@probed@:>@])])
    -
    -  if test "x$with_jtreg" = xno; then
    -    # jtreg disabled
    -    AC_MSG_CHECKING([for jtreg test harness])
    -    AC_MSG_RESULT([no, disabled])
    -  elif test "x$with_jtreg" != xyes && test "x$with_jtreg" != x; then
    -    # An explicit path is specified, use it.
    -    JT_HOME="$with_jtreg"
    -    UTIL_FIXUP_PATH([JT_HOME])
    -    if test ! -d "$JT_HOME"; then
    -      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not exist])
    -    fi
    -
    -    if test ! -e "$JT_HOME/lib/jtreg.jar"; then
    -      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg is not a valid jtreg home])
    -    fi
    -
    -    JTREGEXE="$JT_HOME/bin/jtreg"
    -    if test ! -x "$JTREGEXE"; then
    -      AC_MSG_ERROR([jtreg home directory from --with-jtreg=$with_jtreg does not contain valid jtreg executable])
    -    fi
    -
    -    AC_MSG_CHECKING([for jtreg test harness])
    -    AC_MSG_RESULT([$JT_HOME])
    -  else
    -    # Try to locate jtreg
    -    if test "x$JT_HOME" != x; then
    -      # JT_HOME set in environment, use it
    -      if test ! -d "$JT_HOME"; then
    -        AC_MSG_WARN([Ignoring JT_HOME pointing to invalid directory: $JT_HOME])
    -        JT_HOME=
    -      else
    -        if test ! -e "$JT_HOME/lib/jtreg.jar"; then
    -          AC_MSG_WARN([Ignoring JT_HOME which is not a valid jtreg home: $JT_HOME])
    -          JT_HOME=
    -        elif test ! -x "$JT_HOME/bin/jtreg"; then
    -          AC_MSG_WARN([Ignoring JT_HOME which does not contain valid jtreg executable: $JT_HOME])
    -          JT_HOME=
    -        else
    -          JTREGEXE="$JT_HOME/bin/jtreg"
    -          AC_MSG_NOTICE([Located jtreg using JT_HOME from environment])
    -        fi
    -      fi
    -    fi
    -
    -    if test "x$JT_HOME" = x; then
    -      # JT_HOME is not set in environment, or was deemed invalid.
    -      # Try to find jtreg on path
    -      UTIL_LOOKUP_PROGS(JTREGEXE, jtreg)
    -      if test "x$JTREGEXE" != x; then
    -        # That's good, now try to derive JT_HOME
    -        JT_HOME=`(cd $($DIRNAME $JTREGEXE)/.. && pwd)`
    -        if test ! -e "$JT_HOME/lib/jtreg.jar"; then
    -          AC_MSG_WARN([Ignoring jtreg from path since a valid jtreg home cannot be found])
    -          JT_HOME=
    -          JTREGEXE=
    -        else
    -          AC_MSG_NOTICE([Located jtreg using jtreg executable in path])
    -        fi
    -      fi
    -    fi
    -
    -    AC_MSG_CHECKING([for jtreg test harness])
    -    if test "x$JT_HOME" != x; then
    -      AC_MSG_RESULT([$JT_HOME])
    -    else
    -      AC_MSG_RESULT([no, not found])
    -
    -      if test "x$with_jtreg" = xyes; then
    -        AC_MSG_ERROR([--with-jtreg was specified, but no jtreg found.])
    -      fi
    -    fi
    -  fi
    -
    -  UTIL_FIXUP_EXECUTABLE(JTREGEXE)
    -  UTIL_FIXUP_PATH(JT_HOME)
    -  AC_SUBST(JT_HOME)
    -
    -  # Verify jtreg version
    -  if test "x$JT_HOME" != x; then
    -    AC_MSG_CHECKING([jtreg version number])
    -    # jtreg -version looks like this: "jtreg 6.1+1-19"
    -    # Extract actual version part ("6.1" in this case)
    -    jtreg_version_full=`$JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2`
    -    jtreg_version=${jtreg_version_full/%+*}
    -    AC_MSG_RESULT([$jtreg_version])
    -
    -    # This is a simplified version of TOOLCHAIN_CHECK_COMPILER_VERSION
    -    comparable_actual_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$jtreg_version"`
    -    comparable_minimum_version=`$AWK -F. '{ printf("%05d%05d%05d%05d\n", [$]1, [$]2, [$]3, [$]4) }' <<< "$JTREG_MINIMUM_VERSION"`
    -    if test $comparable_actual_version -lt $comparable_minimum_version ; then
    -      AC_MSG_ERROR([jtreg version is too old, at least version $JTREG_MINIMUM_VERSION is required])
    -    fi
    -  fi
    -
    -  AC_SUBST(JTREGEXE)
    -])
    -
    -# Setup the JIB dependency resolver
    -AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JIB],
    -[
    -  AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib],
    -      [Jib dependency management tool @<:@not used@:>@])])
    -
    -  if test "x$with_jib" = xno || test "x$with_jib" = x; then
    -    # jib disabled
    -    AC_MSG_CHECKING([for jib])
    -    AC_MSG_RESULT(no)
    -  elif test "x$with_jib" = xyes; then
    -    AC_MSG_ERROR([Must supply a value to --with-jib])
    -  else
    -    JIB_HOME="${with_jib}"
    -    AC_MSG_CHECKING([for jib])
    -    AC_MSG_RESULT(${JIB_HOME})
    -    if test ! -d "${JIB_HOME}"; then
    -      AC_MSG_ERROR([--with-jib must be a directory])
    -    fi
    -    JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar)
    -    if test ! -f "${JIB_JAR}"; then
    -      AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}])
    -    fi
    -  fi
    -
    -  AC_SUBST(JIB_HOME)
    -])
    
    From 74822988a3a8e468181d5c3649ec1a6de87aea00 Mon Sep 17 00:00:00 2001
    From: Martin Doerr 
    Date: Wed, 20 Mar 2024 08:57:32 +0000
    Subject: [PATCH 042/149] 8325326: [PPC64] Don't relocate in case of allocation
     failure
    
    Backport-of: 4388095cde20dec602ada9fe2977f1a359ceab91
    ---
     src/hotspot/cpu/ppc/ppc.ad | 16 ++++++++++------
     1 file changed, 10 insertions(+), 6 deletions(-)
    
    diff --git a/src/hotspot/cpu/ppc/ppc.ad b/src/hotspot/cpu/ppc/ppc.ad
    index ebbe80a2637..e5c7b54c0e4 100644
    --- a/src/hotspot/cpu/ppc/ppc.ad
    +++ b/src/hotspot/cpu/ppc/ppc.ad
    @@ -2950,15 +2950,16 @@ encode %{
         intptr_t val = $src$$constant;
         relocInfo::relocType constant_reloc = $src->constant_reloc();  // src
         address const_toc_addr;
    +    RelocationHolder r; // Initializes type to none.
         if (constant_reloc == relocInfo::oop_type) {
           // Create an oop constant and a corresponding relocation.
    -      AddressLiteral a = __ allocate_oop_address((jobject)val);
    +      AddressLiteral a = __ constant_oop_address((jobject)val);
           const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
    -      __ relocate(a.rspec());
    +      r = a.rspec();
         } else if (constant_reloc == relocInfo::metadata_type) {
    +      // Notify OOP recorder (don't need the relocation)
           AddressLiteral a = __ constant_metadata_address((Metadata *)val);
           const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
    -      __ relocate(a.rspec());
         } else {
           // Create a non-oop constant, no relocation needed.
           const_toc_addr = __ long_constant((jlong)$src$$constant);
    @@ -2968,6 +2969,7 @@ encode %{
           ciEnv::current()->record_out_of_memory_failure();
           return;
         }
    +    __ relocate(r); // If set above.
         // Get the constant's TOC offset.
         toc_offset = __ offset_to_method_toc(const_toc_addr);
     
    @@ -2982,15 +2984,16 @@ encode %{
           intptr_t val = $src$$constant;
           relocInfo::relocType constant_reloc = $src->constant_reloc();  // src
           address const_toc_addr;
    +      RelocationHolder r; // Initializes type to none.
           if (constant_reloc == relocInfo::oop_type) {
             // Create an oop constant and a corresponding relocation.
    -        AddressLiteral a = __ allocate_oop_address((jobject)val);
    +        AddressLiteral a = __ constant_oop_address((jobject)val);
             const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
    -        __ relocate(a.rspec());
    +        r = a.rspec();
           } else if (constant_reloc == relocInfo::metadata_type) {
    +        // Notify OOP recorder (don't need the relocation)
             AddressLiteral a = __ constant_metadata_address((Metadata *)val);
             const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none);
    -        __ relocate(a.rspec());
           } else {  // non-oop pointers, e.g. card mark base, heap top
             // Create a non-oop constant, no relocation needed.
             const_toc_addr = __ long_constant((jlong)$src$$constant);
    @@ -3000,6 +3003,7 @@ encode %{
             ciEnv::current()->record_out_of_memory_failure();
             return;
           }
    +      __ relocate(r); // If set above.
           // Get the constant's TOC offset.
           const int toc_offset = __ offset_to_method_toc(const_toc_addr);
           // Store the toc offset of the constant.
    
    From c5ba4b5c3e25364f826da96e17176c90d15d655e Mon Sep 17 00:00:00 2001
    From: Martin Doerr 
    Date: Wed, 20 Mar 2024 08:58:52 +0000
    Subject: [PATCH 043/149] 8326101: [PPC64] Need to bailout cleanly if creation
     of stubs fails when code cache is out of space
    
    Reviewed-by: mbaesken
    Backport-of: e3ae81eeeee8e2b0063a576a90624dd927b512f0
    ---
     src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp |  3 +++
     src/hotspot/cpu/ppc/ppc.ad               | 10 ++++++++--
     2 files changed, 11 insertions(+), 2 deletions(-)
    
    diff --git a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp
    index 214cb59b5d0..b516cfd4e1b 100644
    --- a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp
    +++ b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp
    @@ -449,6 +449,9 @@ void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
       __ extsw(R7_ARG5, length()->as_register());
     
       ce->emit_static_call_stub();
    +  if (ce->compilation()->bailed_out()) {
    +    return; // CodeCache is full
    +  }
     
       bool success = ce->emit_trampoline_stub_for_call(SharedRuntime::get_resolve_static_call_stub());
       if (!success) { return; }
    diff --git a/src/hotspot/cpu/ppc/ppc.ad b/src/hotspot/cpu/ppc/ppc.ad
    index e5c7b54c0e4..c920762013c 100644
    --- a/src/hotspot/cpu/ppc/ppc.ad
    +++ b/src/hotspot/cpu/ppc/ppc.ad
    @@ -2162,7 +2162,10 @@ int HandlerImpl::emit_exception_handler(CodeBuffer &cbuf) {
       MacroAssembler _masm(&cbuf);
     
       address base = __ start_a_stub(size_exception_handler());
    -  if (base == NULL) return 0; // CodeBuffer::expand failed
    +  if (base == NULL) {
    +    ciEnv::current()->record_failure("CodeCache is full");
    +    return 0;  // CodeBuffer::expand failed
    +  }
     
       int offset = __ offset();
       __ b64_patchable((address)OptoRuntime::exception_blob()->content_begin(),
    @@ -2179,7 +2182,10 @@ int HandlerImpl::emit_deopt_handler(CodeBuffer& cbuf) {
       MacroAssembler _masm(&cbuf);
     
       address base = __ start_a_stub(size_deopt_handler());
    -  if (base == NULL) return 0; // CodeBuffer::expand failed
    +  if (base == NULL) {
    +    ciEnv::current()->record_failure("CodeCache is full");
    +    return 0;  // CodeBuffer::expand failed
    +  }
     
       int offset = __ offset();
       __ bl64_patchable((address)SharedRuntime::deopt_blob()->unpack(),
    
    From ac9d090a99c28986a8f20e4c58987ca69e425652 Mon Sep 17 00:00:00 2001
    From: Goetz Lindenmaier 
    Date: Wed, 20 Mar 2024 09:00:37 +0000
    Subject: [PATCH 044/149] 8015739: Background of JInternalFrame is located out
     of JInternalFrame
    
    Reviewed-by: lucy
    Backport-of: 7fb1fb0fa6bfb8258ac0191611f445b83a23408e
    ---
     .../javax/swing/plaf/metal/MetalBorders.java  | 172 ++++++++---
     .../InternalFrameBorderTest.java              | 266 ++++++++++++++++++
     2 files changed, 395 insertions(+), 43 deletions(-)
     create mode 100644 test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java
    
    diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java
    index 5461d7485b1..1ce233de93b 100644
    --- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java
    +++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1998, 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
    @@ -25,24 +25,46 @@
     
     package javax.swing.plaf.metal;
     
    -import javax.swing.*;
    -import javax.swing.border.*;
    -import javax.swing.plaf.*;
    -import javax.swing.plaf.basic.BasicBorders;
    -import javax.swing.text.JTextComponent;
    -
    -import java.awt.Component;
    -import java.awt.Insets;
    +import java.awt.BasicStroke;
     import java.awt.Color;
    +import java.awt.Component;
     import java.awt.Dialog;
     import java.awt.Frame;
     import java.awt.Graphics;
    +import java.awt.Graphics2D;
    +import java.awt.Insets;
    +import java.awt.Stroke;
     import java.awt.Window;
    +import java.awt.geom.AffineTransform;
    +
    +import javax.swing.AbstractButton;
    +import javax.swing.ButtonModel;
    +import javax.swing.JButton;
    +import javax.swing.JComponent;
    +import javax.swing.JInternalFrame;
    +import javax.swing.JMenu;
    +import javax.swing.JMenuBar;
    +import javax.swing.JMenuItem;
    +import javax.swing.JOptionPane;
    +import javax.swing.JScrollPane;
    +import javax.swing.JToolBar;
    +import javax.swing.SwingConstants;
    +import javax.swing.SwingUtilities;
    +import javax.swing.UIManager;
    +import javax.swing.border.AbstractBorder;
    +import javax.swing.border.Border;
    +import javax.swing.border.CompoundBorder;
    +import javax.swing.border.EmptyBorder;
    +import javax.swing.border.LineBorder;
    +import javax.swing.border.MatteBorder;
    +import javax.swing.plaf.BorderUIResource;
    +import javax.swing.plaf.UIResource;
    +import javax.swing.plaf.basic.BasicBorders;
    +import javax.swing.text.JTextComponent;
     
     import sun.swing.StringUIClientPropertyKey;
     import sun.swing.SwingUtilities2;
     
    -
     /**
      * Factory object that can vend Borders appropriate for the metal L & F.
      * @author Steve Wilson
    @@ -203,10 +225,22 @@ public Insets getBorderInsets(Component c, Insets newInsets) {
          */
         @SuppressWarnings("serial") // Superclass is not serializable across versions
         public static class InternalFrameBorder extends AbstractBorder implements UIResource {
    -        private static final int corner = 14;
    +        private static final int CORNER = 14;
    +
    +        /**
    +         * Rounds a double to the nearest integer. It rounds 0.5 down,
    +         * for example 1.5 is rounded to 1.0.
    +         *
    +         * @param d number to be rounded
    +         * @return the rounded value
    +         */
    +        private static int roundHalfDown(double d) {
    +            double decP = (Math.ceil(d) - d);
    +            return (int)((decP == 0.5) ?  Math.floor(d) :  Math.round(d));
    +        }
     
             public void paintBorder(Component c, Graphics g, int x, int y,
    -                          int w, int h) {
    +                                int w, int h) {
     
                 Color background;
                 Color highlight;
    @@ -222,41 +256,93 @@ public void paintBorder(Component c, Graphics g, int x, int y,
                     shadow = MetalLookAndFeel.getControlInfo();
                 }
     
    -              g.setColor(background);
    -              // Draw outermost lines
    -              g.drawLine( 1, 0, w-2, 0);
    -              g.drawLine( 0, 1, 0, h-2);
    -              g.drawLine( w-1, 1, w-1, h-2);
    -              g.drawLine( 1, h-1, w-2, h-1);
    +            Graphics2D g2d = (Graphics2D) g;
    +            AffineTransform at = g2d.getTransform();
    +            Stroke oldStk = g2d.getStroke();
    +            Color oldColor = g2d.getColor();
    +            int stkWidth = 1;
    +
    +            // if m01 or m10 is non-zero, then there is a rotation or shear
    +            // skip resetting the transform
    +            boolean resetTransform = ((at.getShearX() == 0) && (at.getShearY() == 0));
    +
    +            int xtranslation;
    +            int ytranslation;
    +            int width;
    +            int height;
    +
    +            if (resetTransform) {
    +                g2d.setTransform(new AffineTransform());
    +                stkWidth = roundHalfDown(Math.min(at.getScaleX(), at.getScaleY()));
    +
    +                double xx = at.getScaleX() * x + at.getTranslateX();
    +                double yy = at.getScaleY() * y + at.getTranslateY();
    +                xtranslation = roundHalfDown(xx);
    +                ytranslation = roundHalfDown(yy);
    +                width = roundHalfDown(at.getScaleX() * w + xx) - xtranslation;
    +                height = roundHalfDown(at.getScaleY() * h + yy) - ytranslation;
    +            } else {
    +                width = w;
    +                height = h;
    +                xtranslation = x;
    +                ytranslation = y;
    +            }
    +            g2d.translate(xtranslation, ytranslation);
     
    -              // Draw the bulk of the border
    -              for (int i = 1; i < 5; i++) {
    -                  g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);
    -              }
    +            // scaled border
    +            int thickness = (int) Math.ceil(4 * at.getScaleX());
     
    -              if (c instanceof JInternalFrame &&
    -                               ((JInternalFrame)c).isResizable()) {
    -                  g.setColor(highlight);
    -                  // Draw the Long highlight lines
    -                  g.drawLine( corner+1, 3, w-corner, 3);
    -                  g.drawLine( 3, corner+1, 3, h-corner);
    -                  g.drawLine( w-2, corner+1, w-2, h-corner);
    -                  g.drawLine( corner+1, h-2, w-corner, h-2);
    -
    -                  g.setColor(shadow);
    -                  // Draw the Long shadow lines
    -                  g.drawLine( corner, 2, w-corner-1, 2);
    -                  g.drawLine( 2, corner, 2, h-corner-1);
    -                  g.drawLine( w-3, corner, w-3, h-corner-1);
    -                  g.drawLine( corner, h-3, w-corner-1, h-3);
    -              }
    +            g.setColor(background);
    +            // Draw the bulk of the border
    +            for (int i = 0; i <= thickness; i++) {
    +                g.drawRect(i, i, width - (i * 2), height - (i * 2));
    +            }
    +
    +            if (c instanceof JInternalFrame && ((JInternalFrame)c).isResizable()) {
    +                // set new stroke to draw shadow and highlight lines
    +                g2d.setStroke(new BasicStroke((float) stkWidth));
    +
    +                // midpoint at which highlight & shadow lines
    +                // are positioned on the border
    +                int midPoint = thickness / 2;
    +                int offset = ((at.getScaleX() - stkWidth) >= 0 && stkWidth % 2 != 0) ? 1 : 0;
    +                int loc1 = thickness % 2 == 0 ? midPoint + stkWidth / 2 - stkWidth : midPoint;
    +                int loc2 = thickness % 2 == 0 ? midPoint + stkWidth / 2 : midPoint + stkWidth;
    +                // scaled corner
    +                int corner = (int) Math.round(CORNER * at.getScaleX());
    +
    +                // Draw the Long highlight lines
    +                g.setColor(highlight);
    +                g.drawLine(corner + 1, loc2, width - corner, loc2); //top
    +                g.drawLine(loc2, corner + 1, loc2, height - corner); //left
    +                g.drawLine((width - offset) - loc1, corner + 1,
    +                        (width - offset) - loc1, height - corner); //right
    +                g.drawLine(corner + 1, (height - offset) - loc1,
    +                        width - corner, (height - offset) - loc1); //bottom
     
    -          }
    +                // Draw the Long shadow lines
    +                g.setColor(shadow);
    +                g.drawLine(corner, loc1, width - corner - 1, loc1);
    +                g.drawLine(loc1, corner, loc1, height - corner - 1);
    +                g.drawLine((width - offset) - loc2, corner,
    +                        (width - offset) - loc2, height - corner - 1);
    +                g.drawLine(corner, (height - offset) - loc2,
    +                        width - corner - 1, (height - offset) - loc2);
    +            }
     
    -          public Insets getBorderInsets(Component c, Insets newInsets) {
    -              newInsets.set(5, 5, 5, 5);
    -              return newInsets;
    -          }
    +            // restore previous transform
    +            g2d.translate(-xtranslation, -ytranslation);
    +            if (resetTransform) {
    +                g2d.setColor(oldColor);
    +                g2d.setTransform(at);
    +                g2d.setStroke(oldStk);
    +            }
    +        }
    +
    +        public Insets getBorderInsets(Component c, Insets newInsets) {
    +            newInsets.set(4, 4, 4, 4);
    +            return newInsets;
    +        }
         }
     
         /**
    diff --git a/test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java b/test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java
    new file mode 100644
    index 00000000000..ba48c39628e
    --- /dev/null
    +++ b/test/jdk/javax/swing/JInternalFrame/InternalFrameBorderTest.java
    @@ -0,0 +1,266 @@
    +/*
    + * Copyright (c) 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
    + * under the terms of the GNU General Public License version 2 only, as
    + * published by the Free Software Foundation.
    + *
    + * 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.
    + */
    +
    +import java.awt.AWTException;
    +import java.awt.Color;
    +import java.awt.GridBagLayout;
    +import java.awt.Image;
    +import java.awt.Point;
    +import java.awt.Rectangle;
    +import java.awt.Robot;
    +import java.awt.image.MultiResolutionImage;
    +import java.awt.image.RenderedImage;
    +import java.io.File;
    +import java.lang.reflect.InvocationTargetException;
    +import java.util.List;
    +
    +import javax.imageio.ImageIO;
    +import javax.swing.JFrame;
    +import javax.swing.JInternalFrame;
    +import javax.swing.JLabel;
    +import javax.swing.SwingUtilities;
    +import javax.swing.UIManager;
    +
    +/*
    + * @test
    + * @bug 8015739
    + * @key headful
    + * @summary Tests whether background color of JInternalFrame is visible
    + * in the border region at different scales by checking the midpoints
    + * and corners of the border.
    + *
    + * @requires (os.family == "windows")
    + * @run main/othervm -Dsun.java2d.uiScale=1 InternalFrameBorderTest
    + * @run main/othervm -Dsun.java2d.uiScale=1.25 InternalFrameBorderTest
    + * @run main/othervm -Dsun.java2d.uiScale=1.5 InternalFrameBorderTest
    + * @run main/othervm -Dsun.java2d.uiScale=1.75 InternalFrameBorderTest
    + * @run main/othervm -Dsun.java2d.uiScale=2 InternalFrameBorderTest
    + * @run main/othervm -Dsun.java2d.uiScale=2.5 InternalFrameBorderTest
    + * @run main/othervm -Dsun.java2d.uiScale=3 InternalFrameBorderTest
    + */
    +
    +/*
    + * @test
    + * @bug 8015739
    + * @key headful
    + * @summary Tests whether background color of JInternalFrame is visible
    + * in the border region at different scales by checking the midpoints
    + * and corners of the border.
    + *
    + * @requires (os.family == "mac" | os.family == "linux")
    + * @run main/othervm -Dsun.java2d.uiScale=1 InternalFrameBorderTest
    + * @run main/othervm -Dsun.java2d.uiScale=2 InternalFrameBorderTest
    + */
    +
    +public class InternalFrameBorderTest {
    +    private static final int FRAME_SIZE = 300;
    +    private static final int INTFRAME_SIZE = 150;
    +    private static final int MIDPOINT = INTFRAME_SIZE / 2;
    +    private static final int BORDER_THICKNESS = 4;
    +
    +    private static final StringBuffer errorLog = new StringBuffer();
    +
    +    private static JFrame jFrame;
    +    private static Rectangle jFrameBounds;
    +    private static JInternalFrame iFrame;
    +    private static Point iFrameLoc;
    +    private static int iFrameMaxX;
    +    private static int iFrameMaxY;
    +
    +    private static Robot robot;
    +    private static String uiScale;
    +
    +    public static void main(String[] args) throws AWTException,
    +            InterruptedException, InvocationTargetException {
    +        try {
    +            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    +        } catch (Exception e) {
    +            System.out.println("Metal LAF class not supported");
    +            return;
    +        }
    +
    +        try {
    +            robot = new Robot();
    +            robot.setAutoDelay(200);
    +            uiScale = System.getProperty("sun.java2d.uiScale");
    +
    +            SwingUtilities.invokeAndWait(InternalFrameBorderTest::createAndShowGUI);
    +            robot.waitForIdle();
    +            robot.delay(500);
    +
    +            SwingUtilities.invokeAndWait(() -> {
    +                iFrameLoc = iFrame.getLocationOnScreen();
    +                iFrameMaxX = iFrameLoc.x + INTFRAME_SIZE;
    +                iFrameMaxY = iFrameLoc.y + INTFRAME_SIZE;
    +                jFrameBounds = jFrame.getBounds();
    +            });
    +
    +            // Check Borders
    +            checkBorderMidPoints("TOP");
    +            checkBorderMidPoints("RIGHT");
    +            checkBorderMidPoints("BOTTOM");
    +            checkBorderMidPoints("LEFT");
    +
    +            // Check Corner Diagonals
    +            checkCorners("TOP_LEFT");
    +            checkCorners("TOP_RIGHT");
    +            checkCorners("BOTTOM_RIGHT");
    +            checkCorners("BOTTOM_LEFT");
    +
    +            if (errorLog.length() != 0) {
    +                saveScreenCapture("JIF_uiScale_" + uiScale + ".png");
    +                throw new RuntimeException("Following error(s) occurred: \n"
    +                        + errorLog);
    +            }
    +        } finally {
    +            if (jFrame != null) {
    +                jFrame.dispose();
    +            }
    +            robot.delay(500);
    +        }
    +    }
    +
    +    private static void checkBorderMidPoints(String borderDirection) {
    +        int x, y;
    +        int start, stop;
    +
    +        switch (borderDirection) {
    +            case "TOP": {
    +                x = iFrameLoc.x + MIDPOINT;
    +                y = iFrameLoc.y + BORDER_THICKNESS;
    +                start = iFrameLoc.y;
    +                stop = iFrameLoc.y + BORDER_THICKNESS - 1;
    +            } break;
    +            case "RIGHT": {
    +                x = iFrameMaxX - BORDER_THICKNESS;
    +                y = iFrameLoc.y + MIDPOINT;
    +                start = iFrameMaxX - BORDER_THICKNESS + 1;
    +                stop = iFrameMaxX;
    +            } break;
    +            case "BOTTOM": {
    +                x = iFrameLoc.x + MIDPOINT;
    +                y = iFrameMaxY - BORDER_THICKNESS;
    +                start = iFrameMaxY - BORDER_THICKNESS + 1;
    +                stop = iFrameMaxY;
    +            } break;
    +            case "LEFT": {
    +                x = iFrameLoc.x;
    +                y = iFrameLoc.y + MIDPOINT;
    +                start = iFrameLoc.x;
    +                stop = iFrameLoc.x + BORDER_THICKNESS - 1;
    +            } break;
    +            default: throw new IllegalStateException("Unexpected value: "
    +                    + borderDirection);
    +        }
    +
    +        boolean isVertical = borderDirection.equals("RIGHT")
    +                || borderDirection.equals("LEFT");
    +        boolean isHorizontal = borderDirection.equals("TOP")
    +                || borderDirection.equals("BOTTOM");
    +
    +        robot.mouseMove(x, y);
    +        for (int i = start; i < stop; i++) {
    +            int locX = isVertical ? i : (iFrameLoc.x + MIDPOINT);
    +            int locY = isHorizontal ? i : (iFrameLoc.y + MIDPOINT);
    +            if (Color.RED.equals(robot.getPixelColor(locX, locY))) {
    +                errorLog.append("At uiScale: " + uiScale
    +                        + ", Red background color detected at "
    +                        + borderDirection + " border.\n");
    +                break;
    +            }
    +        }
    +        robot.delay(300);
    +    }
    +
    +    private static void checkCorners(String cornerLocation) {
    +        int x, y;
    +
    +        switch (cornerLocation) {
    +            case "TOP_LEFT": {
    +                x = iFrameLoc.x;
    +                y = iFrameLoc.y;
    +            } break;
    +            case "TOP_RIGHT": {
    +                x = iFrameMaxX;
    +                y = iFrameLoc.y;
    +            } break;
    +            case "BOTTOM_RIGHT": {
    +                x = iFrameMaxX;
    +                y = iFrameMaxY;
    +            } break;
    +            case "BOTTOM_LEFT": {
    +                x = iFrameLoc.x;
    +                y = iFrameMaxY;
    +            } break;
    +            default: throw new IllegalStateException("Unexpected value: "
    +                    + cornerLocation);
    +        }
    +
    +        boolean isTop = cornerLocation.equals("TOP_LEFT")
    +                || cornerLocation.equals("TOP_RIGHT");
    +        boolean isLeft = cornerLocation.equals("TOP_LEFT")
    +                || cornerLocation.equals("BOTTOM_LEFT");
    +
    +        robot.mouseMove(x, y);
    +        for (int i = 0; i < BORDER_THICKNESS - 1; i++) {
    +            int locX = isLeft ? (x + i) : (x - i);
    +            int locY = isTop ? (y + i) : (y - i);
    +            if (Color.RED.equals(robot.getPixelColor(locX, locY))) {
    +                errorLog.append("At uiScale: " + uiScale + ", Red background color"
    +                        + " detected at " + cornerLocation + " corner.\n");
    +                break;
    +            }
    +        }
    +        robot.delay(300);
    +    }
    +
    +    private static void createAndShowGUI() {
    +        jFrame = new JFrame();
    +        jFrame.setSize(FRAME_SIZE, FRAME_SIZE);
    +        jFrame.setLayout(null);
    +        jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    +
    +        JLabel scale = new JLabel("UI Scale: " + uiScale);
    +        iFrame = new JInternalFrame("iframe", true);
    +        iFrame.setLayout(new GridBagLayout());
    +        iFrame.setBackground(Color.RED);
    +        iFrame.add(scale);
    +        iFrame.setLocation(30, 30);
    +        jFrame.getContentPane().add(iFrame);
    +        iFrame.setSize(INTFRAME_SIZE, INTFRAME_SIZE);
    +        iFrame.setVisible(true);
    +        jFrame.setLocation(150, 150);
    +        jFrame.setVisible(true);
    +    }
    +
    +    private static void saveScreenCapture(String filename) {
    +        MultiResolutionImage mrImage = robot.createMultiResolutionScreenCapture(jFrameBounds);
    +        List variants = mrImage.getResolutionVariants();
    +        RenderedImage image = (RenderedImage) variants.get(variants.size() - 1);
    +        try {
    +            ImageIO.write(image, "png", new File(filename));
    +        } catch (Exception e) {
    +            e.printStackTrace();
    +        }
    +    }
    +}
    
    From 44825a003b6b172015c7f374d9b5e90a20129489 Mon Sep 17 00:00:00 2001
    From: Goetz Lindenmaier 
    Date: Wed, 20 Mar 2024 09:01:31 +0000
    Subject: [PATCH 045/149] 8328524: [x86] StringRepeat.java failure on
     linux-x86: Could not reserve enough space for 2097152KB object heap
    
    Backport-of: eebcc2181fe27f6aa10559233c7c58882a146f56
    ---
     test/jdk/java/lang/String/StringRepeat.java | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/test/jdk/java/lang/String/StringRepeat.java b/test/jdk/java/lang/String/StringRepeat.java
    index c36e512f8ba..11a0393766e 100644
    --- a/test/jdk/java/lang/String/StringRepeat.java
    +++ b/test/jdk/java/lang/String/StringRepeat.java
    @@ -31,7 +31,7 @@
      * @test
      * @summary This exercises String#repeat patterns with 16 * 1024 * 1024 repeats.
      * @requires os.maxMemory >= 2G
    - * @requires !(os.family == "windows" & sun.arch.data.model == "32")
    + * @requires vm.bits == "64"
      * @run main/othervm -Xmx2g StringRepeat 16777216
      */
     
    
    From 6bcb8ac9f966c552f7284957d8515c5abcf829a5 Mon Sep 17 00:00:00 2001
    From: Andrew Lu 
    Date: Thu, 21 Mar 2024 03:07:18 +0000
    Subject: [PATCH 046/149] 8248194: Need better support for running SA tests on
     core files
    
    Reviewed-by: lucy
    Backport-of: db2d4e8f5af1274d82242d3d86b922656954e1ef
    ---
     .../serviceability/sa/ClhsdbCDSCore.java      | 125 ++--------
     .../jtreg/serviceability/sa/ClhsdbFindPC.java |  94 ++++++--
     .../jtreg/serviceability/sa/TestJmapCore.java |  47 +---
     test/lib/jdk/test/lib/SA/SATestUtils.java     |   2 +-
     test/lib/jdk/test/lib/apps/LingeredApp.java   |  49 +++-
     test/lib/jdk/test/lib/util/CoreUtils.java     | 218 ++++++++++++++++++
     6 files changed, 362 insertions(+), 173 deletions(-)
     create mode 100644 test/lib/jdk/test/lib/util/CoreUtils.java
    
    diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java
    index e93776b3b09..180c241632a 100644
    --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java
    +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java
    @@ -27,7 +27,6 @@
      * @summary Test the clhsdb commands 'printmdo', 'printall', 'jstack' on a CDS enabled corefile.
      * @requires vm.cds
      * @requires vm.hasSA
    - * @requires os.family != "windows"
      * @requires vm.flavor == "server"
      * @library /test/lib
      * @modules java.base/jdk.internal.misc
    @@ -47,15 +46,12 @@
     import java.io.IOException;
     import java.io.File;
     import java.nio.file.Files;
    -import java.nio.file.Path;
     import java.nio.file.Paths;
     import jdk.test.lib.Asserts;
    -import java.util.regex.Pattern;
    -import java.util.regex.Matcher;
     import jdk.internal.misc.Unsafe;
    -import java.util.Scanner;
     import jdk.test.lib.Utils;
     import jtreg.SkippedException;
    +import jdk.test.lib.util.CoreUtils;
     
     class CrashApp {
         public static void main(String[] args) {
    @@ -64,12 +60,8 @@ public static void main(String[] args) {
     }
     
     public class ClhsdbCDSCore {
    -
    -    private static final String TEST_CDS_CORE_FILE_NAME = "cds_core_file";
    -    private static final String LOCATIONS_STRING = "location: ";
    -    private static final String RUN_SHELL_NO_LIMIT = "ulimit -c unlimited && ";
         private static final String SHARED_ARCHIVE_NAME = "ArchiveForClhsdbCDSCore.jsa";
    -    private static final String CORE_PATTERN_FILE_NAME = "/proc/sys/kernel/core_pattern";
    +    private static String coreFileName;
     
         public static void main(String[] args) throws Exception {
             System.out.println("Starting ClhsdbCDSCore test");
    @@ -90,59 +82,23 @@ public static void main(String[] args) throws Exception {
                     CrashApp.class.getName()
                 };
     
    -            OutputAnalyzer crashOut;
    +            OutputAnalyzer crashOutput;
                 try {
                    List options = new ArrayList<>();
                    options.addAll(Arrays.asList(jArgs));
    -               crashOut =
    -                   ProcessTools.executeProcess(getTestJvmCommandlineWithPrefix(
    -                   RUN_SHELL_NO_LIMIT, options.toArray(new String[0])));
    +               ProcessBuilder pb = ProcessTools.createTestJvm(options);
    +               // Add "ulimit -c unlimited" if we can since we are generating a core file.
    +               pb = CoreUtils.addCoreUlimitCommand(pb);
    +               crashOutput = ProcessTools.executeProcess(pb);
                 } catch (Throwable t) {
                    throw new Error("Can't execute the java cds process.", t);
                 }
     
    -            System.out.println(crashOut.getOutput());
    -            String crashOutputString = crashOut.getOutput();
    -            String coreFileLocation = getCoreFileLocation(crashOutputString);
    -            if (coreFileLocation == null) {
    -                if (Platform.isOSX()) {
    -                    File coresDir = new File("/cores");
    -                    if (!coresDir.isDirectory()) {
    -                        cleanup();
    -                        throw new Error(coresDir + " is not a directory");
    -                    }
    -                    // the /cores directory is usually not writable on macOS 10.15
    -                    if (!coresDir.canWrite()) {
    -                        cleanup();
    -                        throw new SkippedException("Directory \"" + coresDir +
    -                            "\" is not writable");
    -                    }
    -                } else if (Platform.isLinux()) {
    -                    // Check if a crash report tool is installed.
    -                    File corePatternFile = new File(CORE_PATTERN_FILE_NAME);
    -                    try (Scanner scanner = new Scanner(corePatternFile)) {
    -                        while (scanner.hasNextLine()) {
    -                            String line = scanner.nextLine();
    -                            line = line.trim();
    -                            System.out.println(line);
    -                            if (line.startsWith("|")) {
    -                                System.out.println(
    -                                    "\nThis system uses a crash report tool ($cat /proc/sys/kernel/core_pattern).\n" +
    -                                    "Core files might not be generated. Please reset /proc/sys/kernel/core_pattern\n" +
    -                                    "to enable core generation. Skipping this test.");
    -                                cleanup();
    -                                throw new SkippedException("This system uses a crash report tool");
    -                            }
    -                        }
    -                    }
    -                }
    -                throw new Error("Couldn't find core file location in: '" + crashOutputString + "'");
    -            }
                 try {
    -                Asserts.assertGT(new File(coreFileLocation).length(), 0L, "Unexpected core size");
    -                Files.move(Paths.get(coreFileLocation), Paths.get(TEST_CDS_CORE_FILE_NAME));
    -            } catch (IOException ioe) {
    -                throw new Error("Can't move core file: " + ioe, ioe);
    +                coreFileName = CoreUtils.getCoreFileLocation(crashOutput.getStdout());
    +            } catch (Exception e) {
    +                cleanup();
    +                throw e;
                 }
     
                 ClhsdbLauncher test = new ClhsdbLauncher();
    @@ -150,8 +106,7 @@ public static void main(String[] args) throws Exception {
                 // Ensure that UseSharedSpaces is turned on.
                 List cmds = List.of("flags UseSharedSpaces");
     
    -            String useSharedSpacesOutput = test.runOnCore(TEST_CDS_CORE_FILE_NAME, cmds,
    -                                                          null, null);
    +            String useSharedSpacesOutput = test.runOnCore(coreFileName, cmds, null, null);
     
                 if (useSharedSpacesOutput == null) {
                     // Output could be null due to attach permission issues.
    @@ -205,7 +160,7 @@ public static void main(String[] args) throws Exception {
                     "Method*"));
                 unExpStrMap.put("jstack -v", List.of(
                     "sun.jvm.hotspot.debugger.UnmappedAddressException"));
    -            test.runOnCore(TEST_CDS_CORE_FILE_NAME, cmds, expStrMap, unExpStrMap);
    +            test.runOnCore(coreFileName, cmds, expStrMap, unExpStrMap);
             } catch (SkippedException e) {
                 throw e;
             } catch (Exception ex) {
    @@ -215,60 +170,8 @@ public static void main(String[] args) throws Exception {
             System.out.println("Test PASSED");
         }
     
    -    // lets search for a few possible locations using process output and return existing location
    -    private static String getCoreFileLocation(String crashOutputString) {
    -        Asserts.assertTrue(crashOutputString.contains(LOCATIONS_STRING),
    -            "Output doesn't contain the location of core file.");
    -        String stringWithLocation = Arrays.stream(crashOutputString.split("\\r?\\n"))
    -            .filter(str -> str.contains(LOCATIONS_STRING))
    -            .findFirst()
    -            .get();
    -        stringWithLocation = stringWithLocation.substring(stringWithLocation
    -            .indexOf(LOCATIONS_STRING) + LOCATIONS_STRING.length());
    -        System.out.println("getCoreFileLocation found stringWithLocation = " + stringWithLocation);
    -        String coreWithPid;
    -        if (stringWithLocation.contains("or ")) {
    -            Matcher m = Pattern.compile("or.* ([^ ]+[^\\)])\\)?").matcher(stringWithLocation);
    -            if (!m.find()) {
    -                throw new Error("Couldn't find path to core inside location string");
    -            }
    -            coreWithPid = m.group(1);
    -        } else {
    -            coreWithPid = stringWithLocation.trim();
    -        }
    -        if (new File(coreWithPid).exists()) {
    -            return coreWithPid;
    -        }
    -        String justCore = Paths.get("core").toString();
    -        if (new File(justCore).exists()) {
    -            return justCore;
    -        }
    -        Path coreWithPidPath = Paths.get(coreWithPid);
    -        String justFile = coreWithPidPath.getFileName().toString();
    -        if (new File(justFile).exists()) {
    -            return justFile;
    -        }
    -        Path parent = coreWithPidPath.getParent();
    -        if (parent != null) {
    -            String coreWithoutPid = parent.resolve("core").toString();
    -            if (new File(coreWithoutPid).exists()) {
    -                return coreWithoutPid;
    -            }
    -        }
    -        return null;
    -    }
    -
    -    private static String[] getTestJvmCommandlineWithPrefix(String prefix, String... args) {
    -        try {
    -            String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJvm(args));
    -            return new String[]{"sh", "-c", prefix + cmd};
    -        } catch (Throwable t) {
    -            throw new Error("Can't create process builder: " + t, t);
    -        }
    -    }
    -
         private static void cleanup() {
    -        remove(TEST_CDS_CORE_FILE_NAME);
    +        if (coreFileName != null) remove(coreFileName);
             remove(SHARED_ARCHIVE_NAME);
         }
     
    diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java
    index 3f7737c1917..05d89ffbfd6 100644
    --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java
    +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java
    @@ -27,26 +27,63 @@
     import java.util.ArrayList;
     
     import jdk.test.lib.apps.LingeredApp;
    +import jdk.test.lib.util.CoreUtils;
     import jtreg.SkippedException;
     
     /**
      * @test
      * @bug 8193124
    - * @summary Test the clhsdb 'findpc' command
    + * @summary Test the clhsdb 'findpc' command with Xcomp on live process
      * @requires vm.hasSA
      * @requires vm.compiler1.enabled
    + * @requires vm.opt.DeoptimizeALot != true
      * @library /test/lib
    - * @run main/othervm/timeout=480 ClhsdbFindPC
    + * @run main/othervm/timeout=480 ClhsdbFindPC true false
    + */
    +
    +/**
    + * @test
    + * @bug 8193124
    + * @summary Test the clhsdb 'findpc' command with Xcomp on core file
    + * @requires vm.compMode != "Xcomp"
    + * @requires vm.hasSA
    + * @requires vm.compiler1.enabled
    + * @library /test/lib
    + * @run main/othervm/timeout=480 ClhsdbFindPC true true
    + */
    +
    +/**
    + * @test
    + * @bug 8193124
    + * @summary Test the clhsdb 'findpc' command w/o Xcomp on live process
    + * @requires vm.hasSA
    + * @requires vm.compiler1.enabled
    + * @requires vm.opt.DeoptimizeALot != true
    + * @library /test/lib
    + * @run main/othervm/timeout=480 ClhsdbFindPC false false
    + */
    +
    +/**
    + * @test
    + * @bug 8193124
    + * @summary Test the clhsdb 'findpc' command w/o Xcomp on core file
    + * @requires vm.compMode != "Xcomp"
    + * @requires vm.hasSA
    + * @requires vm.compiler1.enabled
    + * @library /test/lib
    + * @run main/othervm/timeout=480 ClhsdbFindPC false true
      */
     
     public class ClhsdbFindPC {
     
    -    private static void testFindPC(boolean withXcomp) throws Exception {
    +    private static void testFindPC(boolean withXcomp, boolean withCore) throws Exception {
             LingeredApp theApp = null;
    +        String coreFileName = null;
             try {
                 ClhsdbLauncher test = new ClhsdbLauncher();
     
                 theApp = new LingeredAppWithTrivialMain();
    +            theApp.setForceCrash(withCore);
                 if (withXcomp) {
                     LingeredApp.startApp(List.of("-Xcomp"), theApp);
                 } else {
    @@ -60,27 +97,41 @@ private static void testFindPC(boolean withXcomp) throws Exception {
                 }
                 System.out.println("with pid " + theApp.getPid());
     
    -            // Run 'jstack -v' command to get the pc
    -            List cmds = List.of("jstack -v");
    -            String output = test.run(theApp.getPid(), cmds, null, null);
    +            // Get the core file name if we are debugging a core instead of live process
    +            if (withCore) {
    +                coreFileName = CoreUtils.getCoreFileLocation(theApp.getOutput().getStdout());
    +            }
     
    -            // Test the 'findpc' command passing in the pc obtained from
    -            // the 'jstack -v' command
    -            cmds = new ArrayList();
    +            // Run 'jstack -v' command to get the findpc address
    +            List cmds = List.of("jstack -v");
    +            String output;
    +            if (withCore) {
    +                output = test.runOnCore(coreFileName, cmds, null, null);
    +            } else {
    +                output = test.run(theApp.getPid(), cmds, null, null);
    +            }
     
    -            String cmdStr = null;
    +            // Extract pc address from the following line:
    +            //   - LingeredAppWithTrivialMain.main(java.lang.String[]) @bci=1, line=33, pc=0x00007ff18ff519f0, ...
    +            String pcAddress = null;
                 String[] parts = output.split("LingeredAppWithTrivialMain.main");
                 String[] tokens = parts[1].split(" ");
                 for (String token : tokens) {
                     if (token.contains("pc")) {
    -                    String[] address = token.split("=");
    -                    // address[1] represents the address of the Method
    -                    cmdStr = "findpc " + address[1].replace(",","");
    -                    cmds.add(cmdStr);
    +                    String[] addresses = token.split("=");
    +                    // addresses[1] represents the address of the Method
    +                    pcAddress = addresses[1].replace(",","");
                         break;
                     }
                 }
    +            if (pcAddress == null) {
    +                throw new RuntimeException("Cannot find LingeredAppWithTrivialMain.main pc in output");
    +            }
     
    +            // Test the 'findpc' command passing in the pc obtained from above
    +            cmds = new ArrayList();
    +            String cmdStr = "findpc " + pcAddress;
    +            cmds.add(cmdStr);
                 Map> expStrMap = new HashMap<>();
                 if (withXcomp) {
                     expStrMap.put(cmdStr, List.of(
    @@ -93,20 +144,27 @@ private static void testFindPC(boolean withXcomp) throws Exception {
                                 "In interpreter codelet"));
                 }
     
    -            test.run(theApp.getPid(), cmds, expStrMap, null);
    +            if (withCore) {
    +                test.runOnCore(coreFileName, cmds, expStrMap, null);
    +            } else {
    +                test.run(theApp.getPid(), cmds, expStrMap, null);
    +            }
             } catch (SkippedException se) {
                 throw se;
             } catch (Exception ex) {
                 throw new RuntimeException("Test ERROR " + ex, ex);
             } finally {
    -            LingeredApp.stopApp(theApp);
    +            if (!withCore) {
    +                LingeredApp.stopApp(theApp);
    +            }
             }
         }
     
         public static void main(String[] args) throws Exception {
    +        boolean withXcomp = Boolean.parseBoolean(args[0]);
    +        boolean withCore = Boolean.parseBoolean(args[1]);
             System.out.println("Starting the ClhsdbFindPC test");
    -        testFindPC(true);
    -        testFindPC(false);
    +        testFindPC(withXcomp, withCore);
             System.out.println("Test PASSED");
         }
     }
    diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java
    index fdd0d044d2d..8e0fd4afcae 100644
    --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java
    +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java
    @@ -37,21 +37,18 @@
     import jdk.test.lib.hprof.HprofParser;
     import jdk.test.lib.process.ProcessTools;
     import jdk.test.lib.process.OutputAnalyzer;
    +import jdk.test.lib.util.CoreUtils;
     import jtreg.SkippedException;
     
     import java.io.File;
     
     public class TestJmapCore {
    -    static final String pidSeparator = ":KILLED_PID";
    -
         public static final String HEAP_OOME = "heap";
         public static final String METASPACE_OOME = "metaspace";
     
     
         public static void main(String[] args) throws Throwable {
             if (args.length == 1) {
    -            // If 1 argument is set prints pid so main process could find corefile
    -            System.out.println(ProcessHandle.current().pid() + pidSeparator);
                 try {
                     if (args[0].equals(HEAP_OOME)) {
                         Object[] oa = new Object[Integer.MAX_VALUE / 2];
    @@ -72,19 +69,6 @@ public static void main(String[] args) throws Throwable {
             test(args[1]);
         }
     
    -    // Test tries to run java with ulimit unlimited if it is possible
    -    static boolean useDefaultUlimit() {
    -        if (Platform.isWindows()) {
    -            return true;
    -        }
    -        try {
    -            OutputAnalyzer output = ProcessTools.executeProcess("sh", "-c", "ulimit -c unlimited && ulimit -c");
    -            return !(output.getExitValue() == 0 && output.getStdout().contains("unlimited"));
    -        } catch (Throwable t) {
    -            return true;
    -        }
    -    }
    -
         static void test(String type) throws Throwable {
             ProcessBuilder pb = ProcessTools.createTestJvm("-XX:+CreateCoredumpOnCrash",
                     "-Xmx512m", "-XX:MaxMetaspaceSize=64m", "-XX:+CrashOnOutOfMemoryError", "-XX:-TransmitErrorReport",
    @@ -93,29 +77,12 @@ static void test(String type) throws Throwable {
                     Platform.isDebugBuild() ? "-XX:-VerifyDependencies" : "--show-version",
                     TestJmapCore.class.getName(), type);
     
    -        boolean useDefaultUlimit = useDefaultUlimit();
    -        System.out.println("Run test with ulimit: " + (useDefaultUlimit ? "default" : "unlimited"));
    -        OutputAnalyzer output = useDefaultUlimit
    -            ? ProcessTools.executeProcess(pb)
    -            : ProcessTools.executeProcess("sh", "-c", "ulimit -c unlimited && "
    -                    + ProcessTools.getCommandLine(pb));
    -        File core;
    -        String pattern = Platform.isWindows() ? ".*\\.mdmp" : "core(\\.\\d+)?";
    -        File[] cores = new File(".").listFiles((dir, name) -> name.matches(pattern));
    -        if (cores.length == 0) {
    -            // /cores/core.$pid might be generated on macosx by default
    -            String pid = output.firstMatch("^(\\d+)" + pidSeparator, 1);
    -            core = new File("cores/core." + pid);
    -            if (!core.exists()) {
    -                throw new SkippedException("Has not been able to find coredump");
    -            }
    -        } else {
    -            Asserts.assertTrue(cores.length == 1,
    -                    "There are unexpected files containing core "
    -                    + ": " + String.join(",", new File(".").list()) + ".");
    -            core = cores[0];
    -        }
    -        System.out.println("Found corefile: " + core.getAbsolutePath());
    +        // If we are going to force a core dump, apply "ulimit -c unlimited" if we can.
    +        pb = CoreUtils.addCoreUlimitCommand(pb);
    +        OutputAnalyzer output =  ProcessTools.executeProcess(pb);
    +
    +        String coreFileName = CoreUtils.getCoreFileLocation(output.getStdout());
    +        File core = new File(coreFileName);
     
             File dumpFile = new File("heap.hprof");
             JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
    diff --git a/test/lib/jdk/test/lib/SA/SATestUtils.java b/test/lib/jdk/test/lib/SA/SATestUtils.java
    index 36480c690b9..26a41e8b904 100644
    --- a/test/lib/jdk/test/lib/SA/SATestUtils.java
    +++ b/test/lib/jdk/test/lib/SA/SATestUtils.java
    @@ -30,12 +30,12 @@
     import java.security.PrivilegedExceptionAction;
     import java.util.ArrayList;
     import java.util.Arrays;
    -import java.util.List;
     import java.util.concurrent.TimeUnit;
     
     import jdk.test.lib.JDKToolLauncher;
     import jdk.test.lib.Platform;
     import jtreg.SkippedException;
    +import java.util.List;
     
     public class SATestUtils {
         /**
    diff --git a/test/lib/jdk/test/lib/apps/LingeredApp.java b/test/lib/jdk/test/lib/apps/LingeredApp.java
    index e454a96bbdd..147870b1fce 100644
    --- a/test/lib/jdk/test/lib/apps/LingeredApp.java
    +++ b/test/lib/jdk/test/lib/apps/LingeredApp.java
    @@ -44,6 +44,7 @@
     import jdk.test.lib.Utils;
     import jdk.test.lib.process.OutputBuffer;
     import jdk.test.lib.process.StreamPumper;
    +import jdk.test.lib.util.CoreUtils;
     
     /**
      * This is a framework to launch an app that could be synchronized with caller
    @@ -85,6 +86,8 @@ public class LingeredApp {
         protected static final int appWaitTime = 100;
         protected final String lockFileName;
     
    +    protected boolean forceCrash = false; // set true to force a crash and core file
    +
         /**
          * Create LingeredApp object on caller side. Lock file have be a valid filename
          * at writable location
    @@ -100,6 +103,12 @@ public LingeredApp() {
             this.lockFileName = lockName;
         }
     
    +    public void setForceCrash(boolean forceCrash) {
    +        this.forceCrash = forceCrash;
    +    }
    +
    +    native private static int crash();
    +
         /**
          *
          * @return name of lock file
    @@ -273,7 +282,11 @@ public void waitAppReady(long timeout) throws IOException {
     
                 // Make sure process didn't already exit
                 if (!appProcess.isAlive()) {
    -                throw new IOException("App exited unexpectedly with " + appProcess.exitValue());
    +                if (forceCrash) {
    +                    return; // This is expected. Just return.
    +                } else {
    +                    throw new IOException("App exited unexpectedly with " + appProcess.exitValue());
    +                }
                 }
     
                 try {
    @@ -321,6 +334,11 @@ public List runAppPrepare(List vmArguments) {
                 // Lets user manage LingeredApp options
                 cmd.addAll(vmArguments);
             }
    +        if (forceCrash) {
    +            cmd.add("-XX:+CreateCoredumpOnCrash");
    +            // We need to find libLingeredApp.so for the crash() native method
    +            cmd.add("-Djava.library.path=" + System.getProperty("java.library.path"));
    +        }
     
             // Make sure we set correct classpath to run the app
             cmd.add("-cp");
    @@ -356,10 +374,17 @@ public void runApp(List vmArguments)
     
             cmd.add(this.getAppName());
             cmd.add(lockFileName);
    +        if (forceCrash) {
    +            cmd.add("forceCrash"); // Let the subprocess know to force a crash
    +        }
     
             printCommandLine(cmd);
     
             ProcessBuilder pb = new ProcessBuilder(cmd);
    +        if (forceCrash) {
    +            // If we are going to force a core dump, apply "ulimit -c unlimited" if we can.
    +            pb = CoreUtils.addCoreUlimitCommand(pb);
    +        }
             // ProcessBuilder.start can throw IOException
             appProcess = pb.start();
     
    @@ -493,19 +518,37 @@ public static boolean isLastModifiedWorking() {
         }
     
         /**
    -     * This part is the application it self
    +     * This part is the application itself. First arg is optional "forceCrash".
    +     * Following arg is the lock file name.
          */
         public static void main(String args[]) {
    +        boolean forceCrash = false;
     
    -        if (args.length != 1) {
    +        if (args.length == 0) {
                 System.err.println("Lock file name is not specified");
                 System.exit(7);
    +        } else if (args.length > 2) {
    +            System.err.println("Too many arguments specified: "  + args.length);
    +            System.exit(7);
    +        }
    +
    +        if (args.length == 2) {
    +            if (args[1].equals("forceCrash")) {
    +                forceCrash = true;
    +            } else {
    +                System.err.println("Invalid 1st argment: " + args[1]);
    +                System.exit(7);
    +            }
             }
     
             String theLockFileName = args[0];
             Path path = Paths.get(theLockFileName);
     
             try {
    +            if (forceCrash) {
    +                System.loadLibrary("LingeredApp"); // location of native crash() method
    +                crash();
    +            }
                 while (Files.exists(path)) {
                     // Touch the lock to indicate our readiness
                     setLastModified(theLockFileName, epoch());
    diff --git a/test/lib/jdk/test/lib/util/CoreUtils.java b/test/lib/jdk/test/lib/util/CoreUtils.java
    new file mode 100644
    index 00000000000..c008594bc9c
    --- /dev/null
    +++ b/test/lib/jdk/test/lib/util/CoreUtils.java
    @@ -0,0 +1,218 @@
    +/*
    + * Copyright (c) 2020, 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.
    + *
    + * 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 jdk.test.lib.util;
    +
    +import jdk.test.lib.Asserts;
    +import jdk.test.lib.Platform;
    +import jdk.test.lib.process.OutputAnalyzer;
    +import jdk.test.lib.process.ProcessTools;
    +
    +import jtreg.SkippedException;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.nio.file.Files;
    +import java.nio.file.Path;
    +import java.nio.file.Paths;
    +import java.util.Arrays;
    +import java.util.regex.Matcher;
    +import java.util.regex.Pattern;
    +import java.util.Scanner;
    +import java.util.zip.GZIPInputStream;
    +
    +public class CoreUtils {
    +
    +    private static final String RUN_SHELL_NO_LIMIT = "ulimit -c unlimited && ";
    +
    +    /**
    +     * Returns a {@code ulimit} command that will allow for an unlimited core file size
    +     * if the platform supports it.
    +     *
    +     * @return {@code String} for the ulimit command if supported by the platform,
    +     * otherwise {@code null}.
    +     */
    +    private static String getCoreUlimitCommand() {
    +        String result = null;
    +        try {
    +            OutputAnalyzer output = ProcessTools.executeProcess("sh", "-c", RUN_SHELL_NO_LIMIT + "ulimit -c");
    +            if (output.getExitValue() != 0) {
    +                result = null;
    +            } else if (!output.getStdout().contains("unlimited")) {
    +                result = null;
    +            } else {
    +                result = RUN_SHELL_NO_LIMIT; // success
    +            }
    +        } catch (Throwable t) {
    +            System.out.println("Exception in getCoreUlimitCommand(): " + t.toString());
    +            result = null;
    +        }
    +        System.out.println("Run test with ulimit -c: " +
    +                (result == null ? "default" : "unlimited"));
    +        return result;
    +    }
    +
    +    /**
    +     * Return a {@code ProcessBuilder} that has been prefixed with
    +     * a {@code ulimit} command to allow for an unlimited core file size.
    +     *
    +     * @param pb {@code ProcessBuilder} to prefix with the ulimit command
    +     * @return New {@code ProcessBuilder} with prefixed {@code ulimit} command if
    +     * supported. Otherwise the passed in {@code ProcessBuilder} is returned.
    +     */
    +    public static ProcessBuilder addCoreUlimitCommand(ProcessBuilder pb) {
    +        String cmd = ProcessTools.getCommandLine(pb);
    +        String ulimitCmd = getCoreUlimitCommand();
    +        if (ulimitCmd == null) {
    +            return pb;
    +        } else {
    +            if (Platform.isWindows()) {
    +                // In order to launch on Windows using "sh -c", we need to first
    +                // convert the path to use forward slashes and do some extra quoting.
    +                cmd = cmd.replace('\\', '/').replace(";", "\\;").replace("|", "\\|");
    +            }
    +            return new ProcessBuilder("sh", "-c", ulimitCmd + cmd);
    +        }
    +    }
    +
    +    /**
    +     * Find the path to the core file mentioned in the output and return its path.
    +     *
    +     * @param crashOutputString {@code String} to search in for the core file path
    +     * @return Location of core file if found in the output, otherwise {@code null}.
    +     */
    +    public static String getCoreFileLocation(String crashOutputString) throws IOException {
    +        unzipCores(new File("."));
    +
    +        // Find the core file
    +        String coreFileLocation = parseCoreFileLocationFromOutput(crashOutputString);
    +        if (coreFileLocation != null) {
    +            Asserts.assertGT(new File(coreFileLocation).length(), 0L, "Unexpected core size");
    +            System.out.println("Found core file: " + coreFileLocation);
    +            return coreFileLocation; // success!
    +        }
    +
    +        // See if we can figure out the likely reason the core file was not found.
    +        // Throw SkippedException if appropriate.
    +        if (Platform.isOSX()) {
    +            File coresDir = new File("/cores");
    +            if (!coresDir.isDirectory()) {
    +                throw new RuntimeException(coresDir + " is not a directory");
    +            }
    +            // The /cores directory is usually not writable on macOS 10.15
    +            if (!coresDir.canWrite()) {
    +                throw new SkippedException("Directory \"" + coresDir + "\" is not writable");
    +            }
    +        } else if (Platform.isLinux()) {
    +            // Check if a crash report tool is installed.
    +            File corePatternFile = new File(CORE_PATTERN_FILE_NAME);
    +            try (Scanner scanner = new Scanner(corePatternFile)) {
    +                while (scanner.hasNextLine()) {
    +                    String line = scanner.nextLine();
    +                    line = line.trim();
    +                    System.out.println(line);
    +                    if (line.startsWith("|")) {
    +                        System.out.println(
    +                                "\nThis system uses a crash report tool ($cat /proc/sys/kernel/core_pattern).\n" +
    +                                        "Core files might not be generated. Please reset /proc/sys/kernel/core_pattern\n" +
    +                                        "to enable core generation. Skipping this test.");
    +                        throw new SkippedException("This system uses a crash report tool");
    +                    }
    +                }
    +            }
    +        }
    +        throw new RuntimeException("Couldn't find core file location in: '" + crashOutputString + "'");
    +    }
    +
    +    private static final String CORE_PATTERN_FILE_NAME = "/proc/sys/kernel/core_pattern";
    +    private static final String LOCATION_STRING = "location: ";
    +
    +    private static String parseCoreFileLocationFromOutput(String crashOutputString) {
    +        System.out.println("crashOutputString = [" + crashOutputString + "]");
    +        if(crashOutputString == null || crashOutputString.equals("")) {
    +            return null;
    +        }
    +        // Find the line of output that contains LOCATION_STRING
    +        Asserts.assertTrue(crashOutputString.contains(LOCATION_STRING),
    +                "Output doesn't contain the location of core file.");
    +        String stringWithLocation = Arrays.stream(crashOutputString.split("\\r?\\n"))
    +                .filter(str -> str.contains(LOCATION_STRING))
    +                .findFirst()
    +                .get();
    +        stringWithLocation = stringWithLocation.substring(stringWithLocation
    +                .indexOf(LOCATION_STRING) + LOCATION_STRING.length());
    +        System.out.println("getCoreFileLocation found stringWithLocation = " + stringWithLocation);
    +
    +        // Find the core file name in the output.
    +        String coreWithPid;
    +        if (stringWithLocation.contains("or ") && !Platform.isWindows()) {
    +            Matcher m = Pattern.compile("or.* ([^ ]+[^\\)])\\)?").matcher(stringWithLocation);
    +            if (!m.find()) {
    +                throw new RuntimeException("Couldn't find path to core inside location string");
    +            }
    +            coreWithPid = m.group(1);
    +        } else {
    +            coreWithPid = stringWithLocation.trim();
    +        }
    +        if (new File(coreWithPid).exists()) {
    +            return coreWithPid;
    +        }
    +
    +        // Look for file named "core" in the cwd.
    +        String justCore = Paths.get("core").toString();
    +        if (new File(justCore).exists()) {
    +            return justCore;
    +        }
    +
    +        // Look for the core file name found in the output, but do so in the cwd.
    +        Path coreWithPidPath = Paths.get(coreWithPid);
    +        String justFile = coreWithPidPath.getFileName().toString();
    +        if (new File(justFile).exists()) {
    +            return justFile;
    +        }
    +
    +        // Look for file named "core" in the path to the core file found in the output.
    +        Path parent = coreWithPidPath.getParent();
    +        if (parent != null) {
    +            String coreWithoutPid = parent.resolve("core").toString();
    +            if (new File(coreWithoutPid).exists()) {
    +                return coreWithoutPid;
    +            }
    +        }
    +        return null;
    +    }
    +
    +    private static void unzipCores(File dir) {
    +        File[] gzCores = dir.listFiles((directory, name) -> name.matches("core(\\.\\d+)?\\.gz"));
    +        for (File gzCore : gzCores) {
    +            String coreFileName = gzCore.getName().replace(".gz", "");
    +            System.out.println("Unzipping core into " + coreFileName);
    +            try (GZIPInputStream gzis = new GZIPInputStream(Files.newInputStream(gzCore.toPath()))) {
    +                Files.copy(gzis, Paths.get(coreFileName));
    +            } catch (IOException e) {
    +                throw new SkippedException("Not able to unzip file: " + gzCore.getAbsolutePath(), e);
    +            }
    +        }
    +    }
    +
    +}
    \ No newline at end of file
    
    From 50d0503294ceb77289786532c82a887f12fba425 Mon Sep 17 00:00:00 2001
    From: Goetz Lindenmaier 
    Date: Thu, 21 Mar 2024 12:30:08 +0000
    Subject: [PATCH 047/149] 8314495: Update to use jtreg 7.3.1
    
    Reviewed-by: shade, lucy
    Backport-of: 75e14419d29c1dc98bd040490e93ae8f6eee4e43
    ---
     make/autoconf/lib-tests.m4    | 2 +-
     make/conf/github-actions.conf | 2 +-
     make/conf/jib-profiles.js     | 4 ++--
     test/hotspot/jtreg/TEST.ROOT  | 4 ++--
     test/jaxp/TEST.ROOT           | 2 +-
     test/jdk/TEST.ROOT            | 2 +-
     test/langtools/TEST.ROOT      | 2 +-
     7 files changed, 9 insertions(+), 9 deletions(-)
    
    diff --git a/make/autoconf/lib-tests.m4 b/make/autoconf/lib-tests.m4
    index 104168a14f9..5e7fab4a8aa 100644
    --- a/make/autoconf/lib-tests.m4
    +++ b/make/autoconf/lib-tests.m4
    @@ -28,7 +28,7 @@
     ################################################################################
     
     # Minimum supported version
    -JTREG_MINIMUM_VERSION=6.1
    +JTREG_MINIMUM_VERSION=7.3.1
     
     ###############################################################################
     #
    diff --git a/make/conf/github-actions.conf b/make/conf/github-actions.conf
    index 40dd3b57d6a..06c0326dda3 100644
    --- a/make/conf/github-actions.conf
    +++ b/make/conf/github-actions.conf
    @@ -26,7 +26,7 @@
     # Versions and download locations for dependencies used by GitHub Actions (GHA)
     
     GTEST_VERSION=1.8.1
    -JTREG_VERSION=6.1+3
    +JTREG_VERSION=7.3.1+1
     
     LINUX_X64_BOOT_JDK_EXT=tar.gz
     LINUX_X64_BOOT_JDK_URL=https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.18%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.18_10.tar.gz
    diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js
    index 6bc10c0145d..3b7194e4253 100644
    --- a/make/conf/jib-profiles.js
    +++ b/make/conf/jib-profiles.js
    @@ -941,9 +941,9 @@ var getJibProfilesDependencies = function (input, common) {
             jtreg: {
                 server: "jpg",
                 product: "jtreg",
    -            version: "6",
    +            version: "7.3.1",
                 build_number: "1",
    -            file: "bundles/jtreg-6+1.zip",
    +            file: "bundles/jtreg-7.3.1+1.zip",
                 environment_name: "JT_HOME",
                 environment_path: input.get("jtreg", "install_path") + "/jtreg/bin"
             },
    diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT
    index 2c8021dd76d..0dddd79449b 100644
    --- a/test/hotspot/jtreg/TEST.ROOT
    +++ b/test/hotspot/jtreg/TEST.ROOT
    @@ -1,5 +1,5 @@
     #
    -# Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
    +# Copyright (c) 2005, 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
    @@ -75,7 +75,7 @@ requires.properties= \
         docker.support
     
     # Minimum jtreg version
    -requiredVersion=6+1
    +requiredVersion=7.3.1+1
     
     # Path to libraries in the topmost test directory. This is needed so @library
     # does not need ../../../ notation to reach them
    diff --git a/test/jaxp/TEST.ROOT b/test/jaxp/TEST.ROOT
    index 6bda60fa441..a44ad3a7c01 100644
    --- a/test/jaxp/TEST.ROOT
    +++ b/test/jaxp/TEST.ROOT
    @@ -23,7 +23,7 @@ modules=java.xml
     groups=TEST.groups
     
     # Minimum jtreg version
    -requiredVersion=6+1
    +requiredVersion=7.3.1+1
     
     # Path to libraries in the topmost test directory. This is needed so @library
     # does not need ../../ notation to reach them
    diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT
    index 2b8219940a5..3965ad022a4 100644
    --- a/test/jdk/TEST.ROOT
    +++ b/test/jdk/TEST.ROOT
    @@ -62,7 +62,7 @@ requires.properties= \
         release.implementor
     
     # Minimum jtreg version
    -requiredVersion=6+1
    +requiredVersion=7.3.1+1
     
     # Path to libraries in the topmost test directory. This is needed so @library
     # does not need ../../ notation to reach them
    diff --git a/test/langtools/TEST.ROOT b/test/langtools/TEST.ROOT
    index 3348f3711bc..da089df72a9 100644
    --- a/test/langtools/TEST.ROOT
    +++ b/test/langtools/TEST.ROOT
    @@ -15,7 +15,7 @@ keys=intermittent randomness
     groups=TEST.groups
     
     # Minimum jtreg version
    -requiredVersion=6+1
    +requiredVersion=7.3.1+1
     
     # Use new module options
     useNewOptions=true
    
    From 12a28633d28e08884fafeb654bbc22af166f3651 Mon Sep 17 00:00:00 2001
    From: Andrew Lu 
    Date: Fri, 22 Mar 2024 02:12:04 +0000
    Subject: [PATCH 048/149] 8315663: Open source misc awt tests
    
    Backport-of: a36f5a54ab4871739f2ccbabb684942fc3cadf20
    ---
     .../awt/Icon/SetIconImageExceptionTest.java   |  59 +++++
     test/jdk/sun/awt/PaletteTester.java           | 204 ++++++++++++++++++
     test/jdk/sun/awt/duke.gif                     | Bin 0 -> 1929 bytes
     3 files changed, 263 insertions(+)
     create mode 100644 test/jdk/java/awt/Icon/SetIconImageExceptionTest.java
     create mode 100644 test/jdk/sun/awt/PaletteTester.java
     create mode 100644 test/jdk/sun/awt/duke.gif
    
    diff --git a/test/jdk/java/awt/Icon/SetIconImageExceptionTest.java b/test/jdk/java/awt/Icon/SetIconImageExceptionTest.java
    new file mode 100644
    index 00000000000..6af6974a035
    --- /dev/null
    +++ b/test/jdk/java/awt/Icon/SetIconImageExceptionTest.java
    @@ -0,0 +1,59 @@
    +/*
    + * Copyright (c) 2001, 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.
    + *
    + * 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.
    + */
    +
    +/*
    + * @test
    + * @bug 4475478
    + * @summary Tests that there is no NullPointerException
    +            thrown when we try to set Frame's icon
    +            which has null data
    + * @key headful
    + * @run main SetIconImageExceptionTest
    +*/
    +import java.awt.EventQueue;
    +import java.awt.Frame;
    +import java.awt.Image;
    +import java.awt.Toolkit;
    +
    +public class SetIconImageExceptionTest {
    +    static Frame f;
    +
    +    public static void main(String[] args) throws Exception {
    +        EventQueue.invokeAndWait(() -> {
    +            try {
    +                // Test with non-existent image to test with null data
    +                //  not throwing NPE
    +                Image icon = Toolkit.getDefaultToolkit().getImage("notexistent.gif");
    +                f = new Frame("Frame with icon");
    +                f.setIconImage(icon);
    +                f.setVisible(true);
    +            } finally {
    +                if (f != null) {
    +                    f.dispose();
    +                }
    +            }
    +        });
    +    }
    +
    + }// class SetIconImageExceptionTest
    +
    diff --git a/test/jdk/sun/awt/PaletteTester.java b/test/jdk/sun/awt/PaletteTester.java
    new file mode 100644
    index 00000000000..7fb0d6b26ad
    --- /dev/null
    +++ b/test/jdk/sun/awt/PaletteTester.java
    @@ -0,0 +1,204 @@
    +/*
    + * Copyright (c) 2001, 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.
    + *
    + * 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.
    + */
    +
    +/*
    + * @test
    + * @bug 4366799
    + * @key headful
    + * @requires (os.family == "windows")
    + * @library /java/awt/regtesthelpers
    + * @build PassFailJFrame
    + * @summary verifies that Windows applications react to palette
    + * changes in 8-bit mode correctly.
    + * @run main/manual PaletteTester
    +*/
    +
    +import java.awt.Color;
    +import java.awt.Dimension;
    +import java.awt.EventQueue;
    +import java.awt.Graphics;
    +import java.awt.Image;
    +import java.awt.Frame;
    +import java.awt.event.WindowAdapter;
    +import java.awt.event.WindowEvent;
    +import java.awt.image.VolatileImage;
    +import javax.swing.ImageIcon;
    +import javax.swing.JPanel;
    +import java.io.File;
    +
    +public class PaletteTester {
    +
    +    static VImageColors demo;
    +
    +    private static final String INSTRUCTIONS = """
    +        This test should be run on any Windows platform in 8-bit
    +        (256 color) display mode only. To check for errors, run a browser
    +        application (Firefox or Internet Explorer) at the same time
    +        and switch between this test and the browser (by clicking on the
    +        title bars).
    +
    +        The three panels in this test should look roughly the same (there
    +        may be some dithering differences if you switch display modes
    +        during the test, but the overall look should be the same.  If
    +        completely different colors are being used (either for the orange
    +        background fill, the text, the image, or the rectangles), then the
    +        test has failed.
    +        """;
    +
    +    private static void init() {
    +
    +        int width = 300, height = 300;
    +
    +        demo = new VImageColors();
    +        Frame f = new Frame("PaletteTester");
    +        f.addWindowListener(new WindowAdapter() {
    +            public void windowClosing(WindowEvent e) {}
    +            public void windowDeiconified(WindowEvent e) { demo.start(); }
    +            public void windowIconified(WindowEvent e) { demo.stop(); }
    +        });
    +        f.add(demo);
    +        f.setSize(new Dimension(width, height));
    +        f.setLocationRelativeTo(null);
    +
    +        PassFailJFrame.addTestWindow(f);
    +        PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL);
    +        f.setVisible(true);
    +
    +        demo.start();
    +
    +    }//End  init()
    +
    +    public static void main( String args[] ) throws Exception {
    +
    +        PassFailJFrame passFailJFrame = new PassFailJFrame.Builder()
    +                                        .title("PaletteTester Instructions")
    +                                        .instructions(INSTRUCTIONS)
    +                                        .testTimeOut(5)
    +                                        .rows(15)
    +                                        .columns(40)
    +                                        .screenCapture()
    +                                        .build();
    +
    +        EventQueue.invokeAndWait(PaletteTester::init);
    +
    +
    +        try {
    +            passFailJFrame.awaitAndCheck();
    +        } finally {
    +            demo.stop();
    +        }
    +    }//main
    +}
    +
    +//************ Begin classes defined for the test ****************
    +
    +class VImageColors extends JPanel implements Runnable {
    +
    +    VolatileImage vImage;
    +    Image bImage;
    +    private static int width = 300, height = 300;
    +    private Thread thread;
    +    Color fillColor = new Color(240, 188, 136);
    +    Color textColor = new Color(40, 18, 97);
    +    Color rectColor = new Color(0, 150, 0);
    +    File f = new File(System.getProperty("test.src", "."), "duke.gif");
    +    Image duke = new ImageIcon(f.toString()).getImage();
    +
    +    public void initOffscreen() {
    +        vImage = this.createVolatileImage(getWidth()/3, getHeight());
    +        bImage = this.createImage(getWidth()/3, getHeight());
    +    }
    +
    +    public void paint(Graphics g) {
    +        int width = getWidth();
    +        int height = getHeight();
    +
    +        if (vImage == null) {
    +            initOffscreen();
    +        }
    +
    +        // Render the left panel via VolatileImage
    +        do {
    +            if (
    +                vImage.validate(getGraphicsConfiguration()) ==
    +                VolatileImage.IMAGE_INCOMPATIBLE)
    +            {
    +                vImage = createVolatileImage(width/3, height);
    +            }
    +            Graphics vg = vImage.createGraphics();
    +            vg.setColor(fillColor);
    +            vg.fillRect(0, 0, width/3, height);
    +            vg.drawImage(duke, 0, 0, null);
    +            vg.setColor(textColor);
    +            vg.drawString("Vol Image", 5, height-1);
    +            vg.setColor(rectColor);
    +            vg.drawRect(0, 0, width/3-1, height-1);
    +            vg.dispose();
    +            g.drawImage(vImage, 0, 0, width/3, height, null);
    +        } while (vImage.contentsLost());
    +
    +        // Render the middle panel via BufferedImage
    +        Graphics bg = bImage.getGraphics();
    +        bg.setColor(fillColor);
    +        bg.fillRect(0, 0, width/3, height);
    +        bg.drawImage(duke, 0, 0, null);
    +        bg.setColor(textColor);
    +        bg.drawString("Buff Image", 5, height-1);
    +        bg.setColor(rectColor);
    +        bg.drawRect(0, 0, width/3-1, height-1);
    +        bg.dispose();
    +        g.drawImage(bImage, width/3, 0, width/3, height, null);
    +
    +        // Render the right panel directly to the screen
    +        g.setColor(fillColor);
    +        g.fillRect(2*(width/3), 0, width/3, height);
    +        g.drawImage(duke, 2*(width/3), 0, null);
    +        g.setColor(textColor);
    +        g.drawString("Screen", 2*(width/3) + 5, height-1);
    +        g.setColor(rectColor);
    +        g.drawRect(2*(width/3), 0, width/3-1, height-1);
    +
    +    }
    +
    +    public void start() {
    +        thread = new Thread(this);
    +        thread.setPriority(Thread.MIN_PRIORITY);
    +        thread.start();
    +    }
    +
    +    public synchronized void stop() {
    +        thread = null;
    +    }
    +
    +    public void run() {
    +        Thread me = Thread.currentThread();
    +        while (thread == me) {
    +            try {
    +                thread.sleep(100);
    +            } catch (InterruptedException e) { break; }
    +        }
    +        thread = null;
    +    }
    +}
    +
    +//************** End classes defined for the test *******************
    diff --git a/test/jdk/sun/awt/duke.gif b/test/jdk/sun/awt/duke.gif
    new file mode 100644
    index 0000000000000000000000000000000000000000..ed32e0ff79b05c07b82863ce6fb07fa9898adaa2
    GIT binary patch
    literal 1929
    zcmWlYe^AtB8pi`HvM4_?{J2I$8$dLc1#@!R2zwgXMWdj^k;9xr+bDW&4{JlE8WpDj
    z7F-cwwK{H<)?L&#SJz$!;hJ{%BY2FYf)Wp^xl?aq!5Xcdi$c#hV~>m9_n-Hl=Xsy+
    z=li^?*Q~;pZ+R1N1J40KRkeWM7ew3~jLM24A{CM-A}~TzqzYpq&od0GC=z71!w_=b
    z-==B0rt2t*nA}((5YSLs6a*Z@X__WqiSjTW6oLo{5km&|K1mGAimYjhs#wwZtvV8SV~7LCFpgub+-TTAk%UQb0dE_cj+pc?!+0o?qG$?%
    zVFD)%!w7Z;g)ndE8Uk6Aky=+kLaUQ{UW`XS?Nn*s@SQ{VmFgGdkV{&&98EcEQ5hjc@H$`e)fX
    zj@&GdchxpMUo|-A^M4iBP3(#Ib53Ap?5{nGT7SBA_V!o!TTzL5R~FUWe)4X?@iTd8
    z1;TcF^rQLj?4p0uy?@ikb2eUSXdHVa_jIn=@W%a<6~57D>am6&Z!{lzc=@ZbuGB8`
    zpU38H8d~@82Da!+qdYG5ls&Cx?~|oPMnbqTHMw%I*KlV~?fc{rSwe29?Om}fsknG#
    z@n5IwY=4Mx>>0WJLG>=yJX^WbHA30iQ$H!X)3<4K
    zBe1|sf3NKKTS;)mg{$k(2eDJG^u5=&x{@M!V>EWgzRA((>}?o{WQBehp1mIHU!BGG
    zYz5_6B(+KIVdCVoum2ItM&gXZd+SB^vQTN=a
    zeYbbah=i-xCho2{4Pazv_i%2mH`EkM{r8XYDLbdY@(a7Ud}$%!$QrTN_DqwNXA9~g
    zTGKxKyfto7NDp;5A3O5zgb(hyxjN@OAG!(zy^*Ug4!yjF=Y*8aHA@ovB1({&a4;sR
    zTf1CVC{>Pgy`m$lG;P1$pC_6F7u%iP+qz0q4{lXT`i9g-ThiYgO^GXC`f?JNo*|@p
    zr{b%U-tSKw99q0|YJa9{Va?`H{IaNICo>p5lGEY*+IDR4bfIUwq~CTRuC_mGWA%~W
    zea{@eKJ(Iq^7MvdsPsR%&vt$@4i&s?bPptz#y#!FcRZEaMS0WFTyXMCUEfsNxnJ_9
    zPwpt`Er4O>``2G{7=4r1GCSTO8#0xw+{<^L4X(K8y1wKj72KLrYD}Y7SJuY7y==wf
    z;UkI5?(v?h+4r;vR{P*U`ul~=D@U7K5$eV8c!%rX-38vE>azU80UrhFXCv#d`(ylZS4+i2a^vI91MTIxCx%9gd2&N&D9RC&xcpx8#f=GZv%9;F
    z#?CEVT%UV$nk;L%RJA+d=f8ZB@U*Xz-TZbG?HKKT(VJZMBH!)$#qRuwbFc%Aljqha
    zoNBs8od~V$_^vux0ZSk!iP!hI($t35SxY8`FV{pxCjpU}Ova2VIg1&>V)CvvMb_
    Date: Mon, 25 Mar 2024 07:25:53 +0000
    Subject: [PATCH 049/149] 8312383: Log X509ExtendedKeyManager implementation
     class name in TLS/SSL connection
    
    Reviewed-by: lucy
    Backport-of: bdd1aebea379b63ae405827074530ef8e8a7c239
    ---
     .../classes/sun/security/ssl/X509Authentication.java   | 10 +++++++++-
     1 file changed, 9 insertions(+), 1 deletion(-)
    
    diff --git a/src/java.base/share/classes/sun/security/ssl/X509Authentication.java b/src/java.base/share/classes/sun/security/ssl/X509Authentication.java
    index 32d3b0595e9..55cb7d69fe3 100644
    --- a/src/java.base/share/classes/sun/security/ssl/X509Authentication.java
    +++ b/src/java.base/share/classes/sun/security/ssl/X509Authentication.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2018, 2024, 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
    @@ -226,6 +226,10 @@ public SSLPossession createPossession(HandshakeContext context) {
             private SSLPossession createClientPossession(
                     ClientHandshakeContext chc, String keyType) {
                 X509ExtendedKeyManager km = chc.sslContext.getX509KeyManager();
    +            if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
    +                SSLLogger.finest("X509KeyManager class: " +
    +                        km.getClass().getName());
    +            }
                 String clientAlias = null;
                 if (chc.conContext.transport instanceof SSLSocketImpl) {
                     clientAlias = km.chooseClientAlias(
    @@ -283,6 +287,10 @@ private SSLPossession createClientPossession(
             private SSLPossession createServerPossession(
                     ServerHandshakeContext shc, String keyType) {
                 X509ExtendedKeyManager km = shc.sslContext.getX509KeyManager();
    +            if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
    +                SSLLogger.finest("X509KeyManager class: " +
    +                        km.getClass().getName());
    +            }
                 String serverAlias = null;
                 if (shc.conContext.transport instanceof SSLSocketImpl) {
                     serverAlias = km.chooseServerAlias(keyType,
    
    From 8c18317ef89886ffd7b917c89ab02e047b940c20 Mon Sep 17 00:00:00 2001
    From: Andrew Lu 
    Date: Mon, 25 Mar 2024 07:40:08 +0000
    Subject: [PATCH 050/149] 8270199: Most SA tests are skipped on macosx-aarch64
     because all executables are signed 8241951: SA core file tests failed to find
     core file for signed binaries on OSX 10.15
    
    Reviewed-by: lucy
    Backport-of: 16e0ad0ad088af3ba1c9903ed8df60799a1ba651
    ---
     test/hotspot/jtreg/ProblemList.txt            |  6 +-
     ...stMutuallyExclusivePlatformPredicates.java |  4 +-
     test/lib/jdk/test/lib/Platform.java           | 66 +++++++++++--------
     test/lib/jdk/test/lib/SA/SATestUtils.java     |  6 +-
     test/lib/jdk/test/lib/util/CoreUtils.java     | 10 ++-
     5 files changed, 54 insertions(+), 38 deletions(-)
    
    diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt
    index 73b6f649078..c6db3fc6786 100644
    --- a/test/hotspot/jtreg/ProblemList.txt
    +++ b/test/hotspot/jtreg/ProblemList.txt
    @@ -174,7 +174,7 @@ serviceability/sa/ClhsdbJdis.java 8193639 solaris-all
     serviceability/sa/ClhsdbJhisto.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64
     serviceability/sa/ClhsdbJstack.java 8193639 solaris-all
     serviceability/sa/ClhsdbLongConstant.java 8193639 solaris-all
    -serviceability/sa/ClhsdbPmap.java 8294316,8193639,8211767,8267433 solaris-all,linux-ppc64le,linux-ppc64,macosx-x64
    +serviceability/sa/ClhsdbPmap.java 8269982,8294316,8193639,8211767,8267433 solaris-all,linux-ppc64le,linux-ppc64,macosx-aarch64,macosx-x64
     serviceability/sa/ClhsdbPrintAll.java 8193639 solaris-all
     serviceability/sa/ClhsdbPrintAs.java 8193639 solaris-all
     serviceability/sa/ClhsdbPrintStatics.java 8193639 solaris-all
    @@ -202,8 +202,8 @@ serviceability/sa/TestInstanceKlassSize.java 8193639 solaris-all
     serviceability/sa/TestInstanceKlassSizeForInterface.java 8193639 solaris-all
     serviceability/sa/TestIntConstant.java 8193639,8211767 solaris-all,linux-ppc64le,linux-ppc64
     serviceability/sa/TestJhsdbJstackLock.java 8193639 solaris-all
    -serviceability/sa/TestJmapCore.java 8294316,8193639,8267433 solaris-all,macosx-x64
    -serviceability/sa/TestJmapCoreMetaspace.java 8294316,8193639,8267433 solaris-all,macosx-x64
    +serviceability/sa/TestJmapCore.java 8269982,8294316,8193639,8267433 solaris-all,macosx-aarch64,macosx-x64
    +serviceability/sa/TestJmapCoreMetaspace.java 8269982,8294316,8193639,8267433 solaris-all,macosx-aarch64,macosx-x64
     serviceability/sa/TestPrintMdo.java 8193639 solaris-all
     serviceability/sa/TestRevPtrsForInvokeDynamic.java 8191270 generic-all
     serviceability/sa/TestType.java 8193639 solaris-all
    diff --git a/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java b/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java
    index 77458554b76..042d10ad57f 100644
    --- a/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java
    +++ b/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2014, 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
    @@ -52,7 +52,7 @@ private static enum MethodGroup {
             MODE("isInt", "isMixed", "isComp"),
             IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isSlowDebugBuild",
                     "hasSA", "isRoot", "isTieredSupported", "areCustomLoadersSupportedForCDS",
    -                "isSignedOSX");
    +                "isHardenedOSX");
     
             public final List methodNames;
     
    diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java
    index 5b3f1889cb7..620ddf781bf 100644
    --- a/test/lib/jdk/test/lib/Platform.java
    +++ b/test/lib/jdk/test/lib/Platform.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2013, 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
    @@ -23,8 +23,10 @@
     
     package jdk.test.lib;
     
    +import java.io.BufferedReader;
     import java.io.FileNotFoundException;
     import java.io.IOException;
    +import java.io.InputStreamReader;
     import java.nio.file.Files;
     import java.nio.file.Path;
     import java.nio.file.Paths;
    @@ -254,13 +256,13 @@ public static boolean hasSA() {
         }
     
         /**
    -     * Return true if the test JDK is signed, otherwise false. Only valid on OSX.
    +     * Return true if the test JDK is hardened, otherwise false. Only valid on OSX.
          */
    -    public static boolean isSignedOSX() throws IOException {
    -        // We only care about signed binaries for 10.14 and later (actually 10.14.5, but
    +    public static boolean isHardenedOSX() throws IOException {
    +        // We only care about hardened binaries for 10.14 and later (actually 10.14.5, but
             // for simplicity we'll also include earlier 10.14 versions).
             if (getOsVersionMajor() == 10 && getOsVersionMinor() < 14) {
    -            return false; // assume not signed
    +            return false; // assume not hardened
             }
     
             // Find the path to the java binary.
    @@ -272,38 +274,44 @@ public static boolean isSignedOSX() throws IOException {
             }
     
             // Run codesign on the java binary.
    -        ProcessBuilder pb = new ProcessBuilder("codesign", "-d", "-v", javaFileName);
    -        pb.redirectError(ProcessBuilder.Redirect.DISCARD);
    -        pb.redirectOutput(ProcessBuilder.Redirect.DISCARD);
    +        ProcessBuilder pb = new ProcessBuilder("codesign", "--display", "--verbose", javaFileName);
    +        pb.redirectErrorStream(true); // redirect stderr to stdout
             Process codesignProcess = pb.start();
    +        BufferedReader is = new BufferedReader(new InputStreamReader(codesignProcess.getInputStream()));
    +        String line;
    +        boolean isHardened = false;
    +        boolean hardenedStatusConfirmed = false; // set true when we confirm whether or not hardened
    +        while ((line = is.readLine()) != null) {
    +            System.out.println("STDOUT: " + line);
    +            if (line.indexOf("flags=0x10000(runtime)") != -1 ) {
    +                hardenedStatusConfirmed = true;
    +                isHardened = true;
    +                System.out.println("Target JDK is hardened. Some tests may be skipped.");
    +            } else if (line.indexOf("flags=0x20002(adhoc,linker-signed)") != -1 ) {
    +                hardenedStatusConfirmed = true;
    +                isHardened = false;
    +                System.out.println("Target JDK is adhoc signed, but not hardened.");
    +            } else if (line.indexOf("code object is not signed at all") != -1) {
    +                hardenedStatusConfirmed = true;
    +                isHardened = false;
    +                System.out.println("Target JDK is not signed, therefore not hardened.");
    +            }
    +        }
    +        if (!hardenedStatusConfirmed) {
    +            System.out.println("Could not confirm if TargetJDK is hardened. Assuming not hardened.");
    +            isHardened = false;
    +        }
    +
             try {
                 if (codesignProcess.waitFor(10, TimeUnit.SECONDS) == false) {
    -                System.err.println("Timed out waiting for the codesign process to complete. Assuming not signed.");
    +                System.err.println("Timed out waiting for the codesign process to complete. Assuming not hardened.");
                     codesignProcess.destroyForcibly();
    -                return false; // assume not signed
    +                return false; // assume not hardened
                 }
             } catch (InterruptedException e) {
                 throw new RuntimeException(e);
             }
    -
    -        // Check codesign result to see if java binary is signed. Here are the
    -        // exit code meanings:
    -        //    0: signed
    -        //    1: not signed
    -        //    2: invalid arguments
    -        //    3: only has meaning with the -R argument.
    -        // So we should always get 0 or 1 as an exit value.
    -        if (codesignProcess.exitValue() == 0) {
    -            System.out.println("Target JDK is signed. Some tests may be skipped.");
    -            return true; // signed
    -        } else if (codesignProcess.exitValue() == 1) {
    -            System.out.println("Target JDK is not signed.");
    -            return false; // not signed
    -        } else {
    -            System.err.println("Executing codesign failed. Assuming unsigned: " +
    -                               codesignProcess.exitValue());
    -            return false; // not signed
    -        }
    +        return isHardened;
         }
     
         private static boolean isArch(String archnameRE) {
    diff --git a/test/lib/jdk/test/lib/SA/SATestUtils.java b/test/lib/jdk/test/lib/SA/SATestUtils.java
    index 26a41e8b904..d578c2ee57c 100644
    --- a/test/lib/jdk/test/lib/SA/SATestUtils.java
    +++ b/test/lib/jdk/test/lib/SA/SATestUtils.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2019, 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
    @@ -63,8 +63,8 @@ public static void skipIfCannotAttach() {
                         throw new SkippedException("SA Attach not expected to work. Ptrace attach not supported.");
                     }
                 } else if (Platform.isOSX()) {
    -                if (Platform.isSignedOSX()) {
    -                    throw new SkippedException("SA Attach not expected to work. JDK is signed.");
    +                if (Platform.isHardenedOSX()) {
    +                    throw new SkippedException("SA Attach not expected to work. JDK is hardened.");
                     }
                     if (!Platform.isRoot() && !canAddPrivileges()) {
                         throw new SkippedException("SA Attach not expected to work. Insufficient privileges (not root and can't use sudo).");
    diff --git a/test/lib/jdk/test/lib/util/CoreUtils.java b/test/lib/jdk/test/lib/util/CoreUtils.java
    index c008594bc9c..6675c30973c 100644
    --- a/test/lib/jdk/test/lib/util/CoreUtils.java
    +++ b/test/lib/jdk/test/lib/util/CoreUtils.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2020, 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
    @@ -123,6 +123,14 @@ public static String getCoreFileLocation(String crashOutputString) throws IOExce
                 if (!coresDir.canWrite()) {
                     throw new SkippedException("Directory \"" + coresDir + "\" is not writable");
                 }
    +            if (Platform.isHardenedOSX()) {
    +                if (Platform.getOsVersionMajor() > 10 ||
    +                        (Platform.getOsVersionMajor() == 10 && Platform.getOsVersionMinor() >= 15))
    +                {
    +                    // We can't generate cores files with hardened binaries on OSX 10.15 and later.
    +                    throw new SkippedException("Cannot produce core file with hardened binary on OSX 10.15 and later");
    +                }
    +            }
             } else if (Platform.isLinux()) {
                 // Check if a crash report tool is installed.
                 File corePatternFile = new File(CORE_PATTERN_FILE_NAME);
    
    From f8225a424f763aaead44c98c2f51a9d3a009032e Mon Sep 17 00:00:00 2001
    From: Andrew Lu 
    Date: Mon, 25 Mar 2024 08:46:24 +0000
    Subject: [PATCH 051/149] 8313206: PKCS11 tests silently skip execution
    
    Reviewed-by: lucy
    Backport-of: 7c4aaec0dc74badb8363c10d2a10a29e85ceb246
    ---
     .../sun/security/pkcs11/KeyStore/Basic.java   |   8 +-
     .../security/pkcs11/KeyStore/ClientAuth.java  |  10 +-
     .../pkcs11/KeyStore/SecretKeysBasic.java      |  10 +-
     test/jdk/sun/security/pkcs11/PKCS11Test.java  | 375 ++++++++++--------
     .../pkcs11/Provider/ConfigQuotedString.java   |  10 +-
     .../sun/security/pkcs11/Provider/Login.java   |  10 +-
     .../pkcs11/Provider/MultipleLogins.sh         |   3 +-
     test/jdk/sun/security/pkcs11/SecmodTest.java  |  12 +-
     .../security/pkcs11/SecureRandom/Basic.java   |   2 +-
     9 files changed, 258 insertions(+), 182 deletions(-)
    
    diff --git a/test/jdk/sun/security/pkcs11/KeyStore/Basic.java b/test/jdk/sun/security/pkcs11/KeyStore/Basic.java
    index 56755e07103..f63419b97b1 100644
    --- a/test/jdk/sun/security/pkcs11/KeyStore/Basic.java
    +++ b/test/jdk/sun/security/pkcs11/KeyStore/Basic.java
    @@ -58,6 +58,8 @@
     
     import com.sun.security.auth.module.*;
     import com.sun.security.auth.callback.*;
    +import jtreg.SkippedException;
    +import org.testng.SkipException;
     import org.testng.annotations.BeforeClass;
     import org.testng.annotations.Test;
     
    @@ -113,7 +115,11 @@ public void setUp() throws Exception {
         @Test
         public void testBasic() throws Exception {
             String[] args = {"sm", "Basic.policy"};
    -        main(new Basic(), args);
    +        try {
    +            main(new Basic(), args);
    +        } catch (SkippedException se) {
    +            throw new SkipException("One or more tests are skipped");
    +        }
         }
     
         private static class FooEntry implements KeyStore.Entry { }
    diff --git a/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java b/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java
    index 482624f06cb..1af1258d173 100644
    --- a/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java
    +++ b/test/jdk/sun/security/pkcs11/KeyStore/ClientAuth.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 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,8 @@
      * @run testng/othervm ClientAuth
      */
     
    +import jtreg.SkippedException;
    +import org.testng.SkipException;
     import org.testng.annotations.BeforeClass;
     import org.testng.annotations.Test;
     
    @@ -119,7 +121,11 @@ public void testClientAuthTLSv12AndCipherSuite() throws Exception {
         private void runTest(String[] args) throws Exception {
             System.out.println("Running with args: " + Arrays.toString(args));
             parseArguments(args);
    -        main(new ClientAuth());
    +        try {
    +            main(new ClientAuth());
    +        } catch (SkippedException se) {
    +            throw new SkipException("One or more tests are skipped");
    +        }
         }
     
         /*
    diff --git a/test/jdk/sun/security/pkcs11/KeyStore/SecretKeysBasic.java b/test/jdk/sun/security/pkcs11/KeyStore/SecretKeysBasic.java
    index 741a38995ae..4d876604c01 100644
    --- a/test/jdk/sun/security/pkcs11/KeyStore/SecretKeysBasic.java
    +++ b/test/jdk/sun/security/pkcs11/KeyStore/SecretKeysBasic.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2008, 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
    @@ -26,6 +26,8 @@
      * @library /test/lib ..
      * @run testng/othervm SecretKeysBasic
      */
    +import jtreg.SkippedException;
    +import org.testng.SkipException;
     import org.testng.annotations.BeforeClass;
     import org.testng.annotations.Test;
     
    @@ -62,7 +64,11 @@ public void setUp() throws Exception {
     
         @Test
         public void testBasic() throws Exception {
    -        main(new SecretKeysBasic());
    +        try {
    +            main(new SecretKeysBasic());
    +        } catch (SkippedException se) {
    +            throw new SkipException("One or more tests are skipped");
    +        }
         }
     
         public void main(Provider p) throws Exception {
    diff --git a/test/jdk/sun/security/pkcs11/PKCS11Test.java b/test/jdk/sun/security/pkcs11/PKCS11Test.java
    index 9f0d9287589..ca5ed02db7e 100644
    --- a/test/jdk/sun/security/pkcs11/PKCS11Test.java
    +++ b/test/jdk/sun/security/pkcs11/PKCS11Test.java
    @@ -61,25 +61,17 @@
     import jdk.test.lib.artifacts.Artifact;
     import jdk.test.lib.artifacts.ArtifactResolver;
     import jdk.test.lib.artifacts.ArtifactResolverException;
    +import jtreg.SkippedException;
     
     public abstract class PKCS11Test {
     
    -    private boolean enableSM = false;
    -
         static final Properties props = System.getProperties();
    -
         static final String PKCS11 = "PKCS11";
    -
         // directory of the test source
         static final String BASE = System.getProperty("test.src", ".");
    -
         static final String TEST_CLASSES = System.getProperty("test.classes", ".");
    -
         static final char SEP = File.separatorChar;
     
    -    private static final String DEFAULT_POLICY =
    -            BASE + SEP + ".." + SEP + "policy";
    -
         // Version of the NSS artifact. This coincides with the version of
         // the NSS version
         private static final String NSS_BUNDLE_VERSION = "3.91";
    @@ -87,6 +79,25 @@ public abstract class PKCS11Test {
     
         // directory corresponding to BASE in the /closed hierarchy
         static final String CLOSED_BASE;
    +    private static final String DEFAULT_POLICY = BASE + SEP + ".." + SEP + "policy";
    +    private static final String PKCS11_REL_PATH = "sun/security/pkcs11";
    +    private static final char[] HEX_DIGITS = "0123456789abcdef".toCharArray();
    +
    +    static double nss_version = -1;
    +    static ECCState nss_ecc_status = ECCState.Basic;
    +
    +    // The NSS library we need to search for in getNSSLibDir()
    +    // Default is "libsoftokn3.so", listed as "softokn3"
    +    // The other is "libnss3.so", listed as "nss3".
    +    static String nss_library = "softokn3";
    +
    +    // NSS versions of each library.  It is simpler to keep nss_version
    +    // for quick checking for generic testing than many if-else statements.
    +    static double softoken3_version = -1;
    +    static double nss3_version = -1;
    +    static Provider pkcs11 = newPKCS11Provider();
    +    private static String PKCS11_BASE;
    +    private static Map osMap;
     
         static {
             // hack
    @@ -101,21 +112,15 @@ public abstract class PKCS11Test {
             System.setProperty("closed.base", CLOSED_BASE);
         }
     
    -    // NSS version info
    -    public static enum ECCState { None, Basic, Extended };
    -    static double nss_version = -1;
    -    static ECCState nss_ecc_status = ECCState.Extended;
    -
    -    // The NSS library we need to search for in getNSSLibDir()
    -    // Default is "libsoftokn3.so", listed as "softokn3"
    -    // The other is "libnss3.so", listed as "nss3".
    -    static String nss_library = "softokn3";
    +    static {
    +        try {
    +            PKCS11_BASE = getBase();
    +        } catch (Exception e) {
    +            // ignore
    +        }
    +    }
     
    -    // NSS versions of each library.  It is simplier to keep nss_version
    -    // for quick checking for generic testing than many if-else statements.
    -    static double softoken3_version = -1;
    -    static double nss3_version = -1;
    -    static Provider pkcs11 = newPKCS11Provider();
    +    private boolean enableSM = false;
     
         // Utility methods
         // Used to backport HexFormat from 17.
    @@ -152,7 +157,7 @@ protected static String toHexString(byte[] block) {
         }
     
         public static Provider newPKCS11Provider() {
    -        ServiceLoader sl = ServiceLoader.load(java.security.Provider.class);
    +        ServiceLoader sl = ServiceLoader.load(java.security.Provider.class);
             Iterator iter = sl.iterator();
             Provider p = null;
             boolean found = false;
    @@ -170,8 +175,8 @@ public static Provider newPKCS11Provider() {
             // Nothing found through ServiceLoader; fall back to reflection
             if (!found) {
                 try {
    -                Class clazz = Class.forName("sun.security.pkcs11.SunPKCS11");
    -                p = (Provider) clazz.newInstance();
    +                Class clazz = Class.forName("sun.security.pkcs11.SunPKCS11");
    +                p = (Provider) clazz.getDeclaredConstructor().newInstance();
                 } catch (Exception ex) {
                     ex.printStackTrace();
                 }
    @@ -205,38 +210,6 @@ static Provider getSunPKCS11(String config, Provider p) throws Exception {
             return p.configure(config);
         }
     
    -    public abstract void main(Provider p) throws Exception;
    -
    -    protected boolean skipTest(Provider p) {
    -        return false;
    -    }
    -
    -    private void premain(Provider p) throws Exception {
    -        if (skipTest(p)) {
    -            return;
    -        }
    -
    -        // set a security manager and policy before a test case runs,
    -        // and disable them after the test case finished
    -        try {
    -            if (enableSM) {
    -                System.setSecurityManager(new SecurityManager());
    -            }
    -            long start = System.currentTimeMillis();
    -            System.out.printf(
    -                    "Running test with provider %s (security manager %s) ...%n",
    -                        p.getName(), enableSM ? "enabled" : "disabled");
    -            main(p);
    -            long stop = System.currentTimeMillis();
    -            System.out.println("Completed test with provider " + p.getName() +
    -                " (" + (stop - start) + " ms).");
    -        } finally {
    -            if (enableSM) {
    -                System.setSecurityManager(null);
    -            }
    -        }
    -    }
    -
         public static void main(PKCS11Test test) throws Exception {
             main(test, null);
         }
    @@ -261,9 +234,39 @@ public static void main(PKCS11Test test, String[] args) throws Exception {
             Provider[] oldProviders = Security.getProviders();
             try {
                 System.out.println("Beginning test run " + test.getClass().getName() + "...");
    -            testDefault(test);
    -            testNSS(test);
    -            testDeimos(test);
    +            boolean skippedDefault = false;
    +            boolean skippedNSS = false;
    +            boolean skippedDeimos = false;
    +
    +            // Use separate try-catch for each test to allow all test run
    +            try {
    +                testDefault(test);
    +            } catch (SkippedException se) {
    +                System.out.println("testDefault: Skipped");
    +                skippedDefault = true;
    +                se.printStackTrace(System.out);
    +            }
    +
    +            try {
    +                testNSS(test);
    +            } catch (SkippedException se) {
    +                System.out.println("testNSS: Skipped");
    +                skippedNSS = true;
    +                se.printStackTrace(System.out);
    +            }
    +
    +            try {
    +                testDeimos(test);
    +            } catch (SkippedException se) {
    +                System.out.println("testDeimos: Skipped");
    +                skippedDeimos = true;
    +                se.printStackTrace(System.out);
    +            }
    +
    +            if (skippedDefault && skippedNSS && skippedDeimos) {
    +                throw new SkippedException("All tests are skipped, check logs");
    +            }
    +
             } finally {
                 // NOTE: Do not place a 'return' in any finally block
                 // as it will suppress exceptions and hide test failures.
    @@ -273,7 +276,7 @@ public static void main(PKCS11Test test, String[] args) throws Exception {
                 // useful for ./Provider/Login.sh, where a SecurityManager exists.
                 if (oldProviders.length == newProviders.length) {
                     found = false;
    -                for (int i = 0; i testDeimos: Starting test run");
    +        if ("true".equals(System.getProperty("NO_DEIMOS"))) {
    +            System.out.println("Skip Deimos software as test configured with NO_DEIMOS");
                 return;
             }
    +
    +        if (!new File("/opt/SUNWconn/lib/libpkcs11.so").isFile()) {
    +            throw new SkippedException("testDeimos: \"/opt/SUNWconn/lib/libpkcs11.so\" " +
    +                    "file required for Deimos not found");
    +        }
    +
             String base = getBase();
             String p11config = base + SEP + "nss" + SEP + "p11-deimos.txt";
             Provider p = getSunPKCS11(p11config);
             test.premain(p);
    +        System.out.println("testDeimos: Completed");
         }
     
    +    // Run test for default configured PKCS11 providers (if any)
         public static void testDefault(PKCS11Test test) throws Exception {
    -        // run test for default configured PKCS11 providers (if any)
    +        System.out.println("===> testDefault: Starting test run");
    +        boolean foundPKCS11 = false;
     
             if ("true".equals(System.getProperty("NO_DEFAULT"))) {
    +            System.out.println("Skip default provider as test configured with NO_DEFAULT");
                 return;
             }
     
             Provider[] providers = Security.getProviders();
    -        for (int i = 0; i < providers.length; i++) {
    -            Provider p = providers[i];
    +        for (Provider p : providers) {
                 if (p.getName().startsWith("SunPKCS11-")) {
    +                foundPKCS11 = true;
                     test.premain(p);
                 }
             }
    -    }
     
    -    private static String PKCS11_BASE;
    -    static {
    -        try {
    -            PKCS11_BASE = getBase();
    -        } catch (Exception e) {
    -            // ignore
    +        if (!foundPKCS11) {
    +            throw new SkippedException("testDefault: Skip default test as SunPKCS11 " +
    +                    "provider is not configured");
             }
    -    }
     
    -    private final static String PKCS11_REL_PATH = "sun/security/pkcs11";
    +        System.out.println("testDefault: Completed");
    +    }
     
         public static String getBase() throws Exception {
             if (PKCS11_BASE != null) {
    @@ -341,7 +351,7 @@ public static String getBase() throws Exception {
                 }
                 cwd = cwd.getParentFile();
                 if (cwd == null) {
    -                throw new Exception("Test root directory not found");
    +                throw new RuntimeException("Test root directory not found");
                 }
             }
             PKCS11_BASE = new File(cwd, PKCS11_REL_PATH.replace('/', SEP)).getAbsolutePath();
    @@ -373,7 +383,7 @@ static Path getNSSLibPath(String library) throws Exception {
             String[] nssLibDirs = getNssLibPaths(osid);
             if (nssLibDirs == null) {
                 System.out.println("Warning: unsupported OS: " + osid
    -                    + ", please initialize NSS librarys location firstly, skipping test");
    +                    + ", please initialize NSS library location, skipping test");
                 return null;
             }
             if (nssLibDirs.length == 0) {
    @@ -390,7 +400,7 @@ static Path getNSSLibPath(String library) throws Exception {
                 }
             }
             if (nssLibPath == null) {
    -            System.out.println("Warning: can't find NSS librarys on this machine, skipping test");
    +            System.out.println("Warning: can't find NSS library on this machine, skipping test");
                 return null;
             }
             return nssLibPath;
    @@ -403,9 +413,8 @@ private static String getOsId() {
             } else if (osName.equals("Mac OS X")) {
                 osName = "MacOSX";
             }
    -        String osid = osName + "-" + props.getProperty("os.arch") + "-"
    +        return osName + "-" + props.getProperty("os.arch") + "-"
                     + props.getProperty("sun.arch.data.model");
    -        return osid;
         }
     
         static boolean isBadNSSVersion(Provider p) {
    @@ -418,7 +427,7 @@ static boolean isBadNSSVersion(Provider p) {
             return false;
         }
     
    -    protected static void safeReload(String lib) throws Exception {
    +    protected static void safeReload(String lib) {
             try {
                 System.load(lib);
             } catch (UnsatisfiedLinkError e) {
    @@ -428,11 +437,9 @@ protected static void safeReload(String lib) throws Exception {
             }
         }
     
    -    static boolean loadNSPR(String libdir) throws Exception {
    +    static boolean loadNSPR(String libdir) {
             // load NSS softoken dependencies in advance to avoid resolver issues
    -        String dir = libdir.endsWith(File.separator)
    -                     ? libdir
    -                     : libdir + File.separator;
    +        String dir = libdir.endsWith(File.separator) ? libdir : libdir + File.separator;
             safeReload(dir + System.mapLibraryName("nspr4"));
             safeReload(dir + System.mapLibraryName("plc4"));
             safeReload(dir + System.mapLibraryName("plds4"));
    @@ -443,7 +450,7 @@ static boolean loadNSPR(String libdir) throws Exception {
     
         // Check the provider being used is NSS
         public static boolean isNSS(Provider p) {
    -        return p.getName().toUpperCase().equals("SUNPKCS11-NSS");
    +        return p.getName().equalsIgnoreCase("SUNPKCS11-NSS");
         }
     
         static double getNSSVersion() {
    @@ -539,25 +546,25 @@ static double getNSSInfo(String library) {
     
             // the index after whitespace after nssHeader
             int afterheader = s.indexOf("NSS", i) + 4;
    -        String version = String.valueOf(s.charAt(afterheader));
    +        StringBuilder version = new StringBuilder(String.valueOf(s.charAt(afterheader)));
             for (char c = s.charAt(++afterheader);
    -                c == '.' || (c >= '0' && c <= '9');
    -                c = s.charAt(++afterheader)) {
    -            version += c;
    +             c == '.' || (c >= '0' && c <= '9');
    +             c = s.charAt(++afterheader)) {
    +            version.append(c);
             }
     
             // If a "dot dot" release, strip the extra dots for double parsing
    -        String[] dot = version.split("\\.");
    +        String[] dot = version.toString().split("\\.");
             if (dot.length > 2) {
    -            version = dot[0]+"."+dot[1];
    +            version = new StringBuilder(dot[0] + "." + dot[1]);
                 for (int j = 2; dot.length > j; j++) {
    -                version += dot[j];
    +                version.append(dot[j]);
                 }
             }
     
             // Convert to double for easier version value checking
             try {
    -            nss_version = Double.parseDouble(version);
    +            nss_version = Double.parseDouble(version.toString());
             } catch (NumberFormatException e) {
                 System.out.println("===== Content start =====");
                 System.out.println(s);
    @@ -567,7 +574,7 @@ static double getNSSInfo(String library) {
                 e.printStackTrace();
             }
     
    -        System.out.print("lib" + library + " version = "+version+".  ");
    +        System.out.print("library: " + library + ", version: " + version + ".  ");
     
             // Check for ECC
             if (s.indexOf("Basic") > 0) {
    @@ -596,13 +603,15 @@ public static void useNSS() {
     
         // Run NSS testing on a Provider p configured with test nss config
         public static void testNSS(PKCS11Test test) throws Exception {
    +        System.out.println("===> testNSS: Starting test run");
             String nssConfig = getNssConfig();
             if (nssConfig == null) {
    -            // issue loading libraries
    -            return;
    +            throw new SkippedException("testNSS: Problem loading NSS libraries");
             }
    +
             Provider p = getSunPKCS11(nssConfig);
             test.premain(p);
    +        System.out.println("testNSS: Completed");
         }
     
         public static String getNssConfig() throws Exception {
    @@ -611,7 +620,7 @@ public static String getNssConfig() throws Exception {
                 return null;
             }
     
    -        if (loadNSPR(libdir) == false) {
    +        if (!loadNSPR(libdir)) {
                 return null;
             }
     
    @@ -649,12 +658,12 @@ static List getKnownCurves(Provider p) throws Exception {
     
             if (kcProp == null) {
                 throw new RuntimeException(
    -            "\"AlgorithmParameters.EC SupportedCurves property\" not found");
    +                    "\"AlgorithmParameters.EC SupportedCurves property\" not found");
             }
     
             System.out.println("Finding supported curves using list from SunEC\n");
             index = 0;
    -        for (;;) {
    +        for (; ; ) {
                 // Each set of curve names is enclosed with brackets.
                 begin = kcProp.indexOf('[', index);
                 end = kcProp.indexOf(']', index);
    @@ -671,12 +680,12 @@ static List getKnownCurves(Provider p) throws Exception {
                 end = kcProp.indexOf(',', begin);
                 if (end == -1) {
                     // Only one name in the set.
    -                end = index -1;
    +                end = index - 1;
                 }
     
                 curve = kcProp.substring(begin, end);
                 getSupportedECParameterSpec(curve, p)
    -                .ifPresent(spec -> results.add(spec));
    +                    .ifPresent(spec -> results.add(spec));
             }
     
             if (results.size() == 0) {
    @@ -687,9 +696,9 @@ static List getKnownCurves(Provider p) throws Exception {
         }
     
         static Optional getSupportedECParameterSpec(String curve,
    -            Provider p) throws Exception {
    +                                                                 Provider p) throws Exception {
             ECParameterSpec e = getECParameterSpec(p, curve);
    -        System.out.print("\t "+ curve + ": ");
    +        System.out.print("\t " + curve + ": ");
             try {
                 KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", p);
                 kpg.initialize(e);
    @@ -711,26 +720,13 @@ private static ECParameterSpec getECParameterSpec(Provider p, String name)
                 throws Exception {
     
             AlgorithmParameters parameters =
    -            AlgorithmParameters.getInstance("EC", p);
    +                AlgorithmParameters.getInstance("EC", p);
     
             parameters.init(new ECGenParameterSpec(name));
     
             return parameters.getParameterSpec(ECParameterSpec.class);
         }
     
    -    // Check support for a curve with a provided Vector of EC support
    -    boolean checkSupport(List supportedEC,
    -            ECParameterSpec curve) {
    -        for (ECParameterSpec ec: supportedEC) {
    -            if (ec.equals(curve)) {
    -                return true;
    -            }
    -        }
    -        return false;
    -    }
    -
    -    private static Map osMap;
    -
         // Location of the NSS libraries on each supported platform
         private static Map getOsMap() {
             if (osMap != null) {
    @@ -742,23 +738,23 @@ private static Map getOsMap() {
             osMap.put("SunOS-sparcv9-64", new String[] { "/usr/lib/mps/64/" });
             osMap.put("SunOS-x86-32", new String[] { "/usr/lib/mps/" });
             osMap.put("SunOS-amd64-64", new String[] { "/usr/lib/mps/64/" });
    -        osMap.put("Linux-i386-32", new String[] {
    +        osMap.put("Linux-i386-32", new String[]{
                     "/usr/lib/i386-linux-gnu/",
                     "/usr/lib32/",
    -                "/usr/lib/" });
    -        osMap.put("Linux-amd64-64", new String[] {
    +                "/usr/lib/"});
    +        osMap.put("Linux-amd64-64", new String[]{
                     "/usr/lib/x86_64-linux-gnu/",
                     "/usr/lib/x86_64-linux-gnu/nss/",
    -                "/usr/lib64/" });
    -        osMap.put("Linux-ppc64-64", new String[] { "/usr/lib64/" });
    -        osMap.put("Linux-ppc64le-64", new String[] { "/usr/lib64/" });
    -        osMap.put("Linux-s390x-64", new String[] { "/usr/lib64/" });
    -        osMap.put("Windows-x86-32", new String[] {});
    -        osMap.put("Windows-amd64-64", new String[] {});
    -        osMap.put("MacOSX-x86_64-64", new String[] {});
    -        osMap.put("Linux-arm-32", new String[] {
    +                "/usr/lib64/"});
    +        osMap.put("Linux-ppc64-64", new String[]{"/usr/lib64/"});
    +        osMap.put("Linux-ppc64le-64", new String[]{"/usr/lib64/"});
    +        osMap.put("Linux-s390x-64", new String[]{"/usr/lib64/"});
    +        osMap.put("Windows-x86-32", new String[]{});
    +        osMap.put("Windows-amd64-64", new String[]{});
    +        osMap.put("MacOSX-x86_64-64", new String[]{});
    +        osMap.put("Linux-arm-32", new String[]{
                     "/usr/lib/arm-linux-gnueabi/nss/",
    -                "/usr/lib/arm-linux-gnueabihf/nss/" });
    +                "/usr/lib/arm-linux-gnueabihf/nss/"});
             // Exclude linux-aarch64 at the moment until the following bug is fixed:
             // 8296631: NSS tests failing on OL9 linux-aarch64 hosts
     //        osMap.put("Linux-aarch64-64", new String[] {
    @@ -799,7 +795,7 @@ private static String[] getPreferableNssLibPaths(String osId) {
                 }
             }
     
    -        return nssLibPaths.toArray(new String[nssLibPaths.size()]);
    +        return nssLibPaths.toArray(new String[0]);
         }
     
         private final static char[] hexDigits = "0123456789abcdef".toCharArray();
    @@ -822,8 +818,8 @@ public static String toString(byte[] b) {
                 if (i != 0) {
                     sb.append(':');
                 }
    -            sb.append(hexDigits[k >>> 4]);
    -            sb.append(hexDigits[k & 0xf]);
    +            sb.append(HEX_DIGITS[k >>> 4]);
    +            sb.append(HEX_DIGITS[k & 0xf]);
             }
             return sb.toString();
         }
    @@ -869,20 +865,11 @@ private static int nextNibble(StringReader r) throws IOException {
             }
         }
     
    -     T[] concat(T[] a, T[] b) {
    -        if ((b == null) || (b.length == 0)) {
    -            return a;
    -        }
    -        T[] r = Arrays.copyOf(a, a.length + b.length);
    -        System.arraycopy(b, 0, r, a.length, b.length);
    -        return r;
    -    }
    -
         /**
          * Returns supported algorithms of specified type.
          */
         static List getSupportedAlgorithms(String type, String alg,
    -            Provider p) {
    +                                               Provider p) {
             // prepare a list of supported algorithms
             List algorithms = new ArrayList<>();
             Set services = p.getServices();
    @@ -920,7 +907,7 @@ private static String distro() {
     
         static byte[] generateData(int length) {
             byte data[] = new byte[length];
    -        for (int i=0; i clazz) {
             return path;
         }
     
    +    public abstract void main(Provider p) throws Exception;
    +
    +    protected boolean skipTest(Provider p) {
    +        return false;
    +    }
    +
    +    private void premain(Provider p) throws Exception {
    +        if (skipTest(p)) {
    +            return;
    +        }
    +
    +        // set a security manager and policy before a test case runs,
    +        // and disable them after the test case finished
    +        try {
    +            if (enableSM) {
    +                System.setSecurityManager(new SecurityManager());
    +            }
    +            long start = System.currentTimeMillis();
    +            System.out.printf(
    +                    "Running test with provider %s (security manager %s) ...%n",
    +                    p.getName(), enableSM ? "enabled" : "disabled");
    +            main(p);
    +            long stop = System.currentTimeMillis();
    +            System.out.println("Completed test with provider " + p.getName() +
    +                    " (" + (stop - start) + " ms).");
    +        } finally {
    +            if (enableSM) {
    +                System.setSecurityManager(null);
    +            }
    +        }
    +    }
    +
    +    // Check support for a curve with a provided Vector of EC support
    +    boolean checkSupport(List supportedEC,
    +                         ECParameterSpec curve) {
    +        for (ECParameterSpec ec : supportedEC) {
    +            if (ec.equals(curve)) {
    +                return true;
    +            }
    +        }
    +        return false;
    +    }
    +
    +     T[] concat(T[] a, T[] b) {
    +        if ((b == null) || (b.length == 0)) {
    +            return a;
    +        }
    +        T[] r = Arrays.copyOf(a, a.length + b.length);
    +        System.arraycopy(b, 0, r, a.length, b.length);
    +        return r;
    +    }
    +
         protected void setCommonSystemProps() {
             System.setProperty("java.security.debug", "true");
             System.setProperty("NO_DEIMOS", "true");
    @@ -993,40 +1032,46 @@ protected void copyNssCertKeyToClassesDir(Path dbPath) throws IOException {
                     StandardCopyOption.REPLACE_EXISTING);
         }
     
    +    // NSS version info
    +    public static enum ECCState {None, Basic, Extended}
    +
         @Artifact(
                 organization = NSSLIB,
                 name = "nsslib-windows_x64",
                 revision = NSS_BUNDLE_VERSION,
                 extension = "zip")
    -    private static class WINDOWS_X64 { }
    +    private static class WINDOWS_X64 {
    +    }
     
         @Artifact(
                 organization = NSSLIB,
                 name = "nsslib-macosx_x64",
                 revision = NSS_BUNDLE_VERSION,
                 extension = "zip")
    -    private static class MACOSX_X64 { }
    +    private static class MACOSX_X64 {
    +    }
     
         @Artifact(
                 organization = NSSLIB,
                 name = "nsslib-macosx_aarch64",
                 revision = NSS_BUNDLE_VERSION,
                 extension = "zip")
    -    private static class MACOSX_AARCH64 { }
    +    private static class MACOSX_AARCH64 {
    +    }
     
         @Artifact(
                 organization = NSSLIB,
                 name = "nsslib-linux_x64",
                 revision = NSS_BUNDLE_VERSION,
                 extension = "zip")
    -    private static class LINUX_X64 { }
    +    private static class LINUX_X64 {
    +    }
     
         @Artifact(
                 organization = NSSLIB,
                 name = "nsslib-linux_aarch64",
                 revision = NSS_BUNDLE_VERSION,
    -            extension = "zip"
    -    )
    +            extension = "zip")
         private static class LINUX_AARCH64{
         }
     }
    diff --git a/test/jdk/sun/security/pkcs11/Provider/ConfigQuotedString.java b/test/jdk/sun/security/pkcs11/Provider/ConfigQuotedString.java
    index 24340647d1c..a6c2a9728e0 100644
    --- a/test/jdk/sun/security/pkcs11/Provider/ConfigQuotedString.java
    +++ b/test/jdk/sun/security/pkcs11/Provider/ConfigQuotedString.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2004, 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,8 @@
      * @run testng/othervm ConfigQuotedString
      */
     
    +import jtreg.SkippedException;
    +import org.testng.SkipException;
     import org.testng.annotations.BeforeClass;
     import org.testng.annotations.Test;
     
    @@ -44,7 +46,11 @@ public void setUp() throws Exception {
     
         @Test
         public void testQuotedString() throws Exception {
    -        main(new ConfigQuotedString());
    +        try {
    +            main(new ConfigQuotedString());
    +        } catch (SkippedException se) {
    +            throw new SkipException("One or more tests are skipped");
    +        }
         }
     
         public void main(Provider p) throws Exception {
    diff --git a/test/jdk/sun/security/pkcs11/Provider/Login.java b/test/jdk/sun/security/pkcs11/Provider/Login.java
    index 6d7063f2082..8bb39fe4906 100644
    --- a/test/jdk/sun/security/pkcs11/Provider/Login.java
    +++ b/test/jdk/sun/security/pkcs11/Provider/Login.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2003, 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,8 @@
      * @run testng/othervm Login
      */
     
    +import jtreg.SkippedException;
    +import org.testng.SkipException;
     import org.testng.annotations.BeforeClass;
     import org.testng.annotations.Test;
     
    @@ -55,7 +57,11 @@ public void setUp() throws Exception {
         @Test
         public void testLogin() throws Exception {
             String[] args = new String[]{ "sm", "Login.policy"};
    -        main(new Login(), args);
    +        try {
    +            main(new Login(), args);
    +        } catch (SkippedException se) {
    +            throw new SkipException("One or more tests are skipped");
    +        }
         }
     
         public void main(Provider p) throws Exception {
    diff --git a/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.sh b/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.sh
    index 1e40fcfe981..e4ca0d9d64d 100644
    --- a/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.sh
    +++ b/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.sh
    @@ -1,5 +1,5 @@
     #
    -# Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
    +# Copyright (c) 2021, 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
    @@ -111,6 +111,7 @@ ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
             --add-modules jdk.crypto.cryptoki \
             --add-exports jdk.crypto.cryptoki/sun.security.pkcs11=ALL-UNNAMED \
             ${TESTSRC}${FS}..${FS}..${FS}..${FS}..${FS}..${FS}lib${FS}jdk${FS}test${FS}lib${FS}artifacts${FS}*.java \
    +        ${TESTSRC}${FS}..${FS}..${FS}..${FS}..${FS}..${FS}lib${FS}jtreg${FS}*.java \
             ${TESTSRC}${FS}MultipleLogins.java \
             ${TESTSRC}${FS}..${FS}PKCS11Test.java
     
    diff --git a/test/jdk/sun/security/pkcs11/SecmodTest.java b/test/jdk/sun/security/pkcs11/SecmodTest.java
    index 6ff6dd29acd..c5a01b0a739 100644
    --- a/test/jdk/sun/security/pkcs11/SecmodTest.java
    +++ b/test/jdk/sun/security/pkcs11/SecmodTest.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2005, 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
    @@ -24,6 +24,8 @@
     
     // common infrastructure for Secmod tests
     
    +import jtreg.SkippedException;
    +
     import java.io.*;
     
     import java.security.Provider;
    @@ -43,13 +45,11 @@ static void useSqlite(boolean b) {
         static boolean initSecmod() throws Exception {
             useNSS();
             LIBPATH = getNSSLibDir();
    -        if (LIBPATH == null) {
    -            return false;
    -        }
             // load all the libraries except libnss3 into memory
    -        if (loadNSPR(LIBPATH) == false) {
    -            return false;
    +        if ((LIBPATH == null) || (!loadNSPR(LIBPATH))) {
    +            throw new SkippedException("Failed to load NSS libraries");
             }
    +
             safeReload(LIBPATH + System.mapLibraryName("softokn3"));
             safeReload(LIBPATH + System.mapLibraryName("nssckbi"));
     
    diff --git a/test/jdk/sun/security/pkcs11/SecureRandom/Basic.java b/test/jdk/sun/security/pkcs11/SecureRandom/Basic.java
    index 381efb68942..3518b628f13 100644
    --- a/test/jdk/sun/security/pkcs11/SecureRandom/Basic.java
    +++ b/test/jdk/sun/security/pkcs11/SecureRandom/Basic.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2005, 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 6aa721649d870354a79c3508343b14222e0edcfb Mon Sep 17 00:00:00 2001
    From: Goetz Lindenmaier 
    Date: Mon, 25 Mar 2024 17:54:42 +0000
    Subject: [PATCH 052/149] 8324632: Update Zlib Data Compression Library to
     Version 1.3.1 8315117: Update Zlib Data Compression Library to Version 1.3
     8326351: Update the Zlib version in open/src/java.base/share/legal/zlib.md to
     1.3.1
    
    Backport-of: 6359b2843f83852561b925d3f1315eed5f4b9cda
    ---
     src/java.base/share/legal/zlib.md             |   4 +-
     .../share/native/libzip/zlib/ChangeLog        | 215 ++++--
     src/java.base/share/native/libzip/zlib/README |  19 +-
     .../share/native/libzip/zlib/compress.c       |  21 +-
     .../share/native/libzip/zlib/deflate.c        | 612 ++++++++----------
     .../share/native/libzip/zlib/deflate.h        |  51 +-
     .../share/native/libzip/zlib/gzclose.c        |   4 +-
     .../share/native/libzip/zlib/gzguts.h         |  31 +-
     .../share/native/libzip/zlib/gzlib.c          | 113 +---
     .../share/native/libzip/zlib/gzread.c         |  88 +--
     .../share/native/libzip/zlib/gzwrite.c        |  84 +--
     .../share/native/libzip/zlib/infback.c        |  30 +-
     .../share/native/libzip/zlib/inffast.c        |   5 +-
     .../share/native/libzip/zlib/inffast.h        |   2 +-
     .../share/native/libzip/zlib/inflate.c        | 131 +---
     .../share/native/libzip/zlib/inftrees.c       |  17 +-
     .../share/native/libzip/zlib/inftrees.h       |  10 +-
     .../native/libzip/zlib/patches/ChangeLog_java |   2 +-
     .../share/native/libzip/zlib/trees.c          | 542 +++++++---------
     .../share/native/libzip/zlib/uncompr.c        |  16 +-
     .../share/native/libzip/zlib/zadler32.c       |  32 +-
     .../share/native/libzip/zlib/zconf.h          |  18 +-
     .../share/native/libzip/zlib/zcrc32.c         | 248 +++----
     src/java.base/share/native/libzip/zlib/zlib.h | 391 +++++------
     .../share/native/libzip/zlib/zutil.c          |  60 +-
     .../share/native/libzip/zlib/zutil.h          |  47 +-
     26 files changed, 1183 insertions(+), 1610 deletions(-)
    
    diff --git a/src/java.base/share/legal/zlib.md b/src/java.base/share/legal/zlib.md
    index d856af6ccd4..fcc5457bf5b 100644
    --- a/src/java.base/share/legal/zlib.md
    +++ b/src/java.base/share/legal/zlib.md
    @@ -1,9 +1,9 @@
    -## zlib v1.2.13
    +## zlib v1.3.1
     
     ### zlib License
     
     
    -Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
    +Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
     
     This software is provided 'as-is', without any express or implied
     warranty.  In no event will the authors be held liable for any damages
    diff --git a/src/java.base/share/native/libzip/zlib/ChangeLog b/src/java.base/share/native/libzip/zlib/ChangeLog
    index 30199a65a03..b801a1031ec 100644
    --- a/src/java.base/share/native/libzip/zlib/ChangeLog
    +++ b/src/java.base/share/native/libzip/zlib/ChangeLog
    @@ -1,6 +1,109 @@
     
                     ChangeLog file for zlib
     
    +Changes in 1.3.1 (22 Jan 2024)
    +- Reject overflows of zip header fields in minizip
    +- Fix bug in inflateSync() for data held in bit buffer
    +- Add LIT_MEM define to use more memory for a small deflate speedup
    +- Fix decision on the emission of Zip64 end records in minizip
    +- Add bounds checking to ERR_MSG() macro, used by zError()
    +- Neutralize zip file traversal attacks in miniunz
    +- Fix a bug in ZLIB_DEBUG compiles in check_match()
    +- Various portability and appearance improvements
    +
    +Changes in 1.3 (18 Aug 2023)
    +- Remove K&R function definitions and zlib2ansi
    +- Fix bug in deflateBound() for level 0 and memLevel 9
    +- Fix bug when gzungetc() is used immediately after gzopen()
    +- Fix bug when using gzflush() with a very small buffer
    +- Fix crash when gzsetparams() attempted for transparent write
    +- Fix test/example.c to work with FORCE_STORED
    +- Rewrite of zran in examples (see zran.c version history)
    +- Fix minizip to allow it to open an empty zip file
    +- Fix reading disk number start on zip64 files in minizip
    +- Fix logic error in minizip argument processing
    +- Add minizip testing to Makefile
    +- Read multiple bytes instead of byte-by-byte in minizip unzip.c
    +- Add memory sanitizer to configure (--memory)
    +- Various portability improvements
    +- Various documentation improvements
    +- Various spelling and typo corrections
    +
    +Changes in 1.2.13 (13 Oct 2022)
    +- Fix configure issue that discarded provided CC definition
    +- Correct incorrect inputs provided to the CRC functions
    +- Repair prototypes and exporting of new CRC functions
    +- Fix inflateBack to detect invalid input with distances too far
    +- Have infback() deliver all of the available output up to any error
    +- Fix a bug when getting a gzip header extra field with inflate()
    +- Fix bug in block type selection when Z_FIXED used
    +- Tighten deflateBound bounds
    +- Remove deleted assembler code references
    +- Various portability and appearance improvements
    +
    +Changes in 1.2.12 (27 Mar 2022)
    +- Cygwin does not have _wopen(), so do not create gzopen_w() there
    +- Permit a deflateParams() parameter change as soon as possible
    +- Limit hash table inserts after switch from stored deflate
    +- Fix bug when window full in deflate_stored()
    +- Fix CLEAR_HASH macro to be usable as a single statement
    +- Avoid a conversion error in gzseek when off_t type too small
    +- Have Makefile return non-zero error code on test failure
    +- Avoid some conversion warnings in gzread.c and gzwrite.c
    +- Update use of errno for newer Windows CE versions
    +- Small speedup to inflate [psumbera]
    +- Return an error if the gzputs string length can't fit in an int
    +- Add address checking in clang to -w option of configure
    +- Don't compute check value for raw inflate if asked to validate
    +- Handle case where inflateSync used when header never processed
    +- Avoid the use of ptrdiff_t
    +- Avoid an undefined behavior of memcpy() in gzappend()
    +- Avoid undefined behaviors of memcpy() in gz*printf()
    +- Avoid an undefined behavior of memcpy() in _tr_stored_block()
    +- Make the names in functions declarations identical to definitions
    +- Remove old assembler code in which bugs have manifested
    +- Fix deflateEnd() to not report an error at start of raw deflate
    +- Add legal disclaimer to README
    +- Emphasize the need to continue decompressing gzip members
    +- Correct the initialization requirements for deflateInit2()
    +- Fix a bug that can crash deflate on some input when using Z_FIXED
    +- Assure that the number of bits for deflatePrime() is valid
    +- Use a structure to make globals in enough.c evident
    +- Use a macro for the printf format of big_t in enough.c
    +- Clean up code style in enough.c, update version
    +- Use inline function instead of macro for index in enough.c
    +- Clarify that prefix codes are counted in enough.c
    +- Show all the codes for the maximum tables size in enough.c
    +- Add gznorm.c example, which normalizes gzip files
    +- Fix the zran.c example to work on a multiple-member gzip file
    +- Add tables for crc32_combine(), to speed it up by a factor of 200
    +- Add crc32_combine_gen() and crc32_combine_op() for fast combines
    +- Speed up software CRC-32 computation by a factor of 1.5 to 3
    +- Use atomic test and set, if available, for dynamic CRC tables
    +- Don't bother computing check value after successful inflateSync()
    +- Correct comment in crc32.c
    +- Add use of the ARMv8 crc32 instructions when requested
    +- Use ARM crc32 instructions if the ARM architecture has them
    +- Explicitly note that the 32-bit check values are 32 bits
    +- Avoid adding empty gzip member after gzflush with Z_FINISH
    +- Fix memory leak on error in gzlog.c
    +- Fix error in comment on the polynomial representation of a byte
    +- Clarify gz* function interfaces, referring to parameter names
    +- Change macro name in inflate.c to avoid collision in VxWorks
    +- Correct typo in blast.c
    +- Improve portability of contrib/minizip
    +- Fix indentation in minizip's zip.c
    +- Replace black/white with allow/block. (theresa-m)
    +- minizip warning fix if MAXU32 already defined. (gvollant)
    +- Fix unztell64() in minizip to work past 4GB. (Daniël Hörchner)
    +- Clean up minizip to reduce warnings for testing
    +- Add fallthrough comments for gcc
    +- Eliminate use of ULL constants
    +- Separate out address sanitizing from warnings in configure
    +- Remove destructive aspects of make distclean
    +- Check for cc masquerading as gcc or clang in configure
    +- Fix crc32.c to compile local functions only if used
    +
     Changes in 1.2.11 (15 Jan 2017)
     - Fix deflate stored bug when pulling last block from window
     - Permit immediate deflateParams changes before any deflate input
    @@ -96,7 +199,7 @@ Changes in 1.2.7.1 (24 Mar 2013)
     - Fix types in contrib/minizip to match result of get_crc_table()
     - Simplify contrib/vstudio/vc10 with 'd' suffix
     - Add TOP support to win32/Makefile.msc
    -- Suport i686 and amd64 assembler builds in CMakeLists.txt
    +- Support i686 and amd64 assembler builds in CMakeLists.txt
     - Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h
     - Add vc11 and vc12 build files to contrib/vstudio
     - Add gzvprintf() as an undocumented function in zlib
    @@ -296,14 +399,14 @@ Changes in 1.2.5.1 (10 Sep 2011)
     - Use u4 type for crc_table to avoid conversion warnings
     - Apply casts in zlib.h to avoid conversion warnings
     - Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller]
    -- Improve inflateSync() documentation to note indeterminancy
    +- Improve inflateSync() documentation to note indeterminacy
     - Add deflatePending() function to return the amount of pending output
     - Correct the spelling of "specification" in FAQ [Randers-Pehrson]
     - Add a check in configure for stdarg.h, use for gzprintf()
     - Check that pointers fit in ints when gzprint() compiled old style
     - Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler]
     - Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt]
    -- Add debug records in assmebler code [Londer]
    +- Add debug records in assembler code [Londer]
     - Update RFC references to use http://tools.ietf.org/html/... [Li]
     - Add --archs option, use of libtool to configure for Mac OS X [Borstel]
     
    @@ -511,7 +614,7 @@ Changes in 1.2.3.5 (8 Jan 2010)
     - Don't use _vsnprintf on later versions of MSVC [Lowman]
     - Add CMake build script and input file [Lowman]
     - Update contrib/minizip to 1.1 [Svensson, Vollant]
    -- Moved nintendods directory from contrib to .
    +- Moved nintendods directory from contrib to root
     - Replace gzio.c with a new set of routines with the same functionality
     - Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above
     - Update contrib/minizip to 1.1b
    @@ -685,7 +788,7 @@ Changes in 1.2.2.4 (11 July 2005)
     - Be more strict on incomplete code sets in inflate_table() and increase
       ENOUGH and MAXD -- this repairs a possible security vulnerability for
       invalid inflate input.  Thanks to Tavis Ormandy and Markus Oberhumer for
    -  discovering the vulnerability and providing test cases.
    +  discovering the vulnerability and providing test cases
     - Add ia64 support to configure for HP-UX [Smith]
     - Add error return to gzread() for format or i/o error [Levin]
     - Use malloc.h for OS/2 [Necasek]
    @@ -721,7 +824,7 @@ Changes in 1.2.2.2 (30 December 2004)
     - Add Z_FIXED strategy option to deflateInit2() to force fixed trees
     - Add updated make_vms.com [Coghlan], update README
     - Create a new "examples" directory, move gzappend.c there, add zpipe.c,
    -  fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html.
    +  fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html
     - Add FAQ entry and comments in deflate.c on uninitialized memory access
     - Add Solaris 9 make options in configure [Gilbert]
     - Allow strerror() usage in gzio.c for STDC
    @@ -792,7 +895,7 @@ Changes in 1.2.1.1 (9 January 2004)
     - Fix a big fat bug in inftrees.c that prevented decoding valid
       dynamic blocks with only literals and no distance codes --
       Thanks to "Hot Emu" for the bug report and sample file
    -- Add a note to puff.c on no distance codes case.
    +- Add a note to puff.c on no distance codes case
     
     Changes in 1.2.1 (17 November 2003)
     - Remove a tab in contrib/gzappend/gzappend.c
    @@ -970,7 +1073,7 @@ Changes in 1.2.0.1 (17 March 2003)
         - Include additional header file on VMS for off_t typedef
     - Try to use _vsnprintf where it supplants vsprintf [Vollant]
     - Add some casts in inffast.c
    -- Enchance comments in zlib.h on what happens if gzprintf() tries to
    +- Enhance comments in zlib.h on what happens if gzprintf() tries to
       write more than 4095 bytes before compression
     - Remove unused state from inflateBackEnd()
     - Remove exit(0) from minigzip.c, example.c
    @@ -1036,14 +1139,14 @@ Changes in 1.2.0 (9 March 2003)
     - Add contrib/puff/ simple inflate for deflate format description
     
     Changes in 1.1.4 (11 March 2002)
    -- ZFREE was repeated on same allocation on some error conditions.
    +- ZFREE was repeated on same allocation on some error conditions
       This creates a security problem described in
       http://www.zlib.org/advisory-2002-03-11.txt
     - Returned incorrect error (Z_MEM_ERROR) on some invalid data
     - Avoid accesses before window for invalid distances with inflate window
    -  less than 32K.
    +  less than 32K
     - force windowBits > 8 to avoid a bug in the encoder for a window size
    -  of 256 bytes. (A complete fix will be available in 1.1.5).
    +  of 256 bytes. (A complete fix will be available in 1.1.5)
     
     Changes in 1.1.3 (9 July 1998)
     - fix "an inflate input buffer bug that shows up on rare but persistent
    @@ -1117,7 +1220,7 @@ Changes in 1.1.1 (27 Feb 98)
     - remove block truncation heuristic which had very marginal effect for zlib
       (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
       compression ratio on some files. This also allows inlining _tr_tally for
    -  matches in deflate_slow.
    +  matches in deflate_slow
     - added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier)
     
     Changes in 1.1.0 (24 Feb 98)
    @@ -1148,7 +1251,7 @@ Changes in 1.0.9 (17 Feb 1998)
     - Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8
     - in inftrees.c, avoid cc -O bug on HP (Farshid Elahi)
     - in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with
    -  the declaration of FAR (Gilles VOllant)
    +  the declaration of FAR (Gilles Vollant)
     - install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann)
     - read_buf buf parameter of type Bytef* instead of charf*
     - zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout)
    @@ -1162,7 +1265,7 @@ Changes in 1.0.8 (27 Jan 1998)
     - include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)
     - use constant arrays for the static trees in trees.c instead of computing
       them at run time (thanks to Ken Raeburn for this suggestion). To create
    -  trees.h, compile with GEN_TREES_H and run "make test".
    +  trees.h, compile with GEN_TREES_H and run "make test"
     - check return code of example in "make test" and display result
     - pass minigzip command line options to file_compress
     - simplifying code of inflateSync to avoid gcc 2.8 bug
    @@ -1201,12 +1304,12 @@ Changes in 1.0.6 (19 Jan 1998)
     - add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
       gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
     - Fix a deflate bug occurring only with compression level 0 (thanks to
    -  Andy Buckler for finding this one).
    -- In minigzip, pass transparently also the first byte for .Z files.
    +  Andy Buckler for finding this one)
    +- In minigzip, pass transparently also the first byte for .Z files
     - return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
     - check Z_FINISH in inflate (thanks to Marc Schluper)
     - Implement deflateCopy (thanks to Adam Costello)
    -- make static libraries by default in configure, add --shared option.
    +- make static libraries by default in configure, add --shared option
     - move MSDOS or Windows specific files to directory msdos
     - suppress the notion of partial flush to simplify the interface
       (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4)
    @@ -1218,7 +1321,7 @@ Changes in 1.0.6 (19 Jan 1998)
     - added Makefile.nt (thanks to Stephen Williams)
     - added the unsupported "contrib" directory:
        contrib/asm386/ by Gilles Vollant 
    -        386 asm code replacing longest_match().
    +        386 asm code replacing longest_match()
        contrib/iostream/ by Kevin Ruland 
             A C++ I/O streams interface to the zlib gz* functions
        contrib/iostream2/  by Tyge Løvset 
    @@ -1226,7 +1329,7 @@ Changes in 1.0.6 (19 Jan 1998)
        contrib/untgz/  by "Pedro A. Aranda Guti\irrez" 
             A very simple tar.gz file extractor using zlib
        contrib/visual-basic.txt by Carlos Rios 
    -        How to use compress(), uncompress() and the gz* functions from VB.
    +        How to use compress(), uncompress() and the gz* functions from VB
     - pass params -f (filtered data), -h (huffman only), -1 to -9 (compression
       level) in minigzip (thanks to Tom Lane)
     
    @@ -1235,8 +1338,8 @@ Changes in 1.0.6 (19 Jan 1998)
     - add undocumented function inflateSyncPoint() (hack for Paul Mackerras)
     - add undocumented function zError to convert error code to string
       (for Tim Smithers)
    -- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code.
    -- Use default memcpy for Symantec MSDOS compiler.
    +- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code
    +- Use default memcpy for Symantec MSDOS compiler
     - Add EXPORT keyword for check_func (needed for Windows DLL)
     - add current directory to LD_LIBRARY_PATH for "make test"
     - create also a link for libz.so.1
    @@ -1249,7 +1352,7 @@ Changes in 1.0.6 (19 Jan 1998)
     - allow compilation with ANSI keywords only enabled for TurboC in large model
     - avoid "versionString"[0] (Borland bug)
     - add NEED_DUMMY_RETURN for Borland
    -- use variable z_verbose for tracing in debug mode (L. Peter Deutsch).
    +- use variable z_verbose for tracing in debug mode (L. Peter Deutsch)
     - allow compilation with CC
     - defined STDC for OS/2 (David Charlap)
     - limit external names to 8 chars for MVS (Thomas Lund)
    @@ -1259,7 +1362,7 @@ Changes in 1.0.6 (19 Jan 1998)
     - use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau)
     - added makelcc.bat for lcc-win32 (Tom St Denis)
     - in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe)
    -- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion.
    +- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion
     - check for unistd.h in configure (for off_t)
     - remove useless check parameter in inflate_blocks_free
     - avoid useless assignment of s->check to itself in inflate_blocks_new
    @@ -1280,7 +1383,7 @@ Changes in 1.0.5 (3 Jan 98)
     Changes in 1.0.4 (24 Jul 96)
     - In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
       bit, so the decompressor could decompress all the correct data but went
    -  on to attempt decompressing extra garbage data. This affected minigzip too.
    +  on to attempt decompressing extra garbage data. This affected minigzip too
     - zlibVersion and gzerror return const char* (needed for DLL)
     - port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
     - use z_error only for DEBUG (avoid problem with DLLs)
    @@ -1310,7 +1413,7 @@ Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
     - fix array overlay in deflate.c which sometimes caused bad compressed data
     - fix inflate bug with empty stored block
     - fix MSDOS medium model which was broken in 0.99
    -- fix deflateParams() which could generate bad compressed data.
    +- fix deflateParams() which could generate bad compressed data
     - Bytef is define'd instead of typedef'ed (work around Borland bug)
     - added an INDEX file
     - new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
    @@ -1331,7 +1434,7 @@ Changes in 0.99 (27 Jan 96)
     - allow preset dictionary shared between compressor and decompressor
     - allow compression level 0 (no compression)
     - add deflateParams in zlib.h: allow dynamic change of compression level
    -  and compression strategy.
    +  and compression strategy
     - test large buffers and deflateParams in example.c
     - add optional "configure" to build zlib as a shared library
     - suppress Makefile.qnx, use configure instead
    @@ -1370,33 +1473,33 @@ Changes in 0.99 (27 Jan 96)
     - fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
     - in fcalloc, normalize pointer if size > 65520 bytes
     - don't use special fcalloc for 32 bit Borland C++
    -- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc...
    +- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc.
     - use Z_BINARY instead of BINARY
     - document that gzclose after gzdopen will close the file
    -- allow "a" as mode in gzopen.
    +- allow "a" as mode in gzopen
     - fix error checking in gzread
     - allow skipping .gz extra-field on pipes
     - added reference to Perl interface in README
     - put the crc table in FAR data (I dislike more and more the medium model :)
     - added get_crc_table
    -- added a dimension to all arrays (Borland C can't count).
    +- added a dimension to all arrays (Borland C can't count)
     - workaround Borland C bug in declaration of inflate_codes_new & inflate_fast
     - guard against multiple inclusion of *.h (for precompiled header on Mac)
    -- Watcom C pretends to be Microsoft C small model even in 32 bit mode.
    +- Watcom C pretends to be Microsoft C small model even in 32 bit mode
     - don't use unsized arrays to avoid silly warnings by Visual C++:
          warning C4746: 'inflate_mask' : unsized array treated as  '__far'
    -     (what's wrong with far data in far model?).
    +     (what's wrong with far data in far model?)
     - define enum out of inflate_blocks_state to allow compilation with C++
     
     Changes in 0.95 (16 Aug 95)
     - fix MSDOS small and medium model (now easier to adapt to any compiler)
     - inlined send_bits
     - fix the final (:-) bug for deflate with flush (output was correct but
    -  not completely flushed in rare occasions).
    +  not completely flushed in rare occasions)
     - default window size is same for compression and decompression
    -  (it's now sufficient to set MAX_WBITS in zconf.h).
    +  (it's now sufficient to set MAX_WBITS in zconf.h)
     - voidp -> voidpf and voidnp -> voidp (for consistency with other
    -  typedefs and because voidnp was not near in large model).
    +  typedefs and because voidnp was not near in large model)
     
     Changes in 0.94 (13 Aug 95)
     - support MSDOS medium model
    @@ -1405,12 +1508,12 @@ Changes in 0.94 (13 Aug 95)
     - added support for VMS
     - allow a compression level in gzopen()
     - gzflush now calls fflush
    -- For deflate with flush, flush even if no more input is provided.
    +- For deflate with flush, flush even if no more input is provided
     - rename libgz.a as libz.a
     - avoid complex expression in infcodes.c triggering Turbo C bug
     - work around a problem with gcc on Alpha (in INSERT_STRING)
     - don't use inline functions (problem with some gcc versions)
    -- allow renaming of Byte, uInt, etc... with #define.
    +- allow renaming of Byte, uInt, etc... with #define
     - avoid warning about (unused) pointer before start of array in deflate.c
     - avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c
     - avoid reserved word 'new' in trees.c
    @@ -1429,7 +1532,7 @@ Changes in 0.92 (3 May 95)
     - no memcpy on Pyramid
     - suppressed inftest.c
     - optimized fill_window, put longest_match inline for gcc
    -- optimized inflate on stored blocks.
    +- optimized inflate on stored blocks
     - untabify all sources to simplify patches
     
     Changes in 0.91 (2 May 95)
    @@ -1447,7 +1550,7 @@ Changes in 0.9 (1 May 95)
     - let again gzread copy uncompressed data unchanged (was working in 0.71)
     - deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented
     - added a test of inflateSync in example.c
    -- moved MAX_WBITS to zconf.h because users might want to change that.
    +- moved MAX_WBITS to zconf.h because users might want to change that
     - document explicitly that zalloc(64K) on MSDOS must return a normalized
       pointer (zero offset)
     - added Makefiles for Microsoft C, Turbo C, Borland C++
    @@ -1456,7 +1559,7 @@ Changes in 0.9 (1 May 95)
     Changes in 0.8 (29 April 95)
     - added fast inflate (inffast.c)
     - deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this
    -  is incompatible with previous versions of zlib which returned Z_OK.
    +  is incompatible with previous versions of zlib which returned Z_OK
     - work around a TurboC compiler bug (bad code for b << 0, see infutil.h)
       (actually that was not a compiler bug, see 0.81 above)
     - gzread no longer reads one extra byte in certain cases
    @@ -1466,50 +1569,50 @@ Changes in 0.8 (29 April 95)
     
     Changes in 0.71 (14 April 95)
     - Fixed more MSDOS compilation problems :( There is still a bug with
    -  TurboC large model.
    +  TurboC large model
     
     Changes in 0.7 (14 April 95)
    -- Added full inflate support.
    +- Added full inflate support
     - Simplified the crc32() interface. The pre- and post-conditioning
       (one's complement) is now done inside crc32(). WARNING: this is
    -  incompatible with previous versions; see zlib.h for the new usage.
    +  incompatible with previous versions; see zlib.h for the new usage
     
     Changes in 0.61 (12 April 95)
    -- workaround for a bug in TurboC. example and minigzip now work on MSDOS.
    +- workaround for a bug in TurboC. example and minigzip now work on MSDOS
     
     Changes in 0.6 (11 April 95)
     - added minigzip.c
     - added gzdopen to reopen a file descriptor as gzFile
    -- added transparent reading of non-gziped files in gzread.
    +- added transparent reading of non-gziped files in gzread
     - fixed bug in gzread (don't read crc as data)
    -- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose).
    +- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose)
     - don't allocate big arrays in the stack (for MSDOS)
     - fix some MSDOS compilation problems
     
     Changes in 0.5:
     - do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but
    -  not yet Z_FULL_FLUSH.
    +  not yet Z_FULL_FLUSH
     - support decompression but only in a single step (forced Z_FINISH)
    -- added opaque object for zalloc and zfree.
    +- added opaque object for zalloc and zfree
     - added deflateReset and inflateReset
    -- added a variable zlib_version for consistency checking.
    -- renamed the 'filter' parameter of deflateInit2 as 'strategy'.
    -  Added Z_FILTERED and Z_HUFFMAN_ONLY constants.
    +- added a variable zlib_version for consistency checking
    +- renamed the 'filter' parameter of deflateInit2 as 'strategy'
    +  Added Z_FILTERED and Z_HUFFMAN_ONLY constants
     
     Changes in 0.4:
    -- avoid "zip" everywhere, use zlib instead of ziplib.
    +- avoid "zip" everywhere, use zlib instead of ziplib
     - suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush
    -  if compression method == 8.
    +  if compression method == 8
     - added adler32 and crc32
     - renamed deflateOptions as deflateInit2, call one or the other but not both
    -- added the method parameter for deflateInit2.
    +- added the method parameter for deflateInit2
     - added inflateInit2
    -- simplied considerably deflateInit and inflateInit by not supporting
    +- simplified considerably deflateInit and inflateInit by not supporting
       user-provided history buffer. This is supported only in deflateInit2
    -  and inflateInit2.
    +  and inflateInit2
     
     Changes in 0.3:
     - prefix all macro names with Z_
    -- use Z_FINISH instead of deflateEnd to finish compression.
    +- use Z_FINISH instead of deflateEnd to finish compression
     - added Z_HUFFMAN_ONLY
     - added gzerror()
    diff --git a/src/java.base/share/native/libzip/zlib/README b/src/java.base/share/native/libzip/zlib/README
    index ba34d1894a9..c5f917540b6 100644
    --- a/src/java.base/share/native/libzip/zlib/README
    +++ b/src/java.base/share/native/libzip/zlib/README
    @@ -1,6 +1,6 @@
     ZLIB DATA COMPRESSION LIBRARY
     
    -zlib 1.2.13 is a general purpose data compression library.  All the code is
    +zlib 1.3.1 is a general purpose data compression library.  All the code is
     thread safe.  The data format used by the zlib library is described by RFCs
     (Request for Comments) 1950 to 1952 in the files
     http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
    @@ -29,18 +29,17 @@ PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
     
     Mark Nelson  wrote an article about zlib for the Jan.  1997
     issue of Dr.  Dobb's Journal; a copy of the article is available at
    -http://marknelson.us/1997/01/01/zlib-engine/ .
    +https://marknelson.us/posts/1997/01/01/zlib-engine.html .
     
    -The changes made in version 1.2.13 are documented in the file ChangeLog.
    +The changes made in version 1.3.1 are documented in the file ChangeLog.
     
     Unsupported third party contributions are provided in directory contrib/ .
     
    -zlib is available in Java using the java.util.zip package, documented at
    -http://java.sun.com/developer/technicalArticles/Programming/compression/ .
    +zlib is available in Java using the java.util.zip package. Follow the API
    +Documentation link at: https://docs.oracle.com/search/?q=java.util.zip .
     
    -A Perl interface to zlib written by Paul Marquess  is available
    -at CPAN (Comprehensive Perl Archive Network) sites, including
    -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
    +A Perl interface to zlib and bzip2 written by Paul Marquess 
    +can be found at https://github.com/pmqs/IO-Compress .
     
     A Python interface to zlib written by A.M. Kuchling  is
     available in Python 1.5 and later versions, see
    @@ -64,7 +63,7 @@ Notes for some targets:
     - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
       when compiled with cc.
     
    -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
    +- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is
       necessary to get gzprintf working correctly. This is done by configure.
     
     - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
    @@ -84,7 +83,7 @@ Acknowledgments:
     
     Copyright notice:
     
    - (C) 1995-2022 Jean-loup Gailly and Mark Adler
    + (C) 1995-2024 Jean-loup Gailly and Mark Adler
     
       This software is provided 'as-is', without any express or implied
       warranty.  In no event will the authors be held liable for any damages
    diff --git a/src/java.base/share/native/libzip/zlib/compress.c b/src/java.base/share/native/libzip/zlib/compress.c
    index bc090096785..d7421379673 100644
    --- a/src/java.base/share/native/libzip/zlib/compress.c
    +++ b/src/java.base/share/native/libzip/zlib/compress.c
    @@ -43,13 +43,8 @@
        memory, Z_BUF_ERROR if there was not enough room in the output buffer,
        Z_STREAM_ERROR if the level parameter is invalid.
     */
    -int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
    -    Bytef *dest;
    -    uLongf *destLen;
    -    const Bytef *source;
    -    uLong sourceLen;
    -    int level;
    -{
    +int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
    +                      uLong sourceLen, int level) {
         z_stream stream;
         int err;
         const uInt max = (uInt)-1;
    @@ -89,12 +84,8 @@ int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
     
     /* ===========================================================================
      */
    -int ZEXPORT compress(dest, destLen, source, sourceLen)
    -    Bytef *dest;
    -    uLongf *destLen;
    -    const Bytef *source;
    -    uLong sourceLen;
    -{
    +int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
    +                     uLong sourceLen) {
         return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
     }
     
    @@ -102,9 +93,7 @@ int ZEXPORT compress(dest, destLen, source, sourceLen)
          If the default memLevel or windowBits for deflateInit() is changed, then
        this function needs to be updated.
      */
    -uLong ZEXPORT compressBound(sourceLen)
    -    uLong sourceLen;
    -{
    +uLong ZEXPORT compressBound(uLong sourceLen) {
         return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
                (sourceLen >> 25) + 13;
     }
    diff --git a/src/java.base/share/native/libzip/zlib/deflate.c b/src/java.base/share/native/libzip/zlib/deflate.c
    index 46d512d4200..57fc6802bb8 100644
    --- a/src/java.base/share/native/libzip/zlib/deflate.c
    +++ b/src/java.base/share/native/libzip/zlib/deflate.c
    @@ -23,7 +23,7 @@
      */
     
     /* deflate.c -- compress data using the deflation algorithm
    - * Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
    + * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -76,7 +76,7 @@
     #include "deflate.h"
     
     const char deflate_copyright[] =
    -   " deflate 1.2.13 Copyright 1995-2022 Jean-loup Gailly and Mark Adler ";
    +   " deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler ";
     /*
       If you use the zlib library in a product, an acknowledgment is welcome
       in the documentation of your product. If for some reason you cannot
    @@ -84,9 +84,6 @@ const char deflate_copyright[] =
       copyright string in the executable of your product.
      */
     
    -/* ===========================================================================
    - *  Function prototypes.
    - */
     typedef enum {
         need_more,      /* block not completed, need more input or more output */
         block_done,     /* block flush performed */
    @@ -94,29 +91,16 @@ typedef enum {
         finish_done     /* finish done, accept no more input or output */
     } block_state;
     
    -typedef block_state (*compress_func) OF((deflate_state *s, int flush));
    +typedef block_state (*compress_func)(deflate_state *s, int flush);
     /* Compression function. Returns the block state after the call. */
     
    -local int deflateStateCheck      OF((z_streamp strm));
    -local void slide_hash     OF((deflate_state *s));
    -local void fill_window    OF((deflate_state *s));
    -local block_state deflate_stored OF((deflate_state *s, int flush));
    -local block_state deflate_fast   OF((deflate_state *s, int flush));
    +local block_state deflate_stored(deflate_state *s, int flush);
    +local block_state deflate_fast(deflate_state *s, int flush);
     #ifndef FASTEST
    -local block_state deflate_slow   OF((deflate_state *s, int flush));
    -#endif
    -local block_state deflate_rle    OF((deflate_state *s, int flush));
    -local block_state deflate_huff   OF((deflate_state *s, int flush));
    -local void lm_init        OF((deflate_state *s));
    -local void putShortMSB    OF((deflate_state *s, uInt b));
    -local void flush_pending  OF((z_streamp strm));
    -local unsigned read_buf   OF((z_streamp strm, Bytef *buf, unsigned size));
    -local uInt longest_match  OF((deflate_state *s, IPos cur_match));
    -
    -#ifdef ZLIB_DEBUG
    -local  void check_match OF((deflate_state *s, IPos start, IPos match,
    -                            int length));
    +local block_state deflate_slow(deflate_state *s, int flush);
     #endif
    +local block_state deflate_rle(deflate_state *s, int flush);
    +local block_state deflate_huff(deflate_state *s, int flush);
     
     /* ===========================================================================
      * Local data
    @@ -219,9 +203,12 @@ local const config configuration_table[10] = {
      * bit values at the expense of memory usage). We slide even when level == 0 to
      * keep the hash table consistent if we switch back to level > 0 later.
      */
    -local void slide_hash(s)
    -    deflate_state *s;
    -{
    +#if defined(__has_feature)
    +#  if __has_feature(memory_sanitizer)
    +     __attribute__((no_sanitize("memory")))
    +#  endif
    +#endif
    +local void slide_hash(deflate_state *s) {
         unsigned n, m;
         Posf *p;
         uInt wsize = s->w_size;
    @@ -245,30 +232,177 @@ local void slide_hash(s)
     #endif
     }
     
    +/* ===========================================================================
    + * Read a new buffer from the current input stream, update the adler32
    + * and total number of bytes read.  All deflate() input goes through
    + * this function so some applications may wish to modify it to avoid
    + * allocating a large strm->next_in buffer and copying from it.
    + * (See also flush_pending()).
    + */
    +local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) {
    +    unsigned len = strm->avail_in;
    +
    +    if (len > size) len = size;
    +    if (len == 0) return 0;
    +
    +    strm->avail_in  -= len;
    +
    +    zmemcpy(buf, strm->next_in, len);
    +    if (strm->state->wrap == 1) {
    +        strm->adler = adler32(strm->adler, buf, len);
    +    }
    +#ifdef GZIP
    +    else if (strm->state->wrap == 2) {
    +        strm->adler = crc32(strm->adler, buf, len);
    +    }
    +#endif
    +    strm->next_in  += len;
    +    strm->total_in += len;
    +
    +    return len;
    +}
    +
    +/* ===========================================================================
    + * Fill the window when the lookahead becomes insufficient.
    + * Updates strstart and lookahead.
    + *
    + * IN assertion: lookahead < MIN_LOOKAHEAD
    + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
    + *    At least one byte has been read, or avail_in == 0; reads are
    + *    performed for at least two bytes (required for the zip translate_eol
    + *    option -- not supported here).
    + */
    +local void fill_window(deflate_state *s) {
    +    unsigned n;
    +    unsigned more;    /* Amount of free space at the end of the window. */
    +    uInt wsize = s->w_size;
    +
    +    Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
    +
    +    do {
    +        more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
    +
    +        /* Deal with !@#$% 64K limit: */
    +        if (sizeof(int) <= 2) {
    +            if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
    +                more = wsize;
    +
    +            } else if (more == (unsigned)(-1)) {
    +                /* Very unlikely, but possible on 16 bit machine if
    +                 * strstart == 0 && lookahead == 1 (input done a byte at time)
    +                 */
    +                more--;
    +            }
    +        }
    +
    +        /* If the window is almost full and there is insufficient lookahead,
    +         * move the upper half to the lower one to make room in the upper half.
    +         */
    +        if (s->strstart >= wsize + MAX_DIST(s)) {
    +
    +            zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more);
    +            s->match_start -= wsize;
    +            s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */
    +            s->block_start -= (long) wsize;
    +            if (s->insert > s->strstart)
    +                s->insert = s->strstart;
    +            slide_hash(s);
    +            more += wsize;
    +        }
    +        if (s->strm->avail_in == 0) break;
    +
    +        /* If there was no sliding:
    +         *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
    +         *    more == window_size - lookahead - strstart
    +         * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
    +         * => more >= window_size - 2*WSIZE + 2
    +         * In the BIG_MEM or MMAP case (not yet supported),
    +         *   window_size == input_size + MIN_LOOKAHEAD  &&
    +         *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
    +         * Otherwise, window_size == 2*WSIZE so more >= 2.
    +         * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
    +         */
    +        Assert(more >= 2, "more < 2");
    +
    +        n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
    +        s->lookahead += n;
    +
    +        /* Initialize the hash value now that we have some input: */
    +        if (s->lookahead + s->insert >= MIN_MATCH) {
    +            uInt str = s->strstart - s->insert;
    +            s->ins_h = s->window[str];
    +            UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
    +#if MIN_MATCH != 3
    +            Call UPDATE_HASH() MIN_MATCH-3 more times
    +#endif
    +            while (s->insert) {
    +                UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
    +#ifndef FASTEST
    +                s->prev[str & s->w_mask] = s->head[s->ins_h];
    +#endif
    +                s->head[s->ins_h] = (Pos)str;
    +                str++;
    +                s->insert--;
    +                if (s->lookahead + s->insert < MIN_MATCH)
    +                    break;
    +            }
    +        }
    +        /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
    +         * but this is not important since only literal bytes will be emitted.
    +         */
    +
    +    } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
    +
    +    /* If the WIN_INIT bytes after the end of the current data have never been
    +     * written, then zero those bytes in order to avoid memory check reports of
    +     * the use of uninitialized (or uninitialised as Julian writes) bytes by
    +     * the longest match routines.  Update the high water mark for the next
    +     * time through here.  WIN_INIT is set to MAX_MATCH since the longest match
    +     * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
    +     */
    +    if (s->high_water < s->window_size) {
    +        ulg curr = s->strstart + (ulg)(s->lookahead);
    +        ulg init;
    +
    +        if (s->high_water < curr) {
    +            /* Previous high water mark below current data -- zero WIN_INIT
    +             * bytes or up to end of window, whichever is less.
    +             */
    +            init = s->window_size - curr;
    +            if (init > WIN_INIT)
    +                init = WIN_INIT;
    +            zmemzero(s->window + curr, (unsigned)init);
    +            s->high_water = curr + init;
    +        }
    +        else if (s->high_water < (ulg)curr + WIN_INIT) {
    +            /* High water mark at or above current data, but below current data
    +             * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
    +             * to end of window, whichever is less.
    +             */
    +            init = (ulg)curr + WIN_INIT - s->high_water;
    +            if (init > s->window_size - s->high_water)
    +                init = s->window_size - s->high_water;
    +            zmemzero(s->window + s->high_water, (unsigned)init);
    +            s->high_water += init;
    +        }
    +    }
    +
    +    Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
    +           "not enough room for search");
    +}
    +
     /* ========================================================================= */
    -int ZEXPORT deflateInit_(strm, level, version, stream_size)
    -    z_streamp strm;
    -    int level;
    -    const char *version;
    -    int stream_size;
    -{
    +int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version,
    +                         int stream_size) {
         return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
                              Z_DEFAULT_STRATEGY, version, stream_size);
         /* To do: ignore strm->next_in if we use it as window */
     }
     
     /* ========================================================================= */
    -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
    -                  version, stream_size)
    -    z_streamp strm;
    -    int  level;
    -    int  method;
    -    int  windowBits;
    -    int  memLevel;
    -    int  strategy;
    -    const char *version;
    -    int stream_size;
    -{
    +int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
    +                          int windowBits, int memLevel, int strategy,
    +                          const char *version, int stream_size) {
         deflate_state *s;
         int wrap = 1;
         static const char my_version[] = ZLIB_VERSION;
    @@ -383,7 +517,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
          * symbols from which it is being constructed.
          */
     
    -    s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4);
    +    s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS);
         s->pending_buf_size = (ulg)s->lit_bufsize * 4;
     
         if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
    @@ -393,8 +527,14 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
             deflateEnd (strm);
             return Z_MEM_ERROR;
         }
    +#ifdef LIT_MEM
    +    s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1));
    +    s->l_buf = s->pending_buf + (s->lit_bufsize << 2);
    +    s->sym_end = s->lit_bufsize - 1;
    +#else
         s->sym_buf = s->pending_buf + s->lit_bufsize;
         s->sym_end = (s->lit_bufsize - 1) * 3;
    +#endif
         /* We avoid equality with lit_bufsize*3 because of wraparound at 64K
          * on 16 bit machines and because stored blocks are restricted to
          * 64K-1 bytes.
    @@ -410,9 +550,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
     /* =========================================================================
      * Check for a valid deflate stream state. Return 0 if ok, 1 if not.
      */
    -local int deflateStateCheck(strm)
    -    z_streamp strm;
    -{
    +local int deflateStateCheck(z_streamp strm) {
         deflate_state *s;
         if (strm == Z_NULL ||
             strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
    @@ -433,11 +571,8 @@ local int deflateStateCheck(strm)
     }
     
     /* ========================================================================= */
    -int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength)
    -    z_streamp strm;
    -    const Bytef *dictionary;
    -    uInt  dictLength;
    -{
    +int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary,
    +                                 uInt  dictLength) {
         deflate_state *s;
         uInt str, n;
         int wrap;
    @@ -502,11 +637,8 @@ int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength)
     }
     
     /* ========================================================================= */
    -int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength)
    -    z_streamp strm;
    -    Bytef *dictionary;
    -    uInt  *dictLength;
    -{
    +int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary,
    +                                 uInt *dictLength) {
         deflate_state *s;
         uInt len;
     
    @@ -524,9 +656,7 @@ int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength)
     }
     
     /* ========================================================================= */
    -int ZEXPORT deflateResetKeep(strm)
    -    z_streamp strm;
    -{
    +int ZEXPORT deflateResetKeep(z_streamp strm) {
         deflate_state *s;
     
         if (deflateStateCheck(strm)) {
    @@ -561,10 +691,32 @@ int ZEXPORT deflateResetKeep(strm)
         return Z_OK;
     }
     
    +/* ===========================================================================
    + * Initialize the "longest match" routines for a new zlib stream
    + */
    +local void lm_init(deflate_state *s) {
    +    s->window_size = (ulg)2L*s->w_size;
    +
    +    CLEAR_HASH(s);
    +
    +    /* Set the default configuration parameters:
    +     */
    +    s->max_lazy_match   = configuration_table[s->level].max_lazy;
    +    s->good_match       = configuration_table[s->level].good_length;
    +    s->nice_match       = configuration_table[s->level].nice_length;
    +    s->max_chain_length = configuration_table[s->level].max_chain;
    +
    +    s->strstart = 0;
    +    s->block_start = 0L;
    +    s->lookahead = 0;
    +    s->insert = 0;
    +    s->match_length = s->prev_length = MIN_MATCH-1;
    +    s->match_available = 0;
    +    s->ins_h = 0;
    +}
    +
     /* ========================================================================= */
    -int ZEXPORT deflateReset(strm)
    -    z_streamp strm;
    -{
    +int ZEXPORT deflateReset(z_streamp strm) {
         int ret;
     
         ret = deflateResetKeep(strm);
    @@ -574,10 +726,7 @@ int ZEXPORT deflateReset(strm)
     }
     
     /* ========================================================================= */
    -int ZEXPORT deflateSetHeader(strm, head)
    -    z_streamp strm;
    -    gz_headerp head;
    -{
    +int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) {
         if (deflateStateCheck(strm) || strm->state->wrap != 2)
             return Z_STREAM_ERROR;
         strm->state->gzhead = head;
    @@ -585,11 +734,7 @@ int ZEXPORT deflateSetHeader(strm, head)
     }
     
     /* ========================================================================= */
    -int ZEXPORT deflatePending(strm, pending, bits)
    -    unsigned *pending;
    -    int *bits;
    -    z_streamp strm;
    -{
    +int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
         if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
         if (pending != Z_NULL)
             *pending = strm->state->pending;
    @@ -599,19 +744,21 @@ int ZEXPORT deflatePending(strm, pending, bits)
     }
     
     /* ========================================================================= */
    -int ZEXPORT deflatePrime(strm, bits, value)
    -    z_streamp strm;
    -    int bits;
    -    int value;
    -{
    +int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
         deflate_state *s;
         int put;
     
         if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
         s = strm->state;
    +#ifdef LIT_MEM
    +    if (bits < 0 || bits > 16 ||
    +        (uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3))
    +        return Z_BUF_ERROR;
    +#else
         if (bits < 0 || bits > 16 ||
             s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3))
             return Z_BUF_ERROR;
    +#endif
         do {
             put = Buf_size - s->bi_valid;
             if (put > bits)
    @@ -626,11 +773,7 @@ int ZEXPORT deflatePrime(strm, bits, value)
     }
     
     /* ========================================================================= */
    -int ZEXPORT deflateParams(strm, level, strategy)
    -    z_streamp strm;
    -    int level;
    -    int strategy;
    -{
    +int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) {
         deflate_state *s;
         compress_func func;
     
    @@ -675,13 +818,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
     }
     
     /* ========================================================================= */
    -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
    -    z_streamp strm;
    -    int good_length;
    -    int max_lazy;
    -    int nice_length;
    -    int max_chain;
    -{
    +int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy,
    +                        int nice_length, int max_chain) {
         deflate_state *s;
     
         if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
    @@ -717,10 +855,7 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
      *
      * Shifts are used to approximate divisions, for speed.
      */
    -uLong ZEXPORT deflateBound(strm, sourceLen)
    -    z_streamp strm;
    -    uLong sourceLen;
    -{
    +uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
         deflate_state *s;
         uLong fixedlen, storelen, wraplen;
     
    @@ -776,7 +911,8 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
     
         /* if not default parameters, return one of the conservative bounds */
         if (s->w_bits != 15 || s->hash_bits != 8 + 7)
    -        return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen;
    +        return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) +
    +               wraplen;
     
         /* default settings: return tight bound for that case -- ~0.03% overhead
            plus a small constant */
    @@ -789,10 +925,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
      * IN assertion: the stream state is correct and there is enough room in
      * pending_buf.
      */
    -local void putShortMSB(s, b)
    -    deflate_state *s;
    -    uInt b;
    -{
    +local void putShortMSB(deflate_state *s, uInt b) {
         put_byte(s, (Byte)(b >> 8));
         put_byte(s, (Byte)(b & 0xff));
     }
    @@ -803,9 +936,7 @@ local void putShortMSB(s, b)
      * applications may wish to modify it to avoid allocating a large
      * strm->next_out buffer and copying into it. (See also read_buf()).
      */
    -local void flush_pending(strm)
    -    z_streamp strm;
    -{
    +local void flush_pending(z_streamp strm) {
         unsigned len;
         deflate_state *s = strm->state;
     
    @@ -836,10 +967,7 @@ local void flush_pending(strm)
         } while (0)
     
     /* ========================================================================= */
    -int ZEXPORT deflate(strm, flush)
    -    z_streamp strm;
    -    int flush;
    -{
    +int ZEXPORT deflate(z_streamp strm, int flush) {
         int old_flush; /* value of flush param for previous deflate call */
         deflate_state *s;
     
    @@ -1151,9 +1279,7 @@ int ZEXPORT deflate(strm, flush)
     }
     
     /* ========================================================================= */
    -int ZEXPORT deflateEnd(strm)
    -    z_streamp strm;
    -{
    +int ZEXPORT deflateEnd(z_streamp strm) {
         int status;
     
         if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
    @@ -1177,11 +1303,10 @@ int ZEXPORT deflateEnd(strm)
      * To simplify the source, this is not supported for 16-bit MSDOS (which
      * doesn't have enough memory anyway to duplicate compression states).
      */
    -int ZEXPORT deflateCopy(dest, source)
    -    z_streamp dest;
    -    z_streamp source;
    -{
    +int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
     #ifdef MAXSEG_64K
    +    (void)dest;
    +    (void)source;
         return Z_STREAM_ERROR;
     #else
         deflate_state *ds;
    @@ -1205,7 +1330,7 @@ int ZEXPORT deflateCopy(dest, source)
         ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
         ds->prev   = (Posf *)  ZALLOC(dest, ds->w_size, sizeof(Pos));
         ds->head   = (Posf *)  ZALLOC(dest, ds->hash_size, sizeof(Pos));
    -    ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4);
    +    ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS);
     
         if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
             ds->pending_buf == Z_NULL) {
    @@ -1216,10 +1341,15 @@ int ZEXPORT deflateCopy(dest, source)
         zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
         zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
         zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
    -    zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
    +    zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS);
     
         ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
    +#ifdef LIT_MEM
    +    ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1));
    +    ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2);
    +#else
         ds->sym_buf = ds->pending_buf + ds->lit_bufsize;
    +#endif
     
         ds->l_desc.dyn_tree = ds->dyn_ltree;
         ds->d_desc.dyn_tree = ds->dyn_dtree;
    @@ -1229,66 +1359,6 @@ int ZEXPORT deflateCopy(dest, source)
     #endif /* MAXSEG_64K */
     }
     
    -/* ===========================================================================
    - * Read a new buffer from the current input stream, update the adler32
    - * and total number of bytes read.  All deflate() input goes through
    - * this function so some applications may wish to modify it to avoid
    - * allocating a large strm->next_in buffer and copying from it.
    - * (See also flush_pending()).
    - */
    -local unsigned read_buf(strm, buf, size)
    -    z_streamp strm;
    -    Bytef *buf;
    -    unsigned size;
    -{
    -    unsigned len = strm->avail_in;
    -
    -    if (len > size) len = size;
    -    if (len == 0) return 0;
    -
    -    strm->avail_in  -= len;
    -
    -    zmemcpy(buf, strm->next_in, len);
    -    if (strm->state->wrap == 1) {
    -        strm->adler = adler32(strm->adler, buf, len);
    -    }
    -#ifdef GZIP
    -    else if (strm->state->wrap == 2) {
    -        strm->adler = crc32(strm->adler, buf, len);
    -    }
    -#endif
    -    strm->next_in  += len;
    -    strm->total_in += len;
    -
    -    return len;
    -}
    -
    -/* ===========================================================================
    - * Initialize the "longest match" routines for a new zlib stream
    - */
    -local void lm_init(s)
    -    deflate_state *s;
    -{
    -    s->window_size = (ulg)2L*s->w_size;
    -
    -    CLEAR_HASH(s);
    -
    -    /* Set the default configuration parameters:
    -     */
    -    s->max_lazy_match   = configuration_table[s->level].max_lazy;
    -    s->good_match       = configuration_table[s->level].good_length;
    -    s->nice_match       = configuration_table[s->level].nice_length;
    -    s->max_chain_length = configuration_table[s->level].max_chain;
    -
    -    s->strstart = 0;
    -    s->block_start = 0L;
    -    s->lookahead = 0;
    -    s->insert = 0;
    -    s->match_length = s->prev_length = MIN_MATCH-1;
    -    s->match_available = 0;
    -    s->ins_h = 0;
    -}
    -
     #ifndef FASTEST
     /* ===========================================================================
      * Set match_start to the longest match starting at the given string and
    @@ -1299,10 +1369,7 @@ local void lm_init(s)
      *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
      * OUT assertion: the match length is not greater than s->lookahead.
      */
    -local uInt longest_match(s, cur_match)
    -    deflate_state *s;
    -    IPos cur_match;                             /* current match */
    -{
    +local uInt longest_match(deflate_state *s, IPos cur_match) {
         unsigned chain_length = s->max_chain_length;/* max hash chain length */
         register Bytef *scan = s->window + s->strstart; /* current string */
         register Bytef *match;                      /* matched string */
    @@ -1450,10 +1517,7 @@ local uInt longest_match(s, cur_match)
     /* ---------------------------------------------------------------------------
      * Optimized version for FASTEST only
      */
    -local uInt longest_match(s, cur_match)
    -    deflate_state *s;
    -    IPos cur_match;                             /* current match */
    -{
    +local uInt longest_match(deflate_state *s, IPos cur_match) {
         register Bytef *scan = s->window + s->strstart; /* current string */
         register Bytef *match;                       /* matched string */
         register int len;                           /* length of current match */
    @@ -1514,19 +1578,23 @@ local uInt longest_match(s, cur_match)
     /* ===========================================================================
      * Check that the match at match_start is indeed a match.
      */
    -local void check_match(s, start, match, length)
    -    deflate_state *s;
    -    IPos start, match;
    -    int length;
    -{
    +local void check_match(deflate_state *s, IPos start, IPos match, int length) {
         /* check that the match is indeed a match */
    -    if (zmemcmp(s->window + match,
    -                s->window + start, length) != EQUAL) {
    -        fprintf(stderr, " start %u, match %u, length %d\n",
    -                start, match, length);
    +    Bytef *back = s->window + (int)match, *here = s->window + start;
    +    IPos len = length;
    +    if (match == (IPos)-1) {
    +        /* match starts one byte before the current window -- just compare the
    +           subsequent length-1 bytes */
    +        back++;
    +        here++;
    +        len--;
    +    }
    +    if (zmemcmp(back, here, len) != EQUAL) {
    +        fprintf(stderr, " start %u, match %d, length %d\n",
    +                start, (int)match, length);
             do {
    -            fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
    -        } while (--length != 0);
    +            fprintf(stderr, "(%02x %02x)", *back++, *here++);
    +        } while (--len != 0);
             z_error("invalid match");
         }
         if (z_verbose > 1) {
    @@ -1538,137 +1606,6 @@ local void check_match(s, start, match, length)
     #  define check_match(s, start, match, length)
     #endif /* ZLIB_DEBUG */
     
    -/* ===========================================================================
    - * Fill the window when the lookahead becomes insufficient.
    - * Updates strstart and lookahead.
    - *
    - * IN assertion: lookahead < MIN_LOOKAHEAD
    - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
    - *    At least one byte has been read, or avail_in == 0; reads are
    - *    performed for at least two bytes (required for the zip translate_eol
    - *    option -- not supported here).
    - */
    -local void fill_window(s)
    -    deflate_state *s;
    -{
    -    unsigned n;
    -    unsigned more;    /* Amount of free space at the end of the window. */
    -    uInt wsize = s->w_size;
    -
    -    Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
    -
    -    do {
    -        more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
    -
    -        /* Deal with !@#$% 64K limit: */
    -        if (sizeof(int) <= 2) {
    -            if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
    -                more = wsize;
    -
    -            } else if (more == (unsigned)(-1)) {
    -                /* Very unlikely, but possible on 16 bit machine if
    -                 * strstart == 0 && lookahead == 1 (input done a byte at time)
    -                 */
    -                more--;
    -            }
    -        }
    -
    -        /* If the window is almost full and there is insufficient lookahead,
    -         * move the upper half to the lower one to make room in the upper half.
    -         */
    -        if (s->strstart >= wsize + MAX_DIST(s)) {
    -
    -            zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more);
    -            s->match_start -= wsize;
    -            s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */
    -            s->block_start -= (long) wsize;
    -            if (s->insert > s->strstart)
    -                s->insert = s->strstart;
    -            slide_hash(s);
    -            more += wsize;
    -        }
    -        if (s->strm->avail_in == 0) break;
    -
    -        /* If there was no sliding:
    -         *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
    -         *    more == window_size - lookahead - strstart
    -         * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
    -         * => more >= window_size - 2*WSIZE + 2
    -         * In the BIG_MEM or MMAP case (not yet supported),
    -         *   window_size == input_size + MIN_LOOKAHEAD  &&
    -         *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
    -         * Otherwise, window_size == 2*WSIZE so more >= 2.
    -         * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
    -         */
    -        Assert(more >= 2, "more < 2");
    -
    -        n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
    -        s->lookahead += n;
    -
    -        /* Initialize the hash value now that we have some input: */
    -        if (s->lookahead + s->insert >= MIN_MATCH) {
    -            uInt str = s->strstart - s->insert;
    -            s->ins_h = s->window[str];
    -            UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
    -#if MIN_MATCH != 3
    -            Call UPDATE_HASH() MIN_MATCH-3 more times
    -#endif
    -            while (s->insert) {
    -                UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
    -#ifndef FASTEST
    -                s->prev[str & s->w_mask] = s->head[s->ins_h];
    -#endif
    -                s->head[s->ins_h] = (Pos)str;
    -                str++;
    -                s->insert--;
    -                if (s->lookahead + s->insert < MIN_MATCH)
    -                    break;
    -            }
    -        }
    -        /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
    -         * but this is not important since only literal bytes will be emitted.
    -         */
    -
    -    } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
    -
    -    /* If the WIN_INIT bytes after the end of the current data have never been
    -     * written, then zero those bytes in order to avoid memory check reports of
    -     * the use of uninitialized (or uninitialised as Julian writes) bytes by
    -     * the longest match routines.  Update the high water mark for the next
    -     * time through here.  WIN_INIT is set to MAX_MATCH since the longest match
    -     * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
    -     */
    -    if (s->high_water < s->window_size) {
    -        ulg curr = s->strstart + (ulg)(s->lookahead);
    -        ulg init;
    -
    -        if (s->high_water < curr) {
    -            /* Previous high water mark below current data -- zero WIN_INIT
    -             * bytes or up to end of window, whichever is less.
    -             */
    -            init = s->window_size - curr;
    -            if (init > WIN_INIT)
    -                init = WIN_INIT;
    -            zmemzero(s->window + curr, (unsigned)init);
    -            s->high_water = curr + init;
    -        }
    -        else if (s->high_water < (ulg)curr + WIN_INIT) {
    -            /* High water mark at or above current data, but below current data
    -             * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
    -             * to end of window, whichever is less.
    -             */
    -            init = (ulg)curr + WIN_INIT - s->high_water;
    -            if (init > s->window_size - s->high_water)
    -                init = s->window_size - s->high_water;
    -            zmemzero(s->window + s->high_water, (unsigned)init);
    -            s->high_water += init;
    -        }
    -    }
    -
    -    Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
    -           "not enough room for search");
    -}
    -
     /* ===========================================================================
      * Flush the current block, with given end-of-file flag.
      * IN assertion: strstart is set to the end of the current match.
    @@ -1711,10 +1648,7 @@ local void fill_window(s)
      * copied. It is most efficient with large input and output buffers, which
      * maximizes the opportunities to have a single copy from next_in to next_out.
      */
    -local block_state deflate_stored(s, flush)
    -    deflate_state *s;
    -    int flush;
    -{
    +local block_state deflate_stored(deflate_state *s, int flush) {
         /* Smallest worthy block size when not flushing or finishing. By default
          * this is 32K. This can be as small as 507 bytes for memLevel == 1. For
          * large input and output buffers, the stored block size will be larger.
    @@ -1898,10 +1832,7 @@ local block_state deflate_stored(s, flush)
      * new strings in the dictionary only for unmatched strings or for short
      * matches. It is used only for the fast compression options.
      */
    -local block_state deflate_fast(s, flush)
    -    deflate_state *s;
    -    int flush;
    -{
    +local block_state deflate_fast(deflate_state *s, int flush) {
         IPos hash_head;       /* head of the hash chain */
         int bflush;           /* set if current block must be flushed */
     
    @@ -2000,10 +1931,7 @@ local block_state deflate_fast(s, flush)
      * evaluation for matches: a match is finally adopted only if there is
      * no better match at the next window position.
      */
    -local block_state deflate_slow(s, flush)
    -    deflate_state *s;
    -    int flush;
    -{
    +local block_state deflate_slow(deflate_state *s, int flush) {
         IPos hash_head;          /* head of hash chain */
         int bflush;              /* set if current block must be flushed */
     
    @@ -2131,10 +2059,7 @@ local block_state deflate_slow(s, flush)
      * one.  Do not maintain a hash table.  (It will be regenerated if this run of
      * deflate switches away from Z_RLE.)
      */
    -local block_state deflate_rle(s, flush)
    -    deflate_state *s;
    -    int flush;
    -{
    +local block_state deflate_rle(deflate_state *s, int flush) {
         int bflush;             /* set if current block must be flushed */
         uInt prev;              /* byte at distance one to match */
         Bytef *scan, *strend;   /* scan goes up to strend for length of run */
    @@ -2205,10 +2130,7 @@ local block_state deflate_rle(s, flush)
      * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.
      * (It will be regenerated if this run of deflate switches away from Huffman.)
      */
    -local block_state deflate_huff(s, flush)
    -    deflate_state *s;
    -    int flush;
    -{
    +local block_state deflate_huff(deflate_state *s, int flush) {
         int bflush;             /* set if current block must be flushed */
     
         for (;;) {
    diff --git a/src/java.base/share/native/libzip/zlib/deflate.h b/src/java.base/share/native/libzip/zlib/deflate.h
    index b73f5a04e14..830d46b8894 100644
    --- a/src/java.base/share/native/libzip/zlib/deflate.h
    +++ b/src/java.base/share/native/libzip/zlib/deflate.h
    @@ -23,7 +23,7 @@
      */
     
     /* deflate.h -- internal compression state
    - * Copyright (C) 1995-2018 Jean-loup Gailly
    + * Copyright (C) 1995-2024 Jean-loup Gailly
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -47,6 +47,10 @@
     #  define GZIP
     #endif
     
    +/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
    +   the cost of a larger memory footprint */
    +/* #define LIT_MEM */
    +
     /* ===========================================================================
      * Internal compression state.
      */
    @@ -241,7 +245,14 @@ typedef struct internal_state {
         /* Depth of each subtree used as tie breaker for trees of equal frequency
          */
     
    +#ifdef LIT_MEM
    +#   define LIT_BUFS 5
    +    ushf *d_buf;          /* buffer for distances */
    +    uchf *l_buf;          /* buffer for literals/lengths */
    +#else
    +#   define LIT_BUFS 4
         uchf *sym_buf;        /* buffer for distances and literals/lengths */
    +#endif
     
         uInt  lit_bufsize;
         /* Size of match buffer for literals/lengths.  There are 4 reasons for
    @@ -263,7 +274,7 @@ typedef struct internal_state {
          *   - I can't count above 4
          */
     
    -    uInt sym_next;      /* running index in sym_buf */
    +    uInt sym_next;      /* running index in symbol buffer */
         uInt sym_end;       /* symbol table full when sym_next reaches this */
     
         ulg opt_len;        /* bit length of current block with optimal trees */
    @@ -315,14 +326,14 @@ typedef struct internal_state {
        memory checker errors from longest match routines */
     
             /* in trees.c */
    -void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
    -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
    -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
    -                        ulg stored_len, int last));
    -void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
    -void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
    -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
    -                        ulg stored_len, int last));
    +void ZLIB_INTERNAL _tr_init(deflate_state *s);
    +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
    +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
    +                                   ulg stored_len, int last);
    +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
    +void ZLIB_INTERNAL _tr_align(deflate_state *s);
    +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
    +                                    ulg stored_len, int last);
     
     #define d_code(dist) \
        ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
    @@ -342,6 +353,25 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
       extern const uch ZLIB_INTERNAL _dist_code[];
     #endif
     
    +#ifdef LIT_MEM
    +# define _tr_tally_lit(s, c, flush) \
    +  { uch cc = (c); \
    +    s->d_buf[s->sym_next] = 0; \
    +    s->l_buf[s->sym_next++] = cc; \
    +    s->dyn_ltree[cc].Freq++; \
    +    flush = (s->sym_next == s->sym_end); \
    +   }
    +# define _tr_tally_dist(s, distance, length, flush) \
    +  { uch len = (uch)(length); \
    +    ush dist = (ush)(distance); \
    +    s->d_buf[s->sym_next] = dist; \
    +    s->l_buf[s->sym_next++] = len; \
    +    dist--; \
    +    s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
    +    s->dyn_dtree[d_code(dist)].Freq++; \
    +    flush = (s->sym_next == s->sym_end); \
    +  }
    +#else
     # define _tr_tally_lit(s, c, flush) \
       { uch cc = (c); \
         s->sym_buf[s->sym_next++] = 0; \
    @@ -361,6 +391,7 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
         s->dyn_dtree[d_code(dist)].Freq++; \
         flush = (s->sym_next == s->sym_end); \
       }
    +#endif
     #else
     # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
     # define _tr_tally_dist(s, distance, length, flush) \
    diff --git a/src/java.base/share/native/libzip/zlib/gzclose.c b/src/java.base/share/native/libzip/zlib/gzclose.c
    index 5cce4b03d2f..eff53ace042 100644
    --- a/src/java.base/share/native/libzip/zlib/gzclose.c
    +++ b/src/java.base/share/native/libzip/zlib/gzclose.c
    @@ -32,9 +32,7 @@
     /* gzclose() is in a separate file so that it is linked in only if it is used.
        That way the other gzclose functions can be used instead to avoid linking in
        unneeded compression or decompression routines. */
    -int ZEXPORT gzclose(file)
    -    gzFile file;
    -{
    +int ZEXPORT gzclose(gzFile file) {
     #ifndef NO_GZCOMPRESS
         gz_statep state;
     
    diff --git a/src/java.base/share/native/libzip/zlib/gzguts.h b/src/java.base/share/native/libzip/zlib/gzguts.h
    index 81bedce5445..8cce2c69d24 100644
    --- a/src/java.base/share/native/libzip/zlib/gzguts.h
    +++ b/src/java.base/share/native/libzip/zlib/gzguts.h
    @@ -23,7 +23,7 @@
      */
     
     /* gzguts.h -- zlib internal header definitions for gz* operations
    - * Copyright (C) 2004-2019 Mark Adler
    + * Copyright (C) 2004-2024 Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -31,9 +31,8 @@
     #  ifndef _LARGEFILE_SOURCE
     #    define _LARGEFILE_SOURCE 1
     #  endif
    -#  ifdef _FILE_OFFSET_BITS
    -#    undef _FILE_OFFSET_BITS
    -#  endif
    +#  undef _FILE_OFFSET_BITS
    +#  undef _TIME_BITS
     #endif
     
     #ifdef HAVE_HIDDEN
    @@ -143,8 +142,8 @@
     
     /* gz* functions always use library allocation functions */
     #ifndef STDC
    -  extern voidp  malloc OF((uInt size));
    -  extern void   free   OF((voidpf ptr));
    +  extern voidp  malloc(uInt size);
    +  extern void   free(voidpf ptr);
     #endif
     
     /* get errno and strerror definition */
    @@ -162,10 +161,10 @@
     
     /* provide prototypes for these when building zlib without LFS */
     #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
    -    ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
    -    ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
    -    ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
    -    ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
    +    ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
    +    ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
    +    ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
    +    ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
     #endif
     
     /* default memLevel */
    @@ -227,17 +226,13 @@ typedef struct {
     typedef gz_state FAR *gz_statep;
     
     /* shared functions */
    -void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
    +void ZLIB_INTERNAL gz_error(gz_statep, int, const char *);
     #if defined UNDER_CE
    -char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
    +char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
     #endif
     
     /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
        value -- needed when comparing unsigned to z_off64_t, which is signed
        (possible z_off64_t types off_t, off64_t, and long are all signed) */
    -#ifdef INT_MAX
    -#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
    -#else
    -unsigned ZLIB_INTERNAL gz_intmax OF((void));
    -#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
    -#endif
    +unsigned ZLIB_INTERNAL gz_intmax(void);
    +#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
    diff --git a/src/java.base/share/native/libzip/zlib/gzlib.c b/src/java.base/share/native/libzip/zlib/gzlib.c
    index 1cbc6d25b16..0f4dfae64a0 100644
    --- a/src/java.base/share/native/libzip/zlib/gzlib.c
    +++ b/src/java.base/share/native/libzip/zlib/gzlib.c
    @@ -23,7 +23,7 @@
      */
     
     /* gzlib.c -- zlib functions common to reading and writing gzip files
    - * Copyright (C) 2004-2019 Mark Adler
    + * Copyright (C) 2004-2024 Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -39,10 +39,6 @@
     #endif
     #endif
     
    -/* Local functions */
    -local void gz_reset OF((gz_statep));
    -local gzFile gz_open OF((const void *, int, const char *));
    -
     #if defined UNDER_CE
     
     /* Map the Windows error number in ERROR to a locale-dependent error message
    @@ -54,9 +50,7 @@ local gzFile gz_open OF((const void *, int, const char *));
     
        The gz_strwinerror function does not change the current setting of
        GetLastError. */
    -char ZLIB_INTERNAL *gz_strwinerror(error)
    -     DWORD error;
    -{
    +char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
         static char buf[1024];
     
         wchar_t *msgbuf;
    @@ -96,9 +90,7 @@ char ZLIB_INTERNAL *gz_strwinerror(error)
     #endif /* UNDER_CE */
     
     /* Reset gzip file state */
    -local void gz_reset(state)
    -    gz_statep state;
    -{
    +local void gz_reset(gz_statep state) {
         state->x.have = 0;              /* no output data available */
         if (state->mode == GZ_READ) {   /* for reading ... */
             state->eof = 0;             /* not at end of file */
    @@ -114,11 +106,7 @@ local void gz_reset(state)
     }
     
     /* Open a gzip file either by name or file descriptor. */
    -local gzFile gz_open(path, fd, mode)
    -    const void *path;
    -    int fd;
    -    const char *mode;
    -{
    +local gzFile gz_open(const void *path, int fd, const char *mode) {
         gz_statep state;
         z_size_t len;
         int oflag;
    @@ -293,26 +281,17 @@ local gzFile gz_open(path, fd, mode)
     }
     
     /* -- see zlib.h -- */
    -gzFile ZEXPORT gzopen(path, mode)
    -    const char *path;
    -    const char *mode;
    -{
    +gzFile ZEXPORT gzopen(const char *path, const char *mode) {
         return gz_open(path, -1, mode);
     }
     
     /* -- see zlib.h -- */
    -gzFile ZEXPORT gzopen64(path, mode)
    -    const char *path;
    -    const char *mode;
    -{
    +gzFile ZEXPORT gzopen64(const char *path, const char *mode) {
         return gz_open(path, -1, mode);
     }
     
     /* -- see zlib.h -- */
    -gzFile ZEXPORT gzdopen(fd, mode)
    -    int fd;
    -    const char *mode;
    -{
    +gzFile ZEXPORT gzdopen(int fd, const char *mode) {
         char *path;         /* identifier for error messages */
         gzFile gz;
     
    @@ -330,19 +309,13 @@ gzFile ZEXPORT gzdopen(fd, mode)
     
     /* -- see zlib.h -- */
     #ifdef WIDECHAR
    -gzFile ZEXPORT gzopen_w(path, mode)
    -    const wchar_t *path;
    -    const char *mode;
    -{
    +gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) {
         return gz_open(path, -2, mode);
     }
     #endif
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzbuffer(file, size)
    -    gzFile file;
    -    unsigned size;
    -{
    +int ZEXPORT gzbuffer(gzFile file, unsigned size) {
         gz_statep state;
     
         /* get internal structure and check integrity */
    @@ -359,16 +332,14 @@ int ZEXPORT gzbuffer(file, size)
         /* check and set requested size */
         if ((size << 1) < size)
             return -1;              /* need to be able to double it */
    -    if (size < 2)
    -        size = 2;               /* need two bytes to check magic header */
    +    if (size < 8)
    +        size = 8;               /* needed to behave well with flushing */
         state->want = size;
         return 0;
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzrewind(file)
    -    gzFile file;
    -{
    +int ZEXPORT gzrewind(gzFile file) {
         gz_statep state;
     
         /* get internal structure */
    @@ -389,11 +360,7 @@ int ZEXPORT gzrewind(file)
     }
     
     /* -- see zlib.h -- */
    -z_off64_t ZEXPORT gzseek64(file, offset, whence)
    -    gzFile file;
    -    z_off64_t offset;
    -    int whence;
    -{
    +z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
         unsigned n;
         z_off64_t ret;
         gz_statep state;
    @@ -466,11 +433,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
     }
     
     /* -- see zlib.h -- */
    -z_off_t ZEXPORT gzseek(file, offset, whence)
    -    gzFile file;
    -    z_off_t offset;
    -    int whence;
    -{
    +z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
         z_off64_t ret;
     
         ret = gzseek64(file, (z_off64_t)offset, whence);
    @@ -478,9 +441,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence)
     }
     
     /* -- see zlib.h -- */
    -z_off64_t ZEXPORT gztell64(file)
    -    gzFile file;
    -{
    +z_off64_t ZEXPORT gztell64(gzFile file) {
         gz_statep state;
     
         /* get internal structure and check integrity */
    @@ -495,9 +456,7 @@ z_off64_t ZEXPORT gztell64(file)
     }
     
     /* -- see zlib.h -- */
    -z_off_t ZEXPORT gztell(file)
    -    gzFile file;
    -{
    +z_off_t ZEXPORT gztell(gzFile file) {
         z_off64_t ret;
     
         ret = gztell64(file);
    @@ -505,9 +464,7 @@ z_off_t ZEXPORT gztell(file)
     }
     
     /* -- see zlib.h -- */
    -z_off64_t ZEXPORT gzoffset64(file)
    -    gzFile file;
    -{
    +z_off64_t ZEXPORT gzoffset64(gzFile file) {
         z_off64_t offset;
         gz_statep state;
     
    @@ -528,9 +485,7 @@ z_off64_t ZEXPORT gzoffset64(file)
     }
     
     /* -- see zlib.h -- */
    -z_off_t ZEXPORT gzoffset(file)
    -    gzFile file;
    -{
    +z_off_t ZEXPORT gzoffset(gzFile file) {
         z_off64_t ret;
     
         ret = gzoffset64(file);
    @@ -538,9 +493,7 @@ z_off_t ZEXPORT gzoffset(file)
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzeof(file)
    -    gzFile file;
    -{
    +int ZEXPORT gzeof(gzFile file) {
         gz_statep state;
     
         /* get internal structure and check integrity */
    @@ -555,10 +508,7 @@ int ZEXPORT gzeof(file)
     }
     
     /* -- see zlib.h -- */
    -const char * ZEXPORT gzerror(file, errnum)
    -    gzFile file;
    -    int *errnum;
    -{
    +const char * ZEXPORT gzerror(gzFile file, int *errnum) {
         gz_statep state;
     
         /* get internal structure and check integrity */
    @@ -576,9 +526,7 @@ const char * ZEXPORT gzerror(file, errnum)
     }
     
     /* -- see zlib.h -- */
    -void ZEXPORT gzclearerr(file)
    -    gzFile file;
    -{
    +void ZEXPORT gzclearerr(gzFile file) {
         gz_statep state;
     
         /* get internal structure and check integrity */
    @@ -602,11 +550,7 @@ void ZEXPORT gzclearerr(file)
        memory).  Simply save the error message as a static string.  If there is an
        allocation failure constructing the error message, then convert the error to
        out of memory. */
    -void ZLIB_INTERNAL gz_error(state, err, msg)
    -    gz_statep state;
    -    int err;
    -    const char *msg;
    -{
    +void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
         /* free previously allocated message and clear */
         if (state->msg != NULL) {
             if (state->err != Z_MEM_ERROR)
    @@ -643,21 +587,20 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
     #endif
     }
     
    -#ifndef INT_MAX
     /* portably return maximum value for an int (when limits.h presumed not
        available) -- we need to do this to cover cases where 2's complement not
        used, since C standard permits 1's complement and sign-bit representations,
        otherwise we could just use ((unsigned)-1) >> 1 */
    -unsigned ZLIB_INTERNAL gz_intmax()
    -{
    -    unsigned p, q;
    -
    -    p = 1;
    +unsigned ZLIB_INTERNAL gz_intmax(void) {
    +#ifdef INT_MAX
    +    return INT_MAX;
    +#else
    +    unsigned p = 1, q;
         do {
             q = p;
             p <<= 1;
             p++;
         } while (p > q);
         return q >> 1;
    -}
     #endif
    +}
    diff --git a/src/java.base/share/native/libzip/zlib/gzread.c b/src/java.base/share/native/libzip/zlib/gzread.c
    index fbe4281b4e0..7b9c9df5fa1 100644
    --- a/src/java.base/share/native/libzip/zlib/gzread.c
    +++ b/src/java.base/share/native/libzip/zlib/gzread.c
    @@ -29,25 +29,12 @@
     
     #include "gzguts.h"
     
    -/* Local functions */
    -local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
    -local int gz_avail OF((gz_statep));
    -local int gz_look OF((gz_statep));
    -local int gz_decomp OF((gz_statep));
    -local int gz_fetch OF((gz_statep));
    -local int gz_skip OF((gz_statep, z_off64_t));
    -local z_size_t gz_read OF((gz_statep, voidp, z_size_t));
    -
     /* Use read() to load a buffer -- return -1 on error, otherwise 0.  Read from
        state->fd, and update state->eof, state->err, and state->msg as appropriate.
        This function needs to loop on read(), since read() is not guaranteed to
        read the number of bytes requested, depending on the type of descriptor. */
    -local int gz_load(state, buf, len, have)
    -    gz_statep state;
    -    unsigned char *buf;
    -    unsigned len;
    -    unsigned *have;
    -{
    +local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
    +                  unsigned *have) {
         int ret;
         unsigned get, max = ((unsigned)-1 >> 2) + 1;
     
    @@ -77,9 +64,7 @@ local int gz_load(state, buf, len, have)
        If strm->avail_in != 0, then the current data is moved to the beginning of
        the input buffer, and then the remainder of the buffer is loaded with the
        available data from the input file. */
    -local int gz_avail(state)
    -    gz_statep state;
    -{
    +local int gz_avail(gz_statep state) {
         unsigned got;
         z_streamp strm = &(state->strm);
     
    @@ -112,9 +97,7 @@ local int gz_avail(state)
        case, all further file reads will be directly to either the output buffer or
        a user buffer.  If decompressing, the inflate state will be initialized.
        gz_look() will return 0 on success or -1 on failure. */
    -local int gz_look(state)
    -    gz_statep state;
    -{
    +local int gz_look(gz_statep state) {
         z_streamp strm = &(state->strm);
     
         /* allocate read buffers and inflate memory */
    @@ -194,9 +177,7 @@ local int gz_look(state)
        data.  If the gzip stream completes, state->how is reset to LOOK to look for
        the next gzip stream or raw data, once state->x.have is depleted.  Returns 0
        on success, -1 on failure. */
    -local int gz_decomp(state)
    -    gz_statep state;
    -{
    +local int gz_decomp(gz_statep state) {
         int ret = Z_OK;
         unsigned had;
         z_streamp strm = &(state->strm);
    @@ -248,9 +229,7 @@ local int gz_decomp(state)
        looked for to determine whether to copy or decompress.  Returns -1 on error,
        otherwise 0.  gz_fetch() will leave state->how as COPY or GZIP unless the
        end of the input file has been reached and all data has been processed.  */
    -local int gz_fetch(state)
    -    gz_statep state;
    -{
    +local int gz_fetch(gz_statep state) {
         z_streamp strm = &(state->strm);
     
         do {
    @@ -278,10 +257,7 @@ local int gz_fetch(state)
     }
     
     /* Skip len uncompressed bytes of output.  Return -1 on error, 0 on success. */
    -local int gz_skip(state, len)
    -    gz_statep state;
    -    z_off64_t len;
    -{
    +local int gz_skip(gz_statep state, z_off64_t len) {
         unsigned n;
     
         /* skip over len bytes or reach end-of-file, whichever comes first */
    @@ -313,11 +289,7 @@ local int gz_skip(state, len)
        input.  Return the number of bytes read.  If zero is returned, either the
        end of file was reached, or there was an error.  state->err must be
        consulted in that case to determine which. */
    -local z_size_t gz_read(state, buf, len)
    -    gz_statep state;
    -    voidp buf;
    -    z_size_t len;
    -{
    +local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
         z_size_t got;
         unsigned n;
     
    @@ -394,11 +366,7 @@ local z_size_t gz_read(state, buf, len)
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzread(file, buf, len)
    -    gzFile file;
    -    voidp buf;
    -    unsigned len;
    -{
    +int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
         gz_statep state;
     
         /* get internal structure */
    @@ -430,12 +398,7 @@ int ZEXPORT gzread(file, buf, len)
     }
     
     /* -- see zlib.h -- */
    -z_size_t ZEXPORT gzfread(buf, size, nitems, file)
    -    voidp buf;
    -    z_size_t size;
    -    z_size_t nitems;
    -    gzFile file;
    -{
    +z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) {
         z_size_t len;
         gz_statep state;
     
    @@ -466,9 +429,7 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file)
     #else
     #  undef gzgetc
     #endif
    -int ZEXPORT gzgetc(file)
    -    gzFile file;
    -{
    +int ZEXPORT gzgetc(gzFile file) {
         unsigned char buf[1];
         gz_statep state;
     
    @@ -493,17 +454,12 @@ int ZEXPORT gzgetc(file)
         return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
     }
     
    -int ZEXPORT gzgetc_(file)
    -gzFile file;
    -{
    +int ZEXPORT gzgetc_(gzFile file) {
         return gzgetc(file);
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzungetc(c, file)
    -    int c;
    -    gzFile file;
    -{
    +int ZEXPORT gzungetc(int c, gzFile file) {
         gz_statep state;
     
         /* get internal structure */
    @@ -511,6 +467,10 @@ int ZEXPORT gzungetc(c, file)
             return -1;
         state = (gz_statep)file;
     
    +    /* in case this was just opened, set up the input buffer */
    +    if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
    +        (void)gz_look(state);
    +
         /* check that we're reading and that there's no (serious) error */
         if (state->mode != GZ_READ ||
             (state->err != Z_OK && state->err != Z_BUF_ERROR))
    @@ -560,11 +520,7 @@ int ZEXPORT gzungetc(c, file)
     }
     
     /* -- see zlib.h -- */
    -char * ZEXPORT gzgets(file, buf, len)
    -    gzFile file;
    -    char *buf;
    -    int len;
    -{
    +char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
         unsigned left, n;
         char *str;
         unsigned char *eol;
    @@ -624,9 +580,7 @@ char * ZEXPORT gzgets(file, buf, len)
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzdirect(file)
    -    gzFile file;
    -{
    +int ZEXPORT gzdirect(gzFile file) {
         gz_statep state;
     
         /* get internal structure */
    @@ -644,9 +598,7 @@ int ZEXPORT gzdirect(file)
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzclose_r(file)
    -    gzFile file;
    -{
    +int ZEXPORT gzclose_r(gzFile file) {
         int ret, err;
         gz_statep state;
     
    diff --git a/src/java.base/share/native/libzip/zlib/gzwrite.c b/src/java.base/share/native/libzip/zlib/gzwrite.c
    index 3aff44cc940..008b03e7021 100644
    --- a/src/java.base/share/native/libzip/zlib/gzwrite.c
    +++ b/src/java.base/share/native/libzip/zlib/gzwrite.c
    @@ -29,18 +29,10 @@
     
     #include "gzguts.h"
     
    -/* Local functions */
    -local int gz_init OF((gz_statep));
    -local int gz_comp OF((gz_statep, int));
    -local int gz_zero OF((gz_statep, z_off64_t));
    -local z_size_t gz_write OF((gz_statep, voidpc, z_size_t));
    -
     /* Initialize state for writing a gzip file.  Mark initialization by setting
        state->size to non-zero.  Return -1 on a memory allocation failure, or 0 on
        success. */
    -local int gz_init(state)
    -    gz_statep state;
    -{
    +local int gz_init(gz_statep state) {
         int ret;
         z_streamp strm = &(state->strm);
     
    @@ -94,10 +86,7 @@ local int gz_init(state)
        deflate() flush value.  If flush is Z_FINISH, then the deflate() state is
        reset to start a new gzip stream.  If gz->direct is true, then simply write
        to the output file without compressing, and ignore flush. */
    -local int gz_comp(state, flush)
    -    gz_statep state;
    -    int flush;
    -{
    +local int gz_comp(gz_statep state, int flush) {
         int ret, writ;
         unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
         z_streamp strm = &(state->strm);
    @@ -175,10 +164,7 @@ local int gz_comp(state, flush)
     
     /* Compress len zeros to output.  Return -1 on a write error or memory
        allocation failure by gz_comp(), or 0 on success. */
    -local int gz_zero(state, len)
    -    gz_statep state;
    -    z_off64_t len;
    -{
    +local int gz_zero(gz_statep state, z_off64_t len) {
         int first;
         unsigned n;
         z_streamp strm = &(state->strm);
    @@ -208,11 +194,7 @@ local int gz_zero(state, len)
     
     /* Write len bytes from buf to file.  Return the number of bytes written.  If
        the returned value is less than len, then there was an error. */
    -local z_size_t gz_write(state, buf, len)
    -    gz_statep state;
    -    voidpc buf;
    -    z_size_t len;
    -{
    +local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
         z_size_t put = len;
     
         /* if len is zero, avoid unnecessary operations */
    @@ -276,11 +258,7 @@ local z_size_t gz_write(state, buf, len)
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzwrite(file, buf, len)
    -    gzFile file;
    -    voidpc buf;
    -    unsigned len;
    -{
    +int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
         gz_statep state;
     
         /* get internal structure */
    @@ -304,12 +282,8 @@ int ZEXPORT gzwrite(file, buf, len)
     }
     
     /* -- see zlib.h -- */
    -z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
    -    voidpc buf;
    -    z_size_t size;
    -    z_size_t nitems;
    -    gzFile file;
    -{
    +z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
    +                          gzFile file) {
         z_size_t len;
         gz_statep state;
     
    @@ -334,10 +308,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzputc(file, c)
    -    gzFile file;
    -    int c;
    -{
    +int ZEXPORT gzputc(gzFile file, int c) {
         unsigned have;
         unsigned char buf[1];
         gz_statep state;
    @@ -382,10 +353,7 @@ int ZEXPORT gzputc(file, c)
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzputs(file, s)
    -    gzFile file;
    -    const char *s;
    -{
    +int ZEXPORT gzputs(gzFile file, const char *s) {
         z_size_t len, put;
         gz_statep state;
     
    @@ -412,8 +380,7 @@ int ZEXPORT gzputs(file, s)
     #include 
     
     /* -- see zlib.h -- */
    -int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
    -{
    +int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
         int len;
         unsigned left;
         char *next;
    @@ -484,8 +451,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
         return len;
     }
     
    -int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
    -{
    +int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
         va_list va;
         int ret;
     
    @@ -498,13 +464,10 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
     #else /* !STDC && !Z_HAVE_STDARG_H */
     
     /* -- see zlib.h -- */
    -int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
    -                       a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
    -    gzFile file;
    -    const char *format;
    -    int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
    -        a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
    -{
    +int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
    +                       int a4, int a5, int a6, int a7, int a8, int a9, int a10,
    +                       int a11, int a12, int a13, int a14, int a15, int a16,
    +                       int a17, int a18, int a19, int a20) {
         unsigned len, left;
         char *next;
         gz_statep state;
    @@ -586,10 +549,7 @@ int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
     #endif
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzflush(file, flush)
    -    gzFile file;
    -    int flush;
    -{
    +int ZEXPORT gzflush(gzFile file, int flush) {
         gz_statep state;
     
         /* get internal structure */
    @@ -618,11 +578,7 @@ int ZEXPORT gzflush(file, flush)
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzsetparams(file, level, strategy)
    -    gzFile file;
    -    int level;
    -    int strategy;
    -{
    +int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
         gz_statep state;
         z_streamp strm;
     
    @@ -633,7 +589,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
         strm = &(state->strm);
     
         /* check that we're writing and that there's no error */
    -    if (state->mode != GZ_WRITE || state->err != Z_OK)
    +    if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct)
             return Z_STREAM_ERROR;
     
         /* if no change is requested, then do nothing */
    @@ -660,9 +616,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
     }
     
     /* -- see zlib.h -- */
    -int ZEXPORT gzclose_w(file)
    -    gzFile file;
    -{
    +int ZEXPORT gzclose_w(gzFile file) {
         int ret = Z_OK;
         gz_statep state;
     
    diff --git a/src/java.base/share/native/libzip/zlib/infback.c b/src/java.base/share/native/libzip/zlib/infback.c
    index ea7ea83d8d2..f680e2cdbdc 100644
    --- a/src/java.base/share/native/libzip/zlib/infback.c
    +++ b/src/java.base/share/native/libzip/zlib/infback.c
    @@ -39,9 +39,6 @@
     #include "inflate.h"
     #include "inffast.h"
     
    -/* function prototypes */
    -local void fixedtables OF((struct inflate_state FAR *state));
    -
     /*
        strm provides memory allocation functions in zalloc and zfree, or
        Z_NULL to use the library memory allocation functions.
    @@ -49,13 +46,9 @@ local void fixedtables OF((struct inflate_state FAR *state));
        windowBits is in the range 8..15, and window is a user-supplied
        window and output buffer that is 2**windowBits bytes.
      */
    -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
    -z_streamp strm;
    -int windowBits;
    -unsigned char FAR *window;
    -const char *version;
    -int stream_size;
    -{
    +int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
    +                             unsigned char FAR *window, const char *version,
    +                             int stream_size) {
         struct inflate_state FAR *state;
     
         if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
    @@ -104,9 +97,7 @@ int stream_size;
        used for threaded applications, since the rewriting of the tables and virgin
        may not be thread-safe.
      */
    -local void fixedtables(state)
    -struct inflate_state FAR *state;
    -{
    +local void fixedtables(struct inflate_state FAR *state) {
     #ifdef BUILDFIXED
         static int virgin = 1;
         static code *lenfix, *distfix;
    @@ -272,13 +263,8 @@ struct inflate_state FAR *state;
        inflateBack() can also return Z_STREAM_ERROR if the input parameters
        are not correct, i.e. strm is Z_NULL or the state was not initialized.
      */
    -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
    -z_streamp strm;
    -in_func in;
    -void FAR *in_desc;
    -out_func out;
    -void FAR *out_desc;
    -{
    +int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
    +                        out_func out, void FAR *out_desc) {
         struct inflate_state FAR *state;
         z_const unsigned char FAR *next;    /* next input */
         unsigned char FAR *put;     /* next output */
    @@ -656,9 +642,7 @@ void FAR *out_desc;
         return ret;
     }
     
    -int ZEXPORT inflateBackEnd(strm)
    -z_streamp strm;
    -{
    +int ZEXPORT inflateBackEnd(z_streamp strm) {
         if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
             return Z_STREAM_ERROR;
         ZFREE(strm, strm->state);
    diff --git a/src/java.base/share/native/libzip/zlib/inffast.c b/src/java.base/share/native/libzip/zlib/inffast.c
    index 45aa17d201f..e86dd78d801 100644
    --- a/src/java.base/share/native/libzip/zlib/inffast.c
    +++ b/src/java.base/share/native/libzip/zlib/inffast.c
    @@ -71,10 +71,7 @@
           requires strm->avail_out >= 258 for each loop to avoid checking for
           output space.
      */
    -void ZLIB_INTERNAL inflate_fast(strm, start)
    -z_streamp strm;
    -unsigned start;         /* inflate()'s starting value for strm->avail_out */
    -{
    +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
         struct inflate_state FAR *state;
         z_const unsigned char FAR *in;      /* local strm->next_in */
         z_const unsigned char FAR *last;    /* have enough input while in < last */
    diff --git a/src/java.base/share/native/libzip/zlib/inffast.h b/src/java.base/share/native/libzip/zlib/inffast.h
    index b8da8bb757a..bc4fb6b0df8 100644
    --- a/src/java.base/share/native/libzip/zlib/inffast.h
    +++ b/src/java.base/share/native/libzip/zlib/inffast.h
    @@ -32,4 +32,4 @@
        subject to change. Applications should only use zlib.h.
      */
     
    -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
    +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start);
    diff --git a/src/java.base/share/native/libzip/zlib/inflate.c b/src/java.base/share/native/libzip/zlib/inflate.c
    index b236dcafd80..3370cfe9565 100644
    --- a/src/java.base/share/native/libzip/zlib/inflate.c
    +++ b/src/java.base/share/native/libzip/zlib/inflate.c
    @@ -115,20 +115,7 @@
     #  endif
     #endif
     
    -/* function prototypes */
    -local int inflateStateCheck OF((z_streamp strm));
    -local void fixedtables OF((struct inflate_state FAR *state));
    -local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
    -                           unsigned copy));
    -#ifdef BUILDFIXED
    -   void makefixed OF((void));
    -#endif
    -local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
    -                              unsigned len));
    -
    -local int inflateStateCheck(strm)
    -z_streamp strm;
    -{
    +local int inflateStateCheck(z_streamp strm) {
         struct inflate_state FAR *state;
         if (strm == Z_NULL ||
             strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
    @@ -140,9 +127,7 @@ z_streamp strm;
         return 0;
     }
     
    -int ZEXPORT inflateResetKeep(strm)
    -z_streamp strm;
    -{
    +int ZEXPORT inflateResetKeep(z_streamp strm) {
         struct inflate_state FAR *state;
     
         if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
    @@ -166,9 +151,7 @@ z_streamp strm;
         return Z_OK;
     }
     
    -int ZEXPORT inflateReset(strm)
    -z_streamp strm;
    -{
    +int ZEXPORT inflateReset(z_streamp strm) {
         struct inflate_state FAR *state;
     
         if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
    @@ -179,10 +162,7 @@ z_streamp strm;
         return inflateResetKeep(strm);
     }
     
    -int ZEXPORT inflateReset2(strm, windowBits)
    -z_streamp strm;
    -int windowBits;
    -{
    +int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
         int wrap;
         struct inflate_state FAR *state;
     
    @@ -219,12 +199,8 @@ int windowBits;
         return inflateReset(strm);
     }
     
    -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
    -z_streamp strm;
    -int windowBits;
    -const char *version;
    -int stream_size;
    -{
    +int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,
    +                          const char *version, int stream_size) {
         int ret;
         struct inflate_state FAR *state;
     
    @@ -263,22 +239,17 @@ int stream_size;
         return ret;
     }
     
    -int ZEXPORT inflateInit_(strm, version, stream_size)
    -z_streamp strm;
    -const char *version;
    -int stream_size;
    -{
    +int ZEXPORT inflateInit_(z_streamp strm, const char *version,
    +                         int stream_size) {
         return inflateInit2_(strm, DEF_WBITS, version, stream_size);
     }
     
    -int ZEXPORT inflatePrime(strm, bits, value)
    -z_streamp strm;
    -int bits;
    -int value;
    -{
    +int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) {
         struct inflate_state FAR *state;
     
         if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
    +    if (bits == 0)
    +        return Z_OK;
         state = (struct inflate_state FAR *)strm->state;
         if (bits < 0) {
             state->hold = 0;
    @@ -302,9 +273,7 @@ int value;
        used for threaded applications, since the rewriting of the tables and virgin
        may not be thread-safe.
      */
    -local void fixedtables(state)
    -struct inflate_state FAR *state;
    -{
    +local void fixedtables(struct inflate_state FAR *state) {
     #ifdef BUILDFIXED
         static int virgin = 1;
         static code *lenfix, *distfix;
    @@ -366,7 +335,7 @@ struct inflate_state FAR *state;
     
         a.out > inffixed.h
      */
    -void makefixed()
    +void makefixed(void)
     {
         unsigned low, size;
         struct inflate_state state;
    @@ -420,11 +389,7 @@ void makefixed()
        output will fall in the output data, making match copies simpler and faster.
        The advantage may be dependent on the size of the processor's data caches.
      */
    -local int updatewindow(strm, end, copy)
    -z_streamp strm;
    -const Bytef *end;
    -unsigned copy;
    -{
    +local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) {
         struct inflate_state FAR *state;
         unsigned dist;
     
    @@ -646,10 +611,7 @@ unsigned copy;
        will return Z_BUF_ERROR if it has not reached the end of the stream.
      */
     
    -int ZEXPORT inflate(strm, flush)
    -z_streamp strm;
    -int flush;
    -{
    +int ZEXPORT inflate(z_streamp strm, int flush) {
         struct inflate_state FAR *state;
         z_const unsigned char FAR *next;    /* next input */
         unsigned char FAR *put;     /* next output */
    @@ -1325,9 +1287,7 @@ int flush;
         return ret;
     }
     
    -int ZEXPORT inflateEnd(strm)
    -z_streamp strm;
    -{
    +int ZEXPORT inflateEnd(z_streamp strm) {
         struct inflate_state FAR *state;
         if (inflateStateCheck(strm))
             return Z_STREAM_ERROR;
    @@ -1339,11 +1299,8 @@ z_streamp strm;
         return Z_OK;
     }
     
    -int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
    -z_streamp strm;
    -Bytef *dictionary;
    -uInt *dictLength;
    -{
    +int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary,
    +                                 uInt *dictLength) {
         struct inflate_state FAR *state;
     
         /* check state */
    @@ -1362,11 +1319,8 @@ uInt *dictLength;
         return Z_OK;
     }
     
    -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
    -z_streamp strm;
    -const Bytef *dictionary;
    -uInt dictLength;
    -{
    +int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
    +                                 uInt dictLength) {
         struct inflate_state FAR *state;
         unsigned long dictid;
         int ret;
    @@ -1397,10 +1351,7 @@ uInt dictLength;
         return Z_OK;
     }
     
    -int ZEXPORT inflateGetHeader(strm, head)
    -z_streamp strm;
    -gz_headerp head;
    -{
    +int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) {
         struct inflate_state FAR *state;
     
         /* check state */
    @@ -1425,11 +1376,8 @@ gz_headerp head;
        called again with more data and the *have state.  *have is initialized to
        zero for the first call.
      */
    -local unsigned syncsearch(have, buf, len)
    -unsigned FAR *have;
    -const unsigned char FAR *buf;
    -unsigned len;
    -{
    +local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf,
    +                          unsigned len) {
         unsigned got;
         unsigned next;
     
    @@ -1448,9 +1396,7 @@ unsigned len;
         return next;
     }
     
    -int ZEXPORT inflateSync(strm)
    -z_streamp strm;
    -{
    +int ZEXPORT inflateSync(z_streamp strm) {
         unsigned len;               /* number of bytes to look at or looked at */
         int flags;                  /* temporary to save header status */
         unsigned long in, out;      /* temporary to save total_in and total_out */
    @@ -1465,7 +1411,7 @@ z_streamp strm;
         /* if first time, start search in bit buffer */
         if (state->mode != SYNC) {
             state->mode = SYNC;
    -        state->hold <<= state->bits & 7;
    +        state->hold >>= state->bits & 7;
             state->bits -= state->bits & 7;
             len = 0;
             while (state->bits >= 8) {
    @@ -1506,9 +1452,7 @@ z_streamp strm;
        block. When decompressing, PPP checks that at the end of input packet,
        inflate is waiting for these length bytes.
      */
    -int ZEXPORT inflateSyncPoint(strm)
    -z_streamp strm;
    -{
    +int ZEXPORT inflateSyncPoint(z_streamp strm) {
         struct inflate_state FAR *state;
     
         if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
    @@ -1516,10 +1460,7 @@ z_streamp strm;
         return state->mode == STORED && state->bits == 0;
     }
     
    -int ZEXPORT inflateCopy(dest, source)
    -z_streamp dest;
    -z_streamp source;
    -{
    +int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
         struct inflate_state FAR *state;
         struct inflate_state FAR *copy;
         unsigned char FAR *window;
    @@ -1563,10 +1504,7 @@ z_streamp source;
         return Z_OK;
     }
     
    -int ZEXPORT inflateUndermine(strm, subvert)
    -z_streamp strm;
    -int subvert;
    -{
    +int ZEXPORT inflateUndermine(z_streamp strm, int subvert) {
         struct inflate_state FAR *state;
     
         if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
    @@ -1581,10 +1519,7 @@ int subvert;
     #endif
     }
     
    -int ZEXPORT inflateValidate(strm, check)
    -z_streamp strm;
    -int check;
    -{
    +int ZEXPORT inflateValidate(z_streamp strm, int check) {
         struct inflate_state FAR *state;
     
         if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
    @@ -1596,9 +1531,7 @@ int check;
         return Z_OK;
     }
     
    -long ZEXPORT inflateMark(strm)
    -z_streamp strm;
    -{
    +long ZEXPORT inflateMark(z_streamp strm) {
         struct inflate_state FAR *state;
     
         if (inflateStateCheck(strm))
    @@ -1609,9 +1542,7 @@ z_streamp strm;
                 (state->mode == MATCH ? state->was - state->length : 0));
     }
     
    -unsigned long ZEXPORT inflateCodesUsed(strm)
    -z_streamp strm;
    -{
    +unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) {
         struct inflate_state FAR *state;
         if (inflateStateCheck(strm)) return (unsigned long)-1;
         state = (struct inflate_state FAR *)strm->state;
    diff --git a/src/java.base/share/native/libzip/zlib/inftrees.c b/src/java.base/share/native/libzip/zlib/inftrees.c
    index a60b1bfb393..c4913bc4359 100644
    --- a/src/java.base/share/native/libzip/zlib/inftrees.c
    +++ b/src/java.base/share/native/libzip/zlib/inftrees.c
    @@ -23,7 +23,7 @@
      */
     
     /* inftrees.c -- generate Huffman trees for efficient decoding
    - * Copyright (C) 1995-2022 Mark Adler
    + * Copyright (C) 1995-2024 Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -33,7 +33,7 @@
     #define MAXBITS 15
     
     const char inflate_copyright[] =
    -   " inflate 1.2.13 Copyright 1995-2022 Mark Adler ";
    +   " inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
     /*
       If you use the zlib library in a product, an acknowledgment is welcome
       in the documentation of your product. If for some reason you cannot
    @@ -53,14 +53,9 @@ const char inflate_copyright[] =
        table index bits.  It will differ if the request is greater than the
        longest code or if it is less than the shortest code.
      */
    -int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)
    -codetype type;
    -unsigned short FAR *lens;
    -unsigned codes;
    -code FAR * FAR *table;
    -unsigned FAR *bits;
    -unsigned short FAR *work;
    -{
    +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
    +                                unsigned codes, code FAR * FAR *table,
    +                                unsigned FAR *bits, unsigned short FAR *work) {
         unsigned len;               /* a code's length in bits */
         unsigned sym;               /* index of code symbols */
         unsigned min, max;          /* minimum and maximum code lengths */
    @@ -86,7 +81,7 @@ unsigned short FAR *work;
             35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
         static const unsigned short lext[31] = { /* Length codes 257..285 extra */
             16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
    -        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 194, 65};
    +        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
         static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
             1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
             257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
    diff --git a/src/java.base/share/native/libzip/zlib/inftrees.h b/src/java.base/share/native/libzip/zlib/inftrees.h
    index a05314fefbd..3e2e889301d 100644
    --- a/src/java.base/share/native/libzip/zlib/inftrees.h
    +++ b/src/java.base/share/native/libzip/zlib/inftrees.h
    @@ -65,8 +65,8 @@ typedef struct {
        examples/enough.c found in the zlib distribution.  The arguments to that
        program are the number of symbols, the initial root table size, and the
        maximum bit length of a code.  "enough 286 9 15" for literal/length codes
    -   returns returns 852, and "enough 30 6 15" for distance codes returns 592.
    -   The initial root table size (9 or 6) is found in the fifth argument of the
    +   returns 852, and "enough 30 6 15" for distance codes returns 592. The
    +   initial root table size (9 or 6) is found in the fifth argument of the
        inflate_table() calls in inflate.c and infback.c.  If the root table size is
        changed, then these maximum sizes would be need to be recalculated and
        updated. */
    @@ -81,6 +81,6 @@ typedef enum {
         DISTS
     } codetype;
     
    -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
    -                             unsigned codes, code FAR * FAR *table,
    -                             unsigned FAR *bits, unsigned short FAR *work));
    +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
    +                                unsigned codes, code FAR * FAR *table,
    +                                unsigned FAR *bits, unsigned short FAR *work);
    diff --git a/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java b/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
    index ff48fdaea06..3296c5f2fad 100644
    --- a/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
    +++ b/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
    @@ -1,4 +1,4 @@
    -Changes from zlib 1.2.13
    +Changes from zlib 1.3.1
     
     (1) renamed adler32.c -> zadler32.c, crc32c -> zcrc32.c
     
    diff --git a/src/java.base/share/native/libzip/zlib/trees.c b/src/java.base/share/native/libzip/zlib/trees.c
    index 7214373826f..bbfa9deee5b 100644
    --- a/src/java.base/share/native/libzip/zlib/trees.c
    +++ b/src/java.base/share/native/libzip/zlib/trees.c
    @@ -23,7 +23,7 @@
      */
     
     /* trees.c -- output deflated data using Huffman coding
    - * Copyright (C) 1995-2021 Jean-loup Gailly
    + * Copyright (C) 1995-2024 Jean-loup Gailly
      * detect_data_type() function provided freely by Cosmin Truta, 2006
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
    @@ -146,39 +146,116 @@ struct static_tree_desc_s {
         int     max_length;          /* max bit length for the codes */
     };
     
    -local const static_tree_desc  static_l_desc =
    +#ifdef NO_INIT_GLOBAL_POINTERS
    +#  define TCONST
    +#else
    +#  define TCONST const
    +#endif
    +
    +local TCONST static_tree_desc static_l_desc =
     {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
     
    -local const static_tree_desc  static_d_desc =
    +local TCONST static_tree_desc static_d_desc =
     {static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS};
     
    -local const static_tree_desc  static_bl_desc =
    +local TCONST static_tree_desc static_bl_desc =
     {(const ct_data *)0, extra_blbits, 0,   BL_CODES, MAX_BL_BITS};
     
     /* ===========================================================================
    - * Local (static) routines in this file.
    + * Output a short LSB first on the stream.
    + * IN assertion: there is enough room in pendingBuf.
    + */
    +#define put_short(s, w) { \
    +    put_byte(s, (uch)((w) & 0xff)); \
    +    put_byte(s, (uch)((ush)(w) >> 8)); \
    +}
    +
    +/* ===========================================================================
    + * Reverse the first len bits of a code, using straightforward code (a faster
    + * method would use a table)
    + * IN assertion: 1 <= len <= 15
      */
    +local unsigned bi_reverse(unsigned code, int len) {
    +    register unsigned res = 0;
    +    do {
    +        res |= code & 1;
    +        code >>= 1, res <<= 1;
    +    } while (--len > 0);
    +    return res >> 1;
    +}
     
    -local void tr_static_init OF((void));
    -local void init_block     OF((deflate_state *s));
    -local void pqdownheap     OF((deflate_state *s, ct_data *tree, int k));
    -local void gen_bitlen     OF((deflate_state *s, tree_desc *desc));
    -local void gen_codes      OF((ct_data *tree, int max_code, ushf *bl_count));
    -local void build_tree     OF((deflate_state *s, tree_desc *desc));
    -local void scan_tree      OF((deflate_state *s, ct_data *tree, int max_code));
    -local void send_tree      OF((deflate_state *s, ct_data *tree, int max_code));
    -local int  build_bl_tree  OF((deflate_state *s));
    -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
    -                              int blcodes));
    -local void compress_block OF((deflate_state *s, const ct_data *ltree,
    -                              const ct_data *dtree));
    -local int  detect_data_type OF((deflate_state *s));
    -local unsigned bi_reverse OF((unsigned code, int len));
    -local void bi_windup      OF((deflate_state *s));
    -local void bi_flush       OF((deflate_state *s));
    +/* ===========================================================================
    + * Flush the bit buffer, keeping at most 7 bits in it.
    + */
    +local void bi_flush(deflate_state *s) {
    +    if (s->bi_valid == 16) {
    +        put_short(s, s->bi_buf);
    +        s->bi_buf = 0;
    +        s->bi_valid = 0;
    +    } else if (s->bi_valid >= 8) {
    +        put_byte(s, (Byte)s->bi_buf);
    +        s->bi_buf >>= 8;
    +        s->bi_valid -= 8;
    +    }
    +}
    +
    +/* ===========================================================================
    + * Flush the bit buffer and align the output on a byte boundary
    + */
    +local void bi_windup(deflate_state *s) {
    +    if (s->bi_valid > 8) {
    +        put_short(s, s->bi_buf);
    +    } else if (s->bi_valid > 0) {
    +        put_byte(s, (Byte)s->bi_buf);
    +    }
    +    s->bi_buf = 0;
    +    s->bi_valid = 0;
    +#ifdef ZLIB_DEBUG
    +    s->bits_sent = (s->bits_sent + 7) & ~7;
    +#endif
    +}
    +
    +/* ===========================================================================
    + * Generate the codes for a given tree and bit counts (which need not be
    + * optimal).
    + * IN assertion: the array bl_count contains the bit length statistics for
    + * the given tree and the field len is set for all tree elements.
    + * OUT assertion: the field code is set for all tree elements of non
    + *     zero code length.
    + */
    +local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) {
    +    ush next_code[MAX_BITS+1]; /* next code value for each bit length */
    +    unsigned code = 0;         /* running code value */
    +    int bits;                  /* bit index */
    +    int n;                     /* code index */
    +
    +    /* The distribution counts are first used to generate the code values
    +     * without bit reversal.
    +     */
    +    for (bits = 1; bits <= MAX_BITS; bits++) {
    +        code = (code + bl_count[bits - 1]) << 1;
    +        next_code[bits] = (ush)code;
    +    }
    +    /* Check that the bit counts in bl_count are consistent. The last code
    +     * must be all ones.
    +     */
    +    Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
    +            "inconsistent bit counts");
    +    Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
    +
    +    for (n = 0;  n <= max_code; n++) {
    +        int len = tree[n].Len;
    +        if (len == 0) continue;
    +        /* Now reverse the bits */
    +        tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
    +
    +        Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
    +            n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
    +    }
    +}
     
     #ifdef GEN_TREES_H
    -local void gen_trees_header OF((void));
    +local void gen_trees_header(void);
     #endif
     
     #ifndef ZLIB_DEBUG
    @@ -191,27 +268,12 @@ local void gen_trees_header OF((void));
            send_bits(s, tree[c].Code, tree[c].Len); }
     #endif
     
    -/* ===========================================================================
    - * Output a short LSB first on the stream.
    - * IN assertion: there is enough room in pendingBuf.
    - */
    -#define put_short(s, w) { \
    -    put_byte(s, (uch)((w) & 0xff)); \
    -    put_byte(s, (uch)((ush)(w) >> 8)); \
    -}
    -
     /* ===========================================================================
      * Send a value on a given number of bits.
      * IN assertion: length <= 16 and value fits in length bits.
      */
     #ifdef ZLIB_DEBUG
    -local void send_bits      OF((deflate_state *s, int value, int length));
    -
    -local void send_bits(s, value, length)
    -    deflate_state *s;
    -    int value;  /* value to send */
    -    int length; /* number of bits */
    -{
    +local void send_bits(deflate_state *s, int value, int length) {
         Tracevv((stderr," l %2d v %4x ", length, value));
         Assert(length > 0 && length <= 15, "invalid length");
         s->bits_sent += (ulg)length;
    @@ -253,8 +315,7 @@ local void send_bits(s, value, length)
     /* ===========================================================================
      * Initialize the various 'constant' tables.
      */
    -local void tr_static_init()
    -{
    +local void tr_static_init(void) {
     #if defined(GEN_TREES_H) || !defined(STDC)
         static int static_init_done = 0;
         int n;        /* iterates over tree elements */
    @@ -347,8 +408,7 @@ local void tr_static_init()
           ((i) == (last)? "\n};\n\n" :    \
            ((i) % (width) == (width) - 1 ? ",\n" : ", "))
     
    -void gen_trees_header()
    -{
    +void gen_trees_header(void) {
         FILE *header = fopen("trees.h", "w");
         int i;
     
    @@ -397,12 +457,26 @@ void gen_trees_header()
     }
     #endif /* GEN_TREES_H */
     
    +/* ===========================================================================
    + * Initialize a new block.
    + */
    +local void init_block(deflate_state *s) {
    +    int n; /* iterates over tree elements */
    +
    +    /* Initialize the trees. */
    +    for (n = 0; n < L_CODES;  n++) s->dyn_ltree[n].Freq = 0;
    +    for (n = 0; n < D_CODES;  n++) s->dyn_dtree[n].Freq = 0;
    +    for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
    +
    +    s->dyn_ltree[END_BLOCK].Freq = 1;
    +    s->opt_len = s->static_len = 0L;
    +    s->sym_next = s->matches = 0;
    +}
    +
     /* ===========================================================================
      * Initialize the tree data structures for a new zlib stream.
      */
    -void ZLIB_INTERNAL _tr_init(s)
    -    deflate_state *s;
    -{
    +void ZLIB_INTERNAL _tr_init(deflate_state *s) {
         tr_static_init();
     
         s->l_desc.dyn_tree = s->dyn_ltree;
    @@ -425,24 +499,6 @@ void ZLIB_INTERNAL _tr_init(s)
         init_block(s);
     }
     
    -/* ===========================================================================
    - * Initialize a new block.
    - */
    -local void init_block(s)
    -    deflate_state *s;
    -{
    -    int n; /* iterates over tree elements */
    -
    -    /* Initialize the trees. */
    -    for (n = 0; n < L_CODES;  n++) s->dyn_ltree[n].Freq = 0;
    -    for (n = 0; n < D_CODES;  n++) s->dyn_dtree[n].Freq = 0;
    -    for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
    -
    -    s->dyn_ltree[END_BLOCK].Freq = 1;
    -    s->opt_len = s->static_len = 0L;
    -    s->sym_next = s->matches = 0;
    -}
    -
     #define SMALLEST 1
     /* Index within the heap array of least frequent node in the Huffman tree */
     
    @@ -472,11 +528,7 @@ local void init_block(s)
      * when the heap property is re-established (each father smaller than its
      * two sons).
      */
    -local void pqdownheap(s, tree, k)
    -    deflate_state *s;
    -    ct_data *tree;  /* the tree to restore */
    -    int k;               /* node to move down */
    -{
    +local void pqdownheap(deflate_state *s, ct_data *tree, int k) {
         int v = s->heap[k];
         int j = k << 1;  /* left son of k */
         while (j <= s->heap_len) {
    @@ -507,10 +559,7 @@ local void pqdownheap(s, tree, k)
      *     The length opt_len is updated; static_len is also updated if stree is
      *     not null.
      */
    -local void gen_bitlen(s, desc)
    -    deflate_state *s;
    -    tree_desc *desc;    /* the tree descriptor */
    -{
    +local void gen_bitlen(deflate_state *s, tree_desc *desc) {
         ct_data *tree        = desc->dyn_tree;
         int max_code         = desc->max_code;
         const ct_data *stree = desc->stat_desc->static_tree;
    @@ -585,48 +634,9 @@ local void gen_bitlen(s, desc)
         }
     }
     
    -/* ===========================================================================
    - * Generate the codes for a given tree and bit counts (which need not be
    - * optimal).
    - * IN assertion: the array bl_count contains the bit length statistics for
    - * the given tree and the field len is set for all tree elements.
    - * OUT assertion: the field code is set for all tree elements of non
    - *     zero code length.
    - */
    -local void gen_codes(tree, max_code, bl_count)
    -    ct_data *tree;             /* the tree to decorate */
    -    int max_code;              /* largest code with non zero frequency */
    -    ushf *bl_count;            /* number of codes at each bit length */
    -{
    -    ush next_code[MAX_BITS+1]; /* next code value for each bit length */
    -    unsigned code = 0;         /* running code value */
    -    int bits;                  /* bit index */
    -    int n;                     /* code index */
    -
    -    /* The distribution counts are first used to generate the code values
    -     * without bit reversal.
    -     */
    -    for (bits = 1; bits <= MAX_BITS; bits++) {
    -        code = (code + bl_count[bits - 1]) << 1;
    -        next_code[bits] = (ush)code;
    -    }
    -    /* Check that the bit counts in bl_count are consistent. The last code
    -     * must be all ones.
    -     */
    -    Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
    -            "inconsistent bit counts");
    -    Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
    -
    -    for (n = 0;  n <= max_code; n++) {
    -        int len = tree[n].Len;
    -        if (len == 0) continue;
    -        /* Now reverse the bits */
    -        tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
    -
    -        Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
    -            n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
    -    }
    -}
    +#ifdef DUMP_BL_TREE
    +#  include 
    +#endif
     
     /* ===========================================================================
      * Construct one Huffman tree and assigns the code bit strings and lengths.
    @@ -636,10 +646,7 @@ local void gen_codes(tree, max_code, bl_count)
      *     and corresponding code. The length opt_len is updated; static_len is
      *     also updated if stree is not null. The field max_code is set.
      */
    -local void build_tree(s, desc)
    -    deflate_state *s;
    -    tree_desc *desc; /* the tree descriptor */
    -{
    +local void build_tree(deflate_state *s, tree_desc *desc) {
         ct_data *tree         = desc->dyn_tree;
         const ct_data *stree  = desc->stat_desc->static_tree;
         int elems             = desc->stat_desc->elems;
    @@ -724,11 +731,7 @@ local void build_tree(s, desc)
      * Scan a literal or distance tree to determine the frequencies of the codes
      * in the bit length tree.
      */
    -local void scan_tree(s, tree, max_code)
    -    deflate_state *s;
    -    ct_data *tree;   /* the tree to be scanned */
    -    int max_code;    /* and its largest code of non zero frequency */
    -{
    +local void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
         int n;                     /* iterates over all tree elements */
         int prevlen = -1;          /* last emitted length */
         int curlen;                /* length of current code */
    @@ -769,11 +772,7 @@ local void scan_tree(s, tree, max_code)
      * Send a literal or distance tree in compressed form, using the codes in
      * bl_tree.
      */
    -local void send_tree(s, tree, max_code)
    -    deflate_state *s;
    -    ct_data *tree; /* the tree to be scanned */
    -    int max_code;       /* and its largest code of non zero frequency */
    -{
    +local void send_tree(deflate_state *s, ct_data *tree, int max_code) {
         int n;                     /* iterates over all tree elements */
         int prevlen = -1;          /* last emitted length */
         int curlen;                /* length of current code */
    @@ -820,9 +819,7 @@ local void send_tree(s, tree, max_code)
      * Construct the Huffman tree for the bit lengths and return the index in
      * bl_order of the last bit length code to send.
      */
    -local int build_bl_tree(s)
    -    deflate_state *s;
    -{
    +local int build_bl_tree(deflate_state *s) {
         int max_blindex;  /* index of last bit length code of non zero freq */
     
         /* Determine the bit length frequencies for literal and distance trees */
    @@ -855,10 +852,8 @@ local int build_bl_tree(s)
      * lengths of the bit length codes, the literal tree and the distance tree.
      * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
      */
    -local void send_all_trees(s, lcodes, dcodes, blcodes)
    -    deflate_state *s;
    -    int lcodes, dcodes, blcodes; /* number of codes for each tree */
    -{
    +local void send_all_trees(deflate_state *s, int lcodes, int dcodes,
    +                          int blcodes) {
         int rank;                    /* index in bl_order */
     
         Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
    @@ -884,12 +879,8 @@ local void send_all_trees(s, lcodes, dcodes, blcodes)
     /* ===========================================================================
      * Send a stored block
      */
    -void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
    -    deflate_state *s;
    -    charf *buf;       /* input block */
    -    ulg stored_len;   /* length of input block */
    -    int last;         /* one if this is the last block for a file */
    -{
    +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
    +                                    ulg stored_len, int last) {
         send_bits(s, (STORED_BLOCK<<1) + last, 3);  /* send block type */
         bi_windup(s);        /* align on byte boundary */
         put_short(s, (ush)stored_len);
    @@ -908,9 +899,7 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
     /* ===========================================================================
      * Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
      */
    -void ZLIB_INTERNAL _tr_flush_bits(s)
    -    deflate_state *s;
    -{
    +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) {
         bi_flush(s);
     }
     
    @@ -918,9 +907,7 @@ void ZLIB_INTERNAL _tr_flush_bits(s)
      * Send one empty static block to give enough lookahead for inflate.
      * This takes 10 bits, of which 7 may remain in the bit buffer.
      */
    -void ZLIB_INTERNAL _tr_align(s)
    -    deflate_state *s;
    -{
    +void ZLIB_INTERNAL _tr_align(deflate_state *s) {
         send_bits(s, STATIC_TREES<<1, 3);
         send_code(s, END_BLOCK, static_ltree);
     #ifdef ZLIB_DEBUG
    @@ -929,16 +916,108 @@ void ZLIB_INTERNAL _tr_align(s)
         bi_flush(s);
     }
     
    +/* ===========================================================================
    + * Send the block data compressed using the given Huffman trees
    + */
    +local void compress_block(deflate_state *s, const ct_data *ltree,
    +                          const ct_data *dtree) {
    +    unsigned dist;      /* distance of matched string */
    +    int lc;             /* match length or unmatched char (if dist == 0) */
    +    unsigned sx = 0;    /* running index in symbol buffers */
    +    unsigned code;      /* the code to send */
    +    int extra;          /* number of extra bits to send */
    +
    +    if (s->sym_next != 0) do {
    +#ifdef LIT_MEM
    +        dist = s->d_buf[sx];
    +        lc = s->l_buf[sx++];
    +#else
    +        dist = s->sym_buf[sx++] & 0xff;
    +        dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8;
    +        lc = s->sym_buf[sx++];
    +#endif
    +        if (dist == 0) {
    +            send_code(s, lc, ltree); /* send a literal byte */
    +            Tracecv(isgraph(lc), (stderr," '%c' ", lc));
    +        } else {
    +            /* Here, lc is the match length - MIN_MATCH */
    +            code = _length_code[lc];
    +            send_code(s, code + LITERALS + 1, ltree);   /* send length code */
    +            extra = extra_lbits[code];
    +            if (extra != 0) {
    +                lc -= base_length[code];
    +                send_bits(s, lc, extra);       /* send the extra length bits */
    +            }
    +            dist--; /* dist is now the match distance - 1 */
    +            code = d_code(dist);
    +            Assert (code < D_CODES, "bad d_code");
    +
    +            send_code(s, code, dtree);       /* send the distance code */
    +            extra = extra_dbits[code];
    +            if (extra != 0) {
    +                dist -= (unsigned)base_dist[code];
    +                send_bits(s, dist, extra);   /* send the extra distance bits */
    +            }
    +        } /* literal or match pair ? */
    +
    +        /* Check for no overlay of pending_buf on needed symbols */
    +#ifdef LIT_MEM
    +        Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow");
    +#else
    +        Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
    +#endif
    +
    +    } while (sx < s->sym_next);
    +
    +    send_code(s, END_BLOCK, ltree);
    +}
    +
    +/* ===========================================================================
    + * Check if the data type is TEXT or BINARY, using the following algorithm:
    + * - TEXT if the two conditions below are satisfied:
    + *    a) There are no non-portable control characters belonging to the
    + *       "block list" (0..6, 14..25, 28..31).
    + *    b) There is at least one printable character belonging to the
    + *       "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
    + * - BINARY otherwise.
    + * - The following partially-portable control characters form a
    + *   "gray list" that is ignored in this detection algorithm:
    + *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
    + * IN assertion: the fields Freq of dyn_ltree are set.
    + */
    +local int detect_data_type(deflate_state *s) {
    +    /* block_mask is the bit mask of block-listed bytes
    +     * set bits 0..6, 14..25, and 28..31
    +     * 0xf3ffc07f = binary 11110011111111111100000001111111
    +     */
    +    unsigned long block_mask = 0xf3ffc07fUL;
    +    int n;
    +
    +    /* Check for non-textual ("block-listed") bytes. */
    +    for (n = 0; n <= 31; n++, block_mask >>= 1)
    +        if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0))
    +            return Z_BINARY;
    +
    +    /* Check for textual ("allow-listed") bytes. */
    +    if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
    +            || s->dyn_ltree[13].Freq != 0)
    +        return Z_TEXT;
    +    for (n = 32; n < LITERALS; n++)
    +        if (s->dyn_ltree[n].Freq != 0)
    +            return Z_TEXT;
    +
    +    /* There are no "block-listed" or "allow-listed" bytes:
    +     * this stream either is empty or has tolerated ("gray-listed") bytes only.
    +     */
    +    return Z_BINARY;
    +}
    +
     /* ===========================================================================
      * Determine the best encoding for the current block: dynamic trees, static
      * trees or store, and write out the encoded block.
      */
    -void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
    -    deflate_state *s;
    -    charf *buf;       /* input block, or NULL if too old */
    -    ulg stored_len;   /* length of input block */
    -    int last;         /* one if this is the last block for a file */
    -{
    +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
    +                                   ulg stored_len, int last) {
         ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
         int max_blindex = 0;  /* index of last bit length code of non zero freq */
     
    @@ -1035,14 +1114,15 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
      * Save the match info and tally the frequency counts. Return true if
      * the current block must be flushed.
      */
    -int ZLIB_INTERNAL _tr_tally(s, dist, lc)
    -    deflate_state *s;
    -    unsigned dist;  /* distance of matched string */
    -    unsigned lc;    /* match length - MIN_MATCH or unmatched char (dist==0) */
    -{
    +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) {
    +#ifdef LIT_MEM
    +    s->d_buf[s->sym_next] = (ush)dist;
    +    s->l_buf[s->sym_next++] = (uch)lc;
    +#else
         s->sym_buf[s->sym_next++] = (uch)dist;
         s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
         s->sym_buf[s->sym_next++] = (uch)lc;
    +#endif
         if (dist == 0) {
             /* lc is the unmatched char */
             s->dyn_ltree[lc].Freq++;
    @@ -1059,147 +1139,3 @@ int ZLIB_INTERNAL _tr_tally(s, dist, lc)
         }
         return (s->sym_next == s->sym_end);
     }
    -
    -/* ===========================================================================
    - * Send the block data compressed using the given Huffman trees
    - */
    -local void compress_block(s, ltree, dtree)
    -    deflate_state *s;
    -    const ct_data *ltree; /* literal tree */
    -    const ct_data *dtree; /* distance tree */
    -{
    -    unsigned dist;      /* distance of matched string */
    -    int lc;             /* match length or unmatched char (if dist == 0) */
    -    unsigned sx = 0;    /* running index in sym_buf */
    -    unsigned code;      /* the code to send */
    -    int extra;          /* number of extra bits to send */
    -
    -    if (s->sym_next != 0) do {
    -        dist = s->sym_buf[sx++] & 0xff;
    -        dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8;
    -        lc = s->sym_buf[sx++];
    -        if (dist == 0) {
    -            send_code(s, lc, ltree); /* send a literal byte */
    -            Tracecv(isgraph(lc), (stderr," '%c' ", lc));
    -        } else {
    -            /* Here, lc is the match length - MIN_MATCH */
    -            code = _length_code[lc];
    -            send_code(s, code + LITERALS + 1, ltree);   /* send length code */
    -            extra = extra_lbits[code];
    -            if (extra != 0) {
    -                lc -= base_length[code];
    -                send_bits(s, lc, extra);       /* send the extra length bits */
    -            }
    -            dist--; /* dist is now the match distance - 1 */
    -            code = d_code(dist);
    -            Assert (code < D_CODES, "bad d_code");
    -
    -            send_code(s, code, dtree);       /* send the distance code */
    -            extra = extra_dbits[code];
    -            if (extra != 0) {
    -                dist -= (unsigned)base_dist[code];
    -                send_bits(s, dist, extra);   /* send the extra distance bits */
    -            }
    -        } /* literal or match pair ? */
    -
    -        /* Check that the overlay between pending_buf and sym_buf is ok: */
    -        Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
    -
    -    } while (sx < s->sym_next);
    -
    -    send_code(s, END_BLOCK, ltree);
    -}
    -
    -/* ===========================================================================
    - * Check if the data type is TEXT or BINARY, using the following algorithm:
    - * - TEXT if the two conditions below are satisfied:
    - *    a) There are no non-portable control characters belonging to the
    - *       "block list" (0..6, 14..25, 28..31).
    - *    b) There is at least one printable character belonging to the
    - *       "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
    - * - BINARY otherwise.
    - * - The following partially-portable control characters form a
    - *   "gray list" that is ignored in this detection algorithm:
    - *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
    - * IN assertion: the fields Freq of dyn_ltree are set.
    - */
    -local int detect_data_type(s)
    -    deflate_state *s;
    -{
    -    /* block_mask is the bit mask of block-listed bytes
    -     * set bits 0..6, 14..25, and 28..31
    -     * 0xf3ffc07f = binary 11110011111111111100000001111111
    -     */
    -    unsigned long block_mask = 0xf3ffc07fUL;
    -    int n;
    -
    -    /* Check for non-textual ("block-listed") bytes. */
    -    for (n = 0; n <= 31; n++, block_mask >>= 1)
    -        if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0))
    -            return Z_BINARY;
    -
    -    /* Check for textual ("allow-listed") bytes. */
    -    if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
    -            || s->dyn_ltree[13].Freq != 0)
    -        return Z_TEXT;
    -    for (n = 32; n < LITERALS; n++)
    -        if (s->dyn_ltree[n].Freq != 0)
    -            return Z_TEXT;
    -
    -    /* There are no "block-listed" or "allow-listed" bytes:
    -     * this stream either is empty or has tolerated ("gray-listed") bytes only.
    -     */
    -    return Z_BINARY;
    -}
    -
    -/* ===========================================================================
    - * Reverse the first len bits of a code, using straightforward code (a faster
    - * method would use a table)
    - * IN assertion: 1 <= len <= 15
    - */
    -local unsigned bi_reverse(code, len)
    -    unsigned code; /* the value to invert */
    -    int len;       /* its bit length */
    -{
    -    register unsigned res = 0;
    -    do {
    -        res |= code & 1;
    -        code >>= 1, res <<= 1;
    -    } while (--len > 0);
    -    return res >> 1;
    -}
    -
    -/* ===========================================================================
    - * Flush the bit buffer, keeping at most 7 bits in it.
    - */
    -local void bi_flush(s)
    -    deflate_state *s;
    -{
    -    if (s->bi_valid == 16) {
    -        put_short(s, s->bi_buf);
    -        s->bi_buf = 0;
    -        s->bi_valid = 0;
    -    } else if (s->bi_valid >= 8) {
    -        put_byte(s, (Byte)s->bi_buf);
    -        s->bi_buf >>= 8;
    -        s->bi_valid -= 8;
    -    }
    -}
    -
    -/* ===========================================================================
    - * Flush the bit buffer and align the output on a byte boundary
    - */
    -local void bi_windup(s)
    -    deflate_state *s;
    -{
    -    if (s->bi_valid > 8) {
    -        put_short(s, s->bi_buf);
    -    } else if (s->bi_valid > 0) {
    -        put_byte(s, (Byte)s->bi_buf);
    -    }
    -    s->bi_buf = 0;
    -    s->bi_valid = 0;
    -#ifdef ZLIB_DEBUG
    -    s->bits_sent = (s->bits_sent + 7) & ~7;
    -#endif
    -}
    diff --git a/src/java.base/share/native/libzip/zlib/uncompr.c b/src/java.base/share/native/libzip/zlib/uncompr.c
    index 24af8d2453f..219c1d264d5 100644
    --- a/src/java.base/share/native/libzip/zlib/uncompr.c
    +++ b/src/java.base/share/native/libzip/zlib/uncompr.c
    @@ -48,12 +48,8 @@
        Z_DATA_ERROR if the input data was corrupted, including if the input data is
        an incomplete zlib stream.
     */
    -int ZEXPORT uncompress2(dest, destLen, source, sourceLen)
    -    Bytef *dest;
    -    uLongf *destLen;
    -    const Bytef *source;
    -    uLong *sourceLen;
    -{
    +int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source,
    +                        uLong *sourceLen) {
         z_stream stream;
         int err;
         const uInt max = (uInt)-1;
    @@ -107,11 +103,7 @@ int ZEXPORT uncompress2(dest, destLen, source, sourceLen)
                err;
     }
     
    -int ZEXPORT uncompress(dest, destLen, source, sourceLen)
    -    Bytef *dest;
    -    uLongf *destLen;
    -    const Bytef *source;
    -    uLong sourceLen;
    -{
    +int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source,
    +                       uLong sourceLen) {
         return uncompress2(dest, destLen, source, &sourceLen);
     }
    diff --git a/src/java.base/share/native/libzip/zlib/zadler32.c b/src/java.base/share/native/libzip/zlib/zadler32.c
    index e1480226310..acfd75b908e 100644
    --- a/src/java.base/share/native/libzip/zlib/zadler32.c
    +++ b/src/java.base/share/native/libzip/zlib/zadler32.c
    @@ -31,8 +31,6 @@
     
     #include "zutil.h"
     
    -local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
    -
     #define BASE 65521U     /* largest prime smaller than 65536 */
     #define NMAX 5552
     /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
    @@ -84,11 +82,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
     #endif
     
     /* ========================================================================= */
    -uLong ZEXPORT adler32_z(adler, buf, len)
    -    uLong adler;
    -    const Bytef *buf;
    -    z_size_t len;
    -{
    +uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
         unsigned long sum2;
         unsigned n;
     
    @@ -155,20 +149,12 @@ uLong ZEXPORT adler32_z(adler, buf, len)
     }
     
     /* ========================================================================= */
    -uLong ZEXPORT adler32(adler, buf, len)
    -    uLong adler;
    -    const Bytef *buf;
    -    uInt len;
    -{
    +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
         return adler32_z(adler, buf, len);
     }
     
     /* ========================================================================= */
    -local uLong adler32_combine_(adler1, adler2, len2)
    -    uLong adler1;
    -    uLong adler2;
    -    z_off64_t len2;
    -{
    +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
         unsigned long sum1;
         unsigned long sum2;
         unsigned rem;
    @@ -193,18 +179,10 @@ local uLong adler32_combine_(adler1, adler2, len2)
     }
     
     /* ========================================================================= */
    -uLong ZEXPORT adler32_combine(adler1, adler2, len2)
    -    uLong adler1;
    -    uLong adler2;
    -    z_off_t len2;
    -{
    +uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
         return adler32_combine_(adler1, adler2, len2);
     }
     
    -uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
    -    uLong adler1;
    -    uLong adler2;
    -    z_off64_t len2;
    -{
    +uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
         return adler32_combine_(adler1, adler2, len2);
     }
    diff --git a/src/java.base/share/native/libzip/zlib/zconf.h b/src/java.base/share/native/libzip/zlib/zconf.h
    index 92b7eb23886..46204222f5d 100644
    --- a/src/java.base/share/native/libzip/zlib/zconf.h
    +++ b/src/java.base/share/native/libzip/zlib/zconf.h
    @@ -23,7 +23,7 @@
      */
     
     /* zconf.h -- configuration of the zlib compression library
    - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
    + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -265,7 +265,11 @@
     #endif
     
     #ifdef Z_SOLO
    -   typedef unsigned long z_size_t;
    +#  ifdef _WIN64
    +     typedef unsigned long long z_size_t;
    +#  else
    +     typedef unsigned long z_size_t;
    +#  endif
     #else
     #  define z_longlong long long
     #  if defined(NO_SIZE_T)
    @@ -320,14 +324,6 @@
     #  endif
     #endif
     
    -#ifndef Z_ARG /* function prototypes for stdarg */
    -#  if defined(STDC) || defined(Z_HAVE_STDARG_H)
    -#    define Z_ARG(args)  args
    -#  else
    -#    define Z_ARG(args)  ()
    -#  endif
    -#endif
    -
     /* The following definitions for FAR are needed only for MSDOS mixed
      * model programming (small or medium model with some far allocations).
      * This was tested only with MSC; for other MSDOS compilers you may have
    @@ -544,7 +540,7 @@ typedef uLong FAR uLongf;
     #if !defined(_WIN32) && defined(Z_LARGE64)
     #  define z_off64_t off64_t
     #else
    -#  if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
    +#  if defined(_WIN32) && !defined(__GNUC__)
     #    define z_off64_t __int64
     #  else
     #    define z_off64_t z_off_t
    diff --git a/src/java.base/share/native/libzip/zlib/zcrc32.c b/src/java.base/share/native/libzip/zlib/zcrc32.c
    index 24f2350b55d..3f918f76b7c 100644
    --- a/src/java.base/share/native/libzip/zlib/zcrc32.c
    +++ b/src/java.base/share/native/libzip/zlib/zcrc32.c
    @@ -127,19 +127,6 @@
     #  define ARMCRC32
     #endif
     
    -/* Local functions. */
    -local z_crc_t multmodp OF((z_crc_t a, z_crc_t b));
    -local z_crc_t x2nmodp OF((z_off64_t n, unsigned k));
    -
    -#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE))
    -    local z_word_t byte_swap OF((z_word_t word));
    -#endif
    -
    -#if defined(W) && !defined(ARMCRC32)
    -    local z_crc_t crc_word OF((z_word_t data));
    -    local z_word_t crc_word_big OF((z_word_t data));
    -#endif
    -
     #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE))
     /*
       Swap the bytes in a z_word_t to convert between little and big endian. Any
    @@ -147,9 +134,7 @@ local z_crc_t x2nmodp OF((z_off64_t n, unsigned k));
       instruction, if one is available. This assumes that word_t is either 32 bits
       or 64 bits.
      */
    -local z_word_t byte_swap(word)
    -    z_word_t word;
    -{
    +local z_word_t byte_swap(z_word_t word) {
     #  if W == 8
         return
             (word & 0xff00000000000000) >> 56 |
    @@ -170,24 +155,77 @@ local z_word_t byte_swap(word)
     }
     #endif
     
    +#ifdef DYNAMIC_CRC_TABLE
    +/* =========================================================================
    + * Table of powers of x for combining CRC-32s, filled in by make_crc_table()
    + * below.
    + */
    +   local z_crc_t FAR x2n_table[32];
    +#else
    +/* =========================================================================
    + * Tables for byte-wise and braided CRC-32 calculations, and a table of powers
    + * of x for combining CRC-32s, all made by make_crc_table().
    + */
    +#  include "crc32.h"
    +#endif
    +
     /* CRC polynomial. */
     #define POLY 0xedb88320         /* p(x) reflected, with x^32 implied */
     
    -#ifdef DYNAMIC_CRC_TABLE
    +/*
    +  Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
    +  reflected. For speed, this requires that a not be zero.
    + */
    +local z_crc_t multmodp(z_crc_t a, z_crc_t b) {
    +    z_crc_t m, p;
    +
    +    m = (z_crc_t)1 << 31;
    +    p = 0;
    +    for (;;) {
    +        if (a & m) {
    +            p ^= b;
    +            if ((a & (m - 1)) == 0)
    +                break;
    +        }
    +        m >>= 1;
    +        b = b & 1 ? (b >> 1) ^ POLY : b >> 1;
    +    }
    +    return p;
    +}
     
    +/*
    +  Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
    +  initialized.
    + */
    +local z_crc_t x2nmodp(z_off64_t n, unsigned k) {
    +    z_crc_t p;
    +
    +    p = (z_crc_t)1 << 31;           /* x^0 == 1 */
    +    while (n) {
    +        if (n & 1)
    +            p = multmodp(x2n_table[k & 31], p);
    +        n >>= 1;
    +        k++;
    +    }
    +    return p;
    +}
    +
    +#ifdef DYNAMIC_CRC_TABLE
    +/* =========================================================================
    + * Build the tables for byte-wise and braided CRC-32 calculations, and a table
    + * of powers of x for combining CRC-32s.
    + */
     local z_crc_t FAR crc_table[256];
    -local z_crc_t FAR x2n_table[32];
    -local void make_crc_table OF((void));
     #ifdef W
        local z_word_t FAR crc_big_table[256];
        local z_crc_t FAR crc_braid_table[W][256];
        local z_word_t FAR crc_braid_big_table[W][256];
    -   local void braid OF((z_crc_t [][256], z_word_t [][256], int, int));
    +   local void braid(z_crc_t [][256], z_word_t [][256], int, int);
     #endif
     #ifdef MAKECRCH
    -   local void write_table OF((FILE *, const z_crc_t FAR *, int));
    -   local void write_table32hi OF((FILE *, const z_word_t FAR *, int));
    -   local void write_table64 OF((FILE *, const z_word_t FAR *, int));
    +   local void write_table(FILE *, const z_crc_t FAR *, int);
    +   local void write_table32hi(FILE *, const z_word_t FAR *, int);
    +   local void write_table64(FILE *, const z_word_t FAR *, int);
     #endif /* MAKECRCH */
     
     /*
    @@ -200,7 +238,6 @@ local void make_crc_table OF((void));
     
     /* Definition of once functionality. */
     typedef struct once_s once_t;
    -local void once OF((once_t *, void (*)(void)));
     
     /* Check for the availability of atomics. */
     #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \
    @@ -220,10 +257,7 @@ struct once_s {
       invoke once() at the same time. The state must be a once_t initialized with
       ONCE_INIT.
      */
    -local void once(state, init)
    -    once_t *state;
    -    void (*init)(void);
    -{
    +local void once(once_t *state, void (*init)(void)) {
         if (!atomic_load(&state->done)) {
             if (atomic_flag_test_and_set(&state->begun))
                 while (!atomic_load(&state->done))
    @@ -246,10 +280,7 @@ struct once_s {
     
     /* Test and set. Alas, not atomic, but tries to minimize the period of
        vulnerability. */
    -local int test_and_set OF((int volatile *));
    -local int test_and_set(flag)
    -    int volatile *flag;
    -{
    +local int test_and_set(int volatile *flag) {
         int was;
     
         was = *flag;
    @@ -258,10 +289,7 @@ local int test_and_set(flag)
     }
     
     /* Run the provided init() function once. This is not thread-safe. */
    -local void once(state, init)
    -    once_t *state;
    -    void (*init)(void);
    -{
    +local void once(once_t *state, void (*init)(void)) {
         if (!state->done) {
             if (test_and_set(&state->begun))
                 while (!state->done)
    @@ -303,8 +331,7 @@ local once_t made = ONCE_INIT;
       combinations of CRC register values and incoming bytes.
      */
     
    -local void make_crc_table()
    -{
    +local void make_crc_table(void) {
         unsigned i, j, n;
         z_crc_t p;
     
    @@ -471,11 +498,7 @@ local void make_crc_table()
        Write the 32-bit values in table[0..k-1] to out, five per line in
        hexadecimal separated by commas.
      */
    -local void write_table(out, table, k)
    -    FILE *out;
    -    const z_crc_t FAR *table;
    -    int k;
    -{
    +local void write_table(FILE *out, const z_crc_t FAR *table, int k) {
         int n;
     
         for (n = 0; n < k; n++)
    @@ -488,11 +511,7 @@ local void write_table(out, table, k)
        Write the high 32-bits of each value in table[0..k-1] to out, five per line
        in hexadecimal separated by commas.
      */
    -local void write_table32hi(out, table, k)
    -FILE *out;
    -const z_word_t FAR *table;
    -int k;
    -{
    +local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) {
         int n;
     
         for (n = 0; n < k; n++)
    @@ -508,11 +527,7 @@ int k;
       bits. If not, then the type cast and format string can be adjusted
       accordingly.
      */
    -local void write_table64(out, table, k)
    -    FILE *out;
    -    const z_word_t FAR *table;
    -    int k;
    -{
    +local void write_table64(FILE *out, const z_word_t FAR *table, int k) {
         int n;
     
         for (n = 0; n < k; n++)
    @@ -522,8 +537,7 @@ local void write_table64(out, table, k)
     }
     
     /* Actually do the deed. */
    -int main()
    -{
    +int main(void) {
         make_crc_table();
         return 0;
     }
    @@ -535,12 +549,7 @@ int main()
       Generate the little and big-endian braid tables for the given n and z_word_t
       size w. Each array must have room for w blocks of 256 elements.
      */
    -local void braid(ltl, big, n, w)
    -    z_crc_t ltl[][256];
    -    z_word_t big[][256];
    -    int n;
    -    int w;
    -{
    +local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) {
         int k;
         z_crc_t i, p, q;
         for (k = 0; k < w; k++) {
    @@ -555,69 +564,13 @@ local void braid(ltl, big, n, w)
     }
     #endif
     
    -#else /* !DYNAMIC_CRC_TABLE */
    -/* ========================================================================
    - * Tables for byte-wise and braided CRC-32 calculations, and a table of powers
    - * of x for combining CRC-32s, all made by make_crc_table().
    - */
    -#include "crc32.h"
     #endif /* DYNAMIC_CRC_TABLE */
     
    -/* ========================================================================
    - * Routines used for CRC calculation. Some are also required for the table
    - * generation above.
    - */
    -
    -/*
    -  Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
    -  reflected. For speed, this requires that a not be zero.
    - */
    -local z_crc_t multmodp(a, b)
    -    z_crc_t a;
    -    z_crc_t b;
    -{
    -    z_crc_t m, p;
    -
    -    m = (z_crc_t)1 << 31;
    -    p = 0;
    -    for (;;) {
    -        if (a & m) {
    -            p ^= b;
    -            if ((a & (m - 1)) == 0)
    -                break;
    -        }
    -        m >>= 1;
    -        b = b & 1 ? (b >> 1) ^ POLY : b >> 1;
    -    }
    -    return p;
    -}
    -
    -/*
    -  Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
    -  initialized.
    - */
    -local z_crc_t x2nmodp(n, k)
    -    z_off64_t n;
    -    unsigned k;
    -{
    -    z_crc_t p;
    -
    -    p = (z_crc_t)1 << 31;           /* x^0 == 1 */
    -    while (n) {
    -        if (n & 1)
    -            p = multmodp(x2n_table[k & 31], p);
    -        n >>= 1;
    -        k++;
    -    }
    -    return p;
    -}
    -
     /* =========================================================================
      * This function can be used by asm versions of crc32(), and to force the
      * generation of the CRC tables in a threaded application.
      */
    -const z_crc_t FAR * ZEXPORT get_crc_table()
    -{
    +const z_crc_t FAR * ZEXPORT get_crc_table(void) {
     #ifdef DYNAMIC_CRC_TABLE
         once(&made, make_crc_table);
     #endif /* DYNAMIC_CRC_TABLE */
    @@ -643,11 +596,8 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
     #define Z_BATCH_ZEROS 0xa10d3d0c    /* computed from Z_BATCH = 3990 */
     #define Z_BATCH_MIN 800             /* fewest words in a final batch */
     
    -unsigned long ZEXPORT crc32_z(crc, buf, len)
    -    unsigned long crc;
    -    const unsigned char FAR *buf;
    -    z_size_t len;
    -{
    +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
    +                              z_size_t len) {
         z_crc_t val;
         z_word_t crc1, crc2;
         const z_word_t *word;
    @@ -747,18 +697,14 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
       least-significant byte of the word as the first byte of data, without any pre
       or post conditioning. This is used to combine the CRCs of each braid.
      */
    -local z_crc_t crc_word(data)
    -    z_word_t data;
    -{
    +local z_crc_t crc_word(z_word_t data) {
         int k;
         for (k = 0; k < W; k++)
             data = (data >> 8) ^ crc_table[data & 0xff];
         return (z_crc_t)data;
     }
     
    -local z_word_t crc_word_big(data)
    -    z_word_t data;
    -{
    +local z_word_t crc_word_big(z_word_t data) {
         int k;
         for (k = 0; k < W; k++)
             data = (data << 8) ^
    @@ -769,11 +715,8 @@ local z_word_t crc_word_big(data)
     #endif
     
     /* ========================================================================= */
    -unsigned long ZEXPORT crc32_z(crc, buf, len)
    -    unsigned long crc;
    -    const unsigned char FAR *buf;
    -    z_size_t len;
    -{
    +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf,
    +                              z_size_t len) {
         /* Return initial CRC, if requested. */
         if (buf == Z_NULL) return 0;
     
    @@ -805,8 +748,8 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
             words = (z_word_t const *)buf;
     
             /* Do endian check at execution time instead of compile time, since ARM
    -           processors can change the endianess at execution time. If the
    -           compiler knows what the endianess will be, it can optimize out the
    +           processors can change the endianness at execution time. If the
    +           compiler knows what the endianness will be, it can optimize out the
                check and the unused branch. */
             endian = 1;
             if (*(unsigned char *)&endian) {
    @@ -1093,20 +1036,13 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
     #endif
     
     /* ========================================================================= */
    -unsigned long ZEXPORT crc32(crc, buf, len)
    -    unsigned long crc;
    -    const unsigned char FAR *buf;
    -    uInt len;
    -{
    +unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf,
    +                            uInt len) {
         return crc32_z(crc, buf, len);
     }
     
     /* ========================================================================= */
    -uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
    -    uLong crc1;
    -    uLong crc2;
    -    z_off64_t len2;
    -{
    +uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) {
     #ifdef DYNAMIC_CRC_TABLE
         once(&made, make_crc_table);
     #endif /* DYNAMIC_CRC_TABLE */
    @@ -1114,18 +1050,12 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
     }
     
     /* ========================================================================= */
    -uLong ZEXPORT crc32_combine(crc1, crc2, len2)
    -    uLong crc1;
    -    uLong crc2;
    -    z_off_t len2;
    -{
    +uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) {
         return crc32_combine64(crc1, crc2, (z_off64_t)len2);
     }
     
     /* ========================================================================= */
    -uLong ZEXPORT crc32_combine_gen64(len2)
    -    z_off64_t len2;
    -{
    +uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) {
     #ifdef DYNAMIC_CRC_TABLE
         once(&made, make_crc_table);
     #endif /* DYNAMIC_CRC_TABLE */
    @@ -1133,17 +1063,11 @@ uLong ZEXPORT crc32_combine_gen64(len2)
     }
     
     /* ========================================================================= */
    -uLong ZEXPORT crc32_combine_gen(len2)
    -    z_off_t len2;
    -{
    +uLong ZEXPORT crc32_combine_gen(z_off_t len2) {
         return crc32_combine_gen64((z_off64_t)len2);
     }
     
     /* ========================================================================= */
    -uLong ZEXPORT crc32_combine_op(crc1, crc2, op)
    -    uLong crc1;
    -    uLong crc2;
    -    uLong op;
    -{
    +uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) {
         return multmodp(op, crc1) ^ (crc2 & 0xffffffff);
     }
    diff --git a/src/java.base/share/native/libzip/zlib/zlib.h b/src/java.base/share/native/libzip/zlib/zlib.h
    index 10146088795..07496b5f981 100644
    --- a/src/java.base/share/native/libzip/zlib/zlib.h
    +++ b/src/java.base/share/native/libzip/zlib/zlib.h
    @@ -23,9 +23,9 @@
      */
     
     /* zlib.h -- interface of the 'zlib' general purpose compression library
    -  version 1.2.13, October 13th, 2022
    +  version 1.3.1, January 22nd, 2024
     
    -  Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
    +  Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
     
       This software is provided 'as-is', without any express or implied
       warranty.  In no event will the authors be held liable for any damages
    @@ -61,11 +61,11 @@
     extern "C" {
     #endif
     
    -#define ZLIB_VERSION "1.2.13"
    -#define ZLIB_VERNUM 0x12d0
    +#define ZLIB_VERSION "1.3.1"
    +#define ZLIB_VERNUM 0x1310
     #define ZLIB_VER_MAJOR 1
    -#define ZLIB_VER_MINOR 2
    -#define ZLIB_VER_REVISION 13
    +#define ZLIB_VER_MINOR 3
    +#define ZLIB_VER_REVISION 1
     #define ZLIB_VER_SUBREVISION 0
     
     /*
    @@ -102,8 +102,8 @@ extern "C" {
       even in the case of corrupted input.
     */
     
    -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
    -typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
    +typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size);
    +typedef void   (*free_func)(voidpf opaque, voidpf address);
     
     struct internal_state;
     
    @@ -241,7 +241,7 @@ typedef gz_header FAR *gz_headerp;
     
                             /* basic functions */
     
    -ZEXTERN const char * ZEXPORT zlibVersion OF((void));
    +ZEXTERN const char * ZEXPORT zlibVersion(void);
     /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
        If the first character differs, the library code actually used is not
        compatible with the zlib.h header file used by the application.  This check
    @@ -249,12 +249,12 @@ ZEXTERN const char * ZEXPORT zlibVersion OF((void));
      */
     
     /*
    -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
    +ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level);
     
          Initializes the internal stream state for compression.  The fields
        zalloc, zfree and opaque must be initialized before by the caller.  If
        zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
    -   allocation functions.
    +   allocation functions.  total_in, total_out, adler, and msg are initialized.
     
          The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
        1 gives best speed, 9 gives best compression, 0 gives no compression at all
    @@ -271,7 +271,7 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
     */
     
     
    -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
    +ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush);
     /*
         deflate compresses as much data as possible, and stops when the input
       buffer becomes empty or the output buffer becomes full.  It may introduce
    @@ -344,8 +344,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
       with the same value of the flush parameter and more output space (updated
       avail_out), until the flush is complete (deflate returns with non-zero
       avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
    -  avail_out is greater than six to avoid repeated flush markers due to
    -  avail_out == 0 on return.
    +  avail_out is greater than six when the flush marker begins, in order to avoid
    +  repeated flush markers upon calling deflate() again when avail_out == 0.
     
         If the parameter flush is set to Z_FINISH, pending input is processed,
       pending output is flushed and deflate returns with Z_STREAM_END if there was
    @@ -384,7 +384,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
     */
     
     
    -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
    +ZEXTERN int ZEXPORT deflateEnd(z_streamp strm);
     /*
          All dynamically allocated data structures for this stream are freed.
        This function discards any unprocessed input and does not flush any pending
    @@ -399,7 +399,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
     
     
     /*
    -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
    +ZEXTERN int ZEXPORT inflateInit(z_streamp strm);
     
          Initializes the internal stream state for decompression.  The fields
        next_in, avail_in, zalloc, zfree and opaque must be initialized before by
    @@ -407,7 +407,8 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
        read or consumed.  The allocation of a sliding window will be deferred to
        the first call of inflate (if the decompression does not complete on the
        first call).  If zalloc and zfree are set to Z_NULL, inflateInit updates
    -   them to use default allocation functions.
    +   them to use default allocation functions.  total_in, total_out, adler, and
    +   msg are initialized.
     
          inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
        memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
    @@ -421,7 +422,7 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
     */
     
     
    -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
    +ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush);
     /*
         inflate decompresses as much data as possible, and stops when the input
       buffer becomes empty or the output buffer becomes full.  It may introduce
    @@ -541,7 +542,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
     */
     
     
    -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
    +ZEXTERN int ZEXPORT inflateEnd(z_streamp strm);
     /*
          All dynamically allocated data structures for this stream are freed.
        This function discards any unprocessed input and does not flush any pending
    @@ -559,12 +560,12 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
     */
     
     /*
    -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
    -                                     int  level,
    -                                     int  method,
    -                                     int  windowBits,
    -                                     int  memLevel,
    -                                     int  strategy));
    +ZEXTERN int ZEXPORT deflateInit2(z_streamp strm,
    +                                 int level,
    +                                 int method,
    +                                 int windowBits,
    +                                 int memLevel,
    +                                 int strategy);
     
          This is another version of deflateInit with more compression options.  The
        fields zalloc, zfree and opaque must be initialized before by the caller.
    @@ -631,9 +632,9 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
        compression: this will be done by deflate().
     */
     
    -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
    -                                             const Bytef *dictionary,
    -                                             uInt  dictLength));
    +ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm,
    +                                         const Bytef *dictionary,
    +                                         uInt  dictLength);
     /*
          Initializes the compression dictionary from the given byte sequence
        without producing any compressed output.  When using the zlib format, this
    @@ -675,9 +676,9 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
        not perform any compression: this will be done by deflate().
     */
     
    -ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,
    -                                             Bytef *dictionary,
    -                                             uInt  *dictLength));
    +ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm,
    +                                         Bytef *dictionary,
    +                                         uInt  *dictLength);
     /*
          Returns the sliding dictionary being maintained by deflate.  dictLength is
        set to the number of bytes in the dictionary, and that many bytes are copied
    @@ -697,8 +698,8 @@ ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,
        stream state is inconsistent.
     */
     
    -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
    -                                    z_streamp source));
    +ZEXTERN int ZEXPORT deflateCopy(z_streamp dest,
    +                                z_streamp source);
     /*
          Sets the destination stream as a complete copy of the source stream.
     
    @@ -715,20 +716,20 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
        destination.
     */
     
    -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
    +ZEXTERN int ZEXPORT deflateReset(z_streamp strm);
     /*
          This function is equivalent to deflateEnd followed by deflateInit, but
        does not free and reallocate the internal compression state.  The stream
        will leave the compression level and any other attributes that may have been
    -   set unchanged.
    +   set unchanged.  total_in, total_out, adler, and msg are initialized.
     
          deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
        stream state was inconsistent (such as zalloc or state being Z_NULL).
     */
     
    -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
    -                                      int level,
    -                                      int strategy));
    +ZEXTERN int ZEXPORT deflateParams(z_streamp strm,
    +                                  int level,
    +                                  int strategy);
     /*
          Dynamically update the compression level and compression strategy.  The
        interpretation of level and strategy is as in deflateInit2().  This can be
    @@ -753,7 +754,7 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
        Then no more input data should be provided before the deflateParams() call.
        If this is done, the old level and strategy will be applied to the data
        compressed before deflateParams(), and the new level and strategy will be
    -   applied to the the data compressed after deflateParams().
    +   applied to the data compressed after deflateParams().
     
          deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream
        state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if
    @@ -764,11 +765,11 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
        retried with more output space.
     */
     
    -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
    -                                    int good_length,
    -                                    int max_lazy,
    -                                    int nice_length,
    -                                    int max_chain));
    +ZEXTERN int ZEXPORT deflateTune(z_streamp strm,
    +                                int good_length,
    +                                int max_lazy,
    +                                int nice_length,
    +                                int max_chain);
     /*
          Fine tune deflate's internal compression parameters.  This should only be
        used by someone who understands the algorithm used by zlib's deflate for
    @@ -781,8 +782,8 @@ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
        returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
      */
     
    -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
    -                                       uLong sourceLen));
    +ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm,
    +                                   uLong sourceLen);
     /*
          deflateBound() returns an upper bound on the compressed size after
        deflation of sourceLen bytes.  It must be called after deflateInit() or
    @@ -796,9 +797,9 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
        than Z_FINISH or Z_NO_FLUSH are used.
     */
     
    -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
    -                                       unsigned *pending,
    -                                       int *bits));
    +ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
    +                                   unsigned *pending,
    +                                   int *bits);
     /*
          deflatePending() returns the number of bytes and bits of output that have
        been generated, but not yet provided in the available output.  The bytes not
    @@ -811,9 +812,9 @@ ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
        stream state was inconsistent.
      */
     
    -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
    -                                     int bits,
    -                                     int value));
    +ZEXTERN int ZEXPORT deflatePrime(z_streamp strm,
    +                                 int bits,
    +                                 int value);
     /*
          deflatePrime() inserts bits in the deflate output stream.  The intent
        is that this function is used to start off the deflate output with the bits
    @@ -828,8 +829,8 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
        source stream state was inconsistent.
     */
     
    -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
    -                                         gz_headerp head));
    +ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm,
    +                                     gz_headerp head);
     /*
          deflateSetHeader() provides gzip header information for when a gzip
        stream is requested by deflateInit2().  deflateSetHeader() may be called
    @@ -845,16 +846,17 @@ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
        gzip file" and give up.
     
          If deflateSetHeader is not used, the default gzip header has text false,
    -   the time set to zero, and os set to 255, with no extra, name, or comment
    -   fields.  The gzip header is returned to the default state by deflateReset().
    +   the time set to zero, and os set to the current operating system, with no
    +   extra, name, or comment fields.  The gzip header is returned to the default
    +   state by deflateReset().
     
          deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
        stream state was inconsistent.
     */
     
     /*
    -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
    -                                     int  windowBits));
    +ZEXTERN int ZEXPORT inflateInit2(z_streamp strm,
    +                                 int windowBits);
     
          This is another version of inflateInit with an extra parameter.  The
        fields next_in, avail_in, zalloc, zfree and opaque must be initialized
    @@ -907,9 +909,9 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
        deferred until inflate() is called.
     */
     
    -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
    -                                             const Bytef *dictionary,
    -                                             uInt  dictLength));
    +ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm,
    +                                         const Bytef *dictionary,
    +                                         uInt  dictLength);
     /*
          Initializes the decompression dictionary from the given uncompressed byte
        sequence.  This function must be called immediately after a call of inflate,
    @@ -930,9 +932,9 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
        inflate().
     */
     
    -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
    -                                             Bytef *dictionary,
    -                                             uInt  *dictLength));
    +ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm,
    +                                         Bytef *dictionary,
    +                                         uInt  *dictLength);
     /*
          Returns the sliding dictionary being maintained by inflate.  dictLength is
        set to the number of bytes in the dictionary, and that many bytes are copied
    @@ -945,7 +947,7 @@ ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
        stream state is inconsistent.
     */
     
    -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
    +ZEXTERN int ZEXPORT inflateSync(z_streamp strm);
     /*
          Skips invalid compressed data until a possible full flush point (see above
        for the description of deflate with Z_FULL_FLUSH) can be found, or until all
    @@ -958,14 +960,14 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
          inflateSync returns Z_OK if a possible full flush point has been found,
        Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
        has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
    -   In the success case, the application may save the current current value of
    -   total_in which indicates where valid compressed data was found.  In the
    -   error case, the application may repeatedly call inflateSync, providing more
    -   input each time, until success or end of the input data.
    +   In the success case, the application may save the current value of total_in
    +   which indicates where valid compressed data was found.  In the error case,
    +   the application may repeatedly call inflateSync, providing more input each
    +   time, until success or end of the input data.
     */
     
    -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
    -                                    z_streamp source));
    +ZEXTERN int ZEXPORT inflateCopy(z_streamp dest,
    +                                z_streamp source);
     /*
          Sets the destination stream as a complete copy of the source stream.
     
    @@ -980,18 +982,19 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
        destination.
     */
     
    -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
    +ZEXTERN int ZEXPORT inflateReset(z_streamp strm);
     /*
          This function is equivalent to inflateEnd followed by inflateInit,
        but does not free and reallocate the internal decompression state.  The
        stream will keep attributes that may have been set by inflateInit2.
    +   total_in, total_out, adler, and msg are initialized.
     
          inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
        stream state was inconsistent (such as zalloc or state being Z_NULL).
     */
     
    -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
    -                                      int windowBits));
    +ZEXTERN int ZEXPORT inflateReset2(z_streamp strm,
    +                                  int windowBits);
     /*
          This function is the same as inflateReset, but it also permits changing
        the wrap and window size requests.  The windowBits parameter is interpreted
    @@ -1004,9 +1007,9 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
        the windowBits parameter is invalid.
     */
     
    -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
    -                                     int bits,
    -                                     int value));
    +ZEXTERN int ZEXPORT inflatePrime(z_streamp strm,
    +                                 int bits,
    +                                 int value);
     /*
          This function inserts bits in the inflate input stream.  The intent is
        that this function is used to start inflating at a bit position in the
    @@ -1025,7 +1028,7 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
        stream state was inconsistent.
     */
     
    -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
    +ZEXTERN long ZEXPORT inflateMark(z_streamp strm);
     /*
          This function returns two values, one in the lower 16 bits of the return
        value, and the other in the remaining upper bits, obtained by shifting the
    @@ -1053,8 +1056,8 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
        source stream state was inconsistent.
     */
     
    -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
    -                                         gz_headerp head));
    +ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm,
    +                                     gz_headerp head);
     /*
          inflateGetHeader() requests that gzip header information be stored in the
        provided gz_header structure.  inflateGetHeader() may be called after
    @@ -1094,8 +1097,8 @@ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
     */
     
     /*
    -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
    -                                        unsigned char FAR *window));
    +ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits,
    +                                    unsigned char FAR *window);
     
          Initialize the internal stream state for decompression using inflateBack()
        calls.  The fields zalloc, zfree and opaque in strm must be initialized
    @@ -1115,13 +1118,13 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
        the version of the header file.
     */
     
    -typedef unsigned (*in_func) OF((void FAR *,
    -                                z_const unsigned char FAR * FAR *));
    -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
    +typedef unsigned (*in_func)(void FAR *,
    +                            z_const unsigned char FAR * FAR *);
    +typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned);
     
    -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
    -                                    in_func in, void FAR *in_desc,
    -                                    out_func out, void FAR *out_desc));
    +ZEXTERN int ZEXPORT inflateBack(z_streamp strm,
    +                                in_func in, void FAR *in_desc,
    +                                out_func out, void FAR *out_desc);
     /*
          inflateBack() does a raw inflate with a single call using a call-back
        interface for input and output.  This is potentially more efficient than
    @@ -1189,7 +1192,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
        cannot return Z_OK.
     */
     
    -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
    +ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm);
     /*
          All memory allocated by inflateBackInit() is freed.
     
    @@ -1197,7 +1200,7 @@ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
        state was inconsistent.
     */
     
    -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
    +ZEXTERN uLong ZEXPORT zlibCompileFlags(void);
     /* Return flags indicating compile-time options.
     
         Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
    @@ -1250,8 +1253,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
        you need special options.
     */
     
    -ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
    -                                 const Bytef *source, uLong sourceLen));
    +ZEXTERN int ZEXPORT compress(Bytef *dest,   uLongf *destLen,
    +                             const Bytef *source, uLong sourceLen);
     /*
          Compresses the source buffer into the destination buffer.  sourceLen is
        the byte length of the source buffer.  Upon entry, destLen is the total size
    @@ -1265,9 +1268,9 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
        buffer.
     */
     
    -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
    -                                  const Bytef *source, uLong sourceLen,
    -                                  int level));
    +ZEXTERN int ZEXPORT compress2(Bytef *dest,   uLongf *destLen,
    +                              const Bytef *source, uLong sourceLen,
    +                              int level);
     /*
          Compresses the source buffer into the destination buffer.  The level
        parameter has the same meaning as in deflateInit.  sourceLen is the byte
    @@ -1281,15 +1284,15 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
        Z_STREAM_ERROR if the level parameter is invalid.
     */
     
    -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
    +ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen);
     /*
          compressBound() returns an upper bound on the compressed size after
        compress() or compress2() on sourceLen bytes.  It would be used before a
        compress() or compress2() call to allocate the destination buffer.
     */
     
    -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
    -                                   const Bytef *source, uLong sourceLen));
    +ZEXTERN int ZEXPORT uncompress(Bytef *dest,   uLongf *destLen,
    +                               const Bytef *source, uLong sourceLen);
     /*
          Decompresses the source buffer into the destination buffer.  sourceLen is
        the byte length of the source buffer.  Upon entry, destLen is the total size
    @@ -1306,8 +1309,8 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
        buffer with the uncompressed data up to that point.
     */
     
    -ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest,   uLongf *destLen,
    -                                    const Bytef *source, uLong *sourceLen));
    +ZEXTERN int ZEXPORT uncompress2(Bytef *dest,   uLongf *destLen,
    +                                const Bytef *source, uLong *sourceLen);
     /*
          Same as uncompress, except that sourceLen is a pointer, where the
        length of the source is *sourceLen.  On return, *sourceLen is the number of
    @@ -1326,7 +1329,7 @@ ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest,   uLongf *destLen,
     typedef struct gzFile_s *gzFile;    /* semi-opaque gzip file descriptor */
     
     /*
    -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
    +ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode);
     
          Open the gzip (.gz) file at path for reading and decompressing, or
        compressing and writing.  The mode parameter is as in fopen ("rb" or "wb")
    @@ -1363,7 +1366,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
        file could not be opened.
     */
     
    -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
    +ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode);
     /*
          Associate a gzFile with the file descriptor fd.  File descriptors are
        obtained from calls like open, dup, creat, pipe or fileno (if the file has
    @@ -1386,7 +1389,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
        will not detect if fd is invalid (unless fd is -1).
     */
     
    -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
    +ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size);
     /*
          Set the internal buffer size used by this library's functions for file to
        size.  The default buffer size is 8192 bytes.  This function must be called
    @@ -1402,7 +1405,7 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
        too late.
     */
     
    -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
    +ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy);
     /*
          Dynamically update the compression level and strategy for file.  See the
        description of deflateInit2 for the meaning of these parameters. Previously
    @@ -1413,7 +1416,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
        or Z_MEM_ERROR if there is a memory allocation error.
     */
     
    -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
    +ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len);
     /*
          Read and decompress up to len uncompressed bytes from file into buf.  If
        the input file is not in gzip format, gzread copies the given number of
    @@ -1443,8 +1446,8 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
        Z_STREAM_ERROR.
     */
     
    -ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
    -                                     gzFile file));
    +ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
    +                                 gzFile file);
     /*
          Read and decompress up to nitems items of size size from file into buf,
        otherwise operating as gzread() does.  This duplicates the interface of
    @@ -1469,14 +1472,14 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
        file, resetting and retrying on end-of-file, when size is not 1.
     */
     
    -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len));
    +ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len);
     /*
          Compress and write the len uncompressed bytes at buf to file. gzwrite
        returns the number of uncompressed bytes written or 0 in case of error.
     */
     
    -ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
    -                                      z_size_t nitems, gzFile file));
    +ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size,
    +                                  z_size_t nitems, gzFile file);
     /*
          Compress and write nitems items of size size from buf to file, duplicating
        the interface of stdio's fwrite(), with size_t request and return types.  If
    @@ -1489,7 +1492,7 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
        is returned, and the error state is set to Z_STREAM_ERROR.
     */
     
    -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
    +ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...);
     /*
          Convert, format, compress, and write the arguments (...) to file under
        control of the string format, as in fprintf.  gzprintf returns the number of
    @@ -1504,7 +1507,7 @@ ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
        This can be determined using zlibCompileFlags().
     */
     
    -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
    +ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s);
     /*
          Compress and write the given null-terminated string s to file, excluding
        the terminating null character.
    @@ -1512,7 +1515,7 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
          gzputs returns the number of characters written, or -1 in case of error.
     */
     
    -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
    +ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len);
     /*
          Read and decompress bytes from file into buf, until len-1 characters are
        read, or until a newline character is read and transferred to buf, or an
    @@ -1526,13 +1529,13 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
        buf are indeterminate.
     */
     
    -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
    +ZEXTERN int ZEXPORT gzputc(gzFile file, int c);
     /*
          Compress and write c, converted to an unsigned char, into file.  gzputc
        returns the value that was written, or -1 in case of error.
     */
     
    -ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
    +ZEXTERN int ZEXPORT gzgetc(gzFile file);
     /*
          Read and decompress one byte from file.  gzgetc returns this byte or -1
        in case of end of file or error.  This is implemented as a macro for speed.
    @@ -1541,7 +1544,7 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
        points to has been clobbered or not.
     */
     
    -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
    +ZEXTERN int ZEXPORT gzungetc(int c, gzFile file);
     /*
          Push c back onto the stream for file to be read as the first character on
        the next read.  At least one character of push-back is always allowed.
    @@ -1553,7 +1556,7 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
        gzseek() or gzrewind().
     */
     
    -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
    +ZEXTERN int ZEXPORT gzflush(gzFile file, int flush);
     /*
          Flush all pending output to file.  The parameter flush is as in the
        deflate() function.  The return value is the zlib error number (see function
    @@ -1569,8 +1572,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
     */
     
     /*
    -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
    -                                   z_off_t offset, int whence));
    +ZEXTERN z_off_t ZEXPORT gzseek(gzFile file,
    +                               z_off_t offset, int whence);
     
          Set the starting position to offset relative to whence for the next gzread
        or gzwrite on file.  The offset represents a number of bytes in the
    @@ -1588,7 +1591,7 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
        would be before the current position.
     */
     
    -ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
    +ZEXTERN int ZEXPORT    gzrewind(gzFile file);
     /*
          Rewind file. This function is supported only for reading.
     
    @@ -1596,7 +1599,7 @@ ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
     */
     
     /*
    -ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
    +ZEXTERN z_off_t ZEXPORT    gztell(gzFile file);
     
          Return the starting position for the next gzread or gzwrite on file.
        This position represents a number of bytes in the uncompressed data stream,
    @@ -1607,7 +1610,7 @@ ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
     */
     
     /*
    -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
    +ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file);
     
          Return the current compressed (actual) read or write offset of file.  This
        offset includes the count of bytes that precede the gzip stream, for example
    @@ -1616,7 +1619,7 @@ ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
        be used for a progress indicator.  On error, gzoffset() returns -1.
     */
     
    -ZEXTERN int ZEXPORT gzeof OF((gzFile file));
    +ZEXTERN int ZEXPORT gzeof(gzFile file);
     /*
          Return true (1) if the end-of-file indicator for file has been set while
        reading, false (0) otherwise.  Note that the end-of-file indicator is set
    @@ -1631,7 +1634,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file));
        has grown since the previous end of file was detected.
     */
     
    -ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
    +ZEXTERN int ZEXPORT gzdirect(gzFile file);
     /*
          Return true (1) if file is being copied directly while reading, or false
        (0) if file is a gzip stream being decompressed.
    @@ -1652,7 +1655,7 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
        gzip file reading and decompression, which may not be desired.)
     */
     
    -ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
    +ZEXTERN int ZEXPORT    gzclose(gzFile file);
     /*
          Flush all pending output for file, if necessary, close file and
        deallocate the (de)compression state.  Note that once file is closed, you
    @@ -1665,8 +1668,8 @@ ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
        last read ended in the middle of a gzip stream, or Z_OK on success.
     */
     
    -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
    -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
    +ZEXTERN int ZEXPORT gzclose_r(gzFile file);
    +ZEXTERN int ZEXPORT gzclose_w(gzFile file);
     /*
          Same as gzclose(), but gzclose_r() is only for use when reading, and
        gzclose_w() is only for use when writing or appending.  The advantage to
    @@ -1677,7 +1680,7 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
        zlib library.
     */
     
    -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
    +ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum);
     /*
          Return the error message for the last error which occurred on file.
        errnum is set to zlib error number.  If an error occurred in the file system
    @@ -1693,7 +1696,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
        functions above that do not distinguish those cases in their return values.
     */
     
    -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
    +ZEXTERN void ZEXPORT gzclearerr(gzFile file);
     /*
          Clear the error and end-of-file flags for file.  This is analogous to the
        clearerr() function in stdio.  This is useful for continuing to read a gzip
    @@ -1710,7 +1713,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
        library.
     */
     
    -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
    +ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len);
     /*
          Update a running Adler-32 checksum with the bytes buf[0..len-1] and
        return the updated checksum. An Adler-32 value is in the range of a 32-bit
    @@ -1730,15 +1733,15 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
          if (adler != original_adler) error();
     */
     
    -ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf,
    -                                    z_size_t len));
    +ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf,
    +                                z_size_t len);
     /*
          Same as adler32(), but with a size_t length.
     */
     
     /*
    -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
    -                                          z_off_t len2));
    +ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2,
    +                                      z_off_t len2);
     
          Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1
        and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
    @@ -1748,7 +1751,7 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
        negative, the result has no meaning or utility.
     */
     
    -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
    +ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len);
     /*
          Update a running CRC-32 with the bytes buf[0..len-1] and return the
        updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer.
    @@ -1766,30 +1769,30 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
          if (crc != original_crc) error();
     */
     
    -ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf,
    -                                  z_size_t len));
    +ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf,
    +                              z_size_t len);
     /*
          Same as crc32(), but with a size_t length.
     */
     
     /*
    -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
    +ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2);
     
          Combine two CRC-32 check values into one.  For two sequences of bytes,
        seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
        calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32
        check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
    -   len2.
    +   len2. len2 must be non-negative.
     */
     
     /*
    -ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2));
    +ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2);
     
          Return the operator corresponding to length len2, to be used with
    -   crc32_combine_op().
    +   crc32_combine_op(). len2 must be non-negative.
     */
     
    -ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op));
    +ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op);
     /*
          Give the same result as crc32_combine(), using op in place of len2. op is
        is generated from len2 by crc32_combine_gen(). This will be faster than
    @@ -1802,20 +1805,20 @@ ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op));
     /* deflateInit and inflateInit are macros to allow checking the zlib version
      * and the compiler's view of z_stream:
      */
    -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
    -                                     const char *version, int stream_size));
    -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
    -                                     const char *version, int stream_size));
    -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
    -                                      int windowBits, int memLevel,
    -                                      int strategy, const char *version,
    -                                      int stream_size));
    -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
    -                                      const char *version, int stream_size));
    -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
    -                                         unsigned char FAR *window,
    -                                         const char *version,
    -                                         int stream_size));
    +ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level,
    +                                 const char *version, int stream_size);
    +ZEXTERN int ZEXPORT inflateInit_(z_streamp strm,
    +                                 const char *version, int stream_size);
    +ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int  level, int  method,
    +                                  int windowBits, int memLevel,
    +                                  int strategy, const char *version,
    +                                  int stream_size);
    +ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int  windowBits,
    +                                  const char *version, int stream_size);
    +ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
    +                                     unsigned char FAR *window,
    +                                     const char *version,
    +                                     int stream_size);
     #ifdef Z_PREFIX_SET
     #  define z_deflateInit(strm, level) \
               deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
    @@ -1860,7 +1863,7 @@ struct gzFile_s {
         unsigned char *next;
         z_off64_t pos;
     };
    -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
    +ZEXTERN int ZEXPORT gzgetc_(gzFile file);       /* backward compatibility */
     #ifdef Z_PREFIX_SET
     #  undef z_gzgetc
     #  define z_gzgetc(g) \
    @@ -1877,13 +1880,13 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
      * without large file support, _LFS64_LARGEFILE must also be true
      */
     #ifdef Z_LARGE64
    -   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
    -   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
    -   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
    -   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
    -   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
    -   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
    -   ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t));
    +   ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
    +   ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
    +   ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
    +   ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
    +   ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t);
    +   ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t);
    +   ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t);
     #endif
     
     #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
    @@ -1905,50 +1908,50 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */
     #    define crc32_combine_gen crc32_combine_gen64
     #  endif
     #  ifndef Z_LARGE64
    -     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
    -     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
    -     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
    -     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
    -     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
    -     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
    -     ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
    +     ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
    +     ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int);
    +     ZEXTERN z_off_t ZEXPORT gztell64(gzFile);
    +     ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile);
    +     ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
    +     ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
    +     ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
     #  endif
     #else
    -   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
    -   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
    -   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
    -   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
    -   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
    -   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
    -   ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
    +   ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *);
    +   ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int);
    +   ZEXTERN z_off_t ZEXPORT gztell(gzFile);
    +   ZEXTERN z_off_t ZEXPORT gzoffset(gzFile);
    +   ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t);
    +   ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t);
    +   ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t);
     #endif
     
     #else /* Z_SOLO */
     
    -   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
    -   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
    -   ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
    +   ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t);
    +   ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t);
    +   ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t);
     
     #endif /* !Z_SOLO */
     
     /* undocumented functions */
    -ZEXTERN const char   * ZEXPORT zError           OF((int));
    -ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));
    -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table    OF((void));
    -ZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));
    -ZEXTERN int            ZEXPORT inflateValidate OF((z_streamp, int));
    -ZEXTERN unsigned long  ZEXPORT inflateCodesUsed OF((z_streamp));
    -ZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));
    -ZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));
    +ZEXTERN const char   * ZEXPORT zError(int);
    +ZEXTERN int            ZEXPORT inflateSyncPoint(z_streamp);
    +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void);
    +ZEXTERN int            ZEXPORT inflateUndermine(z_streamp, int);
    +ZEXTERN int            ZEXPORT inflateValidate(z_streamp, int);
    +ZEXTERN unsigned long  ZEXPORT inflateCodesUsed(z_streamp);
    +ZEXTERN int            ZEXPORT inflateResetKeep(z_streamp);
    +ZEXTERN int            ZEXPORT deflateResetKeep(z_streamp);
     #if defined(_WIN32) && !defined(Z_SOLO)
    -ZEXTERN gzFile         ZEXPORT gzopen_w OF((const wchar_t *path,
    -                                            const char *mode));
    +ZEXTERN gzFile         ZEXPORT gzopen_w(const wchar_t *path,
    +                                        const char *mode);
     #endif
     #if defined(STDC) || defined(Z_HAVE_STDARG_H)
     #  ifndef Z_SOLO
    -ZEXTERN int            ZEXPORTVA gzvprintf Z_ARG((gzFile file,
    -                                                  const char *format,
    -                                                  va_list va));
    +ZEXTERN int            ZEXPORTVA gzvprintf(gzFile file,
    +                                           const char *format,
    +                                           va_list va);
     #  endif
     #endif
     
    diff --git a/src/java.base/share/native/libzip/zlib/zutil.c b/src/java.base/share/native/libzip/zlib/zutil.c
    index ae147967861..92dda78497b 100644
    --- a/src/java.base/share/native/libzip/zlib/zutil.c
    +++ b/src/java.base/share/native/libzip/zlib/zutil.c
    @@ -48,13 +48,11 @@ z_const char * const z_errmsg[10] = {
     };
     
     
    -const char * ZEXPORT zlibVersion()
    -{
    +const char * ZEXPORT zlibVersion(void) {
         return ZLIB_VERSION;
     }
     
    -uLong ZEXPORT zlibCompileFlags()
    -{
    +uLong ZEXPORT zlibCompileFlags(void) {
         uLong flags;
     
         flags = 0;
    @@ -145,9 +143,7 @@ uLong ZEXPORT zlibCompileFlags()
     #  endif
     int ZLIB_INTERNAL z_verbose = verbose;
     
    -void ZLIB_INTERNAL z_error(m)
    -    char *m;
    -{
    +void ZLIB_INTERNAL z_error(char *m) {
         fprintf(stderr, "%s\n", m);
         exit(1);
     }
    @@ -156,9 +152,7 @@ void ZLIB_INTERNAL z_error(m)
     /* exported to allow conversion of error code to string for compress() and
      * uncompress()
      */
    -const char * ZEXPORT zError(err)
    -    int err;
    -{
    +const char * ZEXPORT zError(int err) {
         return ERR_MSG(err);
     }
     
    @@ -172,22 +166,14 @@ const char * ZEXPORT zError(err)
     
     #ifndef HAVE_MEMCPY
     
    -void ZLIB_INTERNAL zmemcpy(dest, source, len)
    -    Bytef* dest;
    -    const Bytef* source;
    -    uInt  len;
    -{
    +void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) {
         if (len == 0) return;
         do {
             *dest++ = *source++; /* ??? to be unrolled */
         } while (--len != 0);
     }
     
    -int ZLIB_INTERNAL zmemcmp(s1, s2, len)
    -    const Bytef* s1;
    -    const Bytef* s2;
    -    uInt  len;
    -{
    +int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) {
         uInt j;
     
         for (j = 0; j < len; j++) {
    @@ -196,10 +182,7 @@ int ZLIB_INTERNAL zmemcmp(s1, s2, len)
         return 0;
     }
     
    -void ZLIB_INTERNAL zmemzero(dest, len)
    -    Bytef* dest;
    -    uInt  len;
    -{
    +void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) {
         if (len == 0) return;
         do {
             *dest++ = 0;  /* ??? to be unrolled */
    @@ -240,8 +223,7 @@ local ptr_table table[MAX_PTR];
      * a protected system like OS/2. Use Microsoft C instead.
      */
     
    -voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
    -{
    +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
         voidpf buf;
         ulg bsize = (ulg)items*size;
     
    @@ -266,8 +248,7 @@ voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
         return buf;
     }
     
    -void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
    -{
    +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
         int n;
     
         (void)opaque;
    @@ -303,14 +284,12 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
     #  define _hfree   hfree
     #endif
     
    -voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size)
    -{
    +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) {
         (void)opaque;
         return _halloc((long)items, size);
     }
     
    -void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
    -{
    +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
         (void)opaque;
         _hfree(ptr);
     }
    @@ -323,25 +302,18 @@ void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
     #ifndef MY_ZCALLOC /* Any system without a special alloc function */
     
     #ifndef STDC
    -extern voidp  malloc OF((uInt size));
    -extern voidp  calloc OF((uInt items, uInt size));
    -extern void   free   OF((voidpf ptr));
    +extern voidp malloc(uInt size);
    +extern voidp calloc(uInt items, uInt size);
    +extern void free(voidpf ptr);
     #endif
     
    -voidpf ZLIB_INTERNAL zcalloc(opaque, items, size)
    -    voidpf opaque;
    -    unsigned items;
    -    unsigned size;
    -{
    +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
         (void)opaque;
         return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
                                   (voidpf)calloc(items, size);
     }
     
    -void ZLIB_INTERNAL zcfree(opaque, ptr)
    -    voidpf opaque;
    -    voidpf ptr;
    -{
    +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) {
         (void)opaque;
         free(ptr);
     }
    diff --git a/src/java.base/share/native/libzip/zlib/zutil.h b/src/java.base/share/native/libzip/zlib/zutil.h
    index a7c842d26df..2b7e697bef9 100644
    --- a/src/java.base/share/native/libzip/zlib/zutil.h
    +++ b/src/java.base/share/native/libzip/zlib/zutil.h
    @@ -23,7 +23,7 @@
      */
     
     /* zutil.h -- internal interface and configuration of the compression library
    - * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler
    + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
      * For conditions of distribution and use, see copyright notice in zlib.h
      */
     
    @@ -80,7 +80,7 @@ typedef unsigned long  ulg;
     extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
     /* (size given to avoid silly warnings with Visual C++) */
     
    -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
    +#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
     
     #define ERR_RETURN(strm,err) \
       return (strm->msg = ERR_MSG(err), (err))
    @@ -161,17 +161,8 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
     #  endif
     #endif
     
    -#if defined(MACOS) || defined(TARGET_OS_MAC)
    +#if defined(MACOS)
     #  define OS_CODE  7
    -#  ifndef Z_SOLO
    -#    if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
    -#      include  /* for fdopen */
    -#    else
    -#      ifndef fdopen
    -#        define fdopen(fd,mode) NULL /* No fdopen() */
    -#      endif
    -#    endif
    -#  endif
     #endif
     
     #ifdef __acorn
    @@ -194,18 +185,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
     #  define OS_CODE 19
     #endif
     
    -#if defined(_BEOS_) || defined(RISCOS)
    -#  define fdopen(fd,mode) NULL /* No fdopen() */
    -#endif
    -
    -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
    -#  if defined(_WIN32_WCE)
    -#    define fdopen(fd,mode) NULL /* No fdopen() */
    -#  else
    -#    define fdopen(fd,type)  _fdopen(fd,type)
    -#  endif
    -#endif
    -
     #if defined(__BORLANDC__) && !defined(MSDOS)
       #pragma warn -8004
       #pragma warn -8008
    @@ -215,9 +194,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
     /* provide prototypes for these when building zlib without LFS */
     #if !defined(_WIN32) && \
         (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
    -    ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
    -    ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
    -    ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
    +    ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t);
    +    ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t);
    +    ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t);
     #endif
     
             /* common defaults */
    @@ -256,16 +235,16 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
     #    define zmemzero(dest, len) memset(dest, 0, len)
     #  endif
     #else
    -   void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
    -   int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
    -   void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
    +   void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len);
    +   int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len);
    +   void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len);
     #endif
     
     /* Diagnostic functions */
     #ifdef ZLIB_DEBUG
     #  include 
        extern int ZLIB_INTERNAL z_verbose;
    -   extern void ZLIB_INTERNAL z_error OF((char *m));
    +   extern void ZLIB_INTERNAL z_error(char *m);
     #  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
     #  define Trace(x) {if (z_verbose>=0) fprintf x ;}
     #  define Tracev(x) {if (z_verbose>0) fprintf x ;}
    @@ -282,9 +261,9 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
     #endif
     
     #ifndef Z_SOLO
    -   voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
    -                                    unsigned size));
    -   void ZLIB_INTERNAL zcfree  OF((voidpf opaque, voidpf ptr));
    +   voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items,
    +                                unsigned size);
    +   void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr);
     #endif
     
     #define ZALLOC(strm, items, size) \
    
    From 37cfd4808dead6e846a3626f6e7b50cc9e207d98 Mon Sep 17 00:00:00 2001
    From: Aleksey Shipilev 
    Date: Mon, 25 Mar 2024 18:10:50 +0000
    Subject: [PATCH 053/149] 8328705: GHA: Cross-compilation jobs do not require
     build JDK
    
    Backport-of: 29ba4b7d1e62a834c1693fe6ad383c19467afc81
    ---
     .github/workflows/build-cross-compile.yml | 8 --------
     .github/workflows/main.yml                | 4 +---
     2 files changed, 1 insertion(+), 11 deletions(-)
    
    diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml
    index 7697ab075b2..385b097b9fc 100644
    --- a/.github/workflows/build-cross-compile.yml
    +++ b/.github/workflows/build-cross-compile.yml
    @@ -87,13 +87,6 @@ jobs:
             with:
               platform: linux-x64
     
    -        # Use linux-x64 JDK bundle as build JDK
    -      - name: 'Get build JDK'
    -        id: buildjdk
    -        uses: ./.github/actions/get-bundles
    -        with:
    -          platform: linux-x64
    -
             # Upgrading apt to solve libc6 installation bugs, see JDK-8260460.
           - name: 'Install toolchain and dependencies'
             run: |
    @@ -154,7 +147,6 @@ jobs:
               --disable-precompiled-headers
               --openjdk-target=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}
               --with-sysroot=sysroot
    -          --with-build-jdk=${{ steps.buildjdk.outputs.jdk-path }}
               CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-${{ inputs.gcc-major-version }}
               CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-${{ inputs.gcc-major-version }}
               ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || (
    diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
    index 418dd15df87..318f056aac1 100644
    --- a/.github/workflows/main.yml
    +++ b/.github/workflows/main.yml
    @@ -130,8 +130,7 @@ jobs:
           gcc-major-version: '10'
           configure-arguments: ${{ github.event.inputs.configure-arguments }}
           make-arguments: ${{ github.event.inputs.make-arguments }}
    -    # The linux-x64 jdk bundle is used as buildjdk for the cross-compile job
    -    if: needs.select.outputs.linux-x64 == 'true' || needs.select.outputs.linux-cross-compile == 'true'
    +    if: needs.select.outputs.linux-x64 == 'true'
     
       build-linux-x86:
         name: linux-x86
    @@ -211,7 +210,6 @@ jobs:
         name: linux-cross-compile
         needs:
           - select
    -      - build-linux-x64
         uses: ./.github/workflows/build-cross-compile.yml
         with:
           gcc-major-version: '10'
    
    From b7f78a39c2c11e351a927da97455efa112b70d1c Mon Sep 17 00:00:00 2001
    From: Ben Taylor 
    Date: Mon, 25 Mar 2024 23:27:02 +0000
    Subject: [PATCH 054/149] 8319436: Proxy.newProxyInstance throws NPE if loader
     is null and interface not visible from class loader
    
    Backport-of: 8eb6f617b3f8e2a990e4244af4e56287f9741b20
    ---
     .../share/classes/java/lang/System.java       |   2 +-
     .../lang/reflect/Proxy/ClassRestrictions.java | 187 ++++++------------
     2 files changed, 66 insertions(+), 123 deletions(-)
    
    diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java
    index 290f2742474..0f20f3e6abc 100644
    --- a/src/java.base/share/classes/java/lang/System.java
    +++ b/src/java.base/share/classes/java/lang/System.java
    @@ -2227,7 +2227,7 @@ public byte[] getBytesUTF8NoRepl(String s) {
                 }
     
                 public String getLoaderNameID(ClassLoader loader) {
    -                return loader.nameAndId();
    +                return loader != null ? loader.nameAndId() : "null";
                 }
             });
         }
    diff --git a/test/jdk/java/lang/reflect/Proxy/ClassRestrictions.java b/test/jdk/java/lang/reflect/Proxy/ClassRestrictions.java
    index ba5b407b99d..6f6dcb4d75b 100644
    --- a/test/jdk/java/lang/reflect/Proxy/ClassRestrictions.java
    +++ b/test/jdk/java/lang/reflect/Proxy/ClassRestrictions.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1999, 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
    @@ -22,13 +22,13 @@
      */
     
     /* @test
    - * @bug 4227192 8004928 8072656
    + * @bug 4227192 8004928 8072656 8319436
      * @summary This is a test of the restrictions on the parameters that may
      * be passed to the Proxy.getProxyClass method.
      * @author Peter Jones
      *
      * @build ClassRestrictions
    - * @run main ClassRestrictions
    + * @run junit ClassRestrictions
      */
     
     import java.io.File;
    @@ -37,6 +37,13 @@
     import java.net.URLClassLoader;
     import java.net.URL;
     import java.nio.file.Paths;
    +import java.util.List;
    +import java.util.stream.Stream;
    +
    +import org.junit.jupiter.api.Test;
    +import org.junit.jupiter.params.ParameterizedTest;
    +import org.junit.jupiter.params.provider.MethodSource;
    +import static org.junit.jupiter.api.Assertions.*;
     
     public class ClassRestrictions {
     
    @@ -52,129 +59,65 @@ interface Bashful {
             void foo();
         }
     
    -    public static final String nonPublicIntrfaceName = "java.util.zip.ZipConstants";
    -
    -    public static void main(String[] args) {
    -
    -        System.err.println(
    -            "\nTest of restrictions on parameters to Proxy.getProxyClass\n");
    -
    -        try {
    -            ClassLoader loader = ClassRestrictions.class.getClassLoader();
    -            Class[] interfaces;
    -            Class proxyClass;
    -
    -            /*
    -             * All of the Class objects in the interfaces array must represent
    -             * interfaces, not classes or primitive types.
    -             */
    -            try {
    -                interfaces = new Class[] { Object.class };
    -                proxyClass = Proxy.getProxyClass(loader, interfaces);
    -                throw new Error(
    -                    "proxy class created with java.lang.Object as interface");
    -            } catch (IllegalArgumentException e) {
    -                e.printStackTrace();
    -                System.err.println();
    -                // assume exception is for intended failure
    -            }
    -            try {
    -                interfaces = new Class[] { Integer.TYPE };
    -                proxyClass = Proxy.getProxyClass(loader, interfaces);
    -                throw new Error(
    -                    "proxy class created with int.class as interface");
    -            } catch (IllegalArgumentException e) {
    -                e.printStackTrace();
    -                System.err.println();
    -                // assume exception is for intended failure
    -            }
    -
    -            /*
    -             * No two elements in the interfaces array may refer to identical
    -             * Class objects.
    -             */
    -            try {
    -                interfaces = new Class[] { Bar.class, Bar.class };
    -                proxyClass = Proxy.getProxyClass(loader, interfaces);
    -                throw new Error(
    -                    "proxy class created with repeated interfaces");
    -            } catch (IllegalArgumentException e) {
    -                e.printStackTrace();
    -                System.err.println();
    -                // assume exception is for intended failure
    -            }
    -
    -            /*
    -             * All of the interfaces types must be visible by name though the
    -             * specified class loader.
    -             */
    -            String[] cpaths = System.getProperty("test.classes", ".")
    -                                    .split(File.pathSeparator);
    -            URL[] urls = new URL[cpaths.length];
    -            for (int i=0; i < cpaths.length; i++) {
    -                urls[i] = Paths.get(cpaths[i]).toUri().toURL();
    -            }
    -            ClassLoader altLoader = new URLClassLoader(urls, null);
    -            Class altBarClass;
    -            altBarClass = Class.forName(Bar.class.getName(), false, altLoader);
    -            try {
    -                interfaces = new Class[] { altBarClass };
    -                proxyClass = Proxy.getProxyClass(loader, interfaces);
    -                throw new Error(
    -                    "proxy class created with interface " +
    -                    "not visible to class loader");
    -            } catch (IllegalArgumentException e) {
    -                e.printStackTrace();
    -                System.err.println();
    -                // assume exception is for intended failure
    -            }
    +    private static final String TEST_CLASSES = System.getProperty("test.classes", ".");
    +    private static final ClassLoader LOADER = ClassRestrictions.class.getClassLoader();
    +
    +    static Stream>> badProxyInterfaces() {
    +        return Stream.of(
    +                List.of(Object.class),          // proxy interface cannot be a class
    +                List.of(int.class),             // proxy interface can't be primitive type
    +                List.of(Bar.class, Bar.class),  // cannot have repeated interfaces
    +                // two proxy interfaces have the method of same method name but different return type
    +                List.of(Bar.class, Baz.class)
    +        );
    +    }
     
    -            /*
    -             * All non-public interfaces must be in the same package.
    -             */
    -            Class nonPublic1 = Bashful.class;
    -            Class nonPublic2 = Class.forName(nonPublicIntrfaceName);
    -            if (Modifier.isPublic(nonPublic2.getModifiers())) {
    -                throw new Error(
    -                    "Interface " + nonPublicIntrfaceName +
    -                    " is public and need to be changed!");
    -            }
    -            try {
    -                interfaces = new Class[] { nonPublic1, nonPublic2 };
    -                proxyClass = Proxy.getProxyClass(loader, interfaces);
    -                throw new Error(
    -                    "proxy class created with two non-public interfaces " +
    -                    "in different packages");
    -            } catch (IllegalArgumentException e) {
    -                e.printStackTrace();
    -                System.err.println();
    -                // assume exception is for intended failure
    -            }
    +    /*
    +     * Test cases for illegal proxy interfaces
    +     */
    +    @ParameterizedTest
    +    @MethodSource("badProxyInterfaces")
    +    void testForName(List> interfaces) {
    +        assertThrows(IllegalArgumentException.class, () -> Proxy.getProxyClass(LOADER, interfaces.toArray(Class[]::new)));
    +    }
     
    -            /*
    -             * No two interfaces may each have a method with the same name and
    -             * parameter signature but different return type.
    -             */
    -            try {
    -                interfaces = new Class[] { Bar.class, Baz.class };
    -                proxyClass = Proxy.getProxyClass(loader, interfaces);
    -                throw new Error(
    -                    "proxy class created with conflicting methods");
    -            } catch (IllegalArgumentException e) {
    -                e.printStackTrace();
    -                System.err.println();
    -                // assume exception is for intended failure
    -            }
    +    private static final String nonPublicIntrfaceName = "java.util.zip.ZipConstants";
    +
    +    /*
    +     * All non-public interfaces must be in the same package.
    +     */
    +    @Test
    +    void testNonPublicIntfs() throws Exception {
    +        var nonPublic1 = Bashful.class;
    +        var nonPublic2 = Class.forName(nonPublicIntrfaceName);
    +        assertFalse(Modifier.isPublic(nonPublic2.getModifiers()),
    +            "Interface " + nonPublicIntrfaceName + " is public and need to be changed!");
    +        var interfaces = new Class[] { nonPublic1, nonPublic2 };
    +        assertThrows(IllegalArgumentException.class, () -> Proxy.getProxyClass(LOADER, interfaces));
    +    }
     
    -            /*
    -             * All components of this test have passed.
    -             */
    -            System.err.println("\nTEST PASSED");
    +    static Stream loaders() {
    +        return Stream.of(null,
    +                         ClassLoader.getPlatformClassLoader(),
    +                         ClassLoader.getSystemClassLoader(),
    +                         LOADER);
    +    }
     
    -        } catch (Throwable e) {
    -            System.err.println("\nTEST FAILED:");
    -            e.printStackTrace();
    -            throw new Error("TEST FAILED: ", e);
    +    /*
    +     * All of the interfaces types must be visible by name though the
    +     * specified class loader.
    +     */
    +    @ParameterizedTest
    +    @MethodSource("loaders")
    +    void testNonVisibleInterface(ClassLoader loader) throws Exception {
    +        String[] cpaths = TEST_CLASSES.split(File.pathSeparator);
    +        URL[] urls = new URL[cpaths.length];
    +        for (int i = 0; i < cpaths.length; i++) {
    +            urls[i] = Paths.get(cpaths[i]).toUri().toURL();
             }
    +        var altLoader = new URLClassLoader(urls, null);
    +        var altBarClass = Class.forName(Bar.class.getName(), false, altLoader);
    +        var interfaces = new Class[]{ altBarClass };
    +        assertThrows(IllegalArgumentException.class, () -> Proxy.getProxyClass(loader, interfaces));
         }
     }
    
    From d98b4607e73d74b4b4f77c5e6363486241156926 Mon Sep 17 00:00:00 2001
    From: Martin Balao 
    Date: Wed, 27 Mar 2024 03:22:33 +0000
    Subject: [PATCH 055/149] 8317507: C2 compilation fails with "Exceeded
     _node_regs array"
    
    Reviewed-by: roland, andrew
    Backport-of: a5818972c16bd883d768ff2fb23a8aa9e0142c65
    ---
     src/hotspot/share/adlc/output_c.cpp           |   3 +
     .../regalloc/TestNodeRegArrayOverflow.java    | 599 ++++++++++++++++++
     2 files changed, 602 insertions(+)
     create mode 100644 test/hotspot/jtreg/compiler/regalloc/TestNodeRegArrayOverflow.java
    
    diff --git a/src/hotspot/share/adlc/output_c.cpp b/src/hotspot/share/adlc/output_c.cpp
    index 9d9154eaec1..9fe8b6e3afe 100644
    --- a/src/hotspot/share/adlc/output_c.cpp
    +++ b/src/hotspot/share/adlc/output_c.cpp
    @@ -3040,6 +3040,9 @@ static void define_fill_new_machnode(bool used, FILE *fp_cpp) {
         fprintf(fp_cpp, "    if( i != cisc_operand() ) \n");
         fprintf(fp_cpp, "      to[i] = _opnds[i]->clone();\n");
         fprintf(fp_cpp, "  }\n");
    +    fprintf(fp_cpp, "  // Do not increment node index counter, since node reuses my index\n");
    +    fprintf(fp_cpp, "  Compile* C = Compile::current();\n");
    +    fprintf(fp_cpp, "  C->set_unique(C->unique() - 1);\n");
         fprintf(fp_cpp, "}\n");
       }
       fprintf(fp_cpp, "\n");
    diff --git a/test/hotspot/jtreg/compiler/regalloc/TestNodeRegArrayOverflow.java b/test/hotspot/jtreg/compiler/regalloc/TestNodeRegArrayOverflow.java
    new file mode 100644
    index 00000000000..281524cc13f
    --- /dev/null
    +++ b/test/hotspot/jtreg/compiler/regalloc/TestNodeRegArrayOverflow.java
    @@ -0,0 +1,599 @@
    +/*
    + * 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.
    + *
    + * 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 compiler.regalloc;
    +
    +/**
    + * @test
    + * @bug 8317507
    + * @summary Test that C2's PhaseRegAlloc::_node_regs (a post-register-allocation
    + *          mapping from machine nodes to assigned registers) does not overflow
    + *          in the face of a program with a high-density of CISC spilling
    + *          candidate nodes.
    + * @run main/othervm -Xcomp -XX:CompileOnly=compiler.regalloc.TestNodeRegArrayOverflow::testWithCompilerUnrolling
    +                     -XX:CompileCommand=dontinline,compiler.regalloc.TestNodeRegArrayOverflow::dontInline
    +                     compiler.regalloc.TestNodeRegArrayOverflow compiler
    + * @run main/othervm -Xcomp -XX:CompileOnly=compiler.regalloc.TestNodeRegArrayOverflow::testWithManualUnrolling
    +                     -XX:CompileCommand=dontinline,compiler.regalloc.TestNodeRegArrayOverflow::dontInline
    +                     compiler.regalloc.TestNodeRegArrayOverflow manual
    + */
    +
    +public class TestNodeRegArrayOverflow {
    +
    +    static int dontInline() {
    +        return 0;
    +    }
    +
    +    static float testWithCompilerUnrolling(float inc) {
    +        int i = 0, j = 0;
    +        // This non-inlined method call causes 'inc' to be spilled.
    +        float f = dontInline();
    +        // This two-level reduction loop is unrolled 512 times, which is
    +        // requested by the SLP-specific unrolling analysis, but not vectorized.
    +        // Because 'inc' is spilled, each of the unrolled AddF nodes is
    +        // CISC-spill converted (PhaseChaitin::fixup_spills()). Before the fix,
    +        // this causes the unique node index counter (Compile::_unique) to grow
    +        // beyond the size of the node register array
    +        // (PhaseRegAlloc::_node_regs), and leads to overflow when accessed for
    +        // nodes that are created later (e.g. during the peephole phase).
    +        while (i++ < 128) {
    +            for (j = 0; j < 16; j++) {
    +                f += inc;
    +            }
    +        }
    +        return f;
    +    }
    +
    +    // This test reproduces the same failure as 'testWithCompilerUnrolling'
    +    // without relying on loop transformations.
    +    static float testWithManualUnrolling(float inc) {
    +        int i = 0, j = 0;
    +        float f = dontInline();
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        f += inc;
    +        return f;
    +    }
    +
    +    public static void main(String[] args) {
    +        switch (args[0]) {
    +        case "compiler":
    +            testWithCompilerUnrolling(0);
    +            break;
    +        case "manual":
    +            testWithManualUnrolling(0);
    +            break;
    +        default:
    +            throw new IllegalArgumentException("Invalid mode: " + args[0]);
    +        }
    +    }
    +}
    
    From 4117953453635dbaea56add47a6fde5eb3f1258d Mon Sep 17 00:00:00 2001
    From: Ben Taylor 
    Date: Wed, 27 Mar 2024 17:22:15 +0000
    Subject: [PATCH 056/149] 8273831: PrintServiceLookup spawns 2 threads in the
     current classloader, getting orphaned
    
    Backport-of: 687567822a5380fb7d8c5b54ae548b2a5c848187
    ---
     .../sun/print/PrintServiceLookupProvider.java | 20 +++--
     .../sun/print/PrintServiceLookupProvider.java | 29 +++++--
     .../FlushCustomClassLoader.java               | 84 +++++++++++++++++++
     3 files changed, 117 insertions(+), 16 deletions(-)
     create mode 100644 test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java
    
    diff --git a/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java b/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java
    index 93f65327e08..edce4418919 100644
    --- a/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java
    +++ b/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java
    @@ -26,10 +26,8 @@
     package sun.print;
     
     import java.io.BufferedReader;
    -import java.io.FileInputStream;
    -import java.io.InputStream;
    -import java.io.InputStreamReader;
     import java.io.IOException;
    +import java.security.PrivilegedAction;
     import java.util.ArrayList;
     import java.util.Vector;
     import java.security.AccessController;
    @@ -54,6 +52,8 @@
     import java.net.URL;
     import java.nio.file.Files;
     
    +import sun.awt.util.ThreadGroupUtils;
    +
     /*
      * Remind: This class uses solaris commands. We also need a linux
      * version
    @@ -207,14 +207,18 @@ static int getBSDCommandIndex() {
             return BSD_LPD;
         }
     
    -
    +    @SuppressWarnings("removal")
         public PrintServiceLookupProvider() {
             // start the printer listener thread
             if (pollServices) {
    -            Thread thr = new Thread(null, new PrinterChangeListener(),
    -                                    "PrinterListener", 0, false);
    -            thr.setDaemon(true);
    -            thr.start();
    +            AccessController.doPrivileged((PrivilegedAction) () -> {
    +                Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(),
    +                                        new PrinterChangeListener(),
    +                                        "PrinterListener", 0, false);
    +                thr.setContextClassLoader(null);
    +                thr.setDaemon(true);
    +                return thr;
    +            }).start();
                 IPPPrintService.debug_println(debugPrefix+"polling turned on");
             }
         }
    diff --git a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java
    index f82ca605324..cf488c4b162 100644
    --- a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java
    +++ b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java
    @@ -25,6 +25,8 @@
     
     package sun.print;
     
    +import java.security.AccessController;
    +import java.security.PrivilegedAction;
     import java.util.ArrayList;
     
     import javax.print.DocFlavor;
    @@ -41,6 +43,8 @@
     import javax.print.attribute.PrintServiceAttributeSet;
     import javax.print.attribute.standard.PrinterName;
     
    +import sun.awt.util.ThreadGroupUtils;
    +
     public class PrintServiceLookupProvider extends PrintServiceLookup {
     
         private String defaultPrinter;
    @@ -78,22 +82,31 @@ public static PrintServiceLookupProvider getWin32PrintLUS() {
             return win32PrintLUS;
         }
     
    +    @SuppressWarnings("removal")
         public PrintServiceLookupProvider() {
     
             if (win32PrintLUS == null) {
                 win32PrintLUS = this;
     
                 // start the local printer listener thread
    -            Thread thr = new Thread(null, new PrinterChangeListener(),
    -                                    "PrinterListener", 0, false);
    -            thr.setDaemon(true);
    -            thr.start();
    +            AccessController.doPrivileged((PrivilegedAction) () -> {
    +                Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(),
    +                                        new PrinterChangeListener(),
    +                                        "PrinterListener", 0, false);
    +                thr.setContextClassLoader(null);
    +                thr.setDaemon(true);
    +                return thr;
    +            }).start();
     
                 // start the remote printer listener thread
    -            Thread remThr = new Thread(null, new RemotePrinterChangeListener(),
    -                                       "RemotePrinterListener", 0, false);
    -            remThr.setDaemon(true);
    -            remThr.start();
    +            AccessController.doPrivileged((PrivilegedAction) () -> {
    +                Thread thr = new Thread(ThreadGroupUtils.getRootThreadGroup(),
    +                                        new RemotePrinterChangeListener(),
    +                                        "RemotePrinterListener", 0, false);
    +                thr.setContextClassLoader(null);
    +                thr.setDaemon(true);
    +                return thr;
    +            }).start();
             } /* else condition ought to never happen! */
         }
     
    diff --git a/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java b/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java
    new file mode 100644
    index 00000000000..6e0a25a69d0
    --- /dev/null
    +++ b/test/jdk/javax/print/PrintServiceLookup/FlushCustomClassLoader.java
    @@ -0,0 +1,84 @@
    +/*
    + * Copyright Amazon.com Inc. 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.
    + *
    + * 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.
    + */
    +
    +import java.awt.EventQueue;
    +import java.lang.ref.Reference;
    +import java.lang.ref.WeakReference;
    +import java.net.URL;
    +import java.net.URLClassLoader;
    +
    +import javax.print.DocFlavor;
    +import javax.print.PrintServiceLookup;
    +
    +/**
    + * @test
    + * @bug 8273831
    + * @summary Tests custom class loader cleanup
    + */
    +public final class FlushCustomClassLoader {
    +
    +    public static void main(String[] args) throws Exception {
    +        Reference loader = getLoader("testMethod");
    +
    +        int attempt = 0;
    +        while (loader.get() != null) {
    +            if (++attempt > 10) {
    +                throw new RuntimeException("Too many attempts: " + attempt);
    +            }
    +            System.gc();
    +            Thread.sleep(1000);
    +            System.out.println("Not freed, attempt: " + attempt);
    +        }
    +    }
    +
    +    public static void testMethod() {
    +        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
    +        PrintServiceLookup.lookupPrintServices(flavor, null);
    +    }
    +
    +    private static Reference getLoader(String m) throws Exception {
    +        /*
    +         * The print services are stored per the AppContext, and each AppContext
    +         * caches the "current" class loader during creation.
    +         * see javax.print.PrintServiceLookup.
    +         *
    +         * To prevent AppContext from cache our test loader we force AppContext
    +         * creation early by the invokeAndWait.
    +         * The "EventQueue.invokeAndWait(() -> {});" can be removed when the
    +         * AppContext usage will be deleted in the PrintServiceLookup
    +         */
    +        EventQueue.invokeAndWait(() -> {});
    +
    +        URL url = FlushCustomClassLoader.class.getProtectionDomain()
    +                                              .getCodeSource().getLocation();
    +        URLClassLoader loader = new URLClassLoader(new URL[]{url}, null);
    +
    +        Thread ct = Thread.currentThread();
    +        ct.setContextClassLoader(loader);
    +        Class cls = Class.forName("FlushCustomClassLoader", true, loader);
    +        cls.getDeclaredMethod(m).invoke(null);
    +        ct.setContextClassLoader(null);
    +        loader.close();
    +        return new WeakReference<>(loader);
    +    }
    +}
    
    From 29a08f77e8b1f98ffc6b34b5f3ecebad1424a712 Mon Sep 17 00:00:00 2001
    From: Andrew Lu 
    Date: Thu, 28 Mar 2024 02:08:38 +0000
    Subject: [PATCH 057/149] 8210988: Improved handling of compiler warnings in
     the build
    
    Reviewed-by: lucy
    Backport-of: 09a967ab8143c3d4b0824a0027edaf0e634686ec
    ---
     make/autoconf/flags-cflags.m4     | 74 +++++++++++++++++++------------
     make/autoconf/flags-ldflags.m4    |  8 ++++
     make/autoconf/spec.gmk.in         |  4 ++
     make/common/NativeCompilation.gmk |  9 +++-
     make/hotspot/lib/CompileGtest.gmk | 13 +++---
     make/hotspot/lib/CompileJvm.gmk   | 29 +++++++++---
     6 files changed, 97 insertions(+), 40 deletions(-)
    
    diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4
    index df7fe5f9fef..522204d78c7 100644
    --- a/make/autoconf/flags-cflags.m4
    +++ b/make/autoconf/flags-cflags.m4
    @@ -172,28 +172,53 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS],
           DISABLE_WARNING_PREFIX="-wd"
           BUILD_CC_DISABLE_WARNING_PREFIX="-wd"
           CFLAGS_WARNINGS_ARE_ERRORS="-WX"
    +
    +      WARNINGS_ENABLE_ALL="-W3"
    +      DISABLED_WARNINGS="4800"
           ;;
    +
         solstudio)
           DISABLE_WARNING_PREFIX="-erroff="
    -      CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all"
    +      CFLAGS_WARNINGS_ARE_ERRORS="-errwarn=%all"
    +
    +      WARNINGS_ENABLE_ALL_CFLAGS="-v"
    +      WARNINGS_ENABLE_ALL_CXXFLAGS="+w"
    +
    +      DISABLED_WARNINGS_C=""
    +      DISABLED_WARNINGS_CXX=""
           ;;
    +
         gcc)
           DISABLE_WARNING_PREFIX="-Wno-"
           BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
           CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
           ;;
    +
         clang)
           DISABLE_WARNING_PREFIX="-Wno-"
           CFLAGS_WARNINGS_ARE_ERRORS="-Werror"
    +
    +      WARNINGS_ENABLE_ALL="-Wall -Wextra -Wformat=2"
    +      WARNINGS_ENABLE_ADDITIONAL_JVM="-Wpointer-arith -Wsign-compare -Wunused-function -Wundef -Wunused-value -Woverloaded-virtual -Wreorder"
    +
    +      DISABLED_WARNINGS="unused-parameter unused"
           ;;
    +
         xlc)
           DISABLE_WARNING_PREFIX="-qsuppress="
           CFLAGS_WARNINGS_ARE_ERRORS="-qhalt=w"
    +
    +      # Possibly a better subset than "all" is "lan:trx:ret:zea:cmp:ret"
    +      WARNINGS_ENABLE_ALL="-qinfo=all -qformat=all"
    +      DISABLED_WARNINGS=""
           ;;
       esac
       AC_SUBST(DISABLE_WARNING_PREFIX)
       AC_SUBST(BUILD_CC_DISABLE_WARNING_PREFIX)
       AC_SUBST(CFLAGS_WARNINGS_ARE_ERRORS)
    +  AC_SUBST(DISABLED_WARNINGS)
    +  AC_SUBST(DISABLED_WARNINGS_C)
    +  AC_SUBST(DISABLED_WARNINGS_CXX)
     ])
     
     AC_DEFUN([FLAGS_SETUP_QUALITY_CHECKS],
    @@ -527,11 +552,14 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
           TOOLCHAIN_CFLAGS_JDK_CONLY="-fno-strict-aliasing" # technically NOT for CXX
         fi
       elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
    -    TOOLCHAIN_CFLAGS_JDK="-mt"
    -    TOOLCHAIN_CFLAGS_JDK_CONLY="-xCC -Xa -v -W0,-noglobal" # C only
    +    TOOLCHAIN_FLAGS="-errtags -errfmt"
    +    TOOLCHAIN_CFLAGS="-errshort=tags"
    +
    +    TOOLCHAIN_CFLAGS_JDK="-mt $TOOLCHAIN_FLAGS"
    +    TOOLCHAIN_CFLAGS_JDK_CONLY="-xc99=%none -xCC -Xa -W0,-noglobal $TOOLCHAIN_CFLAGS" # C only
         TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
         TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
    -        -library=stlport4 -mt -features=no%except"
    +        -library=stlport4 -mt -features=no%except $TOOLCHAIN_FLAGS"
         if test "x$DEBUG_LEVEL" = xslowdebug; then
           # Previously -g was used instead of -g0 for slowdebug; this is equivalent
           # to setting +d.
    @@ -539,6 +567,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
         fi
     
       elif test "x$TOOLCHAIN_TYPE" = xxlc; then
    +    # Suggested additions: -qsrcmsg to get improved error reporting
         # set -qtbtable=full for a better traceback table/better stacks in hs_err when xlc16 is used
         TOOLCHAIN_CFLAGS_JDK="-qtbtable=full -qchars=signed -qfullpath -qsaveopt -qstackprotect"  # add on both CFLAGS
         TOOLCHAIN_CFLAGS_JVM="-qtbtable=full -qtune=balanced \
    @@ -550,37 +579,26 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
     
       # CFLAGS WARNINGS STUFF
       # Set JVM_CFLAGS warning handling
    -  if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then
    -    # COMMON to gcc and clang
    -    WARNING_CFLAGS_JVM="-Wpointer-arith -Wsign-compare -Wunused-function"
    -    if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
    -      # Non-zero builds have stricter warnings
    -      WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wundef -Wformat=2"
    -    fi
    -
    -  fi
       if test "x$TOOLCHAIN_TYPE" = xgcc; then
    -    WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
    -    WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wunused-value -Woverloaded-virtual"
    +    WARNING_CFLAGS_JDK="$WARNINGS_ENABLE_ALL"
    +    WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL $WARNINGS_ENABLE_ADDITIONAL_JVM"
     
    -    if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
    -      # Non-zero builds have stricter warnings
    -      WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wreturn-type"
    -    fi
       elif test "x$TOOLCHAIN_TYPE" = xclang; then
    -    WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-deprecated"
         if test "x$OPENJDK_TARGET_OS" = xlinux; then
    -      WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-sometimes-uninitialized"
    -      WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
    +      WARNING_CFLAGS_JDK="$WARNINGS_ENABLE_ALL"
    +    else
    +      WARNING_CFLAGS_JDK="" # currently left empty
         fi
    +    WARNING_CFLAGS_JVM="$WARNINGS_ENABLE_ALL $WARNINGS_ENABLE_ADDITIONAL_JVM"
    +
       elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
    -    WARNING_CFLAGS_JDK_CONLY="-errshort=tags"
    -    WARNING_CFLAGS_JDK_CXXONLY="+w"
    -    WARNING_CFLAGS_JDK="-errtags=yes -errfmt"
    +    WARNING_CFLAGS_JDK_CONLY="$WARNINGS_ENABLE_ALL_CFLAGS"
    +    WARNING_CFLAGS_JDK_CXXONLY="$WARNINGS_ENABLE_ALL_CXXFLAGS"
    +    WARNING_CFLAGS_JVM="" # currently left empty
       elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
    -    WARNING_CFLAGS="-W3"
    -    WARNING_CFLAGS_JDK="-wd4800"
    -    WARNING_CFLAGS_JVM="-wd4800"
    +    WARNING_CFLAGS="$WARNINGS_ENABLE_ALL"
    +  elif test "x$TOOLCHAIN_TYPE" = xxlc; then
    +    WARNING_CFLAGS=""  # currently left empty
       fi
     
       # Set some additional per-OS defines.
    diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4
    index 2202bb69e96..9db09c38380 100644
    --- a/make/autoconf/flags-ldflags.m4
    +++ b/make/autoconf/flags-ldflags.m4
    @@ -137,6 +137,14 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_HELPER],
         fi
       fi
     
    +  # Setup warning flags
    +  if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
    +    LDFLAGS_WARNINGS_ARE_ERRORS="-Wl,-z,fatal-warnings"
    +  else
    +    LDFLAGS_WARNINGS_ARE_ERRORS=""
    +  fi
    +  AC_SUBST(LDFLAGS_WARNINGS_ARE_ERRORS)
    +
       # Setup LDFLAGS for linking executables
       if test "x$TOOLCHAIN_TYPE" = xgcc; then
         EXECUTABLE_LDFLAGS="$EXECUTABLE_LDFLAGS -Wl,--allow-shlib-undefined"
    diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in
    index 3787b126002..34a056ea63e 100644
    --- a/make/autoconf/spec.gmk.in
    +++ b/make/autoconf/spec.gmk.in
    @@ -469,6 +469,10 @@ CXX_FLAG_DEPS:=@CXX_FLAG_DEPS@
     
     DISABLE_WARNING_PREFIX := @DISABLE_WARNING_PREFIX@
     CFLAGS_WARNINGS_ARE_ERRORS:=@CFLAGS_WARNINGS_ARE_ERRORS@
    +LDFLAGS_WARNINGS_ARE_ERRORS:=@LDFLAGS_WARNINGS_ARE_ERRORS@
    +DISABLED_WARNINGS := @DISABLED_WARNINGS@
    +DISABLED_WARNINGS_C := @DISABLED_WARNINGS_C@
    +DISABLED_WARNINGS_CXX := @DISABLED_WARNINGS_CXX@
     
     # A global flag (true or false) determining if native warnings are considered errors.
     WARNINGS_AS_ERRORS := @WARNINGS_AS_ERRORS@
    diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk
    index 0710bf5bf97..d765b77ca90 100644
    --- a/make/common/NativeCompilation.gmk
    +++ b/make/common/NativeCompilation.gmk
    @@ -747,9 +747,13 @@ define SetupNativeCompilationBody
       # Pick up disabled warnings, if possible on this platform.
       ifneq ($(DISABLE_WARNING_PREFIX), )
         $1_EXTRA_CFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
    +        $$(DISABLED_WARNINGS) \
    +        $$(DISABLED_WARNINGS_C) \
             $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
             $$($1_DISABLED_WARNINGS_C_$(TOOLCHAIN_TYPE)))
         $1_EXTRA_CXXFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), \
    +        $$(DISABLED_WARNINGS) \
    +        $$(DISABLED_WARNINGS_CXX) \
             $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)) \
             $$($1_DISABLED_WARNINGS_CXX_$(TOOLCHAIN_TYPE)))
       endif
    @@ -767,6 +771,7 @@ define SetupNativeCompilationBody
       ifeq ($$($1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE)), true)
         $1_EXTRA_CFLAGS += $(CFLAGS_WARNINGS_ARE_ERRORS)
         $1_EXTRA_CXXFLAGS += $(CFLAGS_WARNINGS_ARE_ERRORS)
    +    $1_EXTRA_LDFLAGS += $(LDFLAGS_WARNINGS_ARE_ERRORS)
       endif
     
       ifeq (NONE, $$($1_OPTIMIZATION))
    @@ -975,8 +980,8 @@ define SetupNativeCompilationBody
     
       # Pickup extra OPENJDK_TARGET_OS_TYPE and/or OPENJDK_TARGET_OS dependent variables
       # for LDFLAGS and LIBS
    -  $1_EXTRA_LDFLAGS := $$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS))
    -  $1_EXTRA_LIBS := $$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
    +  $1_EXTRA_LDFLAGS += $$($1_LDFLAGS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LDFLAGS_$(OPENJDK_TARGET_OS))
    +  $1_EXTRA_LIBS += $$($1_LIBS_$(OPENJDK_TARGET_OS_TYPE)) $$($1_LIBS_$(OPENJDK_TARGET_OS))
       ifneq ($$($1_REAL_MAPFILE), )
         $1_EXTRA_LDFLAGS += $(call SET_SHARED_LIBRARY_MAPFILE,$$($1_REAL_MAPFILE))
       endif
    diff --git a/make/hotspot/lib/CompileGtest.gmk b/make/hotspot/lib/CompileGtest.gmk
    index 891c540bb80..f6af4d3b0b4 100644
    --- a/make/hotspot/lib/CompileGtest.gmk
    +++ b/make/hotspot/lib/CompileGtest.gmk
    @@ -77,11 +77,14 @@ $(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \
         CFLAGS_windows := -EHsc, \
         CFLAGS_solaris := -DGTEST_HAS_EXCEPTIONS=0 -library=stlport4 +d, \
         CFLAGS_macosx := -DGTEST_OS_MAC=1, \
    -    DISABLED_WARNINGS_gcc := undef stringop-overflow, \
    -    DISABLED_WARNINGS_clang := undef switch format-nonliteral \
    -        tautological-undefined-compare $(BUILD_LIBJVM_DISABLED_WARNINGS_clang), \
    -    DISABLED_WARNINGS_solstudio := identexpected, \
    -    DISABLED_WARNINGS_microsoft := 4146, \
    +    DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc) \
    +        undef, \
    +    DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang) \
    +        undef switch format-nonliteral tautological-undefined-compare, \
    +    DISABLED_WARNINGS_solstudio := $(DISABLED_WARNINGS_solstudio) \
    +        identexpected, \
    +    DISABLED_WARNINGS_microsoft := $(DISABLED_WARNINGS_microsoft) \
    +        4146, \
         LDFLAGS := $(JVM_LDFLAGS), \
         LDFLAGS_solaris := -library=stlport4 $(call SET_SHARED_LIBRARY_ORIGIN), \
         LIBS := $(JVM_LIBS), \
    diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk
    index bce8bf0c9d1..48e75e241c6 100644
    --- a/make/hotspot/lib/CompileJvm.gmk
    +++ b/make/hotspot/lib/CompileJvm.gmk
    @@ -81,6 +81,25 @@ CFLAGS_VM_VERSION := \
         -DCPU='"$(OPENJDK_TARGET_CPU_VM_VERSION)"' \
         #
     
    +################################################################################
    +# Disabled warnings
    +
    +DISABLED_WARNINGS_gcc := extra all
    +ifeq ($(call check-jvm-feature, zero), true)
    +  DISABLED_WARNINGS_gcc += return-type
    +endif
    +
    +DISABLED_WARNINGS_clang := extra all tautological-compare deprecated-declarations
    +
    +DISABLED_WARNINGS_solstudio :=
    +
    +DISABLED_WARNINGS_xlc := 1540-0216 1540-0198 1540-1090 1540-1639 1540-1088 \
    +    1500-010
    +
    +DISABLED_WARNINGS_microsoft :=
    +
    +
    +
     ################################################################################
     # Platform specific setup
     
    @@ -117,7 +136,7 @@ ifeq ($(call isTargetOs, solaris), true)
       endif
       # Exclude warnings in devstudio 12.6
       ifeq ($(CC_VERSION_NUMBER), 5.15)
    -    DISABLED_WARNINGS_solstudio := SEC_ARR_OUTSIDE_BOUND_READ \
    +    DISABLED_WARNINGS_solstudio += SEC_ARR_OUTSIDE_BOUND_READ \
           SEC_ARR_OUTSIDE_BOUND_WRITE
       endif
     endif
    @@ -162,11 +181,11 @@ $(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
         CFLAGS := $(JVM_CFLAGS), \
         abstract_vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
         arguments.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
    -    DISABLED_WARNINGS_clang := tautological-compare, \
    +    DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc), \
    +    DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang), \
         DISABLED_WARNINGS_solstudio := $(DISABLED_WARNINGS_solstudio), \
    -    DISABLED_WARNINGS_xlc := 1540-0216 1540-0198 1540-1090 1540-1639 \
    -        1540-1088 1500-010, \
    -    DISABLED_WARNINGS_microsoft := 4146, \
    +    DISABLED_WARNINGS_xlc := $(DISABLED_WARNINGS_xlc), \
    +    DISABLED_WARNINGS_microsoft := $(DISABLED_WARNINGS_microsoft) 4146, \
         ASFLAGS := $(JVM_ASFLAGS), \
         LDFLAGS := $(JVM_LDFLAGS), \
         LIBS := $(JVM_LIBS), \
    
    From 518e79717d2ce0ae345d61300fd28d0df8a5f553 Mon Sep 17 00:00:00 2001
    From: Andrew Lu 
    Date: Thu, 28 Mar 2024 08:00:27 +0000
    Subject: [PATCH 058/149] 8326661:
     sun/java2d/cmm/ColorConvertOp/ColConvTest.java assumes profiles were
     generated by LCMS
    
    Backport-of: 1f43fa0f8b0f956b41015e0ebc257e15a11ad99b
    ---
     .../jdk/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java | 8 ++++----
     1 file changed, 4 insertions(+), 4 deletions(-)
    
    diff --git a/test/jdk/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java b/test/jdk/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java
    index 22e055fbe8e..97ed058ff5a 100644
    --- a/test/jdk/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java
    +++ b/test/jdk/sun/java2d/cmm/ColorConvertOp/ColConvCCMTest.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2007, 2024, 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 6476665 7033534 6830714 8052162 8196572
    + * @bug 6476665 7033534 6830714 8052162 8196572 8326661
      * @summary Verifies color conversion of Component Color Model based images
      * @run main ColConvCCMTest
      */
    @@ -59,8 +59,8 @@ public class ColConvCCMTest extends ColConvTest {
             2.5,        // sRGB
             (isOpenProfile() ? 45.0 : 10.1), // LINEAR_RGB
             10.5,       // GRAY
    -        (isOpenProfile() ? 215.0 : 45.5), // PYCC
    -        (isOpenProfile() ? 56.0 : 47.5) // CIEXYZ
    +        (isOpenProfile() ? 215.0 : 64.5), // PYCC
    +        (isOpenProfile() ? 56.0 : 55.5) // CIEXYZ
         };
     
         final static String [] gldImgNames = {
    
    From 741b3400f1ab5feb1143128fe5779c0b9cd3f73a Mon Sep 17 00:00:00 2001
    From: Goetz Lindenmaier 
    Date: Thu, 28 Mar 2024 10:26:48 +0000
    Subject: [PATCH 059/149] 8243010: Test support: Customizable Hex Printer
    
    Reviewed-by: mbaesken
    Backport-of: bdf672659cee13d95abc246de7cde469cf8fc07d
    ---
     test/jdk/com/sun/jndi/ldap/Base64Test.java    |    3 -
     .../com/sun/security/sasl/ntlm/NTLMTest.java  |   11 +-
     .../javax/net/ssl/DTLS/DTLSOverDatagram.java  |   12 +-
     .../ClientHelloBufferUnderflowException.java  |    8 +-
     .../ssl/interop/ClientHelloChromeInterOp.java |    9 +-
     test/jdk/sun/security/krb5/auto/MSOID2.java   |    6 +-
     .../security/krb5/etype/KerberosAesSha2.java  |    7 +-
     .../sun/security/mscapi/PublicKeyInterop.java |   14 +-
     .../sun/security/pkcs/pkcs7/SignerOrder.java  |   11 +-
     .../sun/security/pkcs/pkcs8/PKCS8Test.java    |    7 +-
     .../security/pkcs/pkcs9/UnknownAttribute.java |    7 +-
     .../ssl/SSLSocketImpl/SSLSocketKeyLimit.java  |    4 +-
     .../security/x509/X500Name/NullX500Name.java  |   15 +-
     test/lib-test/TEST.ROOT                       |    9 +
     .../jdk/test/lib/hexdump/HexPrinterTest.java  |  409 ++++++
     test/lib/jdk/test/lib/hexdump/HexPrinter.java | 1181 +++++++++++++++++
     16 files changed, 1655 insertions(+), 58 deletions(-)
     create mode 100644 test/lib-test/TEST.ROOT
     create mode 100644 test/lib-test/jdk/test/lib/hexdump/HexPrinterTest.java
     create mode 100644 test/lib/jdk/test/lib/hexdump/HexPrinter.java
    
    diff --git a/test/jdk/com/sun/jndi/ldap/Base64Test.java b/test/jdk/com/sun/jndi/ldap/Base64Test.java
    index b6c47414b82..900e04ad123 100644
    --- a/test/jdk/com/sun/jndi/ldap/Base64Test.java
    +++ b/test/jdk/com/sun/jndi/ldap/Base64Test.java
    @@ -163,9 +163,6 @@ public static void main(String[] args) throws Exception {
          */
         private static void deserialize(byte[] bytes) throws Exception {
     
    -        //System.out.println("\nSerialized RefAddr object: ");
    -        //System.out.println(new sun.security.util.HexDumpEncoder().encode(bytes));
    -
             ObjectInputStream objectStream =
                 new ObjectInputStream(new ByteArrayInputStream(bytes));
             Object object = objectStream.readObject();
    diff --git a/test/jdk/com/sun/security/sasl/ntlm/NTLMTest.java b/test/jdk/com/sun/security/sasl/ntlm/NTLMTest.java
    index aed713d598c..5b5841b0aae 100644
    --- a/test/jdk/com/sun/security/sasl/ntlm/NTLMTest.java
    +++ b/test/jdk/com/sun/security/sasl/ntlm/NTLMTest.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2010, 2020, 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
    @@ -24,6 +24,7 @@
     /*
      * @test
      * @bug 6911951 7150092
    + * @library /test/lib
      * @summary NTLM should be a supported Java SASL mechanism
      * @modules java.base/sun.security.util
      *          java.security.sasl
    @@ -32,7 +33,7 @@
     import javax.security.sasl.*;
     import javax.security.auth.callback.*;
     import java.util.*;
    -import sun.security.util.HexDumpEncoder;
    +import jdk.test.lib.hexdump.HexPrinter;
     
     public class NTLMTest {
     
    @@ -312,7 +313,7 @@ private static void handshake(SaslClient clnt, SaslServer srv)
             byte[] response = (clnt.hasInitialResponse()
                     ? clnt.evaluateChallenge(EMPTY) : EMPTY);
             System.out.println("Initial:");
    -        new HexDumpEncoder().encodeBuffer(response, System.out);
    +        HexPrinter.simple().format(response);
             byte[] challenge;
     
             while (!clnt.isComplete() || !srv.isComplete()) {
    @@ -320,12 +321,12 @@ private static void handshake(SaslClient clnt, SaslServer srv)
                 response = null;
                 if (challenge != null) {
                     System.out.println("Challenge:");
    -                new HexDumpEncoder().encodeBuffer(challenge, System.out);
    +                HexPrinter.simple().format(challenge);
                     response = clnt.evaluateChallenge(challenge);
                 }
                 if (response != null) {
                     System.out.println("Response:");
    -                new HexDumpEncoder().encodeBuffer(response, System.out);
    +                HexPrinter.simple().format(response);
                 }
             }
     
    diff --git a/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java b/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java
    index 6691aeba06b..4749dc0bb74 100644
    --- a/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java
    +++ b/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2015, 2020, 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
    @@ -43,7 +43,7 @@
     
     import java.util.concurrent.*;
     
    -import sun.security.util.HexDumpEncoder;
    +import jdk.test.lib.hexdump.HexPrinter;
     
     /**
      * An example to show the way to use SSLEngine in datagram connections.
    @@ -688,12 +688,11 @@ public String call() throws Exception {
         }
     
         final static void printHex(String prefix, ByteBuffer bb) {
    -        HexDumpEncoder  dump = new HexDumpEncoder();
     
             synchronized (System.out) {
                 System.out.println(prefix);
                 try {
    -                dump.encodeBuffer(bb.slice(), System.out);
    +                HexPrinter.simple().format(bb.slice());
                 } catch (Exception e) {
                     // ignore
                 }
    @@ -704,13 +703,10 @@ final static void printHex(String prefix, ByteBuffer bb) {
         final static void printHex(String prefix,
                 byte[] bytes, int offset, int length) {
     
    -        HexDumpEncoder  dump = new HexDumpEncoder();
    -
             synchronized (System.out) {
                 System.out.println(prefix);
                 try {
    -                ByteBuffer bb = ByteBuffer.wrap(bytes, offset, length);
    -                dump.encodeBuffer(bb, System.out);
    +                HexPrinter.simple().format(bytes, offset, length);
                 } catch (Exception e) {
                     // ignore
                 }
    diff --git a/test/jdk/javax/net/ssl/interop/ClientHelloBufferUnderflowException.java b/test/jdk/javax/net/ssl/interop/ClientHelloBufferUnderflowException.java
    index 69778aa0045..ca5742f37b2 100644
    --- a/test/jdk/javax/net/ssl/interop/ClientHelloBufferUnderflowException.java
    +++ b/test/jdk/javax/net/ssl/interop/ClientHelloBufferUnderflowException.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2019, 2020, 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
    @@ -30,13 +30,15 @@
      * @test
      * @bug 8215790 8219389
      * @summary Verify exception
    + * @library /test/lib
      * @modules java.base/sun.security.util
      * @run main/othervm ClientHelloBufferUnderflowException
      */
     
    -import sun.security.util.HexDumpEncoder;
     import javax.net.ssl.SSLHandshakeException;
     
    +import jdk.test.lib.hexdump.HexPrinter;
    +
     public class ClientHelloBufferUnderflowException extends ClientHelloInterOp {
         /*
          * Main entry point for this test.
    @@ -75,7 +77,7 @@ protected byte[] createClientHelloMessage() {
     
             System.out.println("The ClientHello message used");
             try {
    -            (new HexDumpEncoder()).encodeBuffer(bytes, System.out);
    +            HexPrinter.simple().format(bytes);
             } catch (Exception e) {
                 // ignore
             }
    diff --git a/test/jdk/javax/net/ssl/interop/ClientHelloChromeInterOp.java b/test/jdk/javax/net/ssl/interop/ClientHelloChromeInterOp.java
    index 1157b6aeafc..f426cce33e3 100644
    --- a/test/jdk/javax/net/ssl/interop/ClientHelloChromeInterOp.java
    +++ b/test/jdk/javax/net/ssl/interop/ClientHelloChromeInterOp.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2016, 2020, 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
    @@ -30,13 +30,15 @@
      * @test
      * @bug 8169362
      * @summary Interop automated testing with Chrome
    + * @library /test/lib
      * @modules jdk.crypto.ec
      *          java.base/sun.security.util
      * @run main/othervm ClientHelloChromeInterOp
      */
     
     import java.util.Base64;
    -import sun.security.util.HexDumpEncoder;
    +import jdk.test.lib.hexdump.HexPrinter;
    +
     
     public class ClientHelloChromeInterOp extends ClientHelloInterOp {
         // The ClientHello message.
    @@ -63,10 +65,9 @@ protected byte[] createClientHelloMessage() {
     
             // Dump the hex codes of the ClientHello message so that developers
             // can easily check whether the message is captured correct or not.
    -        HexDumpEncoder dump = new HexDumpEncoder();
             System.out.println("The ClientHello message used");
             try {
    -            dump.encodeBuffer(bytes, System.out);
    +            HexPrinter.simple().format(bytes);
             } catch (Exception e) {
                 // ignore
             }
    diff --git a/test/jdk/sun/security/krb5/auto/MSOID2.java b/test/jdk/sun/security/krb5/auto/MSOID2.java
    index 3a3b3cf6c26..0b7545ffbe2 100644
    --- a/test/jdk/sun/security/krb5/auto/MSOID2.java
    +++ b/test/jdk/sun/security/krb5/auto/MSOID2.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2015, 2020, 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
    @@ -32,7 +32,7 @@
      */
     
     import sun.security.jgss.GSSUtil;
    -import sun.security.util.HexDumpEncoder;
    +import jdk.test.lib.hexdump.HexPrinter;
     
     // The basic krb5 test skeleton you can copy from
     public class MSOID2 {
    @@ -72,7 +72,7 @@ public static void main(String[] args) throws Exception {
                         nt[pos] = (byte)newLen;
                     }
                     t = nt;
    -                new HexDumpEncoder().encodeBuffer(t, System.out);
    +                HexPrinter.simple().format(t);
                 }
                 if (t != null || !s.x().isEstablished()) t = s.take(t);
                 if (c.x().isEstablished() && s.x().isEstablished()) break;
    diff --git a/test/jdk/sun/security/krb5/etype/KerberosAesSha2.java b/test/jdk/sun/security/krb5/etype/KerberosAesSha2.java
    index 79c8053bf0a..c738e063e02 100644
    --- a/test/jdk/sun/security/krb5/etype/KerberosAesSha2.java
    +++ b/test/jdk/sun/security/krb5/etype/KerberosAesSha2.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2017, 2020, 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,6 +23,7 @@
     /*
      * @test
      * @bug 8014628
    + * @library /test/lib
      * @modules java.base/sun.security.util
      *          java.security.jgss/sun.security.krb5.internal.crypto.dk:+open
      * @summary https://tools.ietf.org/html/rfc8009 Test Vectors
    @@ -33,7 +34,7 @@
     import java.util.Arrays;
     
     import sun.security.krb5.internal.crypto.dk.AesSha2DkCrypto;
    -import sun.security.util.HexDumpEncoder;
    +import jdk.test.lib.hexdump.HexPrinter;
     
     public class KerberosAesSha2 {
     
    @@ -204,6 +205,6 @@ private static void check(byte[] b1, byte[] b2) throws Exception {
         }
     
         private static void dump(byte[] data) throws Exception {
    -        new HexDumpEncoder().encodeBuffer(data, System.err);
    +        HexPrinter.simple().dest(System.err).format(data);
         }
     }
    diff --git a/test/jdk/sun/security/mscapi/PublicKeyInterop.java b/test/jdk/sun/security/mscapi/PublicKeyInterop.java
    index 85da7e041b1..f3b646bc372 100644
    --- a/test/jdk/sun/security/mscapi/PublicKeyInterop.java
    +++ b/test/jdk/sun/security/mscapi/PublicKeyInterop.java
    @@ -35,7 +35,7 @@
     import javax.crypto.*;
     
     import jdk.test.lib.SecurityTools;
    -import sun.security.util.HexDumpEncoder;
    +import jdk.test.lib.hexdump.HexPrinter;
     
     /*
      * Confirm interoperability of RSA public keys between SunMSCAPI and SunJCE
    @@ -84,29 +84,29 @@ static void run() throws Exception {
             System.out.println();
     
             byte[] plain = new byte[] {0x01, 0x02, 0x03, 0x04, 0x05};
    -        HexDumpEncoder hde = new HexDumpEncoder();
    -        System.out.println("Plaintext:\n" + hde.encode(plain) + "\n");
    +        HexPrinter hp = HexPrinter.simple();
    +        System.out.println("Plaintext:\n" + hp.toString(plain) + "\n");
     
             Cipher rsa = Cipher.getInstance("RSA/ECB/PKCS1Padding");
             rsa.init(Cipher.ENCRYPT_MODE, myPuKey);
             byte[] encrypted = rsa.doFinal(plain);
             System.out.println("Encrypted plaintext using RSA Cipher from " +
                 rsa.getProvider().getName() + " JCE provider\n");
    -        System.out.println(hde.encode(encrypted) + "\n");
    +        System.out.println(hp.toString(encrypted) + "\n");
     
             Cipher rsa2 = Cipher.getInstance("RSA/ECB/PKCS1Padding", "SunMSCAPI");
             rsa2.init(Cipher.ENCRYPT_MODE, myPuKey);
             byte[] encrypted2 = rsa2.doFinal(plain);
             System.out.println("Encrypted plaintext using RSA Cipher from " +
                 rsa2.getProvider().getName() + " JCE provider\n");
    -        System.out.println(hde.encode(encrypted2) + "\n");
    +        System.out.println(hp.toString(encrypted2) + "\n");
     
             Cipher rsa3 = Cipher.getInstance("RSA/ECB/PKCS1Padding", "SunMSCAPI");
             rsa3.init(Cipher.DECRYPT_MODE, myPrKey);
             byte[] decrypted = rsa3.doFinal(encrypted);
             System.out.println("Decrypted first ciphertext using RSA Cipher from " +
                 rsa3.getProvider().getName() + " JCE provider\n");
    -        System.out.println(hde.encode(decrypted) + "\n");
    +        System.out.println(hp.toString(decrypted) + "\n");
             if (! Arrays.equals(plain, decrypted)) {
                 throw new Exception("First decrypted ciphertext does not match " +
                     "original plaintext");
    @@ -115,7 +115,7 @@ static void run() throws Exception {
             decrypted = rsa3.doFinal(encrypted2);
             System.out.println("Decrypted second ciphertext using RSA Cipher from "
                 + rsa3.getProvider().getName() + " JCE provider\n");
    -        System.out.println(hde.encode(decrypted) + "\n");
    +        System.out.println(hp.toString(decrypted) + "\n");
             if (! Arrays.equals(plain, decrypted)) {
                 throw new Exception("Second decrypted ciphertext does not match " +
                     "original plaintext");
    diff --git a/test/jdk/sun/security/pkcs/pkcs7/SignerOrder.java b/test/jdk/sun/security/pkcs/pkcs7/SignerOrder.java
    index ef247d5906a..875ca5935e4 100644
    --- a/test/jdk/sun/security/pkcs/pkcs7/SignerOrder.java
    +++ b/test/jdk/sun/security/pkcs/pkcs7/SignerOrder.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2015, 2020, 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
    @@ -25,6 +25,7 @@
      * @test
      * @bug 8048357
      * @summary test PKCS7 data signing, encoding and verification
    + * @library /test/lib
      * @modules java.base/sun.security.pkcs
      *          java.base/sun.security.util
      *          java.base/sun.security.x509
    @@ -40,7 +41,6 @@
     import java.security.SignatureException;
     import java.security.cert.X509Certificate;
     import java.util.Date;
    -import sun.security.util.HexDumpEncoder;
     import sun.security.pkcs.ContentInfo;
     import sun.security.pkcs.PKCS7;
     import sun.security.pkcs.SignerInfo;
    @@ -55,11 +55,10 @@
     import sun.security.x509.X509CertImpl;
     import sun.security.x509.X509CertInfo;
     import sun.security.x509.X509Key;
    +import jdk.test.lib.hexdump.HexPrinter;
     
     public class SignerOrder {
     
    -    static final HexDumpEncoder hexDump = new HexDumpEncoder();
    -
         //signer infos
         static final byte[] data1 = "12345".getBytes();
         static final byte[] data2 = "abcde".getBytes();
    @@ -120,7 +119,7 @@ static void printSignerInfos(SignerInfo signerInfo) throws IOException {
             signerInfo.derEncode(strm);
             System.out.println("SignerInfo, length: "
                     + strm.toByteArray().length);
    -        System.out.println(hexDump.encode(strm.toByteArray()));
    +        HexPrinter.simple().format(strm.toByteArray());
             System.out.println("\n");
             strm.reset();
         }
    @@ -131,7 +130,7 @@ static void printSignerInfos(SignerInfo[] signerInfos) throws IOException {
                 signerInfos[i].derEncode(strm);
                 System.out.println("SignerInfo[" + i + "], length: "
                         + strm.toByteArray().length);
    -            System.out.println(hexDump.encode(strm.toByteArray()));
    +            HexPrinter.simple().format(strm.toByteArray());
                 System.out.println("\n");
                 strm.reset();
             }
    diff --git a/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java b/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java
    index 1bd9f0e54e1..f0555ce59db 100644
    --- a/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java
    +++ b/test/jdk/sun/security/pkcs/pkcs8/PKCS8Test.java
    @@ -25,6 +25,7 @@
      * @test
      * @bug 8048357
      * @summary PKCS8 Standards Conformance Tests
    + * @library /test/lib
      * @requires (os.family != "solaris")
      * @modules java.base/sun.security.pkcs
      *          java.base/sun.security.util
    @@ -42,18 +43,16 @@
     import java.math.BigInteger;
     import java.security.InvalidKeyException;
     import java.util.Arrays;
    -import sun.security.util.HexDumpEncoder;
     import sun.security.pkcs.PKCS8Key;
     import sun.security.provider.DSAPrivateKey;
     import sun.security.util.DerOutputStream;
     import sun.security.util.DerValue;
     import sun.security.x509.AlgorithmId;
    +import jdk.test.lib.hexdump.HexPrinter;
     import static java.lang.System.out;
     
     public class PKCS8Test {
     
    -    static final HexDumpEncoder hexDump = new HexDumpEncoder();
    -
         static final DerOutputStream derOutput = new DerOutputStream();
     
         static final String FORMAT = "PKCS#8";
    @@ -281,6 +280,6 @@ public static void main(String[] args)
     
         static void dumpByteArray(String nm, byte[] bytes) throws IOException {
             out.println(nm + " length: " + bytes.length);
    -        hexDump.encodeBuffer(bytes, out);
    +        HexPrinter.simple().dest(out).format(bytes);
         }
     }
    diff --git a/test/jdk/sun/security/pkcs/pkcs9/UnknownAttribute.java b/test/jdk/sun/security/pkcs/pkcs9/UnknownAttribute.java
    index dbac0ca772f..333550d2ace 100644
    --- a/test/jdk/sun/security/pkcs/pkcs9/UnknownAttribute.java
    +++ b/test/jdk/sun/security/pkcs/pkcs9/UnknownAttribute.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2013, 2020, 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
    @@ -25,6 +25,7 @@
      * @test
      * @bug 8011867 8242151
      * @summary Accept unknown PKCS #9 attributes
    + * @library /test/lib
      * @modules java.base/sun.security.pkcs
      *          java.base/sun.security.util
      */
    @@ -32,10 +33,10 @@
     import java.io.*;
     import java.util.Arrays;
     
    -import sun.security.util.HexDumpEncoder;
     import sun.security.pkcs.PKCS9Attribute;
     import sun.security.util.DerValue;
     import sun.security.util.ObjectIdentifier;
    +import jdk.test.lib.hexdump.HexPrinter;
     
     public class UnknownAttribute {
     
    @@ -58,7 +59,7 @@ public static void main(String[] args) throws Exception {
             }
             ByteArrayOutputStream bout = new ByteArrayOutputStream();
             p2.derEncode(bout);
    -        new HexDumpEncoder().encodeBuffer(bout.toByteArray(), System.err);
    +        HexPrinter.simple().dest(System.err).format(bout.toByteArray());
             if (!Arrays.equals(data, bout.toByteArray())) {
                 throw new Exception();
             }
    diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java
    index f87effe9dce..8b19d39af7e 100644
    --- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java
    +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java
    @@ -69,7 +69,7 @@
     import jdk.test.lib.process.OutputAnalyzer;
     import jdk.test.lib.process.ProcessTools;
     import jdk.test.lib.Utils;
    -import sun.security.util.HexDumpEncoder;
    +import jdk.test.lib.hexdump.HexPrinter;
     
     public class SSLSocketKeyLimit {
         SSLSocket socket;
    @@ -227,7 +227,7 @@ void read(SSLSocket s) throws Exception {
                             continue;
                         }
                         System.out.println("\nData invalid: " +
    -                            new HexDumpEncoder().encode(buf));
    +                            HexPrinter.minimal().toString(buf));
                         break;
                     }
     
    diff --git a/test/jdk/sun/security/x509/X500Name/NullX500Name.java b/test/jdk/sun/security/x509/X500Name/NullX500Name.java
    index fe0b1d3874c..37e12d8a892 100644
    --- a/test/jdk/sun/security/x509/X500Name/NullX500Name.java
    +++ b/test/jdk/sun/security/x509/X500Name/NullX500Name.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1998, 2020, 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
    @@ -24,6 +24,7 @@
     /* @test
      * @bug 4118818
      * @summary allow null X.500 Names
    + * @library /test/lib
      * @modules java.base/sun.security.util
      *          java.base/sun.security.x509
      */
    @@ -31,7 +32,7 @@
     import java.util.Arrays;
     import sun.security.util.DerOutputStream;
     import sun.security.x509.*;
    -import sun.security.util.HexDumpEncoder;
    +import jdk.test.lib.hexdump.HexPrinter;
     
     public class NullX500Name {
     
    @@ -63,16 +64,16 @@ public static void main(String[] argv) throws Exception {
             subject.encode(dos);
             byte[] out = dos.toByteArray();
             byte[] enc = subject.getEncoded();
    -        HexDumpEncoder e = new HexDumpEncoder();
    +        HexPrinter e = HexPrinter.simple();
             if (Arrays.equals(out, enc))
    -            System.out.println("Sucess: out:" + e.encodeBuffer(out));
    +            System.out.println("Success: out:" + e.toString(out));
             else {
    -            System.out.println("Failed: encode:" + e.encodeBuffer(out));
    -            System.out.println("getEncoded:" + e.encodeBuffer(enc));
    +            System.out.println("Failed: encode:" + e.toString(out));
    +            System.out.println("getEncoded:" + e.toString(enc));
             }
             X500Name x = new X500Name(enc);
             if (x.equals(subject))
    -            System.out.println("Sucess: X500Name(byte[]):" + x.toString());
    +            System.out.println("Success: X500Name(byte[]):" + x.toString());
             else
                 System.out.println("Failed: X500Name(byte[]):" + x.toString());
         }
    diff --git a/test/lib-test/TEST.ROOT b/test/lib-test/TEST.ROOT
    new file mode 100644
    index 00000000000..51dfcb33c4f
    --- /dev/null
    +++ b/test/lib-test/TEST.ROOT
    @@ -0,0 +1,9 @@
    +# This file identifies the root of the test-suite hierarchy.
    +# It also contains test-suite configuration information.
    +
    +# Minimum jtreg version
    +requiredVersion=7.3.1+1
    +
    +# Path to libraries in the topmost test directory. This is needed so @library
    +# does not need ../../ notation to reach them
    +external.lib.roots = ../../
    diff --git a/test/lib-test/jdk/test/lib/hexdump/HexPrinterTest.java b/test/lib-test/jdk/test/lib/hexdump/HexPrinterTest.java
    new file mode 100644
    index 00000000000..bad85a1e624
    --- /dev/null
    +++ b/test/lib-test/jdk/test/lib/hexdump/HexPrinterTest.java
    @@ -0,0 +1,409 @@
    +/*
    + * Copyright (c) 2019, 2020, 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.
    + *
    + * 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 jdk.test.lib.hexdump;
    +
    +import jdk.test.lib.hexdump.HexPrinter;
    +
    +import org.testng.Assert;
    +import org.testng.annotations.DataProvider;
    +import org.testng.annotations.Test;
    +
    +import java.io.ByteArrayInputStream;
    +import java.io.ByteArrayOutputStream;
    +import java.io.DataInputStream;
    +import java.io.DataOutputStream;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.nio.ByteBuffer;
    +
    +
    +/*
    + * @test
    + * @summary Check HexPrinter formatting
    + * @library /test/lib
    + * @compile HexPrinterTest.java
    + * @run testng jdk.test.lib.hexdump.HexPrinterTest
    + */
    +public class HexPrinterTest {
    +
    +    @Test
    +    static void testMinimalToStringByteArray() {
    +        int len = 16;
    +        byte[] bytes = genData(len);
    +        StringBuilder expected = new StringBuilder(bytes.length * 2);
    +        for (int i = 0; i < len; i++)
    +            expected.append(String.format("%02x", bytes[i]));
    +        String actual = HexPrinter.minimal().toString(bytes);
    +        System.out.println(actual);
    +        Assert.assertEquals(actual, expected.toString(), "Minimal format incorrect");
    +    }
    +
    +    @DataProvider(name = "ColumnParams")
    +    Object[][] columnParams() {
    +        return new Object[][]{
    +                {"%4d: ", "%d ", 10, " ; ", 50, HexPrinter.Formatters.PRINTABLE, "\n"},
    +                {"%03o: ", "%d ", 16, " ; ", 50, HexPrinter.Formatters.ofPrimitive(byte.class, ""), "\n"},
    +                {"%5d: ", "%02x:", 16, " ; ", 50, HexPrinter.Formatters.ofPrimitive(byte.class, ""), "\n"},
    +                {"%5d: ", "%3d", 16, " ; ", 50, HexPrinter.Formatters.ofPrimitive(byte.class, ""), "\n"},
    +                {"%05o: ", "%3o", 8, " ; ", 50, HexPrinter.Formatters.ofPrimitive(byte.class, ""), "\n"},
    +                {"%6x: ", "%02x", 8, " | ", 50, HexPrinter.Formatters.ofPrimitive(byte.class, "%d "), "\n"},
    +                {"%2x: ", "%02x", 8, " | ", 50, HexPrinter.Formatters.PRINTABLE, "\n"},
    +                {"%5d: ", "%02x", 16, " | ", 50, HexPrinter.Formatters.ofPrimitive(short.class, "%d "), "\n"},
    +        };
    +    }
    +
    +    @DataProvider(name = "BuiltinParams")
    +    Object[][] builtinParams() {
    +        return new Object[][]{
    +                {"minimal", "", "%02x", 16, "", 64, HexPrinter.Formatters.NONE, ""},
    +                {"canonical", "%08x  ", "%02x ", 16, "|", 31, HexPrinter.Formatters.ASCII, "|\n"},
    +                {"simple", "%5d: ", "%02x ", 16, " // ", 64, HexPrinter.Formatters.PRINTABLE, "\n"},
    +                {"source", "    ", "(byte)%3d, ", 8, " // ", 64, HexPrinter.Formatters.PRINTABLE,
    +                        "\n"},
    +        };
    +    }
    +
    +    @Test(dataProvider = "BuiltinParams")
    +    public void testBuiltins(String name, String offsetFormat, String binFormat, int colWidth,
    +                             String annoDelim, int annoWidth,
    +                             HexPrinter.Formatter mapper, String lineSep) {
    +        HexPrinter f = switch (name) {
    +            case "minimal" -> HexPrinter.minimal();
    +            case "simple" -> HexPrinter.simple();
    +            case "canonical" -> HexPrinter.canonical();
    +            case "source" -> HexPrinter.source();
    +            default -> throw new IllegalStateException("Unexpected value: " + name);
    +        };
    +
    +        testParams(f, offsetFormat, binFormat, colWidth, annoDelim, annoWidth, mapper, lineSep);
    +
    +        String actual = f.toString();
    +        HexPrinter f2 = HexPrinter.simple()
    +                .withOffsetFormat(offsetFormat)
    +                .withBytesFormat(binFormat, colWidth)
    +                .formatter(mapper, annoDelim, annoWidth)
    +                .withLineSeparator(lineSep);
    +        String expected = f2.toString();
    +        Assert.assertEquals(actual, expected, "toString of " + name + " does not match");
    +    }
    +
    +    @Test(dataProvider = "ColumnParams")
    +    public void testToStringTwoLines(String offsetFormat, String binFormat, int colWidth,
    +                                     String annoDelim, int annoWidth,
    +                                     HexPrinter.Formatter mapper, String lineSep) {
    +        HexPrinter f = HexPrinter.simple()
    +                .withOffsetFormat(offsetFormat)
    +                .withBytesFormat(binFormat, colWidth)
    +                .formatter(mapper, annoDelim, annoWidth)
    +                .withLineSeparator(lineSep);
    +        testParams(f, offsetFormat, binFormat, colWidth, annoDelim, annoWidth, mapper, lineSep);
    +    }
    +
    +    public static void testParams(HexPrinter printer, String offsetFormat, String binFormat, int colWidth,
    +                                  String annoDelim, int annoWidth,
    +                                  HexPrinter.Formatter mapper, String lineSep) {
    +        byte[] bytes = genData(colWidth * 2);
    +        System.out.println("Params: " + printer.toString());
    +        String out = printer.toString(bytes);
    +        System.out.println(out);
    +
    +        // Compare the actual output with the expected output of each formatting element
    +        int padToWidth = colWidth * String.format(binFormat, 0xff).length();
    +        int ndx = 0;
    +        int valuesStart = 0;
    +        int l;
    +        for (int i = 0; i < bytes.length; i++) {
    +            if (i % colWidth == 0) {
    +                String offset = String.format(offsetFormat, i);
    +                l = offset.length();
    +                Assert.assertEquals(out.substring(ndx, ndx + l), offset,
    +                        "offset format mismatch: " + ndx);
    +                ndx += l;
    +                valuesStart = ndx;
    +            }
    +            String value = String.format(binFormat, (0xff & bytes[i]));
    +            l = value.length();
    +            Assert.assertEquals(out.substring(ndx, ndx + l), value,
    +                    "value format mismatch: " + ndx + ", i: " + i);
    +            ndx += l;
    +            if (((i + 1) % colWidth) == 0) {
    +                // Rest of line is for padding, delimiter, formatter
    +                String padding = " ".repeat(padToWidth - (ndx - valuesStart));
    +                Assert.assertEquals(out.substring(ndx, ndx + padding.length()), padding, "padding");
    +                ndx += padding.length();
    +                Assert.assertEquals(out.substring(ndx, ndx + annoDelim.length()), annoDelim,
    +                        "delimiter mismatch");
    +                ndx += annoDelim.length();
    +
    +                // Formatter output is tested separately
    +                ndx = out.indexOf(lineSep, ndx) + lineSep.length();
    +            }
    +        }
    +    }
    +
    +    @DataProvider(name = "PrimitiveFormatters")
    +    Object[][] formatterParams() {
    +        return new Object[][]{
    +                {byte.class, ""},
    +                {byte.class, "%02x: "},
    +                {short.class, "%d "},
    +                {int.class, "%08x, "},
    +                {long.class, "%16x "},
    +                {float.class, "%3.4f "},
    +                {double.class, "%6.3g "},
    +                {boolean.class, "%b "},
    +        };
    +    }
    +
    +    @Test(dataProvider = "PrimitiveFormatters")
    +    public void testFormatter(Class primClass, String fmtString) {
    +        HexPrinter.Formatter formatter = HexPrinter.Formatters.ofPrimitive(primClass, fmtString);
    +        // Create a byte array with data for two lines
    +        int colWidth = 8;
    +        byte[] bytes = genData(colWidth);
    +        StringBuilder sb = new StringBuilder();
    +        DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
    +        DataInputStream in2 = new DataInputStream(new ByteArrayInputStream(bytes));
    +        try {
    +            while (true) {
    +                formatter.annotate(in, sb);
    +                Object n = readPrimitive(primClass, in2);
    +                String expected = String.format(fmtString, n);
    +                Assert.assertEquals(sb.toString(), expected, "mismatch");
    +                sb.setLength(0);
    +            }
    +        } catch (IOException ioe) {
    +            // EOF is done
    +        }
    +        try {
    +            Assert.assertEquals(in.available(), 0, "not all input consumed");
    +            Assert.assertEquals(in2.available(), 0, "not all 2nd stream input consumed");
    +        } catch (IOException ioe) {
    +            //
    +        }
    +    }
    +
    +    @Test(dataProvider = "PrimitiveFormatters")
    +    static void testHexPrinterPrimFormatter(Class primClass, String fmtString) {
    +        // Create a byte array with data for two lines
    +        int colWidth = 8;
    +        byte[] bytes = genData(colWidth);
    +
    +        HexPrinter p = HexPrinter.simple()
    +                .formatter(primClass, fmtString);
    +        String actual = p.toString(bytes);
    +        System.out.println(actual);
    +        // The formatter should produce the same output as using the formatter method
    +        // with an explicit formatter for the primitive
    +        String expected = HexPrinter.simple()
    +                .formatter(HexPrinter.Formatters.ofPrimitive(primClass, fmtString))
    +                .toString(bytes);
    +        Assert.assertEquals(actual, expected, "mismatch");
    +    }
    +
    +    private static Object readPrimitive(Class primClass, DataInputStream in) throws IOException {
    +        if (int.class.equals(primClass)) {
    +            return in.readInt();
    +        } else if (byte.class.equals(primClass)) {
    +            return (int) in.readByte();
    +        } else if (short.class.equals(primClass)) {
    +            return in.readShort();
    +        } else if (char.class.equals(primClass)) {
    +            return in.readChar();
    +        } else if (long.class.equals(primClass)) {
    +            return in.readLong();
    +        } else if (float.class.equals(primClass)) {
    +            return in.readFloat();
    +        } else if (double.class.equals(primClass)) {
    +            return in.readDouble();
    +        } else if (boolean.class.equals(primClass)) {
    +            return in.readBoolean();
    +        } else {
    +            throw new RuntimeException("unknown primitive class: " + primClass);
    +        }
    +    }
    +
    +    @DataProvider(name = "sources")
    +    Object[][] sources() {
    +        return new Object[][]{
    +                {genBytes(21), 0, -1},
    +                {genBytes(21), 5, 12},
    +        };
    +    }
    +
    +    public static byte[] genData(int len) {
    +        // Create a byte array with data for two lines
    +        byte[] bytes = new byte[len];
    +        for (int i = 0; i < len / 2; i++) {
    +            bytes[i] = (byte) (i + 'A');
    +            bytes[i + len / 2] = (byte) (i + 'A' + 128);
    +        }
    +        return bytes;
    +    }
    +
    +    public static byte[] genFloat(int len) {
    +        byte[] bytes = null;
    +        try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
    +             DataOutputStream out = new DataOutputStream(baos)) {
    +            for (int i = 0; i < len; i++) {
    +                out.writeFloat(i);
    +            }
    +            bytes = baos.toByteArray();
    +        } catch (IOException unused) {
    +        }
    +        return bytes;
    +    }
    +
    +    public static byte[] genDouble(int len) {
    +        byte[] bytes = null;
    +        try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
    +             DataOutputStream out = new DataOutputStream(baos)) {
    +            for (int i = 0; i < len; i++) {
    +                out.writeDouble(i);
    +            }
    +            bytes = baos.toByteArray();
    +        } catch (IOException unused) {
    +        }
    +        return bytes;
    +    }
    +
    +    public static byte[] genBytes(int len) {
    +        byte[] bytes = new byte[len];
    +        for (int i = 0; i < len; i++)
    +            bytes[i] = (byte) ('A' + i);
    +        return bytes;
    +    }
    +
    +    public ByteBuffer genByteBuffer(int len) {
    +        return ByteBuffer.wrap(genBytes(len));
    +    }
    +
    +    public InputStream genInputStream(int len) {
    +        return new ByteArrayInputStream(genBytes(len));
    +    }
    +
    +    @Test
    +    public void testNilPrinterBigBuffer() {
    +        byte[] bytes = new byte[1024];
    +        HexPrinter p = HexPrinter.minimal();
    +        String r = p.toString(bytes);
    +        Assert.assertEquals(r.length(), bytes.length * 2, "encoded byte wrong size");
    +        Assert.assertEquals(r.replace("00", "").length(), 0, "contents not all zeros");
    +    }
    +
    +    @Test(dataProvider = "sources")
    +    public void testToStringByteBuffer(byte[] bytes, int offset, int length) {
    +        if (length < 0)
    +            length = bytes.length - offset;
    +        ByteBuffer bb = ByteBuffer.wrap(bytes, 0, bytes.length);
    +        System.out.printf("Source: %s, off: %d, len: %d%n",
    +                bytes.getClass().getName(), offset, length);
    +        String actual;
    +        if (offset == 0 && length < 0) {
    +            bb.position(offset);
    +            bb.limit(length);
    +            actual = HexPrinter.simple().toString(bb);
    +        } else
    +            actual = HexPrinter.simple().toString(bb, offset, length);
    +        System.out.println(actual);
    +        String expected = HexPrinter.simple().toString(bytes, offset, length);
    +        Assert.assertEquals(actual, expected, "mismatch in format()");
    +    }
    +
    +    @Test(dataProvider = "sources")
    +    public void testFormatBytes(byte[] bytes, int offset, int length) {
    +        int len = length >= 0 ? length : bytes.length;
    +        System.out.printf("Source: %s, off: %d, len: %d%n",
    +                "bytes", offset, len);
    +        StringBuilder sb = new StringBuilder();
    +        if (offset == 0 && length < 0)
    +            HexPrinter.simple().dest(sb).format(bytes);
    +        else
    +            HexPrinter.simple().dest(sb).format(bytes, offset, len);
    +        String actual = sb.toString();
    +        System.out.println(actual);
    +        String expected = HexPrinter.simple().toString(bytes, offset, len);
    +        Assert.assertEquals(actual, expected, "mismatch in format()");
    +    }
    +
    +    @Test(dataProvider = "sources")
    +    public void testFormatByteBuffer(byte[] bytes, int offset, int length) {
    +        if (length < 0)
    +            length = bytes.length - offset;
    +        ByteBuffer bb = ByteBuffer.wrap(bytes, 0, bytes.length);
    +        System.out.printf("Source: %s, off: %d, len: %d%n",
    +                bytes.getClass().getName(), offset, length);
    +        StringBuilder sb = new StringBuilder();
    +        if (offset == 0 && length < 0) {
    +            bb.position(offset);
    +            bb.limit(length);
    +            HexPrinter.simple().dest(sb).format(bb);
    +        } else
    +            HexPrinter.simple().dest(sb).format(bb, offset, length);
    +        String actual = sb.toString();
    +        System.out.println(actual);
    +        String expected = HexPrinter.simple().toString(bytes, offset, length);
    +        Assert.assertEquals(actual, expected, "mismatch in format()");
    +    }
    +
    +    @Test(dataProvider = "sources")
    +    public void testFormatInputStream(byte[] bytes, int offset, int length) {
    +        // Offset is ignored
    +        InputStream is = new ByteArrayInputStream(bytes, 0, length);
    +        StringBuilder sb = new StringBuilder();
    +        System.out.printf("Source: %s, off: %d, len: %d%n",
    +                bytes.getClass().getName(), offset, length);
    +        HexPrinter.simple().dest(sb).format(is);
    +        String actual = sb.toString();
    +        System.out.println(actual);
    +        String expected = HexPrinter.simple().toString(bytes, 0, length);
    +        Assert.assertEquals(actual, expected, "mismatch in format()");
    +    }
    +
    +    @Test(expectedExceptions = NullPointerException.class)
    +    public void testNullByteArray() {
    +        HexPrinter.simple().dest(System.out).format((byte[]) null);
    +    }
    +
    +    @Test(expectedExceptions = NullPointerException.class)
    +    public void testNullByteArrayOff() {
    +        HexPrinter.simple().dest(System.out).format((byte[]) null, 0, 1);
    +    }
    +
    +    @Test(expectedExceptions = NullPointerException.class)
    +    public void testNullByteBuffer() {
    +        HexPrinter.simple().dest(System.out).format((ByteBuffer) null);
    +    }
    +
    +    @Test(expectedExceptions = NullPointerException.class)
    +    public void testNullByteBufferOff() {
    +        HexPrinter.simple().dest(System.out).format((ByteBuffer) null, 0, 1);
    +    }
    +
    +    @Test(expectedExceptions = NullPointerException.class)
    +    public void testNullInputStream() {
    +        HexPrinter.simple().dest(System.out).format((InputStream) null);
    +    }
    +
    +}
    diff --git a/test/lib/jdk/test/lib/hexdump/HexPrinter.java b/test/lib/jdk/test/lib/hexdump/HexPrinter.java
    new file mode 100644
    index 00000000000..ad4575d14e9
    --- /dev/null
    +++ b/test/lib/jdk/test/lib/hexdump/HexPrinter.java
    @@ -0,0 +1,1181 @@
    +/*
    + * Copyright (c) 2019, 2020, 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.
    + *
    + * 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 jdk.test.lib.hexdump;
    +
    +import java.io.BufferedInputStream;
    +import java.io.ByteArrayInputStream;
    +import java.io.CharArrayWriter;
    +import java.io.DataInputStream;
    +import java.io.EOFException;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.io.PrintStream;
    +import java.io.UncheckedIOException;
    +import java.io.Writer;
    +import java.nio.ByteBuffer;
    +import java.util.Objects;
    +
    +/**
    + * Decode a sequence of bytes to a readable format.
    + * 

    + * The predefined formats are: + *

    + *
    {@link #minimal() Minimal format}: {@code "Now is the time for Java.\n"}
    + *
        {@code
    + *     4e6f77206973207468652074696d6520666f72204a6176612e0a} 
    + *
    + * + *
    {@link #simple() Simple format}: {@code "Now is the time for Java.\n"}
    + *
    {@code
    + *     0: 4e 6f 77 20 69 73 20 74 68 65 20 74 69 6d 65 20  // Now is the time for Java.\n
    + *    16: 66 6f 72 20 4a 61 76 61 2e 0a} 
    + *
    + * + *
    {@link #canonical() Canonical format}: {@code "Now is the time for Java.\n"}
    + *
    {@code
    + *     00000000  4e 6f 77 20 69 73 20 74 68 65 20 74 69 6d 65 20 |Now is the time |
    + *     00000010  66 6f 72 20 4a 61 76 61 2e 0a                   |for Java.|} 
    + *
    + *
    {@link #source() Byte array initialization source}: {@code "Now is the time for Java.\n"}
    + *
    {@code
    + *     (byte) 78, (byte)111, (byte)119, (byte) 32, (byte)105, (byte)115, (byte) 32, (byte)116,  // Now is t
    + *     (byte)104, (byte)101, (byte) 32, (byte)116, (byte)105, (byte)109, (byte)101, (byte) 32,  // he time
    + *     (byte)102, (byte)111, (byte)114, (byte) 32, (byte) 74, (byte) 97, (byte)118, (byte) 97,  // for Java
    + *     (byte) 46, (byte) 10,                                                                    // .\n}
    + *
    + *
    + *

    + * The static factories {@link #minimal minimal}, {@link #simple simple}, + * {@link #canonical canonical}, and {@link #source() Java source} + * return predefined {@code HexPrinter}s for the formats above. + * HexPrinter holds the formatting parameters that control the width and formatting + * of each of the offset, byte values, and formatted output. + * New HexPrinters with different parameters are created using an existing HexPrinter + * as a template with the methods {@link #formatter(Formatter)}, + * {@link #withBytesFormat(String, int)}, {@link #withOffsetFormat(String)}, + * and {@link #withLineSeparator(String)}. + *

    + * The source of the bytes includes byte arrays, InputStreams, and ByteBuffers. + * For example, {@link #toString(InputStream)} reads the input and returns a String. + * Each of the {@code toString(...)} methods immediately reads and + * formats all of the bytes from the source and returns a String. + *

    + * Each of the {@code format(...)} methods immediately reads and + * formats all of the bytes from the source and appends it to the destination. + * For example, {@link #format(InputStream)} reads the input and + * appends the output to {@link System#out System.out} unless the + * {@link #dest(Appendable) destination} is changed to an {@link Appendable} + * such as {@link PrintStream}, {@link StringBuilder}, or {@link Writer}. + *

    + * {@linkplain Formatter Formatter} functions read and interpret the bytes to show the + * structure and content of a protocol or data stream. + * Built-in formatters include {@link HexPrinter#formatter(Class, String) primitives}, + * {@link Formatters#PRINTABLE printable ascii}, + * and {@link Formatters#utf8Parser(DataInputStream, Appendable) UTF-8 strings}. + * The {@link #formatter(Formatter, String, int) formatter} method sets the + * formatting function, the delimiter, and the width. + * Custom formatter functions can be implemented as a lambda, a method, an inner class, or a concrete class. + *

    + * The format of each line is customizable. + * The {@link #withOffsetFormat(String) withOffsetFormat} method controls + * the format of the byte offset. + * The {@link #withBytesFormat(String, int) withBytesFormat} method controls + * the printing of each byte value including the separator, + * and the maximum number of byte values per line. + * The offset and byte values are formatted using the familiar + * {@link String#format String formats} with spacing + * and delimiters included in the format string. + * The {@link #withLineSeparator(String) withLineSeparator} method sets + * the line separator. + *

    + * Examples: + *

      + *
    • Encoding bytes to a minimal string. + *
      {@code
      + * byte[] bytes = new byte[] { ' ', 0x41, 0x42, '\n'};
      + * String s = HexPrinter.minimal().toString(bytes);
      + * Result: "2041420a"
      + * }
      + *
    • Simple formatting of a byte array. + *
      {@code
      + * byte[] bytes = new byte[] { ' ', 0x41, 0x42, '\n'};
      + * String s = HexPrinter.simple().toString(bytes);
      + * Result:    0: 20 41 42 0a                                      //  AB\n
      + * }
      + *
    • Simple formatting of a ByteBuffer. + *
      {@code
      + * ByteBuffer bb = ByteBuffer.wrap(bytes);
      + * String s = HexPrinter.simple().toString(bb);
      + * Result:    0: 20 41 42 0a                                      //  AB\n
      + * }
      + *
    • Simple formatting of ranges of a byte array to System.err. + *
      {@code
      + * byte[] bytes = new byte[] { ' ', 0x41, 0x42, 0x43, 0x44, '\n'};
      + * HexPrinter hex = HexPrinter.simple()
      + *                            .dest(System.err);
      + *                            .format(bytes, 1, 2)
      + *                            .format(bytes, 3, 2);
      + * Result:
      + * 1: 41 42                                            // AB
      + * 3: 43 44                                            // CD
      + * }
      + *
    + *

    + * This is a value-based + * class; use of identity-sensitive operations (including reference equality + * ({@code ==}), identity hash code, or synchronization) on instances + * may have unpredictable results and should be avoided. + * The {@code equals} method should be used for comparisons. + * + *

    + * This class is immutable and thread-safe. + */ +public final class HexPrinter { + + /** + * Mnemonics for control characters. + */ + static final String[] CONTROL_MNEMONICS = { + "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel", + "b", "t", "n", "vt", "f", "r", "so", "si", + "dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb", + "can", "em", "sub", "esc", "fs", "gs", "rs", "us" + }; + private static final String initOffsetFormat = "%5d: "; + private static final int initBytesCount = 16; // 16 byte values + private static final String initBytesFormat = "%02x "; + private static final int initAnnoWidth = initBytesCount * 4; + private static final String initAnnoDelim = " // "; + + final Appendable dest; // Final output target + final String offsetFormat; // Byte offset Formatter String + final String bytesFormat; // Hex bytes Formatter string + final int bytesCount; // Maximum number of byte values per line + final String annoDelim; // Annotation delimiter + final int annoWidth; // Annotation field width (characters) + final String lineSeparator; // End of line separator + final Formatter annoFormatter; // formatter function + + /** + * Construct a new HexPrinter with all new values. + * + * @param printer the formatter + * @param offsetFormat the offset format + * @param bytesFormat the bytes format + * @param bytesCount the count of bytes per line + * @param annoDelim the delimiter before the annotation + * @param annoWidth the width of the annotation + * @param lineSeparator the line separator + * @param dest the destination + */ + private HexPrinter(Formatter printer, String offsetFormat, String bytesFormat, int bytesCount, + String annoDelim, int annoWidth, + String lineSeparator, Appendable dest) { + this.annoFormatter = Objects.requireNonNull(printer, "formatter"); + this.bytesCount = bytesCount; + this.bytesFormat = Objects.requireNonNull(bytesFormat, bytesFormat); + this.offsetFormat = Objects.requireNonNull(offsetFormat, "offsetFormat"); + this.annoDelim = Objects.requireNonNull(annoDelim, "annoDelim"); + this.annoWidth = annoWidth; + this.lineSeparator = Objects.requireNonNull(lineSeparator, "lineSeparator"); + this.dest = Objects.requireNonNull(dest, "dest"); + } + + /** + * Returns a new HexPrinter setting the parameters to produce a minimal string. + * The parameters are set to: + *

      + *
    • byte offset format: none {@code ""}, + *
    • each byte value is formatted as 2 hex digits: {@code "%02x"}, + *
    • maximum number of byte values per line: unbounded, + *
    • delimiter for the annotation: none {@code ""}, + *
    • formatter: {@link Formatters#NONE does not output a formatted byte}, and + *
    • destination: {@link System#out System.out}. + *
    + * Example, + *
    +     * {@code     byte[] bytes = new byte[] { ' ', 0x41, 0x42, '\n'};
    +     *     String s = HexPrinter.minimal()
    +     *             .toString(bytes);
    +     *     Result: "2041420a"
    +     * }
    + * + * @return a new HexPrinter + */ + public static HexPrinter minimal() { + return new HexPrinter(Formatters.NONE, "", + "%02x", initBytesCount, + "", initAnnoWidth, "", + System.out); + } + + /** + * Returns a new HexPrinter setting the parameters to produce canonical output. + * The parameters are set to: + *
      + *
    • byte offset format: {@code "%08x "}, + *
    • each byte value is formatted as 2 hex digits and a space: {@code "%02x "}, + *
    • maximum number of byte values per line: {@value initBytesCount}, + *
    • delimiter for the annotation: {@code "|"}, + *
    • formatter: {@link Formatters#ASCII ASCII bytes}, and + *
    • line separator: "|" + {@link System#lineSeparator()}, + *
    • destination: {@link System#out System.out}. + *
    + * Example, + *
    +     * {@code     byte[] bytes = new byte[] { ' ', 0x41, 0x42, '\n'};
    +     *     String s = HexPrinter.canonical()
    +     *             .toString(bytes);
    +     *
    +     *     Result: "00000000  20 41 42 0a                                     | AB|"
    +     * }
    + * + * @return a new HexPrinter + */ + public static HexPrinter canonical() { + return new HexPrinter(Formatters.ASCII, "%08x ", + "%02x ", initBytesCount, + "|", 31, "|" + System.lineSeparator(), + System.out); + } + + /** + * Returns a new HexPrinter setting simple formatting parameters to output + * to a multi-line string. + * The parameters are set to: + *
      + *
    • byte offset format: signed decimal width 5 and a space, {@code "%5d: "}, + *
    • each byte value is formatted as 2 hex digits and a space: {@code "%02x "}, + *
    • maximum number of byte values per line: {@value initBytesCount}, + *
    • delimiter for the annotation: {@code " // "}, + *
    • width for the annotation: {@value initAnnoWidth}, + *
    • line separator: {@link System#lineSeparator()}, + *
    • formatter: {@link Formatters#PRINTABLE printable ASCII} + * showing printable characters, mnemonics for control chars, and + * otherwise the decimal byte values, + *
    • destination default: {@link System#out System.out}. + *
    + * Example, + *
    +     * {@code    byte[] bytes = new byte[] { ' ', 0x41, 0x42, '\n'};
    +     *    String s = HexPrinter.simple()
    +     *            .toString(bytes);
    +     *
    +     *    Result: "    0: 20 41 42 0a                                      //  AB\n"
    +     * }
    + * + * @return a new HexPrinter + */ + public static HexPrinter simple() { + return new HexPrinter(Formatters.PRINTABLE, initOffsetFormat, + initBytesFormat, initBytesCount, + initAnnoDelim, initAnnoWidth, System.lineSeparator(), + System.out); + } + + /** + * Returns a new HexPrinter setting formatting parameters to output + * to a multi-line string as a byte array initialization for Java source. + * The parameters are set to: + *
      + *
    • byte offset format: 4 space indent: {@code " "}, + *
    • each byte value is formatted as: {@code "(byte)%3d, "}, + *
    • maximum number of byte values per line: {@code 8}, + *
    • delimiter for the annotation: {@code " // "}, + *
    • width for the annotation: {@value initAnnoWidth}, + *
    • line separator: {@link System#lineSeparator()}, + *
    • formatter: {@link Formatters#PRINTABLE printable ASCII} + * showing printable characters, mnemonics for control chars, and + * otherwise the decimal byte values, + *
    • destination default: {@link System#out System.out}. + *
    + * + * @return a new HexPrinter + */ + public static HexPrinter source() { + return new HexPrinter(Formatters.PRINTABLE, " ", + "(byte)%3d, ", 8, + " // ", initAnnoWidth, System.lineSeparator(), + System.out); + } + + /** + * Returns a new HexPrinter setting the destination to the Appendable. + * {@code Appendable} classes include: {@link PrintStream}, {@link Writer}, + * {@link StringBuilder}, and {@link StringBuffer}. + * + * @param dest the Appendable destination for the output, non-null + * @return a new HexPrinter + * @throws UncheckedIOException if an I/O error occurs + */ + public HexPrinter dest(Appendable dest) { + Objects.requireNonNull(dest, "dest"); + return new HexPrinter(annoFormatter, offsetFormat, + bytesFormat, bytesCount, annoDelim, + annoWidth, lineSeparator, dest); + } + + /** + * The formatter function is called repeatedly to read all of the bytes + * and append the output. + * All output is appended and flushed to the destination. + *

    + * The result is equivalent to calling + * {@code format(new ByteArrayInputStream(source))}. + * + * @param source a non-null array of bytes. + * @return this HexPrinter + * @throws java.io.UncheckedIOException if an I/O error occurs + */ + public HexPrinter format(byte[] source) { + Objects.requireNonNull(source, "byte array must be non-null"); + return format(new ByteArrayInputStream(source)); + } + + /** + * The formatter function is called repeatedly to read the bytes from offset + * for length and append the output. + * All output is appended and flushed to the destination. + * Only {@code length} bytes starting at the {@code offset} are formatted. + *

    + * The result is equivalent to calling + * {@code format(new ByteArrayInputStream(source, offset, len))}. + * + * @param source a non-null array of bytes. + * @param offset the offset into the array to start + * @param length the length of bytes in the array to format + * @return this HexPrinter + * @throws java.io.UncheckedIOException if an I/O error occurs + */ + public HexPrinter format(byte[] source, int offset, int length) { + Objects.requireNonNull(source, "byte array must be non-null"); + return format(new ByteArrayInputStream(source, offset, length), offset); + } + + /** + * The formatter function is called repeatedly to read all of the bytes + * and append the output. + * All output is appended and flushed to the destination. + *

    + * The {@code format} method invokes the {@code formatter} to read bytes from the + * source and append the formatted sequence of byte values to the destination. + * As the bytes are read they are printed using the {@link #withBytesFormat} + * to fill the bytes values of the output destination. + * The output of the {@code formatter} fills the annotation field. + * A new line is started when either the byte values or annotation + * is filled to its respective width. The offset of the first byte on the line + * is inserted at the beginning of each line using {@link #withOffsetFormat(String)}. + *

    + * This method may block indefinitely reading from the input stream, + * or writing to the output stream. The behavior for the case where + * the input and/or output stream is asynchronously closed, + * or the thread interrupted during the transfer, is highly input + * and output stream specific, and therefore not specified. + *

    + * If an I/O error occurs reading from the input stream or + * writing to the output stream, then it may do so after some bytes + * have been read or written. Consequently the input stream + * may not be at end of stream and one, or both, streams may be + * in an inconsistent state. It is strongly recommended that both streams + * be promptly closed if an I/O error occurs. + * + * @param source an InputStream to read from, the stream not closed and + * is at end-of-file. + * @return this HexPrinter + * @throws java.io.UncheckedIOException if an I/O error occurs + */ + public HexPrinter format(InputStream source) { + return format(source, 0); + } + + /** + * Format an InputStream and supply the initial offset. + * + * @param source an InputStream + * @param offset an offset + * @return this HexPrinter + */ + private HexPrinter format(InputStream source, int offset) { + Objects.requireNonNull(source, "InputStream must be non-null"); + try (AnnotationWriter writer = + new AnnotationWriter(this, source, offset, dest)) { + writer.flush(); + return this; + } + } + + /** + * The formatter function is called repeatedly to read the bytes + * from the offset for the length and append the output. + * All annotation output is appended and flushed to the output destination. + * The ByteBuffer position and limit are unused and not modified. + * + * @param source a ByteBuffer + * @param offset the offset in the ByteBuffer + * @param length the length in the ByteBuffer + * @return this HexPrinter + * @throws java.io.UncheckedIOException if an I/O error occurs + */ + public HexPrinter format(ByteBuffer source, int offset, int length) { + Objects.requireNonNull(source, "ByteBuffer must be non-null"); + ByteArrayInputStream bais; + if (source.hasArray() && !source.isReadOnly()) { + bais = new ByteArrayInputStream(source.array(), offset, length); + } else { + int size = source.limit() - source.position(); + byte[] bytes = new byte[size]; + source.get(bytes, offset, length); + bais = new ByteArrayInputStream(bytes); + } + return format(bais, offset); + } + + /** + * The formatter function is called repeatedly to read all of the bytes + * in the source and append the output. + * The source bytes are from the {@code ByteBuffer.position()} + * to the {@code ByteBuffer.limit()}. + * The position is not modified. + * All output is appended and flushed to the destination. + * + * @param source a ByteBuffer + * @return this HexPrinter + * @throws java.io.UncheckedIOException if an I/O error occurs + */ + public HexPrinter format(ByteBuffer source) { + return format(source, source.position(), source.limit()); + } + + /** + * The formatter function is called repeatedly to read all of the bytes + * and return a String. + * + * @param source a non-null array of bytes. + * @return the output as a non-null {@code String} + * @throws java.io.UncheckedIOException if an I/O error occurs + */ + public String toString(byte[] source) { + Objects.requireNonNull(source, "byte array must be non-null"); + return toString(new ByteArrayInputStream(source)); + } + + /** + * The formatter function is called repeatedly to read the bytes from offset + * for length and return a String. + * Only {@code length} bytes starting at the {@code offset} are formatted. + * + * @param source a non-null array of bytes. + * @param offset the offset into the array to start + * @param length the length of bytes in the array to format + * @return the output as a non-null {@code String} + * @throws java.io.UncheckedIOException if an I/O error occurs + */ + public String toString(byte[] source, int offset, int length) { + Objects.requireNonNull(source, "byte array must be non-null"); + StringBuilder sb = new StringBuilder(); + try (AnnotationWriter writer = + new AnnotationWriter(this, new ByteArrayInputStream(source, offset, length), + offset, sb)) { + writer.flush(); + return sb.toString(); + } + } + + /** + * The formatter function is called repeatedly to read all of the bytes + * and return a String. + *

    + * The {@code toString} method invokes the formatter to read bytes from the + * source and append the formatted sequence of byte values. + * As the bytes are read they are printed using the {@link #withBytesFormat} + * to fill the second field of the line. + * The output of the {@code formatter} fills the annotation field. + * A new line is started when either the byte values or annotation + * is filled to its respective width. The offset of the first byte on the line + * is inserted at the beginning of each line using {@link #withOffsetFormat(String)}. + *

    + * This method may block indefinitely reading from the input stream, + * or writing to the output stream. The behavior for the case where + * the input and/or output stream is asynchronously closed, + * or the thread interrupted during the transfer, is highly input + * and output stream specific, and therefore not specified. + *

    + * If an I/O error occurs reading from the input stream or + * writing to the output stream, then it may do so after some bytes + * have been read or written. Consequently the input stream + * may not be at end of stream and one, or both, streams may be + * in an inconsistent state. It is strongly recommended that both streams + * be promptly closed if an I/O error occurs. + * + * @param source an InputStream to read from, the stream not closed and + * is at end-of-file upon return. + * @return the output as a non-null {@code String} + * @throws java.io.UncheckedIOException if an I/O error occurs + */ + public String toString(InputStream source) { + Objects.requireNonNull(source, "InputStream must be non-null"); + StringBuilder sb = new StringBuilder(); + try (AnnotationWriter writer = + new AnnotationWriter(this, source, 0, sb)) { + writer.flush(); + return sb.toString(); + } + } + + /** + * The formatter function is called repeatedly to read the bytes + * from the offset for the length and return a String. + * The ByteBuffer position and limit are unused and not modified. + * + * @param source a ByteBuffer + * @param offset the offset in the ByteBuffer + * @param length the length in the ByteBuffer + * @return the output as a non-null {@code String} + * @throws java.io.UncheckedIOException if an I/O error occurs + */ + public String toString(ByteBuffer source, int offset, int length) { + Objects.requireNonNull(source, "ByteBuffer must be non-null"); + StringBuilder sb = new StringBuilder(); + ByteArrayInputStream bais; + if (source.hasArray() && !source.isReadOnly()) { + bais = new ByteArrayInputStream(source.array(), offset, length); + } else { + byte[] bytes = new byte[length]; + source.get(bytes, offset, length); + bais = new ByteArrayInputStream(bytes); + } + try (AnnotationWriter writer = + new AnnotationWriter(this, bais, offset, sb)) { + writer.flush(); + return sb.toString(); + } + } + + /** + * The formatter function is called repeatedly to read all of the bytes + * in the source and return a String. + * The source bytes are from the {@code ByteBuffer.position()} + * to the {@code ByteBuffer.limit()}. + * The position is not modified. + * + * @param source a ByteBuffer + * @return the output as a non-null {@code String} + * @throws java.io.UncheckedIOException if an I/O error occurs + */ + public String toString(ByteBuffer source) { + return toString(source, source.position(), source.limit()); + } + + /** + * Returns a new HexPrinter setting the format for the byte offset. + * The format string is specified by {@link String#format String format} + * including any delimiters. For example, {@code "%3x: "}. + * If the format is an empty string, there is no offset in the output. + * + * @param offsetFormat a new format string for the byte offset. + * @return a new HexPrinter + */ + public HexPrinter withOffsetFormat(String offsetFormat) { + Objects.requireNonNull(offsetFormat, "offsetFormat"); + return new HexPrinter(annoFormatter, offsetFormat, bytesFormat, bytesCount, + annoDelim, annoWidth, lineSeparator, dest); + } + + /** + * Returns a new HexPrinter setting the format for each byte value and + * the maximum number of byte values per line. + * The format string is specified by {@link String#format String format}, + * including any delimiters or padding. For example, {@code "%02x "}. + * If the byteFormat is an empty String, there are no byte values in the output. + * + * @param byteFormat a format string for each byte + * @param bytesCount the maximum number of byte values per line + * @return a new HexPrinter + */ + public HexPrinter withBytesFormat(String byteFormat, int bytesCount) { + Objects.requireNonNull(bytesFormat, "bytesFormat"); + return new HexPrinter(annoFormatter, offsetFormat, byteFormat, bytesCount, + annoDelim, annoWidth, lineSeparator, dest); + } + + /** + * Returns a new HexPrinter setting the line separator. + * The line separator can be set to an empty string or to + * a string to be added at the end of each line. It should include the line + * separator {@link System#lineSeparator()} if a line break is to be output. + * + * @param separator the line separator + * @return a new HexPrinter + */ + public HexPrinter withLineSeparator(String separator) { + return new HexPrinter(annoFormatter, offsetFormat, bytesFormat, bytesCount, + annoDelim, annoWidth, separator, dest); + } + + /** + * Returns a new HexPrinter setting the formatter. + * The widths, delimiters and other parameters are unchanged. + * + * @param formatter a non-null Formatter + * @return a new HexPrinter + */ + public HexPrinter formatter(Formatter formatter) { + Objects.requireNonNull(formatter, "Formatter must be non-null"); + return new HexPrinter(formatter, offsetFormat, bytesFormat, bytesCount, + annoDelim, annoWidth, lineSeparator, dest); + } + + /** + * Returns a new HexPrinter setting the formatter, delimiter, and width of the annotation. + * Note: The annotations may exceed the width. + * + * @param formatter a non-null Formatter + * @param delim a string delimiter for the annotation + * @param width the width of the annotation, non-negative + * @return a new HexPrinter + */ + public HexPrinter formatter(Formatter formatter, String delim, int width) { + Objects.requireNonNull(formatter, "formatter"); + Objects.requireNonNull(delim, "delim"); + return new HexPrinter(formatter, offsetFormat, bytesFormat, bytesCount, + delim, width, lineSeparator, dest); + } + + /** + * Returns a new HexPrinter setting the formatter to format a primitive type + * using the format string. + * The format string should include any pre or post spacing and delimiters. + *

    + * This is a convenience function equivalent to finding a formatter using + * {@link HexPrinter.Formatters#ofPrimitive}. + *

    + * + * @param primClass a primitive class, for example, {@code int.class} + * @param fmtString a {@link java.util.Formatter format string}. + * @return a new HexPrinter + * @throws IllegalArgumentException if the class is not a primitive class + */ + public HexPrinter formatter(Class primClass, String fmtString) { + Formatter formatter = getFormatter(primClass, fmtString); + return new HexPrinter(formatter, offsetFormat, bytesFormat, bytesCount, + annoDelim, annoWidth, lineSeparator, dest); + } + + /** + * Returns a formatter for the primitive type using the format string. + * The formatter reads a value of the primitive type from the stream + * and formats it using the format string. + * The format string includes any pre or post spacing and delimiters. + * + * @param primClass a primitive class, for example, {@code int.class} + * @param fmtString a {@link java.util.Formatter format string} + * @return a Formatter for the primitive type using the format string + */ + static Formatter getFormatter(Class primClass, String fmtString) { + return new PrimitiveFormatter(primClass, fmtString); + } + + /** + * Returns a string describing this HexPrinter. + * The string indicates the type of the destination and + * the formatting options. + * + * @return a String describing this HexPrinter + */ + public String toString() { + return "formatter: " + annoFormatter + + ", dest: " + dest.getClass().getName() + + ", offset: \"" + offsetFormat + + "\", bytes: " + bytesCount + + " x \"" + bytesFormat + "\"" + + ", delim: \"" + annoDelim + "\"" + + ", width: " + annoWidth + + ", nl: \"" + expand(lineSeparator) + "\""; + } + + private String expand(String sep) { + return sep.replace("\n", "\\n") + .replace("\r", "\\r"); + } + + private static class PrimitiveFormatter implements Formatter { + + private final Class primClass; + private final String fmtString; + + PrimitiveFormatter(Class primClass, String fmtString) { + Objects.requireNonNull(primClass, "primClass"); + Objects.requireNonNull(fmtString, "fmtString"); + if (!primClass.isPrimitive()) + throw new IllegalArgumentException("Not a primitive type: " + primClass.getName()); + this.primClass = primClass; + this.fmtString = fmtString; + } + + public void annotate(DataInputStream in, Appendable out) throws IOException { + if (primClass == byte.class) { + int v = in.readByte(); + out.append(String.format(fmtString, v)); + } else if (primClass == boolean.class) { + boolean v = in.readByte() != 0; + out.append(String.format(fmtString, v)); + } else if (primClass == short.class | primClass == char.class) { + int v = in.readShort(); + out.append(String.format(fmtString, v)); + } else if (primClass == float.class) { + float v = in.readFloat(); + out.append(String.format(fmtString, v)); + } else if (primClass == int.class) { + int v = in.readInt(); + out.append(String.format(fmtString, v)); + } else if (primClass == double.class) { + double v = in.readDouble(); + out.append(String.format(fmtString, v)); + } else if (primClass == long.class) { + long v = in.readLong(); + out.append(String.format(fmtString, v)); + } else { + throw new AssertionError("missing case on primitive class"); + } + } + + public String toString() { + return "(" + primClass.getName() + ", \"" + fmtString + "\")"; + } + } + + /** + * Formatter function reads bytes from a stream and + * appends a readable annotation to the output destination. + *

    + * Each invocation of the {@link #annotate annotate} method reads and annotates + * a single instance of its protocol or data type. + *

    + * Built-in formatting functions are provided in the {@link Formatters} class. + *

    + * As described by the {@link HexPrinter#toString(InputStream)} method, + * the {@link #annotate annotate} method is called to read bytes and produce + * the descriptive annotation. + *

    + * For example, a custom lambda formatter to read a float value (4 bytes) and + * print as a floating number could be written as a static method. + *

    {@code
    +     *     // Format 4 bytes read from the input as a float 3.4.
    +     *     static void annotate(DataInputStream in, Appendable out) throws IOException {
    +     *         float f = in.readFloat();
    +     *         out.append(String.format("%3.4f, ", f));
    +     *     }
    +     *
    +     *     byte[] bytes = new byte[] {00 00 00 00 3f 80 00 00 40 00 00 00 40 40 00 00};
    +     *     HexPrinter pp = HexPrinter.simple()
    +     *         .withBytesFormat("%02x ", 8)
    +     *         .formatter(Example::annotate)
    +     *         .format(bytes);
    +     *
    +     * Result:
    +     *     0: 00 00 00 00 3f 80 00 00  // 0.0000, 1.0000,
    +     *     8: 40 00 00 00 40 40 00 00  // 2.0000, 3.0000,
    +     * }
    + * + *

    + * The details of the buffering and calling of the formatter {@code annotate} + * methods is roughly as follows. + * The bytes read by the {@code annotate} method are logically buffered + * for each line of output. + * The {@code annotate} method writes its description of the bytes read + * to the output, this output is also buffered. + * When the number of bytes read exceeds the + * {@link #withBytesFormat(String, int) byte values count per line}, + * the buffered output exceeds the + * {@link #formatter(Formatter, String, int) width of the annotation field}, + * or a new line {@code "\n"} character is found in the output then + * a line of output is assembled and written to the destination Appendable. + * The formatter's {@code annotate} method is called repeatedly + * until the input is completely consumed or an exception is thrown. + * Any remaining buffered bytes or description are flushed to the destination Appendable. + */ + @FunctionalInterface + public interface Formatter { + + /** + * Read bytes from the input stream and append a descriptive annotation + * to the output destination. + * + * @param in a DataInputStream + * @param out an Appendable for the output + * @throws IOException if an I/O error occurs + */ + void annotate(DataInputStream in, Appendable out) throws IOException; + } + + /** + * Built-in formatters for printable byte, ASCII, UTF-8 and primitive types. + * Formatters for primitive types and different formatting options + * can be found by calling {@link #ofPrimitive(Class, String)}. + */ + public enum Formatters implements Formatter { + /** + * Read a byte and if it is ASCII write it, + * otherwise, write its mnemonic or its decimal value. + */ + PRINTABLE, + /** + * Read a byte, if it is ASCII write it, otherwise write a ".". + */ + ASCII, + /** + * Read a modified UTF-8 string and write it. + */ + UTF8, + /** + * Read a byte and write nothing. + */ + NONE; + + public void annotate(DataInputStream in, Appendable out) throws IOException { + switch (this) { + case PRINTABLE: bytePrintable(in, out); break; + case ASCII: byteASCII(in, out); break; + case UTF8: utf8Parser(in, out); break; + case NONE: byteNoneParser(in, out); break; + } + } + + /** + * Read a byte and write it as ASCII if it is printable, + * print its mnemonic if it is a control character, + * and print its decimal value otherwise. + * A space separator character is appended for control and decimal values. + * + * @param in a DataInputStream + * @param out an Appendable to write to + * @throws IOException if an I/O error occurs + */ + static void bytePrintable(DataInputStream in, Appendable out) throws IOException { + int v = in.readUnsignedByte(); + if (v < 32) { + out.append("\\").append(CONTROL_MNEMONICS[v]); + } else if (v < 126 && Character.isDefined(v)) { + out.append((char) v); + } else { + out.append("\\").append(Integer.toString(v, 10)); + } + } + + /** + * Read a byte and write it as ASCII if it is printable, otherwise print ".". + * + * @param in a DataInputStream + * @param out an Appendable to write to + * @throws IOException if an I/O error occurs + */ + static void byteASCII(DataInputStream in, Appendable out) throws IOException { + int v = in.readUnsignedByte(); + if (Character.isDefined(v)) { + out.append((char) v); + } else { + out.append('.'); + } + } + + /** + * Read a modified UTF-8 string and write it to the output destination. + * + * @param in a DataInputStream + * @param out an Appendable to write the output to + * @throws IOException if an I/O error occurs + */ + static void utf8Parser(DataInputStream in, Appendable out) throws IOException { + out.append(in.readUTF()).append(" "); + } + + /** + * Read a a byte and write nothing. + * + * @param in a DataInputStream + * @param out an Appendable to write the output to + * @throws IOException if an I/O error occurs + */ + static void byteNoneParser(DataInputStream in, Appendable out) throws IOException { + in.readByte(); + } + + /** + * Returns a {@code Formatter} for a primitive using the format string. + * The format string includes any pre or post spacing or delimiters. + * A value of the primitive is read using the type specific methods + * of {@link DataInputStream}, formatted using the format string, and + * written to the output. + * + * @param primClass a primitive class, for example, {@code int.class} + * @param fmtString a {@link java.util.Formatter format string}. + * @return a Formatter + */ + public static Formatter ofPrimitive(Class primClass, String fmtString) { + Objects.requireNonNull(primClass, "primClass"); + Objects.requireNonNull(fmtString, "fmtString"); + return new PrimitiveFormatter(primClass, fmtString); + } + } + + /** + * Internal implementation of the annotation output and processor of annotated output. + * Created for each new input source and discarded after each use. + * An OffsetInputStream is created to buffer and count the input bytes. + * + */ + private static final class AnnotationWriter extends CharArrayWriter { + private final transient OffsetInputStream source; + private final transient DataInputStream in; + private final transient int baseOffset; + private final transient HexPrinter params; + private final transient int bytesColWidth; + private final transient int annoWidth; + private final transient Appendable dest; + + /** + * Construct a new AnnotationWriter to process the source into the destination. + * Initializes the DataInputStream and marking of the input to keep track + * of bytes as they are read by the formatter. + * @param params formatting parameters + * @param source source InputStream + * @param baseOffset initial offset + * @param dest destination Appendable + */ + AnnotationWriter(HexPrinter params, InputStream source, int baseOffset, Appendable dest) { + this.params = params; + this.baseOffset = baseOffset; + Objects.requireNonNull(source, "Source is null"); + this.source = new OffsetInputStream(source); + this.source.mark(1024); + this.in = new DataInputStream(this.source); + this.bytesColWidth = params.bytesCount * String.format(params.bytesFormat, 255).length(); + this.annoWidth = params.annoWidth; + this.dest = dest; + } + + @Override + public void write(int c) { + super.write(c); + checkFlush(); + } + + @Override + public void write(char[] c, int off, int len) { + super.write(c, off, len); + for (int i = 0; i < len; i++) { + if (c[off+i] == '\n') { + process(); + return; + } + } + checkFlush(); + } + + @Override + public void write(String str, int off, int len) { + super.write(str, off, len); + if (str.indexOf('\n') >=0 ) + process(); + else + checkFlush(); + } + + private void checkFlush() { + if (size() > annoWidth) + process(); + } + + /** + * The annotation printing function is called repeatedly to read all of the bytes + * in the source stream and annotate the stream. + * The annotated output is appended to the output dest or buffered. + *

    + * The HexPrinter is not closed and can be used as a template + * to create a new formatter with a new Source or different formatting + * options. + *

    + */ + @Override + public void flush() { + try { + while (true) { + if (source.markedByteCount() >= params.bytesCount) + process(); + params.annoFormatter.annotate(in, this); + if (source.markedByteCount() > 256) { + // Normally annotations would cause processing more often + // Guard against overrunning the mark/reset buffer. + process(); + } + } + } catch (IOException ioe) { + process(); + if (!(ioe instanceof EOFException)) { + throw new UncheckedIOException(ioe); + } + } catch (UncheckedIOException uio) { + process(); // clear out the buffers + throw uio; + } + } + + /** + * Merge the buffered stream of annotations with the formatted bytes + * and append them to the dest. + *

    + * The annotation mapping function has read some bytes and buffered + * some output that corresponds to those bytes. + * The un-formatted bytes are in the OffsetInputStream after the mark. + * The stream is reset and the bytes are read again. + * Each line of the produced one line at a time to the dest. + * The byte offset is formatted according to the offsetFormat. + * The bytes after the mark are read and formatted using the bytesFormat + * and written to the dest up to the bytesWidth. + * The annotation stream is appended to the dest, but only up to the + * first newline (if any). The alignment between the annotated stream + * and the formatted bytes is approximate. + * New line characters in the annotation cause a new line to be started + * without regard to the number of formatted bytes. The column of formatted + * bytes may be incomplete. + */ + private void process() { + String info = toString(); + reset(); + int count = source.markedByteCount(); + try { + source.reset(); + long binColOffset = source.byteOffset(); + while (count > 0 || info.length() > 0) { + dest.append(String.format(params.offsetFormat, binColOffset + baseOffset)); + int colWidth = 0; + int byteCount = Math.min(params.bytesCount, count); + for (int i = 0; i < byteCount; i++) { + int b = source.read(); + if (b == -1) + throw new IllegalStateException("BUG"); + String s = String.format(params.bytesFormat, b); + colWidth += s.length(); + dest.append(s); + } + binColOffset += byteCount; + count -= byteCount; + + // Pad out the bytes column to its width + dest.append(" ".repeat(Math.max(0, bytesColWidth - colWidth))); + dest.append(params.annoDelim); + + // finish a line and prepare for next line + // Add a line from annotation buffer + if (info.length() > 0) { + int nl = info.indexOf('\n'); + if (nl < 0) { + dest.append(info); + info = ""; + } else { + dest.append(info, 0, nl); + info = info.substring(nl + 1); + } + } + dest.append(params.lineSeparator); + } + } catch (IOException ioe) { + try { + dest.append("\nIOException during annotations: ") + .append(ioe.getMessage()) + .append("\n"); + } catch (IOException ignore) { + // ignore + } + } + // reset the mark for the next line + source.mark(1024); + } + } + + /** + * Buffered InputStream that keeps track of byte offset. + */ + private static final class OffsetInputStream extends BufferedInputStream { + private long byteOffset; + private long markByteOffset; + + OffsetInputStream(InputStream in) { + super(in); + byteOffset = 0; + markByteOffset = 0; + } + + long byteOffset() { + return byteOffset; + } + + @Override + public void reset() throws IOException { + super.reset(); + byteOffset = markByteOffset; + } + + @Override + public synchronized void mark(int readlimit) { + super.mark(readlimit); + markByteOffset = byteOffset; + } + + int markedByteCount() { + if (markpos < 0) + return 0; + return pos - markpos; + } + + @Override + public int read() throws IOException { + int b = super.read(); + if (b >= 0) + byteOffset++; + return b; + } + + @Override + public long skip(long n) throws IOException { + long size = super.skip(n); + byteOffset += size; + return size; + } + + @Override + public int read(byte[] b) throws IOException { + int size = super.read(b); + byteOffset += Math.max(size, 0); + return size; + } + + @Override + public int read(byte[] b, int off, int len) throws IOException { + int size = super.read(b, off, len); + byteOffset += Math.max(size, 0); + return size; + } + } +} From 5d4de366d7092aefc26246ab1a4039f8bd30d7fa Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Fri, 29 Mar 2024 16:45:59 +0000 Subject: [PATCH 060/149] 8286705: GCC 12 reports use-after-free potential bugs Reviewed-by: phh Backport-of: 0e4bece5b5143b8505496ea7430bbfa11e151aff --- src/java.base/share/native/libjli/parse_manifest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/native/libjli/parse_manifest.c b/src/java.base/share/native/libjli/parse_manifest.c index 2889fab0686..a0d87b8bb9e 100644 --- a/src/java.base/share/native/libjli/parse_manifest.c +++ b/src/java.base/share/native/libjli/parse_manifest.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -288,8 +288,8 @@ find_positions(int fd, Byte *eb, jlong* base_offset, jlong* censtart) for (cp = &buffer[bytes - ENDHDR]; cp >= &buffer[0]; cp--) if (ENDSIG_AT(cp) && (cp + ENDHDR + ENDCOM(cp) == endpos)) { (void) memcpy(eb, cp, ENDHDR); - free(buffer); pos = flen - (endpos - cp); + free(buffer); return find_positions64(fd, eb, pos, base_offset, censtart); } free(buffer); From 979daf54de3a9244f9316ea1fc18b7a615835680 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Sat, 30 Mar 2024 09:08:37 +0000 Subject: [PATCH 061/149] 8264152: javax/net/ssl/DTLS/RespondToRetransmit.java timed out Reviewed-by: lucy Backport-of: 79adc16fd8ba47a8d9438f3467f92ab241766c1d --- .../javax/net/ssl/DTLS/DTLSOverDatagram.java | 359 ++++++++---------- .../ssl/DTLS/PacketLossRetransmission.java | 6 +- .../net/ssl/DTLS/RespondToRetransmit.java | 6 +- 3 files changed, 172 insertions(+), 199 deletions(-) diff --git a/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java b/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java index 4749dc0bb74..1014cff3a5b 100644 --- a/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java +++ b/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2021, 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 @@ -50,33 +50,33 @@ */ public class DTLSOverDatagram { - private static int MAX_HANDSHAKE_LOOPS = 200; - private static int MAX_APP_READ_LOOPS = 60; - private static int SOCKET_TIMEOUT = 10 * 1000; // in millis - private static int BUFFER_SIZE = 1024; - private static int MAXIMUM_PACKET_SIZE = 1024; + private static final int MAX_HANDSHAKE_LOOPS = 200; + private static final int MAX_APP_READ_LOOPS = 60; + private static final int SOCKET_TIMEOUT = 10 * 1000; // in millis + private static final int BUFFER_SIZE = 1024; + private static final int MAXIMUM_PACKET_SIZE = 1024; /* * The following is to set up the keystores. */ - private static String pathToStores = "../etc"; - private static String keyStoreFile = "keystore"; - private static String trustStoreFile = "truststore"; - - private static String keyFilename = - System.getProperty("test.src", ".") + "/" + pathToStores + - "/" + keyStoreFile; - private static String trustFilename = - System.getProperty("test.src", ".") + "/" + pathToStores + - "/" + trustStoreFile; - private static Exception clientException = null; - private static Exception serverException = null; - - private static ByteBuffer serverApp = + private static final String PATH_TO_STORES = "../etc"; + private static final String KEY_STORE_FILE = "keystore"; + private static final String TRUST_STORE_FILE = "truststore"; + + private static final String KEY_FILENAME = + System.getProperty("test.src", ".") + "/" + PATH_TO_STORES + + "/" + KEY_STORE_FILE; + private static final String TRUST_FILENAME = + System.getProperty("test.src", ".") + "/" + PATH_TO_STORES + + "/" + TRUST_STORE_FILE; + + private static final ByteBuffer SERVER_APP = ByteBuffer.wrap("Hi Client, I'm Server".getBytes()); - private static ByteBuffer clientApp = + private static final ByteBuffer CLIENT_APP = ByteBuffer.wrap("Hi Server, I'm Client".getBytes()); + private static Exception clientException = null; + private static Exception serverException = null; /* * ============================================================= * The test case @@ -91,18 +91,19 @@ public static void main(String[] args) throws Exception { */ void doServerSide(DatagramSocket socket, InetSocketAddress clientSocketAddr) throws Exception { + String side = "Server"; // create SSLEngine SSLEngine engine = createSSLEngine(false); // handshaking - handshake(engine, socket, clientSocketAddr, "Server"); + handshake(engine, socket, clientSocketAddr, side); // read client application data - receiveAppData(engine, socket, clientApp); + receiveAppData(engine, socket, CLIENT_APP); // write server application data - deliverAppData(engine, socket, serverApp, clientSocketAddr); + deliverAppData(engine, socket, SERVER_APP, clientSocketAddr, side); } /* @@ -110,18 +111,19 @@ void doServerSide(DatagramSocket socket, InetSocketAddress clientSocketAddr) */ void doClientSide(DatagramSocket socket, InetSocketAddress serverSocketAddr) throws Exception { + String side = "Client"; // create SSLEngine SSLEngine engine = createSSLEngine(true); // handshaking - handshake(engine, socket, serverSocketAddr, "Client"); + handshake(engine, socket, serverSocketAddr, side); // write client application data - deliverAppData(engine, socket, clientApp, serverSocketAddr); + deliverAppData(engine, socket, CLIENT_APP, serverSocketAddr, side); // read server application data - receiveAppData(engine, socket, serverApp); + receiveAppData(engine, socket, SERVER_APP); } /* @@ -153,117 +155,95 @@ void handshake(SSLEngine engine, DatagramSocket socket, if (--loops < 0) { throw new RuntimeException( - "Too much loops to produce handshake packets"); + "Too many loops to produce handshake packets"); } SSLEngineResult.HandshakeStatus hs = engine.getHandshakeStatus(); log(side, "=======handshake(" + loops + ", " + hs + ")======="); - if (hs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP || - hs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP_AGAIN) { - - log(side, "Receive DTLS records, handshake status is " + hs); - - ByteBuffer iNet; - ByteBuffer iApp; - if (hs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) { - byte[] buf = new byte[BUFFER_SIZE]; - DatagramPacket packet = new DatagramPacket(buf, buf.length); - try { - socket.receive(packet); - } catch (SocketTimeoutException ste) { - log(side, "Warning: " + ste); - - List packets = new ArrayList<>(); - boolean finished = onReceiveTimeout( - engine, peerAddr, side, packets); - - log(side, "Reproduced " + packets.size() + " packets"); - for (DatagramPacket p : packets) { - printHex("Reproduced packet", - p.getData(), p.getOffset(), p.getLength()); - socket.send(p); - } - if (finished) { - log(side, "Handshake status is FINISHED " - + "after calling onReceiveTimeout(), " - + "finish the loop"); - endLoops = true; + switch (hs) { + case NEED_UNWRAP: + case NEED_UNWRAP_AGAIN: { + log(side, "Receive DTLS records, handshake status is " + hs); + + ByteBuffer iNet; + ByteBuffer iApp; + + if (hs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) { + byte[] buf = new byte[BUFFER_SIZE]; + DatagramPacket packet = new DatagramPacket(buf, buf.length); + try { + socket.receive(packet); + } catch (SocketTimeoutException ste) { + log(side, "Warning: " + ste); + + List packets = new ArrayList<>(); + boolean finished = onReceiveTimeout( + engine, peerAddr, side, packets); + + log(side, "Reproduced " + packets.size() + " packets"); + for (DatagramPacket p : packets) { + printHex("Reproduced packet", + p.getData(), p.getOffset(), p.getLength()); + socket.send(p); + } + + if (finished) { + log(side, "Handshake status is FINISHED " + + "after calling onReceiveTimeout(), " + + "finish the loop"); + endLoops = true; + } + + log(side, "New handshake status is " + + engine.getHandshakeStatus()); + + continue; } - log(side, "New handshake status is " - + engine.getHandshakeStatus()); - - continue; + iNet = ByteBuffer.wrap(buf, 0, packet.getLength()); + } else { + iNet = ByteBuffer.allocate(0); } - iNet = ByteBuffer.wrap(buf, 0, packet.getLength()); iApp = ByteBuffer.allocate(BUFFER_SIZE); - } else { - iNet = ByteBuffer.allocate(0); - iApp = ByteBuffer.allocate(BUFFER_SIZE); - } - - SSLEngineResult r = engine.unwrap(iNet, iApp); - SSLEngineResult.Status rs = r.getStatus(); - hs = r.getHandshakeStatus(); - if (rs == SSLEngineResult.Status.OK) { - // OK - } else if (rs == SSLEngineResult.Status.BUFFER_OVERFLOW) { - log(side, "BUFFER_OVERFLOW, handshake status is " + hs); - // the client maximum fragment size config does not work? - throw new Exception("Buffer overflow: " + - "incorrect client maximum fragment size"); - } else if (rs == SSLEngineResult.Status.BUFFER_UNDERFLOW) { - log(side, "BUFFER_UNDERFLOW, handshake status is " + hs); - - // bad packet, or the client maximum fragment size - // config does not work? - if (hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { - throw new Exception("Buffer underflow: " + - "incorrect client maximum fragment size"); - } // otherwise, ignore this packet - } else if (rs == SSLEngineResult.Status.CLOSED) { - throw new Exception( - "SSL engine closed, handshake status is " + hs); - } else { - throw new Exception("Can't reach here, result is " + rs); - } + SSLEngineResult r = engine.unwrap(iNet, iApp); + hs = r.getHandshakeStatus(); - if (hs == SSLEngineResult.HandshakeStatus.FINISHED) { - log(side, "Handshake status is FINISHED, finish the loop"); - endLoops = true; - } - } else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP) { - List packets = new ArrayList<>(); - boolean finished = produceHandshakePackets( - engine, peerAddr, side, packets); - - log(side, "Produced " + packets.size() + " packets"); - for (DatagramPacket p : packets) { - socket.send(p); - } + verifySSLEngineResultStatus(r, side); + if (hs == SSLEngineResult.HandshakeStatus.FINISHED) { + log(side, "Handshake status is FINISHED, finish the loop"); + endLoops = true; + } + } break; + case NEED_WRAP: { + List packets = new ArrayList<>(); + boolean finished = produceHandshakePackets( + engine, peerAddr, side, packets); + + log(side, "Produced " + packets.size() + " packets"); + for (DatagramPacket p : packets) { + socket.send(p); + } - if (finished) { - log(side, "Handshake status is FINISHED " - + "after producing handshake packets, " - + "finish the loop"); + if (finished) { + log(side, "Handshake status is FINISHED " + + "after producing handshake packets, " + + "finish the loop"); + endLoops = true; + } + } break; + case NEED_TASK: runDelegatedTasks(engine); break; + case NOT_HANDSHAKING: { + log(side, + "Handshake status is NOT_HANDSHAKING, finish the loop"); endLoops = true; - } - } else if (hs == SSLEngineResult.HandshakeStatus.NEED_TASK) { - runDelegatedTasks(engine); - } else if (hs == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { - log(side, - "Handshake status is NOT_HANDSHAKING, finish the loop"); - endLoops = true; - } else if (hs == SSLEngineResult.HandshakeStatus.FINISHED) { - throw new Exception( - "Unexpected status, SSLEngine.getHandshakeStatus() " - + "shouldn't return FINISHED"); - } else { - throw new Exception( - "Can't reach here, handshake status is " + hs); + } break; + case FINISHED: throw new Exception( "Unexpected status, " + + "SSLEngine.getHandshakeStatus() shouldn't return FINISHED"); + default: throw new Exception("Can't reach here, " + + "handshake status is " + hs); } } @@ -291,13 +271,39 @@ void handshake(SSLEngine engine, DatagramSocket socket, } } + void verifySSLEngineResultStatus(SSLEngineResult r, String side) throws Exception { + SSLEngineResult.Status rs = r.getStatus(); + SSLEngineResult.HandshakeStatus hs = r.getHandshakeStatus(); + switch (rs) { + case OK: log(side, "SSLEngineResult status OK"); break; + case BUFFER_OVERFLOW: { + log(side, "BUFFER_OVERFLOW, handshake status is " + hs); + // the client maximum fragment size config does not work? + throw new Exception("Buffer overflow: " + + "incorrect client maximum fragment size"); + } + case BUFFER_UNDERFLOW: { + log(side, "BUFFER_UNDERFLOW, handshake status is " + hs); + // bad packet, or the client maximum fragment size + // config does not work? + if (hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { + throw new Exception("Buffer underflow: " + + "incorrect client maximum fragment size"); + } // otherwise, ignore this packet + } break; + case CLOSED: throw new Exception( + "SSL engine closed, handshake status is " + hs); + default: throw new Exception("Can't reach here, result is " + rs); + } + } + // deliver application data void deliverAppData(SSLEngine engine, DatagramSocket socket, - ByteBuffer appData, SocketAddress peerAddr) throws Exception { + ByteBuffer appData, SocketAddress peerAddr, String side) throws Exception { // Note: have not consider the packet loses List packets = - produceApplicationPackets(engine, appData, peerAddr); + produceApplicationPackets(engine, appData, peerAddr, side); appData.flip(); for (DatagramPacket p : packets) { socket.send(p); @@ -344,7 +350,7 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, if (--loops < 0) { throw new RuntimeException( - "Too much loops to produce handshake packets"); + "Too many loops to produce handshake packets"); } ByteBuffer oNet = ByteBuffer.allocate(32768); @@ -356,30 +362,9 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, SSLEngineResult.HandshakeStatus hs = r.getHandshakeStatus(); log(side, "----produce handshake packet(" + loops + ", " + rs + ", " + hs + ")----"); - if (rs == SSLEngineResult.Status.BUFFER_OVERFLOW) { - // the client maximum fragment size config does not work? - throw new Exception("Buffer overflow: " + - "incorrect server maximum fragment size"); - } else if (rs == SSLEngineResult.Status.BUFFER_UNDERFLOW) { - log(side, - "Produce handshake packets: BUFFER_UNDERFLOW occured"); - log(side, - "Produce handshake packets: Handshake status: " + hs); - // bad packet, or the client maximum fragment size - // config does not work? - if (hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { - throw new Exception("Buffer underflow: " + - "incorrect server maximum fragment size"); - } // otherwise, ignore this packet - } else if (rs == SSLEngineResult.Status.CLOSED) { - throw new Exception("SSLEngine has closed"); - } else if (rs == SSLEngineResult.Status.OK) { - // OK - } else { - throw new Exception("Can't reach here, result is " + rs); - } - // SSLEngineResult.Status.OK: + verifySSLEngineResultStatus(r, side); + if (oNet.hasRemaining()) { byte[] ba = new byte[oNet.remaining()]; oNet.get(ba); @@ -396,24 +381,22 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, boolean endInnerLoop = false; SSLEngineResult.HandshakeStatus nhs = hs; while (!endInnerLoop) { - if (nhs == SSLEngineResult.HandshakeStatus.NEED_TASK) { - runDelegatedTasks(engine); - } else if (nhs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP || - nhs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP_AGAIN || - nhs == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { - - endInnerLoop = true; - endLoops = true; - } else if (nhs == SSLEngineResult.HandshakeStatus.NEED_WRAP) { - endInnerLoop = true; - } else if (nhs == SSLEngineResult.HandshakeStatus.FINISHED) { - throw new Exception( + switch (nhs) { + case NEED_TASK: runDelegatedTasks(engine); break; + case NEED_UNWRAP: + case NEED_UNWRAP_AGAIN: + case NOT_HANDSHAKING: { + endInnerLoop = true; + endLoops = true; + } break; + case NEED_WRAP: endInnerLoop = true; break; + case FINISHED: throw new Exception( "Unexpected status, SSLEngine.getHandshakeStatus() " - + "shouldn't return FINISHED"); - } else { - throw new Exception("Can't reach here, handshake status is " + + "should not return FINISHED"); + default: throw new Exception("Can't reach here, handshake status is " + nhs); } + nhs = engine.getHandshakeStatus(); } } @@ -428,30 +411,15 @@ DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) { // produce application packets List produceApplicationPackets( SSLEngine engine, ByteBuffer source, - SocketAddress socketAddr) throws Exception { + SocketAddress socketAddr, String side) throws Exception { List packets = new ArrayList<>(); ByteBuffer appNet = ByteBuffer.allocate(32768); SSLEngineResult r = engine.wrap(source, appNet); appNet.flip(); - SSLEngineResult.Status rs = r.getStatus(); - if (rs == SSLEngineResult.Status.BUFFER_OVERFLOW) { - // the client maximum fragment size config does not work? - throw new Exception("Buffer overflow: " + - "incorrect server maximum fragment size"); - } else if (rs == SSLEngineResult.Status.BUFFER_UNDERFLOW) { - // unlikely - throw new Exception("Buffer underflow during wraping"); - } else if (rs == SSLEngineResult.Status.CLOSED) { - throw new Exception("SSLEngine has closed"); - } else if (rs == SSLEngineResult.Status.OK) { - // OK - } else { - throw new Exception("Can't reach here, result is " + rs); - } + verifySSLEngineResultStatus(r, side); - // SSLEngineResult.Status.OK: if (appNet.hasRemaining()) { byte[] ba = new byte[appNet.remaining()]; appNet.get(ba); @@ -472,7 +440,7 @@ static DatagramPacket getPacket( int offset = packet.getOffset(); int length = packet.getLength(); - // Normally, this pakcet should be a handshake message + // Normally, this packet should be a handshake message // record. However, even if the underlying platform // splits the record more, we don't really worry about // the improper packet loss because DTLS implementation @@ -490,12 +458,12 @@ static DatagramPacket getPacket( if (data[offset + 4] == 0x00) { // plaintext matched = (data[offset + 13] == handshakeType); - } else { // cipherext + } else { // ciphertext // The 1st ciphertext is a Finished message. // // If it is not proposed to loss the Finished // message, it is not necessary to check the - // following packets any mroe as a Finished + // following packets any more as a Finished // message is the last handshake message. matched = (handshakeType == 20); } @@ -540,8 +508,8 @@ boolean onReceiveTimeout(SSLEngine engine, SocketAddress socketAddr, SSLContext getDTLSContext() throws Exception { String passphrase = "passphrase"; return SSLContextBuilder.builder() - .trustStore(KeyStoreUtils.loadKeyStore(trustFilename, passphrase)) - .keyStore(KeyStoreUtils.loadKeyStore(keyFilename, passphrase)) + .trustStore(KeyStoreUtils.loadKeyStore(TRUST_FILENAME, passphrase)) + .keyStore(KeyStoreUtils.loadKeyStore(KEY_FILENAME, passphrase)) .kmfPassphrase(passphrase) .protocol("DTLS") .build(); @@ -559,17 +527,22 @@ public boolean isGoodJob() { } public final void runTest(DTLSOverDatagram testCase) throws Exception { - try (DatagramSocket serverSocket = new DatagramSocket(); - DatagramSocket clientSocket = new DatagramSocket()) { + InetSocketAddress serverSocketAddress = new InetSocketAddress + (InetAddress.getLoopbackAddress(), 0); + InetSocketAddress clientSocketAddress = new InetSocketAddress + (InetAddress.getLoopbackAddress(), 0); + + try (DatagramSocket serverSocket = new DatagramSocket(serverSocketAddress); + DatagramSocket clientSocket = new DatagramSocket(clientSocketAddress)) { serverSocket.setSoTimeout(SOCKET_TIMEOUT); clientSocket.setSoTimeout(SOCKET_TIMEOUT); InetSocketAddress serverSocketAddr = new InetSocketAddress( - InetAddress.getLocalHost(), serverSocket.getLocalPort()); + InetAddress.getLoopbackAddress(), serverSocket.getLocalPort()); InetSocketAddress clientSocketAddr = new InetSocketAddress( - InetAddress.getLocalHost(), clientSocket.getLocalPort()); + InetAddress.getLoopbackAddress(), clientSocket.getLocalPort()); ExecutorService pool = Executors.newFixedThreadPool(2); Future server, client; @@ -687,7 +660,7 @@ public String call() throws Exception { } } - final static void printHex(String prefix, ByteBuffer bb) { + static void printHex(String prefix, ByteBuffer bb) { synchronized (System.out) { System.out.println(prefix); @@ -700,7 +673,7 @@ final static void printHex(String prefix, ByteBuffer bb) { } } - final static void printHex(String prefix, + static void printHex(String prefix, byte[] bytes, int offset, int length) { synchronized (System.out) { diff --git a/test/jdk/javax/net/ssl/DTLS/PacketLossRetransmission.java b/test/jdk/javax/net/ssl/DTLS/PacketLossRetransmission.java index e0b94363913..f0b245d3279 100644 --- a/test/jdk/javax/net/ssl/DTLS/PacketLossRetransmission.java +++ b/test/jdk/javax/net/ssl/DTLS/PacketLossRetransmission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, 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 @@ -84,7 +84,7 @@ public class PacketLossRetransmission extends DTLSOverDatagram { public static void main(String[] args) throws Exception { isClient = args[0].equals("client"); - handshakeType = Byte.valueOf(args[1]); + handshakeType = Byte.parseByte(args[1]); PacketLossRetransmission testCase = new PacketLossRetransmission(); testCase.runTest(testCase); @@ -97,7 +97,7 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, boolean finished = super.produceHandshakePackets( engine, socketAddr, side, packets); - if (needPacketLoss && (!(isClient ^ engine.getUseClientMode()))) { + if (needPacketLoss && (isClient == engine.getUseClientMode())) { DatagramPacket packet = getPacket(packets, handshakeType); if (packet != null) { needPacketLoss = false; diff --git a/test/jdk/javax/net/ssl/DTLS/RespondToRetransmit.java b/test/jdk/javax/net/ssl/DTLS/RespondToRetransmit.java index d61d4d9623e..72b7715805e 100644 --- a/test/jdk/javax/net/ssl/DTLS/RespondToRetransmit.java +++ b/test/jdk/javax/net/ssl/DTLS/RespondToRetransmit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2021, 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 @@ -85,7 +85,7 @@ public class RespondToRetransmit extends DTLSOverDatagram { public static void main(String[] args) throws Exception { isClient = args[0].equals("client"); - handshakeType = Byte.valueOf(args[1]); + handshakeType = Byte.parseByte(args[1]); RespondToRetransmit testCase = new RespondToRetransmit(); testCase.runTest(testCase); @@ -98,7 +98,7 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, boolean finished = super.produceHandshakePackets( engine, socketAddr, side, packets); - if (needPacketDuplicate && (!(isClient ^ engine.getUseClientMode()))) { + if (needPacketDuplicate && (isClient == engine.getUseClientMode())) { DatagramPacket packet = getPacket(packets, handshakeType); if (packet != null) { needPacketDuplicate = false; From 00736021bc6b769dfc6d99dfa5079b4d9427aadd Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Sat, 30 Mar 2024 15:11:56 +0000 Subject: [PATCH 062/149] 8297798: Timeout with DTLSOverDatagram test template Reviewed-by: mbaesken Backport-of: 23457a664ce00de33fdb6846ff31f489e6dd2177 --- .../javax/net/ssl/DTLS/DTLSOverDatagram.java | 197 ++++++------------ .../javax/net/ssl/DTLS/InvalidRecords.java | 33 ++- 2 files changed, 77 insertions(+), 153 deletions(-) diff --git a/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java b/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java index 1014cff3a5b..4a45cb2b98e 100644 --- a/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java +++ b/test/jdk/javax/net/ssl/DTLS/DTLSOverDatagram.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -33,6 +33,7 @@ * @run main/othervm DTLSOverDatagram */ +import java.io.IOException; import java.nio.*; import java.net.*; import java.util.*; @@ -42,6 +43,7 @@ import jdk.test.lib.security.SSLContextBuilder; import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicBoolean; import jdk.test.lib.hexdump.HexPrinter; @@ -50,8 +52,6 @@ */ public class DTLSOverDatagram { - private static final int MAX_HANDSHAKE_LOOPS = 200; - private static final int MAX_APP_READ_LOOPS = 60; private static final int SOCKET_TIMEOUT = 10 * 1000; // in millis private static final int BUFFER_SIZE = 1024; private static final int MAXIMUM_PACKET_SIZE = 1024; @@ -75,8 +75,9 @@ public class DTLSOverDatagram { private static final ByteBuffer CLIENT_APP = ByteBuffer.wrap("Hi Server, I'm Client".getBytes()); - private static Exception clientException = null; - private static Exception serverException = null; + private final AtomicBoolean exceptionOccurred = new AtomicBoolean(false); + + private final CountDownLatch serverStarted = new CountDownLatch(1); /* * ============================================================= * The test case @@ -148,18 +149,12 @@ void handshake(SSLEngine engine, DatagramSocket socket, SocketAddress peerAddr, String side) throws Exception { boolean endLoops = false; - int loops = MAX_HANDSHAKE_LOOPS; + int loops = 0; engine.beginHandshake(); - while (!endLoops && - (serverException == null) && (clientException == null)) { - - if (--loops < 0) { - throw new RuntimeException( - "Too many loops to produce handshake packets"); - } + while (!endLoops && !exceptionOccurred.get()) { SSLEngineResult.HandshakeStatus hs = engine.getHandshakeStatus(); - log(side, "=======handshake(" + loops + ", " + hs + ")======="); + log(side, "=======handshake(" + ++loops + ", " + hs + ")======="); switch (hs) { case NEED_UNWRAP: @@ -314,16 +309,10 @@ void deliverAppData(SSLEngine engine, DatagramSocket socket, void receiveAppData(SSLEngine engine, DatagramSocket socket, ByteBuffer expectedApp) throws Exception { - int loops = MAX_APP_READ_LOOPS; - while ((serverException == null) && (clientException == null)) { - if (--loops < 0) { - throw new RuntimeException( - "Too much loops to receive application data"); - } - + while (!exceptionOccurred.get()) { byte[] buf = new byte[BUFFER_SIZE]; - DatagramPacket packet = new DatagramPacket(buf, buf.length); - socket.receive(packet); + DatagramPacket packet = readFromSocket(socket, buf); + ByteBuffer netBuffer = ByteBuffer.wrap(buf, 0, packet.getLength()); ByteBuffer recBuffer = ByteBuffer.allocate(BUFFER_SIZE); SSLEngineResult rs = engine.unwrap(netBuffer, recBuffer); @@ -339,19 +328,31 @@ void receiveAppData(SSLEngine engine, } } + /* + Some tests failed with receive time-out errors when the client tried to read + from the server. The server thread had exited normally so the read _should_ + succeed. So let's try to read a couple of times before giving up. + */ + DatagramPacket readFromSocket(DatagramSocket socket, byte[] buffer) throws IOException { + for (int i = 1 ; i <= 2 ; ++i) { + try { + DatagramPacket packet = new DatagramPacket(buffer, buffer.length); + socket.receive(packet); + return packet; + } catch (SocketTimeoutException exc) { + System.out.println("Attempt " + i + ": Timeout occurred reading from socket."); + } + } + throw new IOException("Did not receive data after 2 attempts."); + } + // produce handshake packets boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, String side, List packets) throws Exception { boolean endLoops = false; - int loops = MAX_HANDSHAKE_LOOPS / 2; - while (!endLoops && - (serverException == null) && (clientException == null)) { - - if (--loops < 0) { - throw new RuntimeException( - "Too many loops to produce handshake packets"); - } + int loops = 0; + while (!endLoops && !exceptionOccurred.get()) { ByteBuffer oNet = ByteBuffer.allocate(32768); ByteBuffer oApp = ByteBuffer.allocate(0); @@ -361,7 +362,7 @@ boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, SSLEngineResult.Status rs = r.getStatus(); SSLEngineResult.HandshakeStatus hs = r.getHandshakeStatus(); log(side, "----produce handshake packet(" + - loops + ", " + rs + ", " + hs + ")----"); + ++loops + ", " + rs + ", " + hs + ")----"); verifySSLEngineResultStatus(r, side); @@ -521,10 +522,6 @@ SSLContext getDTLSContext() throws Exception { * The remainder is support stuff to kickstart the testing. */ - // Will the handshaking and application data exchange succeed? - public boolean isGoodJob() { - return true; - } public final void runTest(DTLSOverDatagram testCase) throws Exception { InetSocketAddress serverSocketAddress = new InetSocketAddress @@ -544,119 +541,51 @@ public final void runTest(DTLSOverDatagram testCase) throws Exception { InetSocketAddress clientSocketAddr = new InetSocketAddress( InetAddress.getLoopbackAddress(), clientSocket.getLocalPort()); - ExecutorService pool = Executors.newFixedThreadPool(2); - Future server, client; + ExecutorService pool = Executors.newFixedThreadPool(1); + Future server; - try { - server = pool.submit(new ServerCallable( + server = pool.submit(() -> runServer( testCase, serverSocket, clientSocketAddr)); - client = pool.submit(new ClientCallable( - testCase, clientSocket, serverSocketAddr)); - } finally { - pool.shutdown(); - } - - boolean failed = false; - - // wait for client to finish - try { - System.out.println("Client finished: " + client.get()); - } catch (CancellationException | InterruptedException - | ExecutionException e) { - System.out.println("Exception on client side: "); - e.printStackTrace(System.out); - failed = true; - } - - // wait for server to finish - try { - System.out.println("Client finished: " + server.get()); - } catch (CancellationException | InterruptedException - | ExecutionException e) { - System.out.println("Exception on server side: "); - e.printStackTrace(System.out); - failed = true; - } + pool.shutdown(); - if (failed) { - throw new RuntimeException("Test failed"); - } + runClient(testCase, clientSocket, serverSocketAddr); + server.get(); } } - final static class ServerCallable implements Callable { - - private final DTLSOverDatagram testCase; - private final DatagramSocket socket; - private final InetSocketAddress clientSocketAddr; + Void runServer(DTLSOverDatagram testCase, DatagramSocket socket, + InetSocketAddress clientSocketAddr) throws Exception { + try { + serverStarted.countDown(); + testCase.doServerSide(socket, clientSocketAddr); - ServerCallable(DTLSOverDatagram testCase, DatagramSocket socket, - InetSocketAddress clientSocketAddr) { + } catch (Exception exc) { + exceptionOccurred.set(true); - this.testCase = testCase; - this.socket = socket; - this.clientSocketAddr = clientSocketAddr; + // log for debugging clarity + System.out.println("Unexpected exception in server"); + exc.printStackTrace(System.err); + throw exc; } - @Override - public String call() throws Exception { - try { - testCase.doServerSide(socket, clientSocketAddr); - } catch (Exception e) { - System.out.println("Exception in ServerCallable.call():"); - e.printStackTrace(System.out); - serverException = e; - - if (testCase.isGoodJob()) { - throw e; - } else { - return "Well done, server!"; - } - } - - if (testCase.isGoodJob()) { - return "Well done, server!"; - } else { - throw new Exception("No expected exception"); - } - } + return null; } - final static class ClientCallable implements Callable { - - private final DTLSOverDatagram testCase; - private final DatagramSocket socket; - private final InetSocketAddress serverSocketAddr; - - ClientCallable(DTLSOverDatagram testCase, DatagramSocket socket, - InetSocketAddress serverSocketAddr) { - - this.testCase = testCase; - this.socket = socket; - this.serverSocketAddr = serverSocketAddr; + private void runClient(DTLSOverDatagram testCase, DatagramSocket socket, + InetSocketAddress serverSocketAddr) throws Exception { + if(!serverStarted.await(5, TimeUnit.SECONDS)) { + throw new Exception("Server did not start within 5 seconds."); } - @Override - public String call() throws Exception { - try { - testCase.doClientSide(socket, serverSocketAddr); - } catch (Exception e) { - System.out.println("Exception in ClientCallable.call():"); - e.printStackTrace(System.out); - clientException = e; - - if (testCase.isGoodJob()) { - throw e; - } else { - return "Well done, client!"; - } - } + try { + testCase.doClientSide(socket, serverSocketAddr); + } catch (Exception exc) { + exceptionOccurred.set(true); - if (testCase.isGoodJob()) { - return "Well done, client!"; - } else { - throw new Exception("No expected exception"); - } + // log for debugging clarity + System.out.println("Unexpected exception in client."); + exc.printStackTrace(System.err); + throw exc; } } diff --git a/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java b/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java index af5bdc36134..304cb0695d6 100644 --- a/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java +++ b/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -36,27 +36,32 @@ import java.net.DatagramPacket; import java.net.SocketAddress; +import java.util.concurrent.atomic.AtomicBoolean; /** - * Test that if handshake messages are crasged, the handshake would fail + * Test that if handshake messages are changed, the handshake would fail * because of handshaking hash verification. */ public class InvalidRecords extends DTLSOverDatagram { - boolean needInvalidRecords = true; + private static final AtomicBoolean needInvalidRecords = new AtomicBoolean(true); public static void main(String[] args) throws Exception { InvalidRecords testCase = new InvalidRecords(); testCase.runTest(testCase); - } - @Override - public boolean isGoodJob() { - return false; + if (needInvalidRecords.get()) { + // if this is true, the createHandshakePacket() method + // was NOT called twice to create ClientHello messages + throw new RuntimeException( + "The invalid handshake packet was not" + + " rejected as it should have been."); + } } + @Override DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) { - if ((ba.length >= 60) && + if (needInvalidRecords.get() && (ba.length >= 60) && (ba[0x00] == (byte)0x16) && (ba[0x0D] == (byte)0x01) && (ba[0x3B] == (byte)0x00) && (ba[0x3C] > 0)) { @@ -65,18 +70,8 @@ DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) { // ba[0x3B]: length of session ID // ba[0x3C]: length of cookie - if (!needInvalidRecords) { - // The 2nd ClientHello with cookie. The 1st one should be - // rejected as expected. - // - // This may happen if the last few bytes of the packet are - // for supported_version extension. - throw new RuntimeException( - "the crashed handshake message was rejected as expected"); - } - // ClientHello with cookie - needInvalidRecords = false; + needInvalidRecords.set(false); System.out.println("invalidate ClientHello message"); if (ba[ba.length - 1] == (byte)0xFF) { ba[ba.length - 1] = (byte)0xFE; From b05024a199d9653698c50b4079f7220192d00e1a Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Mon, 1 Apr 2024 01:55:44 +0000 Subject: [PATCH 063/149] 8310380: Handle problems in core-related tests on macOS when codesign tool does not work Reviewed-by: lucy Backport-of: 39c104df44f17c1d65e35becd4272f73e2c6610c --- .../sa/TestJmapCoreMetaspace.java | 4 +- ...stMutuallyExclusivePlatformPredicates.java | 4 +- test/lib/jdk/test/lib/Platform.java | 46 +++++++++++++------ test/lib/jdk/test/lib/util/CoreUtils.java | 9 +++- 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java index 3dd060be231..b8e00e53848 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCoreMetaspace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 TestJmapCoreMetaspace - * @summary Test verifies that jhsdb jmap could generate heap dump from core when metspace is full + * @summary Test verifies that jhsdb jmap could generate heap dump from core when metaspace is full * @requires vm.hasSA * @library /test/lib * @run driver/timeout=480 TestJmapCore run metaspace diff --git a/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java b/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java index 042d10ad57f..271c3fd2443 100644 --- a/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java +++ b/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -52,7 +52,7 @@ private static enum MethodGroup { MODE("isInt", "isMixed", "isComp"), IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isSlowDebugBuild", "hasSA", "isRoot", "isTieredSupported", "areCustomLoadersSupportedForCDS", - "isHardenedOSX"); + "isHardenedOSX", "hasOSXPlistEntries"); public final List methodNames; diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java index 620ddf781bf..371560956b8 100644 --- a/test/lib/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -255,28 +255,46 @@ public static boolean hasSA() { return true; } - /** - * Return true if the test JDK is hardened, otherwise false. Only valid on OSX. - */ - public static boolean isHardenedOSX() throws IOException { - // We only care about hardened binaries for 10.14 and later (actually 10.14.5, but - // for simplicity we'll also include earlier 10.14 versions). - if (getOsVersionMajor() == 10 && getOsVersionMinor() < 14) { - return false; // assume not hardened - } - - // Find the path to the java binary. + private static Process launchCodesignOnJavaBinary() throws IOException { String jdkPath = System.getProperty("java.home"); Path javaPath = Paths.get(jdkPath + "/bin/java"); String javaFileName = javaPath.toAbsolutePath().toString(); if (!javaPath.toFile().exists()) { throw new FileNotFoundException("Could not find file " + javaFileName); } - - // Run codesign on the java binary. ProcessBuilder pb = new ProcessBuilder("codesign", "--display", "--verbose", javaFileName); pb.redirectErrorStream(true); // redirect stderr to stdout Process codesignProcess = pb.start(); + return codesignProcess; + } + + public static boolean hasOSXPlistEntries() throws IOException { + Process codesignProcess = launchCodesignOnJavaBinary(); + BufferedReader is = new BufferedReader(new InputStreamReader(codesignProcess.getInputStream())); + String line; + while ((line = is.readLine()) != null) { + System.out.println("STDOUT: " + line); + if (line.indexOf("Info.plist=not bound") != -1) { + return false; + } + if (line.indexOf("Info.plist entries=") != -1) { + return true; + } + } + System.out.println("No matching Info.plist entry was found"); + return false; + } + + /** + * Return true if the test JDK is hardened, otherwise false. Only valid on OSX. + */ + public static boolean isHardenedOSX() throws IOException { + // We only care about hardened binaries for 10.14 and later (actually 10.14.5, but + // for simplicity we'll also include earlier 10.14 versions). + if (getOsVersionMajor() == 10 && getOsVersionMinor() < 14) { + return false; // assume not hardened + } + Process codesignProcess = launchCodesignOnJavaBinary(); BufferedReader is = new BufferedReader(new InputStreamReader(codesignProcess.getInputStream())); String line; boolean isHardened = false; diff --git a/test/lib/jdk/test/lib/util/CoreUtils.java b/test/lib/jdk/test/lib/util/CoreUtils.java index 6675c30973c..100b19e61f6 100644 --- a/test/lib/jdk/test/lib/util/CoreUtils.java +++ b/test/lib/jdk/test/lib/util/CoreUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, 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 @@ -110,6 +110,8 @@ public static String getCoreFileLocation(String crashOutputString) throws IOExce Asserts.assertGT(new File(coreFileLocation).length(), 0L, "Unexpected core size"); System.out.println("Found core file: " + coreFileLocation); return coreFileLocation; // success! + } else { + System.out.println("Core file not found. Trying to find a reason why..."); } // See if we can figure out the likely reason the core file was not found. @@ -130,6 +132,11 @@ public static String getCoreFileLocation(String crashOutputString) throws IOExce // We can't generate cores files with hardened binaries on OSX 10.15 and later. throw new SkippedException("Cannot produce core file with hardened binary on OSX 10.15 and later"); } + } else { + // codesign has to add entitlements using the plist. If this is not present we might not generate a core file. + if (!Platform.hasOSXPlistEntries()) { + throw new SkippedException("Cannot produce core file with binary having no plist entitlement entries"); + } } } else if (Platform.isLinux()) { // Check if a crash report tool is installed. From d27c9ba7c8aebce090e9098efa3575223c6aaf02 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Mon, 1 Apr 2024 01:56:53 +0000 Subject: [PATCH 064/149] 8328812: Update and move siphash license Backport-of: ce7ebaa606f96fdfee66d300b56022d9903b5ae3 --- src/{hotspot => java.base}/share/legal/siphash.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename src/{hotspot => java.base}/share/legal/siphash.md (98%) diff --git a/src/hotspot/share/legal/siphash.md b/src/java.base/share/legal/siphash.md similarity index 98% rename from src/hotspot/share/legal/siphash.md rename to src/java.base/share/legal/siphash.md index 1583f229e1e..a1183acf2b0 100644 --- a/src/hotspot/share/legal/siphash.md +++ b/src/java.base/share/legal/siphash.md @@ -4,12 +4,12 @@ SipHash reference C implementation ``` - Copyright (c) 2012-2021 Jean-Philippe Aumasson - - Copyright (c) 2012-2014 Daniel J. Bernstein + Copyright (c) 2016 Jean-Philippe Aumasson + To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. + You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see From e922114fa71cc7234f7ac067f191522cb5b0187f Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 1 Apr 2024 16:26:32 +0000 Subject: [PATCH 065/149] 8280546: Remove hard-coded 127.0.0.1 loopback address Backport-of: b5de2cc9d36e1fad7d0bf70f7c83ff829e16b7f3 --- test/jdk/javax/net/ssl/TLS/TestJSSE.java | 3 ++- test/jdk/javax/net/ssl/sanity/interop/JSSEClient.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/jdk/javax/net/ssl/TLS/TestJSSE.java b/test/jdk/javax/net/ssl/TLS/TestJSSE.java index 2c5a2c6274d..29631064011 100644 --- a/test/jdk/javax/net/ssl/TLS/TestJSSE.java +++ b/test/jdk/javax/net/ssl/TLS/TestJSSE.java @@ -21,12 +21,13 @@ * questions. */ +import java.net.InetAddress; import java.security.Provider; import java.security.Security; public class TestJSSE { - private static final String LOCAL_IP = "127.0.0.1"; + private static final String LOCAL_IP = InetAddress.getLoopbackAddress().getHostAddress(); public static void main(String... args) throws Exception { // reset the security property to make sure that the algorithms diff --git a/test/jdk/javax/net/ssl/sanity/interop/JSSEClient.java b/test/jdk/javax/net/ssl/sanity/interop/JSSEClient.java index 2207749302d..21416f0aaef 100644 --- a/test/jdk/javax/net/ssl/sanity/interop/JSSEClient.java +++ b/test/jdk/javax/net/ssl/sanity/interop/JSSEClient.java @@ -23,6 +23,7 @@ import java.io.InputStream; import java.io.OutputStream; +import java.net.InetAddress; import java.security.cert.Certificate; import javax.net.ssl.KeyManager; @@ -52,7 +53,8 @@ void runTest(CipherTest.TestParameters params) throws Exception { new TrustManager[] { CipherTest.trustManager }, CipherTest.secureRandom); SSLSocketFactory factory = (SSLSocketFactory)sslContext.getSocketFactory(); - socket = (SSLSocket)factory.createSocket("127.0.0.1", CipherTest.serverPort); + socket = (SSLSocket)factory.createSocket( + InetAddress.getLoopbackAddress().getHostAddress(), CipherTest.serverPort); socket.setSoTimeout(CipherTest.TIMEOUT); socket.setEnabledCipherSuites(new String[] { params.cipherSuite.name() }); socket.setEnabledProtocols(new String[] { params.protocol.name }); From fa8f02ece8aff872f1d67b9401a71949f3aa7407 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 2 Apr 2024 04:37:18 +0000 Subject: [PATCH 066/149] 8318727: Enable parallelism in vmTestbase/vm/gc/concurrent tests Backport-of: 29d462a07239a57b83850b9a8662573291fdbdf7 --- .../lp30yp0rp0mr30st300/TEST.properties | 23 ------------------- .../lp30yp0rp0mr70st300t1/TEST.properties | 23 ------------------- .../lp30yp0rp30mr0st300/TEST.properties | 23 ------------------- .../lp30yp0rp30mr30st0t1/TEST.properties | 23 ------------------- .../lp30yp0rp30mr70st0/TEST.properties | 23 ------------------- .../lp30yp0rp30mr70st300t1/TEST.properties | 23 ------------------- .../lp30yp0rp70mr30st0/TEST.properties | 23 ------------------- .../lp30yp0rp70mr30st300t1/TEST.properties | 23 ------------------- .../lp30yp10rp0mr30st300/TEST.properties | 23 ------------------- .../lp30yp10rp0mr70st300t1/TEST.properties | 23 ------------------- .../lp30yp10rp30mr0st300/TEST.properties | 23 ------------------- .../lp30yp10rp30mr30st0t1/TEST.properties | 23 ------------------- .../lp30yp10rp30mr70st0/TEST.properties | 23 ------------------- .../lp30yp10rp30mr70st300t1/TEST.properties | 23 ------------------- .../lp30yp10rp70mr30st0/TEST.properties | 23 ------------------- .../lp30yp10rp70mr30st300t1/TEST.properties | 23 ------------------- .../lp30yp25rp0mr30st300/TEST.properties | 23 ------------------- .../lp30yp25rp0mr70st300t1/TEST.properties | 23 ------------------- .../lp30yp25rp30mr0st300/TEST.properties | 23 ------------------- .../lp30yp25rp30mr30st0t1/TEST.properties | 23 ------------------- .../lp30yp25rp30mr70st0/TEST.properties | 23 ------------------- .../lp30yp25rp30mr70st300t1/TEST.properties | 23 ------------------- .../lp30yp25rp70mr30st0/TEST.properties | 23 ------------------- .../lp30yp25rp70mr30st300t1/TEST.properties | 23 ------------------- .../lp50yp0rp0mr30st300/TEST.properties | 23 ------------------- .../lp50yp0rp0mr70st300t1/TEST.properties | 23 ------------------- .../lp50yp0rp30mr0st300/TEST.properties | 23 ------------------- .../lp50yp0rp30mr30st0t1/TEST.properties | 23 ------------------- .../lp50yp0rp30mr70st0/TEST.properties | 23 ------------------- .../lp50yp0rp30mr70st300t1/TEST.properties | 23 ------------------- .../lp50yp0rp70mr30st0/TEST.properties | 23 ------------------- .../lp50yp0rp70mr30st300t1/TEST.properties | 23 ------------------- .../lp50yp10rp0mr30st300/TEST.properties | 23 ------------------- .../lp50yp10rp0mr70st300t1/TEST.properties | 23 ------------------- .../lp50yp10rp30mr0st300/TEST.properties | 23 ------------------- .../lp50yp10rp30mr30st0t1/TEST.properties | 23 ------------------- .../lp50yp10rp30mr70st0/TEST.properties | 23 ------------------- .../lp50yp10rp30mr70st300t1/TEST.properties | 23 ------------------- .../lp50yp10rp70mr30st0/TEST.properties | 23 ------------------- .../lp50yp10rp70mr30st300t1/TEST.properties | 23 ------------------- .../lp60yp0rp30mr0st300/TEST.properties | 23 ------------------- 41 files changed, 943 deletions(-) delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp0mr30st300/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp0mr70st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr0st300/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr30st0t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr70st0/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr70st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp70mr30st0/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp70mr30st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp0mr30st300/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp0mr70st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr0st300/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr30st0t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr70st0/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr70st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp70mr30st0/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp70mr30st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp0mr30st300/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp0mr70st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr0st300/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr30st0t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr70st0/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr70st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp70mr30st0/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp70mr30st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp0mr30st300/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp0mr70st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr0st300/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr30st0t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr70st0/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr70st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp70mr30st0/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp70mr30st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp0mr30st300/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp0mr70st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr0st300/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr30st0t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr70st0/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr70st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp70mr30st0/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp70mr30st300t1/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp60yp0rp30mr0st300/TEST.properties diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp0mr30st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp0mr30st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp0mr30st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp0mr70st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp0mr70st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp0mr70st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr0st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr0st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr0st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr30st0t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr30st0t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr30st0t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr70st0/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr70st0/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr70st0/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr70st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr70st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp30mr70st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp70mr30st0/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp70mr30st0/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp70mr30st0/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp70mr30st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp70mr30st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp0rp70mr30st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp0mr30st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp0mr30st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp0mr30st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp0mr70st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp0mr70st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp0mr70st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr0st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr0st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr0st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr30st0t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr30st0t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr30st0t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr70st0/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr70st0/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr70st0/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr70st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr70st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp30mr70st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp70mr30st0/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp70mr30st0/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp70mr30st0/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp70mr30st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp70mr30st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp10rp70mr30st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp0mr30st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp0mr30st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp0mr30st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp0mr70st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp0mr70st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp0mr70st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr0st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr0st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr0st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr30st0t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr30st0t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr30st0t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr70st0/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr70st0/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr70st0/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr70st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr70st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp30mr70st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp70mr30st0/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp70mr30st0/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp70mr30st0/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp70mr30st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp70mr30st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp30yp25rp70mr30st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp0mr30st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp0mr30st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp0mr30st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp0mr70st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp0mr70st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp0mr70st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr0st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr0st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr0st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr30st0t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr30st0t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr30st0t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr70st0/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr70st0/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr70st0/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr70st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr70st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp30mr70st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp70mr30st0/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp70mr30st0/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp70mr30st0/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp70mr30st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp70mr30st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp0rp70mr30st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp0mr30st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp0mr30st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp0mr30st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp0mr70st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp0mr70st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp0mr70st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr0st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr0st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr0st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr30st0t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr30st0t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr30st0t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr70st0/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr70st0/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr70st0/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr70st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr70st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp30mr70st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp70mr30st0/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp70mr30st0/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp70mr30st0/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp70mr30st300t1/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp70mr30st300t1/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp50yp10rp70mr30st300t1/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp60yp0rp30mr0st300/TEST.properties b/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp60yp0rp30mr0st300/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/gc/concurrent/lp60yp0rp30mr0st300/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. From 8e46e3714e3230db2d8f027b016fe186c07037d6 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 2 Apr 2024 04:37:41 +0000 Subject: [PATCH 067/149] 8305942: Open source several AWT Focus related tests Backport-of: 8346ae2bc1152f13bc77c643252d84e2043ffe0b --- test/jdk/java/awt/Focus/QuickTypeTest.java | 215 +++++++++++++++++ .../Focus/RowToleranceTransitivityTest.java | 220 ++++++++++++++++++ .../Focus/TemporaryLostComponentDeadlock.java | 74 ++++++ .../Focus/TraversalKeysPropertyNamesTest.java | 112 +++++++++ test/jdk/java/awt/Focus/UpFocusCycleTest.java | 95 ++++++++ .../Focus/VetoableChangeListenerLoopTest.java | 115 +++++++++ 6 files changed, 831 insertions(+) create mode 100644 test/jdk/java/awt/Focus/QuickTypeTest.java create mode 100644 test/jdk/java/awt/Focus/RowToleranceTransitivityTest.java create mode 100644 test/jdk/java/awt/Focus/TemporaryLostComponentDeadlock.java create mode 100644 test/jdk/java/awt/Focus/TraversalKeysPropertyNamesTest.java create mode 100644 test/jdk/java/awt/Focus/UpFocusCycleTest.java create mode 100644 test/jdk/java/awt/Focus/VetoableChangeListenerLoopTest.java diff --git a/test/jdk/java/awt/Focus/QuickTypeTest.java b/test/jdk/java/awt/Focus/QuickTypeTest.java new file mode 100644 index 00000000000..0cfd0ef5f1d --- /dev/null +++ b/test/jdk/java/awt/Focus/QuickTypeTest.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ +/* + @test + @bug 4423838 + @summary KEY_TYPED and KEY_PRESSED generated by the same key are notified to + different TextFields + @key headful + @run main QuickTypeTest +*/ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextArea; +import java.awt.EventQueue; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +import java.util.Properties; + +import javax.swing.JFrame; +import javax.swing.JTextField; + +public class QuickTypeTest { + static final int TEST_TIMEOUT=10000; + static JFrame frame1; + static JFrame frame2; + static JTextField tf1; + static JTextField tf2; + static SmartKeyAdapter ska; + static Object keyMonitor; + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(() -> { + frame1 = new JFrame("First Frame"); + frame2 = new JFrame("Second Frame"); + tf1 = new JTextField("", 10); + tf2 = new JTextField("", 10); + frame1.getContentPane().add(tf1); + frame2.getContentPane().add(tf2); + frame1.setLocation(200,220); + frame2.setLocation(220,300); + frame1.pack(); + frame2.pack(); + keyMonitor = new Object(); + ska = new SmartKeyAdapter(frame2, keyMonitor); + tf1.addKeyListener(ska); + frame1.setVisible(true); + }); + + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(100); + robot.waitForIdle(); + robot.delay(1000); + Object tf1Monitor = new Object(); + MonitoredFocusListener monitorer = new MonitoredFocusListener(tf1Monitor); + tf1.addFocusListener(monitorer); + Point origin = tf1.getLocationOnScreen(); + Dimension dim = tf1.getSize(); + robot.mouseMove((int)origin.getX() + (int)dim.getWidth()/2, + (int)origin.getY() + (int)dim.getHeight()/2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + if (!tf1.isFocusOwner()) { + synchronized (tf1Monitor) { + tf1Monitor.wait(TEST_TIMEOUT); + } + } + if (!tf1.isFocusOwner()) { + throw new RuntimeException("TEST FAILED. tf1 doesn't receive focus."); + } + + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.keyPress(KeyEvent.VK_B); + robot.keyRelease(KeyEvent.VK_B); + if (!ska.isFrameShown) { + synchronized (keyMonitor) { + keyMonitor.wait(TEST_TIMEOUT); + } + } + if (!ska.isFrameShown) { + throw new RuntimeException("TEST FAILED. Second frame is not shown."); + } + + Object waitMonitor = new Object(); + ReleaseWaiter waiter = new ReleaseWaiter(waitMonitor, KeyEvent.VK_C); + tf1.addKeyListener(waiter); + tf2.addKeyListener(waiter); + robot.keyPress(KeyEvent.VK_C); + robot.keyRelease(KeyEvent.VK_C); + + synchronized (waitMonitor) { + waitMonitor.wait(2000); + } + + if ((tf1.getText().length() > 2) || (tf2.getText().length() < 1)) { + System.out.println("tf1's text = \"" + tf1.getText() + "\""); + System.out.println("tf2's text = \"" + tf2.getText() + "\""); + System.out.println("l1 = " + tf1.getText().length()); + System.out.println("l2 = " + tf2.getText().length()); + throw new RuntimeException("TEST FAILED."); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (frame1 != null) { + frame1.dispose(); + } + if (frame2 != null) { + frame2.dispose(); + } + }); + } + } + + }// class QuickTypeTest + +class ReleaseWaiter extends KeyAdapter { + Object monitor; + int keycode; + public ReleaseWaiter(Object monitor, int keycode) { + this.monitor = monitor; + this.keycode = keycode; + } + + public void keyReleased(KeyEvent ke) { + System.out.println("keyReleased " + ke.getKeyCode()); + if (ke.getKeyCode() == keycode) { + synchronized (monitor) { + monitor.notify(); + } + } + } +} + +class SmartKeyAdapter implements KeyListener { + JFrame frame; + int charCounter = 0; + boolean isFrameShown = false; + Object monitor; + + public SmartKeyAdapter(JFrame frame, Object monitor) { + this.frame = frame; + this.monitor = monitor; + } + + public void keyReleased(KeyEvent ke) { + System.out.println(ke.toString()); + } + public void keyPressed(KeyEvent ke) { + System.out.println(ke.toString()); + charCounter++; + if (charCounter == 2) { + frame.setVisible(true); + isFrameShown = true; + synchronized (monitor) { + monitor.notify(); + } + } + } + public void keyTyped(KeyEvent ke) { + System.out.println(ke.toString()); + } +} + +class MonitoredFocusListener extends FocusAdapter { + Object monitor; + + public MonitoredFocusListener(Object monitor) { + this.monitor = monitor; + } + + public void focusLost(FocusEvent fe) { + System.out.println(fe.toString()); + } + public void focusGained(FocusEvent fe) { + System.out.println(fe.toString()); + synchronized (monitor) { + monitor.notify(); + } + } +} diff --git a/test/jdk/java/awt/Focus/RowToleranceTransitivityTest.java b/test/jdk/java/awt/Focus/RowToleranceTransitivityTest.java new file mode 100644 index 00000000000..099e81a1ab0 --- /dev/null +++ b/test/jdk/java/awt/Focus/RowToleranceTransitivityTest.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2005, 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. + * + * 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. + */ + +/* + @test + @bug 5070991 + @key headful + @summary Tests for a transitivity problem with ROW_TOLERANCE in SortingFTP. + @run main RowToleranceTransitivityTest +*/ +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.KeyboardFocusManager; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import javax.swing.JCheckBox; +import javax.swing.JFrame; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.JPanel; +import java.util.concurrent.atomic.AtomicBoolean; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.atomic.AtomicBoolean; + +public class RowToleranceTransitivityTest { + static JFrame frame; + static JPanel panel; + static JFormattedTextField ft; + static JCheckBox cb; + static GridBagConstraints gc; + static Robot robot; + + static AtomicBoolean focusGained = new AtomicBoolean(false); + + public static void main(String[] args) throws Exception { + robot = new Robot(); + robot.setAutoDelay(100); + robot.setAutoWaitForIdle(true); + try { + EventQueue.invokeAndWait(() -> { + gc = new GridBagConstraints(); + frame = new JFrame("JFrame"); + JPanel panel = new JPanel(new GridBagLayout()); + ft = new JFormattedTextField(); + cb = new JCheckBox("JCheckBox"); + Dimension dim = new Dimension(100, ft.getPreferredSize().height); + ft.setPreferredSize(dim); + ft.setMinimumSize(dim); + gc.gridx = 5; + gc.gridy = 1; + gc.gridwidth = 10; + panel.add(ft, gc); + + gc.gridy = 3; + panel.add(cb, gc); + + cb.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + System.out.println(e.toString()); + synchronized (focusGained) { + focusGained.set(true); + focusGained.notifyAll(); + } + } + }); + + gc.weightx = 1.0; + gc.gridwidth = 1; + gc.gridy = 0; + gc.gridx = 0; + for (int n = 0; n < 7; n++) { + panel.add(getlabel(), gc); + gc.gridy++; + } + + gc.gridx = 0; + gc.gridy = 0; + for (int n = 0; n < 7; n++) { + panel.add(getlabel(), gc); + gc.gridx++; + } + + frame.getContentPane().add(panel); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frame.setAlwaysOnTop(true); + + }); + robot.waitForIdle(); + robot.delay(1000); + test(); + } finally { + if (frame != null) { + frame.dispose(); + } + } + } + + static void test() throws Exception { + robot.delay(500); + + // Set focus on the first component to start traversal + if (!setFocusOn(ft, new Runnable() { + public void run() { + clickOn(ft); + } + })) { + System.out.println("Couldn't set focus on " + ft); + throw new RuntimeException("Test couldn't be performed."); + } + + robot.delay(500); + + // Try to traverse + if (!setFocusOn(cb, new Runnable() { + public void run() { + robot.keyPress(KeyEvent.VK_TAB); + } + })) { + System.out.println("Focus got stuck while traversing."); + throw new RuntimeException("Test failed!"); + } + + System.out.println("Test passed."); + } + + static boolean setFocusOn(Component comp, Runnable action) { + + if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == comp) { + System.out.println("Already focus owner: " + comp); + return true; + } + + focusGained.set(false); + + System.out.println("Setting focus on " + comp); + + comp.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + System.out.println(e.toString()); + synchronized (focusGained) { + focusGained.set(true); + focusGained.notifyAll(); + } + } + }); + + action.run(); + + synchronized (focusGained) { + if (!focusGained.get()) { + try { + focusGained.wait(3000); + } catch (InterruptedException e) { + System.out.println("Unexpected exception caught!"); + throw new RuntimeException(e); + } + } + } + + return focusGained.get(); + } + + static JLabel getlabel(){ + Dimension dim = new Dimension(5, 9); // LayoutComparator.ROW_TOLERANCE = 10; + JLabel l = new JLabel("*"); + l.setMinimumSize(dim); + l.setMaximumSize(dim); + l.setPreferredSize(dim); + return l; + } + + static void clickOn(Component c) { + Point p = c.getLocationOnScreen(); + Dimension d = c.getSize(); + + System.out.println("Clicking " + c); + + if (c instanceof Frame) { + robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + ((Frame)c).getInsets().top/2); + } else { + robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2)); + } + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + } + +} diff --git a/test/jdk/java/awt/Focus/TemporaryLostComponentDeadlock.java b/test/jdk/java/awt/Focus/TemporaryLostComponentDeadlock.java new file mode 100644 index 00000000000..e14492ecf16 --- /dev/null +++ b/test/jdk/java/awt/Focus/TemporaryLostComponentDeadlock.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4794413 + * @summary Tests that access to temporaryLostComponent from two different threads doesn't cause a deadlock + * @key headful + * @run main TemporaryLostComponentDeadlock +*/ +import java.awt.Button; +import java.awt.Dialog; +import java.awt.EventQueue; +import java.awt.Frame; + +public class TemporaryLostComponentDeadlock { + static Dialog frame1; + static Frame frame; + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> { + frame = new Frame("frame"); + frame1 = new Dialog(frame, "Frame 1", false); + frame1.add(new Button("focus owner")); + frame1.pack(); + frame1.setLocationRelativeTo(null); + frame1.setVisible(true); + }); + + Thread t1 = new Thread() { + public void run() { + synchronized(frame1) { + frame1.dispose(); + synchronized(frame1) { + frame1.notify(); + } + } + } + }; + try { + synchronized(frame1) { + t1.start(); + frame1.wait(); + } + } catch( InterruptedException ie) { + } finally { + if (frame != null) { + frame.dispose(); + } + } + System.out.println("Test PASSED"); + } + +}// class TemporaryLostComponentDeadlock diff --git a/test/jdk/java/awt/Focus/TraversalKeysPropertyNamesTest.java b/test/jdk/java/awt/Focus/TraversalKeysPropertyNamesTest.java new file mode 100644 index 00000000000..aec724e457d --- /dev/null +++ b/test/jdk/java/awt/Focus/TraversalKeysPropertyNamesTest.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2001, 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. + * + * 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. + */ + +/* + @test + @bug 4457455 + @summary Component and KeyboardFocusManager use wrong names of the properties + @run main TraversalKeysPropertyNamesTest +*/ + +import java.awt.AWTKeyStroke; +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.EventQueue; +import java.awt.KeyboardFocusManager; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.HashSet; + +public class TraversalKeysPropertyNamesTest implements PropertyChangeListener { + final String[] properties = { + "forwardDefaultFocusTraversalKeys", + "backwardDefaultFocusTraversalKeys", + "upCycleDefaultFocusTraversalKeys", + "downCycleDefaultFocusTraversalKeys", + "forwardFocusTraversalKeys", + "backwardFocusTraversalKeys", + "upCycleFocusTraversalKeys", + "downCycleFocusTraversalKeys" + }; + final int PROPERTIES_COUNT = properties.length; + boolean[] flags = new boolean[PROPERTIES_COUNT]; + + public static void main(String[] args) throws Exception { + TraversalKeysPropertyNamesTest test = new TraversalKeysPropertyNamesTest(); + test.start(); + } + + public void start() throws Exception { + EventQueue.invokeAndWait(() -> { + Container cont = new Container() {}; + HashSet forwardKeys = new HashSet(); + forwardKeys.add(AWTKeyStroke.getAWTKeyStroke("ctrl A")); + HashSet backwardKeys = new HashSet(); + backwardKeys.add(AWTKeyStroke.getAWTKeyStroke("ctrl B")); + HashSet upKeys = new HashSet(); + upKeys.add(AWTKeyStroke.getAWTKeyStroke("ctrl C")); + HashSet downKeys = new HashSet(); + downKeys.add(AWTKeyStroke.getAWTKeyStroke("ctrl D")); + + KeyboardFocusManager manager = + KeyboardFocusManager.getCurrentKeyboardFocusManager(); + manager.addPropertyChangeListener(this); + manager.setDefaultFocusTraversalKeys( + KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardKeys); + manager.setDefaultFocusTraversalKeys( + KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys); + manager.setDefaultFocusTraversalKeys( + KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS, downKeys); + manager.setDefaultFocusTraversalKeys( + KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, upKeys); + + cont.addPropertyChangeListener(this); + cont.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardKeys); + cont.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys); + cont.setFocusTraversalKeys(KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS, downKeys); + cont.setFocusTraversalKeys(KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, upKeys); + + for (int i = 0; i < PROPERTIES_COUNT; i++) { + if (!flags[i]) { + throw new RuntimeException( + "Notification on "+properties[i]+" change was not received"); + } + } + }); + }// start() + + public void propertyChange(PropertyChangeEvent pce) { + String property = pce.getPropertyName(); + System.err.println(property); + int index; + for (index = 0; index < PROPERTIES_COUNT; index++) { + if (property.equals(properties[index])) { + break; + } + } + + if (index < PROPERTIES_COUNT) { + flags[index] = true; + } + } + }// class TraversalKeysPropertyNamesTest diff --git a/test/jdk/java/awt/Focus/UpFocusCycleTest.java b/test/jdk/java/awt/Focus/UpFocusCycleTest.java new file mode 100644 index 00000000000..2c421ffe822 --- /dev/null +++ b/test/jdk/java/awt/Focus/UpFocusCycleTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2001, 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. + * + * 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. + */ + +/* + @test + @bug 4394789 + @summary KeyboardFocusManager.upFocusCycle is not working for Swing properly + @key headful + @run main UpFocusCycleTest +*/ +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Color; +import java.awt.DefaultKeyboardFocusManager; +import java.awt.EventQueue; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.Robot; +import javax.swing.DefaultFocusManager; +import javax.swing.JButton; +import javax.swing.JFrame; + +public class UpFocusCycleTest { + static boolean isFailed = true; + static Object sema = new Object(); + static JFrame frame; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + EventQueue.invokeAndWait(() -> { + + frame = new JFrame("Test frame"); + + Container container1 = frame.getContentPane(); + container1.setBackground(Color.yellow); + + JButton button = new JButton("Button"); + button.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent fe) { + DefaultKeyboardFocusManager manager = new DefaultFocusManager(); + manager.upFocusCycle(button); + System.out.println("Button receive focus"); + frame.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent fe) { + System.out.println("Frame receive focus"); + synchronized (sema) { + isFailed = false; + sema.notifyAll(); + } + } + }); + } + }); + container1.add(button,BorderLayout.WEST); + button.requestFocus(); + frame.setSize(300,300); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + if (isFailed) { + System.out.println("Test FAILED"); + throw new RuntimeException("Test FAILED"); + } else { + System.out.println("Test PASSED"); + } + } finally { + if (frame != null) { + frame.dispose(); + } + } + } + }// class UpFocusCycleTest diff --git a/test/jdk/java/awt/Focus/VetoableChangeListenerLoopTest.java b/test/jdk/java/awt/Focus/VetoableChangeListenerLoopTest.java new file mode 100644 index 00000000000..b6449b16dbc --- /dev/null +++ b/test/jdk/java/awt/Focus/VetoableChangeListenerLoopTest.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2004, 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. + * + * 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. + */ + +/* + @test + @bug 5074189 + @summary Tests that VetoableChangeListener doesn't initiate infinite loop. + @key headful + @run main VetoableChangeListenerLoopTest +*/ +import java.awt.AWTEvent; +import java.awt.Button; +import java.awt.Component; +import java.awt.EventQueue; +import java.awt.KeyboardFocusManager; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.AWTEventListener; +import java.awt.event.FocusEvent; +import java.awt.event.WindowEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; + +public class VetoableChangeListenerLoopTest { + static Button b1; + static Button b2; + static Frame frame; + static Robot robot; + + static int counter = 0; + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + EventQueue.invokeAndWait(() -> { + KeyboardFocusManager.getCurrentKeyboardFocusManager(). + addVetoableChangeListener(new VetoableChangeListener () { + public void vetoableChange(PropertyChangeEvent evt) + throws PropertyVetoException { + if (b1.equals(evt.getNewValue())) { + System.out.println("VETOING: " + (counter++)); + if (counter > 2) { + throw new RuntimeException("Test failed!"); + } + throw new PropertyVetoException("Change in property", evt); + } + } + }); + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + public void eventDispatched(AWTEvent e) { + System.out.println(e.toString()); + } + }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK); + + b1 = new Button("Button 1"); + b2 = new Button("Button 2"); + Frame frame = new Frame(); + frame.add(b1); + frame.add(b2); + frame.setSize(200, 100); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + + robot.delay(1000); + test(); + } finally { + if (frame != null) { + frame.dispose(); + } + } + } + + static void test() { + b2.requestFocusInWindow(); + waitTillFocus(b2); + b2.setVisible(false); + } + + + static void waitTillFocus(Component comp) { + while (!checkFocusOwner(comp)) { + robot.delay(100); + } + } + + static boolean checkFocusOwner(Component comp) { + return (comp == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()); + } +} From 1bbf93c51e89ee5563140ea8623b6b1bfe9e4bb5 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 2 Apr 2024 04:38:53 +0000 Subject: [PATCH 068/149] 8305943: Open source few AWT Focus related tests Backport-of: 64ed816ad9f1a9773c9865a013e89b709a130e9c --- .../java/awt/Focus/NoFocusOwnerAWTTest.java | 133 +++++++++++++ .../java/awt/Focus/NoFocusOwnerSwingTest.java | 100 ++++++++++ .../Focus/RestoreFocusInfiniteLoopTest.java | 180 ++++++++++++++++++ .../SequencedLightweightRequestsTest.java | 173 +++++++++++++++++ test/jdk/java/awt/Focus/SetFocusableTest.java | 179 +++++++++++++++++ 5 files changed, 765 insertions(+) create mode 100644 test/jdk/java/awt/Focus/NoFocusOwnerAWTTest.java create mode 100644 test/jdk/java/awt/Focus/NoFocusOwnerSwingTest.java create mode 100644 test/jdk/java/awt/Focus/RestoreFocusInfiniteLoopTest.java create mode 100644 test/jdk/java/awt/Focus/SequencedLightweightRequestsTest.java create mode 100644 test/jdk/java/awt/Focus/SetFocusableTest.java diff --git a/test/jdk/java/awt/Focus/NoFocusOwnerAWTTest.java b/test/jdk/java/awt/Focus/NoFocusOwnerAWTTest.java new file mode 100644 index 00000000000..953c392e79f --- /dev/null +++ b/test/jdk/java/awt/Focus/NoFocusOwnerAWTTest.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2001, 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. + * + * 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. + */ +/* + @test + @bug 4390019 + @summary REGRESSION: Alt-F4 keybinding no longer shuts down java application on Windows + @key headful + @requires (os.family == "windows") + @run main NoFocusOwnerAWTTest +*/ +import java.awt.Frame; +import java.awt.BorderLayout; +import java.awt.EventQueue; +import java.awt.Label; +import java.awt.MenuBar; +import java.awt.Menu; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyEvent; +import java.awt.event.WindowEvent; +import java.awt.event.WindowAdapter; + +public class NoFocusOwnerAWTTest { + + static boolean actionFired = false; + static boolean closingWindowCalled = false; + static Frame frame; + + public static void main(String[] args) throws Exception { + try { + if (!System.getProperty("os.name").startsWith("Windows")) { + // this test is Win32 test only + return; + } + EventQueue.invokeAndWait(() -> { + + frame = new Frame("No Focus Owner AWT Test"); + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.out.println("windowClosing() is called."); + closingWindowCalled = true; + } + }); + frame.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent fe) { + System.out.println("focus gained on frame"); + } + public void focusLost(FocusEvent fe) { + System.out.println("focus lost on frame"); + } + }); + MenuBar mb = new MenuBar(); + Menu m = new Menu("This is Menu"); + MenuItem mi = new MenuItem("Menu Item"); + mi.setShortcut(new MenuShortcut(KeyEvent.VK_A)); + mi.addActionListener( new ActionListener() { + public void actionPerformed(ActionEvent ae) { + System.out.println("action"); + actionFired = true; + } + }); + m.add(mi); + mb.add(m); + frame.setMenuBar(mb); + Label lb; + frame.add(lb = new Label("press")); + lb.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent fe) { + System.out.println("focus gained on label"); + } + public void focusLost(FocusEvent fe) { + System.out.println("focus lost on label"); + } + }); + frame.pack(); + frame.toFront(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + + Robot robot = new Robot(); + robot.setAutoDelay(100); + robot.delay(1000); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyPress(KeyEvent.VK_A); + robot.waitForIdle(); + robot.keyRelease(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_ALT); + robot.keyPress(KeyEvent.VK_F4); + robot.waitForIdle(); + robot.keyRelease(KeyEvent.VK_F4); + robot.keyRelease(KeyEvent.VK_ALT); + robot.waitForIdle(); + robot.delay(1000); + + if (!actionFired || !closingWindowCalled) { + throw new RuntimeException("Test FAILED(actionFired="+actionFired+ + ";closingWindowCalled="+closingWindowCalled+")"); + } + } finally { + if (frame != null) { + frame.dispose(); + } + } + } + }// class NoFocusOwnerAWTTest diff --git a/test/jdk/java/awt/Focus/NoFocusOwnerSwingTest.java b/test/jdk/java/awt/Focus/NoFocusOwnerSwingTest.java new file mode 100644 index 00000000000..23c898ae823 --- /dev/null +++ b/test/jdk/java/awt/Focus/NoFocusOwnerSwingTest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2001, 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. + * + * 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. + */ +/* + @test + @bug 4390019 + @summary REGRESSION: Alt-F4 keybinding no longer shuts down java application on Windows + @key headful + @requires (os.family == "windows") + @run main NoFocusOwnerSwingTest +*/ + +import java.awt.BorderLayout; +import java.awt.EventQueue; +import java.awt.Label; +import java.awt.MenuBar; +import java.awt.Menu; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyEvent; +import java.awt.event.WindowEvent; +import java.awt.event.WindowAdapter; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class NoFocusOwnerSwingTest { + static boolean closingWindowCalled = false; + static JFrame frame; + + public static void main(String[] args) throws Exception { + try { + if (!System.getProperty("os.name").startsWith("Windows")) { + // this test is Win32 test only + return; + } + + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("No Focus Owner Swing Test"); + JButton btn; + frame.getContentPane().add(btn = new JButton("press")); + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.out.println("windowClosing is called"); + closingWindowCalled = true; + } + }); + frame.pack(); + frame.toFront(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + + Robot robot = new Robot(); + robot.setAutoDelay(100); + robot.delay(1000); + robot.keyPress(KeyEvent.VK_ALT); + robot.keyPress(KeyEvent.VK_F4); + robot.waitForIdle(); + robot.keyRelease(KeyEvent.VK_F4); + robot.keyRelease(KeyEvent.VK_ALT); + robot.waitForIdle(); + + if (!closingWindowCalled) { + throw new RuntimeException("Test FAILED(closingWindowCalled=" + + closingWindowCalled + ")"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +}// class NoFocusOwnerSwingTest diff --git a/test/jdk/java/awt/Focus/RestoreFocusInfiniteLoopTest.java b/test/jdk/java/awt/Focus/RestoreFocusInfiniteLoopTest.java new file mode 100644 index 00000000000..64b1ae9477c --- /dev/null +++ b/test/jdk/java/awt/Focus/RestoreFocusInfiniteLoopTest.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ +/* + @test + @bug 4504665 + @summary MerlinBeta2 - vetoing a focus change causes infinite loop + @key headful + @run main RestoreFocusInfiniteLoopTest +*/ + +import java.awt.AWTException; +import java.awt.Button; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.KeyboardFocusManager; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextArea; + +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; + +public class RestoreFocusInfiniteLoopTest { + static final int TEST_TIMEOUT = 1000; + static final int DELAY = 100; + static Button b1; + static Frame frame; + static Object b1Monitor; + static Point origin; + static Dimension dim; + static MonitoredFocusListener monitorer; + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(() -> { + + b1Monitor = new Object(); + frame = new Frame(); + b1 = new Button("1"); + Button b2 = new Button("2"); + b1.setName("b1"); + b2.setName("b2"); + + frame.setLayout(new FlowLayout()); + frame.add(b1); + frame.add(b2); + frame.pack(); + frame.setSize(100, 100); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + FocusVetoableChangeListener vetoer = new FocusVetoableChangeListener(b2); + KeyboardFocusManager.getCurrentKeyboardFocusManager(). + addVetoableChangeListener("focusOwner", vetoer); + + }); + Robot robot = new Robot(); + robot.setAutoDelay(DELAY); + robot.setAutoWaitForIdle(true); + robot.delay(1000); + EventQueue.invokeAndWait(() -> { + monitorer = new MonitoredFocusListener(b1Monitor); + b1.addFocusListener(monitorer); + origin = b1.getLocationOnScreen(); + dim = b1.getSize(); + }); + robot.mouseMove((int)origin.getX() + (int)dim.getWidth()/2, + (int)origin.getY() + (int)dim.getHeight()/2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + if (!b1.isFocusOwner()) { + synchronized (b1Monitor) { + b1Monitor.wait(TEST_TIMEOUT); + } + } + + monitorer.resetFocusLost(); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + + if (!monitorer.isFocusLostReceived() || !b1.isFocusOwner()) { + synchronized (b1Monitor) { + b1Monitor.wait(TEST_TIMEOUT); + } + } + if (!b1.isFocusOwner()) { + throw new RuntimeException("Test is FAILED"); + } else { + System.out.println("Test is PASSED"); + } + } finally { + if (frame != null) { + frame.dispose(); + } + } + } + + }// class RestoreFocusInfiniteLoopTest + +class FocusVetoableChangeListener implements VetoableChangeListener { + Component vetoedComponent; + public FocusVetoableChangeListener(Component vetoedComponent) { + this.vetoedComponent = vetoedComponent; + } + public void vetoableChange(PropertyChangeEvent evt) + throws PropertyVetoException + { + Component oldComp = (Component)evt.getOldValue(); + Component newComp = (Component)evt.getNewValue(); + + boolean vetoFocusChange = (newComp == vetoedComponent); + process(evt.getPropertyName(), oldComp, newComp); + + if (vetoFocusChange) { + throw new PropertyVetoException("message", evt); + } + } + boolean process(String propName, Component o1, Component o2) { + System.out.println(propName + + " old=" + (o1 != null ? o1.getName() : "null") + + " new=" + (o2 != null ? o2.getName() : "null")); + return true; + } + } + +class MonitoredFocusListener extends FocusAdapter { + Object monitor; + boolean focuslost = false; + + public void resetFocusLost() { + focuslost = false; + } + public boolean isFocusLostReceived() { + return focuslost; + } + public MonitoredFocusListener(Object monitor) { + this.monitor = monitor; + } + + public void focusLost(FocusEvent fe) { + System.out.println(fe.toString()); + focuslost = true; + } + public void focusGained(FocusEvent fe) { + System.out.println(fe.toString()); + synchronized (monitor) { + monitor.notify(); + } + } +} diff --git a/test/jdk/java/awt/Focus/SequencedLightweightRequestsTest.java b/test/jdk/java/awt/Focus/SequencedLightweightRequestsTest.java new file mode 100644 index 00000000000..9daa87a4263 --- /dev/null +++ b/test/jdk/java/awt/Focus/SequencedLightweightRequestsTest.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ +/* + @test + @bug 4648816 + @summary Sometimes focus requests on LW components are delayed + @key headful + @run main SequencedLightweightRequestsTest +*/ + +import java.awt.AWTException; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextArea; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.InputEvent; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; + +public class SequencedLightweightRequestsTest implements FocusListener { + final int WAIT_TIME = 5000; + + JFrame testFrame; + JButton testButton1; + JButton testButton2; + JTextField testField; + + public void focusGained(FocusEvent fe) { + System.err.println("FocusGained on " + fe.getComponent().getName()); + } + + public void focusLost(FocusEvent fe) { + System.err.println("FocusLost on " + fe.getComponent().getName()); + } + + public static void main(String[] args) throws Exception { + SequencedLightweightRequestsTest test = + new SequencedLightweightRequestsTest(); + test.start(); + } + + public void start() throws Exception { + try { + + SwingUtilities.invokeAndWait(() -> { + testFrame = new JFrame("See my components!"); + testButton1 = new JButton("Click me!"); + testButton2 = new JButton("Do I have focus?"); + testField = new JTextField("Do I have focus?"); + testFrame.getContentPane().setLayout(new FlowLayout()); + testFrame.getContentPane().add(testButton1); + testFrame.getContentPane().add(testField); + testFrame.getContentPane().add(testButton2); + + testButton1.setName("Button1"); + testButton2.setName("Button2"); + testField.setName("textField"); + testButton1.addFocusListener(this); + testButton2.addFocusListener(this); + testField.addFocusListener(this); + testFrame.addFocusListener(this); + + testFrame.setSize(300, 100); + testFrame.setLocationRelativeTo(null); + testFrame.setVisible(true); + }); + + Robot robot = new Robot(); + robot.setAutoDelay(100); + robot.setAutoWaitForIdle(true); + + // wait to give to frame time for showing + robot.delay(1000); + + // make sure that first button has focus + Object monitor = new Object(); + MonitoredFocusListener monitorer = + new MonitoredFocusListener(monitor); + Point origin = testButton1.getLocationOnScreen(); + Dimension dim = testButton1.getSize(); + robot.mouseMove((int)origin.getX() + (int)dim.getWidth()/2, + (int)origin.getY() + (int)dim.getHeight()/2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + if (!testButton1.isFocusOwner()) { + synchronized (monitor) { + testButton1.addFocusListener(monitorer); + monitor.wait(WAIT_TIME); + testButton1.removeFocusListener(monitorer); + } + } + + // if first button still doesn't have focus, test fails + if (!testButton1.isFocusOwner()) { + throw new RuntimeException("First button doesn't receive focus"); + } + + // two lightweight requests + java.awt.EventQueue.invokeAndWait(new Runnable() { + public void run() { + testButton2.requestFocus(); + testField.requestFocus(); + } + }); + + // make sure third button receives focus + if (!testField.isFocusOwner()) { + synchronized (monitor) { + testField.addFocusListener(monitorer); + monitor.wait(WAIT_TIME); + testField.removeFocusListener(monitorer); + } + } + + // if the text field still doesn't have focus, test fails + if (!testField.isFocusOwner()) { + throw new RuntimeException("Text field doesn't receive focus"); + } + System.out.println("Test PASSED"); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (testFrame != null) { + testFrame.dispose(); + } + }); + } + } +}// class SequencedLightweightRequestsTest + +class MonitoredFocusListener extends FocusAdapter { + Object monitor; + + public MonitoredFocusListener(Object monitor) { + this.monitor = monitor; + } + + public void focusGained(FocusEvent fe) { + synchronized (monitor) { + monitor.notify(); + } + } +} diff --git a/test/jdk/java/awt/Focus/SetFocusableTest.java b/test/jdk/java/awt/Focus/SetFocusableTest.java new file mode 100644 index 00000000000..371b8ff49ba --- /dev/null +++ b/test/jdk/java/awt/Focus/SetFocusableTest.java @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ +/* + @test + @bug 4597455 + @summary setFocusable(false) is not moving the focus to next Focusable Component + @key headful + @run main SetFocusableTest +*/ + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextArea; +import java.awt.TextField; + +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +public class SetFocusableTest implements KeyListener { + static Object buttonMonitor; + Object tfMonitor; + static final int TEST_TIMEOUT = 5000; + Button button; + Frame frame; + TextField textfield; + + public static void main(String[] args) throws Exception { + SetFocusableTest test = new SetFocusableTest(); + test.start(); + } + + public void start() throws Exception { + try { + EventQueue.invokeAndWait(() -> { + buttonMonitor = new Object(); + tfMonitor = new Object(); + frame = new Frame(); + frame.setTitle("Test Frame"); + frame.setLocation(100, 100); + frame.setLayout(new FlowLayout()); + + button = new Button("BUTTON"); + textfield = new TextField("First"); + + button.addKeyListener(this); + textfield.addKeyListener(this); + + frame.add(button); + frame.add(textfield); + + frame.setBackground(Color.red); + frame.setSize(500,200); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frame.toFront(); + button.addFocusListener(new MonitoredFocusListener(buttonMonitor)); + textfield.addFocusListener(new MonitoredFocusListener(tfMonitor)); + }); + + Robot robot; + robot = new Robot(); + robot.setAutoDelay(100); + robot.setAutoWaitForIdle(true); + robot.delay(1000); + + Point buttonOrigin = button.getLocationOnScreen(); + Dimension buttonSize = button.getSize(); + robot.mouseMove( + (int)buttonOrigin.getX() + (int)buttonSize.getWidth() / 2, + (int)buttonOrigin.getY() + (int)buttonSize.getHeight() / 2); + + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + if (!button.isFocusOwner()) { + synchronized (buttonMonitor) { + buttonMonitor.wait(TEST_TIMEOUT); + } + } + System.out.println("\n\nBefore calling the method button.setFocusable(false)"); + System.out.println("===================================================="); + System.out.println("Button is Focusable(button.isFocusable()) :"+button.isFocusable()); + System.out.println("Button is Focus owner(button.isFocusOwner()) :"+button.isFocusOwner()); + System.out.println("Button has Focus (button.hasFocus) :"+button.hasFocus()); + System.out.println("===================================================="); + + button.setFocusable(false); + + if (!textfield.isFocusOwner()) { + synchronized (tfMonitor) { + tfMonitor.wait(TEST_TIMEOUT); + } + } + + System.out.println("\nAfter Calling button.setFocusable(false)"); + System.out.println("===================================================="); + System.out.println("Button is Focusable(button.isFocusable()) :"+button.isFocusable()); + System.out.println("Button is Focus owner(button.isFocusOwner()) :"+button.isFocusOwner()); + System.out.println("Button has Focus (button.hasFocus()) :"+button.hasFocus()); + System.out.println("TextField is Focusable(textfield.isFocusable()) :"+textfield.isFocusable()); + System.out.println("TextField is Focus owner(textfield.isFocusOwner()) :"+textfield.isFocusOwner()); + System.out.println("TextField has Focus (textfield.hasFocus()) :"+textfield.hasFocus()); + System.out.println("====================================================n\n\n\n"); + + if (!button.hasFocus() && !button.isFocusOwner() && + textfield.hasFocus() && textfield.isFocusOwner()){ + System.out.println("\n\n\nASSERTION :PASSED"); + System.out.println("========================="); + System.out.println("Textfield is having the Focus.Transfer of Focus has happend."); + } else { + System.out.println("\n\n\nASSERTION :FAILED"); + System.out.println("=========================="); + System.out.println("Button is still having the Focus instead of TextField"); + throw new RuntimeException("Test FIALED"); + } + } finally { + if (frame != null) { + frame.dispose(); + } + } + }// start() + + public void keyPressed(KeyEvent e) { + System.out.println("Key Pressed "); + } + public void keyReleased(KeyEvent ke) { + System.out.println("keyReleased called "); + } + public void keyTyped(KeyEvent ke) { + System.out.println("keyTyped called "); + } +}// class SetFocusableTest + +class MonitoredFocusListener extends FocusAdapter { + Object monitor; + public MonitoredFocusListener(Object monitor) { + this.monitor = monitor; + } + + public void focusGained(FocusEvent fe) { + System.out.println(fe.toString()); + synchronized (monitor) { + monitor.notify(); + } + } +} From 910eb0ef1b4701966cfe76e28fca9da49446158d Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 2 Apr 2024 04:39:19 +0000 Subject: [PATCH 069/149] 8306714: Open source few Swing event and AbstractAction tests Backport-of: 31a73b0d7088d10a5ffb5541d66806a92b681ef9 --- test/jdk/javax/swing/Action/bug4186951.java | 82 +++++++++++++++++++++ test/jdk/javax/swing/Action/bug4211425.java | 47 ++++++++++++ test/jdk/javax/swing/Action/bug4211454.java | 49 ++++++++++++ test/jdk/javax/swing/Action/bug4244034.java | 59 +++++++++++++++ test/jdk/javax/swing/event/bug4143690.java | 48 ++++++++++++ test/jdk/javax/swing/event/bug4160240.java | 44 +++++++++++ 6 files changed, 329 insertions(+) create mode 100644 test/jdk/javax/swing/Action/bug4186951.java create mode 100644 test/jdk/javax/swing/Action/bug4211425.java create mode 100644 test/jdk/javax/swing/Action/bug4211454.java create mode 100644 test/jdk/javax/swing/Action/bug4244034.java create mode 100644 test/jdk/javax/swing/event/bug4143690.java create mode 100644 test/jdk/javax/swing/event/bug4160240.java diff --git a/test/jdk/javax/swing/Action/bug4186951.java b/test/jdk/javax/swing/Action/bug4186951.java new file mode 100644 index 00000000000..3d3529f9470 --- /dev/null +++ b/test/jdk/javax/swing/Action/bug4186951.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* @test + @bug 4186951 + @summary Bulletproofing for AbstractAction.ArrayTable Serialization. + @run main bug4186951 +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import javax.swing.SwingUtilities; + +public class bug4186951 { + public static void main(String[] args) throws Exception { + AbstractAction ma = new MyAction(); + MyClassSer mcs = new MyClassSer(); + ma.putValue("serializable",mcs); + MyClassNonSer mcn = new MyClassNonSer(); + ma.putValue("non-serializable",mcn); + FileOutputStream fos = new FileOutputStream("file.test"); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(ma); + FileInputStream fis = new FileInputStream("file.test"); + ObjectInputStream ois = new ObjectInputStream(fis); + ma = (MyAction)ois.readObject(); + File fil = new File("file.test"); + if (fil!=null) { + fil.delete(); + } + if (!((MyClassSer)ma.getValue("serializable")).equals(mcs)) { + throw new RuntimeException("Serialisable class " + + " wasn't serialized..."); + } + if ((MyClassNonSer)ma.getValue("non-serializable") != null) { + throw new RuntimeException("Serialisation occurs for " + + " non-serialisable class..."); + } + } + + static class MyAction extends AbstractAction { + public void actionPerformed(ActionEvent e) {} + } + + static class MyClassSer implements Serializable { + String str = "default_string"; + public boolean equals(MyClassSer s) { + return str.equals(s.str); + } + } + + static class MyClassNonSer { + String str = "default_string"; + } + +} diff --git a/test/jdk/javax/swing/Action/bug4211425.java b/test/jdk/javax/swing/Action/bug4211425.java new file mode 100644 index 00000000000..8046ab0a81c --- /dev/null +++ b/test/jdk/javax/swing/Action/bug4211425.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* @test + @bug 4211425 + @summary Verifies ClassCastException in AbstractAction + @run main bug4211425 +*/ + +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; + +public class bug4211425 { + + public static void main(String[] args) { + AbstractAction at = new AbstractAction() { + public void actionPerformed(ActionEvent e) { + System.out.println("Action!"); + } + }; + for (int i = 0; i < 10; i++) { + at.putValue("key " + i, "name"); + at.putValue("key " + i, "name"); // Adding another with same key + // tickles this bug + } + } +} diff --git a/test/jdk/javax/swing/Action/bug4211454.java b/test/jdk/javax/swing/Action/bug4211454.java new file mode 100644 index 00000000000..9db82ba0602 --- /dev/null +++ b/test/jdk/javax/swing/Action/bug4211454.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* @test + @bug 4211454 + @summary Verifies ClassCastException in AbstractAction + @run main bug4211454 +*/ + +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; + +public class bug4211454 { + + public static void main(String[] args) { + AbstractAction at = new AbstractAction() { + public void actionPerformed(ActionEvent e) { + System.out.println("Action!"); + } + }; + for (int i = 0; i<9; i++) { + at.putValue("key " + i, "name"); + } + for (int i = 9; i>3; i--) { + at.putValue("key " + i, null); + at.putValue("Not a key " + i, null); + } + } +} diff --git a/test/jdk/javax/swing/Action/bug4244034.java b/test/jdk/javax/swing/Action/bug4244034.java new file mode 100644 index 00000000000..9efb11c8204 --- /dev/null +++ b/test/jdk/javax/swing/Action/bug4244034.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* @test + @bug 4244034 + @summary Tests that AbstractAction has method getKeys() + @run main bug4244034 +*/ + +import java.util.Arrays; +import java.util.List; +import java.awt.event.ActionEvent; +import javax.swing.Action; +import javax.swing.AbstractAction; + +public class bug4244034 { + + /** Auxilliary class extending AbstractAction + */ + static class NullAction extends AbstractAction { + public void actionPerformed(ActionEvent e) {} + } + + public static void main(String[] args) { + AbstractAction action = new NullAction(); + action.putValue(Action.SHORT_DESCRIPTION, "my short descr"); + action.putValue(Action.LONG_DESCRIPTION, "my long descr"); + action.putValue(Action.NAME, "my name"); + + Object[] keys = action.getKeys(); + List keysList = Arrays.asList(keys); + if (! keysList.contains(Action.SHORT_DESCRIPTION) || + ! keysList.contains(Action.LONG_DESCRIPTION) || + ! keysList.contains(Action.NAME)) { + + throw new Error("Failed: getKeys() works improperly"); + } + } +} diff --git a/test/jdk/javax/swing/event/bug4143690.java b/test/jdk/javax/swing/event/bug4143690.java new file mode 100644 index 00000000000..971d1984656 --- /dev/null +++ b/test/jdk/javax/swing/event/bug4143690.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* @test + @bug 4143690 + @summary Tests that TreeSelectionEvent has isAddedPath(int) method + @run main bug4143690 +*/ + +import javax.swing.event.TreeSelectionEvent; +import javax.swing.tree.TreePath; + +public class bug4143690 { + + public static void main(String[] argv) throws Exception { + bug4143690 test = new bug4143690(); + TreePath p = new TreePath(""); + TreeSelectionEvent e = new TreeSelectionEvent(test, p, true, p, p); + + TreePath[] paths = e.getPaths(); + for(int i = 0; i < paths.length; i++) { + TreePath path = paths[i]; + if (e.isAddedPath(i) != true) { + throw new RuntimeException("Incorrect isAddedPath(int)..."); + } + } + } +} diff --git a/test/jdk/javax/swing/event/bug4160240.java b/test/jdk/javax/swing/event/bug4160240.java new file mode 100644 index 00000000000..4a3654271dc --- /dev/null +++ b/test/jdk/javax/swing/event/bug4160240.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* @test + @bug 4160240 + @summary InternalFrameEvent has getInternalFrame() method. + @run main bug4160240 +*/ + +import javax.swing.JInternalFrame; +import javax.swing.event.InternalFrameEvent; + +public class bug4160240 { + + public static void main(String[] argv) throws Exception { + JInternalFrame jif = new JInternalFrame(); + InternalFrameEvent ife = new InternalFrameEvent(jif, + InternalFrameEvent.INTERNAL_FRAME_OPENED); + if (ife.getInternalFrame() != jif) { + throw new RuntimeException("JInternalFrame.getInternalFrame " + + " doesn't work correctly..."); + } + } +} From 6808c5c89d1e30f481ebe444f93175232bcd30e2 Mon Sep 17 00:00:00 2001 From: Suchismith Roy Date: Wed, 3 Apr 2024 08:00:56 +0000 Subject: [PATCH 070/149] 8320005: Allow loading of shared objects with .a extension on AIX Backport-of: e85355ada4ac1061c49ee9f1247d37a437c7b5ab --- src/hotspot/os/aix/os_aix.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index 85a97888d90..5b877b159b4 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -1313,10 +1313,9 @@ bool os::dll_address_to_library_name(address addr, char* buf, // Loads .dll/.so and in case of error it checks if .dll/.so was built // for the same architecture as Hotspot is running on. -void *os::dll_load(const char *filename, char *ebuf, int ebuflen) { +static void* dll_load_library(const char *filename, char *ebuf, int ebuflen) { log_info(os)("attempting shared library load of %s", filename); - if (ebuf && ebuflen > 0) { ebuf[0] = '\0'; ebuf[ebuflen - 1] = '\0'; @@ -1359,6 +1358,26 @@ void* os::dll_lookup(void* handle, const char* name) { void* os::get_default_process_handle() { return (void*)::dlopen(NULL, RTLD_LAZY); } +// Load library named +// If filename matches .so, and loading fails, repeat with .a. +void *os::dll_load(const char *filename, char *ebuf, int ebuflen) { + void* result = nullptr; + char* const file_path = strdup(filename); + char* const pointer_to_dot = strrchr(file_path, '.'); + const char old_extension[] = ".so"; + const char new_extension[] = ".a"; + STATIC_ASSERT(sizeof(old_extension) >= sizeof(new_extension)); + // First try to load the existing file. + result = dll_load_library(filename, ebuf, ebuflen); + // If the load fails,we try to reload by changing the extension to .a for .so files only. + // Shared object in .so format dont have braces, hence they get removed for archives with members. + if (result == nullptr && pointer_to_dot != nullptr && strcmp(pointer_to_dot, old_extension) == 0) { + snprintf(pointer_to_dot, sizeof(old_extension), "%s", new_extension); + result = dll_load_library(file_path, ebuf, ebuflen); + } + FREE_C_HEAP_ARRAY(char, file_path); + return result; +} void os::print_dll_info(outputStream *st) { st->print_cr("Dynamic libraries:"); From 9ac4063d14dfa9633cea90e13e2cd13681826255 Mon Sep 17 00:00:00 2001 From: Paul Hohensee Date: Thu, 4 Apr 2024 22:08:01 +0000 Subject: [PATCH 071/149] 8299677: Formatter.format might take a long time to format an integer or floating-point Reviewed-by: mdoerr, shade Backport-of: 33412c102ce799ff2de3512df77e6e07d76acd36 --- .../share/classes/java/util/Formatter.java | 9 +- test/jdk/java/util/Formatter/Padding.java | 313 ++++++++++++++++++ 2 files changed, 317 insertions(+), 5 deletions(-) create mode 100644 test/jdk/java/util/Formatter/Padding.java diff --git a/src/java.base/share/classes/java/util/Formatter.java b/src/java.base/share/classes/java/util/Formatter.java index 0fd1176b970..160d77e7e54 100644 --- a/src/java.base/share/classes/java/util/Formatter.java +++ b/src/java.base/share/classes/java/util/Formatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -4526,10 +4526,9 @@ private StringBuilder localizedMagnitude(StringBuilder sb, } // apply zero padding - if (width != -1 && f.contains(Flags.ZERO_PAD)) { - for (int k = sb.length(); k < width; k++) { - sb.insert(begin, zero); - } + if (width > sb.length() && f.contains(Flags.ZERO_PAD)) { + String zeros = String.valueOf(zero).repeat(width - sb.length()); + sb.insert(begin, zeros); } return sb; diff --git a/test/jdk/java/util/Formatter/Padding.java b/test/jdk/java/util/Formatter/Padding.java new file mode 100644 index 00000000000..982b6967928 --- /dev/null +++ b/test/jdk/java/util/Formatter/Padding.java @@ -0,0 +1,313 @@ +/* + * 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. + * + * 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. + */ + +/* + * @test + * @bug 4906370 + * @summary Tests to excercise padding on int and double values, + * with various flag combinations. + * @run junit Padding + */ + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.params.provider.Arguments.arguments; + +public class Padding { + + static Arguments[] padding() { + return new Arguments[] { + /* blank padding, right adjusted, optional plus sign */ + arguments("12", "%1d", 12), + arguments("12", "%2d", 12), + arguments(" 12", "%3d", 12), + arguments(" 12", "%4d", 12), + arguments(" 12", "%5d", 12), + arguments(" 12", "%10d", 12), + + arguments("-12", "%1d", -12), + arguments("-12", "%2d", -12), + arguments("-12", "%3d", -12), + arguments(" -12", "%4d", -12), + arguments(" -12", "%5d", -12), + arguments(" -12", "%10d", -12), + + arguments("1.2", "%1.1f", 1.2), + arguments("1.2", "%2.1f", 1.2), + arguments("1.2", "%3.1f", 1.2), + arguments(" 1.2", "%4.1f", 1.2), + arguments(" 1.2", "%5.1f", 1.2), + arguments(" 1.2", "%10.1f", 1.2), + + arguments("-1.2", "%1.1f", -1.2), + arguments("-1.2", "%2.1f", -1.2), + arguments("-1.2", "%3.1f", -1.2), + arguments("-1.2", "%4.1f", -1.2), + arguments(" -1.2", "%5.1f", -1.2), + arguments(" -1.2", "%10.1f", -1.2), + + /* blank padding, right adjusted, mandatory plus sign */ + arguments("+12", "%+1d", 12), + arguments("+12", "%+2d", 12), + arguments("+12", "%+3d", 12), + arguments(" +12", "%+4d", 12), + arguments(" +12", "%+5d", 12), + arguments(" +12", "%+10d", 12), + + arguments("-12", "%+1d", -12), + arguments("-12", "%+2d", -12), + arguments("-12", "%+3d", -12), + arguments(" -12", "%+4d", -12), + arguments(" -12", "%+5d", -12), + arguments(" -12", "%+10d", -12), + + arguments("+1.2", "%+1.1f", 1.2), + arguments("+1.2", "%+2.1f", 1.2), + arguments("+1.2", "%+3.1f", 1.2), + arguments("+1.2", "%+4.1f", 1.2), + arguments(" +1.2", "%+5.1f", 1.2), + arguments(" +1.2", "%+10.1f", 1.2), + + arguments("-1.2", "%+1.1f", -1.2), + arguments("-1.2", "%+2.1f", -1.2), + arguments("-1.2", "%+3.1f", -1.2), + arguments("-1.2", "%+4.1f", -1.2), + arguments(" -1.2", "%+5.1f", -1.2), + arguments(" -1.2", "%+10.1f", -1.2), + + /* blank padding, right adjusted, mandatory blank sign */ + arguments(" 12", "% 1d", 12), + arguments(" 12", "% 2d", 12), + arguments(" 12", "% 3d", 12), + arguments(" 12", "% 4d", 12), + arguments(" 12", "% 5d", 12), + arguments(" 12", "% 10d", 12), + + arguments("-12", "% 1d", -12), + arguments("-12", "% 2d", -12), + arguments("-12", "% 3d", -12), + arguments(" -12", "% 4d", -12), + arguments(" -12", "% 5d", -12), + arguments(" -12", "% 10d", -12), + + arguments(" 1.2", "% 1.1f", 1.2), + arguments(" 1.2", "% 2.1f", 1.2), + arguments(" 1.2", "% 3.1f", 1.2), + arguments(" 1.2", "% 4.1f", 1.2), + arguments(" 1.2", "% 5.1f", 1.2), + arguments(" 1.2", "% 10.1f", 1.2), + + arguments("-1.2", "% 1.1f", -1.2), + arguments("-1.2", "% 2.1f", -1.2), + arguments("-1.2", "% 3.1f", -1.2), + arguments("-1.2", "% 4.1f", -1.2), + arguments(" -1.2", "% 5.1f", -1.2), + arguments(" -1.2", "% 10.1f", -1.2), + + /* blank padding, left adjusted, optional sign */ + arguments("12", "%-1d", 12), + arguments("12", "%-2d", 12), + arguments("12 ", "%-3d", 12), + arguments("12 ", "%-4d", 12), + arguments("12 ", "%-5d", 12), + arguments("12 ", "%-10d", 12), + + arguments("-12", "%-1d", -12), + arguments("-12", "%-2d", -12), + arguments("-12", "%-3d", -12), + arguments("-12 ", "%-4d", -12), + arguments("-12 ", "%-5d", -12), + arguments("-12 ", "%-10d", -12), + + arguments("1.2", "%-1.1f", 1.2), + arguments("1.2", "%-2.1f", 1.2), + arguments("1.2", "%-3.1f", 1.2), + arguments("1.2 ", "%-4.1f", 1.2), + arguments("1.2 ", "%-5.1f", 1.2), + arguments("1.2 ", "%-10.1f", 1.2), + + arguments("-1.2", "%-1.1f", -1.2), + arguments("-1.2", "%-2.1f", -1.2), + arguments("-1.2", "%-3.1f", -1.2), + arguments("-1.2", "%-4.1f", -1.2), + arguments("-1.2 ", "%-5.1f", -1.2), + arguments("-1.2 ", "%-10.1f", -1.2), + + /* blank padding, left adjusted, mandatory plus sign */ + arguments("+12", "%-+1d", 12), + arguments("+12", "%-+2d", 12), + arguments("+12", "%-+3d", 12), + arguments("+12 ", "%-+4d", 12), + arguments("+12 ", "%-+5d", 12), + arguments("+12 ", "%-+10d", 12), + + arguments("-12", "%-+1d", -12), + arguments("-12", "%-+2d", -12), + arguments("-12", "%-+3d", -12), + arguments("-12 ", "%-+4d", -12), + arguments("-12 ", "%-+5d", -12), + arguments("-12 ", "%-+10d", -12), + + arguments("+1.2", "%-+1.1f", 1.2), + arguments("+1.2", "%-+2.1f", 1.2), + arguments("+1.2", "%-+3.1f", 1.2), + arguments("+1.2", "%-+4.1f", 1.2), + arguments("+1.2 ", "%-+5.1f", 1.2), + arguments("+1.2 ", "%-+10.1f", 1.2), + + arguments("-1.2", "%-+1.1f", -1.2), + arguments("-1.2", "%-+2.1f", -1.2), + arguments("-1.2", "%-+3.1f", -1.2), + arguments("-1.2", "%-+4.1f", -1.2), + arguments("-1.2 ", "%-+5.1f", -1.2), + arguments("-1.2 ", "%-+10.1f", -1.2), + + /* blank padding, left adjusted, mandatory blank sign */ + arguments(" 12", "%- 1d", 12), + arguments(" 12", "%- 2d", 12), + arguments(" 12", "%- 3d", 12), + arguments(" 12 ", "%- 4d", 12), + arguments(" 12 ", "%- 5d", 12), + arguments(" 12 ", "%- 10d", 12), + + arguments("-12", "%- 1d", -12), + arguments("-12", "%- 2d", -12), + arguments("-12", "%- 3d", -12), + arguments("-12 ", "%- 4d", -12), + arguments("-12 ", "%- 5d", -12), + arguments("-12 ", "%- 10d", -12), + + arguments(" 1.2", "%- 1.1f", 1.2), + arguments(" 1.2", "%- 2.1f", 1.2), + arguments(" 1.2", "%- 3.1f", 1.2), + arguments(" 1.2", "%- 4.1f", 1.2), + arguments(" 1.2 ", "%- 5.1f", 1.2), + arguments(" 1.2 ", "%- 10.1f", 1.2), + + arguments("-1.2", "%- 1.1f", -1.2), + arguments("-1.2", "%- 2.1f", -1.2), + arguments("-1.2", "%- 3.1f", -1.2), + arguments("-1.2", "%- 4.1f", -1.2), + arguments("-1.2 ", "%- 5.1f", -1.2), + arguments("-1.2 ", "%- 10.1f", -1.2), + + /* zero padding, right adjusted, optional sign */ + arguments("12", "%01d", 12), + arguments("12", "%02d", 12), + arguments("012", "%03d", 12), + arguments("0012", "%04d", 12), + arguments("00012", "%05d", 12), + arguments("0000000012", "%010d", 12), + + arguments("-12", "%01d", -12), + arguments("-12", "%02d", -12), + arguments("-12", "%03d", -12), + arguments("-012", "%04d", -12), + arguments("-0012", "%05d", -12), + arguments("-000000012", "%010d", -12), + + arguments("1.2", "%01.1f", 1.2), + arguments("1.2", "%02.1f", 1.2), + arguments("1.2", "%03.1f", 1.2), + arguments("01.2", "%04.1f", 1.2), + arguments("001.2", "%05.1f", 1.2), + arguments("00000001.2", "%010.1f", 1.2), + + arguments("-1.2", "%01.1f", -1.2), + arguments("-1.2", "%02.1f", -1.2), + arguments("-1.2", "%03.1f", -1.2), + arguments("-1.2", "%04.1f", -1.2), + arguments("-01.2", "%05.1f", -1.2), + arguments("-0000001.2", "%010.1f", -1.2), + + /* zero padding, right adjusted, mandatory plus sign */ + arguments("+12", "%+01d", 12), + arguments("+12", "%+02d", 12), + arguments("+12", "%+03d", 12), + arguments("+012", "%+04d", 12), + arguments("+0012", "%+05d", 12), + arguments("+000000012", "%+010d", 12), + + arguments("-12", "%+01d", -12), + arguments("-12", "%+02d", -12), + arguments("-12", "%+03d", -12), + arguments("-012", "%+04d", -12), + arguments("-0012", "%+05d", -12), + arguments("-000000012", "%+010d", -12), + + arguments("+1.2", "%+01.1f", 1.2), + arguments("+1.2", "%+02.1f", 1.2), + arguments("+1.2", "%+03.1f", 1.2), + arguments("+1.2", "%+04.1f", 1.2), + arguments("+01.2", "%+05.1f", 1.2), + arguments("+0000001.2", "%+010.1f", 1.2), + + arguments("-1.2", "%+01.1f", -1.2), + arguments("-1.2", "%+02.1f", -1.2), + arguments("-1.2", "%+03.1f", -1.2), + arguments("-1.2", "%+04.1f", -1.2), + arguments("-01.2", "%+05.1f", -1.2), + arguments("-0000001.2", "%+010.1f", -1.2), + + /* zero padding, right adjusted, mandatory blank sign */ + arguments(" 12", "% 01d", 12), + arguments(" 12", "% 02d", 12), + arguments(" 12", "% 03d", 12), + arguments(" 012", "% 04d", 12), + arguments(" 0012", "% 05d", 12), + arguments(" 000000012", "% 010d", 12), + + arguments("-12", "% 01d", -12), + arguments("-12", "% 02d", -12), + arguments("-12", "% 03d", -12), + arguments("-012", "% 04d", -12), + arguments("-0012", "% 05d", -12), + arguments("-000000012", "% 010d", -12), + + arguments(" 1.2", "% 01.1f", 1.2), + arguments(" 1.2", "% 02.1f", 1.2), + arguments(" 1.2", "% 03.1f", 1.2), + arguments(" 1.2", "% 04.1f", 1.2), + arguments(" 01.2", "% 05.1f", 1.2), + arguments(" 0000001.2", "% 010.1f", 1.2), + + arguments("-1.2", "% 01.1f", -1.2), + arguments("-1.2", "% 02.1f", -1.2), + arguments("-1.2", "% 03.1f", -1.2), + arguments("-1.2", "% 04.1f", -1.2), + arguments("-01.2", "% 05.1f", -1.2), + arguments("-0000001.2", "% 010.1f", -1.2), + + }; + } + + @ParameterizedTest + @MethodSource + void padding(String expected, String format, Object value) { + assertEquals(expected, String.format(format, value)); + } + +} From 2f285fd96aaf064e7040b20e51297c9b75c8f501 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Fri, 5 Apr 2024 02:01:40 +0000 Subject: [PATCH 072/149] 8323994: gtest runner repeats test name for every single gtest assertion 8158048: Fix failure message from jtreg gtest wrapper 8263659: Reflow GTestResultParser for better readability Reviewed-by: lucy Backport-of: 1aae980c549741cf5fc5ca51f3c299285bafa49d --- .../jtreg/gtest/GTestResultParser.java | 81 +++++++++++++++++++ test/hotspot/jtreg/gtest/GTestWrapper.java | 56 ++++++++----- 2 files changed, 118 insertions(+), 19 deletions(-) create mode 100644 test/hotspot/jtreg/gtest/GTestResultParser.java diff --git a/test/hotspot/jtreg/gtest/GTestResultParser.java b/test/hotspot/jtreg/gtest/GTestResultParser.java new file mode 100644 index 00000000000..ffa98bf29f2 --- /dev/null +++ b/test/hotspot/jtreg/gtest/GTestResultParser.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019, 2024, 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. + * + * 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. + */ + +import javax.xml.XMLConstants; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import java.io.IOException; +import java.io.Reader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class GTestResultParser { + private final List _failedTests; + + public GTestResultParser(Path file) { + List failedTests = new ArrayList<>(); + try (Reader r = Files.newBufferedReader(file)) { + XMLInputFactory factory = XMLInputFactory.newInstance(); + factory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); + factory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); + XMLStreamReader xmlReader = factory.createXMLStreamReader(r); + String testSuite = null; + String testCase = null; + while (xmlReader.hasNext()) { + int code = xmlReader.next(); + if (code == XMLStreamConstants.START_ELEMENT) { + switch (xmlReader.getLocalName()) { + case "testsuite": + testSuite = xmlReader.getAttributeValue("", "name"); + break; + case "testcase": + testCase = xmlReader.getAttributeValue("", "name"); + break; + case "failure": + String failedStr = testSuite + "::" + testCase; + if (!failedTests.contains(failedStr)) { + failedTests.add(failedStr); + } + break; + default: + // ignore + } + } + } + } catch (XMLStreamException e) { + throw new IllegalArgumentException("can't open parse xml " + file, e); + } catch (IOException e) { + throw new IllegalArgumentException("can't open result file " + file, e); + } + _failedTests = Collections.unmodifiableList(failedTests); + } + + public List failedTests() { + return _failedTests; + } +} diff --git a/test/hotspot/jtreg/gtest/GTestWrapper.java b/test/hotspot/jtreg/gtest/GTestWrapper.java index 08ee033a60b..4f9a775f020 100644 --- a/test/hotspot/jtreg/gtest/GTestWrapper.java +++ b/test/hotspot/jtreg/gtest/GTestWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -25,24 +25,22 @@ * @summary a jtreg wrapper for gtest tests * @library /test/lib * @modules java.base/jdk.internal.misc + * java.xml * @requires vm.flagless * @run main/native GTestWrapper */ -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Stream; -import java.util.stream.Collectors; - -import java.io.File; -import java.nio.file.Paths; -import java.nio.file.Path; - import jdk.test.lib.Platform; import jdk.test.lib.Utils; import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.List; +import java.util.Map; public class GTestWrapper { public static void main(String[] args) throws Throwable { @@ -77,13 +75,33 @@ public static void main(String[] args) throws Throwable { env.put(pathVar, path + File.pathSeparator + ldLibraryPath); } - pb.command(new String[] { - execPath.toString(), - "-jdk", - System.getProperty("test.jdk"), - "--gtest_catch_exceptions=0" - }); - ProcessTools.executeCommand(pb).shouldHaveExitValue(0); + Path resultFile = Paths.get("test_result.xml"); + pb.command(execPath.toAbsolutePath().toString(), + "-jdk", Utils.TEST_JDK, + "--gtest_output=xml:" + resultFile); + int exitCode = ProcessTools.executeCommand(pb).getExitValue(); + if (exitCode != 0) { + List failedTests = failedTests(resultFile); + String message = "gtest execution failed; exit code = " + exitCode + "."; + if (!failedTests.isEmpty()) { + message += " the failed tests: " + failedTests; + } + throw new AssertionError(message); + } + } + + private static List failedTests(Path xml) { + if (!Files.exists(xml)) { + System.err.println("WARNING: test result file (" + xml + ") hasn't been found"); + } + + try { + return new GTestResultParser(xml).failedTests(); + } catch (Throwable t) { + System.err.println("WARNING: failed to parse result file (" + xml + ") " + t); + t.printStackTrace(); + } + return Collections.emptyList(); } private static String getJVMVariantSubDir() { From eca369614ccaa0c0109724231984a3acfd8e2756 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Fri, 5 Apr 2024 02:01:58 +0000 Subject: [PATCH 073/149] 8310923: Refactor Currency tests to use JUnit Reviewed-by: lucy Backport-of: e848d9471f5de86e5ac157b710cd7371f12f0024 --- test/jdk/java/util/Currency/Bug4512215.java | 68 --- test/jdk/java/util/Currency/Bug6807534.java | 84 ---- test/jdk/java/util/Currency/Bug8154295.java | 55 --- .../java/util/Currency/CNPGetDisplayName.java | 101 ++++ .../java/util/Currency/CheckDataVersion.java | 22 +- test/jdk/java/util/Currency/CurrencyTest.java | 456 +++++++++-------- .../Currency/NoMinorUnitCurrenciesTest.java | 66 +++ .../util/Currency/NumCodeAsStringTest.java | 61 +++ .../java/util/Currency/ValidateISO4217.java | 460 +++++++++--------- 9 files changed, 721 insertions(+), 652 deletions(-) delete mode 100644 test/jdk/java/util/Currency/Bug4512215.java delete mode 100644 test/jdk/java/util/Currency/Bug6807534.java delete mode 100644 test/jdk/java/util/Currency/Bug8154295.java create mode 100644 test/jdk/java/util/Currency/CNPGetDisplayName.java create mode 100644 test/jdk/java/util/Currency/NoMinorUnitCurrenciesTest.java create mode 100644 test/jdk/java/util/Currency/NumCodeAsStringTest.java diff --git a/test/jdk/java/util/Currency/Bug4512215.java b/test/jdk/java/util/Currency/Bug4512215.java deleted file mode 100644 index 2e2a78c279b..00000000000 --- a/test/jdk/java/util/Currency/Bug4512215.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2007, 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. - * - * 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. - */ -/* - * @test - * @bug 4512215 4818420 4819436 - * @summary Updated currency data. - */ - -import java.util.Currency; -import java.util.Locale; - -public class Bug4512215 { - - public static void main(String[] args) throws Exception { - testCurrencyDefined("XBD", -1); - testCountryCurrency("TJ", "TJS", 2); - testCountryCurrency("FO", "DKK", 2); - testCountryCurrency("FK", "FKP", 2); - - testCountryCurrency("AF", "AFN", 2); // changed from "AFA" - - // Newsletter V-5 on ISO 3166-1 (2002-05-20) - testCountryCurrency("TL", "USD", 2); // successor to TP/TPE - - // Newsletter V-8 on ISO 3166-1 (2003-07-23) - testCountryCurrency("CS", "CSD", 2); // successor to YU/YUM - } - - private static void testCountryCurrency(String country, String currencyCode, - int digits) { - testCurrencyDefined(currencyCode, digits); - Currency currency = Currency.getInstance(new Locale("", country)); - if (!currency.getCurrencyCode().equals(currencyCode)) { - throw new RuntimeException("[" + country - + "] expected: " + currencyCode - + "; got: " + currency.getCurrencyCode()); - } - } - - private static void testCurrencyDefined(String currencyCode, int digits) { - Currency currency = Currency.getInstance(currencyCode); - if (currency.getDefaultFractionDigits() != digits) { - throw new RuntimeException("[" + currencyCode - + "] expected: " + digits - + "; got: " + currency.getDefaultFractionDigits()); - } - } -} diff --git a/test/jdk/java/util/Currency/Bug6807534.java b/test/jdk/java/util/Currency/Bug6807534.java deleted file mode 100644 index 073518d45ac..00000000000 --- a/test/jdk/java/util/Currency/Bug6807534.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2010, 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. - * - * 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. - */ -/* - * @test - * @bug 6807534 - * @summary check whether the default implementation of - * CurrencNameProvider.getDisplayName(String, Locale) throws appropriate - * exceptions when necessary. - */ - -import java.util.Locale; -import java.util.spi.CurrencyNameProvider; - -public class Bug6807534 { - - static final CurrencyNameProvider cnp = new CurrencyNameProviderImpl(); - - public static void main(String[] args) throws Exception { - // test for NullPointerException (currencyCode) - try { - cnp.getDisplayName(null, Locale.US); - throwException("NPE was not thrown with null currencyCode"); - } catch (NullPointerException npe) {} - - // test for NullPointerException (locale) - try { - cnp.getDisplayName("USD", null); - throwException("NPE was not thrown with null locale"); - } catch (NullPointerException npe) {} - - // test for IllegalArgumentException (illegal currencyCode) - try { - cnp.getDisplayName("INVALID", Locale.US); - throwException("IllegalArgumentException was not thrown with invalid currency code"); - } catch (IllegalArgumentException iae) {} - try { - cnp.getDisplayName("inv", Locale.US); - throwException("IllegalArgumentException was not thrown with invalid currency code"); - } catch (IllegalArgumentException iae) {} - - // test for IllegalArgumentException (non-supported locale) - try { - cnp.getDisplayName("USD", Locale.JAPAN); - throwException("IllegalArgumentException was not thrown with non-supported locale"); - } catch (IllegalArgumentException iae) {} - } - - static void throwException(String msg) { - throw new RuntimeException("test failed. "+msg); - } - - static class CurrencyNameProviderImpl extends CurrencyNameProvider { - // dummy implementation - public String getSymbol(String currencyCode, Locale locale) { - return ""; - } - - public Locale[] getAvailableLocales() { - Locale[] avail = new Locale[1]; - avail[0] = Locale.US; - return avail; - } - } -} diff --git a/test/jdk/java/util/Currency/Bug8154295.java b/test/jdk/java/util/Currency/Bug8154295.java deleted file mode 100644 index 356d00ba36b..00000000000 --- a/test/jdk/java/util/Currency/Bug8154295.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. - * - * 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. - */ -/* - * @test - * @bug 8154295 - * @summary Check getNumericCodeAsString() method which returns numeric code as a 3 digit String. - */ - -import java.util.Currency; - -public class Bug8154295 { - - public static void main(String[] args) { - - String numericCode = Currency.getInstance("AFA").getNumericCodeAsString(); - if (!numericCode.equals("004")) { //should return "004" (a 3 digit string) - throw new RuntimeException("[Expected 004, " - + "found "+numericCode+" for AFA]"); - } - - numericCode = Currency.getInstance("AUD").getNumericCodeAsString(); - if (!numericCode.equals("036")) { //should return "036" (a 3 digit string) - throw new RuntimeException("[Expected 036, " - + "found "+numericCode+" for AUD]"); - } - - numericCode = Currency.getInstance("USD").getNumericCodeAsString(); - if (!numericCode.equals("840")) {// should return "840" (a 3 digit string) - throw new RuntimeException("[Expected 840, " - + "found "+numericCode+" for USD]"); - } - - } - -} diff --git a/test/jdk/java/util/Currency/CNPGetDisplayName.java b/test/jdk/java/util/Currency/CNPGetDisplayName.java new file mode 100644 index 00000000000..af399bee540 --- /dev/null +++ b/test/jdk/java/util/Currency/CNPGetDisplayName.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2010, 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. + * + * 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. + */ + +/* + * @test + * @bug 6807534 + * @summary check whether the default implementation of + * CurrencyNameProvider.getDisplayName(String, Locale) throws appropriate + * exceptions when necessary. + * @run junit CNPGetDisplayName + */ + +import java.util.Locale; +import java.util.spi.CurrencyNameProvider; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class CNPGetDisplayName { + + static final CurrencyNameProvider cnp = new CurrencyNameProviderImpl(); + + /** + * Tests that the currency name provider throws a NullPointerException + * under the expected circumstances. + */ + @ParameterizedTest + @MethodSource("nullArgProvider") + public void NPETest(String currencyCode, Locale locale, String err) { + assertThrows(NullPointerException.class, + () -> cnp.getDisplayName(currencyCode, locale), err); + } + + /** + * Tests that the currency name provider throws a IllegalArgumentException + * under the expected circumstances. + */ + @ParameterizedTest + @MethodSource("illegalArgProvider") + public void IAETest(String currencyCode, Locale locale, String err) { + assertThrows(IllegalArgumentException.class, + () -> cnp.getDisplayName(currencyCode, locale), err); + } + + private static Stream nullArgProvider() { + return Stream.of( + Arguments.of(null, Locale.US, + "NPE was not thrown with null currencyCode"), + Arguments.of("USD", null, + "NPE was not thrown with null locale") + ); + } + + private static Stream illegalArgProvider() { + return Stream.of( + Arguments.of("INVALID", Locale.US, + "IAE was not thrown with invalid currency code"), + Arguments.of("inv", Locale.US, + "IAE was not thrown with invalid currency code"), + Arguments.of("USD", Locale.JAPAN, + "IllegalArgumentException was not thrown with non-supported locale") + ); + } + + static class CurrencyNameProviderImpl extends CurrencyNameProvider { + // dummy implementation + public String getSymbol(String currencyCode, Locale locale) { + return ""; + } + + public Locale[] getAvailableLocales() { + Locale[] avail = new Locale[1]; + avail[0] = Locale.US; + return avail; + } + } +} diff --git a/test/jdk/java/util/Currency/CheckDataVersion.java b/test/jdk/java/util/Currency/CheckDataVersion.java index 204a80a8557..ba18677dbbe 100644 --- a/test/jdk/java/util/Currency/CheckDataVersion.java +++ b/test/jdk/java/util/Currency/CheckDataVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -20,15 +20,21 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/** - * - * - * Check the consistency between the regression tests and the currency data in the JRE + + +/* + Check the consistency between the regression tests and the currency + data in the JRE. This class is used by other test classes. */ -import java.io.*; -import java.lang.reflect.*; -import java.security.*; +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Currency; class CheckDataVersion { diff --git a/test/jdk/java/util/Currency/CurrencyTest.java b/test/jdk/java/util/Currency/CurrencyTest.java index ad7c596485b..380bf3b338a 100644 --- a/test/jdk/java/util/Currency/CurrencyTest.java +++ b/test/jdk/java/util/Currency/CurrencyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -20,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + /* * @test * @bug 4290801 4692419 4693631 5101540 5104960 6296410 6336600 6371531 @@ -28,6 +29,7 @@ * @summary Basic tests for Currency class. * @modules java.base/java.util:open * jdk.localedata + * @run junit CurrencyTest */ import java.io.ByteArrayInputStream; @@ -38,198 +40,236 @@ import java.time.LocalTime; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.util.ArrayList; import java.util.Currency; +import java.util.List; import java.util.Locale; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class CurrencyTest { - public static void main(String[] args) throws Exception { + // 'tablea1.txt' should be up-to-date before testing + @Test + public void dataVersionTest() { CheckDataVersion.check(); - testCurrencyCodeValidation(); - testLocaleMapping(); - testSymbols(); - testFractionDigits(); - testSerialization(); - testDisplayNames(); - testFundsCodes(); } - static void testCurrencyCodeValidation() { - // test creation of some valid currencies - testValidCurrency("USD"); - testValidCurrency("EUR"); - testValidCurrency("GBP"); - testValidCurrency("JPY"); - testValidCurrency("CNY"); - testValidCurrency("CHF"); - - // test creation of some fictitious currencies - testInvalidCurrency("AQD"); - testInvalidCurrency("US$"); - testInvalidCurrency("\u20AC"); - } + @Nested + @TestInstance(TestInstance.Lifecycle.PER_CLASS) + class CodeValidationTests { + // Calling getInstance() on equal currency codes should return equal currencies + @ParameterizedTest + @MethodSource("validCurrencies") + public void validCurrencyTest(String currencyCode) { + compareCurrencies(currencyCode); + } - static void testValidCurrency(String currencyCode) { - Currency currency1 = Currency.getInstance(currencyCode); - Currency currency2 = Currency.getInstance(currencyCode); - if (currency1 != currency2) { - throw new RuntimeException("Didn't get same instance for same currency code"); + private Stream validCurrencies() { + return Stream.of("USD", "EUR", "GBP", "JPY", "CNY", "CHF"); + } + + // Calling getInstance() with an invalid currency code should throw an IAE + @ParameterizedTest + @MethodSource("invalidCurrencies") + public void invalidCurrencyTest(String currencyCode) { + assertThrows(IllegalArgumentException.class, () -> + Currency.getInstance(currencyCode), "getInstance() did not throw IAE"); } - if (!currency1.getCurrencyCode().equals(currencyCode)) { - throw new RuntimeException("Currency code changed"); + + private Stream invalidCurrencies() { + return Stream.of("AQD", "US$", "\u20AC"); } } - static void testInvalidCurrency(String currencyCode) { - boolean gotException = false; - try { - Currency currency = Currency.getInstance(currencyCode); - } catch (IllegalArgumentException e) { - gotException = true; + @Nested + @TestInstance(TestInstance.Lifecycle.PER_CLASS) + class FundsCodesTests { + // Calling getInstance() on equal currency codes should return equal currencies + @ParameterizedTest + @MethodSource("fundsCodes") + public void validCurrencyTest(String currencyCode) { + compareCurrencies(currencyCode); } - if (!gotException) { - throw new RuntimeException("didn't get specified exception"); + + // Verify a currency has the expected fractional digits + @ParameterizedTest + @MethodSource("fundsCodes") + public void fractionDigitTest(String currencyCode, int expectedFractionDigits) { + compareFractionDigits(currencyCode, expectedFractionDigits); + } + + // Verify a currency has the expected numeric code + @ParameterizedTest + @MethodSource("fundsCodes") + public void numericCodeTest(String currencyCode, int ignored, int expectedNumeric) { + int numeric = Currency.getInstance(currencyCode).getNumericCode(); + assertEquals(numeric, expectedNumeric, String.format( + "Wrong numeric code for currency %s, expected %s, got %s", + currencyCode, expectedNumeric, numeric)); + } + + private Stream fundsCodes() { + return Stream.of( + Arguments.of("BOV", 2, 984), Arguments.of("CHE", 2, 947), + Arguments.of("CHW", 2, 948), Arguments.of("CLF", 4, 990), + Arguments.of("COU", 2, 970), Arguments.of("MXV", 2, 979), + Arguments.of("USN", 2, 997), Arguments.of("UYI", 0, 940) + ); } } - static void testLocaleMapping() { + @Nested + @TestInstance(TestInstance.Lifecycle.PER_CLASS) + class LocaleMappingTests { + // very basic test: most countries have their own currency, and then // their currency code is an extension of their country code. - Locale[] locales = Locale.getAvailableLocales(); - int goodCountries = 0; - int ownCurrencies = 0; - for (int i = 0; i < locales.length; i++) { - Locale locale = locales[i]; - String ctryCode = locale.getCountry(); - int ctryLength = ctryCode.length(); - if (ctryLength == 0 || - ctryLength == 3 || // UN M.49 code - ctryCode.matches("AA|Q[M-Z]|X[A-JL-Z]|ZZ" + // user defined codes, excluding "XK" (Kosovo) - "AC|CP|DG|EA|EU|FX|IC|SU|TA|UK")) { // exceptional reservation codes - boolean gotException = false; - try { - Currency.getInstance(locale); - } catch (IllegalArgumentException e) { - gotException = true; - } - if (!gotException) { - throw new RuntimeException("didn't get specified exception"); - } - } else { - goodCountries++; - Currency currency = Currency.getInstance(locale); - if (currency.getCurrencyCode().indexOf(locale.getCountry()) == 0) { - ownCurrencies++; + @Test + public void localeMappingTest() { + Locale[] locales = Locale.getAvailableLocales(); + int goodCountries = 0; + int ownCurrencies = 0; + for (Locale locale : locales) { + String ctryCode = locale.getCountry(); + int ctryLength = ctryCode.length(); + if (ctryLength == 0 || + ctryLength == 3 || // UN M.49 code + ctryCode.matches("AA|Q[M-Z]|X[A-JL-Z]|ZZ" + // user defined codes, excluding "XK" (Kosovo) + "AC|CP|DG|EA|EU|FX|IC|SU|TA|UK")) { // exceptional reservation codes + assertThrows(IllegalArgumentException.class, () -> Currency.getInstance(locale), "Did not throw IAE"); + } else { + goodCountries++; + Currency currency = Currency.getInstance(locale); + if (currency.getCurrencyCode().indexOf(locale.getCountry()) == 0) { + ownCurrencies++; + } } } + System.out.println("Countries tested: " + goodCountries + + ", own currencies: " + ownCurrencies); + if (ownCurrencies < (goodCountries / 2 + 1)) { + throw new RuntimeException("suspicious: not enough countries have their own currency."); + } } - System.out.println("Countries tested: " + goodCountries + - ", own currencies: " + ownCurrencies); - if (ownCurrencies < (goodCountries / 2 + 1)) { - throw new RuntimeException("suspicious: not enough countries have their own currency."); + + // Check an invalid country code + @Test + public void invalidCountryTest() { + assertThrows(IllegalArgumentException.class, ()-> + Currency.getInstance(new Locale("", "EU")), "Did not throw IAE"); } - // check a few countries that don't change their currencies too often - String[] country1 = {"US", "CA", "JP", "CN", "SG", "CH"}; - String[] currency1 = {"USD", "CAD", "JPY", "CNY", "SGD", "CHF"}; - for (int i = 0; i < country1.length; i++) { - checkCountryCurrency(country1[i], currency1[i]); + // Ensure a selection of countries have the expected currency + @ParameterizedTest + @MethodSource({"countryProvider", "switchedOverCountries"}) + public void countryCurrencyTest(String countryCode, String expected) { + Locale locale = new Locale("", countryCode); + Currency currency = Currency.getInstance(locale); + String code = (currency != null) ? currency.getCurrencyCode() : null; + assertEquals(expected, code, generateErrMsg( + "currency for", locale.getDisplayCountry(), expected, code)); } - /* - * check currency changes - * In current implementation, there is no data of old currency and transition date at jdk/make/data/currency/CurrencyData.properties. - * So, all the switch data arrays are empty. In the future, if data of old currency and transition date are necessary for any country, the - * arrays here can be updated so that the program can check the currency switch. - */ - String[] switchOverCtry = {}; - String[] switchOverOld = {}; - String[] switchOverNew = {}; - String[] switchOverTZ = {}; - int[] switchOverYear = {}; - int[] switchOverMonth = {}; // java.time APIs accept month starting from 1 i.e. 01 for January - int[] switchOverDay = {}; - - for (int i = 0; i < switchOverCtry.length; i++) { - ZoneId zoneId = ZoneId.of(switchOverTZ[i]); - ZonedDateTime zonedDateAndTime = ZonedDateTime.of(LocalDate.of(switchOverYear[i], switchOverMonth[i], switchOverDay[i]), - LocalTime.MIDNIGHT, zoneId); - ZonedDateTime currentZonedDateAndTime = ZonedDateTime.now(zoneId); - checkCountryCurrency(switchOverCtry[i], (currentZonedDateAndTime.isAfter(zonedDateAndTime) || - currentZonedDateAndTime.isEqual(zonedDateAndTime)) ? switchOverNew[i] : switchOverOld[i]); + private Stream countryProvider() { + return Stream.of( + // Check country that does not have a currency + Arguments.of("AQ", null), + // Check some countries that don't change their currencies often + Arguments.of("US", "USD"), + Arguments.of("CA", "CAD"), + Arguments.of("JP", "JPY"), + Arguments.of("CN", "CNY"), + Arguments.of("SG", "SGD"), + Arguments.of("CH", "CHF") + ); } - // check a country code which doesn't have a currency - checkCountryCurrency("AQ", null); + /* + * Check Currency Changes + * In the current implementation, there is no data of old currency and transition + * date at jdk/src/java.base/share/data/currency/CurrencyData.properties. + * So, all the switch data arrays are empty. In the future, if data of old + * currency and transition date are necessary for any country, the + * arrays here can be updated so that the program can check the currency switch. + */ + private List switchedOverCountries() { + List switched = new ArrayList(); + String[] switchOverCtry = {}; + String[] switchOverOld = {}; + String[] switchOverNew = {}; + String[] switchOverTZ = {}; + int[] switchOverYear = {}; + int[] switchOverMonth = {}; // java.time APIs accept month starting from 1 i.e. 01 for January + int[] switchOverDay = {}; - // check an invalid country code - boolean gotException = false; - try { - Currency.getInstance(new Locale("", "EU")); - } catch (IllegalArgumentException e) { - gotException = true; - } - if (!gotException) { - throw new RuntimeException("didn't get specified exception."); + for (int i = 0; i < switchOverCtry.length; i++) { + ZoneId zoneId = ZoneId.of(switchOverTZ[i]); + ZonedDateTime zonedDateAndTime = ZonedDateTime.of(LocalDate.of( + switchOverYear[i], switchOverMonth[i], switchOverDay[i]), LocalTime.MIDNIGHT, zoneId); + ZonedDateTime currentZonedDateAndTime = ZonedDateTime.now(zoneId); + switched.add(Arguments.of(switchOverCtry[i], (currentZonedDateAndTime.isAfter(zonedDateAndTime) + || currentZonedDateAndTime.isEqual(zonedDateAndTime)) ? switchOverNew[i] : switchOverOld[i])); + } + return switched; } } - static void checkCountryCurrency(String countryCode, String expected) { - Locale locale = new Locale("", countryCode); - Currency currency = Currency.getInstance(locale); - String code = (currency != null) ? currency.getCurrencyCode() : null; - if (!(expected == null ? code == null : expected.equals(code))) { - throw new RuntimeException("Wrong currency for " + - locale.getDisplayCountry() + - ": expected " + expected + ", got " + code); - } - } + // NON-NESTED TESTS - static void testSymbols() { - testSymbol("USD", Locale.US, "$"); - testSymbol("EUR", Locale.GERMANY, "\u20AC"); - testSymbol("USD", Locale.PRC, "US$"); + // Ensure selection of currencies have the correct fractional digits + @ParameterizedTest + @MethodSource("expectedFractionsProvider") + public void fractionDigitsTest(String currencyCode, int expectedFractionDigits) { + compareFractionDigits(currencyCode, expectedFractionDigits); } - static void testSymbol(String currencyCode, Locale locale, String expectedSymbol) { - String symbol = Currency.getInstance(currencyCode).getSymbol(locale); - if (!symbol.equals(expectedSymbol)) { - throw new RuntimeException("Wrong symbol for currency " + - currencyCode +": expected " + expectedSymbol + - ", got " + symbol); - } + private static Stream expectedFractionsProvider() { + return Stream.of( + Arguments.of("USD", 2), Arguments.of("EUR", 2), + Arguments.of("JPY", 0), Arguments.of("XDR", -1), + Arguments.of("BHD", 3), Arguments.of("IQD", 3), + Arguments.of("JOD", 3), Arguments.of("KWD", 3), + Arguments.of("LYD", 3), Arguments.of("OMR", 3), + Arguments.of("TND", 3), + + // Old and New Turkish Lira + Arguments.of("TRL", 0), Arguments.of("TRY", 2) + ); } - static void testFractionDigits() { - testFractionDigits("USD", 2); - testFractionDigits("EUR", 2); - testFractionDigits("JPY", 0); - testFractionDigits("XDR", -1); - - testFractionDigits("BHD", 3); - testFractionDigits("IQD", 3); - testFractionDigits("JOD", 3); - testFractionDigits("KWD", 3); - testFractionDigits("LYD", 3); - testFractionDigits("OMR", 3); - testFractionDigits("TND", 3); - - // Turkish Lira - testFractionDigits("TRL", 0); - testFractionDigits("TRY", 2); + // Ensure selection of currencies have the expected symbol + @ParameterizedTest + @MethodSource("symbolProvider") + public void symbolTest(String currencyCode, Locale locale, String expectedSymbol) { + String symbol = Currency.getInstance(currencyCode).getSymbol(locale); + assertEquals(symbol, expectedSymbol, generateErrMsg( + "symbol for", currencyCode, expectedSymbol, symbol)); } - static void testFractionDigits(String currencyCode, int expectedFractionDigits) { - int digits = Currency.getInstance(currencyCode).getDefaultFractionDigits(); - if (digits != expectedFractionDigits) { - throw new RuntimeException("Wrong number of fraction digits for currency " + - currencyCode +": expected " + expectedFractionDigits + - ", got " + digits); - } + private static Stream symbolProvider() { + return Stream.of( + Arguments.of("USD", Locale.US, "$"), + Arguments.of("EUR", Locale.GERMANY, "\u20AC"), + Arguments.of("USD", Locale.PRC, "US$") + ); } - static void testSerialization() throws Exception { + // Ensure serialization does not break class invariant. + // Currency should be able to round-trip and remain the same value. + @Test + public void serializationTest() throws Exception { Currency currency1 = Currency.getInstance("DEM"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -241,74 +281,66 @@ static void testSerialization() throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream iStream = new ObjectInputStream(bais); Currency currency2 = (Currency) iStream.readObject(); - - if (currency1 != currency2) { - throw new RuntimeException("serialization breaks class invariant"); - } + assertEquals(currency1, currency2, "serialization breaks class invariant"); } - static void testDisplayNames() { - // null argument test - try { - testDisplayName("USD", null, ""); - throw new RuntimeException("getDisplayName(NULL) did not throw an NPE."); - } catch (NullPointerException npe) {} - - testDisplayName("USD", Locale.ENGLISH, "US Dollar"); - testDisplayName("FRF", Locale.FRENCH, "franc fran\u00e7ais"); - testDisplayName("DEM", Locale.GERMAN, "Deutsche Mark"); - testDisplayName("ESP", new Locale("es"), "peseta espa\u00f1ola"); - testDisplayName("ITL", new Locale("it"), "lira italiana"); - testDisplayName("JPY", Locale.JAPANESE, "\u65e5\u672c\u5186"); - testDisplayName("KRW", Locale.KOREAN, "\ub300\ud55c\ubbfc\uad6d \uc6d0"); - testDisplayName("SEK", new Locale("sv"), "svensk krona"); - testDisplayName("CNY", Locale.SIMPLIFIED_CHINESE, "\u4eba\u6c11\u5e01"); - testDisplayName("TWD", Locale.TRADITIONAL_CHINESE, "\u65b0\u53f0\u5e63"); + // Ensure getInstance() throws null when passed a null locale + @Test + public void nullDisplayNameTest() { + assertThrows(NullPointerException.class, ()-> + Currency.getInstance("USD").getDisplayName(null)); } - static void testDisplayName(String currencyCode, Locale locale, String expectedName) { + // Ensure a selection of currencies/locale combos have the correct display name + @ParameterizedTest + @MethodSource("displayNameProvider") + public void displayNameTest(String currencyCode, Locale locale, String expectedName) { String name = Currency.getInstance(currencyCode).getDisplayName(locale); - if (!name.equals(expectedName)) { - throw new RuntimeException("Wrong display name for currency " + - currencyCode +": expected '" + expectedName + - "', got '" + name + "'"); - } + assertEquals(name, expectedName, generateErrMsg( + "display name for", currencyCode, expectedName, name)); } - static void testFundsCodes() { - testValidCurrency("BOV"); - testValidCurrency("CHE"); - testValidCurrency("CHW"); - testValidCurrency("CLF"); - testValidCurrency("COU"); - testValidCurrency("MXV"); - testValidCurrency("USN"); - testValidCurrency("UYI"); - - testFractionDigits("BOV", 2); - testFractionDigits("CHE", 2); - testFractionDigits("CHW", 2); - testFractionDigits("CLF", 4); - testFractionDigits("COU", 2); - testFractionDigits("MXV", 2); - testFractionDigits("USN", 2); - testFractionDigits("UYI", 0); - - testNumericCode("BOV", 984); - testNumericCode("CHE", 947); - testNumericCode("CHW", 948); - testNumericCode("CLF", 990); - testNumericCode("COU", 970); - testNumericCode("MXV", 979); - testNumericCode("USN", 997); - testNumericCode("UYI", 940); + + private static Stream displayNameProvider() { + return Stream.of( + Arguments.of("USD", Locale.ENGLISH, "US Dollar"), + Arguments.of("FRF", Locale.FRENCH, "franc fran\u00e7ais"), + Arguments.of("DEM", Locale.GERMAN, "Deutsche Mark"), + Arguments.of("ESP", new Locale("es"), "peseta espa\u00f1ola"), + Arguments.of("ITL", Locale.ITALIAN, "lira italiana"), + Arguments.of("JPY", Locale.JAPANESE, "\u65e5\u672c\u5186"), + Arguments.of("KRW", Locale.KOREAN, "\ub300\ud55c\ubbfc\uad6d \uc6d0"), + Arguments.of("SEK", new Locale("sv"), "svensk krona"), + Arguments.of("CNY", Locale.SIMPLIFIED_CHINESE, "\u4eba\u6c11\u5e01"), + Arguments.of("TWD", Locale.TRADITIONAL_CHINESE, "\u65b0\u53f0\u5e63") + ); } - static void testNumericCode(String currencyCode, int expectedNumeric) { - int numeric = Currency.getInstance(currencyCode).getNumericCode(); - if (numeric != expectedNumeric) { - throw new RuntimeException("Wrong numeric code for currency " + - currencyCode +": expected " + expectedNumeric + - ", got " + numeric); - } + // HELPER FUNCTIONS + + // A Currency instance returned from getInstance() should always be + // equal if supplied the same currencyCode. getCurrencyCode() should + // always be equal to the currencyCode used to create the Currency. + private static void compareCurrencies(String currencyCode) { + Currency currency1 = Currency.getInstance(currencyCode); + Currency currency2 = Currency.getInstance(currencyCode); + assertEquals(currency1, currency2, "Didn't get same instance for same currency code"); + assertEquals(currency1.getCurrencyCode(), currencyCode, "getCurrencyCode()" + + " did not return the expected value"); + } + + // Ensures the getDefaultFractionDigits() method returns the expected amount + private static void compareFractionDigits(String currencyCode, + int expectedFractionDigits) { + int digits = Currency.getInstance(currencyCode).getDefaultFractionDigits(); + assertEquals(digits, expectedFractionDigits, generateErrMsg( + "number of fraction digits for currency", + currencyCode, Integer.toString(expectedFractionDigits), Integer.toString(digits))); + } + + // Used for logging on failing tests + private static String generateErrMsg(String subject, String currency, + String expected, String got) { + return String.format("Wrong %s %s: expected '%s', got '%s'", + subject, currency, expected, got); } } diff --git a/test/jdk/java/util/Currency/NoMinorUnitCurrenciesTest.java b/test/jdk/java/util/Currency/NoMinorUnitCurrenciesTest.java new file mode 100644 index 00000000000..1fe9c8b64d8 --- /dev/null +++ b/test/jdk/java/util/Currency/NoMinorUnitCurrenciesTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2007, 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. + * + * 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. + */ + +/* + * @test + * @bug 4512215 4818420 4819436 8310923 + * @summary Test currencies without minor units. + * @run junit NoMinorUnitCurrenciesTest + */ + +import java.util.Currency; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class NoMinorUnitCurrenciesTest { + + /** + * Spot check some minor undefined currencies and ensure their default fraction + * digits are not 2. + */ + @ParameterizedTest + @MethodSource("minorUndefined") + public void checkFractionDigits(String currencyCode, int digits) { + Currency currency = Currency.getInstance(currencyCode); + assertEquals(currency.getCurrencyCode(), currencyCode); + assertEquals(currency.getDefaultFractionDigits(), digits, String.format( + "[%s] expected: %s; got: %s", currencyCode, digits, currency.getDefaultFractionDigits())); + } + + // Currencies from the minorUndefined key of CurrencyData.properties + // (These are currencies without minor units) + private static Stream minorUndefined() { + return Stream.of( + Arguments.of("XBD", -1), + Arguments.of("XAG", -1), + Arguments.of("XAU", -1), + Arguments.of("XBA", -1), + Arguments.of("XBB", -1) + ); + } +} diff --git a/test/jdk/java/util/Currency/NumCodeAsStringTest.java b/test/jdk/java/util/Currency/NumCodeAsStringTest.java new file mode 100644 index 00000000000..8bec0856364 --- /dev/null +++ b/test/jdk/java/util/Currency/NumCodeAsStringTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +/* + * @test + * @bug 8154295 + * @summary Check getNumericCodeAsString() method which returns numeric code as a 3 digit String. + * @run junit NumCodeAsStringTest + */ + +import java.util.Currency; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class NumCodeAsStringTest { + + /** + * Ensure getNumericCodeAsString() returns the correct 3-digit numeric code + * for the associated currency Code. + */ + @ParameterizedTest + @MethodSource("codeProvider") + public void checkNumCodeTest(String currCode, String expectedNumCode) { + String actualNumCode = Currency.getInstance(currCode).getNumericCodeAsString(); + assertEquals(expectedNumCode, actualNumCode, String.format( + "Expected: %s, but got: %s, for %s", expectedNumCode, actualNumCode, currCode)); + } + + private static Stream codeProvider() { + return Stream.of( + Arguments.of("AFA", "004"), + Arguments.of("AUD", "036"), + Arguments.of("USD", "840") + ); + } +} diff --git a/test/jdk/java/util/Currency/ValidateISO4217.java b/test/jdk/java/util/Currency/ValidateISO4217.java index 3f8d858b8a1..9a92e74eb3f 100644 --- a/test/jdk/java/util/Currency/ValidateISO4217.java +++ b/test/jdk/java/util/Currency/ValidateISO4217.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -20,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + /* * @test * @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759 @@ -28,285 +29,294 @@ * @summary Validate ISO 4217 data for Currency class. * @modules java.base/java.util:open * jdk.localedata + * @run junit ValidateISO4217 */ -/* - * ############################################################################ - * - * ValidateISO4217 is a tool to detect differences between the latest ISO 4217 - * data and Java's currency data which is based on ISO 4217. - * If there is a difference, the following file which includes currency data - * may need to be updated. - * src/share/classes/java/util/CurrencyData.properties - * - * ############################################################################ - * - * 1) Make a golden-data file. - * From BSi's ISO4217 data (TABLE A1.doc), extract four (or eight, if currency is changing) - * fields and save as ./tablea1.txt. - * \t\t\t[\t\t\t\t] - * The Cutover Date is given in SimpleDateFormat's 'yyyy-MM-dd-HH-mm-ss' format in the GMT time zone. - * - * 2) Compile ValidateISO4217.java - * - * 3) Execute ValidateISO4217 as follows: - * java ValidateISO4217 +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Currency; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.TimeZone; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * This class tests the latest ISO 4217 data and Java's currency data which is + * based on ISO 4217. The golden-data file (ISO 4217 data) 'tablea1.txt' has the following + * format: \t\t\t[\t\t\t\t] + * The Cutover Date is given in SimpleDateFormat's 'yyyy-MM-dd-HH-mm-ss' format in the GMT time zone. */ - -import java.io.*; -import java.text.*; -import java.util.*; - public class ValidateISO4217 { - static final int ALPHA_NUM = 26; - - static final byte UNDEFINED = 0; - static final byte DEFINED = 1; - static final byte SKIPPED = 2; - - /* input files */ - static final String datafile = "tablea1.txt"; - - /* alpha2-code table */ - static byte[] codes = new byte[ALPHA_NUM * ALPHA_NUM]; - - static final String[][] additionalCodes = { - /* Defined in ISO 4217 list, but don't have code and minor unit info. */ - {"AQ", "", "", "0"}, // Antarctica - - /* - * Defined in ISO 4217 list, but don't have code and minor unit info in - * it. On the other hand, both code and minor unit are defined in - * .properties file. I don't know why, though. - */ - {"GS", "GBP", "826", "2"}, // South Georgia And The South Sandwich Islands - - /* Not defined in ISO 4217 list, but defined in .properties file. */ - {"AX", "EUR", "978", "2"}, // \u00c5LAND ISLANDS - {"PS", "ILS", "376", "2"}, // Palestinian Territory, Occupied - - /* Not defined in ISO 4217 list, but added in ISO 3166 country code list */ - {"JE", "GBP", "826", "2"}, // Jersey - {"GG", "GBP", "826", "2"}, // Guernsey - {"IM", "GBP", "826", "2"}, // Isle of Man - {"BL", "EUR", "978", "2"}, // Saint Barthelemy - {"MF", "EUR", "978", "2"}, // Saint Martin - - /* Defined neither in ISO 4217 nor ISO 3166 list */ - {"XK", "EUR", "978", "2"}, // Kosovo + // Input golden-data file + private static final File dataFile = new File(System.getProperty( + "test.src", "."), "tablea1.txt"); + // Code statuses + private static final byte UNDEFINED = 0; + private static final byte DEFINED = 1; + private static final byte SKIPPED = 2; + private static final byte TESTED = 4; + private static final int ALPHA_NUM = 26; + // An alpha2 code table which maps the status of a country + private static final byte[] codes = new byte[ALPHA_NUM * ALPHA_NUM]; + // Codes derived from ISO4217 golden-data file + private static final List ISO4217Codes = new ArrayList(); + // Additional codes not from the ISO4217 golden-data file + private static final List additionalCodes = new ArrayList(); + // Currencies to test (derived from ISO4217Codes and additionalCodes) + private static final Set testCurrencies = new HashSet<>(); + // Codes that are obsolete, do not have related country, extra currency + private static final String otherCodes = + "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-BYR-CHE-CHW-CLF-COU-CUC-CYP-" + + "DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-HRK-IEP-ITL-LTL-LUF-LVL-MGF-MRO-MTL-MXV-MZM-NLG-" + + "PTE-ROL-RUR-SDD-SIT-SLL-SKK-SRG-STD-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-VED-" + + "XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-" + + "YUM-ZMK-ZWD-ZWN-ZWR"; + private static final String[][] extraCodes = { + /* Defined in ISO 4217 list, but don't have code and minor unit info. */ + {"AQ", "", "", "0"}, // Antarctica + /* + * Defined in ISO 4217 list, but don't have code and minor unit info in + * it. On the other hand, both code and minor unit are defined in + * .properties file. I don't know why, though. + */ + {"GS", "GBP", "826", "2"}, // South Georgia And The South Sandwich Islands + /* Not defined in ISO 4217 list, but defined in .properties file. */ + {"AX", "EUR", "978", "2"}, // \u00c5LAND ISLANDS + {"PS", "ILS", "376", "2"}, // Palestinian Territory, Occupied + /* Not defined in ISO 4217 list, but added in ISO 3166 country code list */ + {"JE", "GBP", "826", "2"}, // Jersey + {"GG", "GBP", "826", "2"}, // Guernsey + {"IM", "GBP", "826", "2"}, // Isle of Man + {"BL", "EUR", "978", "2"}, // Saint Barthelemy + {"MF", "EUR", "978", "2"}, // Saint Martin + /* Defined neither in ISO 4217 nor ISO 3166 list */ + {"XK", "EUR", "978", "2"}, // Kosovo }; - - /* Codes that are obsolete, do not have related country, extra currency */ - static final String otherCodes = - "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-BYR-CHE-CHW-CLF-COU-CUC-CYP-" - + "DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-HRK-IEP-ITL-LTL-LUF-LVL-MGF-MRO-MTL-MXV-MZM-NLG-" - + "PTE-ROL-RUR-SDD-SIT-SLL-SKK-SRG-STD-TMM-TPE-TRL-VEF-UYI-USN-USS-VEB-VED-" - + "XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-" - + "YUM-ZMK-ZWD-ZWN-ZWR"; - - static boolean err = false; - - static Set testCurrencies = new HashSet(); - - public static void main(String[] args) throws Exception { - CheckDataVersion.check(); - test1(); - test2(); - getAvailableCurrenciesTest(); - - if (err) { - throw new RuntimeException("Failed: Validation ISO 4217 data"); - } + private static SimpleDateFormat format = null; + + // Sets up the following test data: + // ISO4217Codes, additionalCodes, testCurrencies, codes + @BeforeAll + static void setUpTestingData() throws Exception { + // These functions laterally setup 'testCurrencies' and 'codes' + // at the same time + setUpISO4217Codes(); + setUpAdditionalCodes(); + setUpOtherCurrencies(); } - static void test1() throws Exception { - - try (FileReader fr = new FileReader(new File(System.getProperty("test.src", "."), datafile)); + // Parse the ISO4217 file and populate ISO4217Codes and testCurrencies. + private static void setUpISO4217Codes() throws Exception{ + try (FileReader fr = new FileReader(dataFile); BufferedReader in = new BufferedReader(fr)) { String line; - SimpleDateFormat format = null; - while ((line = in.readLine()) != null) { if (line.length() == 0 || line.charAt(0) == '#') { + // Skip comments and empty lines continue; } - StringTokenizer tokens = new StringTokenizer(line, "\t"); String country = tokens.nextToken(); if (country.length() != 2) { + // Skip invalid countries continue; } + // If the country is valid, process the additional columns + processColumns(tokens, country); + } + } + } - String currency; - String numeric; - String minorUnit; - int tokensCount = tokens.countTokens(); - if (tokensCount < 3) { - currency = ""; - numeric = "0"; - minorUnit = "0"; - } else { + private static void processColumns(StringTokenizer tokens, String country) throws ParseException { + String currency; + String numeric; + String minorUnit; + int tokensCount = tokens.countTokens(); + if (tokensCount < 3) { + // Ill-defined columns + currency = ""; + numeric = "0"; + minorUnit = "0"; + } else { + // Fully defined columns + currency = tokens.nextToken(); + numeric = tokens.nextToken(); + minorUnit = tokens.nextToken(); + testCurrencies.add(Currency.getInstance(currency)); + // Check for the cut-over if a currency is changing + if (tokensCount > 3) { + if (format == null) { + createDateFormat(); + } + // If the cut-over already passed, use the new curency for ISO4217Codes + if (format.parse(tokens.nextToken()).getTime() < System.currentTimeMillis()) { currency = tokens.nextToken(); numeric = tokens.nextToken(); minorUnit = tokens.nextToken(); testCurrencies.add(Currency.getInstance(currency)); - - // check for the cutover - if (tokensCount > 3) { - if (format == null) { - format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US); - format.setTimeZone(TimeZone.getTimeZone("GMT")); - format.setLenient(false); - } - if (format.parse(tokens.nextToken()).getTime() < - System.currentTimeMillis()) { - currency = tokens.nextToken(); - numeric = tokens.nextToken(); - minorUnit = tokens.nextToken(); - testCurrencies.add(Currency.getInstance(currency)); - } - } } - int index = toIndex(country); - testCountryCurrency(country, currency, Integer.parseInt(numeric), - Integer.parseInt(minorUnit), index); } } + int index = toIndex(country); + ISO4217Codes.add(Arguments.of(country, currency, Integer.parseInt(numeric), + Integer.parseInt(minorUnit), index)); + codes[index] = DEFINED; + } + + // Generates a unique index for an alpha-2 country + private static int toIndex(String country) { + return ((country.charAt(0) - 'A') * ALPHA_NUM + country.charAt(1) - 'A'); + } + + private static void createDateFormat() { + format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US); + format.setTimeZone(TimeZone.getTimeZone("GMT")); + format.setLenient(false); + } - for (int i = 0; i < additionalCodes.length; i++) { - int index = toIndex(additionalCodes[i][0]); - if (additionalCodes[i][1].length() != 0) { - testCountryCurrency(additionalCodes[i][0], additionalCodes[i][1], - Integer.parseInt(additionalCodes[i][2]), - Integer.parseInt(additionalCodes[i][3]), index); - testCurrencies.add(Currency.getInstance(additionalCodes[i][1])); + // Process 'extraCodes', turning them into JUnit arguments and populate + // both additionalCodes and testCurrencies. + private static void setUpAdditionalCodes() { + for (String[] extraCode : extraCodes) { + int index = toIndex(extraCode[0]); + if (extraCode[1].length() != 0) { + additionalCodes.add(Arguments.of(extraCode[0], extraCode[1], + Integer.parseInt(extraCode[2]), Integer.parseInt(extraCode[3]), index)); + testCurrencies.add(Currency.getInstance(extraCode[1])); } else { - codes[index] = SKIPPED; + codes[index] = SKIPPED; // For example, Antarctica } } } - static int toIndex(String s) { - return ((s.charAt(0) - 'A') * ALPHA_NUM + s.charAt(1) - 'A'); + // The previous set-up method populated most of testCurrencies. This + // method finishes populating the list with 'otherCodes'. + private static void setUpOtherCurrencies() { + // Add otherCodes + StringTokenizer st = new StringTokenizer(otherCodes, "-"); + while (st.hasMoreTokens()) { + testCurrencies.add(Currency.getInstance(st.nextToken())); + } } - static void testCountryCurrency(String country, String currencyCode, - int numericCode, int digits, int index) { - if (currencyCode.length() == 0) { - return; - } - testCurrencyDefined(currencyCode, numericCode, digits); + // Check that the data file is up-to-date + @Test + public void dataVersionTest() { + CheckDataVersion.check(); + } - Locale loc = new Locale("", country); - try { - Currency currency = Currency.getInstance(loc); - if (!currency.getCurrencyCode().equals(currencyCode)) { - System.err.println("Error: [" + country + ":" + - loc.getDisplayCountry() + "] expected: " + currencyCode + - ", got: " + currency.getCurrencyCode()); - err = true; - } + /** + * Tests the JDK's ISO4217 data and ensures the values for getNumericCode(), + * getDefaultFractionDigits(), and getCurrencyCode() are as expected. + */ + @ParameterizedTest + @MethodSource({"ISO4217CodesProvider", "additionalCodesProvider"}) + public void countryCurrencyTest(String country, String currencyCode, + int numericCode, int digits, int index) { + currencyTest(currencyCode, numericCode, digits); + countryTest(country, currencyCode); + assertNotEquals(codes[index], TESTED, + "Error: Re-testing a previously defined code, possible duplication"); + codes[index] = TESTED; + } - if (codes[index] != UNDEFINED) { - System.out.println("Warning: [" + country + ":" + - loc.getDisplayCountry() + - "] multiple definitions. currency code=" + currencyCode); - } - codes[index] = DEFINED; - } - catch (Exception e) { - System.err.println("Error: " + e + ": Country=" + country); - err = true; - } + // Test a Currency built from currencyCode + private static void currencyTest(String currencyCode, int numericCode, int digits) { + Currency currency = Currency.getInstance(currencyCode); + assertEquals(currency.getNumericCode(), numericCode); + assertEquals(currency.getDefaultFractionDigits(), digits); + } + + // Test a Currency built from country + private static void countryTest(String country, String currencyCode) { + Locale loc = new Locale("", country); + Currency currency = Currency.getInstance(loc); + assertEquals(currency.getCurrencyCode(), currencyCode); } - static void testCurrencyDefined(String currencyCode, int numericCode, int digits) { - try { - Currency currency = currency = Currency.getInstance(currencyCode); + private static List ISO4217CodesProvider() { + return ISO4217Codes; + } - if (currency.getNumericCode() != numericCode) { - System.err.println("Error: [" + currencyCode + "] expected: " + - numericCode + "; got: " + currency.getNumericCode()); - err = true; - } + private static List additionalCodesProvider() { + return additionalCodes; + } - if (currency.getDefaultFractionDigits() != digits) { - System.err.println("Error: [" + currencyCode + "] expected: " + - digits + "; got: " + currency.getDefaultFractionDigits()); - err = true; + /** + * Tests trying to create a Currency from an invalid alpha-2 country either + * throws an IllegalArgumentException or returns null. The test data + * supplied is every possible combination of AA -> ZZ. + */ + @Test + public void twoLetterCodesTest() { + for (String country : codeCombos()) { + if (codes[toIndex(country)] == UNDEFINED) { + // if a code is undefined / 0, creating a Currency from it + // should throw an IllegalArgumentException + assertThrows(IllegalArgumentException.class, + () -> Currency.getInstance(new Locale("", country)), + "Error: This should be an undefined code and throw IllegalArgumentException: " + country); + } else if (codes[toIndex(country)] == SKIPPED) { + // if a code is marked as skipped / 2, creating a Currency from it + // should return null + assertNull(Currency.getInstance(new Locale("", country)), + "Error: Currency.getInstance() for this locale should return null: " + country); } } - catch (Exception e) { - System.err.println("Error: " + e + ": Currency code=" + - currencyCode); - err = true; - } } - static void test2() { + // This method generates code combos from AA to ZZ + private static List codeCombos() { + List codeCombos = new ArrayList<>(); for (int i = 0; i < ALPHA_NUM; i++) { for (int j = 0; j < ALPHA_NUM; j++) { char[] code = new char[2]; - code[0] = (char)('A'+ i); - code[1] = (char)('A'+ j); - String country = new String(code); - boolean ex; - - if (codes[toIndex(country)] == UNDEFINED) { - ex = false; - try { - Currency.getInstance(new Locale("", country)); - } - catch (IllegalArgumentException e) { - ex = true; - } - if (!ex) { - System.err.println("Error: This should be an undefined code and throw IllegalArgumentException: " + - country); - err = true; - } - } else if (codes[toIndex(country)] == SKIPPED) { - Currency cur = null; - try { - cur = Currency.getInstance(new Locale("", country)); - } - catch (Exception e) { - System.err.println("Error: " + e + ": Country=" + - country); - err = true; - } - if (cur != null) { - System.err.println("Error: Currency.getInstance() for an this locale should return null: " + - country); - err = true; - } - } + code[0] = (char) ('A' + i); + code[1] = (char) ('A' + j); + codeCombos.add(new String(code)); } } + return codeCombos; } - /** - * This test depends on test1(), where 'testCurrencies' set is constructed - */ - static void getAvailableCurrenciesTest() { + // This method ensures that getAvailableCurrencies() returns + // the expected amount of currencies. + @Test + public void getAvailableCurrenciesTest() { Set jreCurrencies = Currency.getAvailableCurrencies(); + // Ensure that testCurrencies has all the JRE currency codes + assertTrue(testCurrencies.containsAll(jreCurrencies), + getSetDiffs(jreCurrencies, testCurrencies)); + } - // add otherCodes - StringTokenizer st = new StringTokenizer(otherCodes, "-"); - while (st.hasMoreTokens()) { - testCurrencies.add(Currency.getInstance(st.nextToken())); - } - - if (!testCurrencies.containsAll(jreCurrencies)) { - System.err.print("Error: getAvailableCurrencies() returned extra currencies than expected: "); - jreCurrencies.removeAll(testCurrencies); - for (Currency c : jreCurrencies) { - System.err.print(" "+c); - } - System.err.println(); - err = true; + private static String getSetDiffs(Set jreCurrencies, Set testCurrencies) { + StringBuilder bldr = new StringBuilder(); + bldr.append("Error: getAvailableCurrencies() returned unexpected currencies: "); + jreCurrencies.removeAll(testCurrencies); + for (Currency curr : jreCurrencies) { + bldr.append(" " + curr); } + bldr.append("\n"); + return bldr.toString(); } } From 2e46aad2d2521555b3cc1b35706e65b3f66ce4c0 Mon Sep 17 00:00:00 2001 From: Sergey Nazarkin Date: Fri, 5 Apr 2024 05:27:56 +0000 Subject: [PATCH 074/149] 8268974: GetJREPath() JLI function fails to locate libjava.so if not standard Java launcher is used Reviewed-by: yan Backport-of: 984003d5c969443abae2d889e92cba30da26e55f --- .../unix/native/libjli/java_md_common.c | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/java.base/unix/native/libjli/java_md_common.c b/src/java.base/unix/native/libjli/java_md_common.c index 2d87a9ad1a4..48e57e380ff 100644 --- a/src/java.base/unix/native/libjli/java_md_common.c +++ b/src/java.base/unix/native/libjli/java_md_common.c @@ -44,20 +44,27 @@ char* findLastPathComponent(char *buffer, const char *comp) { /* * Removes the trailing file name and any intermediate platform * directories, if any, and its enclosing directory. + * Second parameter is a hint about the type of a file. JNI_TRUE is for + * shared libraries and JNI_FALSE is for executables. * Ex: if a buffer contains "/foo/bin/javac" or "/foo/bin/x64/javac", the * truncated resulting buffer will contain "/foo". */ jboolean -TruncatePath(char *buf) +TruncatePath(char *buf, jboolean pathisdll) { - // try bin directory, maybe an executable - char *p = findLastPathComponent(buf, "/bin/"); + /* + * If the file is a library, try lib directory first and then bin + * directory. + * If the file is an executable, try bin directory first and then lib + * directory. + */ + + char *p = findLastPathComponent(buf, pathisdll ? "/lib/" : "/bin/"); if (p != NULL) { *p = '\0'; return JNI_TRUE; } - // try lib directory, maybe a library - p = findLastPathComponent(buf, "/lib/"); + p = findLastPathComponent(buf, pathisdll ? "/bin/" : "/lib/"); if (p != NULL) { *p = '\0'; return JNI_TRUE; @@ -79,7 +86,7 @@ GetApplicationHome(char *buf, jint bufsize) } else { return JNI_FALSE; } - return TruncatePath(buf); + return TruncatePath(buf, JNI_FALSE); } /* @@ -94,7 +101,7 @@ GetApplicationHomeFromDll(char *buf, jint bufsize) if (dladdr((void*)&GetApplicationHomeFromDll, &info) != 0) { char *path = realpath(info.dli_fname, buf); if (path == buf) { - return TruncatePath(buf); + return TruncatePath(buf, JNI_TRUE); } } return JNI_FALSE; From aa16bfe54906a89671cf7837de31ec7b9e7c55b9 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 9 Apr 2024 08:40:37 +0000 Subject: [PATCH 075/149] 8319128: sun/security/pkcs11 tests fail on OL 7.9 aarch64 8319136: Skip pkcs11 tests on linux-aarch64 Reviewed-by: lucy Backport-of: 1f9b03e597d87679964e8772c6bea538c74feb2c --- ...TestMutuallyExclusivePlatformPredicates.java | 2 +- test/jdk/sun/security/pkcs11/PKCS11Test.java | 17 ++++++++++++++--- .../pkcs11/Provider/MultipleLogins.java | 15 ++++++++++----- .../security/pkcs11/Provider/MultipleLogins.sh | 1 + test/lib/jdk/test/lib/Platform.java | 15 +++++++++++++++ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java b/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java index 271c3fd2443..126a43a9001 100644 --- a/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java +++ b/test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java @@ -52,7 +52,7 @@ private static enum MethodGroup { MODE("isInt", "isMixed", "isComp"), IGNORED("isEmulatedClient", "isDebugBuild", "isFastDebugBuild", "isSlowDebugBuild", "hasSA", "isRoot", "isTieredSupported", "areCustomLoadersSupportedForCDS", - "isHardenedOSX", "hasOSXPlistEntries"); + "isHardenedOSX", "hasOSXPlistEntries", "isOracleLinux7"); public final List methodNames; diff --git a/test/jdk/sun/security/pkcs11/PKCS11Test.java b/test/jdk/sun/security/pkcs11/PKCS11Test.java index ca5ed02db7e..a539c879b03 100644 --- a/test/jdk/sun/security/pkcs11/PKCS11Test.java +++ b/test/jdk/sun/security/pkcs11/PKCS11Test.java @@ -57,7 +57,11 @@ import java.util.ServiceConfigurationError; import java.util.ServiceLoader; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import jdk.test.lib.Platform; import jdk.test.lib.artifacts.Artifact; import jdk.test.lib.artifacts.ArtifactResolver; import jdk.test.lib.artifacts.ArtifactResolverException; @@ -925,11 +929,18 @@ private static String fetchNssLib(String osId) { return fetchNssLib(MACOSX_AARCH64.class); case "Linux-amd64-64": - return fetchNssLib(LINUX_X64.class); + if (Platform.isOracleLinux7()) { + throw new SkippedException("Skipping Oracle Linux prior to v8"); + } else { + return fetchNssLib(LINUX_X64.class); + } case "Linux-aarch64-64": - return fetchNssLib(LINUX_AARCH64.class); - + if (Platform.isOracleLinux7()) { + throw new SkippedException("Skipping Oracle Linux prior to v8"); + } else { + return fetchNssLib(LINUX_AARCH64.class); + } default: return null; } diff --git a/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.java b/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.java index 353a5b99a64..855abe50e7b 100644 --- a/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.java +++ b/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -21,6 +21,7 @@ * questions. */ + import sun.security.pkcs11.SunPKCS11; import javax.security.auth.Subject; @@ -32,12 +33,10 @@ import java.io.IOException; import java.lang.ref.WeakReference; import java.security.*; -import java.util.Iterator; import java.util.PropertyPermission; -import java.util.ServiceConfigurationError; -import java.util.ServiceLoader; import jdk.test.lib.util.ForceGC; +import jtreg.SkippedException; public class MultipleLogins { private static final String KS_TYPE = "PKCS11"; @@ -47,7 +46,13 @@ public class MultipleLogins { static final Policy DEFAULT_POLICY = Policy.getPolicy(); public static void main(String[] args) throws Exception { - String nssConfig = PKCS11Test.getNssConfig(); + String nssConfig = null; + try { + nssConfig = PKCS11Test.getNssConfig(); + } catch (SkippedException exc) { + System.out.println("Skipping test: " + exc.getMessage()); + } + if (nssConfig == null) { // No test framework support yet. Ignore System.out.println("No NSS config found. Skipping."); diff --git a/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.sh b/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.sh index e4ca0d9d64d..c768834da7f 100644 --- a/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.sh +++ b/test/jdk/sun/security/pkcs11/Provider/MultipleLogins.sh @@ -26,6 +26,7 @@ # @summary # @library /test/lib/ # @build jdk.test.lib.util.ForceGC +# jdk.test.lib.Platform # @run shell MultipleLogins.sh # set a few environment variables so that the shell-script can run stand-alone diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java index 371560956b8..6269373c2b6 100644 --- a/test/lib/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -33,6 +33,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; import java.util.regex.Pattern; public class Platform { @@ -338,6 +339,20 @@ private static boolean isArch(String archnameRE) { .matches(); } + public static boolean isOracleLinux7() { + if (System.getProperty("os.name").toLowerCase().contains("linux") && + System.getProperty("os.version").toLowerCase().contains("el")) { + Pattern p = Pattern.compile("el(\\d+)"); + Matcher m = p.matcher(System.getProperty("os.version")); + if (m.find()) { + try { + return Integer.parseInt(m.group(1)) <= 7; + } catch (NumberFormatException nfe) {} + } + } + return false; + } + /** * Returns file extension of shared library, e.g. "so" on linux, "dll" on windows. * @return file extension From 21f04a2a46291e0ffaca4f69d47eadfc780995cd Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 9 Apr 2024 18:13:20 +0000 Subject: [PATCH 076/149] 8218917: KeyEvent.getModifiers() returns inconsistent values for ALT keys Backport-of: 2044245c90810075fbead432ad92de8fcb8af68a --- .../macosx/native/libawt_lwawt/awt/AWTEvent.m | 21 ++-- .../AltGraphModifierTest.java | 1 - .../java/awt/keyboard/8218917/AltKeyBug.java | 105 ++++++++++++++++++ 3 files changed, 112 insertions(+), 15 deletions(-) create mode 100644 test/jdk/java/awt/keyboard/8218917/AltKeyBug.java diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m index 19af0afada2..8333ff48972 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -318,7 +318,6 @@ }; static BOOL leftAltKeyPressed; -static BOOL altGRPressed = NO; /* * Almost all unicode characters just go from NS to Java with no translation. @@ -566,19 +565,13 @@ jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods) for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) { if ((cur->nsMask & nsFlags) != 0) { - - if (cur->nsMask == NSAlternateKeyMask) { - if (leftAltKeyPressed == YES) { - javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask; - if (altGRPressed == NO) - break; - } else { - leftAltKeyPressed = YES; - altGRPressed = YES; - continue; - } - } + //This code will consider the mask value for left alt as well as + //right alt, but that should be ok, since right alt contains left alt + //mask value. javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask; + if (cur->nsMask == NSAlternateKeyMask && leftAltKeyPressed) { + break; //since right alt key struct is defined last, break out of the loop } + } } } diff --git a/test/jdk/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java b/test/jdk/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java index 18f1e4d186e..ed33b5aa8dd 100644 --- a/test/jdk/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java +++ b/test/jdk/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java @@ -25,7 +25,6 @@ @test @bug 8041928 8158616 @summary Confirm that the Alt-Gr Modifier bit is set correctly. - @requires (os.family != "windows" & os.family != "mac") @run main/manual AltGraphModifierTest */ diff --git a/test/jdk/java/awt/keyboard/8218917/AltKeyBug.java b/test/jdk/java/awt/keyboard/8218917/AltKeyBug.java new file mode 100644 index 00000000000..d1f0eb123a9 --- /dev/null +++ b/test/jdk/java/awt/keyboard/8218917/AltKeyBug.java @@ -0,0 +1,105 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +/* + * @test + * @key headful + * @bug 8218917 + * @summary Tests whether sending an ALT_GRAPH key once, will result in the + * system reporting only ALT_GRAPH even if an ALT was sent and vice versa. + * @run main AltKeyBug + */ +import javax.swing.JTextField; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +import java.awt.Robot; +import java.awt.event.KeyListener; +import java.awt.event.KeyEvent; + +public class AltKeyBug { + private static JFrame f; + private static boolean rightAltPressed = false; + private static boolean throwException = false; + private static String errorString; + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(() -> { + JTextField comp = new JTextField(); + comp.addKeyListener(new KeyListener() { + @Override public void keyTyped(KeyEvent e) {} + @Override public void keyPressed(KeyEvent e) { + System.out.println("ModEx : " +e.getModifiersEx()); + System.out.println("Mod : " +e.getModifiers()); + System.out.println("ALT_DOWN : " + e.isAltDown()); + System.out.println("ALT_GR_DOWN: " + e.isAltGraphDown()); + System.out.println("-----------"); + if (rightAltPressed && !e.isAltGraphDown()) { + throwException = true; + errorString = "Right Alt press was sent but not received back."; + } else if (!rightAltPressed && e.isAltGraphDown()) { + throwException = true; + errorString = "Left Alt press was sent, but received Right Alt"; + } + } + @Override public void keyReleased(KeyEvent e) {} + }); + f = new JFrame(); + f.add(comp); + f.setSize(100,100); + f.setVisible(true); + }); + + for(int i = 0; i < 20; i++) { + rightAltPressed = true; + robot.keyPress(KeyEvent.VK_ALT_GRAPH); + robot.keyRelease(KeyEvent.VK_ALT_GRAPH); + + robot.waitForIdle(); + + if (throwException) { + throw new RuntimeException(errorString); + } + rightAltPressed = false; + robot.keyPress(KeyEvent.VK_ALT); + robot.keyRelease(KeyEvent.VK_ALT); + + robot.waitForIdle(); + + if (throwException) { + throw new RuntimeException(errorString); + } + } + } finally { + SwingUtilities.invokeAndWait(()-> { + if (f != null) + f.dispose(); + }); + } + + System.out.println("Test passed."); + } +} From dd927ede30cb237c1bb3a6609a68a06b9c818a94 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 9 Apr 2024 18:16:02 +0000 Subject: [PATCH 077/149] 8305645: System Tray icons get corrupted when Windows primary monitor changes Backport-of: 6cd370e04b01c3033eb439de0f38e9b6d703c6f4 --- .../native/libawt/windows/awt_TrayIcon.cpp | 4 ++-- .../awt/TrayIcon/TrayIconScalingTest.java | 21 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp b/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp index 5d4c11e478d..a30c6bf76d7 100644 --- a/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp +++ b/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -262,7 +262,7 @@ LRESULT CALLBACK AwtTrayIcon::TrayWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam } } break; - case WM_DPICHANGED: + case WM_DISPLAYCHANGE: // Set the flag to update icon images, see WmTaskbarCreated m_bDPIChanged = true; break; diff --git a/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java b/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java index ed72ce115cf..e5c082ac6d2 100644 --- a/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java +++ b/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -52,8 +52,9 @@ public class TrayIconScalingTest { private static TrayIcon icon; private static final String INSTRUCTIONS = - "This test checks if the tray icon gets updated when DPI / Scale" + - " is changed on the fly.\n\n" + + "This test checks if the tray icon gets updated correctly under 2 scenarios:\n\n" + + "Case 1: Single Screen - when DPI / Scale is changed on the fly.\n" + + "Case 2: Multi Screen - when both screens are set to different scales.\n\n" + "STEPS: \n\n" + "1. Check the system tray / notification area on Windows" + " taskbar, you should see a white icon which displays a" + @@ -61,11 +62,17 @@ public class TrayIconScalingTest { "2. Navigate to Settings > System > Display and change the" + " display scale by selecting any value from" + " Scale & Layout dropdown.\n\n"+ - "3. When the scale changes, check the white tray icon," + + "3. For Case 1, when the scale changes, check the white tray icon," + " there should be no distortion, it should be displayed sharp,\n" + " and the displayed number should correspond to the current"+ - " scale:\n" + - " 100% - 16, 125% - 20, 150% - 24, 175% - 28, 200% - 32.\n\n"+ + " scale.\n\n" + + "4. For Case 2, a dual monitor setup is required with 'Multiple Display'" + + " option under Display settings set to 'Extend the display'.\n\n" + + "5. Have the monitors set to different scales and toggle the" + + " 'Make this my main display' option under Display settings.\n\n" + + " In both cases, the tray icon should be displayed as a clear image" + + " without any distortion with the display number corresponding to the scale.\n" + + " 100% - 16, 125% - 20, 150% - 24, 175% - 28, 200% - 32.\n\n" + " If the icon is displayed sharp and without any distortion," + " press PASS, otherwise press FAIL.\n"; @@ -79,7 +86,7 @@ public static void main(String[] args) return; } PassFailJFrame passFailJFrame = new PassFailJFrame("TrayIcon " + - "Test Instructions", INSTRUCTIONS, 8, 18, 85); + "Test Instructions", INSTRUCTIONS, 8, 25, 85); createAndShowGUI(); // does not have a test window, // hence only the instruction frame is positioned From 7d0de463c153373c1892912143bc9ffb5a52ccc3 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 9 Apr 2024 18:18:11 +0000 Subject: [PATCH 078/149] 8061729: Update java/net tests to eliminate dependency on sun.net.www.MessageHeader and some other internal APIs Reviewed-by: lucy Backport-of: 0f3d3ac32c9d163a5d91c6839d313111c72f1ad4 --- .../www/http/HttpClient/ProxyFromCache.java | 27 +- .../net/www/http/HttpClient/RequestURI.java | 11 +- .../www/protocol/http/CloseOptionHeader.java | 32 +- .../protocol/http/HttpHeaderParserTest.java | 498 ++++++++++++++++++ .../sun/net/www/protocol/http/NTLMTest.java | 8 +- .../jdk/sun/net/www/protocol/http/NoNTLM.java | 18 +- .../www/protocol/http/RetryUponTimeout.java | 8 +- .../sun/net/www/protocol/http/UserAgent.java | 10 +- .../https/HttpsURLConnection/B6226610.java | 16 +- .../https/HttpsURLConnection/TunnelProxy.java | 7 +- .../jdk/test/lib/net/HttpHeaderParser.java | 390 ++++++++++++++ 11 files changed, 968 insertions(+), 57 deletions(-) create mode 100644 test/jdk/sun/net/www/protocol/http/HttpHeaderParserTest.java create mode 100644 test/lib/jdk/test/lib/net/HttpHeaderParser.java diff --git a/test/jdk/sun/net/www/http/HttpClient/ProxyFromCache.java b/test/jdk/sun/net/www/http/HttpClient/ProxyFromCache.java index 920e5b0e254..f1d571498e7 100644 --- a/test/jdk/sun/net/www/http/HttpClient/ProxyFromCache.java +++ b/test/jdk/sun/net/www/http/HttpClient/ProxyFromCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -25,13 +25,23 @@ * @test * @bug 6498566 * @summary URL.openConnection(Proxy.NO_PROXY) may connect through a proxy. - * @modules java.base/sun.net.www + * @library /test/lib * @run main/othervm ProxyFromCache */ -import java.net.*; -import java.io.*; -import sun.net.www.MessageHeader; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.URL; + +import jdk.test.lib.net.HttpHeaderParser; +import jdk.test.lib.net.URIBuilder; /* Creates a simple proxy and http server that just return 200 OK. * Open a URL pointing to the http server and specify that the @@ -124,15 +134,12 @@ public void run() { connectionCount++; InputStream is = sock.getInputStream(); OutputStream os = sock.getOutputStream(); - - MessageHeader headers = new MessageHeader (is); + HttpHeaderParser httpHeaderParser = new HttpHeaderParser(is); os.write(replyOK.getBytes("UTF-8")); - - headers = new MessageHeader (is); + httpHeaderParser = new HttpHeaderParser(is); // If we get here then we received a second request. connectionCount++; os.write(replyOK.getBytes("UTF-8")); - sock.close(); } catch (Exception e) { //e.printStackTrace(); diff --git a/test/jdk/sun/net/www/http/HttpClient/RequestURI.java b/test/jdk/sun/net/www/http/HttpClient/RequestURI.java index 667a0778abf..a5b55989b12 100644 --- a/test/jdk/sun/net/www/http/HttpClient/RequestURI.java +++ b/test/jdk/sun/net/www/http/HttpClient/RequestURI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -25,13 +25,14 @@ * @test * @bug 6469663 * @summary HTTP Request-URI contains fragment when connecting through proxy - * @modules java.base/sun.net.www + * @library /test/lib * @run main/othervm RequestURI */ import java.net.*; import java.io.*; -import sun.net.www.MessageHeader; + +import jdk.test.lib.net.HttpHeaderParser; // Create a Server listening on port 5001 to act as the proxy. Requests // never need to be forwared from it. We are only interested in the @@ -91,8 +92,8 @@ public void run() { InputStream is = sock.getInputStream(); OutputStream os = sock.getOutputStream(); - MessageHeader headers = new MessageHeader (is); - String requestLine = headers.getValue(0); + HttpHeaderParser headers = new HttpHeaderParser (is); + String requestLine = headers.getRequestDetails(); int first = requestLine.indexOf(' '); int second = requestLine.lastIndexOf(' '); diff --git a/test/jdk/sun/net/www/protocol/http/CloseOptionHeader.java b/test/jdk/sun/net/www/protocol/http/CloseOptionHeader.java index bc1ec86fee4..28bb8af30cd 100644 --- a/test/jdk/sun/net/www/protocol/http/CloseOptionHeader.java +++ b/test/jdk/sun/net/www/protocol/http/CloseOptionHeader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -24,16 +24,23 @@ /** * @test * @bug 6189206 - * @modules java.base/sun.net.www * @library /test/lib * @run main/othervm -Dhttp.keepAlive=false CloseOptionHeader * @summary HTTP client should set "Connection: close" header in request when keepalive is disabled */ -import java.net.*; -import java.util.*; -import java.io.*; -import sun.net.www.MessageHeader; +import java.io.BufferedOutputStream; +import java.io.InputStream; +import java.io.PrintStream; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.URL; +import java.util.List; + +import jdk.test.lib.net.HttpHeaderParser; import jdk.test.lib.net.URIBuilder; public class CloseOptionHeader implements Runnable { @@ -49,10 +56,15 @@ public void run() { /* check the request to find close connection option header */ InputStream is = s.getInputStream (); - MessageHeader mh = new MessageHeader(is); - String connHeader = mh.findValue("Connection"); - if (connHeader != null && connHeader.equalsIgnoreCase("close")) { - hasCloseHeader = true; + HttpHeaderParser mh = new HttpHeaderParser(is); + List connHeader = mh.getHeaderValue("Connection"); + if (connHeader != null) { + for(String value : connHeader) { + if (value.equalsIgnoreCase("close")) { + hasCloseHeader = true; + break; + } + } } PrintStream out = new PrintStream( diff --git a/test/jdk/sun/net/www/protocol/http/HttpHeaderParserTest.java b/test/jdk/sun/net/www/protocol/http/HttpHeaderParserTest.java new file mode 100644 index 00000000000..245cd49d518 --- /dev/null +++ b/test/jdk/sun/net/www/protocol/http/HttpHeaderParserTest.java @@ -0,0 +1,498 @@ + + +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +/* @test + * @bug 8061729 + * @library /test/lib + * @summary Sanity check that HttpHeaderParser works same as MessageHeader + * @modules java.base/sun.net.www java.base/sun.net.www.protocol.http:open + * @run testng/othervm HttpHeaderParserTest + */ + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import static java.lang.String.format; +import static java.nio.charset.StandardCharsets.ISO_8859_1; +import static java.nio.charset.StandardCharsets.US_ASCII; +import jdk.test.lib.net.HttpHeaderParser; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import sun.net.www.MessageHeader; + +public class HttpHeaderParserTest { + @DataProvider(name = "responses") + public Object[][] responses() { + List responses = new ArrayList<>(); + + String[] basic = + { "HTTP/1.1 200 OK\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" + + "Server: Apache/1.3.14 (Unix)\r\n" + + "Connection: close\r\n" + + "Content-Type: text/html; charset=iso-8859-1\r\n" + + "Content-Length: 10\r\n\r\n" + + "123456789", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 9\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "X-Header: U\u00ffU\r\n" + // value with U+00FF - Extended Latin-1 + "Content-Length: 9\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 9\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + // more than one SP after ':' + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length:\t10\r\n" + + "Content-Type:\ttext/html; charset=UTF-8\r\n\r\n" + // HT separator + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length:\t\t10\r\n" + + "Content-Type:\t\ttext/html; charset=UTF-8\r\n\r\n" + // more than one HT after ':' + "XXXXX", + + "HTTP/1.1 407 Proxy Authorization Required\r\n" + + "Proxy-Authenticate: Basic realm=\"a fake realm\"\r\n\r\n", + + "HTTP/1.1 401 Unauthorized\r\n" + + "WWW-Authenticate: Digest realm=\"wally land\" domain=/ " + + "nonce=\"2B7F3A2B\" qop=\"auth\"\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + "X-Foo:\r\n\r\n", // no value + + "HTTP/1.1 200 OK\r\n" + + "X-Foo:\r\n\r\n" + // no value, with response body + "Some Response Body", + + "HTTP/1.1 200 OK\r\n" + + "X-Foo:\r\n" + // no value, followed by another header + "Content-Length: 10\r\n\r\n" + + "Some Response Body", + + "HTTP/1.1 200 OK\r\n" + + "X-Foo:\r\n" + // no value, followed by another header, with response body + "Content-Length: 10\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + "X-Foo: chegar\r\n" + + "X-Foo: dfuchs\r\n" + // same header appears multiple times + "Content-Length: 0\r\n" + + "X-Foo: michaelm\r\n" + + "X-Foo: prappo\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + "X-Foo:\r\n" + // no value, same header appears multiple times + "X-Foo: dfuchs\r\n" + + "Content-Length: 0\r\n" + + "X-Foo: michaelm\r\n" + + "X-Foo: prappo\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + "Accept-Ranges: bytes\r\n" + + "Cache-control: max-age=0, no-cache=\"set-cookie\"\r\n" + + "Content-Length: 132868\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n" + + "Date: Sun, 05 Nov 2017 22:24:03 GMT\r\n" + + "Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips Communique/4.2.2\r\n" + + "Set-Cookie: AWSELB=AF7927F5100F4202119876ED2436B5005EE;PATH=/;MAX-AGE=900\r\n" + + "Vary: Host,Accept-Encoding,User-Agent\r\n" + + "X-Mod-Pagespeed: 1.12.34.2-0\r\n" + + "Connection: keep-alive\r\n\r\n" + }; + Arrays.stream(basic).forEach(responses::add); + // add some tests where some of the CRLF are replaced + // by a single LF + Arrays.stream(basic) + .map(HttpHeaderParserTest::mixedCRLF) + .forEach(responses::add); + + String[] foldingTemplate = + { "HTTP/1.1 200 OK\r\n" + + "Content-Length: 9\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r' + " charset=UTF-8\r\n" + // one preceding SP + "Connection: close\r\n\r\n" + + "XXYYZZAABBCCDDEE", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 19\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r + " charset=UTF-8\r\n" + // more than one preceding SP + "Connection: keep-alive\r\n\r\n" + + "XXYYZZAABBCCDDEEFFGG", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 999\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r + "\tcharset=UTF-8\r\n" + // one preceding HT + "Connection: close\r\n\r\n" + + "XXYYZZAABBCCDDEE", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 54\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r + "\t\t\tcharset=UTF-8\r\n" + // more than one preceding HT + "Connection: keep-alive\r\n\r\n" + + "XXYYZZAABBCCDDEEFFGG", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: -1\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r + "\t \t \tcharset=UTF-8\r\n" + // mix of preceding HT and SP + "Connection: keep-alive\r\n\r\n" + + "XXYYZZAABBCCDDEEFFGGHH", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 65\r\n" + + "Content-Type: text/html;$NEWLINE" + // folding field-value with '\n'|'\r + " \t \t charset=UTF-8\r\n" + // mix of preceding SP and HT + "Connection: keep-alive\r\n\r\n" + + "XXYYZZAABBCCDDEEFFGGHHII", + + "HTTP/1.1 401 Unauthorized\r\n" + + "WWW-Authenticate: Digest realm=\"wally land\"," + +"$NEWLINE domain=/," + +"$NEWLINE nonce=\"2B7F3A2B\"," + +"$NEWLINE\tqop=\"auth\"\r\n\r\n", + + }; + for (String newLineChar : new String[] { "\n", "\r", "\r\n" }) { + for (String template : foldingTemplate) + responses.add(template.replace("$NEWLINE", newLineChar)); + } + // add some tests where some of the CRLF are replaced + // by a single LF + for (String newLineChar : new String[] { "\n", "\r", "\r\n" }) { + for (String template : foldingTemplate) + responses.add(mixedCRLF(template).replace("$NEWLINE", newLineChar)); + } + + String[] bad = // much of this is to retain parity with legacy MessageHeaders + { "HTTP/1.1 200 OK\r\n" + + "Connection:\r\n\r\n", // empty value, no body + + "HTTP/1.1 200 OK\r\n" + + "Connection:\r\n\r\n" + // empty value, with body + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + ": no header\r\n\r\n", // no/empty header-name, no body, no following header + + "HTTP/1.1 200 OK\r\n" + + ": no; header\r\n" + // no/empty header-name, no body, following header + "Content-Length: 65\r\n\r\n", + + "HTTP/1.1 200 OK\r\n" + + ": no header\r\n" + // no/empty header-name + "Content-Length: 65\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "X-foo: bar\r\n" + + " : no header\r\n" + // fold, not a blank header-name + "Content-Length: 65\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "X-foo: bar\r\n" + + " \t : no header\r\n" + // fold, not a blank header-name + "Content-Length: 65\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + ": no header\r\n\r\n" + // no/empty header-name, followed by header + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Conte\r" + + "nt-Length: 9\r\n" + // fold/bad header name ??? without preceding space + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXXYYZZ", + + "HTTP/1.0 404 Not Found\r\n" + + "header-without-colon\r\n\r\n", + + "HTTP/1.0 404 Not Found\r\n" + + "header-without-colon\r\n\r\n" + + "SOMEBODY", + + }; + Arrays.stream(bad).forEach(responses::add); + + return responses.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); + } + + static final AtomicInteger index = new AtomicInteger(); + static final AtomicInteger limit = new AtomicInteger(1); + static final AtomicBoolean useCRLF = new AtomicBoolean(); + // A small method to replace part of the CRLF present in a string + // with simple LF. The method uses a deterministic algorithm based + // on current values of static index/limit/useCRLF counters. + // These counters are used to produce a stream of substitutes that + // looks like this: + // LF CRLF LF LF CRLF CRLF LF LF LF CRLF CRLF CRLF (then repeat from start) + static final String mixedCRLF(String headers) { + int next; + int start = 0; + int last = headers.lastIndexOf("\r\n"); + String prev = ""; + StringBuilder res = new StringBuilder(); + while ((next = headers.indexOf("\r\n", start)) > 0) { + res.append(headers.substring(start, next)); + if ("\n".equals(prev) && next == last) { + // for some reason the legacy MessageHeader parser will + // not consume the final LF if the headers are terminated + // by instead of . It consume + // but leaves the last in the stream. + // Here we just make sure to avoid using + // as that would cause the legacy parser to consume + // 1 byte less than the Http1HeadersParser - which + // does consume the last , as it should. + // if this is the last CRLF and the previous one + // was replaced by LF then use LF. + res.append(prev); + } else { + prev = useCRLF.get() ? "\r\n" : "\n"; + res.append(prev); + } + // skip CRLF + start = next + 2; + + // The idea is to substitute some of the CRLF with LF. + // Rather than doing this randomly, always use the following + // sequence: + // LF CRLF LF LF CRLF CRLF LF LF LF CRLF CRLF CRLF + index.incrementAndGet(); + if (index.get() == limit.get()) { + index.set(0); + if (useCRLF.get()) limit.incrementAndGet(); + if (limit.get() > 3) limit.set(1); + useCRLF.set(!useCRLF.get()); + } + } + res.append(headers.substring(start)); + return res.toString(); + } + + + @Test(dataProvider = "responses") + public void verifyHeaders(String respString) throws Exception { + System.out.println("\ntesting:\n\t" + respString + .replace("\r\n", "") + .replace("\r", "") + .replace("\n","") + .replace("LF>", "LF>\n\t")); + byte[] bytes = respString.getBytes(ISO_8859_1); + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + MessageHeader m = new MessageHeader(bais); + Map> messageHeaderMap = m.getHeaders(); + int availableBytes = bais.available(); + + HttpHeaderParser decoder = new HttpHeaderParser(); + ByteArrayInputStream headerStream = new ByteArrayInputStream(bytes); + int initialBytes = headerStream.available(); + decoder.parse(headerStream); + System.out.printf("HttpHeaderParser parsed %d bytes out of %d%n", initialBytes - headerStream.available(), bytes.length); + Map> decoderMap1 = decoder.getHeaderMap(); + + + // assert status-line + String statusLine1 = messageHeaderMap.get(null).get(0); + String statusLine2 = decoder.getRequestDetails(); + if (statusLine1.startsWith("HTTP")) {// skip the case where MH's messes up the status-line + assertEquals(statusLine2, statusLine1, "Status-line not equal"); + } else { + assertTrue(statusLine2.startsWith("HTTP/1."), "Status-line not HTTP/1."); + } + + // remove the null'th entry with is the status-line + Map> map = new HashMap<>(); + for (Map.Entry> e : messageHeaderMap.entrySet()) { + if (e.getKey() != null) { + map.put(e.getKey(), e.getValue()); + } + } + messageHeaderMap = map; + + assertHeadersEqual(messageHeaderMap, decoderMap1, + "messageHeaderMap not equal to decoderMap1"); + + assertEquals(availableBytes, headerStream.available(), + String.format("stream available (%d) not equal to remaining (%d)", + availableBytes, headerStream.available())); + } + + @DataProvider(name = "errors") + public Object[][] errors() { + List responses = new ArrayList<>(); + + // These responses are parsed, somewhat, by MessageHeaders but give + // nonsensible results. They, correctly, fail with the Http1HeaderParser. + String[] bad = + {// "HTTP/1.1 402 Payment Required\r\n" + + // "Content-Length: 65\r\n\r", // missing trailing LF //TODO: incomplete + + "HTTP/1.1 402 Payment Required\r\n" + + "Content-Length: 65\r\n\rT\r\n\r\nGGGGGG", + + "HTTP/1.1 200OK\r\n\rT", + + "HTTP/1.1 200OK\rT", + + "HTTP/1.0 FOO\r\n", + + "HTTP/1.1 BAR\r\n", + + "HTTP/1.1 +99\r\n", + + "HTTP/1.1 -22\r\n", + + "HTTP/1.1 -20 \r\n", + + "HTTP/1.1 200 OK\r\n" + + "X-fo\u00ffo: foo\r\n" + // invalid char in name + "Content-Length: 5\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "HTTP/1.1 200 OK\r\n" + + "X-foo : bar\r\n" + // trim space after name + "Content-Length: 5\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + " X-foo: bar\r\n" + // trim space before name + "Content-Length: 5\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "X foo: bar\r\n" + // invalid space in name + "Content-Length: 5\r\n" + + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Content-Length: 5\r\n" + + "Content Type: text/html; charset=UTF-8\r\n\r\n" + // invalid space in name + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + "Conte\r" + + " nt-Length: 9\r\n" + // fold results in space in header name + "Content-Type: text/html; charset=UTF-8\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + " : no header\r\n" + // all blank header-name (not fold) + "Content-Length: 65\r\n\r\n" + + "XXXXX", + + "HTTP/1.1 200 OK\r\n" + + " \t : no header\r\n" + // all blank header-name (not fold) + "Content-Length: 65\r\n\r\n" + + "XXXXX", + + }; + Arrays.stream(bad).forEach(responses::add); + + return responses.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); + } + + @Test(dataProvider = "errors", expectedExceptions = IOException.class) + public void errors(String respString) throws IOException { + byte[] bytes = respString.getBytes(US_ASCII); + HttpHeaderParser decoder = new HttpHeaderParser(); + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + decoder.parse(bais); + } + + void assertHeadersEqual(Map> expected, + Map> actual, + String msg) { + + if (expected.equals(actual)) + return; + + assertEquals(expected.size(), actual.size(), + format("%s. Expected size %d, actual size %s. %nexpected= %s,%n actual=%s.", + msg, expected.size(), actual.size(), mapToString(expected), mapToString(actual))); + + for (Map.Entry> e : expected.entrySet()) { + String key = e.getKey(); + List values = e.getValue(); + + boolean found = false; + for (Map.Entry> other: actual.entrySet()) { + if (key.equalsIgnoreCase(other.getKey())) { + found = true; + List otherValues = other.getValue(); + assertEquals(values.size(), otherValues.size(), + format("%s. Expected list size %d, actual size %s", + msg, values.size(), otherValues.size())); + if (!(values.containsAll(otherValues) && otherValues.containsAll(values))) + assertTrue(false, format("Lists are unequal [%s] [%s]", values, otherValues)); + break; + } + } + assertTrue(found, format("header name, %s, not found in %s", key, actual)); + } + } + + static String mapToString(Map> map) { + StringBuilder sb = new StringBuilder(); + List sortedKeys = new ArrayList(map.keySet()); + Collections.sort(sortedKeys); + for (String key : sortedKeys) { + List values = map.get(key); + sb.append("\n\t" + key + " | " + values); + } + return sb.toString(); + } +} diff --git a/test/jdk/sun/net/www/protocol/http/NTLMTest.java b/test/jdk/sun/net/www/protocol/http/NTLMTest.java index 73d0cb98603..37282f15b03 100644 --- a/test/jdk/sun/net/www/protocol/http/NTLMTest.java +++ b/test/jdk/sun/net/www/protocol/http/NTLMTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -24,7 +24,6 @@ /* * @test * @bug 6520665 6357133 - * @modules java.base/sun.net.www * @library /test/lib * @run main/othervm NTLMTest * @summary 6520665 & 6357133: NTLM authentication issues. @@ -32,7 +31,8 @@ import java.net.*; import java.io.*; -import sun.net.www.MessageHeader; + +import jdk.test.lib.net.HttpHeaderParser; import jdk.test.lib.net.URIBuilder; public class NTLMTest @@ -160,7 +160,7 @@ static void handleConnection(Socket s, String[] resp, int start, int end) { OutputStream os = s.getOutputStream(); for (int i=start; i server // client <--- 401 ---- server try (Socket s = ss.accept()) { - new MessageHeader().parseHeader(s.getInputStream()); + new HttpHeaderParser().parse(s.getInputStream()); s.getOutputStream().write(reply.getBytes("US-ASCII")); } @@ -171,10 +171,10 @@ static void test(String... schemes) throws IOException { // client <--- 200 ---- server String auth; try (Socket s = ss.accept()) { - MessageHeader mh = new MessageHeader(); - mh.parseHeader(s.getInputStream()); + HttpHeaderParser mh = new HttpHeaderParser(); + mh.parse(s.getInputStream()); s.getOutputStream().write(OKAY.getBytes("US-ASCII")); - auth = mh.findValue("Authorization"); + auth = mh.getHeaderValue("Authorization").get(0); } // check Authorization header @@ -208,7 +208,7 @@ static void testNTLM() throws Exception { // client ---- GET ---> server // client <--- 401 ---- client try (Socket s = ss.accept()) { - new MessageHeader().parseHeader(s.getInputStream()); + new HttpHeaderParser().parse(s.getInputStream()); s.getOutputStream().write(reply.getBytes("US-ASCII")); } diff --git a/test/jdk/sun/net/www/protocol/http/RetryUponTimeout.java b/test/jdk/sun/net/www/protocol/http/RetryUponTimeout.java index bfda1663259..b2214780c2e 100644 --- a/test/jdk/sun/net/www/protocol/http/RetryUponTimeout.java +++ b/test/jdk/sun/net/www/protocol/http/RetryUponTimeout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -26,13 +26,13 @@ * @bug 4772077 * @library /test/lib * @summary using defaultReadTimeout appear to retry request upon timeout - * @modules java.base/sun.net.www */ import java.net.*; import java.io.*; + +import jdk.test.lib.net.HttpHeaderParser; import jdk.test.lib.net.URIBuilder; -import sun.net.www.*; public class RetryUponTimeout implements Runnable { // run server @@ -42,7 +42,7 @@ public void run(){ for (int i = 0; i < 2; i++) { socket = server.accept(); InputStream is = socket.getInputStream (); - MessageHeader header = new MessageHeader (is); + HttpHeaderParser header = new HttpHeaderParser (is); count++; } } catch (Exception ex) { diff --git a/test/jdk/sun/net/www/protocol/http/UserAgent.java b/test/jdk/sun/net/www/protocol/http/UserAgent.java index 7db84882488..40ff5d3106f 100644 --- a/test/jdk/sun/net/www/protocol/http/UserAgent.java +++ b/test/jdk/sun/net/www/protocol/http/UserAgent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -25,7 +25,6 @@ * @test * @bug 4512200 * @library /test/lib - * @modules java.base/sun.net.www * @run main/othervm -Dhttp.agent=foo UserAgent * @run main/othervm -Dhttp.agent=foo -Djava.net.preferIPv6Addresses=true UserAgent * @summary HTTP header "User-Agent" format incorrect @@ -34,8 +33,9 @@ import java.io.*; import java.util.*; import java.net.*; + +import jdk.test.lib.net.HttpHeaderParser; import jdk.test.lib.net.URIBuilder; -import sun.net.www.MessageHeader; class Server extends Thread { Server (ServerSocket server) { @@ -46,8 +46,8 @@ public void run () { String version = System.getProperty ("java.version"); String expected = "foo Java/"+version; Socket s = server.accept (); - MessageHeader header = new MessageHeader (s.getInputStream()); - String v = header.findValue ("User-Agent"); + HttpHeaderParser header = new HttpHeaderParser (s.getInputStream()); + String v = header.getHeaderValue ("User-Agent").get(0); if (!expected.equals (v)) { error ("Got unexpected User-Agent: " + v); } else { diff --git a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java index ec75bcc3e11..9fca12c9958 100644 --- a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java +++ b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/B6226610.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -25,7 +25,7 @@ * @test * @bug 6226610 6973030 * @summary HTTP tunnel connections send user headers to proxy - * @modules java.base/sun.net.www + * @library /test/lib * @run main/othervm B6226610 */ @@ -37,7 +37,9 @@ import java.io.*; import java.net.*; -import sun.net.www.MessageHeader; + +import jdk.test.lib.net.HttpHeaderParser; + public class B6226610 { static HeaderCheckerProxyTunnelServer proxy; @@ -138,21 +140,21 @@ public int getLocalPort() { private void processRequests() throws IOException { InputStream in = clientSocket.getInputStream(); - MessageHeader mheader = new MessageHeader(in); - String statusLine = mheader.getValue(0); + HttpHeaderParser mheader = new HttpHeaderParser(in); + String statusLine = mheader.getRequestDetails(); if (statusLine.startsWith("CONNECT")) { // retrieve the host and port info from the status-line retrieveConnectInfo(statusLine); - if (mheader.findValue("X-TestHeader") != null) { + if (mheader.getHeaderValue("X-TestHeader") != null) { System.out.println("Proxy should not receive user defined headers for tunneled requests"); failed = true; } // 6973030 String value; - if ((value = mheader.findValue("Proxy-Connection")) == null || + if ((value = mheader.getHeaderValue("Proxy-Connection").get(0)) == null || !value.equals("keep-alive")) { System.out.println("Proxy-Connection:keep-alive not being sent"); failed = true; diff --git a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java index 5b6deec2512..43542941416 100644 --- a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java +++ b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -45,7 +45,8 @@ import java.util.Iterator; import java.util.Set; -import sun.net.www.MessageHeader; +import jdk.test.lib.net.HttpHeaderParser; + public class TunnelProxy { @@ -263,7 +264,7 @@ private boolean read (SocketChannel chan, SelectionKey key) { try { InputStream is = new BufferedInputStream (new NioInputStream (chan)); String requestline = readLine (is); - MessageHeader mhead = new MessageHeader (is); + HttpHeaderParser mhead = new HttpHeaderParser (is); String[] req = requestline.split (" "); if (req.length < 2) { /* invalid request line */ diff --git a/test/lib/jdk/test/lib/net/HttpHeaderParser.java b/test/lib/jdk/test/lib/net/HttpHeaderParser.java new file mode 100644 index 00000000000..9a55d28f4a9 --- /dev/null +++ b/test/lib/jdk/test/lib/net/HttpHeaderParser.java @@ -0,0 +1,390 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 jdk.test.lib.net; + +import java.io.IOException; +import java.io.InputStream; +import java.net.ProtocolException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import static java.util.Objects.requireNonNull; + +public class HttpHeaderParser { + private static final char CR = '\r'; + private static final char LF = '\n'; + private static final char HT = '\t'; + private static final char SP = ' '; + // ABNF primitives defined in RFC 7230 + private static boolean[] tchar = new boolean[256]; + private static boolean[] fieldvchar = new boolean[256]; + + static { + char[] allowedTokenChars = + ("!#$%&'*+-.^_`|~0123456789" + + "abcdefghijklmnopqrstuvwxyz" + + "ABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray(); + for (char c : allowedTokenChars) { + tchar[c] = true; + } + for (char c = 0x21; c <= 0xFF; c++) { + fieldvchar[c] = true; + } + fieldvchar[0x7F] = false; // a little hole (DEL) in the range + } + + private StringBuilder sb = new StringBuilder(); + + private Map > headerMap = new LinkedHashMap<>(); + private List keyList = new ArrayList<>(); + private String requestOrStatusLine; + private int responseCode; + private boolean eof; + + + + enum State { INITIAL, + STATUS_OR_REQUEST_LINE, + STATUS_OR_REQUEST_LINE_FOUND_CR, + STATUS_OR_REQUEST_LINE_FOUND_LF, + STATUS_OR_REQUEST_LINE_END, + STATUS_OR_REQUEST_LINE_END_CR, + STATUS_OR_REQUEST_LINE_END_LF, + HEADER, + HEADER_FOUND_CR, + HEADER_FOUND_LF, + HEADER_FOUND_CR_LF, + HEADER_FOUND_CR_LF_CR, + FINISHED } + + private HttpHeaderParser.State state = HttpHeaderParser.State.INITIAL; + + public HttpHeaderParser() { + } + + + public HttpHeaderParser(InputStream is) throws IOException, ProtocolException { + parse(is); + } + + public Map> getHeaderMap() { + return headerMap; + } + + public List getHeaderValue(String key) { + if(headerMap.containsKey(key.toLowerCase(Locale.ROOT))) { + return headerMap.get(key.toLowerCase(Locale.ROOT)); + } + return null; + } + public List getValue(int id) { + String key = keyList.get(id); + return headerMap.get(key); + } + + public String getRequestDetails() { + return requestOrStatusLine; + } + + /** + * Parses HTTP/1.X status-line or request-line and headers from the given input stream. + * @param input Containing the input stream of bytes representing request or response header data + * @return true if the end of the headers block has been reached + */ + public boolean parse(InputStream input) throws IOException { + requireNonNull(input, "null input"); + while (canContinueParsing()) { + switch (state) { + case INITIAL : state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE; break; + case STATUS_OR_REQUEST_LINE : readResumeStatusLine(input); break; + case STATUS_OR_REQUEST_LINE_FOUND_CR: case STATUS_OR_REQUEST_LINE_FOUND_LF : readStatusLineFeed(input); break; + case STATUS_OR_REQUEST_LINE_END : maybeStartHeaders(input); break; + case STATUS_OR_REQUEST_LINE_END_CR: case STATUS_OR_REQUEST_LINE_END_LF : maybeEndHeaders(input); break; + case HEADER : readResumeHeader(input); break; + case HEADER_FOUND_CR: case HEADER_FOUND_LF : resumeOrLF(input); break; + case HEADER_FOUND_CR_LF : resumeOrSecondCR(input); break; + case HEADER_FOUND_CR_LF_CR : resumeOrEndHeaders(input); break; + default : throw new InternalError("Unexpected state: " + state); + } + } + return state == HttpHeaderParser.State.FINISHED; + } + + private boolean canContinueParsing() { + // some states don't require any input to transition + // to the next state. + switch (state) { + case FINISHED : return false; + case STATUS_OR_REQUEST_LINE_FOUND_LF: STATUS_OR_REQUEST_LINE_END_LF: HEADER_FOUND_LF : return true; + default : return !eof; + } + } + + /** + * Returns a character (char) corresponding to the next byte in the + * input, interpreted as an ISO-8859-1 encoded character. + *

    + * The ISO-8859-1 encoding is a 8-bit character coding that + * corresponds to the first 256 Unicode characters - from U+0000 to + * U+00FF. UTF-16 is backward compatible with ISO-8859-1 - which + * means each byte in the input should be interpreted as an unsigned + * value from [0, 255] representing the character code. + * + * @param input a {@code InputStream} containing input stream of Bytes. + * @return the next byte in the input, interpreted as an ISO-8859-1 + * encoded char + * @throws IOException + * if an I/O error occurs. + */ + private char get(InputStream input) throws IOException { + int c = input.read(); + if(c < 0) + eof = true; + return (char)(c & 0xFF); + } + + private void readResumeStatusLine(InputStream input) throws IOException { + char c; + while ((c = get(input)) != CR && !eof) { + if (c == LF) break; + sb.append(c); + } + if (c == CR) { + state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_FOUND_CR; + } else if (c == LF) { + state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_FOUND_LF; + } + } + + private void readStatusLineFeed(InputStream input) throws IOException { + char c = state == HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_FOUND_LF ? LF : get(input); + if (c != LF) { + throw protocolException("Bad trailing char, \"%s\", when parsing status line, \"%s\"", + c, sb.toString()); + } + requestOrStatusLine = sb.toString(); + sb = new StringBuilder(); + if (!requestOrStatusLine.startsWith("HTTP/1.")) { + if(!requestOrStatusLine.startsWith("GET") && !requestOrStatusLine.startsWith("POST") && + !requestOrStatusLine.startsWith("PUT") && !requestOrStatusLine.startsWith("DELETE") && + !requestOrStatusLine.startsWith("OPTIONS") && !requestOrStatusLine.startsWith("HEAD") && + !requestOrStatusLine.startsWith("PATCH") && !requestOrStatusLine.startsWith("CONNECT")) { + throw protocolException("Invalid request Or Status line: \"%s\"", requestOrStatusLine); + } else { //This is request + System.out.println("Request is :"+requestOrStatusLine); + } + } else { //This is response + if (requestOrStatusLine.length() < 12) { + throw protocolException("Invalid status line: \"%s\"", requestOrStatusLine); + } + try { + responseCode = Integer.parseInt(requestOrStatusLine.substring(9, 12)); + } catch (NumberFormatException nfe) { + throw protocolException("Invalid status line: \"%s\"", requestOrStatusLine); + } + // response code expected to be a 3-digit integer (RFC-2616, section 6.1.1) + if (responseCode < 100) { + throw protocolException("Invalid status line: \"%s\"", requestOrStatusLine); + } + } + state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END; + } + + private void maybeStartHeaders(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END; + assert sb.length() == 0; + char c = get(input); + if(!eof) { + if (c == CR) { + state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END_CR; + } else if (c == LF) { + state = HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END_LF; + } else { + sb.append(c); + state = HttpHeaderParser.State.HEADER; + } + } + } + + private void maybeEndHeaders(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END_CR || state == HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END_LF; + assert sb.length() == 0; + char c = state == HttpHeaderParser.State.STATUS_OR_REQUEST_LINE_END_LF ? LF : get(input); + if (c == LF) { + state = HttpHeaderParser.State.FINISHED; // no headers + } else { + throw protocolException("Unexpected \"%s\", after status line CR", c); + } + } + + private void readResumeHeader(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.HEADER; + assert !eof; + char c = get(input); + while (!eof) { + if (c == CR) { + state = HttpHeaderParser.State.HEADER_FOUND_CR; + break; + } else if (c == LF) { + state = HttpHeaderParser.State.HEADER_FOUND_LF; + break; + } + if (c == HT) + c = SP; + sb.append(c); + c = get(input); + } + } + + private void addHeaderFromString(String headerString) throws ProtocolException { + assert sb.length() == 0; + int idx = headerString.indexOf(':'); + if (idx == -1) + return; + String name = headerString.substring(0, idx); + + // compatibility with HttpURLConnection; + if (name.isEmpty()) return; + + if (!isValidName(name)) { + throw protocolException("Invalid header name \"%s\"", name); + } + String value = headerString.substring(idx + 1).trim(); + if (!isValidValue(value)) { + throw protocolException("Invalid header value \"%s: %s\"", name, value); + } + + keyList.add(name); + headerMap.computeIfAbsent(name.toLowerCase(Locale.US), + k -> new ArrayList<>()).add(value); + } + + private void resumeOrLF(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.HEADER_FOUND_CR || state == HttpHeaderParser.State.HEADER_FOUND_LF; + char c = state == HttpHeaderParser.State.HEADER_FOUND_LF ? LF : get(input); + if (!eof) { + if (c == LF) { + state = HttpHeaderParser.State.HEADER_FOUND_CR_LF; + } else if (c == SP || c == HT) { + sb.append(SP); // parity with MessageHeaders + state = HttpHeaderParser.State.HEADER; + } else { + sb = new StringBuilder(); + sb.append(c); + state = HttpHeaderParser.State.HEADER; + } + } + } + + private void resumeOrSecondCR(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.HEADER_FOUND_CR_LF; + char c = get(input); + if (!eof) { + if (c == CR || c == LF) { + if (sb.length() > 0) { + // no continuation line - flush + // previous header value. + String headerString = sb.toString(); + sb = new StringBuilder(); + addHeaderFromString(headerString); + } + if (c == CR) { + state = HttpHeaderParser.State.HEADER_FOUND_CR_LF_CR; + } else { + state = HttpHeaderParser.State.FINISHED; + } + } else if (c == SP || c == HT) { + assert sb.length() != 0; + sb.append(SP); // continuation line + state = HttpHeaderParser.State.HEADER; + } else { + if (sb.length() > 0) { + // no continuation line - flush + // previous header value. + String headerString = sb.toString(); + sb = new StringBuilder(); + addHeaderFromString(headerString); + } + sb.append(c); + state = HttpHeaderParser.State.HEADER; + } + } + } + + private void resumeOrEndHeaders(InputStream input) throws IOException { + assert state == HttpHeaderParser.State.HEADER_FOUND_CR_LF_CR; + char c = get(input); + if (!eof) { + if (c == LF) { + state = HttpHeaderParser.State.FINISHED; + } else { + throw protocolException("Unexpected \"%s\", after CR LF CR", c); + } + } + } + + private ProtocolException protocolException(String format, Object ... args) { + return new ProtocolException(String.format(format, args)); + } + + /* + * Validates a RFC 7230 field-name. + */ + public boolean isValidName(String token) { + for (int i = 0; i < token.length(); i++) { + char c = token.charAt(i); + if (c > 255 || !tchar[c]) { + return false; + } + } + return !token.isEmpty(); + } + + /* + * Validates a RFC 7230 field-value. + * + * "Obsolete line folding" rule + * + * obs-fold = CRLF 1*( SP / HTAB ) + * + * is not permitted! + */ + public boolean isValidValue(String token) { + for (int i = 0; i < token.length(); i++) { + char c = token.charAt(i); + if (c > 255) { + return false; + } + if (c == ' ' || c == '\t') { + continue; + } else if (!fieldvchar[c]) { + return false; // forbidden byte + } + } + return true; + } +} From 4daa077a4f17729d46497bcd1dcc52bcea7ac6db Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 9 Apr 2024 18:22:28 +0000 Subject: [PATCH 079/149] 8315834: Open source several Swing JSpinner related tests Backport-of: 4a63eb05221c1829b157a025a4d35cdd77a9fe04 --- test/jdk/javax/swing/JSpinner/bug4522737.java | 51 ++++++++ test/jdk/javax/swing/JSpinner/bug4656590.java | 117 ++++++++++++++++++ test/jdk/javax/swing/JSpinner/bug4680204.java | 116 +++++++++++++++++ test/jdk/javax/swing/JSpinner/bug4862257.java | 40 ++++++ test/jdk/javax/swing/JSpinner/bug5104421.java | 46 +++++++ 5 files changed, 370 insertions(+) create mode 100644 test/jdk/javax/swing/JSpinner/bug4522737.java create mode 100644 test/jdk/javax/swing/JSpinner/bug4656590.java create mode 100644 test/jdk/javax/swing/JSpinner/bug4680204.java create mode 100644 test/jdk/javax/swing/JSpinner/bug4862257.java create mode 100644 test/jdk/javax/swing/JSpinner/bug5104421.java diff --git a/test/jdk/javax/swing/JSpinner/bug4522737.java b/test/jdk/javax/swing/JSpinner/bug4522737.java new file mode 100644 index 00000000000..60ea8d5c10f --- /dev/null +++ b/test/jdk/javax/swing/JSpinner/bug4522737.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ + +import javax.swing.JComponent; +import javax.swing.JSpinner; +import java.io.ByteArrayOutputStream; +import java.io.ObjectOutputStream; + +/* + * @test + * @bug 4522737 + * @summary Cannot serialize JSpinner twice. + * @run main bug4522737 + */ + +public class bug4522737 { + public static void main(String[] args) throws Exception { + final JComponent originalComponent = new JSpinner(); + + ByteArrayOutputStream byteArrayOutputStream = + new ByteArrayOutputStream(); + ObjectOutputStream objectOutputStream = + new ObjectOutputStream(byteArrayOutputStream); + objectOutputStream.writeObject(originalComponent); + + objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); + objectOutputStream.writeObject(originalComponent); + + System.out.println("Test Passed!"); + } +} diff --git a/test/jdk/javax/swing/JSpinner/bug4656590.java b/test/jdk/javax/swing/JSpinner/bug4656590.java new file mode 100644 index 00000000000..b2cfd3123ee --- /dev/null +++ b/test/jdk/javax/swing/JSpinner/bug4656590.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JSpinner; +import javax.swing.SpinnerDateModel; +import javax.swing.SpinnerListModel; +import javax.swing.SpinnerNumberModel; +import javax.swing.SwingUtilities; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.Robot; + +/* + * @test + * @bug 4656590 + * @summary JSpinner.setFont() does nothing + * @key headful + * @run main bug4656590 + */ + +public class bug4656590 { + private static JSpinner[] spinner = new JSpinner[6]; + private static Font font = new Font("Arial", Font.BOLD, 24); + private static volatile boolean failed = false; + private static JFrame frame; + private static Robot robot; + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame(); + frame.getContentPane().setLayout(new GridLayout(3, 2)); + spinner[0] = new JSpinner(); + spinner[0].setModel(new SpinnerNumberModel()); + spinner[0].setFont(font); + frame.getContentPane().add(spinner[0]); + + spinner[1] = new JSpinner(); + spinner[1].setModel(new SpinnerDateModel()); + spinner[1].setFont(font); + frame.getContentPane().add(spinner[1]); + + spinner[2] = new JSpinner(); + spinner[2].setModel(new SpinnerListModel + (new Object[]{"one", "two", "three"})); + spinner[2].setFont(font); + frame.getContentPane().add(spinner[2]); + + spinner[3] = new JSpinner(); + spinner[3].setFont(font); + spinner[3].setModel(new SpinnerNumberModel()); + frame.getContentPane().add(spinner[3]); + + spinner[4] = new JSpinner(); + spinner[4].setFont(font); + spinner[4].setModel(new SpinnerDateModel()); + frame.getContentPane().add(spinner[4]); + + spinner[5] = new JSpinner(); + spinner[5].setFont(font); + spinner[5].setModel(new SpinnerListModel + (new Object[]{"one", "two", "three"})); + frame.getContentPane().add(spinner[5]); + frame.pack(); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + JFormattedTextField ftf; + for (int i = 1; i < 6; i++) { + ftf = ((JSpinner.DefaultEditor) + spinner[i].getEditor()).getTextField(); + if (!ftf.getFont().equals(font)) { + failed = true; + } + } + }); + robot.waitForIdle(); + robot.delay(1000); + if (failed) { + throw new RuntimeException("JSpinner.setFont() " + + "doesn't set the font properly"); + } + System.out.println("Test Passed!"); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} diff --git a/test/jdk/javax/swing/JSpinner/bug4680204.java b/test/jdk/javax/swing/JSpinner/bug4680204.java new file mode 100644 index 00000000000..ecd923f2a4d --- /dev/null +++ b/test/jdk/javax/swing/JSpinner/bug4680204.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JSpinner; +import javax.swing.JTextField; +import javax.swing.SpinnerNumberModel; +import javax.swing.SwingUtilities; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.Robot; + +/* + * @test + * @bug 4680204 + * @summary JSpinner shows ToolTipText only on it's border + * @key headful + * @run main bug4680204 + */ + +public class bug4680204 { + + private static JSpinner sp1, sp2; + private static final String TOOL_TIP_TEXT = "ToolTipText"; + private static JFrame frame; + private static Robot robot; + private static volatile boolean failed = false; + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame(); + frame.getContentPane().setLayout(new FlowLayout()); + + sp1 = new JSpinner(new SpinnerNumberModel(1, 1, 100, 1)); + sp1.setToolTipText(TOOL_TIP_TEXT); + frame.getContentPane().add(sp1); + + sp2 = new JSpinner(); + sp2.setToolTipText(TOOL_TIP_TEXT); + frame.getContentPane().add(sp2); + sp2.setModel(new SpinnerNumberModel(1, 1, 100, 1)); + frame.setLocationRelativeTo(null); + frame.pack(); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + Component[] children = sp1.getComponents(); + for (int i = 0; i < children.length; i++) { + if (children[i] instanceof JSpinner.DefaultEditor) { + JTextField tf = ((JSpinner.DefaultEditor) children[i]).getTextField(); + if (!TOOL_TIP_TEXT.equals(tf.getToolTipText())) { + failed = true; + } + } else if (children[i] instanceof JComponent) { + String text = ((JComponent) children[i]).getToolTipText(); + if (!TOOL_TIP_TEXT.equals(text)) { + failed = true; + } + } + } + + children = sp2.getComponents(); + for (int i = 0; i < children.length; i++) { + if (children[i] instanceof JSpinner.DefaultEditor) { + JTextField tf = ((JSpinner.DefaultEditor) children[i]).getTextField(); + if (!TOOL_TIP_TEXT.equals(tf.getToolTipText())) { + failed = true; + } + } else if (children[i] instanceof JComponent) { + String text = ((JComponent) children[i]).getToolTipText(); + if (!TOOL_TIP_TEXT.equals(text)) { + failed = true; + } + } + } + }); + robot.waitForIdle(); + robot.delay(1000); + if (failed) { + throw new RuntimeException("The tooltip text is not correctly set for JSpinner"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + System.out.println("Test Passed!"); + } +} diff --git a/test/jdk/javax/swing/JSpinner/bug4862257.java b/test/jdk/javax/swing/JSpinner/bug4862257.java new file mode 100644 index 00000000000..b87b7b359a3 --- /dev/null +++ b/test/jdk/javax/swing/JSpinner/bug4862257.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +import javax.swing.JButton; +import javax.swing.JSpinner; + +/* + * @test + * @bug 4862257 + * @summary Class cast Exception occurred when JButton is set to JSpinner + * @run main bug4862257 + */ + +public class bug4862257 { + public static void main(String[] argv) { + JSpinner spinner = new JSpinner(); + spinner.setEditor(new JButton("JButton")); + System.out.println("Test Passed!"); + } +} diff --git a/test/jdk/javax/swing/JSpinner/bug5104421.java b/test/jdk/javax/swing/JSpinner/bug5104421.java new file mode 100644 index 00000000000..cad5d8c9e0a --- /dev/null +++ b/test/jdk/javax/swing/JSpinner/bug5104421.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2004, 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. + * + * 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. + */ + +import javax.swing.SpinnerDateModel; + +/* + * @test + * @bug 5104421 + * @summary SpinnerDateModel.setValue(Object) throws exception with incorrect message + * @run main bug5104421 + */ + +public class bug5104421 { + public static void main(String[] args) { + SpinnerDateModel model = new SpinnerDateModel(); + try { + model.setValue(Integer.valueOf(42)); + } catch (IllegalArgumentException e) { + if (e.getMessage().toLowerCase().indexOf("null value") != -1) { + throw new RuntimeException("SpinnerDateModel.setValue(Object) throws " + + "exception with incorrect message"); + } + } + System.out.println("Test Passed!"); + } +} From 4941b84aa1f08a2e6aac74360815279f7684cf57 Mon Sep 17 00:00:00 2001 From: Soumadipta Roy Date: Thu, 11 Apr 2024 07:09:48 +0000 Subject: [PATCH 080/149] 8316608: Enable parallelism in vmTestbase/gc/vector tests Backport-of: f61499c73fe03e2e3680d7f58a84183364c5c5ac --- .../vector/CircularListHigh/TEST.properties | 23 ------------------- .../gc/vector/CircularListLow/TEST.properties | 23 ------------------- .../gc/vector/DoubleArrayHigh/TEST.properties | 23 ------------------- .../gc/vector/DoubleArrayLow/TEST.properties | 23 ------------------- .../gc/vector/FloatArrayHigh/TEST.properties | 23 ------------------- .../gc/vector/FloatArrayLow/TEST.properties | 23 ------------------- .../gc/vector/LinearListHigh/TEST.properties | 23 ------------------- .../gc/vector/LinearListLow/TEST.properties | 23 ------------------- .../vector/NonbranchyTreeHigh/TEST.properties | 23 ------------------- .../vector/NonbranchyTreeLow/TEST.properties | 23 ------------------- .../gc/vector/ObjectArrayHigh/TEST.properties | 23 ------------------- .../gc/vector/ObjectArrayLow/TEST.properties | 23 ------------------- .../gc/vector/SimpleGC/TEST.properties | 23 ------------------- 13 files changed, 299 deletions(-) delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/CircularListHigh/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/CircularListLow/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/DoubleArrayHigh/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/DoubleArrayLow/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/FloatArrayHigh/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/FloatArrayLow/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/LinearListHigh/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/LinearListLow/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/NonbranchyTreeHigh/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/NonbranchyTreeLow/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/ObjectArrayHigh/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/ObjectArrayLow/TEST.properties delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/vector/SimpleGC/TEST.properties diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/CircularListHigh/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/CircularListHigh/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/CircularListHigh/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/CircularListLow/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/CircularListLow/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/CircularListLow/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/DoubleArrayHigh/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/DoubleArrayHigh/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/DoubleArrayHigh/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/DoubleArrayLow/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/DoubleArrayLow/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/DoubleArrayLow/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/FloatArrayHigh/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/FloatArrayHigh/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/FloatArrayHigh/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/FloatArrayLow/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/FloatArrayLow/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/FloatArrayLow/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/LinearListHigh/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/LinearListHigh/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/LinearListHigh/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/LinearListLow/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/LinearListLow/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/LinearListLow/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/NonbranchyTreeHigh/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/NonbranchyTreeHigh/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/NonbranchyTreeHigh/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/NonbranchyTreeLow/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/NonbranchyTreeLow/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/NonbranchyTreeLow/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/ObjectArrayHigh/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/ObjectArrayHigh/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/ObjectArrayHigh/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/ObjectArrayLow/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/ObjectArrayLow/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/ObjectArrayLow/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. diff --git a/test/hotspot/jtreg/vmTestbase/gc/vector/SimpleGC/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/vector/SimpleGC/TEST.properties deleted file mode 100644 index 04b22a107ac..00000000000 --- a/test/hotspot/jtreg/vmTestbase/gc/vector/SimpleGC/TEST.properties +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2017, 2018, 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. -# -# 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. -# -exclusiveAccess.dirs=. From 8e6a71d9ba4d5aab41600b488b7bf4737f6a33ae Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Mon, 15 Apr 2024 07:41:24 +0000 Subject: [PATCH 081/149] 8299858: [Metrics] Swap memory limit reported incorrectly when too large Backport-of: 64ddf9536f55fb81956ebde6dfc0a3c4147af371 --- .../jdk/internal/platform/CgroupMetrics.java | 15 ++++++- .../linux/native/libjava/CgroupMetrics.c | 13 ++++++ .../docker/TestMemoryAwareness.java | 42 ++++++++++++++++++- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/java.base/linux/classes/jdk/internal/platform/CgroupMetrics.java b/src/java.base/linux/classes/jdk/internal/platform/CgroupMetrics.java index 8f0ac0102b0..8797711bf4b 100644 --- a/src/java.base/linux/classes/jdk/internal/platform/CgroupMetrics.java +++ b/src/java.base/linux/classes/jdk/internal/platform/CgroupMetrics.java @@ -122,9 +122,11 @@ public long getMemoryFailCount() { @Override public long getMemoryLimit() { long subsMem = subsystem.getMemoryLimit(); + long systemTotal = getTotalMemorySize0(); + assert(systemTotal > 0); // Catch the cgroup memory limit exceeding host physical memory. // Treat this as unlimited. - if (subsMem >= getTotalMemorySize0()) { + if (subsMem >= systemTotal) { return CgroupSubsystem.LONG_RETVAL_UNLIMITED; } return subsMem; @@ -142,7 +144,15 @@ public long getTcpMemoryUsage() { @Override public long getMemoryAndSwapLimit() { - return subsystem.getMemoryAndSwapLimit(); + long totalSystemMemSwap = getTotalMemorySize0() + getTotalSwapSize0(); + assert(totalSystemMemSwap > 0); + // Catch the cgroup memory and swap limit exceeding host physical swap + // and memory. Treat this case as unlimited. + long subsSwapMem = subsystem.getMemoryAndSwapLimit(); + if (subsSwapMem >= totalSystemMemSwap) { + return CgroupSubsystem.LONG_RETVAL_UNLIMITED; + } + return subsSwapMem; } @Override @@ -185,5 +195,6 @@ public static Metrics getInstance() { private static native boolean isUseContainerSupport(); private static native long getTotalMemorySize0(); + private static native long getTotalSwapSize0(); } diff --git a/src/java.base/linux/native/libjava/CgroupMetrics.c b/src/java.base/linux/native/libjava/CgroupMetrics.c index d9bb7369f1d..4f7847edbde 100644 --- a/src/java.base/linux/native/libjava/CgroupMetrics.c +++ b/src/java.base/linux/native/libjava/CgroupMetrics.c @@ -23,6 +23,7 @@ * questions. */ #include +#include #include "jni.h" #include "jvm.h" @@ -43,3 +44,15 @@ Java_jdk_internal_platform_CgroupMetrics_getTotalMemorySize0 jlong page_size = sysconf(_SC_PAGESIZE); return pages * page_size; } + +JNIEXPORT jlong JNICALL +Java_jdk_internal_platform_CgroupMetrics_getTotalSwapSize0 + (JNIEnv *env, jclass ignored) +{ + struct sysinfo si; + int retval = sysinfo(&si); + if (retval < 0) { + return 0; // syinfo failed, treat as no swap + } + return (jlong)si.totalswap; +} diff --git a/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java b/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java index ae364bb37b6..a8e67576d21 100644 --- a/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java +++ b/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java @@ -37,6 +37,7 @@ * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm -Xbootclasspath/a:whitebox.jar -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestMemoryAwareness */ +import java.util.function.Consumer; import jdk.test.lib.containers.docker.Common; import jdk.test.lib.containers.docker.DockerRunOptions; import jdk.test.lib.containers.docker.DockerTestUtils; @@ -96,7 +97,9 @@ public static void main(String[] args) throws Exception { true /* additional cgroup fs mounts */ ); testOSMXBeanIgnoresMemLimitExceedingPhysicalMemory(); + testOSMXBeanIgnoresSwapLimitExceedingPhysical(); testMetricsExceedingPhysicalMemory(); + testMetricsSwapExceedingPhysical(); testContainerMemExceedsPhysical(); } finally { if (!DockerTestUtils.RETAIN_IMAGE_AFTER_TEST) { @@ -183,6 +186,13 @@ private static void testOperatingSystemMXBeanAwareness(String memoryAllocation, private static void testOperatingSystemMXBeanAwareness(String memoryAllocation, String expectedMemory, String swapAllocation, String expectedSwap, boolean addCgroupMounts) throws Exception { + Consumer noOp = o -> {}; + testOperatingSystemMXBeanAwareness(memoryAllocation, expectedMemory, swapAllocation, expectedSwap, false, noOp); + } + + private static void testOperatingSystemMXBeanAwareness(String memoryAllocation, String expectedMemory, + String swapAllocation, String expectedSwap, boolean addCgroupMounts, + Consumer additionalMatch) throws Exception { Common.logNewTestCase("Check OperatingSystemMXBean"); @@ -191,6 +201,7 @@ private static void testOperatingSystemMXBeanAwareness(String memoryAllocation, "--memory", memoryAllocation, "--memory-swap", swapAllocation ) + .addJavaOpts("-esa") // CheckOperatingSystemMXBean uses Metrics (jdk.internal.platform) for // diagnostics .addJavaOpts("--add-exports") @@ -224,9 +235,9 @@ private static void testOperatingSystemMXBeanAwareness(String memoryAllocation, } catch(RuntimeException ex) { out.shouldMatch("OperatingSystemMXBean\\.getFreeSwapSpaceSize: 0"); } + additionalMatch.accept(out); } - // JDK-8292541: Ensure OperatingSystemMXBean ignores container memory limits above the host's physical memory. private static void testOSMXBeanIgnoresMemLimitExceedingPhysicalMemory() throws Exception { @@ -235,6 +246,35 @@ private static void testOSMXBeanIgnoresMemLimitExceedingPhysicalMemory() testOperatingSystemMXBeanAwareness(badMem, hostMaxMem, badMem, hostMaxMem); } + private static void testOSMXBeanIgnoresSwapLimitExceedingPhysical() + throws Exception { + long totalSwap = wb.hostPhysicalSwap() + wb.hostPhysicalMemory(); + String expectedSwap = Long.valueOf(totalSwap).toString(); + String hostMaxMem = getHostMaxMemory(); + String badMem = hostMaxMem + "0"; + final String badSwap = expectedSwap + "0"; + testOperatingSystemMXBeanAwareness(badMem, hostMaxMem, badSwap, expectedSwap, false, o -> { + o.shouldNotContain("Metrics.getMemoryAndSwapLimit() == " + badSwap); + }); + } + + private static void testMetricsSwapExceedingPhysical() + throws Exception { + Common.logNewTestCase("Metrics ignore container swap memory limit exceeding physical"); + long totalSwap = wb.hostPhysicalSwap() + wb.hostPhysicalMemory(); + String expectedSwap = Long.valueOf(totalSwap).toString(); + final String badSwap = expectedSwap + "0"; + String badMem = getHostMaxMemory() + "0"; + DockerRunOptions opts = Common.newOpts(imageName) + .addJavaOpts("-XshowSettings:system") + .addDockerOpts("--memory", badMem) + .addDockerOpts("--memory-swap", badSwap); + + OutputAnalyzer out = DockerTestUtils.dockerRunJava(opts); + out.shouldContain("Memory Limit: Unlimited"); + out.shouldContain("Memory & Swap Limit: Unlimited"); + } + // JDK-8292541: Ensure Metrics ignores container memory limits above the host's physical memory. private static void testMetricsExceedingPhysicalMemory() throws Exception { From f9a672abaf15a4cf999bd66700218679f0cb7ad6 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 16 Apr 2024 01:57:38 +0000 Subject: [PATCH 082/149] 8328540: test javax/swing/JSplitPane/4885629/bug4885629.java fails on windows hidpi Backport-of: fa823bd21c6676c67c42275efb59868200409b38 --- test/jdk/javax/swing/JSplitPane/4885629/bug4885629.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/jdk/javax/swing/JSplitPane/4885629/bug4885629.java b/test/jdk/javax/swing/JSplitPane/4885629/bug4885629.java index c7e980081cf..fa6c1f21063 100644 --- a/test/jdk/javax/swing/JSplitPane/4885629/bug4885629.java +++ b/test/jdk/javax/swing/JSplitPane/4885629/bug4885629.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ -104,9 +104,9 @@ public void run() { SwingUtilities.convertPointToScreen(p, sp); - for (int i = 0; i < rect.width; i++) { + for (int i = 1; i < rect.width - 1; i++) { if (!BGCOLOR.equals(robot.getPixelColor(p.x + i, p.y + rect.height - 1))) { - throw new Error("The divider's area has incorrect color."); + throw new Error("The divider's area has incorrect color. i=" + i); } } } From 06cca199fe70da2ec452872ba12d4b080884c67e Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Tue, 16 Apr 2024 11:53:21 +0000 Subject: [PATCH 083/149] 8324598: use mem_unit when working with sysinfo memory and swap related information Backport-of: 7a798d3cebea0915f8a73af57333b3488c2091af --- src/hotspot/os/linux/os_linux.cpp | 2 +- src/java.base/linux/native/libjava/CgroupMetrics.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 0af357ea563..c1cf8619b67 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -368,7 +368,7 @@ pid_t os::Linux::gettid() { julong os::Linux::host_swap() { struct sysinfo si; sysinfo(&si); - return (julong)si.totalswap; + return (julong)(si.totalswap * si.mem_unit); } // Most versions of linux have a bug where the number of processors are diff --git a/src/java.base/linux/native/libjava/CgroupMetrics.c b/src/java.base/linux/native/libjava/CgroupMetrics.c index 4f7847edbde..a5e41167bc3 100644 --- a/src/java.base/linux/native/libjava/CgroupMetrics.c +++ b/src/java.base/linux/native/libjava/CgroupMetrics.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Red Hat, Inc. + * Copyright (c) 2020, 2024, Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,5 +54,5 @@ Java_jdk_internal_platform_CgroupMetrics_getTotalSwapSize0 if (retval < 0) { return 0; // syinfo failed, treat as no swap } - return (jlong)si.totalswap; + return (jlong)(si.totalswap * si.mem_unit); } From b39a4d24c51c2379ff82d5e46e185a6d2039ad72 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 16 Apr 2024 12:01:12 +0000 Subject: [PATCH 084/149] 8256660: Disable DTLS 1.0 Reviewed-by: mbaesken Backport-of: 16744b34498e7aac59caef8c9b1a3d4d15f8c22e --- .../sun/security/ssl/SSLContextImpl.java | 6 +- .../share/conf/security/java.security | 4 +- .../javax/net/ssl/DTLS/InvalidRecords.java | 3 + .../net/ssl/DTLS/NoMacInitialClientHello.java | 4 ++ .../ssl/SSLContextImpl/SSLContextDefault.java | 70 +++++++++++++------ 5 files changed, 58 insertions(+), 29 deletions(-) diff --git a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java index e06b2a588cc..3585f9140a8 100644 --- a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java +++ b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java @@ -1344,7 +1344,7 @@ List getClientDefaultCipherSuites() { } /* - * The SSLContext implementation for customized TLS protocols + * The SSLContext implementation for customized DTLS protocols * * @see SSLContext */ @@ -1402,13 +1402,11 @@ private static List customizedProtocols(boolean client, ProtocolVersion.DTLS12, ProtocolVersion.DTLS10 }; - if (!client) - return Arrays.asList(candidates); } else { // Use the customized TLS protocols. candidates = new ProtocolVersion[customized.size()]; - candidates = customized.toArray(candidates); + candidates = refactored.toArray(candidates); } return getAvailableProtocols(candidates); diff --git a/src/java.base/share/conf/security/java.security b/src/java.base/share/conf/security/java.security index c871d72bd51..087b81b9fe9 100644 --- a/src/java.base/share/conf/security/java.security +++ b/src/java.base/share/conf/security/java.security @@ -756,8 +756,8 @@ jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \ # Example: # jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048, \ # rsa_pkcs1_sha1, secp224r1 -jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, \ - DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \ +jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, DTLSv1.0, RC4, DES, \ + MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \ include jdk.disabled.namedCurves # diff --git a/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java b/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java index 304cb0695d6..53b50bd7464 100644 --- a/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java +++ b/test/jdk/javax/net/ssl/DTLS/InvalidRecords.java @@ -38,6 +38,8 @@ import java.net.SocketAddress; import java.util.concurrent.atomic.AtomicBoolean; +import jdk.test.lib.security.SecurityUtils; + /** * Test that if handshake messages are changed, the handshake would fail * because of handshaking hash verification. @@ -46,6 +48,7 @@ public class InvalidRecords extends DTLSOverDatagram { private static final AtomicBoolean needInvalidRecords = new AtomicBoolean(true); public static void main(String[] args) throws Exception { + SecurityUtils.removeFromDisabledTlsAlgs("DTLSv1.0"); InvalidRecords testCase = new InvalidRecords(); testCase.runTest(testCase); diff --git a/test/jdk/javax/net/ssl/DTLS/NoMacInitialClientHello.java b/test/jdk/javax/net/ssl/DTLS/NoMacInitialClientHello.java index 2263ee2a5a6..40de51e1952 100644 --- a/test/jdk/javax/net/ssl/DTLS/NoMacInitialClientHello.java +++ b/test/jdk/javax/net/ssl/DTLS/NoMacInitialClientHello.java @@ -38,6 +38,9 @@ import java.net.DatagramPacket; import java.net.SocketAddress; +import jdk.test.lib.security.SecurityUtils; + + /** * Test that a server is able to discard invalid initial ClientHello silently. */ @@ -45,6 +48,7 @@ public class NoMacInitialClientHello extends DTLSOverDatagram { boolean needInvalidRecords = true; public static void main(String[] args) throws Exception { + SecurityUtils.removeFromDisabledTlsAlgs("DTLSv1.0"); System.setProperty("jdk.tls.useExtendedMasterSecret", "false"); NoMacInitialClientHello testCase = new NoMacInitialClientHello(); testCase.runTest(testCase); diff --git a/test/jdk/sun/security/ssl/SSLContextImpl/SSLContextDefault.java b/test/jdk/sun/security/ssl/SSLContextImpl/SSLContextDefault.java index b0327d69a66..7a790e72a1e 100644 --- a/test/jdk/sun/security/ssl/SSLContextImpl/SSLContextDefault.java +++ b/test/jdk/sun/security/ssl/SSLContextImpl/SSLContextDefault.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -28,8 +28,9 @@ /* * @test - * @bug 8202343 - * @summary Check that SSLv3, TLSv1 and TLSv1.1 are disabled by default + * @bug 8202343 8256660 + * @summary Check that SSLv3, TLSv1, TLSv1.1, and DTLSv1.0 are disabled + * by default * @run main/othervm SSLContextDefault */ @@ -38,26 +39,43 @@ public class SSLContextDefault { - private final static String[] protocols = { + private static final String[] tlsProtocols = { "", "SSL", "TLS", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3" }; - private final static List disabledProtocols = List.of( + private static final String[] dtlsProtocols = { + "DTLS", "DTLSv1.0", "DTLSv1.2" + }; + + private static final List disabledTlsProtocols = List.of( "SSLv3", "TLSv1", "TLSv1.1" ); + private static final List disabledDtlsProtocols = List.of( + "DTLSv1.0" + ); + public static void main(String[] args) throws Exception { - for (String protocol : protocols) { - System.out.println("//"); - System.out.println("// " + "Testing for SSLContext of " + - (protocol.isEmpty() ? "" : protocol)); - System.out.println("//"); - checkForProtocols(protocol); - System.out.println(); + for (String tlsProtocol : tlsProtocols) { + testProtocol(tlsProtocol, disabledTlsProtocols); + } + for (String dtlsProtocol : dtlsProtocols) { + testProtocol(dtlsProtocol, disabledDtlsProtocols); } } - public static void checkForProtocols(String protocol) throws Exception { + private static void testProtocol(String protocol, + List disabledProtocols) throws Exception { + System.out.println("//"); + System.out.println("// " + "Testing for SSLContext of " + + (protocol.isEmpty() ? "" : protocol)); + System.out.println("//"); + checkForProtocols(protocol, disabledProtocols); + System.out.println(); + } + + private static void checkForProtocols(String protocol, + List disabledProtocols) throws Exception { SSLContext context; if (protocol.isEmpty()) { context = SSLContext.getDefault(); @@ -68,32 +86,35 @@ public static void checkForProtocols(String protocol) throws Exception { // check for the presence of supported protocols of SSLContext SSLParameters parameters = context.getSupportedSSLParameters(); - checkProtocols(parameters.getProtocols(), + checkProtocols(parameters.getProtocols(), disabledProtocols, "Supported protocols in SSLContext", false); - // check for the presence of default protocols of SSLContext parameters = context.getDefaultSSLParameters(); - checkProtocols(parameters.getProtocols(), + checkProtocols(parameters.getProtocols(), disabledProtocols, "Enabled protocols in SSLContext", true); // check for the presence of supported protocols of SSLEngine SSLEngine engine = context.createSSLEngine(); - checkProtocols(engine.getSupportedProtocols(), + checkProtocols(engine.getSupportedProtocols(), disabledProtocols, "Supported protocols in SSLEngine", false); // Check for the presence of default protocols of SSLEngine - checkProtocols(engine.getEnabledProtocols(), + checkProtocols(engine.getEnabledProtocols(), disabledProtocols, "Enabled protocols in SSLEngine", true); + if (protocol.startsWith("DTLS")) { + return; + } + SSLSocketFactory factory = context.getSocketFactory(); try (SSLSocket socket = (SSLSocket)factory.createSocket()) { // check for the presence of supported protocols of SSLSocket - checkProtocols(socket.getSupportedProtocols(), + checkProtocols(socket.getSupportedProtocols(), disabledProtocols, "Supported cipher suites in SSLSocket", false); // Check for the presence of default protocols of SSLSocket - checkProtocols(socket.getEnabledProtocols(), + checkProtocols(socket.getEnabledProtocols(), disabledProtocols, "Enabled protocols in SSLSocket", true); } @@ -102,16 +123,19 @@ public static void checkForProtocols(String protocol) throws Exception { (SSLServerSocket)serverFactory.createServerSocket()) { // check for the presence of supported protocols of SSLServerSocket checkProtocols(serverSocket.getSupportedProtocols(), - "Supported cipher suites in SSLServerSocket", false); + disabledProtocols, "Supported cipher suites in SSLServerSocket", + false); // Check for the presence of default protocols of SSLServerSocket checkProtocols(serverSocket.getEnabledProtocols(), - "Enabled protocols in SSLServerSocket", true); + disabledProtocols, "Enabled protocols in SSLServerSocket", + true); } } private static void checkProtocols(String[] protocols, - String title, boolean disabled) throws Exception { + List disabledProtocols, String title, boolean disabled) + throws Exception { showProtocols(protocols, title); if (disabled) { From 8b8774d1c65b7535af579f9431a597f51db4f653 Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Tue, 16 Apr 2024 15:11:46 +0000 Subject: [PATCH 085/149] 8326529: JFR: Test for CompilerCompile events fails due to time out Backport-of: 4dd6c44cbdb0b5957414fa87b6c559fa4d6f2fa8 --- test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java b/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java index 8b6b27261b9..f4b802b79ed 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java +++ b/test/jdk/jdk/jfr/event/compiler/TestCompilerCompile.java @@ -50,6 +50,7 @@ * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm -Xbootclasspath/a:. * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:CompileOnly=jdk.jfr.event.compiler.TestCompilerCompile::dummyMethod,jdk.jfr.event.compiler.TestCompilerCompile::doTest * jdk.jfr.event.compiler.TestCompilerCompile */ public class TestCompilerCompile { From 85d891b8191614ee6c16a7ea73ca8c428875e7a6 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Thu, 18 Apr 2024 01:05:53 +0000 Subject: [PATCH 086/149] 8316164: Opensource JMenuBar manual test Backport-of: 8f4dfc443ba5820f5799fff1418d6632d502d57b --- test/jdk/javax/swing/JMenuBar/bug4403749.java | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 test/jdk/javax/swing/JMenuBar/bug4403749.java diff --git a/test/jdk/javax/swing/JMenuBar/bug4403749.java b/test/jdk/javax/swing/JMenuBar/bug4403749.java new file mode 100644 index 00000000000..e98c0eaee3f --- /dev/null +++ b/test/jdk/javax/swing/JMenuBar/bug4403749.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2001, 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. + * + * 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. + */ + +/* + * @test + * @bug 4403749 + * @summary Tests that keyboard accelerator implementation in JMenuBar is + MenuElement aware + * @key headful + * @run main bug4403749 + */ + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JPanel; +import javax.swing.KeyStroke; +import javax.swing.MenuElement; +import javax.swing.MenuSelectionManager; +import javax.swing.SwingUtilities; + +public class bug4403749 { + static JFrame frame; + static volatile Point pt; + static volatile Dimension dim; + static volatile boolean passed; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(100); + try { + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("bug4403749"); + JMenuBar mbar = new JMenuBar(); + JMenu menu = new JMenu("Menu"); + JPanel panel = new TestMenuElement(); + menu.add(panel); + mbar.add(menu); + frame.setJMenuBar(mbar); + + frame.getContentPane().add(new JButton("")); + frame.setSize(200, 200); + frame.setLocationRelativeTo(null); + frame.setAlwaysOnTop(true); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + pt = frame.getLocationOnScreen(); + dim = frame.getSize(); + }); + robot.mouseMove(pt.x + dim.width / 2, pt.y + dim.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(200); + robot.keyPress(KeyEvent.VK_ALT); + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_ALT); + if (!passed) { + throw new RuntimeException("Failed: processKeyBinding wasn't called"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + static class TestMenuElement extends JPanel implements MenuElement { + public void processMouseEvent(MouseEvent event, + MenuElement[] path, + MenuSelectionManager manager) {} + + public void processKeyEvent(KeyEvent event, + MenuElement[] path, + MenuSelectionManager manager) {} + + public void menuSelectionChanged(boolean isIncluded) {} + + public MenuElement[] getSubElements() { + return new MenuElement[0]; + } + + public Component getComponent() { + return this; + } + + protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, + int condition, boolean pressed) { + passed = true; + return super.processKeyBinding(ks, e, condition, pressed); + } + } +} From 583477f96f58a2608ced8bf75bdc7670dc24d180 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Thu, 18 Apr 2024 01:06:54 +0000 Subject: [PATCH 087/149] 8316017: Refactor timeout handler in PassFailJFrame Backport-of: 3abd772672a4dfd984459283235f3b1d8fb28a49 --- .../awt/regtesthelpers/PassFailJFrame.java | 173 ++++++++++++------ 1 file changed, 116 insertions(+), 57 deletions(-) diff --git a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java index 94d6c2e4967..15a914934e7 100644 --- a/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java +++ b/test/jdk/java/awt/regtesthelpers/PassFailJFrame.java @@ -34,6 +34,8 @@ import java.awt.Robot; import java.awt.Toolkit; import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; @@ -159,14 +161,26 @@ public final class PassFailJFrame { * Prefix for the user-provided failure reason. */ private static final String FAILURE_REASON = "Failure Reason:\n"; + /** + * The failure reason message when the user didn't provide one. + */ + private static final String EMPTY_REASON = "(no reason provided)"; private static final List windowList = new ArrayList<>(); - private static final Timer timer = new Timer(0, null); + private static final CountDownLatch latch = new CountDownLatch(1); - private static volatile boolean failed; - private static volatile boolean timeout; - private static volatile String testFailedReason; + private static TimeoutHandler timeoutHandler; + + /** + * The description of why the test fails. + *

    + * Note: do not use this field directly, + * use the {@link #setFailureReason(String) setFailureReason} and + * {@link #getFailureReason() getFailureReason} methods to modify and + * to read its value. + */ + private static String failureReason; private static final AtomicInteger imgCounter = new AtomicInteger(0); @@ -327,42 +341,27 @@ private static void createUI(String title, String instructions, frame = new JFrame(title); frame.setLayout(new BorderLayout()); + JLabel testTimeoutLabel = new JLabel("", JLabel.CENTER); + timeoutHandler = new TimeoutHandler(testTimeoutLabel, testTimeOut); + frame.add(testTimeoutLabel, BorderLayout.NORTH); + JTextComponent text = instructions.startsWith("") ? configureHTML(instructions, rows, columns) : configurePlainText(instructions, rows, columns); text.setEditable(false); - long tTimeout = TimeUnit.MINUTES.toMillis(testTimeOut); - - final JLabel testTimeoutLabel = new JLabel(String.format("Test " + - "timeout: %s", convertMillisToTimeStr(tTimeout)), JLabel.CENTER); - final long startTime = System.currentTimeMillis(); - timer.setDelay(1000); - timer.addActionListener((e) -> { - long leftTime = tTimeout - (System.currentTimeMillis() - startTime); - if ((leftTime < 0) || failed) { - timer.stop(); - testFailedReason = FAILURE_REASON - + "Timeout User did not perform testing."; - timeout = true; - latch.countDown(); - } - testTimeoutLabel.setText(String.format("Test timeout: %s", convertMillisToTimeStr(leftTime))); - }); - timer.start(); - frame.add(testTimeoutLabel, BorderLayout.NORTH); frame.add(new JScrollPane(text), BorderLayout.CENTER); JButton btnPass = new JButton("Pass"); btnPass.addActionListener((e) -> { latch.countDown(); - timer.stop(); + timeoutHandler.stop(); }); JButton btnFail = new JButton("Fail"); btnFail.addActionListener((e) -> { - getFailureReason(); - timer.stop(); + requestFailureReason(); + timeoutHandler.stop(); }); JPanel buttonsPanel = new JPanel(); @@ -506,12 +505,58 @@ public interface InstructionUI { } + private static final class TimeoutHandler implements ActionListener { + private final long endTime; + + private final Timer timer; + + private final JLabel label; + + public TimeoutHandler(final JLabel label, final long testTimeOut) { + endTime = System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(testTimeOut); + + this.label = label; + + timer = new Timer(1000, this); + timer.start(); + updateTime(testTimeOut); + } + + @Override + public void actionPerformed(ActionEvent e) { + long leftTime = endTime - System.currentTimeMillis(); + if (leftTime < 0) { + timer.stop(); + setFailureReason(FAILURE_REASON + + "Timeout - User did not perform testing."); + latch.countDown(); + } + updateTime(leftTime); + } + + private void updateTime(final long leftTime) { + if (leftTime < 0) { + label.setText("Test timeout: 00:00:00"); + return; + } + long hours = leftTime / 3_600_000; + long minutes = (leftTime - hours * 3_600_000) / 60_000; + long seconds = (leftTime - hours * 3_600_000 - minutes * 60_000) / 1_000; + label.setText(String.format("Test timeout: %02d:%02d:%02d", + hours, minutes, seconds)); + } + + public void stop() { + timer.stop(); + } + } + + private static final class WindowClosingHandler extends WindowAdapter { @Override public void windowClosing(WindowEvent e) { - testFailedReason = FAILURE_REASON - + "User closed a window"; - failed = true; + setFailureReason(FAILURE_REASON + + "User closed a window"); latch.countDown(); } } @@ -605,14 +650,28 @@ private static void captureScreen(CaptureType type) { JOptionPane.INFORMATION_MESSAGE); } - private static String convertMillisToTimeStr(long millis) { - if (millis < 0) { - return "00:00:00"; + /** + * Sets the failure reason which describes why the test fails. + * This method ensures the {@code failureReason} field does not change + * after it's set to a non-{@code null} value. + * @param reason the description of why the test fails + * @throws IllegalArgumentException if the {@code reason} parameter + * is {@code null} + */ + private static synchronized void setFailureReason(final String reason) { + if (reason == null) { + throw new IllegalArgumentException("The failure reason must not be null"); } - long hours = millis / 3_600_000; - long minutes = (millis - hours * 3_600_000) / 60_000; - long seconds = (millis - hours * 3_600_000 - minutes * 60_000) / 1_000; - return String.format("%02d:%02d:%02d", hours, minutes, seconds); + if (failureReason == null) { + failureReason = reason; + } + } + + /** + * {@return the description of why the test fails} + */ + private static synchronized String getFailureReason() { + return failureReason; } /** @@ -633,30 +692,18 @@ public void awaitAndCheck() throws InterruptedException, InvocationTargetExcepti latch.await(); invokeAndWait(PassFailJFrame::disposeWindows); - if (timeout) { - throw new RuntimeException(testFailedReason); - } - - if (failed) { - throw new RuntimeException("Test failed! : " + testFailedReason); + String failure = getFailureReason(); + if (failure != null) { + throw new RuntimeException(failure); } System.out.println("Test passed!"); } /** - * Disposes of all the windows. It disposes of the test instruction frame - * and all other windows added via {@link #addTestWindow(Window)}. - */ - private static synchronized void disposeWindows() { - windowList.forEach(Window::dispose); - } - - /** - * Read the test failure reason and add the reason to the test result - * example in the jtreg .jtr file. + * Requests the description of the test failure reason from the tester. */ - private static void getFailureReason() { + private static void requestFailureReason() { final JDialog dialog = new JDialog(frame, "Test Failure ", true); dialog.setTitle("Failure reason"); JPanel jPanel = new JPanel(new BorderLayout()); @@ -664,7 +711,9 @@ private static void getFailureReason() { JButton okButton = new JButton("OK"); okButton.addActionListener((ae) -> { - testFailedReason = FAILURE_REASON + jTextArea.getText(); + String text = jTextArea.getText(); + setFailureReason(FAILURE_REASON + + (!text.isEmpty() ? text : EMPTY_REASON)); dialog.setVisible(false); }); @@ -679,11 +728,22 @@ private static void getFailureReason() { dialog.pack(); dialog.setVisible(true); - failed = true; + // Ensure the test fails even if the dialog is closed + // without clicking the OK button + setFailureReason(FAILURE_REASON + EMPTY_REASON); + dialog.dispose(); latch.countDown(); } + /** + * Disposes of all the windows. It disposes of the test instruction frame + * and all other windows added via {@link #addTestWindow(Window)}. + */ + private static synchronized void disposeWindows() { + windowList.forEach(Window::dispose); + } + private static void positionInstructionFrame(final Position position) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); @@ -876,8 +936,7 @@ public static void forceFail() { * @param reason the reason why the test is failed */ public static void forceFail(String reason) { - failed = true; - testFailedReason = FAILURE_REASON + reason; + setFailureReason(FAILURE_REASON + reason); latch.countDown(); } From 64990670519ba8e084f32383fb101224db99add2 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Fri, 19 Apr 2024 10:10:15 +0000 Subject: [PATCH 088/149] 8318599: HttpURLConnection cache issues leading to crashes in JGSS w/ native GSS introduced by 8303809 Backport-of: f1a24f6d4827f9b8648dd2afe6d606dab67d51fe --- .../sun/net/www/protocol/http/NegotiateAuthentication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.base/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java b/src/java.base/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java index cd5c1f8b35f..925067b4204 100644 --- a/src/java.base/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java +++ b/src/java.base/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java @@ -136,7 +136,7 @@ private static synchronized HashMap getCache() { @Override protected boolean useAuthCache() { - return super.useAuthCache() && cacheSPNEGO; + return false; } /** From a33a174ae7deaa6b256409052c9fd66c572bdd78 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Fri, 19 Apr 2024 10:12:42 +0000 Subject: [PATCH 089/149] 8297449: Update JInternalFrame Metal Border code Reviewed-by: lucy Backport-of: 09629570f5d064dc2a5cd670de8d648156ac3991 --- .../javax/swing/plaf/metal/MetalBorders.java | 73 +++++++++---------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java index 1ce233de93b..121b09b4c0c 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalBorders.java @@ -65,6 +65,8 @@ import sun.swing.StringUIClientPropertyKey; import sun.swing.SwingUtilities2; +import static sun.java2d.pipe.Region.clipRound; + /** * Factory object that can vend Borders appropriate for the metal L & F. * @author Steve Wilson @@ -227,18 +229,6 @@ public Insets getBorderInsets(Component c, Insets newInsets) { public static class InternalFrameBorder extends AbstractBorder implements UIResource { private static final int CORNER = 14; - /** - * Rounds a double to the nearest integer. It rounds 0.5 down, - * for example 1.5 is rounded to 1.0. - * - * @param d number to be rounded - * @return the rounded value - */ - private static int roundHalfDown(double d) { - double decP = (Math.ceil(d) - d); - return (int)((decP == 0.5) ? Math.floor(d) : Math.round(d)); - } - public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { @@ -256,15 +246,28 @@ public void paintBorder(Component c, Graphics g, int x, int y, shadow = MetalLookAndFeel.getControlInfo(); } - Graphics2D g2d = (Graphics2D) g; - AffineTransform at = g2d.getTransform(); - Stroke oldStk = g2d.getStroke(); - Color oldColor = g2d.getColor(); + AffineTransform at = null; + Stroke oldStk = null; + boolean resetTransform = false; int stkWidth = 1; - - // if m01 or m10 is non-zero, then there is a rotation or shear - // skip resetting the transform - boolean resetTransform = ((at.getShearX() == 0) && (at.getShearY() == 0)); + double scaleFactor = 1; + + if (g instanceof Graphics2D) { + Graphics2D g2d = (Graphics2D) g; + at = g2d.getTransform(); + scaleFactor = at.getScaleX(); + oldStk = g2d.getStroke(); + + // if m01 or m10 is non-zero, then there is a rotation or shear + // skip resetting the transform + resetTransform = ((at.getShearX() == 0) && (at.getShearY() == 0)); + + if (resetTransform) { + g2d.setTransform(new AffineTransform()); + stkWidth = clipRound(Math.min(at.getScaleX(), at.getScaleY())); + g2d.setStroke(new BasicStroke((float) stkWidth)); + } + } int xtranslation; int ytranslation; @@ -272,25 +275,22 @@ public void paintBorder(Component c, Graphics g, int x, int y, int height; if (resetTransform) { - g2d.setTransform(new AffineTransform()); - stkWidth = roundHalfDown(Math.min(at.getScaleX(), at.getScaleY())); - double xx = at.getScaleX() * x + at.getTranslateX(); double yy = at.getScaleY() * y + at.getTranslateY(); - xtranslation = roundHalfDown(xx); - ytranslation = roundHalfDown(yy); - width = roundHalfDown(at.getScaleX() * w + xx) - xtranslation; - height = roundHalfDown(at.getScaleY() * h + yy) - ytranslation; + xtranslation = clipRound(xx); + ytranslation = clipRound(yy); + width = clipRound(at.getScaleX() * w + xx) - xtranslation; + height = clipRound(at.getScaleY() * h + yy) - ytranslation; } else { - width = w; - height = h; xtranslation = x; ytranslation = y; + width = w; + height = h; } - g2d.translate(xtranslation, ytranslation); + g.translate(xtranslation, ytranslation); // scaled border - int thickness = (int) Math.ceil(4 * at.getScaleX()); + int thickness = (int) Math.ceil(4 * scaleFactor); g.setColor(background); // Draw the bulk of the border @@ -299,17 +299,14 @@ public void paintBorder(Component c, Graphics g, int x, int y, } if (c instanceof JInternalFrame && ((JInternalFrame)c).isResizable()) { - // set new stroke to draw shadow and highlight lines - g2d.setStroke(new BasicStroke((float) stkWidth)); - // midpoint at which highlight & shadow lines // are positioned on the border int midPoint = thickness / 2; - int offset = ((at.getScaleX() - stkWidth) >= 0 && stkWidth % 2 != 0) ? 1 : 0; + int offset = (((scaleFactor - stkWidth) >= 0) && ((stkWidth % 2) != 0)) ? 1 : 0; int loc1 = thickness % 2 == 0 ? midPoint + stkWidth / 2 - stkWidth : midPoint; int loc2 = thickness % 2 == 0 ? midPoint + stkWidth / 2 : midPoint + stkWidth; // scaled corner - int corner = (int) Math.round(CORNER * at.getScaleX()); + int corner = (int) Math.round(CORNER * scaleFactor); // Draw the Long highlight lines g.setColor(highlight); @@ -331,9 +328,9 @@ public void paintBorder(Component c, Graphics g, int x, int y, } // restore previous transform - g2d.translate(-xtranslation, -ytranslation); + g.translate(-xtranslation, -ytranslation); if (resetTransform) { - g2d.setColor(oldColor); + Graphics2D g2d = (Graphics2D) g; g2d.setTransform(at); g2d.setStroke(oldStk); } From 215cf9b9a9f19fcff9272af7f28f17281a8bdab8 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 19 Apr 2024 11:02:12 +0000 Subject: [PATCH 090/149] 8322783: prioritize /etc/os-release over /etc/SuSE-release in hs_err/info output Reviewed-by: stuefe Backport-of: 33af09083493940667958f951080e9d8700f784b --- src/hotspot/os/linux/os_linux.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index c1cf8619b67..41a3e32f553 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2015, 2022 SAP SE. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024 SAP SE. 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 @@ -2313,7 +2313,6 @@ const char* distro_files[] = { "/etc/mandrake-release", "/etc/sun-release", "/etc/redhat-release", - "/etc/SuSE-release", "/etc/lsb-release", "/etc/turbolinux-release", "/etc/gentoo-release", @@ -2321,6 +2320,7 @@ const char* distro_files[] = { "/etc/angstrom-version", "/etc/system-release", "/etc/os-release", + "/etc/SuSE-release", // Deprecated in favor of os-release since SuSE 12 NULL }; void os::Linux::print_distro_info(outputStream* st) { From cc2313975cfbda592e98cb28255c30a2506c68f7 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Mon, 22 Apr 2024 07:38:48 +0000 Subject: [PATCH 091/149] 8302512: Update IANA Language Subtag Registry to Version 2023-02-14 Backport-of: 8210811b1924816da265da64da557111a2961e53 --- make/data/lsrdata/language-subtag-registry.txt | 8 +++++++- test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/make/data/lsrdata/language-subtag-registry.txt b/make/data/lsrdata/language-subtag-registry.txt index 92e0a26f0cd..d7269c8e03d 100644 --- a/make/data/lsrdata/language-subtag-registry.txt +++ b/make/data/lsrdata/language-subtag-registry.txt @@ -1,4 +1,4 @@ -File-Date: 2022-08-08 +File-Date: 2023-02-14 %% Type: language Subtag: aa @@ -26378,6 +26378,7 @@ Type: language Subtag: nrf Description: Jèrriais Description: Guernésiais +Description: Sercquiais Added: 2015-02-12 %% Type: language @@ -46013,6 +46014,11 @@ Description: Clipperton Island Added: 2009-07-29 %% Type: region +Subtag: CQ +Description: Sark +Added: 2023-02-07 +%% +Type: region Subtag: CR Description: Costa Rica Added: 2005-10-16 diff --git a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java index a617aeb02cd..1064a090ffa 100644 --- a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java +++ b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -24,9 +24,9 @@ /* * @test * @bug 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432 - * 8258795 8267038 + * 8258795 8267038 8287180 8302512 * @summary Checks the IANA language subtag registry data update - * (LSR Revision: 2022-08-08) with Locale and Locale.LanguageRange + * (LSR Revision: 2023-02-14) with Locale and Locale.LanguageRange * class methods. * @run main LanguageSubtagRegistryTest */ From 7af75fb400a0a450d7ee5e7c89fe4e024e60ede3 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Tue, 23 Apr 2024 07:04:50 +0000 Subject: [PATCH 092/149] 8304761: Update IANA Language Subtag Registry to Version 2023-03-22 Backport-of: ae3aa7289a3de98001dde382f511b574b1d26c8d --- .../data/lsrdata/language-subtag-registry.txt | 150 ++++++++++++++++-- .../Locale/LanguageSubtagRegistryTest.java | 34 +++- 2 files changed, 169 insertions(+), 15 deletions(-) diff --git a/make/data/lsrdata/language-subtag-registry.txt b/make/data/lsrdata/language-subtag-registry.txt index d7269c8e03d..1a29e6f0450 100644 --- a/make/data/lsrdata/language-subtag-registry.txt +++ b/make/data/lsrdata/language-subtag-registry.txt @@ -1,4 +1,4 @@ -File-Date: 2023-02-14 +File-Date: 2023-03-22 %% Type: language Subtag: aa @@ -2143,6 +2143,8 @@ Type: language Subtag: ajp Description: South Levantine Arabic Added: 2009-07-29 +Deprecated: 2023-03-17 +Preferred-Value: apc Macrolanguage: ar %% Type: language @@ -2790,7 +2792,7 @@ Added: 2009-07-29 %% Type: language Subtag: apc -Description: North Levantine Arabic +Description: Levantine Arabic Added: 2009-07-29 Macrolanguage: ar %% @@ -8910,6 +8912,11 @@ Description: Kuwaataay Added: 2009-07-29 %% Type: language +Subtag: cxh +Description: Cha'ari +Added: 2023-03-17 +%% +Type: language Subtag: cya Description: Nopala Chatino Added: 2009-07-29 @@ -10176,6 +10183,11 @@ Description: Disa Added: 2009-07-29 %% Type: language +Subtag: dsk +Description: Dokshi +Added: 2023-03-17 +%% +Type: language Subtag: dsl Description: Danish Sign Language Added: 2009-07-29 @@ -10503,6 +10515,11 @@ Description: Jola-Fonyi Added: 2009-07-29 %% Type: language +Subtag: dyr +Description: Dyarim +Added: 2023-03-17 +%% +Type: language Subtag: dyu Description: Dyula Added: 2005-10-16 @@ -10522,7 +10539,6 @@ Type: language Subtag: dzd Description: Daza Added: 2009-07-29 -Deprecated: 2015-02-12 %% Type: language Subtag: dze @@ -11146,6 +11162,11 @@ Description: Semimi Added: 2009-07-29 %% Type: language +Subtag: eud +Description: Eudeve +Added: 2023-03-17 +%% +Type: language Subtag: euq Description: Basque (family) Added: 2009-07-29 @@ -14805,6 +14826,11 @@ Added: 2009-07-29 Macrolanguage: iu %% Type: language +Subtag: ikh +Description: Ikhin-Arokho +Added: 2023-03-17 +%% +Type: language Subtag: iki Description: Iko Added: 2009-07-29 @@ -15380,6 +15406,11 @@ Deprecated: 2013-09-10 Comments: see eza, gmz, iqw, izz %% Type: language +Subtag: izm +Description: Kizamani +Added: 2023-03-17 +%% +Type: language Subtag: izr Description: Izere Added: 2009-07-29 @@ -16922,6 +16953,8 @@ Type: language Subtag: kgm Description: Karipúna Added: 2009-07-29 +Deprecated: 2023-03-17 +Preferred-Value: plu %% Type: language Subtag: kgn @@ -18339,7 +18372,7 @@ Scope: collection %% Type: language Subtag: krp -Description: Korop +Description: Durop Added: 2009-07-29 %% Type: language @@ -18392,6 +18425,8 @@ Type: language Subtag: ksa Description: Shuwa-Zamani Added: 2009-07-29 +Deprecated: 2023-03-17 +Comments: see izm, rsw %% Type: language Subtag: ksb @@ -19476,7 +19511,7 @@ Added: 2009-07-29 %% Type: language Subtag: lag -Description: Langi +Description: Rangi Added: 2009-07-29 %% Type: language @@ -20011,6 +20046,12 @@ Description: Lengo Added: 2009-07-29 %% Type: language +Subtag: lgs +Description: Guinea-Bissau Sign Language +Description: Língua Gestual Guineense +Added: 2023-03-17 +%% +Type: language Subtag: lgt Description: Pahi Added: 2009-07-29 @@ -20655,6 +20696,7 @@ Added: 2009-07-29 %% Type: language Subtag: loh +Description: Laarim Description: Narim Added: 2009-07-29 %% @@ -21129,6 +21171,11 @@ Description: Lavukaleve Added: 2009-07-29 %% Type: language +Subtag: lvl +Description: Lwel +Added: 2023-03-17 +%% +Type: language Subtag: lvs Description: Standard Latvian Added: 2010-03-11 @@ -26188,6 +26235,8 @@ Type: language Subtag: nom Description: Nocamán Added: 2009-07-29 +Deprecated: 2023-03-17 +Preferred-Value: cbr %% Type: language Subtag: non @@ -27088,6 +27137,11 @@ Description: Zeme Naga Added: 2009-07-29 %% Type: language +Subtag: nzr +Description: Dir-Nyamzak-Mbarimi +Added: 2023-03-17 +%% +Type: language Subtag: nzs Description: New Zealand Sign Language Added: 2009-07-29 @@ -28846,6 +28900,8 @@ Type: language Subtag: plj Description: Polci Added: 2009-07-29 +Deprecated: 2023-03-17 +Comments: see nzr, pze, uly, zlu %% Type: language Subtag: plk @@ -28971,6 +29027,8 @@ Type: language Subtag: pmk Description: Pamlico Added: 2009-07-29 +Deprecated: 2023-03-17 +Preferred-Value: crr %% Type: language Subtag: pml @@ -29447,6 +29505,8 @@ Type: language Subtag: prp Description: Parsi Added: 2009-07-29 +Deprecated: 2023-03-17 +Preferred-Value: gu %% Type: language Subtag: prq @@ -29858,6 +29918,11 @@ Description: Pyen Added: 2009-07-29 %% Type: language +Subtag: pze +Description: Pesse +Added: 2023-03-17 +%% +Type: language Subtag: pzh Description: Pazeh Added: 2022-02-25 @@ -30874,7 +30939,7 @@ Deprecated: 2017-02-23 Type: language Subtag: rsk Description: Ruthenian -Description: Rusyn +Description: Rusnak Added: 2022-02-25 %% Type: language @@ -30893,6 +30958,11 @@ Description: Rwandan Sign Language Added: 2022-02-25 %% Type: language +Subtag: rsw +Description: Rishiwa +Added: 2023-03-17 +%% +Type: language Subtag: rtc Description: Rungtu Chin Added: 2012-08-12 @@ -32329,6 +32399,7 @@ Type: language Subtag: slq Description: Salchuq Added: 2009-07-29 +Deprecated: 2023-03-17 %% Type: language Subtag: slr @@ -33686,6 +33757,8 @@ Type: language Subtag: szd Description: Seru Added: 2009-07-29 +Deprecated: 2023-03-17 +Preferred-Value: umi %% Type: language Subtag: sze @@ -35066,6 +35139,8 @@ Type: language Subtag: tmk Description: Northwestern Tamang Added: 2009-07-29 +Deprecated: 2023-03-17 +Preferred-Value: tdg %% Type: language Subtag: tml @@ -35482,6 +35557,8 @@ Type: language Subtag: tpw Description: Tupí Added: 2009-07-29 +Deprecated: 2023-03-17 +Preferred-Value: tpn %% Type: language Subtag: tpx @@ -36077,6 +36154,11 @@ Description: Te'un Added: 2009-07-29 %% Type: language +Subtag: tvi +Description: Tulai +Added: 2023-03-17 +%% +Type: language Subtag: tvk Description: Southeast Ambrym Added: 2009-07-29 @@ -36728,6 +36810,11 @@ Description: Ulwa Added: 2010-03-11 %% Type: language +Subtag: uly +Description: Buli +Added: 2023-03-17 +%% +Type: language Subtag: uma Description: Umatilla Added: 2009-07-29 @@ -37319,6 +37406,11 @@ Description: Iduna Added: 2009-07-29 %% Type: language +Subtag: vjk +Description: Bajjika +Added: 2023-03-17 +%% +Type: language Subtag: vka Description: Kariyarra Added: 2009-07-29 @@ -38317,7 +38409,7 @@ Added: 2009-07-29 %% Type: language Subtag: wnb -Description: Wanambre +Description: Mokati Added: 2009-07-29 %% Type: language @@ -38620,6 +38712,11 @@ Description: Wotapuri-Katarqalai Added: 2009-07-29 %% Type: language +Subtag: wtb +Description: Matambwe +Added: 2023-03-17 +%% +Type: language Subtag: wtf Description: Watiwa Added: 2009-07-29 @@ -40086,6 +40183,8 @@ Type: language Subtag: xss Description: Assan Added: 2009-07-29 +Deprecated: 2023-03-17 +Preferred-Value: zko %% Type: language Subtag: xsu @@ -40669,6 +40768,11 @@ Description: Chepya Added: 2009-07-29 %% Type: language +Subtag: ycr +Description: Yilan Creole +Added: 2023-03-17 +%% +Type: language Subtag: yda Description: Yanda Added: 2013-09-10 @@ -40948,6 +41052,11 @@ Description: Northern Yukaghir Added: 2009-07-29 %% Type: language +Subtag: ykh +Description: Khamnigan Mongol +Added: 2023-03-17 +%% +Type: language Subtag: yki Description: Yoke Added: 2009-07-29 @@ -41922,6 +42031,11 @@ Added: 2009-07-29 Macrolanguage: za %% Type: language +Subtag: zem +Description: Zeem +Added: 2023-03-17 +%% +Type: language Subtag: zen Description: Zenaga Added: 2005-10-16 @@ -42048,6 +42162,8 @@ Type: language Subtag: zkb Description: Koibal Added: 2009-07-29 +Deprecated: 2023-03-17 +Preferred-Value: kjh %% Type: language Subtag: zkd @@ -42151,6 +42267,11 @@ Added: 2009-07-29 Scope: collection %% Type: language +Subtag: zlu +Description: Zul +Added: 2023-03-17 +%% +Type: language Subtag: zlw Description: West Slavic languages Added: 2009-07-29 @@ -42655,6 +42776,8 @@ Type: language Subtag: zua Description: Zeem Added: 2009-07-29 +Deprecated: 2023-03-17 +Comments: see cxh, dsk, dyr, tvi, zem %% Type: language Subtag: zuh @@ -42862,7 +42985,8 @@ Type: extlang Subtag: ajp Description: South Levantine Arabic Added: 2009-07-29 -Preferred-Value: ajp +Deprecated: 2023-03-17 +Preferred-Value: apc Prefix: ar Macrolanguage: ar %% @@ -42875,7 +42999,7 @@ Prefix: sgn %% Type: extlang Subtag: apc -Description: North Levantine Arabic +Description: Levantine Arabic Added: 2009-07-29 Preferred-Value: apc Prefix: ar @@ -43696,6 +43820,14 @@ Prefix: ms Macrolanguage: ms %% Type: extlang +Subtag: lgs +Description: Guinea-Bissau Sign Language +Description: Língua Gestual Guineense +Added: 2023-03-17 +Preferred-Value: lgs +Prefix: sgn +%% +Type: extlang Subtag: liw Description: Col Added: 2009-07-29 diff --git a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java index 1064a090ffa..50fc824beb8 100644 --- a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java +++ b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java @@ -24,9 +24,9 @@ /* * @test * @bug 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432 - * 8258795 8267038 8287180 8302512 + * 8258795 8267038 8287180 8302512 8304761 * @summary Checks the IANA language subtag registry data update - * (LSR Revision: 2023-02-14) with Locale and Locale.LanguageRange + * (LSR Revision: 2023-03-22) with Locale and Locale.LanguageRange * class methods. * @run main LanguageSubtagRegistryTest */ @@ -44,10 +44,10 @@ public class LanguageSubtagRegistryTest { static boolean err = false; private static final String ACCEPT_LANGUAGE = - "Accept-Language: aam, adp, aeb, ajs, aog, aue, bcg, bic, bpp, cey, cnp, cqu, csp, csx, dif, dmw, dsz, ehs, ema," - + " en-gb-oed, gti, iba, jks, kdz, kmb, koj, kru, ksp, kwq, kxe, kzk, lii, lmm, lsb, lsc, lsn, lsv, lsw, lvi, mtm," - + " ngv, nns, ola, oyb, pat, phr, pnd, pub, rib, rnb, rsn, scv, snz, sqx, suj, szy, taj, tjj, tjp, tvx," - + " uss, uth, ysm, wkr;q=0.9, ar-hyw;q=0.8, yug;q=0.5, gfx;q=0.4"; + "Accept-Language: aam, adp, aeb, ajs, aog, apc, aue, bcg, bic, bpp, cey, cbr, cnp, cqu, crr, csp, csx, dif, dmw, dsz, ehs, ema," + + " en-gb-oed, gti, iba, jks, kdz, kjh, kmb, koj, kru, ksp, kwq, kxe, kzk, lgs, lii, lmm, lsb, lsc, lsn, lsv, lsw, lvi, mtm," + + " ngv, nns, ola, oyb, pat, phr, plu, pnd, pub, rib, rnb, rsn, scv, snz, sqx, suj, szy, taj, tdg, tjj, tjp, tpn, tvx," + + " umi, uss, uth, ysm, zko, wkr;q=0.9, ar-hyw;q=0.8, yug;q=0.5, gfx;q=0.4"; private static final List EXPECTED_RANGE_LIST = List.of( new LanguageRange("aam", 1.0), new LanguageRange("aas", 1.0), @@ -60,6 +60,10 @@ public class LanguageSubtagRegistryTest { new LanguageRange("sgn-ajs", 1.0), new LanguageRange("aog", 1.0), new LanguageRange("myd", 1.0), + new LanguageRange("apc", 1.0), + new LanguageRange("ar-apc", 1.0), + new LanguageRange("ar-ajp", 1.0), + new LanguageRange("ajp", 1.0), new LanguageRange("aue", 1.0), new LanguageRange("ktz", 1.0), new LanguageRange("bcg", 1.0), @@ -69,10 +73,14 @@ public class LanguageSubtagRegistryTest { new LanguageRange("bpp", 1.0), new LanguageRange("nxu", 1.0), new LanguageRange("cey", 1.0), + new LanguageRange("cbr", 1.0), + new LanguageRange("nom", 1.0), new LanguageRange("cnp", 1.0), new LanguageRange("zh-cnp", 1.0), new LanguageRange("cqu", 1.0), new LanguageRange("quh", 1.0), + new LanguageRange("crr", 1.0), + new LanguageRange("pmk", 1.0), new LanguageRange("csp", 1.0), new LanguageRange("zh-csp", 1.0), new LanguageRange("csx", 1.0), @@ -98,6 +106,8 @@ public class LanguageSubtagRegistryTest { new LanguageRange("sgn-jks", 1.0), new LanguageRange("kdz", 1.0), new LanguageRange("ncp", 1.0), + new LanguageRange("kjh", 1.0), + new LanguageRange("zkb", 1.0), new LanguageRange("kmb", 1.0), new LanguageRange("smd", 1.0), new LanguageRange("koj", 1.0), @@ -113,6 +123,8 @@ public class LanguageSubtagRegistryTest { new LanguageRange("kzk", 1.0), new LanguageRange("gli", 1.0), new LanguageRange("drr", 1.0), + new LanguageRange("lgs", 1.0), + new LanguageRange("sgn-lgs", 1.0), new LanguageRange("lii", 1.0), new LanguageRange("raq", 1.0), new LanguageRange("lmm", 1.0), @@ -144,6 +156,8 @@ public class LanguageSubtagRegistryTest { new LanguageRange("kxr", 1.0), new LanguageRange("phr", 1.0), new LanguageRange("pmu", 1.0), + new LanguageRange("plu", 1.0), + new LanguageRange("kgm", 1.0), new LanguageRange("pnd", 1.0), new LanguageRange("pub", 1.0), new LanguageRange("puz", 1.0), @@ -163,13 +177,21 @@ public class LanguageSubtagRegistryTest { new LanguageRange("szy", 1.0), new LanguageRange("taj", 1.0), new LanguageRange("tsf", 1.0), + new LanguageRange("tdg", 1.0), + new LanguageRange("tmk", 1.0), new LanguageRange("tjj", 1.0), new LanguageRange("tjp", 1.0), + new LanguageRange("tpn", 1.0), + new LanguageRange("tpw", 1.0), new LanguageRange("tvx", 1.0), + new LanguageRange("umi", 1.0), + new LanguageRange("szd", 1.0), new LanguageRange("uss", 1.0), new LanguageRange("uth", 1.0), new LanguageRange("ysm", 1.0), new LanguageRange("sgn-ysm", 1.0), + new LanguageRange("zko", 1.0), + new LanguageRange("xss", 1.0), new LanguageRange("wkr", 0.9), new LanguageRange("ar-hyw", 0.8), new LanguageRange("yug", 0.5), From 358a35a6a93fc28a1a8cf18f2cd890fa598c384e Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:13:06 +0000 Subject: [PATCH 093/149] 8326006: Allow TEST_VM_FLAGLESS to set flagless mode Backport-of: d10f277bd39bb5ac9bd48939c916de607fef8ace --- test/jtreg-ext/requires/VMProps.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 07879d44cee..c31290ac525 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -571,14 +571,15 @@ private String implementor() { * Checks if we are in almost out-of-box configuration, i.e. the flags * which JVM is started with don't affect its behavior "significantly". * {@code TEST_VM_FLAGLESS} enviroment variable can be used to force this - * method to return true and allow any flags. + * method to return true or false and allow or reject any flags. * * @return true if there are no JVM flags */ private String isFlagless() { boolean result = true; - if (System.getenv("TEST_VM_FLAGLESS") != null) { - return "" + result; + String flagless = System.getenv("TEST_VM_FLAGLESS"); + if (flagless != null) { + return "" + "true".equalsIgnoreCase(flagless); } List allFlags = new ArrayList(); From 00f8277e960bbf82102a4de34dcbdcc25654e1b0 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:13:32 +0000 Subject: [PATCH 094/149] 8316242: Opensource SwingGraphics manual test Backport-of: a57b9dab6c02c313f3975f47d502dae270c67508 --- .../swing/SwingGraphics/TranslateTest.java | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 test/jdk/javax/swing/SwingGraphics/TranslateTest.java diff --git a/test/jdk/javax/swing/SwingGraphics/TranslateTest.java b/test/jdk/javax/swing/SwingGraphics/TranslateTest.java new file mode 100644 index 00000000000..305b5c0b3a4 --- /dev/null +++ b/test/jdk/javax/swing/SwingGraphics/TranslateTest.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* + * @test + * @bug 4207383 + * @summary This tests, in a round about manner, that SwingGraphics does + * not wrongly translate the original graphics when disposed. While + * this test seems rather ugly, it was possible to get this to happen + * in real world apps. This test is really only valid for 1.1.x. + * @key headful + * @run main TranslateTest + */ + +import java.io.File; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Image; +import java.awt.image.BufferedImage; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.plaf.ComponentUI; +import javax.imageio.ImageIO; + +public class TranslateTest { + static JFrame frame; + static volatile Point pt; + static volatile Dimension dim; + static final int WIDTH = 200; + static final int HEIGHT = 200; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + + try { + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("TranslateTest"); + + // paintComponent() triggers create swing graphics which will + // be invoked on child. + MyPanel panel = new MyPanel(); + panel.setPreferredSize(new Dimension(WIDTH, HEIGHT)); + frame.getContentPane().add(panel); + frame.pack(); + frame.setLocationRelativeTo(null); + panel.test(); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + pt = frame.getLocationOnScreen(); + dim = frame.getSize(); + }); + BufferedImage img = robot.createScreenCapture( + new Rectangle(pt.x + dim.width / 2, + pt.y + dim.height / 2, + WIDTH / 2, HEIGHT / 2)); + robot.waitForIdle(); + robot.delay(500); + Color c = new Color(img.getRGB(img.getWidth() / 2, img.getHeight() / 2)); + if (c.getRed() < 250) { + ImageIO.write(img, "png", new File("image.png")); + System.out.println("Color " + c); + throw new RuntimeException("Translated Color is not red"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + + static class MyPanel extends JPanel { + int state; + Graphics realG; + Image image; + + public void test() { + image = createImage(TranslateTest.WIDTH, TranslateTest.HEIGHT); + Graphics g = image.getGraphics(); + g.setClip(0, 0, TranslateTest.WIDTH, TranslateTest.HEIGHT); + realG = g; + state = 1; + paintComponent(g); + state = 3; + paintComponent(g); + state = 4; + } + + + public void paint(Graphics g) { + if (state == 0) { + test(); + } + super.paint(g); + } + + protected void paintComponent(Graphics g) { + super.paintComponent(g); + } + + public void updateUI() { + setUI(new ComponentUI() { + public void paint(Graphics g, JComponent c) { + if (state == 1) { + // g is the first SwingGraphics, when it is disposed + // translateX/translateY will be wrong + //System.out.println("FIRST:" + g); + g.translate(100, 100); + state = 2; + paintComponent(realG); + } + else if (state == 2) { + // g is the first SwingGraphics, when it is disposed + // translateX/translateY will be wrong + g.translate(100, 100); + //System.out.println("Second:" + g); + } + else if (state == 3) { + // g should be the same as the first, with the wrong + // translate. + // otherG should be the second graphics, again with + // the wrong translation, disposing the second will + // cause g to be translated to -100, -100, which + // should not happen. + Graphics otherG = g.create(0, 0, 100, 100); + //System.out.println("THIRD:" + g); + otherG.dispose(); + g.setColor(Color.red); + //System.out.println("LAST: " + g); + g.fillRect(100, 100, 100, 100); + } + else if (state == 4) { + g.drawImage(image, 0, 0, null); + } + } + }); + } + } +} From 0be4705eef80880550b11af0a73423fb22ee4845 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:13:51 +0000 Subject: [PATCH 095/149] 8315824: Open source several Swing Text/HTML related tests Backport-of: c11f8352e96a01b39e54080716030ec96f717cae --- .../text/StyledEditorKit/bug4253334.java | 87 +++++++++++++++ .../text/StyledEditorKit/bug4329418.java | 101 ++++++++++++++++++ test/jdk/javax/swing/text/bug4739057.java | 53 +++++++++ test/jdk/javax/swing/text/bug4763466.java | 51 +++++++++ .../jdk/javax/swing/text/html/bug4210307.java | 96 +++++++++++++++++ .../jdk/javax/swing/text/html/bug4839739.java | 97 +++++++++++++++++ 6 files changed, 485 insertions(+) create mode 100644 test/jdk/javax/swing/text/StyledEditorKit/bug4253334.java create mode 100644 test/jdk/javax/swing/text/StyledEditorKit/bug4329418.java create mode 100644 test/jdk/javax/swing/text/bug4739057.java create mode 100644 test/jdk/javax/swing/text/bug4763466.java create mode 100644 test/jdk/javax/swing/text/html/bug4210307.java create mode 100644 test/jdk/javax/swing/text/html/bug4839739.java diff --git a/test/jdk/javax/swing/text/StyledEditorKit/bug4253334.java b/test/jdk/javax/swing/text/StyledEditorKit/bug4253334.java new file mode 100644 index 00000000000..625b47055c0 --- /dev/null +++ b/test/jdk/javax/swing/text/StyledEditorKit/bug4253334.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +import javax.swing.Action; +import javax.swing.JEditorPane; +import javax.swing.text.AttributeSet; +import javax.swing.text.Caret; +import javax.swing.text.Element; +import javax.swing.text.MutableAttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.HTMLEditorKit; +import java.awt.event.ActionEvent; +import java.io.StringReader; + +/* + * @test + * @bug 4253334 + * @summary Tests that bold attribute unsets properly + */ + +public class bug4253334 { + + public static void main(String[] args) throws Exception { + JEditorPane ep = new JEditorPane(); + ep.setEditable(true); + ep.setContentType("text/html"); + + HTMLEditorKit kit = (HTMLEditorKit)ep.getEditorKit(); + HTMLDocument doc = (HTMLDocument)kit.createDefaultDocument(); + ep.setDocument(doc); + String text = "somesampletext"; + kit.read(new StringReader(text), doc, 0); + + // make some text bold & italic + MutableAttributeSet attrs = new SimpleAttributeSet(); + StyleConstants.setBold(attrs, true); + StyleConstants.setItalic(attrs, true); + doc.setCharacterAttributes(3, 9, attrs, false); + + Action[] as = kit.getActions(); + Action boldAction = null; + + for (Action a : as) { + String s = (String) (a.getValue(Action.NAME)); + if (s.equals("font-bold")) { + boldAction = a; + } + } + Caret caret = ep.getCaret(); + ActionEvent event = new ActionEvent(ep, ActionEvent.ACTION_PERFORMED, + "font-bold"); + caret.setDot(3); + caret.moveDot(7); + boldAction.actionPerformed(event); + caret.setDot(7); + caret.moveDot(12); + boldAction.actionPerformed(event); + + Element elem = doc.getCharacterElement(9); + AttributeSet at = elem.getAttributes(); + if (StyleConstants.isBold(at)) { + throw new RuntimeException("Test Failed: bold attribute set"); + } + } +} diff --git a/test/jdk/javax/swing/text/StyledEditorKit/bug4329418.java b/test/jdk/javax/swing/text/StyledEditorKit/bug4329418.java new file mode 100644 index 00000000000..e06c9d36aa7 --- /dev/null +++ b/test/jdk/javax/swing/text/StyledEditorKit/bug4329418.java @@ -0,0 +1,101 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +import java.awt.Robot; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.text.Document; +import javax.swing.text.MutableAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledEditorKit; + +/* + * @test + * @bug 4329418 + * @key headful + * @summary Tests if setCharacterAttributes() is maintained + * after return in J(Editor/Text)Pane + */ + +public class bug4329418 { + private static JFrame jf; + private static StyledEditorKit sek; + + private static volatile boolean passed = false; + private static final int FONT_SIZE = 36; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + + SwingUtilities.invokeAndWait(bug4329418::createAndShowUI); + robot.waitForIdle(); + robot.delay(500); + + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + robot.delay(300); + + if (!passed) { + throw new RuntimeException("Test failed." + + " setCharacterAttributes() does not work correctly"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (jf != null) { + jf.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + jf = new JFrame("setCharacterAttributes Test"); + sek = new StyledEditorKit(); + JEditorPane jep = new JEditorPane(); + jep.setEditorKit(sek); + + MutableAttributeSet attrs = sek.getInputAttributes(); + StyleConstants.setFontSize(attrs, FONT_SIZE); + + jep.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent e) { + MutableAttributeSet attrs = sek.getInputAttributes(); + passed = (StyleConstants.getFontSize(attrs) == FONT_SIZE); + } + }); + + jep.setText("aaa"); + Document doc = jep.getDocument(); + jep.setCaretPosition(doc.getLength()); + + jf.getContentPane().add(jep); + jf.setLocationRelativeTo(null); + jf.setSize(200, 200); + jf.setVisible(true); + } +} diff --git a/test/jdk/javax/swing/text/bug4739057.java b/test/jdk/javax/swing/text/bug4739057.java new file mode 100644 index 00000000000..904ea8de18f --- /dev/null +++ b/test/jdk/javax/swing/text/bug4739057.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +import javax.swing.JFormattedTextField; +import javax.swing.SwingUtilities; +import javax.swing.text.MaskFormatter; +import java.text.ParseException; + +/* + * @test + * @bug 4739057 + * @summary replaceSelection() method fails on JFormattedTextField + */ + +public class bug4739057 { + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + MaskFormatter formatter; + try { + formatter = new MaskFormatter("(###) ###-####"); + } catch (ParseException e) { + throw new RuntimeException(e); + } + formatter.setPlaceholderCharacter('#'); + JFormattedTextField textField = new JFormattedTextField(formatter); + textField.replaceSelection("12345"); + if (!textField.getText().equals("(123) 45#-####")) { + throw new RuntimeException("Test Failed! replaceSelection() didn't replace text properly"); + } + }); + } +} diff --git a/test/jdk/javax/swing/text/bug4763466.java b/test/jdk/javax/swing/text/bug4763466.java new file mode 100644 index 00000000000..db2a914cb8b --- /dev/null +++ b/test/jdk/javax/swing/text/bug4763466.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +import javax.swing.JFormattedTextField; +import javax.swing.text.NumberFormatter; +import java.text.DecimalFormat; + +/* + * @test + * @bug 4763466 + * @summary JFormattedTextField and the - sign + */ + +public class bug4763466 { + + public static void main(String[] args) throws Exception { + DecimalFormat decimalFormat = new DecimalFormat("##0.00"); + NumberFormatter textFormatter = new NumberFormatter(decimalFormat); + textFormatter.setAllowsInvalid(false); + textFormatter.setValueClass(Double.class); + + JFormattedTextField ftf = new JFormattedTextField(textFormatter); + ftf.setCaretPosition(0); + ftf.setValue((double) -1); + + if (ftf.getCaretPosition() == 0) { + throw new RuntimeException("Test Failed. Caret position shouldn't be 0" + + " as the sign is literal"); + } + } +} diff --git a/test/jdk/javax/swing/text/html/bug4210307.java b/test/jdk/javax/swing/text/html/bug4210307.java new file mode 100644 index 00000000000..6af4e62f805 --- /dev/null +++ b/test/jdk/javax/swing/text/html/bug4210307.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +import javax.swing.JButton; +import javax.swing.JEditorPane; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.text.Document; +import javax.swing.text.Element; +import javax.swing.text.html.FormView; + +/* + * @test + * @bug 4210307 4210308 + * @summary Tests that FormView button text is internationalized + */ + +public class bug4210307 { + private static final String RESET_PROPERTY = "TEST RESET"; + private static final String SUBMIT_PROPERTY = "TEST SUBMIT"; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + Object oldReset = UIManager.put("FormView.resetButtonText", + RESET_PROPERTY); + Object oldSubmit = UIManager.put("FormView.submitButtonText", + SUBMIT_PROPERTY); + + try { + JEditorPane ep = new JEditorPane("text/html", + ""); + Document doc = ep.getDocument(); + Element elem = findInputElement(doc.getDefaultRootElement()); + TestView view = new TestView(elem); + view.test(SUBMIT_PROPERTY); + + ep = new JEditorPane("text/html", + ""); + doc = ep.getDocument(); + elem = findInputElement(doc.getDefaultRootElement()); + view = new TestView(elem); + view.test(RESET_PROPERTY); + } finally { + UIManager.put("FormView.resetButtonText", oldReset); + UIManager.put("FormView.submitButtonText", oldSubmit); + } + }); + } + + private static Element findInputElement(Element root) { + for (int i = 0; i < root.getElementCount(); i++) { + Element elem = root.getElement(i); + if (elem.getName().equals("input")) { + return elem; + } else { + Element e = findInputElement(elem); + if (e != null) return e; + } + } + return null; + } + + static class TestView extends FormView { + public TestView(Element elem) { + super(elem); + } + + public void test(String caption) { + JButton comp = (JButton) createComponent(); + if (!comp.getText().equals(caption)) { + throw new RuntimeException("Failed: '" + comp.getText() + + "' instead of `" + caption + "'"); + } + } + } +} diff --git a/test/jdk/javax/swing/text/html/bug4839739.java b/test/jdk/javax/swing/text/html/bug4839739.java new file mode 100644 index 00000000000..1dc5fbef123 --- /dev/null +++ b/test/jdk/javax/swing/text/html/bug4839739.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.text.html.HTMLEditorKit; +import java.awt.Component; +import java.awt.KeyboardFocusManager; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +/* + * @test + * @bug 4839739 + * @key headful + * @summary Tests if JEditorPane works correctly with HTML comments. + */ + +public class bug4839739 { + + private static JFrame jFrame; + private static JEditorPane jep; + private static volatile Point p; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.delay(50); + + SwingUtilities.invokeAndWait(bug4839739::createAndShowUI); + robot.waitForIdle(); + robot.delay(500); + + SwingUtilities.invokeAndWait(() -> p = jep.getLocationOnScreen()); + robot.delay(200); + + robot.mouseMove(p.x + 20, p.y + 20); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + robot.delay(300); + + Component comp = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); + if (!(comp instanceof JEditorPane)) { + throw new RuntimeException("Test failed." + + " JEditorPane doesn't work as expected with HTML comments"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (jFrame != null) { + jFrame.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + String text = "" + + "some always visible text"; + + jFrame = new JFrame("JEditorPane With HTML"); + jep = new JEditorPane(); + jep.setEditorKit(new HTMLEditorKit()); + jep.setEditable(false); + + jep.setText(text); + jFrame.getContentPane().add(jep); + jFrame.setSize(200,200); + jFrame.setLocationRelativeTo(null); + jFrame.setVisible(true); + } +} From e1662fb9275dd0ab957d6e42c2bac4b4456d3303 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:14:20 +0000 Subject: [PATCH 096/149] 8316154: Opensource JTextArea manual tests Backport-of: 33c62e4fffe33a7593fd0c01de53507bfd01dc3b --- .../jdk/javax/swing/JTextArea/bug4265784.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 test/jdk/javax/swing/JTextArea/bug4265784.java diff --git a/test/jdk/javax/swing/JTextArea/bug4265784.java b/test/jdk/javax/swing/JTextArea/bug4265784.java new file mode 100644 index 00000000000..3465fced595 --- /dev/null +++ b/test/jdk/javax/swing/JTextArea/bug4265784.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* + * @test + * @bug 4265784 4267291 + * @summary Tests work of TAB key in JTextArea + * @key headful + * @run main bug4265784 + */ + +import javax.swing.JFrame; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +public class bug4265784 { + static JFrame frame; + static JTextArea ta; + static volatile Point p; + static volatile int pos; + static volatile int pos1; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(100); + try { + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame("bug4265784"); + ta = new JTextArea(); + frame.getContentPane().add(ta); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + p = ta.getLocationOnScreen(); + }); + robot.mouseMove(p.x + 10, p.y + 10); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + SwingUtilities.invokeAndWait(() -> { + pos = ta.getCaretPosition(); + }); + System.out.println(pos); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + pos1 = ta.getCaretPosition(); + }); + System.out.println(pos1); + if (pos == pos1) { + throw new RuntimeException("TAB ignored"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} From 3f12da52abab3ed64aff7e7c2f14bff0dee9504c Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:16:15 +0000 Subject: [PATCH 097/149] 8315741: Open source few swing JFormattedTextField and JPopupMenu tests Backport-of: bfbc41c1f177c7a2b8e91351ac41eaffaab2d8fc --- .../swing/JFormattedTextField/bug4741926.java | 134 ++++++++++++++++++ .../swing/JFormattedTextField/bug4863121.java | 101 +++++++++++++ .../swing/JFormattedTextField/bug4886538.java | 75 ++++++++++ .../javax/swing/JPopupMenu/bug4123919.java | 74 ++++++++++ .../javax/swing/JPopupMenu/bug4197019.java | 102 +++++++++++++ 5 files changed, 486 insertions(+) create mode 100644 test/jdk/javax/swing/JFormattedTextField/bug4741926.java create mode 100644 test/jdk/javax/swing/JFormattedTextField/bug4863121.java create mode 100644 test/jdk/javax/swing/JFormattedTextField/bug4886538.java create mode 100644 test/jdk/javax/swing/JPopupMenu/bug4123919.java create mode 100644 test/jdk/javax/swing/JPopupMenu/bug4197019.java diff --git a/test/jdk/javax/swing/JFormattedTextField/bug4741926.java b/test/jdk/javax/swing/JFormattedTextField/bug4741926.java new file mode 100644 index 00000000000..58725e68780 --- /dev/null +++ b/test/jdk/javax/swing/JFormattedTextField/bug4741926.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4741926 + * @summary JFormattedTextField/JSpinner always consumes certain key events + * @key headful + * @run main bug4741926 + */ + +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; +import java.util.Date; +import javax.swing.AbstractAction; +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; + +public class bug4741926 { + + static MyFormattedTextField ftf; + static JFrame fr; + static Robot robot; + static volatile boolean passed_enter = false; + static volatile boolean passed_escape = false; + static volatile boolean ftfFocused = false; + static volatile boolean keyProcessed = false; + + public static void main(String[] args) throws Exception { + + try { + robot = new Robot(); + robot.setAutoDelay(100); + SwingUtilities.invokeAndWait(() -> { + fr = new JFrame("Test"); + ftf = new MyFormattedTextField(); + ftf.setValue("JFormattedTextField"); + JPanel p = (JPanel) fr.getContentPane(); + p.add(ftf); + ftf.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + ftfFocused = true; + } + }); + InputMap map = p.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); + + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), + "enter-action"); + p.getActionMap().put("enter-action", new AbstractAction() { + public void actionPerformed(ActionEvent e) { + passed_enter = true; + keyProcessed = true; + } + }); + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), + "escape-action"); + p.getActionMap().put("escape-action", new AbstractAction() { + public void actionPerformed(ActionEvent e) { + passed_escape = true; + keyProcessed = true; + } + }); + fr.pack(); + fr.setLocationRelativeTo(null); + fr.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + test(); + if (!(passed_enter && passed_escape)) { + throw new RuntimeException("JFormattedTextField consume " + + "Enter/Escape key event"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (fr != null) { + fr.dispose(); + } + }); + } + } + + public static void test() throws Exception { + SwingUtilities.invokeAndWait(() -> { + ftf.requestFocus(); + }); + robot.delay(500); + doTest(KeyEvent.VK_ENTER); + doTest(KeyEvent.VK_ESCAPE); + } + + static void doTest(int keyCode) throws InterruptedException { + keyProcessed = false; + KeyEvent key = new KeyEvent(ftf, KeyEvent.KEY_PRESSED, + new Date().getTime(), 0, + keyCode, + KeyEvent.CHAR_UNDEFINED); + ftf.processKey(key); + } + + static class MyFormattedTextField extends JFormattedTextField { + public void processKey(KeyEvent e) { + processKeyEvent(e); + } + } +} diff --git a/test/jdk/javax/swing/JFormattedTextField/bug4863121.java b/test/jdk/javax/swing/JFormattedTextField/bug4863121.java new file mode 100644 index 00000000000..22e50f087c7 --- /dev/null +++ b/test/jdk/javax/swing/JFormattedTextField/bug4863121.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4863121 + * @summary JFormattedTextField's NotifyAction should invoke invalidEdit if + commit fails + * @key headful + * @run main bug4863121 + */ + +import java.awt.Robot; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; +import java.text.Format; +import java.text.DecimalFormat; +import javax.swing.JFormattedTextField; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class bug4863121 { + + static TestFormattedTextField ftf; + static JFrame fr; + static Robot robot; + + private static volatile boolean focused = false; + private static volatile boolean passed = false; + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + robot.setAutoDelay(100); + SwingUtilities.invokeAndWait(() -> { + fr = new JFrame("Test"); + ftf = new TestFormattedTextField(new DecimalFormat("####")); + ftf.setText("q"); + fr.getContentPane().add(ftf); + + ftf.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + focused = true; + } + }); + fr.pack(); + fr.setLocationRelativeTo(null); + fr.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + ftf.requestFocus(); + }); + robot.waitForIdle(); + robot.delay(500); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + if (!passed) { + throw new RuntimeException("JFormattedTextField's NotifyAction " + + "should invoke invalidEdit if commit fails"); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (fr != null) { + fr.dispose(); + } + }); + } + } + + public static class TestFormattedTextField extends JFormattedTextField { + public TestFormattedTextField(Format f) { + super(f); + } + protected void invalidEdit() { + passed = true; + } + } +} diff --git a/test/jdk/javax/swing/JFormattedTextField/bug4886538.java b/test/jdk/javax/swing/JFormattedTextField/bug4886538.java new file mode 100644 index 00000000000..e50b15e9175 --- /dev/null +++ b/test/jdk/javax/swing/JFormattedTextField/bug4886538.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4886538 + * @summary JFormattedTextField not returning correct value (class) + * @run main bug4886538 + */ + +import javax.swing.JFormattedTextField; +import javax.swing.SwingUtilities; +import javax.swing.text.DefaultFormatterFactory; + +public class bug4886538 { + + public static void main(String[] args) throws Exception { + // test default display formatter + TestFormattedTextField field = new TestFormattedTextField(0.0); + field.setFormatter(((DefaultFormatterFactory) field. + getFormatterFactory()).getDisplayFormatter()); + field.setText("10"); + field.commitEdit(); + + Object dblValue = field.getValue(); + if (!(dblValue instanceof Double)) { + throw new RuntimeException("The JFormattedTextField's value " + + "should be instanceof Double"); + } + + // test default editor formatter + field = new TestFormattedTextField(0.0); + field.setFormatter(((DefaultFormatterFactory) field. + getFormatterFactory()).getEditFormatter()); + field.setText("10"); + field.commitEdit(); + + dblValue = field.getValue(); + if (!(dblValue instanceof Double)) { + throw new RuntimeException("The JFormattedTextField's value " + + "should be instanceof Double"); + } + + } + + static class TestFormattedTextField extends JFormattedTextField { + public TestFormattedTextField(Object value) { + super(value); + } + public void setFormatter(JFormattedTextField.AbstractFormatter formatter) { + super.setFormatter(formatter); + } + } + +} diff --git a/test/jdk/javax/swing/JPopupMenu/bug4123919.java b/test/jdk/javax/swing/JPopupMenu/bug4123919.java new file mode 100644 index 00000000000..fcc37795b7d --- /dev/null +++ b/test/jdk/javax/swing/JPopupMenu/bug4123919.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* + * @test + * @bug 4123919 + * @requires (os.family == "windows") + * @summary JPopupMenu.isPopupTrigger() under a different L&F. + * @key headful + * @run main bug4123919 + */ + +import javax.swing.JLabel; +import javax.swing.JPopupMenu; +import javax.swing.UIManager; +import javax.swing.SwingUtilities; +import java.awt.event.MouseEvent; +import java.util.Date; + +public class bug4123919 { + + public static void main(String[] args) throws Exception { + JPopupMenu popup = new JPopupMenu("Test"); + JLabel lb = new JLabel(); + UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + SwingUtilities.updateComponentTreeUI(lb); + SwingUtilities.updateComponentTreeUI(popup); + if (!popup.isPopupTrigger(new MouseEvent(lb, MouseEvent.MOUSE_PRESSED, + (new Date()).getTime(), MouseEvent.BUTTON3_MASK, 10, 10, 1, true))) { + throw new RuntimeException("JPopupMenu.isPopupTrigger() fails on" + + " MotifLookAndFeel when mouse pressed..."); + } + if (popup.isPopupTrigger(new MouseEvent(lb, MouseEvent.MOUSE_RELEASED, + (new Date()).getTime(), MouseEvent.BUTTON3_MASK, 10, 10, 1, true))) { + throw new RuntimeException("JPopupMenu.isPopupTrigger() fails on" + + " MotifLookAndFeel when mouse released..."); + } + + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + SwingUtilities.updateComponentTreeUI(lb); + SwingUtilities.updateComponentTreeUI(popup); + + if (popup.isPopupTrigger(new MouseEvent(lb, MouseEvent.MOUSE_PRESSED, + (new Date()).getTime(), MouseEvent.BUTTON3_MASK, 10, 10, 1, true))) { + throw new RuntimeException("JPopupMenu.isPopupTrigger() fails on" + + " WindowsLookAndFeel when mouse pressed..."); + } + if (!popup.isPopupTrigger(new MouseEvent(lb, MouseEvent.MOUSE_RELEASED, + (new Date()).getTime(), MouseEvent.BUTTON3_MASK, 10, 10, 1, true))) { + throw new RuntimeException("JPopupMenu.isPopupTrigger() fails on" + + " WindowsLookAndFeel when mouse released..."); + } + } +} diff --git a/test/jdk/javax/swing/JPopupMenu/bug4197019.java b/test/jdk/javax/swing/JPopupMenu/bug4197019.java new file mode 100644 index 00000000000..428bef49174 --- /dev/null +++ b/test/jdk/javax/swing/JPopupMenu/bug4197019.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/* + * @test + * @bug 4197019 + * @key headful + * @run main bug4197019 + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Polygon; +import java.awt.event.ActionEvent; + +import javax.swing.Action; +import javax.swing.AbstractAction; +import javax.swing.Icon; +import javax.swing.JMenuItem; +import javax.swing.JMenu; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; + +public class bug4197019 { + static volatile JMenuItem mi1; + static volatile JMenuItem mi2; + static volatile Icon i2; + static volatile boolean isPassed = false; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + JMenu fileMenu = new JMenu("File"); + JPopupMenu p = new JPopupMenu(); + Icon i = new ArrowIcon(); + Action a = new TestAction("Test", i); + mi1 = fileMenu.add(a); + mi2 = p.add(a); + + i2 = new SquareIcon(); + a.putValue(Action.SMALL_ICON, i2); + + isPassed = (mi2.getIcon() != i2) || (mi1.getIcon() != i2) || + (mi1.getIcon() != mi2.getIcon()); + }); + if (isPassed) { + throw new RuntimeException("Failed bug test 4197019"); + } + } + + private static class TestAction extends AbstractAction { + public TestAction(String s, Icon i) { + super(s,i); + } + public void actionPerformed(ActionEvent e) { + + } + } + + private static class ArrowIcon implements Icon { + public void paintIcon(Component c, Graphics g, int x, int y) { + Polygon p = new Polygon(); + p.addPoint(x, y); + p.addPoint(x+getIconWidth(), y+getIconHeight()/2); + p.addPoint(x, y+getIconHeight()); + g.fillPolygon(p); + + } + public int getIconWidth() { return 4; } + public int getIconHeight() { return 8; } + } // End class MenuArrowIcon + + private static class SquareIcon implements Icon { + public void paintIcon(Component c, Graphics g, int x, int y) { + g.setColor(Color.red); + g.fill3DRect(x,y,4,8,true); + } + public int getIconWidth() { return 8; } + public int getIconHeight() { return 8; } + } // End class MenuArrowIcon + +} From 295a8cd371a40dc5c04e401ac534c9aeb630815b Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:17:17 +0000 Subject: [PATCH 098/149] 8163921: HttpURLConnection default Accept header is malformed according to HTTP/1.1 RFC Backport-of: 28796cbd1d15de678b80295418f5d1f9f59176a6 --- .../net/www/protocol/http/HttpURLConnection.java | 5 ++--- test/jdk/sun/net/www/B8185898.java | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 54d80e689af..9aaee966828 100644 --- a/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -285,8 +285,7 @@ private static Set schemesListToSet(String list) { } static final String httpVersion = "HTTP/1.1"; - static final String acceptString = - "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"; + static final String acceptString = "*/*"; // the following http request headers should NOT have their values // returned for security reasons. diff --git a/test/jdk/sun/net/www/B8185898.java b/test/jdk/sun/net/www/B8185898.java index a50c6f93c7e..cfa54e15a52 100644 --- a/test/jdk/sun/net/www/B8185898.java +++ b/test/jdk/sun/net/www/B8185898.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -23,7 +23,7 @@ /** * @test - * @bug 8185898 + * @bug 8185898 8163921 * @modules java.base/sun.net.www * @library /test/lib * @run main/othervm B8185898 @@ -143,32 +143,32 @@ static void testMessageHeaderMethods() throws IOException { // {{inputString1, expectedToString1, expectedPrint1}, {...}} String[][] strings = { {"HTTP/1.1 200 OK\r\n" - + "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n" + + "Accept: */*\r\n" + "Connection: keep-alive\r\n" + "Host: 127.0.0.1:12345\r\n" + "User-agent: Java/12\r\n\r\nfoooo", "pairs: {null: HTTP/1.1 200 OK}" - + "{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}" + + "{Accept: */*}" + "{Connection: keep-alive}" + "{Host: 127.0.0.1:12345}" + "{User-agent: Java/12}", - "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n" + "Accept: */*\r\n" + "Connection: keep-alive\r\n" + "Host: 127.0.0.1:12345\r\n" + "User-agent: Java/12\r\n\r\n"}, {"HTTP/1.1 200 OK\r\n" - + "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n" + + "Accept: */*\r\n" + "Connection: keep-alive\r\n" + "Host: 127.0.0.1:12345\r\n" + "User-agent: Java/12\r\n" + "X-Header:\r\n\r\n", "pairs: {null: HTTP/1.1 200 OK}" - + "{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}" + + "{Accept: */*}" + "{Connection: keep-alive}" + "{Host: 127.0.0.1:12345}" + "{User-agent: Java/12}" + "{X-Header: }", - "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n" + "Accept: */*\r\n" + "Connection: keep-alive\r\n" + "Host: 127.0.0.1:12345\r\n" + "User-agent: Java/12\r\n" From 7491ed45bb1d7fd9aae7b6cd0000223f059bc015 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:17:49 +0000 Subject: [PATCH 099/149] 8302069: javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java update Backport-of: 1c7b09bc23ac37f83b9043de35b71bea7e814da5 --- test/jdk/ProblemList.txt | 2 -- .../notif/NotifReconnectDeadlockTest.java | 22 ++++++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 581f721c4fe..5bf69113f80 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -533,8 +533,6 @@ java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java 8247426 generic- javax/management/MBeanServer/OldMBeanServerTest.java 8030957 aix-all -javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java 8042215 generic-all - ############################################################################ # jdk_net diff --git a/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java b/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java index 72319d72cb9..3f16ed00369 100644 --- a/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java +++ b/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -87,7 +87,10 @@ public static void main(String[] args) throws Exception { JMXServiceURL addr = server.getAddress(); JMXConnector client = JMXConnectorFactory.connect(addr, env); - Thread.sleep(100); // let pass the first client open notif if there is + // Sleeping here was an attempt to avoid seeing an initial notification. + // This does not work, but does not matter. + // Thread.sleep(100); + client.getMBeanServerConnection().addNotificationListener(oname, listener, null, @@ -100,12 +103,13 @@ public static void main(String[] args) throws Exception { synchronized(lock) { while(clientState == null && System.currentTimeMillis() < end) { + System.out.println("Calling sendNotifications"); mbs.invoke(oname, "sendNotifications", new Object[] {new Notification("MyType", "", 0)}, new String[] {"javax.management.Notification"}); try { - lock.wait(10); + lock.wait(1000); // sleep as no point in constant notifications } catch (Exception e) {} } } @@ -143,10 +147,10 @@ public interface NotificationEmitterMBean { private final static NotificationListener listener = new NotificationListener() { public void handleNotification(Notification n, Object hb) { - // treat the client notif to know the end + System.out.println("handleNotification: " + n); if (n instanceof JMXConnectionNotification) { if (!JMXConnectionNotification.NOTIFS_LOST.equals(n.getType())) { - + // Expected: [type=jmx.remote.connection.opened][message=Reconnected to server] clientState = n.getType(); System.out.println( ">>> The client state has been changed to: "+clientState); @@ -159,7 +163,7 @@ public void handleNotification(Notification n, Object hb) { return; } - System.out.println(">>> Do sleep to make reconnection."); + System.out.println(">>> sleeping in NotificationListener to force reconnection."); synchronized(lock) { try { lock.wait(listenerSleep); @@ -170,9 +174,11 @@ public void handleNotification(Notification n, Object hb) { } }; - private static final long serverTimeout = 1000; + // serverTimeout increased to avoid occasional problems with initial connect. + // Not using Utils.adjustTimeout to avoid accidentally making it too long. + private static final long serverTimeout = 2000; private static final long listenerSleep = serverTimeout*6; - private static String clientState = null; + private volatile static String clientState = null; private static final int[] lock = new int[0]; } From 4ca2d02974f6e76286aba7a5cbf56a15f93f48b3 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:18:20 +0000 Subject: [PATCH 100/149] 8305874: Open source AWT Key, Text Event related tests Backport-of: d6cf4aa1551df591c7bc75cb8c5e90d57630ca2a --- .../KeyEvent/KeyTyped/DeleteKeyTyped.java | 143 ++++++++++++++++++ .../KeyEvent/KeyTyped/EscapeKeyTyped.java | 136 +++++++++++++++++ .../java/awt/event/KeyEvent/ShiftF10Test.java | 68 +++++++++ .../OtherEvents/ContainerEventChildTest.java | 87 +++++++++++ .../event/TextEvent/InitialTextEventTest.java | 113 ++++++++++++++ 5 files changed, 547 insertions(+) create mode 100644 test/jdk/java/awt/event/KeyEvent/KeyTyped/DeleteKeyTyped.java create mode 100644 test/jdk/java/awt/event/KeyEvent/KeyTyped/EscapeKeyTyped.java create mode 100644 test/jdk/java/awt/event/KeyEvent/ShiftF10Test.java create mode 100644 test/jdk/java/awt/event/OtherEvents/ContainerEventChildTest.java create mode 100644 test/jdk/java/awt/event/TextEvent/InitialTextEventTest.java diff --git a/test/jdk/java/awt/event/KeyEvent/KeyTyped/DeleteKeyTyped.java b/test/jdk/java/awt/event/KeyEvent/KeyTyped/DeleteKeyTyped.java new file mode 100644 index 00000000000..cde75cf7c3a --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/KeyTyped/DeleteKeyTyped.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +/* + * @test + * @bug 4724007 + * @key headful + * @summary Tests that KeyTyped events are fired for the Delete key + * and that no extraneous characters are entered as a result. + */ + +public class DeleteKeyTyped { + private static Frame frame; + private static TextField tf; + + private static boolean deleteKeyTypedReceived = false; + private static final String ORIGINAL = "0123456789"; + private static final String SUCCESS = "123456789"; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(100); + + EventQueue.invokeAndWait(DeleteKeyTyped::createTestUI); + robot.waitForIdle(); + robot.delay(1000); + + // Move cursor to start of TextField + robot.keyPress(KeyEvent.VK_HOME); + robot.keyRelease(KeyEvent.VK_HOME); + robot.waitForIdle(); + robot.delay(50); + + // Press and release Delete + robot.keyPress(KeyEvent.VK_DELETE); + robot.keyRelease(KeyEvent.VK_DELETE); + robot.waitForIdle(); + robot.delay(50); + + EventQueue.invokeAndWait(DeleteKeyTyped::testDeleteKeyEvent); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createTestUI() { + frame = new Frame(); + tf = new TextField(ORIGINAL, 20); + frame.add(tf); + frame.setSize(300, 100); + frame.setVisible(true); + tf.requestFocusInWindow(); + + tf.addKeyListener(new KeyListener() { + @Override + public void keyPressed(KeyEvent evt) { + printKey(evt); + } + + @Override + public void keyTyped(KeyEvent evt) { + printKey(evt); + int keychar = evt.getKeyChar(); + if (keychar == 127) { // Delete character is 127 or \u007F + deleteKeyTypedReceived = true; + } + } + + @Override + public void keyReleased(KeyEvent evt) { + printKey(evt); + } + + private void printKey(KeyEvent evt) { + switch(evt.getID()) { + case KeyEvent.KEY_TYPED: + case KeyEvent.KEY_PRESSED: + case KeyEvent.KEY_RELEASED: + break; + default: + System.out.println("Other Event"); + return; + } + + System.out.println("params= " + evt.paramString() + " \n" + + "KeyChar: " + evt.getKeyChar() + " = " + (int) evt.getKeyChar() + + " KeyCode: " + evt.getKeyCode() + + " Modifiers: " + evt.getModifiersEx()); + + if (evt.isActionKey()) { + System.out.println("Action Key"); + } + + System.out.println("keyText= " + KeyEvent.getKeyText(evt.getKeyCode()) + "\n"); + } + }); + } + + private static void testDeleteKeyEvent() { + if (deleteKeyTypedReceived) { + if (tf.getText().equals(SUCCESS)) { + System.out.println("Test PASSED"); + } else { + System.out.println("Test FAILED: wrong string"); + throw new RuntimeException("The test failed: wrong string: " + + tf.getText()); + } + } + } +} diff --git a/test/jdk/java/awt/event/KeyEvent/KeyTyped/EscapeKeyTyped.java b/test/jdk/java/awt/event/KeyEvent/KeyTyped/EscapeKeyTyped.java new file mode 100644 index 00000000000..6410fc4bad8 --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/KeyTyped/EscapeKeyTyped.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.TextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +/* + * @test + * @key headful + * @bug 4734408 + * @summary Tests that KeyTyped events are fired for the Escape key + * and that no extraneous characters are entered as a result. + */ + +public class EscapeKeyTyped { + private static Frame frame; + private static TextField tf; + + private static final String ORIGINAL = "0123456789"; + private static boolean escapeKeyTypedReceived = false; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(30); + + EventQueue.invokeAndWait(EscapeKeyTyped::createAndShowUI); + robot.waitForIdle(); + robot.delay(1000); + + // Press and release Escape + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.waitForIdle(); + robot.delay(20); + + EventQueue.invokeAndWait(EscapeKeyTyped::testEscKeyEvent); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private static void createAndShowUI() { + frame = new Frame(); + tf = new TextField(ORIGINAL, 20); + frame.add(tf); + frame.setSize(300, 100); + frame.setVisible(true); + tf.requestFocusInWindow(); + + tf.addKeyListener(new KeyListener() { + @Override + public void keyTyped(KeyEvent e) { + printKey(e); + } + + @Override + public void keyPressed(KeyEvent e) { + printKey(e); + int keychar = e.getKeyChar(); + if (keychar == 27) { // Escape character is 27 or \u0021 + escapeKeyTypedReceived = true; + } + } + + @Override + public void keyReleased(KeyEvent e) { + printKey(e); + } + + private void printKey(KeyEvent evt) { + switch (evt.getID()) { + case KeyEvent.KEY_TYPED: + case KeyEvent.KEY_PRESSED: + case KeyEvent.KEY_RELEASED: + break; + default: + System.out.println("Other Event"); + return; + } + + System.out.println("params= " + evt.paramString() + " \n" + + "KeyChar: " + evt.getKeyChar() + " = " + (int) evt.getKeyChar() + + " KeyCode: " + evt.getKeyCode() + + " Modifiers: " + evt.getModifiersEx()); + + if (evt.isActionKey()) { + System.out.println("Action Key"); + } + + System.out.println("keyText= " + KeyEvent.getKeyText(evt.getKeyCode()) + "\n"); + } + }); + } + + private static void testEscKeyEvent() { + if (escapeKeyTypedReceived) { + if (tf.getText().equals(ORIGINAL)) { + System.out.println("Test PASSED"); + } else { + System.out.println("Test FAILED: wrong string"); + throw new RuntimeException("The test failed: wrong string: " + + tf.getText()); + } + } + } +} diff --git a/test/jdk/java/awt/event/KeyEvent/ShiftF10Test.java b/test/jdk/java/awt/event/KeyEvent/ShiftF10Test.java new file mode 100644 index 00000000000..df002164ef8 --- /dev/null +++ b/test/jdk/java/awt/event/KeyEvent/ShiftF10Test.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2004, 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. + * + * 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. + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Robot; +import java.awt.event.KeyEvent; + +/* + * @test + * @key headful + * @bug 4965227 + * @requires (os.family == "linux") + * @summary tests that Shift+F10 during Window show doesn't cause deadlock- Linux only + */ + +public class ShiftF10Test { + private static Frame frame; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(10); + + EventQueue.invokeLater(() -> { + frame = new Frame("Deadlocking one"); + frame.setSize(100, 100); + frame.setVisible(true); + }); + + for (int i = 0; i < 250; i++) { + robot.keyPress(KeyEvent.VK_SHIFT); + robot.keyPress(KeyEvent.VK_F10); + robot.keyRelease(KeyEvent.VK_F10); + robot.keyRelease(KeyEvent.VK_SHIFT); + robot.delay(10); + } + } catch (Exception e) { + throw new RuntimeException("Test Failed due to following error: ", e); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} diff --git a/test/jdk/java/awt/event/OtherEvents/ContainerEventChildTest.java b/test/jdk/java/awt/event/OtherEvents/ContainerEventChildTest.java new file mode 100644 index 00000000000..5e0d6a4d32a --- /dev/null +++ b/test/jdk/java/awt/event/OtherEvents/ContainerEventChildTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 1998, 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. + * + * 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. + */ + +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Panel; +import java.awt.event.ContainerAdapter; +import java.awt.event.ContainerEvent; + +/* + * @test + * @key headful + * @bug 4028904 + * @summary Tests whether System.out.println(ContainerEvent e) + * yields incorrect display or not. + */ + +public class ContainerEventChildTest { + private static Frame frame; + private static String com1, com2; + + public static void main(String[] args) throws Exception { + try { + EventQueue.invokeAndWait(() -> { + frame = new Frame(); + Panel outerPanel = new Panel(); + Panel innerPanel = new Panel(); + Button b = new Button("Panel Button"); + + innerPanel.addContainerListener(new ContainerAdapter() { + public void componentAdded(ContainerEvent e) { + String str1 = e.toString(); + String str2 = (e.getChild()).toString(); + + // extracting child values from ContainerEvent i.e., "e" and "e.getChild()" + com1 = str1.substring(str1.indexOf("child") + 6, str1.indexOf("]")); + com2 = str2.substring(str2.indexOf("[") + 1, str2.indexOf(",")); + + System.out.println("e : " + com1); + System.out.println("e.getChild() : " + com2); + + // comparing the child values between "e" and "e.getChild()" + // if child value of "e" equals null and child values between + // "e" and "e.getChild()" are not equal then throws exception + if (com1.equals("null") && !(com1.equals(com2))) { + System.out.println("unequal"); + throw new RuntimeException("Test Failed e.toString returns false value"); + } else { + System.out.println("Test Passed - e and e.getChild() are same"); + } + } + }); + innerPanel.add(b); + outerPanel.add(innerPanel); + frame.add(outerPanel); + frame.setVisible(true); + }); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} diff --git a/test/jdk/java/awt/event/TextEvent/InitialTextEventTest.java b/test/jdk/java/awt/event/TextEvent/InitialTextEventTest.java new file mode 100644 index 00000000000..00d3e16a618 --- /dev/null +++ b/test/jdk/java/awt/event/TextEvent/InitialTextEventTest.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.IllegalComponentStateException; +import java.awt.Point; +import java.awt.Robot; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.event.TextEvent; +import java.awt.event.TextListener; + +/* + * @test + * @bug 4503516 + * @key headful + * @summary TextEvent behaves differently across platforms, especially Solaris. + * Following testcase is used to test whether an initial TextEvent + * is triggered when a TextArea or TextField is initially added to UI. + */ + +public class InitialTextEventTest implements TextListener { + private static Frame frame; + private static TextField textField; + private static TextArea textArea; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + + InitialTextEventTest textEventObj = new InitialTextEventTest(); + EventQueue.invokeAndWait(textEventObj::createUI); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(textEventObj::testInitialTextEvent); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + private void createUI() { + frame = new Frame(); + frame.setTitle("Text Event Test"); + frame.setLayout(new FlowLayout()); + + textField = new TextField("TextField"); + textArea = new TextArea("TextArea", 5, 10); + + textField.addTextListener(this); + textArea.addTextListener(this); + + frame.add(textField); + frame.add(textArea); + + frame.setBackground(Color.red); + frame.setSize(500,200); + frame.setVisible(true); + } + + private void testInitialTextEvent() { + Point pt; + boolean drawn = false; + while (!drawn) { + try { + pt = textArea.getLocationOnScreen(); + System.out.println("On-Screen Location on Text Area: " + pt); + pt = textField.getLocationOnScreen(); + System.out.println("On-Screen Location on Text Field: " + pt); + } catch (IllegalComponentStateException icse) { + try { + Thread.sleep(50); + } catch (InterruptedException ignored) {} + continue; + } + drawn = true; + } + } + + @Override + public void textValueChanged(TextEvent e) { + System.out.println("text event paramString: " + e.paramString()); + System.out.println("text event changed on: " + e.getSource().getClass().getName()); + throw new RuntimeException("InitialTextEventTest FAILED"); + } +} From f1687ea796874df6855c2ee78c53acef689dddc4 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:18:40 +0000 Subject: [PATCH 101/149] 8306634: Open source AWT Event related tests Backport-of: 9ed456fac87f598af7d71f9c0887234a09e10eed --- test/jdk/java/awt/Component/RepaintTest.java | 81 ++++++++ .../MouseEventAbsoluteCoordsTest.java | 191 ++++++++++++++++++ .../event/OtherEvents/UndecoratedShrink.java | 76 +++++++ .../swing/JInternalFrame/bug4212562.java | 43 ++++ .../jdk/sun/awt/font/DoubleAntialiasTest.java | 104 ++++++++++ 5 files changed, 495 insertions(+) create mode 100644 test/jdk/java/awt/Component/RepaintTest.java create mode 100644 test/jdk/java/awt/event/MouseEvent/MouseEventAbsoluteCoordsTest.java create mode 100644 test/jdk/java/awt/event/OtherEvents/UndecoratedShrink.java create mode 100644 test/jdk/javax/swing/JInternalFrame/bug4212562.java create mode 100644 test/jdk/sun/awt/font/DoubleAntialiasTest.java diff --git a/test/jdk/java/awt/Component/RepaintTest.java b/test/jdk/java/awt/Component/RepaintTest.java new file mode 100644 index 00000000000..69d0ff8e3d4 --- /dev/null +++ b/test/jdk/java/awt/Component/RepaintTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Point; +import java.awt.Robot; + +/* + * @test + * @bug 4189198 + * @key headful + * @summary updateClient should post a PaintEvent + */ + +public class RepaintTest { + private static volatile Frame frame; + private static volatile Label label; + private static volatile Point frameLoc; + + private static final int FRAME_DIM = 100; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + EventQueue.invokeAndWait(() -> { + frame = new Frame("Repaint Tester"); + frame.setSize(FRAME_DIM, FRAME_DIM); + label = new Label("Hi"); + frame.add(label); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + label.setBackground(Color.GREEN); + label.repaint(); + frameLoc = frame.getLocationOnScreen(); + }); + robot.waitForIdle(); + robot.delay(500); + + Color expectedColor = robot.getPixelColor(frameLoc.x + FRAME_DIM / 2, + frameLoc.y + FRAME_DIM / 2); + if (!Color.GREEN.equals(expectedColor)) { + throw new RuntimeException("Test Failed! \n" + + "PaintEvent was not triggered: "); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} diff --git a/test/jdk/java/awt/event/MouseEvent/MouseEventAbsoluteCoordsTest.java b/test/jdk/java/awt/event/MouseEvent/MouseEventAbsoluteCoordsTest.java new file mode 100644 index 00000000000..2444861ff54 --- /dev/null +++ b/test/jdk/java/awt/event/MouseEvent/MouseEventAbsoluteCoordsTest.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2005, 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. + * + * 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. + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/* + * @test + * @bug 4992908 + * @key headful + * @summary Need way to get location of MouseEvent in screen coordinates + */ + +// The test consists of several parts: +// 1. create MouseEvent with new Ctor and checking get(X|Y)OnScreen(), +// getLocationOnScreen(), get(X|Y), getPoint(). +// 2. create MouseEvent with old Ctor and checking get(X|Y)OnScreen(), +// getLocationOnScreen(), get(X|Y), getPoint() . + +public class MouseEventAbsoluteCoordsTest implements MouseListener { + private static Frame frame; + private static Robot robot; + + private static Point mousePositionOnScreen = new Point(200, 200); + private static final Point mousePosition = new Point(100, 100); + + public static void main(String[] args) throws Exception { + try { + robot = new Robot(); + robot.setAutoWaitForIdle(true); + robot.setAutoDelay(50); + + MouseEventAbsoluteCoordsTest cordsTest = + new MouseEventAbsoluteCoordsTest(); + cordsTest.createTestUI(); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + public void createTestUI() throws Exception { + EventQueue.invokeAndWait(() -> { + frame = new Frame("MouseEvent Test Frame"); + frame.setSize(200, 200); + frame.setLocation(300, 400); + frame.addMouseListener(this); + frame.setVisible(true); + }); + + robot.waitForIdle(); + robot.delay(1000); + + // use new MouseEvent's Ctor with user-defined absolute + // coordinates + System.out.println("Stage MOUSE_PRESSED"); + postMouseEventNewCtor(MouseEvent.MOUSE_PRESSED); + + System.out.println("Stage MOUSE_RELEASED"); + postMouseEventNewCtor(MouseEvent.MOUSE_RELEASED); + + System.out.println("Stage MOUSE_CLICKED"); + postMouseEventNewCtor(MouseEvent.MOUSE_CLICKED); + + // call syncLocation to get correct on-screen frame position + syncLocationToWindowManager(); + + // now we gonna use old MouseEvent's Ctor thus absolute + // position calculates as frame's location + relative coords + // of the event. + EventQueue.invokeAndWait(() -> mousePositionOnScreen = new Point( + frame.getLocationOnScreen().x + mousePosition.x, + frame.getLocationOnScreen().y + mousePosition.y)); + + System.out.println("Stage MOUSE_PRESSED"); + postMouseEventOldCtor(MouseEvent.MOUSE_PRESSED); + + System.out.println("Stage MOUSE_RELEASED"); + postMouseEventOldCtor(MouseEvent.MOUSE_RELEASED); + + System.out.println("Stage MOUSE_CLICKED"); + postMouseEventOldCtor(MouseEvent.MOUSE_CLICKED); + } + + private static void syncLocationToWindowManager() { + Toolkit.getDefaultToolkit().sync(); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + @Override + public void mousePressed(MouseEvent e) { + checkEventAbsolutePosition(e, "MousePressed OK"); + }; + + @Override + public void mouseExited(MouseEvent e) { + System.out.println("mouse exited"); + }; + + @Override + public void mouseReleased(MouseEvent e) { + checkEventAbsolutePosition(e, "MousePressed OK"); + }; + + @Override + public void mouseEntered(MouseEvent e) { + System.out.println("mouse entered"); + }; + + @Override + public void mouseClicked(MouseEvent e) { + checkEventAbsolutePosition(e, "MousePressed OK"); + }; + + public void postMouseEventNewCtor(int MouseEventType) { + MouseEvent mouseEvt = new MouseEvent(frame, + MouseEventType, + System.currentTimeMillis(), + MouseEvent.BUTTON1_DOWN_MASK, + mousePosition.x, mousePosition.y, + mousePositionOnScreen.x, + mousePositionOnScreen.y, + 1, + false, + MouseEvent.NOBUTTON + ); + frame.dispatchEvent(mouseEvt); + } + + public void postMouseEventOldCtor(int MouseEventType) { + MouseEvent oldMouseEvt = new MouseEvent(frame, + MouseEventType, + System.currentTimeMillis(), + MouseEvent.BUTTON1_DOWN_MASK, + mousePosition.x, mousePosition.y, + 1, + false, + MouseEvent.NOBUTTON + ); + frame.dispatchEvent(oldMouseEvt); + } + + public void checkEventAbsolutePosition(MouseEvent evt, String message) { + if (evt.getXOnScreen() != mousePositionOnScreen.x || + evt.getYOnScreen() != mousePositionOnScreen.y || + !evt.getLocationOnScreen().equals( mousePositionOnScreen)) { + System.out.println("evt.location = "+evt.getLocationOnScreen()); + System.out.println("mouse.location = "+mousePositionOnScreen); + throw new RuntimeException("get(X|Y)OnScreen() or getPointOnScreen() work incorrectly"); + } + + if (evt.getX() != mousePosition.x || + evt.getY() != mousePosition.y || + !evt.getPoint().equals( mousePosition)) { + throw new RuntimeException("get(X|Y)() or getPoint() work incorrectly"); + } + System.out.println(message); + } +} diff --git a/test/jdk/java/awt/event/OtherEvents/UndecoratedShrink.java b/test/jdk/java/awt/event/OtherEvents/UndecoratedShrink.java new file mode 100644 index 00000000000..1ac59666ca5 --- /dev/null +++ b/test/jdk/java/awt/event/OtherEvents/UndecoratedShrink.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2001, 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. + * + * 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. + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Robot; + +/* + * @test + * @bug 4418155 + * @key headful + * @summary Checks Undecorated Frame repaints when shrinking + */ + +public class UndecoratedShrink extends Frame { + private static boolean passed = false; + private static UndecoratedShrink frame; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + EventQueue.invokeAndWait(() -> { + frame = new UndecoratedShrink(); + frame.setUndecorated(true); + frame.setSize(100, 100); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + frame.setSize(50, 50); + frame.repaint(); + }); + robot.waitForIdle(); + robot.delay(500); + + if (!passed) { + throw new RuntimeException("Test Fails." + + " Frame does not get repainted"); + } + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + @Override + public void paint(Graphics g) { + passed = true; + } +} diff --git a/test/jdk/javax/swing/JInternalFrame/bug4212562.java b/test/jdk/javax/swing/JInternalFrame/bug4212562.java new file mode 100644 index 00000000000..e63186139b9 --- /dev/null +++ b/test/jdk/javax/swing/JInternalFrame/bug4212562.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +import javax.swing.JInternalFrame; + +/* + * @test + * @bug 4212562 + * @summary To check if StackOverflow occurs if foreground is set to null. + */ + +public class bug4212562 { + public static void main(String[] args) { + try { + JInternalFrame jif = new JInternalFrame(); + jif.getContentPane().setForeground(null); + jif.getForeground(); + } catch (Exception e) { + throw new RuntimeException("Following exception occurred" + + " when getForeground() was called", e); + } + } +} diff --git a/test/jdk/sun/awt/font/DoubleAntialiasTest.java b/test/jdk/sun/awt/font/DoubleAntialiasTest.java new file mode 100644 index 00000000000..e9057922895 --- /dev/null +++ b/test/jdk/sun/awt/font/DoubleAntialiasTest.java @@ -0,0 +1,104 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.Robot; + +import static java.awt.RenderingHints.KEY_ANTIALIASING; +import static java.awt.RenderingHints.KEY_TEXT_ANTIALIASING; +import static java.awt.RenderingHints.VALUE_ANTIALIAS_ON; +import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON; + +/* + * @test + * @bug 4357180 + * @key headful + * @summary When both KEY_ANTIALIASING and KEY_TEXT_ANTIALIASING hints + * were turned on, java aborts with EXCEPTION_ACCESS_VIOLATION + * at attempt to draw characters in Hebrew or Arabic. + * This could happen immediately or after several draws, + * depending on th locale and platform. This test draws + * large number of characters that are among this range repeatedly. + */ + +public class DoubleAntialiasTest extends Panel { + private static Frame frame; + + public static void main(String[] args) throws Exception { + try { + Robot robot = new Robot(); + EventQueue.invokeAndWait(() -> { + frame = new Frame(); + frame.setTitle("DoubleAntialiasTest"); + frame.add(new DoubleAntialiasTest()); + frame.pack(); + frame.setSize(500, 500); + frame.setVisible(true); + }); + + robot.waitForIdle(); + robot.delay(2000); + } catch (Exception e) { + throw new RuntimeException("Following exception occurred" + + " when testing Antialiasing Rendering hints: ", e); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } + + @Override + public void paint(Graphics g) { + Graphics2D g2 = (Graphics2D) g; + int y = 50; + for (int i = 0; i < 2; i++) { + int k = 5; + for (int j = 0x500; j < 0x700; j++) { + g2.setRenderingHint(KEY_TEXT_ANTIALIASING, + VALUE_TEXT_ANTIALIAS_ON); + g2.setRenderingHint(KEY_ANTIALIASING, + VALUE_ANTIALIAS_ON); + g2.drawString(String.valueOf((char) j), (5 + k), y); + k = k + 15; + } + k = 5; + y += 50; + for (int j = 0x700; j > 0x500; j--) { + g2.setRenderingHint(KEY_TEXT_ANTIALIASING, + VALUE_TEXT_ANTIALIAS_ON); + g2.setRenderingHint(KEY_ANTIALIASING, + VALUE_ANTIALIAS_ON); + g2.drawString(String.valueOf((char) j), (5 + k), y); + k = k + 15; + } + y += 50; + } + } +} From ff1b975997b6aec2b7a3f64f8785b58e61646051 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:19:00 +0000 Subject: [PATCH 102/149] 8315071: Modify TrayIconScalingTest.java, PrintLatinCJKTest.java to use new PassFailJFrame's builder pattern usage Backport-of: 31e26814db5d5ad5018fb6ed2e8160e8a01938ab --- test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java | 13 ++++++++++--- .../awt/print/PrinterJob/PrintLatinCJKTest.java | 11 ++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java b/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java index e5c082ac6d2..ec878c10c20 100644 --- a/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java +++ b/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 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 @@ -85,8 +85,15 @@ public static void main(String[] args) System.out.println("SystemTray is not supported"); return; } - PassFailJFrame passFailJFrame = new PassFailJFrame("TrayIcon " + - "Test Instructions", INSTRUCTIONS, 8, 25, 85); + PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() + .title("TrayIcon Test Instructions") + .instructions(INSTRUCTIONS) + .testTimeOut(8) + .rows(25) + .columns(70) + .screenCapture() + .build(); + createAndShowGUI(); // does not have a test window, // hence only the instruction frame is positioned diff --git a/test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java b/test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java index 4b3ef8b537d..72ae0e2b67d 100644 --- a/test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java +++ b/test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -97,8 +97,13 @@ public int print(Graphics g, PageFormat pf, int pageIndex) } public static void main(String[] args) throws InterruptedException, InvocationTargetException { - PassFailJFrame passFailJFrame = new PassFailJFrame("Test Instruction" + - "Frame", info, 10, 10, 45); + PassFailJFrame passFailJFrame = new PassFailJFrame.Builder() + .title("Test Instructions Frame") + .instructions(info) + .testTimeOut(10) + .rows(10) + .columns(45) + .build(); showFrame(); passFailJFrame.awaitAndCheck(); } From e73d88f982d449822b45f1446128d49161fe995c Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:19:26 +0000 Subject: [PATCH 103/149] 8315609: Open source few more swing text/html tests Backport-of: a04c6c1ac663a1eab7d45913940cb6ac0af2c11c --- .../javax/swing/text/html/Map/bug4322891.java | 107 ++++++++++++++++ .../text/html/StyleSheet/bug4476002.java | 99 +++++++++++++++ .../swing/text/html/TableView/bug4412522.java | 115 ++++++++++++++++++ .../swing/text/html/TableView/bug4690812.java | 101 +++++++++++++++ 4 files changed, 422 insertions(+) create mode 100644 test/jdk/javax/swing/text/html/Map/bug4322891.java create mode 100644 test/jdk/javax/swing/text/html/StyleSheet/bug4476002.java create mode 100644 test/jdk/javax/swing/text/html/TableView/bug4412522.java create mode 100644 test/jdk/javax/swing/text/html/TableView/bug4690812.java diff --git a/test/jdk/javax/swing/text/html/Map/bug4322891.java b/test/jdk/javax/swing/text/html/Map/bug4322891.java new file mode 100644 index 00000000000..daee724e3a1 --- /dev/null +++ b/test/jdk/javax/swing/text/html/Map/bug4322891.java @@ -0,0 +1,107 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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. + */ + +/* + * @test + * @bug 4322891 + * @summary Tests if image map receives correct coordinates. + * @key headful + * @run main bug4322891 +*/ + +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import javax.swing.JFrame; +import javax.swing.JEditorPane; +import javax.swing.SwingUtilities; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.text.html.HTMLEditorKit; + +public class bug4322891 { + + private boolean finished = false; + private static boolean passed = false; + private static Robot robot; + private static JFrame f; + private static JEditorPane jep; + private static volatile Point p; + + public static void main(String[] args) throws Exception { + robot = new Robot(); + robot.setAutoDelay(100); + try { + bug4322891 test = new bug4322891(); + SwingUtilities.invokeAndWait(test::init); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + p = jep.getLocationOnScreen(); + }); + robot.mouseMove(p.x, p.y); + robot.waitForIdle(); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + for (int i = 1; i < 30; i++) { + robot.mouseMove(p.x + i, p.y + i); + robot.waitForIdle(); + } + if (!passed) { + throw new RuntimeException("Test failed."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } + + public void init() { + String text = "" + + "" + + "" + + ""; + + f = new JFrame(); + jep = new JEditorPane(); + jep.setEditorKit(new HTMLEditorKit()); + jep.setEditable(false); + + jep.setText(text); + + jep.addHyperlinkListener(new HyperlinkListener() { + public void hyperlinkUpdate(HyperlinkEvent e) { + passed = true; + } + }); + f.getContentPane().add(jep); + f.setSize(500,500); + f.setLocationRelativeTo(null); + f.setVisible(true); + } + +} diff --git a/test/jdk/javax/swing/text/html/StyleSheet/bug4476002.java b/test/jdk/javax/swing/text/html/StyleSheet/bug4476002.java new file mode 100644 index 00000000000..bb3a1d72b0e --- /dev/null +++ b/test/jdk/javax/swing/text/html/StyleSheet/bug4476002.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4476002 + * @summary Verifies JEditorPane:

      list numbers do not pick up color of the list text + * @key headful + * @run main bug4476002 +*/ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; + +public class bug4476002 { + + private static boolean passed = true; + private static JLabel htmlComponent; + + private static Robot robot; + private static JFrame mainFrame; + private static volatile Point p; + private static volatile Dimension d; + + public static void main(String[] args) throws Exception { + robot = new Robot(); + + try { + SwingUtilities.invokeAndWait(() -> { + String htmlText = + "" + + "
      1. wwwww
      "; + + mainFrame = new JFrame("bug4476002"); + + htmlComponent = new JLabel(htmlText); + mainFrame.getContentPane().add(htmlComponent); + + mainFrame.pack(); + mainFrame.setLocationRelativeTo(null); + mainFrame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait(() -> { + p = htmlComponent.getLocationOnScreen(); + d = htmlComponent.getSize(); + }); + int x0 = p.x; + int y = p.y + d.height/2; + + for (int x = x0; x < x0 + d.width; x++) { + if (robot.getPixelColor(x, y).equals(Color.black)) { + passed = false; + break; + } + } + if (!passed) { + throw new RuntimeException("Test failed."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (mainFrame != null) { + mainFrame.dispose(); + } + }); + } + } + +} diff --git a/test/jdk/javax/swing/text/html/TableView/bug4412522.java b/test/jdk/javax/swing/text/html/TableView/bug4412522.java new file mode 100644 index 00000000000..f983b07ecfc --- /dev/null +++ b/test/jdk/javax/swing/text/html/TableView/bug4412522.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4412522 + * @summary Tests if HTML that has comments inside of tables is rendered correctly + * @key headful + * @run main bug4412522 +*/ + +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.text.View; +import javax.swing.text.html.HTMLEditorKit; + +import java.awt.Robot; +import java.awt.Shape; + +public class bug4412522 { + + private static boolean passed = false; + + private static JEditorPane jep; + private static JFrame f; + private static Robot robot; + + public void init() { + + String text = + "" + + "" + + "" + + "
      first cellsecond cell
      row heading
      "; + + JFrame f = new JFrame(); + jep = new JEditorPane(); + jep.setEditorKit(new HTMLEditorKit()); + jep.setEditable(false); + + jep.setText(text); + + f.getContentPane().add(jep); + f.setSize(500,500); + f.setLocationRelativeTo(null); + f.setVisible(true); + } + + + public static void main(String args[]) throws Exception { + robot = new Robot(); + robot.setAutoDelay(100); + bug4412522 test = new bug4412522(); + try { + SwingUtilities.invokeAndWait(() -> test.init()); + robot.waitForIdle(); + robot.delay(1000); + Shape r = jep.getBounds(); + View v = jep.getUI().getRootView(jep); + int tableWidth = 0; + int cellsWidth = 0; + + while (!(v instanceof javax.swing.text.html.ParagraphView)) { + + int n = v.getViewCount(); + Shape sh = v.getChildAllocation(n - 1, r); + String viewName = v.getClass().getName(); + if (viewName.endsWith("TableView")) { + tableWidth = r.getBounds().width; + } + + if (viewName.endsWith("CellView")) { + cellsWidth = r.getBounds().x + r.getBounds().width; + } + + v = v.getView(n - 1); + if (sh != null) { + r = sh; + } + } + + passed = ((tableWidth - cellsWidth) > 10); + if (!passed) { + throw new RuntimeException("Test failed."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } +} diff --git a/test/jdk/javax/swing/text/html/TableView/bug4690812.java b/test/jdk/javax/swing/text/html/TableView/bug4690812.java new file mode 100644 index 00000000000..263bba71f14 --- /dev/null +++ b/test/jdk/javax/swing/text/html/TableView/bug4690812.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + * @test + * @bug 4690812 + * @summary Tests if tables are correctly formatted in some cases + * @key headful + * @run main bug4690812 +*/ + +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.text.View; +import javax.swing.text.html.HTMLEditorKit; + +import java.awt.Robot; +import java.awt.Shape; + +public class bug4690812 { + + private static boolean passed = false; + + private static JEditorPane jep; + private static JFrame f; + + public void init() { + + String text = + "" + + "" + + "" + + "" + + "
      a
      something
      "; + + JFrame f = new JFrame(); + jep = new JEditorPane(); + jep.setEditorKit(new HTMLEditorKit()); + jep.setEditable(false); + + jep.setText(text); + + f.getContentPane().add(jep); + f.setSize(500,500); + f.setLocationRelativeTo(null); + f.setVisible(true); + } + + public static void main(String args[]) throws Exception { + Robot robot = new Robot(); + bug4690812 test = new bug4690812(); + try { + SwingUtilities.invokeAndWait(() -> test.init()); + robot.waitForIdle(); + robot.delay(1000); + Shape r = jep.getBounds(); + View v = jep.getUI().getRootView(jep); + int tableHeight = 0; + while (!(v instanceof javax.swing.text.html.ParagraphView)) { + int n = v.getViewCount(); + Shape sh = v.getChildAllocation(n - 1, r); + v = v.getView(n - 1); + if (sh != null) { + r = sh; + } + } + // left column in the second table row should have width == 1 + passed = (r.getBounds().width == 1) ? true : false; + if (!passed) { + throw new RuntimeException("Test failed."); + } + } finally { + SwingUtilities.invokeAndWait(() -> { + if (f != null) { + f.dispose(); + } + }); + } + } +} From 533b45835fc245bf02a70fc684ace4d7a7bf9578 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Tue, 23 Apr 2024 07:19:43 +0000 Subject: [PATCH 104/149] 8293965: Code signing warnings after JDK-8293550 Backport-of: f91762f56ea7fb27b6fa54d07d3b3b0650bab0bc --- make/common/NativeCompilation.gmk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index d765b77ca90..cdab42b9811 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -1219,11 +1219,15 @@ define SetupNativeCompilationBody $$($1_MT) -nologo -manifest $$($1_MANIFEST) -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" -outputresource:$$@;#1 endif endif - # On macosx, optionally run codesign on every binary + # On macosx, optionally run codesign on every binary. + # Remove signature explicitly first to avoid warnings if the linker + # added a default adhoc signature. ifeq ($(MACOSX_CODESIGN_MODE), hardened) + $(CODESIGN) --remove-signature $$@ $(CODESIGN) -f -s "$(MACOSX_CODESIGN_IDENTITY)" --timestamp --options runtime \ --entitlements $$(call GetEntitlementsFile, $$@) $$@ else ifeq ($(MACOSX_CODESIGN_MODE), debug) + $(CODESIGN) --remove-signature $$@ $(CODESIGN) -f -s - --entitlements $$(call GetEntitlementsFile, $$@) $$@ endif endif From 6cce290c1f6e0a6f16ed49f44f2b5c83ef357cea Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Thu, 25 Apr 2024 15:11:48 +0000 Subject: [PATCH 105/149] 8318854: [macos14] Running any AWT app prints Secure coding warning Backport-of: 940f67c1a62c6f9462266f3a108649aca114cffa --- .../native/libawt_lwawt/awt/AWTWindow.m | 4 +- .../libawt_lwawt/awt/ApplicationDelegate.m | 61 +++++++++++++------ .../macosx/native/libawt_lwawt/awt/CMenuBar.m | 8 ++- .../libosxapp/QueuingApplicationDelegate.m | 15 +++++ 4 files changed, 64 insertions(+), 24 deletions(-) diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m index bd151ca0ea6..7fe2e394c7c 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m @@ -811,7 +811,7 @@ - (void) activateWindowMenuBar { isDisabled = !awtWindow.isEnabled; } - if (menuBar == nil) { + if (menuBar == nil && [ApplicationDelegate sharedDelegate] != nil) { menuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar]; isDisabled = NO; } @@ -1180,7 +1180,7 @@ + (AWTWindow *) lastKeyWindow { window.javaMenuBar = menuBar; CMenuBar* actualMenuBar = menuBar; - if (actualMenuBar == nil) { + if (actualMenuBar == nil && [ApplicationDelegate sharedDelegate] != nil) { actualMenuBar = [[ApplicationDelegate sharedDelegate] defaultMenuBar]; } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m index 8d1691866cf..2462f7912ed 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m @@ -116,8 +116,9 @@ + (ApplicationDelegate *)sharedDelegate { // don't install the EAWT delegate if another kind of NSApplication is installed, like say, Safari BOOL shouldInstall = NO; + BOOL overrideDelegate = (getenv("AWT_OVERRIDE_NSDELEGATE") != NULL); if (NSApp != nil) { - if ([NSApp isMemberOfClass:[NSApplication class]]) shouldInstall = YES; + if ([NSApp isMemberOfClass:[NSApplication class]] && overrideDelegate) shouldInstall = YES; if ([NSApp isKindOfClass:[NSApplicationAWT class]]) shouldInstall = YES; } checked = YES; @@ -409,6 +410,19 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)app { return NSTerminateLater; } +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app { + static BOOL checked = NO; + static BOOL supportsSecureState = YES; + + if (checked == NO) { + checked = YES; + if (getenv("AWT_DISABLE_NSDELEGATE_SECURE_SAVE") != NULL) { + supportsSecureState = NO; + } + } + return supportsSecureState; +} + + (void)_systemWillPowerOff { [self _notifyJava:com_apple_eawt__AppEventHandler_NOTIFY_SHUTDOWN]; } @@ -506,8 +520,10 @@ + (void)_setDockIconImage:(NSImage *)image { [dockImageView setImageScaling:NSImageScaleProportionallyUpOrDown]; [dockImageView setImage:image]; - [[ApplicationDelegate sharedDelegate].fProgressIndicator removeFromSuperview]; - [dockImageView addSubview:[ApplicationDelegate sharedDelegate].fProgressIndicator]; + if ([ApplicationDelegate sharedDelegate] != nil) { + [[ApplicationDelegate sharedDelegate].fProgressIndicator removeFromSuperview]; + [dockImageView addSubview:[ApplicationDelegate sharedDelegate].fProgressIndicator]; + } // add it to the NSDockTile [dockTile setContentView: dockImageView]; @@ -520,14 +536,15 @@ + (void)_setDockIconProgress:(NSNumber *)value { AWT_ASSERT_APPKIT_THREAD; ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate]; - if ([value doubleValue] >= 0 && [value doubleValue] <=100) { - [delegate.fProgressIndicator setDoubleValue:[value doubleValue]]; - [delegate.fProgressIndicator setHidden:NO]; - } else { - [delegate.fProgressIndicator setHidden:YES]; + if (delegate != nil) { + if ([value doubleValue] >= 0 && [value doubleValue] <=100) { + [delegate.fProgressIndicator setDoubleValue:[value doubleValue]]; + [delegate.fProgressIndicator setHidden:NO]; + } else { + [delegate.fProgressIndicator setHidden:YES]; + } + [[NSApp dockTile] display]; } - - [[NSApp dockTile] display]; } // Obtains the image of the Dock icon, either manually set, a drawn copy, or the default NSApplicationIcon @@ -638,7 +655,9 @@ + (NSImage *)_dockIconImage { NSMenu *menu = (NSMenu *)jlong_to_ptr(nsMenuPtr); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - [ApplicationDelegate sharedDelegate].fDockMenu = menu; + if ([ApplicationDelegate sharedDelegate] != nil) { + [ApplicationDelegate sharedDelegate].fDockMenu = menu; + } }]; JNI_COCOA_EXIT(env); @@ -818,13 +837,15 @@ + (NSImage *)_dockIconImage { [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate]; - switch (menuID) { - case com_apple_eawt__AppMenuBarHandler_MENU_ABOUT: - [delegate _updateAboutMenu:visible enabled:enabled]; - break; - case com_apple_eawt__AppMenuBarHandler_MENU_PREFS: - [delegate _updatePreferencesMenu:visible enabled:enabled]; - break; + if (delegate != nil) { + switch (menuID) { + case com_apple_eawt__AppMenuBarHandler_MENU_ABOUT: + [delegate _updateAboutMenu:visible enabled:enabled]; + break; + case com_apple_eawt__AppMenuBarHandler_MENU_PREFS: + [delegate _updatePreferencesMenu:visible enabled:enabled]; + break; + } } }]; @@ -843,7 +864,9 @@ + (NSImage *)_dockIconImage { CMenuBar *menu = (CMenuBar *)jlong_to_ptr(cMenuBarPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ - [ApplicationDelegate sharedDelegate].fDefaultMenuBar = menu; + if ([ApplicationDelegate sharedDelegate] != nil) { + [ApplicationDelegate sharedDelegate].fDefaultMenuBar = menu; + } }]; JNI_COCOA_EXIT(env); diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m index 49a6a80da21..b02cc818063 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuBar.m @@ -210,9 +210,11 @@ -(void) deactivate { // In theory, this might cause flickering if the window gaining focus // has its own menu. However, I couldn't reproduce it on practice, so // perhaps this is a non issue. - CMenuBar* defaultMenu = [[ApplicationDelegate sharedDelegate] defaultMenuBar]; - if (defaultMenu != nil) { - [CMenuBar activate:defaultMenu modallyDisabled:NO]; + if ([ApplicationDelegate sharedDelegate] != nil) { + CMenuBar* defaultMenu = [[ApplicationDelegate sharedDelegate] defaultMenuBar]; + if (defaultMenu != nil) { + [CMenuBar activate:defaultMenu modallyDisabled:NO]; + } } } } diff --git a/src/java.desktop/macosx/native/libosxapp/QueuingApplicationDelegate.m b/src/java.desktop/macosx/native/libosxapp/QueuingApplicationDelegate.m index 034a990ebc8..ced48c72a36 100644 --- a/src/java.desktop/macosx/native/libosxapp/QueuingApplicationDelegate.m +++ b/src/java.desktop/macosx/native/libosxapp/QueuingApplicationDelegate.m @@ -200,6 +200,21 @@ - (void)_appDidUnhide } copy]]; } + +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app +{ + static BOOL checked = NO; + static BOOL supportsSecureState = YES; + + if (checked == NO) { + checked = YES; + if (getenv("AWT_DISABLE_NSDELEGATE_SECURE_SAVE") != NULL) { + supportsSecureState = NO; + } + } + return supportsSecureState; +} + - (void)processQueuedEventsWithTargetDelegate:(id )delegate { self.realDelegate = delegate; From 1ea18523ec5ef263e54e5835013d7304c61ebb2c Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Thu, 25 Apr 2024 15:27:48 +0000 Subject: [PATCH 106/149] 8187759: Background not refreshed when painting over a transparent JFrame Backport-of: 04d43c435d3ede519df169053dd9d724aa2312eb --- .../swing/BufferStrategyPaintManager.java | 9 + .../JFrame/JFrameBackgroundRefreshTest.java | 210 ++++++++++++++++++ 2 files changed, 219 insertions(+) create mode 100644 test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java diff --git a/src/java.desktop/share/classes/javax/swing/BufferStrategyPaintManager.java b/src/java.desktop/share/classes/javax/swing/BufferStrategyPaintManager.java index 9ea050b0d80..3efacfcf225 100644 --- a/src/java.desktop/share/classes/javax/swing/BufferStrategyPaintManager.java +++ b/src/java.desktop/share/classes/javax/swing/BufferStrategyPaintManager.java @@ -243,6 +243,15 @@ public boolean paint(JComponent paintingComponent, ((SunGraphics2D)bsg).constrain(xOffset + cx, yOffset + cy, x + w, y + h); bsg.setClip(x, y, w, h); + + if (!bufferComponent.isOpaque()) { + final SunGraphics2D g2d = (SunGraphics2D) bsg; + final Color oldBg = g2d.getBackground(); + g2d.setBackground(paintingComponent.getBackground()); + g2d.clearRect(x, y, w, h); + g2d.setBackground(oldBg); + } + paintingComponent.paintToOffscreen(bsg, x, y, w, h, x + w, y + h); accumulate(xOffset + x, yOffset + y, w, h); diff --git a/test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java b/test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java new file mode 100644 index 00000000000..cb2e0051216 --- /dev/null +++ b/test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java @@ -0,0 +1,210 @@ +/* + * 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. + * + * 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. + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.MouseInfo; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +/* + * @test + * @key headful + * @bug 8187759 + * @summary Test to check if JFrame background is refreshed in Linux. + * @requires (os.family == "linux") + * @run main JFrameBackgroundRefreshTest + */ + +public class JFrameBackgroundRefreshTest { + public static JFrame frame; + private static final BufferedImage test = generateImage(); + private static Point p = new Point(); + private static Robot robot; + private static JFrame whiteFrame; + private static Point frameLocation; + private static int frameCenterX, frameCenterY, awayX, awayY; + private static int imageCenterX, imageCenterY; + + public static void main(String[] args) throws Exception { + try { + SwingUtilities.invokeAndWait(() -> { + try { + JFrameBackgroundRefreshTest.initialize(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + + SwingUtilities.invokeAndWait(() -> { + frameLocation = whiteFrame.getLocationOnScreen(); + frameCenterX = frameLocation.x + whiteFrame.getWidth() / 2; + frameCenterY = frameLocation.y + whiteFrame.getHeight() / 2; + awayX = frameLocation.x + whiteFrame.getWidth() + 100; + awayY = frameLocation.y + whiteFrame.getHeight() / 2; + imageCenterX = p.x + test.getWidth() / 2; + imageCenterY = p.y + test.getHeight() / 2; + }); + robot.delay(100); + robot.waitForIdle(); + robot.mouseMove(imageCenterX, imageCenterY); + robot.delay(100); + robot.waitForIdle(); + moveMouseSlowly(frameCenterX, frameCenterY); + robot.delay(1000); + robot.waitForIdle(); + + moveMouseSlowly(awayX, awayY); + robot.delay(100); + robot.waitForIdle(); + Rectangle screenCaptureRect = new Rectangle(frameCenterX - 50, + frameCenterY - 50, 100, 100); + BufferedImage bufferedImage = robot.createScreenCapture(screenCaptureRect); + + if (!compareImages(bufferedImage)) { + try { + ImageIO.write(bufferedImage, "png", + new File("FailureImage.png")); + } catch (IOException e) { + e.printStackTrace(); + } + throw new RuntimeException("Test Failed!"); + } + System.out.println("Test Passed!"); + } finally { + SwingUtilities.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + if (whiteFrame != null) { + whiteFrame.dispose(); + } + }); + } + } + + private static void moveMouseSlowly( int targetX, int targetY) { + Point currentMousePos = MouseInfo.getPointerInfo().getLocation(); + int currentX = currentMousePos.x; + int currentY = currentMousePos.y; + int deltaX = targetX - currentX; + int deltaY = targetY - currentY; + int steps = 50; + double stepX = (double) deltaX / steps; + double stepY = (double) deltaY / steps; + for (int i = 1; i <= steps; i++) { + int nextX = currentX + (int) Math.round(i * stepX); + int nextY = currentY + (int) Math.round(i * stepY); + robot.mouseMove(nextX, nextY); + robot.delay(10); + } + robot.mouseMove(targetX, targetY); + } + + private static boolean compareImages(BufferedImage bufferedImage) { + int sampleRGB = bufferedImage.getRGB(0,0); + for (int x = 0; x < bufferedImage.getWidth(); x++) { + for (int y = 0; y < bufferedImage.getHeight(); y++) { + if (bufferedImage.getRGB(x, y) != sampleRGB) { + return false; + } + } + } + return true; + } + + public static void initialize() throws Exception { + frame = new JFrame("JFrame Background refresh test"); + whiteFrame = new JFrame("White Frame"); + robot = new Robot(); + whiteFrame.setSize(200, 200); + whiteFrame.setBackground(Color.WHITE); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setUndecorated(true); + frame.setExtendedState(JFrame.MAXIMIZED_BOTH); + frame.setBackground(new Color(0, 0, 0, 0)); + frame.setContentPane(new TranslucentPane()); + frame.addMouseMotionListener(new MouseDragListener()); + whiteFrame.setLocationRelativeTo(null); + whiteFrame.setVisible(true); + frame.setVisible(true); + frame.setAlwaysOnTop(true); + } + private static class MouseDragListener extends MouseAdapter { + @Override + public void mouseMoved(MouseEvent e) { + p = e.getPoint(); + frame.repaint(); + } + } + + /** Capture an image of any component **/ + private static BufferedImage getImage(Component c) { + if (c == null) { + return null; + } + BufferedImage image = new BufferedImage(c.getWidth(), + c.getHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics2D g = image.createGraphics(); + c.printAll(g); + g.dispose(); + return image; + } + + /** Generates a dummy image to be painted on the frame **/ + private static BufferedImage generateImage() { + JLabel label = new JLabel("test"); + label.setFont(new Font("Arial", Font.BOLD, 24)); + label.setSize(label.getPreferredSize()); + return getImage(label); + } + + public static class TranslucentPane extends JPanel { + public TranslucentPane() { + setOpaque(false); + } + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setColor(new Color(0,0,0,0)); + g2d.fillRect(0, 0, getWidth(), getHeight()); + g2d.drawImage(test, p.x, p.y, this); + g2d.dispose(); + } + } +} From decacb83b2b7902cd67642616766a4f341cae538 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Thu, 25 Apr 2024 15:28:13 +0000 Subject: [PATCH 107/149] 8282017: sun/net/www/protocol/https/HttpsURLConnection/B6216082.java fails with "SocketException: Unexpected end of file from server" Reviewed-by: lucy Backport-of: cd9a3cf05b2c200709103e2e8596414a62a1c441 --- .../www/protocol/https/HttpsURLConnection/TunnelProxy.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java index 43542941416..2326c57d9cf 100644 --- a/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java +++ b/test/jdk/sun/net/www/protocol/https/HttpsURLConnection/TunnelProxy.java @@ -263,9 +263,9 @@ private boolean read (SocketChannel chan, SelectionKey key) { boolean res; try { InputStream is = new BufferedInputStream (new NioInputStream (chan)); - String requestline = readLine (is); - HttpHeaderParser mhead = new HttpHeaderParser (is); - String[] req = requestline.split (" "); + HttpHeaderParser mHead = new HttpHeaderParser (is); + String requestLine = mHead.getRequestDetails(); + String[] req = requestLine.split (" "); if (req.length < 2) { /* invalid request line */ return false; From dabf4d16a190f5169a2eb56ff964f9a3365bce62 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Thu, 25 Apr 2024 15:31:02 +0000 Subject: [PATCH 108/149] 8220202: Simplify/standardize method naming for HtmlTree Reviewed-by: lucy Backport-of: 1b9db9b7a131f7cf24b0ca64337ff61ad3544ef5 --- .../html/AbstractExecutableMemberWriter.java | 78 +++---- .../formats/html/AbstractIndexWriter.java | 70 +++--- .../formats/html/AbstractMemberWriter.java | 44 ++-- .../html/AbstractModuleIndexWriter.java | 22 +- .../html/AbstractPackageIndexWriter.java | 12 +- .../formats/html/AbstractTreeWriter.java | 20 +- .../formats/html/AllClassesFrameWriter.java | 8 +- .../formats/html/AllClassesIndexWriter.java | 22 +- .../formats/html/AllPackagesIndexWriter.java | 20 +- .../html/AnnotationTypeFieldWriterImpl.java | 24 +- ...nnotationTypeOptionalMemberWriterImpl.java | 10 +- ...nnotationTypeRequiredMemberWriterImpl.java | 24 +- .../html/AnnotationTypeWriterImpl.java | 46 ++-- .../doclets/formats/html/ClassUseWriter.java | 40 ++-- .../doclets/formats/html/ClassWriterImpl.java | 120 +++++----- .../html/ConstantsSummaryWriterImpl.java | 64 +++--- .../formats/html/ConstructorWriterImpl.java | 30 +-- .../doclets/formats/html/Contents.java | 18 +- .../formats/html/DeprecatedListWriter.java | 28 +-- .../formats/html/DocFilesHandlerImpl.java | 6 +- .../formats/html/EnumConstantWriterImpl.java | 24 +- .../doclets/formats/html/FieldWriterImpl.java | 34 +-- .../formats/html/FrameOutputWriter.java | 22 +- .../doclets/formats/html/HelpWriter.java | 206 +++++++++--------- .../formats/html/HtmlDocletWriter.java | 130 +++++------ .../formats/html/HtmlSerialFieldWriter.java | 32 +-- .../formats/html/HtmlSerialMethodWriter.java | 10 +- .../formats/html/IndexRedirectWriter.java | 16 +- .../doclets/formats/html/LinkFactoryImpl.java | 30 +-- .../formats/html/MethodWriterImpl.java | 62 +++--- .../formats/html/ModuleFrameWriter.java | 14 +- .../formats/html/ModuleIndexFrameWriter.java | 18 +- .../formats/html/ModuleIndexWriter.java | 12 +- .../html/ModulePackageIndexFrameWriter.java | 30 +-- .../formats/html/ModuleWriterImpl.java | 98 ++++----- .../formats/html/NestedClassWriterImpl.java | 18 +- .../formats/html/PackageFrameWriter.java | 14 +- .../formats/html/PackageIndexFrameWriter.java | 14 +- .../formats/html/PackageIndexWriter.java | 8 +- .../formats/html/PackageTreeWriter.java | 20 +- .../formats/html/PackageUseWriter.java | 38 ++-- .../formats/html/PackageWriterImpl.java | 44 ++-- .../formats/html/PropertyWriterImpl.java | 40 ++-- .../html/SerializedFormWriterImpl.java | 26 +-- .../formats/html/SingleIndexWriter.java | 22 +- .../formats/html/SourceToHTMLConverter.java | 20 +- .../formats/html/SplitIndexWriter.java | 22 +- .../formats/html/SubWriterHolderWriter.java | 18 +- .../formats/html/TagletWriterImpl.java | 62 +++--- .../doclets/formats/html/TreeWriter.java | 22 +- .../doclets/formats/html/markup/Comment.java | 6 +- .../formats/html/markup/ContentBuilder.java | 10 +- .../html/markup/FixedStringContent.java | 6 +- .../doclets/formats/html/markup/Head.java | 30 +-- .../doclets/formats/html/markup/HtmlTree.java | 84 +++---- .../doclets/formats/html/markup/Links.java | 8 +- .../formats/html/markup/Navigation.java | 114 +++++----- .../doclets/formats/html/markup/RawHtml.java | 6 +- .../doclets/formats/html/markup/Script.java | 16 +- .../formats/html/markup/StringContent.java | 6 +- .../doclets/formats/html/markup/Table.java | 35 ++- .../formats/html/markup/TableHeader.java | 4 +- .../internal/doclets/toolkit/Content.java | 6 +- .../builders/AnnotationTypeBuilder.java | 8 +- .../builders/AnnotationTypeFieldBuilder.java | 8 +- .../AnnotationTypeRequiredMemberBuilder.java | 8 +- .../toolkit/builders/ClassBuilder.java | 8 +- .../toolkit/builders/ConstructorBuilder.java | 8 +- .../toolkit/builders/EnumConstantBuilder.java | 8 +- .../toolkit/builders/FieldBuilder.java | 8 +- .../builders/MemberSummaryBuilder.java | 6 +- .../toolkit/builders/MethodBuilder.java | 8 +- .../builders/ModuleSummaryBuilder.java | 4 +- .../builders/PackageSummaryBuilder.java | 4 +- .../toolkit/builders/PropertyBuilder.java | 9 +- .../builders/SerializedFormBuilder.java | 28 +-- .../doclets/toolkit/taglets/ParamTaglet.java | 16 +- .../doclets/toolkit/taglets/TagletWriter.java | 4 +- .../doclets/toolkit/taglets/ThrowsTaglet.java | 18 +- .../doclets/toolkit/taglets/UserTaglet.java | 6 +- .../toolkit/util/links/LinkFactory.java | 48 ++-- .../doclets/toolkit/util/links/LinkInfo.java | 6 +- .../testHtmlDocument/TestHtmlDocument.java | 66 +++--- 83 files changed, 1219 insertions(+), 1223 deletions(-) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java index a92fa6bbbf5..b95e7e6234d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -78,8 +78,8 @@ public AbstractExecutableMemberWriter(SubWriterHolderWriter writer) { protected void addTypeParameters(ExecutableElement member, Content htmltree) { Content typeParameters = getTypeParameters(member); if (!typeParameters.isEmpty()) { - htmltree.addContent(typeParameters); - htmltree.addContent(Contents.SPACE); + htmltree.add(typeParameters); + htmltree.add(Contents.SPACE); } } @@ -100,16 +100,16 @@ protected Content getTypeParameters(ExecutableElement member) { @Override protected Content getDeprecatedLink(Element member) { Content deprecatedLinkContent = new ContentBuilder(); - deprecatedLinkContent.addContent(utils.getFullyQualifiedName(member)); + deprecatedLinkContent.add(utils.getFullyQualifiedName(member)); if (!utils.isConstructor(member)) { - deprecatedLinkContent.addContent("."); - deprecatedLinkContent.addContent(member.getSimpleName()); + deprecatedLinkContent.add("."); + deprecatedLinkContent.add(member.getSimpleName()); } String signature = utils.flatSignature((ExecutableElement) member); if (signature.length() > 2) { - deprecatedLinkContent.addContent(Contents.ZERO_WIDTH_SPACE); + deprecatedLinkContent.add(Contents.ZERO_WIDTH_SPACE); } - deprecatedLinkContent.addContent(signature); + deprecatedLinkContent.add(signature); return writer.getDocLink(MEMBER, utils.getEnclosingTypeElement(member), member, deprecatedLinkContent); } @@ -131,7 +131,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement te, Element name(ee), false)); Content code = HtmlTree.CODE(memberLink); addParameters(ee, false, code, name(ee).length() - 1); - tdSummary.addContent(code); + tdSummary.add(code); } /** @@ -143,7 +143,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement te, Element */ @Override protected void addInheritedSummaryLink(TypeElement te, Element member, Content linksTree) { - linksTree.addContent(writer.getDocLink(MEMBER, te, member, name(member), false)); + linksTree.add(writer.getDocLink(MEMBER, te, member, name(member), false)); } /** @@ -158,10 +158,10 @@ protected void addParam(ExecutableElement member, VariableElement param, boolean isVarArg, Content tree) { Content link = writer.getLink(new LinkInfoImpl(configuration, EXECUTABLE_MEMBER_PARAM, param.asType()).varargs(isVarArg)); - tree.addContent(link); + tree.add(link); if(name(param).length() > 0) { - tree.addContent(Contents.SPACE); - tree.addContent(name(param)); + tree.add(Contents.SPACE); + tree.add(name(param)); } } @@ -176,12 +176,12 @@ protected void addParam(ExecutableElement member, VariableElement param, protected void addReceiverAnnotations(ExecutableElement member, TypeMirror rcvrType, List annotationMirrors, Content tree) { writer.addReceiverAnnotationInfo(member, rcvrType, annotationMirrors, tree); - tree.addContent(Contents.SPACE); - tree.addContent(utils.getTypeName(rcvrType, false)); + tree.add(Contents.SPACE); + tree.add(utils.getTypeName(rcvrType, false)); LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, RECEIVER_TYPE, rcvrType); - tree.addContent(writer.getTypeParameterLinks(linkInfo)); - tree.addContent(Contents.SPACE); - tree.addContent("this"); + tree.add(writer.getTypeParameterLinks(linkInfo)); + tree.add(Contents.SPACE); + tree.add("this"); } @@ -216,7 +216,7 @@ protected void addParameters(ExecutableElement member, } int paramstart; for (paramstart = 0; paramstart < parameters.size(); paramstart++) { - paramTree.addContent(sep); + paramTree.add(sep); VariableElement param = parameters.get(paramstart); if (param.getKind() != ElementKind.INSTANCE_INIT) { @@ -225,8 +225,8 @@ protected void addParameters(ExecutableElement member, writer.addAnnotationInfo(indent.length(), member, param, paramTree); if (foundAnnotations) { - paramTree.addContent(DocletConstants.NL); - paramTree.addContent(indent); + paramTree.add(DocletConstants.NL); + paramTree.add(indent); } } addParam(member, param, @@ -236,28 +236,28 @@ protected void addParameters(ExecutableElement member, } for (int i = paramstart + 1; i < parameters.size(); i++) { - paramTree.addContent(","); - paramTree.addContent(DocletConstants.NL); - paramTree.addContent(indent); + paramTree.add(","); + paramTree.add(DocletConstants.NL); + paramTree.add(indent); if (includeAnnotations) { boolean foundAnnotations = writer.addAnnotationInfo(indent.length(), member, parameters.get(i), paramTree); if (foundAnnotations) { - paramTree.addContent(DocletConstants.NL); - paramTree.addContent(indent); + paramTree.add(DocletConstants.NL); + paramTree.add(indent); } } addParam(member, parameters.get(i), (i == parameters.size() - 1) && member.isVarArgs(), paramTree); } if (paramTree.isEmpty()) { - htmltree.addContent("()"); + htmltree.add("()"); } else { - htmltree.addContent(Contents.ZERO_WIDTH_SPACE); - htmltree.addContent("("); - htmltree.addContent(paramTree); - paramTree.addContent(")"); + htmltree.add(Contents.ZERO_WIDTH_SPACE); + htmltree.add("("); + htmltree.add(paramTree); + paramTree.add(")"); } } @@ -271,19 +271,19 @@ protected void addExceptions(ExecutableElement member, Content htmltree, int ind List exceptions = member.getThrownTypes(); if (!exceptions.isEmpty()) { CharSequence indent = makeSpace(indentSize + 1 - 7); - htmltree.addContent(DocletConstants.NL); - htmltree.addContent(indent); - htmltree.addContent("throws "); + htmltree.add(DocletConstants.NL); + htmltree.add(indent); + htmltree.add("throws "); indent = makeSpace(indentSize + 1); Content link = writer.getLink(new LinkInfoImpl(configuration, MEMBER, exceptions.get(0))); - htmltree.addContent(link); + htmltree.add(link); for(int i = 1; i < exceptions.size(); i++) { - htmltree.addContent(","); - htmltree.addContent(DocletConstants.NL); - htmltree.addContent(indent); + htmltree.add(","); + htmltree.add(DocletConstants.NL); + htmltree.add(indent); Content exceptionLink = writer.getLink(new LinkInfoImpl(configuration, MEMBER, exceptions.get(i))); - htmltree.addContent(exceptionLink); + htmltree.add(exceptionLink); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java index c693581816e..d39181a6371 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java @@ -109,7 +109,7 @@ protected void addContents(Character uc, Collection memberlis for (Element element : memberlist) { addDescription(dl, element); } - contentTree.addContent(dl); + contentTree.add(dl); } } @@ -122,7 +122,7 @@ protected void addSearchContents(Character uc, List searchList, for (SearchIndexItem sii : searchList) { addDescription(sii, dl); } - contentTree.addContent(dl); + contentTree.add(dl); } } @@ -163,16 +163,16 @@ protected void addContents(Character uc, List memberlist, i++; } } - contentTree.addContent(dl); + contentTree.add(dl); } protected void addHeading(Character uc, Content contentTree) { String unicode = uc.toString(); - contentTree.addContent(getMarkerAnchorForIndex(unicode)); + contentTree.add(getMarkerAnchorForIndex(unicode)); Content headContent = new StringContent(unicode); Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, false, HtmlStyle.title, headContent); - contentTree.addContent(heading); + contentTree.add(heading); } protected void addDescription(Content dl, Element element) { @@ -225,13 +225,13 @@ protected void addDescription(ModuleElement mdle, Content dlTree, SearchIndexIte si.setLabel(moduleName); si.setCategory(resources.getText("doclet.Modules")); Content dt = HtmlTree.DT(link); - dt.addContent(" - "); - dt.addContent(contents.module_); - dt.addContent(" " + moduleName); - dlTree.addContent(dt); + dt.add(" - "); + dt.add(contents.module_); + dt.add(" " + moduleName); + dlTree.add(dt); Content dd = new HtmlTree(HtmlTag.DD); addSummaryComment(mdle, dd); - dlTree.addContent(dd); + dlTree.add(dd); } /** @@ -249,13 +249,13 @@ protected void addDescription(PackageElement pkg, Content dlTree, SearchIndexIte si.setLabel(utils.getPackageName(pkg)); si.setCategory(resources.getText("doclet.Packages")); Content dt = HtmlTree.DT(link); - dt.addContent(" - "); - dt.addContent(contents.package_); - dt.addContent(" " + utils.getPackageName(pkg)); - dlTree.addContent(dt); + dt.add(" - "); + dt.add(contents.package_); + dt.add(" " + utils.getPackageName(pkg)); + dlTree.add(dt); Content dd = new HtmlTree(HtmlTag.DD); addSummaryComment(pkg, dd); - dlTree.addContent(dd); + dlTree.add(dd); } /** @@ -272,12 +272,12 @@ protected void addDescription(TypeElement typeElement, Content dlTree, SearchInd si.setLabel(utils.getSimpleName(typeElement)); si.setCategory(resources.getText("doclet.Types")); Content dt = HtmlTree.DT(link); - dt.addContent(" - "); + dt.add(" - "); addClassInfo(typeElement, dt); - dlTree.addContent(dt); + dlTree.add(dt); Content dd = new HtmlTree(HtmlTag.DD); addComment(typeElement, dd); - dlTree.addContent(dd); + dlTree.add(dd); } /** @@ -288,7 +288,7 @@ protected void addDescription(TypeElement typeElement, Content dlTree, SearchInd * @param contentTree the content tree to which the class info will be added */ protected void addClassInfo(TypeElement te, Content contentTree) { - contentTree.addContent(contents.getContent("doclet.in", + contentTree.add(contents.getContent("doclet.in", utils.getTypeElementName(te, false), getPackageLink(utils.containingPackage(te), utils.getPackageName(utils.containingPackage(te))) @@ -322,12 +322,12 @@ protected void addDescription(Element member, Content dlTree, SearchIndexItem si Content span = HtmlTree.SPAN(HtmlStyle.memberNameLink, getDocLink(LinkInfoImpl.Kind.INDEX, member, name)); Content dt = HtmlTree.DT(span); - dt.addContent(" - "); + dt.add(" - "); addMemberDesc(member, dt); - dlTree.addContent(dt); + dlTree.add(dt); Content dd = new HtmlTree(HtmlTag.DD); addComment(member, dd); - dlTree.addContent(dd); + dlTree.add(dd); } protected void addDescription(SearchIndexItem sii, Content dlTree) { @@ -335,16 +335,16 @@ protected void addDescription(SearchIndexItem sii, Content dlTree) { siiPath += sii.getUrl(); HtmlTree labelLink = HtmlTree.A(siiPath, new StringContent(sii.getLabel())); Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.searchTagLink, labelLink)); - dt.addContent(" - "); - dt.addContent(contents.getContent("doclet.Search_tag_in", sii.getHolder())); - dlTree.addContent(dt); + dt.add(" - "); + dt.add(contents.getContent("doclet.Search_tag_in", sii.getHolder())); + dlTree.add(dt); Content dd = new HtmlTree(HtmlTag.DD); if (sii.getDescription().isEmpty()) { - dd.addContent(Contents.SPACE); + dd.add(Contents.SPACE); } else { - dd.addContent(sii.getDescription()); + dd.add(sii.getDescription()); } - dlTree.addContent(dd); + dlTree.add(dd); } /** @@ -362,17 +362,17 @@ protected void addComment(Element element, Content contentTree) { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.deprecationBlock); if (utils.isDeprecated(element)) { - div.addContent(span); + div.add(span); tags = utils.getBlockTags(element, DocTree.Kind.DEPRECATED); if (!tags.isEmpty()) addInlineDeprecatedComment(element, tags.get(0), div); - contentTree.addContent(div); + contentTree.add(div); } else { TypeElement encl = utils.getEnclosingTypeElement(element); while (encl != null) { if (utils.isDeprecated(encl)) { - div.addContent(span); - contentTree.addContent(div); + div.add(span); + contentTree.add(div); break; } encl = utils.getEnclosingTypeElement(encl); @@ -395,15 +395,15 @@ protected void addMemberDesc(Element member, Content contentTree) { Content resource = contents.getContent(utils.isStatic(member) ? "doclet.Static_variable_in" : "doclet.Variable_in", classdesc); - contentTree.addContent(resource); + contentTree.add(resource); } else if (utils.isConstructor(member)) { - contentTree.addContent( + contentTree.add( contents.getContent("doclet.Constructor_for", classdesc)); } else if (utils.isMethod(member)) { Content resource = contents.getContent(utils.isStatic(member) ? "doclet.Static_method_in" : "doclet.Method_in", classdesc); - contentTree.addContent(resource); + contentTree.add(resource); } addPreQualifiedClassLink(LinkInfoImpl.Kind.INDEX, containing, false, contentTree); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java index 27e7c0d15d7..fd0c65159fc 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java @@ -220,7 +220,7 @@ protected abstract void addInheritedSummaryLink(TypeElement typeElement, * @param htmltree the content tree to which the name will be added. */ protected void addName(String name, Content htmltree) { - htmltree.addContent(name); + htmltree.add(name); } /** @@ -257,8 +257,8 @@ protected void addModifiers(Element member, Content htmltree) { } if (!set.isEmpty()) { String mods = set.stream().map(Modifier::toString).collect(Collectors.joining(" ")); - htmltree.addContent(mods); - htmltree.addContent(Contents.SPACE); + htmltree.add(mods); + htmltree.add(Contents.SPACE); } } @@ -285,8 +285,8 @@ protected void addModifierAndType(Element member, TypeMirror type, HtmlTree code = new HtmlTree(HtmlTag.CODE); addModifier(member, code); if (type == null) { - code.addContent(utils.isClass(member) ? "class" : "interface"); - code.addContent(Contents.SPACE); + code.add(utils.isClass(member) ? "class" : "interface"); + code.add(Contents.SPACE); } else { List list = utils.isExecutableElement(member) ? ((ExecutableElement)member).getTypeParameters() @@ -294,24 +294,24 @@ protected void addModifierAndType(Element member, TypeMirror type, if (list != null && !list.isEmpty()) { Content typeParameters = ((AbstractExecutableMemberWriter) this) .getTypeParameters((ExecutableElement)member); - code.addContent(typeParameters); + code.add(typeParameters); //Code to avoid ugly wrapping in member summary table. if (typeParameters.charCount() > 10) { - code.addContent(new HtmlTree(HtmlTag.BR)); + code.add(new HtmlTree(HtmlTag.BR)); } else { - code.addContent(Contents.SPACE); + code.add(Contents.SPACE); } - code.addContent( + code.add( writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type))); } else { - code.addContent( + code.add( writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type))); } } - tdSummaryType.addContent(code); + tdSummaryType.add(code); } /** @@ -322,24 +322,24 @@ protected void addModifierAndType(Element member, TypeMirror type, */ private void addModifier(Element member, Content code) { if (utils.isProtected(member)) { - code.addContent("protected "); + code.add("protected "); } else if (utils.isPrivate(member)) { - code.addContent("private "); + code.add("private "); } else if (!utils.isPublic(member)) { // Package private - code.addContent(configuration.getText("doclet.Package_private")); - code.addContent(" "); + code.add(configuration.getText("doclet.Package_private")); + code.add(" "); } boolean isAnnotatedTypeElement = utils.isAnnotationType(member.getEnclosingElement()); if (!isAnnotatedTypeElement && utils.isMethod(member)) { if (!utils.isInterface(member.getEnclosingElement()) && utils.isAbstract(member)) { - code.addContent("abstract "); + code.add("abstract "); } if (utils.isDefault(member)) { - code.addContent("default "); + code.add("default "); } } if (utils.isStatic(member)) { - code.addContent("static "); + code.add("static "); } } @@ -355,7 +355,7 @@ protected void addDeprecatedInfo(Element member, Content contentTree) { if (!output.isEmpty()) { Content deprecatedContent = output; Content div = HtmlTree.DIV(HtmlStyle.deprecationBlock, deprecatedContent); - contentTree.addContent(div); + contentTree.add(div); } } @@ -441,8 +441,8 @@ protected void addUseInfo(List mems, && !utils.isAnnotationType(element)) { HtmlTree name = new HtmlTree(HtmlTag.SPAN); name.setStyle(HtmlStyle.typeNameLabel); - name.addContent(name(te) + "."); - typeContent.addContent(name); + name.add(name(te) + "."); + typeContent.add(name); } addSummaryLink(utils.isClass(element) || utils.isInterface(element) ? LinkInfoImpl.Kind.CLASS_USE @@ -452,7 +452,7 @@ protected void addUseInfo(List mems, writer.addSummaryLinkComment(this, element, desc); useTable.addRow(summaryType, typeContent, desc); } - contentTree.addContent(useTable.toContent()); + contentTree.add(useTable.toContent()); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java index 23b3457cb00..6336766443f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java @@ -139,9 +139,9 @@ protected void buildModuleIndexFile(String title, boolean includeScript) throws addOverview(main); Content footer = createTagIfAllowed(HtmlTag.FOOTER, HtmlTree::FOOTER, ContentBuilder::new); addNavigationBarFooter(footer); - body.addContent(header); - body.addContent(main); - body.addContent(footer); + body.add(header); + body.add(main); + body.add(footer); printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title, configuration.doctitle), includeScript, body); } @@ -168,9 +168,9 @@ protected void buildModulePackagesIndexFile(String title, addOverview(main); Content footer = createTagIfAllowed(HtmlTag.FOOTER, HtmlTree::FOOTER, ContentBuilder::new); addNavigationBarFooter(footer); - body.addContent(header); - body.addContent(main); - body.addContent(footer); + body.add(header); + body.add(main); + body.add(footer); printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title, configuration.doctitle), includeScript, body); } @@ -226,8 +226,8 @@ protected void addIndexContents(Collection modules, String text, HtmlTree ul = new HtmlTree(HtmlTag.UL); addAllClassesLink(ul); addAllPackagesLink(ul); - htmlTree.addContent(ul); - header.addContent(htmlTree); + htmlTree.add(ul); + header.add(htmlTree); addModulesList(main); } @@ -249,8 +249,8 @@ protected void addModulePackagesIndexContents(String text, addAllClassesLink(ul); addAllPackagesLink(ul); addAllModulesLink(ul); - htmlTree.addContent(ul); - header.addContent(htmlTree); + htmlTree.add(ul); + header.add(htmlTree); addModulePackagesList(modules, text, tableSummary, main, mdle); } @@ -265,7 +265,7 @@ protected void addConfigurationTitle(Content body) { Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.title, title); Content div = HtmlTree.DIV(HtmlStyle.header, heading); - body.addContent(div); + body.add(div); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java index 4d61bca924e..c606fec3b96 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java @@ -124,9 +124,9 @@ protected void buildPackageIndexFile(String title, boolean includeScript) throws addOverview(main); Content footer = createTagIfAllowed(HtmlTag.FOOTER, HtmlTree::FOOTER, ContentBuilder::new); addNavigationBarFooter(footer); - body.addContent(header); - body.addContent(main); - body.addContent(footer); + body.add(header); + body.add(main); + body.add(footer); printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title, configuration.doctitle), includeScript, body); } @@ -164,8 +164,8 @@ protected void addIndexContents(Content header, Content main) { if (configuration.showModules && configuration.modules.size() > 1) { addAllModulesLink(ul); } - htmlTree.addContent(ul); - header.addContent(htmlTree); + htmlTree.add(ul); + header.add(htmlTree); addPackagesList(main); } } @@ -181,7 +181,7 @@ protected void addConfigurationTitle(Content body) { Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.title, title); Content div = HtmlTree.DIV(HtmlStyle.header, heading); - body.addContent(div); + body.add(div); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java index 81ee8ceeaf3..79098fedd43 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java @@ -93,9 +93,9 @@ protected void addLevelInfo(TypeElement parent, Collection collecti addExtendsImplements(parent, local, li); addLevelInfo(local, classtree.directSubClasses(local, isEnum), isEnum, li); // Recurse - ul.addContent(li); + ul.add(li); } - contentTree.addContent(ul); + contentTree.add(ul); } } @@ -123,13 +123,13 @@ protected void addTree(SortedSet sset, String heading, if (configuration.allowTag(HtmlTag.SECTION)) { htmlTree = HtmlTree.SECTION(sectionHeading); } else { - div.addContent(sectionHeading); + div.add(sectionHeading); htmlTree = div; } addLevelInfo(!utils.isInterface(firstTypeElement) ? firstTypeElement : null, sset, isEnums, htmlTree); if (configuration.allowTag(HtmlTag.SECTION)) { - div.addContent(htmlTree); + div.add(htmlTree); } } } @@ -156,21 +156,21 @@ protected void addExtendsImplements(TypeElement parent, TypeElement typeElement, if (isFirst) { isFirst = false; if (utils.isInterface(typeElement)) { - contentTree.addContent(" ("); - contentTree.addContent(contents.also); - contentTree.addContent(" extends "); + contentTree.add(" ("); + contentTree.add(contents.also); + contentTree.add(" extends "); } else { - contentTree.addContent(" (implements "); + contentTree.add(" (implements "); } } else { - contentTree.addContent(", "); + contentTree.add(", "); } addPreQualifiedClassLink(LinkInfoImpl.Kind.TREE, intf, contentTree); } } } if (!isFirst) { - contentTree.addContent(")"); + contentTree.add(")"); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java index 20b7b61154e..091f99b2570 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java @@ -118,13 +118,13 @@ protected void buildAllClassesFile(boolean wantFrames) throws DocFileIOException Content htmlTree = createTagIfAllowed(HtmlTag.MAIN, HtmlTree::MAIN, ContentBuilder::new); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, contents.allClassesLabel); - htmlTree.addContent(heading); + htmlTree.add(heading); Content ul = new HtmlTree(HtmlTag.UL); // Generate the class links and add it to the tdFont tree. addAllClasses(ul, wantFrames); HtmlTree div = HtmlTree.DIV(HtmlStyle.indexContainer, ul); - htmlTree.addContent(div); - body.addContent(htmlTree); + htmlTree.add(div); + body.add(htmlTree); printHtmlDocument(null, false, body); } @@ -168,7 +168,7 @@ protected void addContents(Iterable classlist, boolean wantFr linkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, typeElement).label(label)); } Content li = HtmlTree.LI(linkContent); - content.addContent(li); + content.add(li); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java index 0ede2d070de..ba7b71bb983 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesIndexWriter.java @@ -108,26 +108,26 @@ protected void buildAllClassesFile() throws DocFileIOException { : bodyTree; addTop(htmlTree); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } Content allClassesContent = new ContentBuilder(); addContents(allClassesContent); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(allClassesContent); - bodyTree.addContent(mainTree); + mainTree.add(allClassesContent); + bodyTree.add(mainTree); } else { - bodyTree.addContent(allClassesContent); + bodyTree.add(allClassesContent); } Content tree = (configuration.allowTag(HtmlTag.FOOTER)) ? HtmlTree.FOOTER() : bodyTree; navBar.setUserFooter(getUserHeaderFooter(false)); - tree.addContent(navBar.getContent(false)); + tree.add(navBar.getContent(false)); addBottom(tree); if (configuration.allowTag(HtmlTag.FOOTER)) { - bodyTree.addContent(tree); + bodyTree.add(tree); } printHtmlDocument(null, true, bodyTree); } @@ -166,14 +166,14 @@ protected void addContents(Content content) { Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, titleContent); Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading); - content.addContent(headerDiv); + content.add(headerDiv); if (!table.isEmpty()) { HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, table.toContent()); HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.allClassesContainer); - div.addContent(ul); - content.addContent(div); + div.add(ul); + content.add(div); if (table.needsScript()) { getMainBodyScript().append(table.getScript()); } @@ -192,7 +192,7 @@ protected void addTableRow(Table table, TypeElement klass) { configuration, LinkInfoImpl.Kind.INDEX, klass)); ContentBuilder description = new ContentBuilder(); if (utils.isDeprecated(klass)) { - description.addContent(getDeprecatedPhrase(klass)); + description.add(getDeprecatedPhrase(klass)); List tags = utils.getDeprecatedTrees(klass); if (!tags.isEmpty()) { addSummaryDeprecatedComment(klass, tags.get(0), description); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java index 2b359bbd169..6e09a020464 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllPackagesIndexWriter.java @@ -90,9 +90,9 @@ protected void buildAllPackagesFile() throws DocFileIOException { : bodyTree; addTop(htmlTree); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.allPackagesContainer); @@ -102,21 +102,21 @@ protected void buildAllPackagesFile() throws DocFileIOException { HtmlStyle.title, titleContent); Content headerDiv = HtmlTree.DIV(HtmlStyle.header, pHeading); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(headerDiv); - mainTree.addContent(div); - bodyTree.addContent(mainTree); + mainTree.add(headerDiv); + mainTree.add(div); + bodyTree.add(mainTree); } else { - bodyTree.addContent(headerDiv); - bodyTree.addContent(div); + bodyTree.add(headerDiv); + bodyTree.add(div); } Content tree = (configuration.allowTag(HtmlTag.FOOTER)) ? HtmlTree.FOOTER() : bodyTree; navBar.setUserFooter(getUserHeaderFooter(false)); - tree.addContent(navBar.getContent(false)); + tree.add(navBar.getContent(false)); addBottom(tree); if (configuration.allowTag(HtmlTag.FOOTER)) { - bodyTree.addContent(tree); + bodyTree.add(tree); } printHtmlDocument(null, true, bodyTree); } @@ -141,6 +141,6 @@ protected void addPackages(Content content) { } } HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, table.toContent()); - content.addContent(HtmlTree.UL(HtmlStyle.blockList, li)); + content.add(HtmlTree.UL(HtmlStyle.blockList, li)); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java index 65c4c7503a2..88644830ed6 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java @@ -71,7 +71,7 @@ public AnnotationTypeFieldWriterImpl(SubWriterHolderWriter writer, */ public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent( + memberSummaryTree.add( HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); @@ -96,7 +96,7 @@ public void addMemberTree(Content memberSummaryTree, Content memberTree) { * {@inheritDoc} */ public void addAnnotationFieldDetailsMarker(Content memberDetails) { - memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_DETAILS); + memberDetails.add(HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_DETAILS); } /** @@ -105,11 +105,11 @@ public void addAnnotationFieldDetailsMarker(Content memberDetails) { public void addAnnotationDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { if (!writer.printedAnnotationFieldHeading) { - memberDetailsTree.addContent(links.createAnchor( + memberDetailsTree.add(links.createAnchor( SectionName.ANNOTATION_TYPE_FIELD_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, contents.fieldDetailsLabel); - memberDetailsTree.addContent(heading); + memberDetailsTree.add(heading); writer.printedAnnotationFieldHeading = true; } } @@ -119,11 +119,11 @@ public void addAnnotationDetailsTreeHeader(TypeElement typeElement, */ public Content getAnnotationDocTreeHeader(Element member, Content annotationDetailsTree) { - annotationDetailsTree.addContent(links.createAnchor(name(member))); + annotationDetailsTree.add(links.createAnchor(name(member))); Content annotationDocTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); - heading.addContent(name(member)); - annotationDocTree.addContent(heading); + heading.add(name(member)); + annotationDocTree.add(heading); return annotationDocTree; } @@ -137,8 +137,8 @@ public Content getSignature(Element member) { Content link = writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, getType(member))); - pre.addContent(link); - pre.addContent(Contents.SPACE); + pre.add(link); + pre.add(Contents.SPACE); if (configuration.linksource) { Content memberName = new StringContent(name(member)); writer.addSrcLink(member, memberName, pre); @@ -194,7 +194,7 @@ public Content getAnnotationDoc(Content annotationDocTree, public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, contents.fieldSummaryLabel); - memberTree.addContent(label); + memberTree.add(label); } /** @@ -230,7 +230,7 @@ protected Table createSummaryTable() { */ @Override public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { - memberTree.addContent(links.createAnchor( + memberTree.add(links.createAnchor( SectionName.ANNOTATION_TYPE_FIELD_SUMMARY)); } @@ -257,7 +257,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, writer.getDocLink(context, member, name(member), false)); Content code = HtmlTree.CODE(memberLink); - tdSummary.addContent(code); + tdSummary.add(code); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java index 5ad100d0df6..c6972ffef69 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java @@ -74,7 +74,7 @@ public AnnotationTypeOptionalMemberWriterImpl(SubWriterHolderWriter writer, @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent( + memberSummaryTree.add( HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); @@ -101,8 +101,8 @@ public void addDefaultValueInfo(Element member, Content annotationDocTree) { Content dt = HtmlTree.DT(contents.default_); Content dl = HtmlTree.DL(dt); Content dd = HtmlTree.DD(new StringContent(value.toString())); - dl.addContent(dd); - annotationDocTree.addContent(dl); + dl.add(dd); + annotationDocTree.add(dl); } } } @@ -114,7 +114,7 @@ public void addDefaultValueInfo(Element member, Content annotationDocTree) { public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, contents.annotateTypeOptionalMemberSummaryLabel); - memberTree.addContent(label); + memberTree.add(label); } /** @@ -149,7 +149,7 @@ public TableHeader getSummaryTableHeader(Element member) { */ @Override public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { - memberTree.addContent(links.createAnchor( + memberTree.add(links.createAnchor( SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY)); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java index c29711027a2..cd5fb87b0e5 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java @@ -74,7 +74,7 @@ public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer, */ public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent( + memberSummaryTree.add( HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); @@ -99,7 +99,7 @@ public void addMemberTree(Content memberSummaryTree, Content memberTree) { * {@inheritDoc} */ public void addAnnotationDetailsMarker(Content memberDetails) { - memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS); + memberDetails.add(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS); } /** @@ -108,11 +108,11 @@ public void addAnnotationDetailsMarker(Content memberDetails) { public void addAnnotationDetailsTreeHeader(TypeElement te, Content memberDetailsTree) { if (!writer.printedAnnotationHeading) { - memberDetailsTree.addContent(links.createAnchor( + memberDetailsTree.add(links.createAnchor( SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, contents.annotationTypeDetailsLabel); - memberDetailsTree.addContent(heading); + memberDetailsTree.add(heading); writer.printedAnnotationHeading = true; } } @@ -123,12 +123,12 @@ public void addAnnotationDetailsTreeHeader(TypeElement te, @Override public Content getAnnotationDocTreeHeader(Element member, Content annotationDetailsTree) { String simpleName = name(member); - annotationDetailsTree.addContent(links.createAnchor( + annotationDetailsTree.add(links.createAnchor( simpleName + utils.signature((ExecutableElement) member))); Content annotationDocTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); - heading.addContent(simpleName); - annotationDocTree.addContent(heading); + heading.add(simpleName); + annotationDocTree.add(heading); return annotationDocTree; } @@ -142,8 +142,8 @@ public Content getSignature(Element member) { Content link = writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, getType(member))); - pre.addContent(link); - pre.addContent(Contents.SPACE); + pre.add(link); + pre.add(Contents.SPACE); if (configuration.linksource) { Content memberName = new StringContent(name(member)); writer.addSrcLink(member, memberName, pre); @@ -199,7 +199,7 @@ public Content getAnnotationDoc(Content annotationDocTree, public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, contents.annotateTypeRequiredMemberSummaryLabel); - memberTree.addContent(label); + memberTree.add(label); } /** @@ -250,7 +250,7 @@ protected Table createSummaryTable() { * {@inheritDoc} */ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { - memberTree.addContent(links.createAnchor( + memberTree.add(links.createAnchor( SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY)); } @@ -274,7 +274,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, writer.getDocLink(context, member, name(member), false)); Content code = HtmlTree.CODE(memberLink); - tdSummary.addContent(code); + tdSummary.add(code); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java index 8d48a554e2d..cc1aa74f440 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java @@ -95,41 +95,41 @@ public Content getHeader(String header) { navBar.setNavLinkModule(linkContent); navBar.setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this)); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } - bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA); + bodyTree.add(HtmlConstants.START_OF_CLASS_DATA); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.header); if (configuration.showModules) { ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(annotationType); Content typeModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInType, contents.moduleLabel); Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, typeModuleLabel); - moduleNameDiv.addContent(Contents.SPACE); - moduleNameDiv.addContent(getModuleLink(mdle, new StringContent(mdle.getQualifiedName()))); - div.addContent(moduleNameDiv); + moduleNameDiv.add(Contents.SPACE); + moduleNameDiv.add(getModuleLink(mdle, new StringContent(mdle.getQualifiedName()))); + div.add(moduleNameDiv); } PackageElement pkg = utils.containingPackage(annotationType); if (!pkg.isUnnamed()) { Content typePackageLabel = HtmlTree.SPAN(HtmlStyle.packageLabelInType, contents.packageLabel); Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, typePackageLabel); - pkgNameDiv.addContent(Contents.SPACE); + pkgNameDiv.add(Contents.SPACE); Content pkgNameContent = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); - pkgNameDiv.addContent(pkgNameContent); - div.addContent(pkgNameDiv); + pkgNameDiv.add(pkgNameContent); + div.add(pkgNameDiv); } LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_HEADER, annotationType); Content headerContent = new StringContent(header); Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, HtmlStyle.title, headerContent); - heading.addContent(getTypeParameterLinks(linkInfo)); - div.addContent(heading); + heading.add(getTypeParameterLinks(linkInfo)); + div.add(heading); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(div); + mainTree.add(div); } else { - bodyTree.addContent(div); + bodyTree.add(div); } return bodyTree; } @@ -147,15 +147,15 @@ public Content getAnnotationContentHeader() { */ @Override public void addFooter(Content contentTree) { - contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA); + contentTree.add(HtmlConstants.END_OF_CLASS_DATA); Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER)) ? HtmlTree.FOOTER() : contentTree; navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); + htmlTree.add(navBar.getContent(false)); addBottom(htmlTree); if (configuration.allowTag(HtmlTag.FOOTER)) { - contentTree.addContent(htmlTree); + contentTree.add(htmlTree); } } @@ -190,23 +190,23 @@ public Content getAnnotationInfo(Content annotationInfoTree) { @Override public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree) { Content hr = new HtmlTree(HtmlTag.HR); - annotationInfoTree.addContent(hr); + annotationInfoTree.add(hr); Content pre = new HtmlTree(HtmlTag.PRE); addAnnotationInfo(annotationType, pre); - pre.addContent(modifiers); + pre.add(modifiers); LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType); Content annotationName = new StringContent(utils.getSimpleName(annotationType)); Content parameterLinks = getTypeParameterLinks(linkInfo); if (configuration.linksource) { addSrcLink(annotationType, annotationName, pre); - pre.addContent(parameterLinks); + pre.add(parameterLinks); } else { Content span = HtmlTree.SPAN(HtmlStyle.memberNameLabel, annotationName); - span.addContent(parameterLinks); - pre.addContent(span); + span.add(parameterLinks); + pre.add(span); } - annotationInfoTree.addContent(pre); + annotationInfoTree.add(pre); } /** @@ -248,7 +248,7 @@ public void addAnnotationTypeDeprecationInfo(Content annotationInfoTree) { addInlineDeprecatedComment(annotationType, deprs.get(0), div); } } - annotationInfoTree.addContent(div); + annotationInfoTree.add(div); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java index 9b44e521be2..36984bd9db4 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java @@ -255,23 +255,23 @@ protected void generateClassUseFile() throws DocFileIOException { if (pkgSet.size() > 0) { addClassUse(div); } else { - div.addContent(contents.getContent("doclet.ClassUse_No.usage.of.0", + div.add(contents.getContent("doclet.ClassUse_No.usage.of.0", utils.getFullyQualifiedName(typeElement))); } if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(div); - body.addContent(mainTree); + mainTree.add(div); + body.add(mainTree); } else { - body.addContent(div); + body.add(div); } HtmlTree htmlTree = (configuration.allowTag(HtmlTag.FOOTER)) ? HtmlTree.FOOTER() : body; navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); + htmlTree.add(navBar.getContent(false)); addBottom(htmlTree); if (configuration.allowTag(HtmlTag.FOOTER)) { - body.addContent(htmlTree); + body.add(htmlTree); } printHtmlDocument(null, true, body); } @@ -289,7 +289,7 @@ protected void addClassUse(Content contentTree) { addPackageAnnotationList(ul); } addClassList(ul); - contentTree.addContent(ul); + contentTree.add(ul); } /** @@ -311,7 +311,7 @@ protected void addPackageList(Content contentTree) { addPackageUse(pkg, table); } Content li = HtmlTree.LI(HtmlStyle.blockList, table.toContent()); - contentTree.addContent(li); + contentTree.add(li); } /** @@ -341,7 +341,7 @@ protected void addPackageAnnotationList(Content contentTree) { table.addRow(getPackageLink(pkg), summary); } Content li = HtmlTree.LI(HtmlStyle.blockList, table.toContent()); - contentTree.addContent(li); + contentTree.add(li); } /** @@ -362,16 +362,16 @@ protected void addClassList(Content contentTree) { typeElement)), getPackageLink(pkg, utils.getPackageName(pkg))); Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link); - htmlTree.addContent(heading); + htmlTree.add(heading); addClassUse(pkg, htmlTree); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } } Content li = HtmlTree.LI(HtmlStyle.blockList, ul); - contentTree.addContent(li); + contentTree.add(li); } /** @@ -488,21 +488,21 @@ protected HtmlTree getClassUseHeader() { .label(configuration.getText("doclet.Class"))); navBar.setNavLinkClass(classLinkContent); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } ContentBuilder headContent = new ContentBuilder(); - headContent.addContent(contents.getContent("doclet.ClassUse_Title", cltype)); - headContent.addContent(new HtmlTree(HtmlTag.BR)); - headContent.addContent(clname); + headContent.add(contents.getContent("doclet.ClassUse_Title", cltype)); + headContent.add(new HtmlTree(HtmlTag.BR)); + headContent.add(clname); Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(div); + mainTree.add(div); } else { - bodyTree.addContent(div); + bodyTree.add(div); } return bodyTree; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java index a8614f9eee6..8505de62e08 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java @@ -106,31 +106,31 @@ public Content getHeader(String header) { navBar.setNavLinkModule(linkContent); navBar.setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this)); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } - bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA); + bodyTree.add(HtmlConstants.START_OF_CLASS_DATA); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.header); if (configuration.showModules) { ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(typeElement); Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInType, contents.moduleLabel); Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classModuleLabel); - moduleNameDiv.addContent(Contents.SPACE); - moduleNameDiv.addContent(getModuleLink(mdle, + moduleNameDiv.add(Contents.SPACE); + moduleNameDiv.add(getModuleLink(mdle, new StringContent(mdle.getQualifiedName()))); - div.addContent(moduleNameDiv); + div.add(moduleNameDiv); } PackageElement pkg = utils.containingPackage(typeElement); if (!pkg.isUnnamed()) { Content classPackageLabel = HtmlTree.SPAN(HtmlStyle.packageLabelInType, contents.packageLabel); Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classPackageLabel); - pkgNameDiv.addContent(Contents.SPACE); + pkgNameDiv.add(Contents.SPACE); Content pkgNameContent = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); - pkgNameDiv.addContent(pkgNameContent); - div.addContent(pkgNameDiv); + pkgNameDiv.add(pkgNameContent); + div.add(pkgNameDiv); } LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_HEADER, typeElement); @@ -139,12 +139,12 @@ public Content getHeader(String header) { Content headerContent = new StringContent(header); Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, HtmlStyle.title, headerContent); - heading.addContent(getTypeParameterLinks(linkInfo)); - div.addContent(heading); + heading.add(getTypeParameterLinks(linkInfo)); + div.add(heading); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(div); + mainTree.add(div); } else { - bodyTree.addContent(div); + bodyTree.add(div); } return bodyTree; } @@ -162,15 +162,15 @@ public Content getClassContentHeader() { */ @Override public void addFooter(Content contentTree) { - contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA); + contentTree.add(HtmlConstants.END_OF_CLASS_DATA); Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER)) ? HtmlTree.FOOTER() : contentTree; navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); + htmlTree.add(navBar.getContent(false)); addBottom(htmlTree); if (configuration.allowTag(HtmlTag.FOOTER)) { - contentTree.addContent(htmlTree); + contentTree.add(htmlTree); } } @@ -205,10 +205,10 @@ public Content getClassInfo(Content classInfoTree) { @Override public void addClassSignature(String modifiers, Content classInfoTree) { Content hr = new HtmlTree(HtmlTag.HR); - classInfoTree.addContent(hr); + classInfoTree.add(hr); Content pre = new HtmlTree(HtmlTag.PRE); addAnnotationInfo(typeElement, pre); - pre.addContent(modifiers); + pre.add(modifiers); LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_SIGNATURE, typeElement); //Let's not link to ourselves in the signature. @@ -217,21 +217,21 @@ public void addClassSignature(String modifiers, Content classInfoTree) { Content parameterLinks = getTypeParameterLinks(linkInfo); if (configuration.linksource) { addSrcLink(typeElement, className, pre); - pre.addContent(parameterLinks); + pre.add(parameterLinks); } else { Content span = HtmlTree.SPAN(HtmlStyle.typeNameLabel, className); - span.addContent(parameterLinks); - pre.addContent(span); + span.add(parameterLinks); + pre.add(span); } if (!utils.isInterface(typeElement)) { TypeMirror superclass = utils.getFirstVisibleSuperClass(typeElement); if (superclass != null) { - pre.addContent(DocletConstants.NL); - pre.addContent("extends "); + pre.add(DocletConstants.NL); + pre.add("extends "); Content link = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME, superclass)); - pre.addContent(link); + pre.add(link); } } List interfaces = typeElement.getInterfaces(); @@ -243,19 +243,19 @@ public void addClassSignature(String modifiers, Content classInfoTree) { continue; } if (isFirst) { - pre.addContent(DocletConstants.NL); - pre.addContent(utils.isInterface(typeElement) ? "extends " : "implements "); + pre.add(DocletConstants.NL); + pre.add(utils.isInterface(typeElement) ? "extends " : "implements "); isFirst = false; } else { - pre.addContent(", "); + pre.add(", "); } Content link = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME, type)); - pre.addContent(link); + pre.add(link); } } - classInfoTree.addContent(pre); + classInfoTree.add(pre); } /** @@ -298,17 +298,17 @@ private Content getClassInheritenceTree(TypeMirror type) { if (sup != null) { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.setStyle(HtmlStyle.inheritance); - ul.addContent(getTreeForClassHelper(type)); + ul.add(getTreeForClassHelper(type)); if (liTree != null) - ul.addContent(liTree); + ul.add(liTree); Content li = HtmlTree.LI(ul); liTree = li; type = sup; } else - classTreeUl.addContent(getTreeForClassHelper(type)); + classTreeUl.add(getTreeForClassHelper(type)); } while (sup != null); if (liTree != null) - classTreeUl.addContent(liTree); + classTreeUl.add(liTree); return classTreeUl; } @@ -325,17 +325,17 @@ private Content getTreeForClassHelper(TypeMirror type) { new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE, typeElement)); if (configuration.shouldExcludeQualifier(utils.containingPackage(typeElement).toString())) { - li.addContent(utils.asTypeElement(type).getSimpleName()); - li.addContent(typeParameters); + li.add(utils.asTypeElement(type).getSimpleName()); + li.add(typeParameters); } else { - li.addContent(utils.asTypeElement(type).getQualifiedName()); - li.addContent(typeParameters); + li.add(utils.asTypeElement(type).getQualifiedName()); + li.add(typeParameters); } } else { Content link = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_TREE_PARENT, type) .label(configuration.getClassName(utils.asTypeElement(type)))); - li.addContent(link); + li.add(link); } return li; } @@ -348,7 +348,7 @@ public void addClassTree(Content classContentTree) { if (!utils.isClass(typeElement)) { return; } - classContentTree.addContent(getClassInheritenceTree(typeElement.asType())); + classContentTree.add(getClassInheritenceTree(typeElement.asType())); } /** @@ -360,7 +360,7 @@ public void addTypeParamInfo(Content classInfoTree) { Content typeParam = (new ParamTaglet()).getTagletOutput(typeElement, getTagletWriterInstance(false)); Content dl = HtmlTree.DL(typeParam); - classInfoTree.addContent(dl); + classInfoTree.add(dl); } } @@ -379,9 +379,9 @@ public void addSubClassInfo(Content classInfoTree) { Content label = contents.subclassesLabel; Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); - dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES, + dl.add(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES, subclasses)); - classInfoTree.addContent(dl); + classInfoTree.add(dl); } } } @@ -397,9 +397,9 @@ public void addSubInterfacesInfo(Content classInfoTree) { Content label = contents.subinterfacesLabel; Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); - dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES, + dl.add(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES, subInterfaces)); - classInfoTree.addContent(dl); + classInfoTree.add(dl); } } } @@ -421,9 +421,9 @@ public void addInterfaceUsageInfo (Content classInfoTree) { Content label = contents.implementingClassesLabel; Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); - dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES, + dl.add(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES, implcl)); - classInfoTree.addContent(dl); + classInfoTree.add(dl); } } @@ -438,8 +438,8 @@ public void addImplementedInterfacesInfo(Content classInfoTree) { Content label = contents.allImplementedInterfacesLabel; Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); - dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES, interfaces)); - classInfoTree.addContent(dl); + dl.add(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES, interfaces)); + classInfoTree.add(dl); } } @@ -456,8 +456,8 @@ public void addSuperInterfacesInfo(Content classInfoTree) { Content label = contents.allSuperinterfacesLabel; Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); - dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES, interfaces)); - classInfoTree.addContent(dl); + dl.add(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES, interfaces)); + classInfoTree.add(dl); } } @@ -478,10 +478,10 @@ public Void visitType(TypeElement e, Void p) { Content dt = HtmlTree.DT(label); Content dl = HtmlTree.DL(dt); Content dd = new HtmlTree(HtmlTag.DD); - dd.addContent(getLink(new LinkInfoImpl(configuration, + dd.add(getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS, e))); - dl.addContent(dd); - classInfoTree.addContent(dl); + dl.add(dd); + classInfoTree.add(dl); return null; } }.visit(outerClass); @@ -496,9 +496,9 @@ public void addFunctionalInterfaceInfo (Content classInfoTree) { Content dt = HtmlTree.DT(contents.functionalInterface); Content dl = HtmlTree.DL(dt); Content dd = new HtmlTree(HtmlTag.DD); - dd.addContent(contents.functionalInterfaceMessage); - dl.addContent(dd); - classInfoTree.addContent(dl); + dd.add(contents.functionalInterfaceMessage); + dl.add(dd); + classInfoTree.add(dl); } } @@ -530,7 +530,7 @@ public void addClassDeprecationInfo(Content classInfoTree) { addInlineDeprecatedComment(typeElement, deprs.get(0), div); } } - classInfoTree.addContent(div); + classInfoTree.add(div); } } @@ -547,7 +547,7 @@ private Content getClassLinks(LinkInfoImpl.Kind context, Collection list) { for (Object type : list) { if (!isFirst) { Content separator = new StringContent(", "); - dd.addContent(separator); + dd.add(separator); } else { isFirst = false; } @@ -555,11 +555,11 @@ private Content getClassLinks(LinkInfoImpl.Kind context, Collection list) { if (type instanceof TypeElement) { Content link = getLink( new LinkInfoImpl(configuration, context, (TypeElement)(type))); - dd.addContent(HtmlTree.CODE(link)); + dd.add(HtmlTree.CODE(link)); } else { Content link = getLink( new LinkInfoImpl(configuration, context, ((TypeMirror)type))); - dd.addContent(HtmlTree.CODE(link)); + dd.add(HtmlTree.CODE(link)); } } return dd; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java index edfec7138a5..cd701962c1c 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java @@ -116,9 +116,9 @@ public Content getHeader() { : bodyTree; addTop(htmlTree); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } return bodyTree; } @@ -145,13 +145,13 @@ public void addLinkToPackageContent(PackageElement pkg, } else { String parsedPackageName = utils.parsePackageName(pkg); Content packageNameContent = getPackageLabel(parsedPackageName); - packageNameContent.addContent(".*"); + packageNameContent.add(".*"); link = links.createLink(DocLink.fragment(parsedPackageName), packageNameContent, "", ""); PackageElement abbrevPkg = configuration.workArounds.getAbbreviatedPackageElement(pkg); printedPackageHeaders.add(abbrevPkg); } - contentListTree.addContent(HtmlTree.LI(link)); + contentListTree.add(HtmlTree.LI(link)); } /** @@ -168,13 +168,13 @@ public void addContentsList(Content contentTree, Content contentListTree) { headingContent); if (configuration.allowTag(HtmlTag.SECTION)) { HtmlTree section = HtmlTree.SECTION(heading); - section.addContent(contentListTree); - div.addContent(section); - mainTree.addContent(div); + section.add(contentListTree); + div.add(section); + mainTree.add(div); } else { - div.addContent(heading); - div.addContent(contentListTree); - contentTree.addContent(div); + div.add(heading); + div.add(contentListTree); + contentTree.add(div); } } @@ -195,24 +195,24 @@ public Content getConstantSummaries() { public void addPackageName(PackageElement pkg, Content summariesTree, boolean first) { Content pkgNameContent; if (!first && configuration.allowTag(HtmlTag.SECTION)) { - summariesTree.addContent(summaryTree); + summariesTree.add(summaryTree); } if (pkg.isUnnamed()) { - summariesTree.addContent(links.createAnchor(SectionName.UNNAMED_PACKAGE_ANCHOR)); + summariesTree.add(links.createAnchor(SectionName.UNNAMED_PACKAGE_ANCHOR)); pkgNameContent = contents.defaultPackageLabel; } else { String parsedPackageName = utils.parsePackageName(pkg); - summariesTree.addContent(links.createAnchor(parsedPackageName)); + summariesTree.add(links.createAnchor(parsedPackageName)); pkgNameContent = getPackageLabel(parsedPackageName); } Content headingContent = new StringContent(".*"); Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, pkgNameContent); - heading.addContent(headingContent); + heading.add(headingContent); if (configuration.allowTag(HtmlTag.SECTION)) { summaryTree = HtmlTree.SECTION(heading); } else { - summariesTree.addContent(heading); + summariesTree.add(heading); } } @@ -232,9 +232,9 @@ public Content getClassConstantHeader() { @Override public void addClassConstant(Content summariesTree, Content classConstantTree) { if (configuration.allowTag(HtmlTag.SECTION)) { - summaryTree.addContent(classConstantTree); + summaryTree.add(classConstantTree); } else { - summariesTree.addContent(classConstantTree); + summariesTree.add(classConstantTree); } } @@ -255,10 +255,10 @@ public void addConstantMembers(TypeElement typeElement, Collection deprList, String headingKey, if (!tags.isEmpty()) { addInlineDeprecatedComment(e, tags.get(0), desc); } else { - desc.addContent(HtmlTree.EMPTY); + desc.add(HtmlTree.EMPTY); } table.addRow(link, desc); } Content li = HtmlTree.LI(HtmlStyle.blockList, table.toContent()); Content ul = HtmlTree.UL(HtmlStyle.blockList, li); - contentTree.addContent(ul); + contentTree.add(ul); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java index e6df1f6059a..48e33a564aa 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DocFilesHandlerImpl.java @@ -183,15 +183,15 @@ private boolean handleHtmlFile(DocFile srcfile, DocPath dstPath) throws DocFileI Content pkgLinkContent = docletWriter.getPackageLink(pkg, docletWriter.contents.packageLabel); navBar.setNavLinkPackage(pkgLinkContent); navBar.setUserHeader(docletWriter.getUserHeaderFooter(true)); - htmlContent.addContent(navBar.getContent(true)); + htmlContent.add(navBar.getContent(true)); List fullBody = utils.getFullBody(dfElement); Content bodyContent = docletWriter.commentTagsToContent(null, dfElement, fullBody, false); docletWriter.addTagsInfo(dfElement, bodyContent); - htmlContent.addContent(bodyContent); + htmlContent.add(bodyContent); navBar.setUserFooter(docletWriter.getUserHeaderFooter(false)); - htmlContent.addContent(navBar.getContent(false)); + htmlContent.add(navBar.getContent(false)); docletWriter.addBottom(htmlContent); docletWriter.printHtmlDocument(Collections.emptyList(), false, htmlContent); return true; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java index 514b313cbe7..692bd653510 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java @@ -71,7 +71,7 @@ public EnumConstantWriterImpl(SubWriterHolderWriter writer) { @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY); + memberSummaryTree.add(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -91,13 +91,13 @@ public void addMemberTree(Content memberSummaryTree, Content memberTree) { @Override public Content getEnumConstantsDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { - memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS); + memberDetailsTree.add(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS); Content enumConstantsDetailsTree = writer.getMemberTreeHeader(); - enumConstantsDetailsTree.addContent(links.createAnchor( + enumConstantsDetailsTree.add(links.createAnchor( SectionName.ENUM_CONSTANT_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, contents.enumConstantDetailLabel); - enumConstantsDetailsTree.addContent(heading); + enumConstantsDetailsTree.add(heading); return enumConstantsDetailsTree; } @@ -107,11 +107,11 @@ public Content getEnumConstantsDetailsTreeHeader(TypeElement typeElement, @Override public Content getEnumConstantsTreeHeader(VariableElement enumConstant, Content enumConstantsDetailsTree) { - enumConstantsDetailsTree.addContent(links.createAnchor(name(enumConstant))); + enumConstantsDetailsTree.add(links.createAnchor(name(enumConstant))); Content enumConstantsTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); - heading.addContent(name(enumConstant)); - enumConstantsTree.addContent(heading); + heading.add(name(enumConstant)); + enumConstantsTree.add(heading); return enumConstantsTree; } @@ -125,8 +125,8 @@ public Content getSignature(VariableElement enumConstant) { addModifiers(enumConstant, pre); Content enumConstantLink = writer.getLink(new LinkInfoImpl( configuration, LinkInfoImpl.Kind.MEMBER, enumConstant.asType())); - pre.addContent(enumConstantLink); - pre.addContent(" "); + pre.add(enumConstantLink); + pre.add(" "); if (configuration.linksource) { Content enumConstantName = new StringContent(name(enumConstant)); writer.addSrcLink(enumConstant, enumConstantName, pre); @@ -188,7 +188,7 @@ public Content getEnumConstants(Content enumConstantsTree, public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, contents.enumConstantSummary); - memberTree.addContent(label); + memberTree.add(label); } /** @@ -221,7 +221,7 @@ protected Table createSummaryTable() { */ @Override public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { - memberTree.addContent(links.createAnchor(SectionName.ENUM_CONSTANT_SUMMARY)); + memberTree.add(links.createAnchor(SectionName.ENUM_CONSTANT_SUMMARY)); } /** @@ -247,7 +247,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, writer.getDocLink(context, member, name(member), false)); Content code = HtmlTree.CODE(memberLink); - tdSummary.addContent(code); + tdSummary.add(code); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java index 4b551737460..76cb909dc07 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java @@ -75,7 +75,7 @@ public FieldWriterImpl(SubWriterHolderWriter writer) { @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_FIELD_SUMMARY); + memberSummaryTree.add(HtmlConstants.START_OF_FIELD_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -94,13 +94,13 @@ public void addMemberTree(Content memberSummaryTree, Content memberTree) { */ @Override public Content getFieldDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { - memberDetailsTree.addContent(HtmlConstants.START_OF_FIELD_DETAILS); + memberDetailsTree.add(HtmlConstants.START_OF_FIELD_DETAILS); Content fieldDetailsTree = writer.getMemberTreeHeader(); - fieldDetailsTree.addContent(links.createAnchor( + fieldDetailsTree.add(links.createAnchor( SectionName.FIELD_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, contents.fieldDetailsLabel); - fieldDetailsTree.addContent(heading); + fieldDetailsTree.add(heading); return fieldDetailsTree; } @@ -109,11 +109,11 @@ public Content getFieldDetailsTreeHeader(TypeElement typeElement, Content member */ @Override public Content getFieldDocTreeHeader(VariableElement field, Content fieldDetailsTree) { - fieldDetailsTree.addContent(links.createAnchor(name(field))); + fieldDetailsTree.add(links.createAnchor(name(field))); Content fieldTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); - heading.addContent(name(field)); - fieldTree.addContent(heading); + heading.add(name(field)); + fieldTree.add(heading); return fieldTree; } @@ -127,8 +127,8 @@ public Content getSignature(VariableElement field) { addModifiers(field, pre); Content fieldlink = writer.getLink(new LinkInfoImpl( configuration, LinkInfoImpl.Kind.MEMBER, field.asType())); - pre.addContent(fieldlink); - pre.addContent(" "); + pre.add(fieldlink); + pre.add(" "); if (configuration.linksource) { Content fieldName = new StringContent(name(field)); writer.addSrcLink(field, fieldName, pre); @@ -192,7 +192,7 @@ public Content getFieldDoc(Content fieldTree, public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, contents.fieldSummaryLabel); - memberTree.addContent(label); + memberTree.add(label); } /** @@ -227,7 +227,7 @@ protected Table createSummaryTable() { */ @Override public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { - memberTree.addContent(links.createAnchor( + memberTree.add(links.createAnchor( SectionName.FIELD_SUMMARY)); } @@ -236,7 +236,7 @@ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { */ @Override public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) { - inheritedTree.addContent(links.createAnchor( + inheritedTree.add(links.createAnchor( SectionName.FIELDS_INHERITANCE, configuration.getClassName(typeElement))); } @@ -259,9 +259,9 @@ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedT } Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); - labelHeading.addContent(Contents.SPACE); - labelHeading.addContent(classLink); - inheritedTree.addContent(labelHeading); + labelHeading.add(Contents.SPACE); + labelHeading.add(classLink); + inheritedTree.add(labelHeading); } /** @@ -273,7 +273,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, writer.getDocLink(context, typeElement , member, name(member), false)); Content code = HtmlTree.CODE(memberLink); - tdSummary.addContent(code); + tdSummary.add(code); } /** @@ -281,7 +281,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement */ @Override protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) { - linksTree.addContent( + linksTree.add( writer.getDocLink(LinkInfoImpl.Kind.MEMBER, typeElement, member, name(member), false)); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java index 4764b768529..0a88c9c884a 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java @@ -25,8 +25,8 @@ package jdk.javadoc.internal.doclets.formats.html; -import jdk.javadoc.internal.doclets.formats.html.markup.Head; import jdk.javadoc.internal.doclets.formats.html.markup.DocType; +import jdk.javadoc.internal.doclets.formats.html.markup.Head; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; @@ -96,21 +96,21 @@ public static void generate(HtmlConfiguration configuration) throws DocFileIOExc protected void generateFrameFile() throws DocFileIOException { Content frame = getFrameDetails(); HtmlTree body = new HtmlTree(HtmlTag.BODY); - body.addAttr(HtmlAttr.ONLOAD, "loadFrames()"); + body.put(HtmlAttr.ONLOAD, "loadFrames()"); String topFilePath = configuration.topFile.getPath(); Script script = new Script( "\nif (targetPage == \"\" || targetPage == \"undefined\")\n" + " window.location.replace(") .appendStringLiteral(topFilePath, '\'') .append(");\n"); - body.addContent(script.asContent()); + body.add(script.asContent()); Content noScript = HtmlTree.NOSCRIPT(contents.noScriptMessage); - body.addContent(noScript); + body.add(noScript); if (configuration.allowTag(HtmlTag.MAIN)) { HtmlTree main = HtmlTree.MAIN(frame); - body.addContent(main); + body.add(main); } else { - body.addContent(frame); + body.add(frame); } if (configuration.windowtitle.length() > 0) { printFramesDocument(configuration.windowtitle, body); @@ -161,7 +161,7 @@ protected Content getFrameDetails() { addAllClassesFrameTag(leftContainerDiv); addClassFrameTag(rightContainerDiv); HtmlTree mainContainer = HtmlTree.DIV(HtmlStyle.mainContainer, leftContainerDiv); - mainContainer.addContent(rightContainerDiv); + mainContainer.add(rightContainerDiv); return mainContainer; } @@ -174,7 +174,7 @@ private void addAllModulesFrameTag(Content contentTree) { HtmlTree frame = HtmlTree.IFRAME(DocPaths.MODULE_OVERVIEW_FRAME.getPath(), "packageListFrame", configuration.getText("doclet.All_Modules")); HtmlTree leftTop = HtmlTree.DIV(HtmlStyle.leftTop, frame); - contentTree.addContent(leftTop); + contentTree.add(leftTop); } /** @@ -186,7 +186,7 @@ private void addAllPackagesFrameTag(Content contentTree) { HtmlTree frame = HtmlTree.IFRAME(DocPaths.OVERVIEW_FRAME.getPath(), "packageListFrame", configuration.getText("doclet.All_Packages")); HtmlTree leftTop = HtmlTree.DIV(HtmlStyle.leftTop, frame); - contentTree.addContent(leftTop); + contentTree.add(leftTop); } /** @@ -198,7 +198,7 @@ private void addAllClassesFrameTag(Content contentTree) { HtmlTree frame = HtmlTree.IFRAME(DocPaths.ALLCLASSES_FRAME.getPath(), "packageFrame", configuration.getText("doclet.All_classes_and_interfaces")); HtmlTree leftBottom = HtmlTree.DIV(HtmlStyle.leftBottom, frame); - contentTree.addContent(leftBottom); + contentTree.add(leftBottom); } /** @@ -210,7 +210,7 @@ private void addClassFrameTag(Content contentTree) { HtmlTree frame = HtmlTree.IFRAME(configuration.topFile.getPath(), "classFrame", configuration.getText("doclet.Package_class_and_interface_descriptions")); frame.setStyle(HtmlStyle.rightIframe); - contentTree.addContent(frame); + contentTree.add(frame); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java index 064dcb41351..53aa341569f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java @@ -94,19 +94,19 @@ protected void generateHelpFile() throws DocFileIOException { : body; addTop(htmlTree); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - body.addContent(htmlTree); + body.add(htmlTree); } addHelpFileContents(body); if (configuration.allowTag(HtmlTag.FOOTER)) { htmlTree = HtmlTree.FOOTER(); } navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); + htmlTree.add(navBar.getContent(false)); addBottom(htmlTree); if (configuration.allowTag(HtmlTag.FOOTER)) { - body.addContent(htmlTree); + body.add(htmlTree); } printHtmlDocument(null, true, body); } @@ -126,11 +126,11 @@ protected void addHelpFileContents(Content contentTree) { Content div = HtmlTree.DIV(HtmlStyle.header, heading); Content intro = HtmlTree.DIV(HtmlStyle.subTitle, contents.getContent("doclet.help.intro")); - div.addContent(intro); + div.add(intro); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(div); + mainTree.add(div); } else { - contentTree.addContent(div); + contentTree.add(div); } HtmlTree htmlTree; HtmlTree ul = new HtmlTree(HtmlTag.UL); @@ -151,11 +151,11 @@ protected void addHelpFileContents(Content contentTree) { resources.getText("doclet.Overview")); Content overviewBody = contents.getContent(overviewKey, overviewLink); Content overviewPara = HtmlTree.P(overviewBody); - htmlTree.addContent(overviewPara); + htmlTree.add(overviewPara); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } } @@ -168,16 +168,16 @@ protected void addHelpFileContents(Content contentTree) { : HtmlTree.LI(HtmlStyle.blockList, moduleHead); Content moduleIntro = contents.getContent("doclet.help.module.intro"); Content modulePara = HtmlTree.P(moduleIntro); - htmlTree.addContent(modulePara); + htmlTree.add(modulePara); HtmlTree ulModule = new HtmlTree(HtmlTag.UL); - ulModule.addContent(HtmlTree.LI(contents.packagesLabel)); - ulModule.addContent(HtmlTree.LI(contents.modulesLabel)); - ulModule.addContent(HtmlTree.LI(contents.servicesLabel)); - htmlTree.addContent(ulModule); + ulModule.add(HtmlTree.LI(contents.packagesLabel)); + ulModule.add(HtmlTree.LI(contents.modulesLabel)); + ulModule.add(HtmlTree.LI(contents.servicesLabel)); + htmlTree.add(ulModule); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } } @@ -190,19 +190,19 @@ protected void addHelpFileContents(Content contentTree) { : HtmlTree.LI(HtmlStyle.blockList, packageHead); Content packageIntro = contents.getContent("doclet.help.package.intro"); Content packagePara = HtmlTree.P(packageIntro); - htmlTree.addContent(packagePara); + htmlTree.add(packagePara); HtmlTree ulPackage = new HtmlTree(HtmlTag.UL); - ulPackage.addContent(HtmlTree.LI(contents.interfaces)); - ulPackage.addContent(HtmlTree.LI(contents.classes)); - ulPackage.addContent(HtmlTree.LI(contents.enums)); - ulPackage.addContent(HtmlTree.LI(contents.exceptions)); - ulPackage.addContent(HtmlTree.LI(contents.errors)); - ulPackage.addContent(HtmlTree.LI(contents.annotationTypes)); - htmlTree.addContent(ulPackage); + ulPackage.add(HtmlTree.LI(contents.interfaces)); + ulPackage.add(HtmlTree.LI(contents.classes)); + ulPackage.add(HtmlTree.LI(contents.enums)); + ulPackage.add(HtmlTree.LI(contents.exceptions)); + ulPackage.add(HtmlTree.LI(contents.errors)); + ulPackage.add(HtmlTree.LI(contents.annotationTypes)); + htmlTree.add(ulPackage); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } // Class/interface @@ -213,37 +213,37 @@ protected void addHelpFileContents(Content contentTree) { : HtmlTree.LI(HtmlStyle.blockList, classHead); Content classIntro = contents.getContent("doclet.help.class_interface.intro"); Content classPara = HtmlTree.P(classIntro); - htmlTree.addContent(classPara); + htmlTree.add(classPara); HtmlTree ul1 = new HtmlTree(HtmlTag.UL); - ul1.addContent(HtmlTree.LI(contents.getContent("doclet.help.class_interface.inheritance_diagram"))); - ul1.addContent(HtmlTree.LI(contents.getContent("doclet.help.class_interface.subclasses"))); - ul1.addContent(HtmlTree.LI(contents.getContent("doclet.help.class_interface.subinterfaces"))); - ul1.addContent(HtmlTree.LI(contents.getContent("doclet.help.class_interface.implementations"))); - ul1.addContent(HtmlTree.LI(contents.getContent("doclet.help.class_interface.declaration"))); - ul1.addContent(HtmlTree.LI(contents.getContent("doclet.help.class_interface.description"))); - htmlTree.addContent(ul1); - htmlTree.addContent(new HtmlTree(HtmlTag.BR)); + ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.inheritance_diagram"))); + ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.subclasses"))); + ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.subinterfaces"))); + ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.implementations"))); + ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.declaration"))); + ul1.add(HtmlTree.LI(contents.getContent("doclet.help.class_interface.description"))); + htmlTree.add(ul1); + htmlTree.add(new HtmlTree(HtmlTag.BR)); HtmlTree ul2 = new HtmlTree(HtmlTag.UL); - ul2.addContent(HtmlTree.LI(contents.nestedClassSummary)); - ul2.addContent(HtmlTree.LI(contents.fieldSummaryLabel)); - ul2.addContent(HtmlTree.LI(contents.propertySummaryLabel)); - ul2.addContent(HtmlTree.LI(contents.constructorSummaryLabel)); - ul2.addContent(HtmlTree.LI(contents.methodSummary)); - htmlTree.addContent(ul2); - htmlTree.addContent(new HtmlTree(HtmlTag.BR)); + ul2.add(HtmlTree.LI(contents.nestedClassSummary)); + ul2.add(HtmlTree.LI(contents.fieldSummaryLabel)); + ul2.add(HtmlTree.LI(contents.propertySummaryLabel)); + ul2.add(HtmlTree.LI(contents.constructorSummaryLabel)); + ul2.add(HtmlTree.LI(contents.methodSummary)); + htmlTree.add(ul2); + htmlTree.add(new HtmlTree(HtmlTag.BR)); HtmlTree ul3 = new HtmlTree(HtmlTag.UL); - ul3.addContent(HtmlTree.LI(contents.fieldDetailsLabel)); - ul3.addContent(HtmlTree.LI(contents.propertyDetailsLabel)); - ul3.addContent(HtmlTree.LI(contents.constructorDetailsLabel)); - ul3.addContent(HtmlTree.LI(contents.methodDetailLabel)); - htmlTree.addContent(ul3); + ul3.add(HtmlTree.LI(contents.fieldDetailsLabel)); + ul3.add(HtmlTree.LI(contents.propertyDetailsLabel)); + ul3.add(HtmlTree.LI(contents.constructorDetailsLabel)); + ul3.add(HtmlTree.LI(contents.methodDetailLabel)); + htmlTree.add(ul3); Content classSummary = contents.getContent("doclet.help.class_interface.summary"); Content para = HtmlTree.P(classSummary); - htmlTree.addContent(para); + htmlTree.add(para); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } // Annotation Types @@ -254,18 +254,18 @@ protected void addHelpFileContents(Content contentTree) { : HtmlTree.LI(HtmlStyle.blockList, aHead); Content aIntro = contents.getContent("doclet.help.annotation_type.intro"); Content aPara = HtmlTree.P(aIntro); - htmlTree.addContent(aPara); + htmlTree.add(aPara); HtmlTree aul = new HtmlTree(HtmlTag.UL); - aul.addContent(HtmlTree.LI(contents.getContent("doclet.help.annotation_type.declaration"))); - aul.addContent(HtmlTree.LI(contents.getContent("doclet.help.annotation_type.description"))); - aul.addContent(HtmlTree.LI(contents.annotateTypeRequiredMemberSummaryLabel)); - aul.addContent(HtmlTree.LI(contents.annotateTypeOptionalMemberSummaryLabel)); - aul.addContent(HtmlTree.LI(contents.annotationTypeMemberDetail)); - htmlTree.addContent(aul); + aul.add(HtmlTree.LI(contents.getContent("doclet.help.annotation_type.declaration"))); + aul.add(HtmlTree.LI(contents.getContent("doclet.help.annotation_type.description"))); + aul.add(HtmlTree.LI(contents.annotateTypeRequiredMemberSummaryLabel)); + aul.add(HtmlTree.LI(contents.annotateTypeOptionalMemberSummaryLabel)); + aul.add(HtmlTree.LI(contents.annotationTypeMemberDetail)); + htmlTree.add(aul); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } // Enums @@ -275,17 +275,17 @@ protected void addHelpFileContents(Content contentTree) { : HtmlTree.LI(HtmlStyle.blockList, enumHead); Content eIntro = contents.getContent("doclet.help.enum.intro"); Content enumPara = HtmlTree.P(eIntro); - htmlTree.addContent(enumPara); + htmlTree.add(enumPara); HtmlTree eul = new HtmlTree(HtmlTag.UL); - eul.addContent(HtmlTree.LI(contents.getContent("doclet.help.enum.declaration"))); - eul.addContent(HtmlTree.LI(contents.getContent("doclet.help.enum.definition"))); - eul.addContent(HtmlTree.LI(contents.enumConstantSummary)); - eul.addContent(HtmlTree.LI(contents.enumConstantDetailLabel)); - htmlTree.addContent(eul); + eul.add(HtmlTree.LI(contents.getContent("doclet.help.enum.declaration"))); + eul.add(HtmlTree.LI(contents.getContent("doclet.help.enum.definition"))); + eul.add(HtmlTree.LI(contents.enumConstantSummary)); + eul.add(HtmlTree.LI(contents.enumConstantDetailLabel)); + htmlTree.add(eul); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } // Class Use @@ -297,11 +297,11 @@ protected void addHelpFileContents(Content contentTree) { : HtmlTree.LI(HtmlStyle.blockList, useHead); Content useBody = contents.getContent("doclet.help.use.body"); Content usePara = HtmlTree.P(useBody); - htmlTree.addContent(usePara); + htmlTree.add(usePara); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } } @@ -317,15 +317,15 @@ protected void addHelpFileContents(Content contentTree) { configuration.getText("doclet.Class_Hierarchy")), HtmlTree.CODE(new StringContent("java.lang.Object"))); Content treePara = HtmlTree.P(treeIntro); - htmlTree.addContent(treePara); + htmlTree.add(treePara); HtmlTree tul = new HtmlTree(HtmlTag.UL); - tul.addContent(HtmlTree.LI(contents.getContent("doclet.help.tree.overview"))); - tul.addContent(HtmlTree.LI(contents.getContent("doclet.help.tree.package"))); - htmlTree.addContent(tul); + tul.add(HtmlTree.LI(contents.getContent("doclet.help.tree.overview"))); + tul.add(HtmlTree.LI(contents.getContent("doclet.help.tree.package"))); + htmlTree.add(tul); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } } @@ -340,11 +340,11 @@ protected void addHelpFileContents(Content contentTree) { links.createLink(DocPaths.DEPRECATED_LIST, configuration.getText("doclet.Deprecated_API"))); Content dPara = HtmlTree.P(deprBody); - htmlTree.addContent(dPara); + htmlTree.add(dPara); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } } @@ -365,11 +365,11 @@ protected void addHelpFileContents(Content contentTree) { : HtmlTree.LI(HtmlStyle.blockList, indexHead); Content indexBody = contents.getContent("doclet.help.index.body", indexlink); Content indexPara = HtmlTree.P(indexBody); - htmlTree.addContent(indexPara); + htmlTree.add(indexPara); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } } @@ -382,12 +382,12 @@ protected void addHelpFileContents(Content contentTree) { : HtmlTree.LI(HtmlStyle.blockList, frameHead); Content framesBody = contents.getContent("doclet.help.frames.body"); Content framePara = HtmlTree.P(framesBody); - htmlTree.addContent(framePara); + htmlTree.add(framePara); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } } @@ -401,11 +401,11 @@ protected void addHelpFileContents(Content contentTree) { links.createLink(DocPaths.AllClasses(configuration.frames), resources.getText("doclet.All_Classes"))); Content allclassesPara = HtmlTree.P(allClassesBody); - htmlTree.addContent(allclassesPara); + htmlTree.add(allclassesPara); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } // Serialized Form @@ -416,11 +416,11 @@ protected void addHelpFileContents(Content contentTree) { : HtmlTree.LI(HtmlStyle.blockList, sHead); Content serialBody = contents.getContent("doclet.help.serial_form.body"); Content serialPara = HtmlTree.P(serialBody); - htmlTree.addContent(serialPara); + htmlTree.add(serialPara); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } // Constant Field Values @@ -433,11 +433,11 @@ protected void addHelpFileContents(Content contentTree) { links.createLink(DocPaths.CONSTANT_VALUES, resources.getText("doclet.Constants_Summary"))); Content constPara = HtmlTree.P(constantsBody); - htmlTree.addContent(constPara); + htmlTree.add(constPara); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } // Search @@ -448,23 +448,23 @@ protected void addHelpFileContents(Content contentTree) { : HtmlTree.LI(HtmlStyle.blockList, searchHead); Content searchBody = contents.getContent("doclet.help.search.body"); Content searchPara = HtmlTree.P(searchBody); - htmlTree.addContent(searchPara); + htmlTree.add(searchPara); if (configuration.allowTag(HtmlTag.SECTION)) { - ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); + ul.add(HtmlTree.LI(HtmlStyle.blockList, htmlTree)); } else { - ul.addContent(htmlTree); + ul.add(htmlTree); } Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul); - divContent.addContent(new HtmlTree(HtmlTag.HR)); + divContent.add(new HtmlTree(HtmlTag.HR)); Content footnote = HtmlTree.SPAN(HtmlStyle.emphasizedPhrase, contents.getContent("doclet.help.footnote")); - divContent.addContent(footnote); + divContent.add(footnote); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(divContent); - contentTree.addContent(mainTree); + mainTree.add(divContent); + contentTree.add(mainTree); } else { - contentTree.addContent(divContent); + contentTree.add(divContent); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index 4fa600af951..9c8148ad5f1 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -284,7 +284,7 @@ public Content getAllClassesLinkScript(String id) { Content div = HtmlTree.DIV(script.asContent()); Content div_noscript = HtmlTree.DIV(contents.noScriptMessage); Content noScript = HtmlTree.NOSCRIPT(div_noscript); - div.addContent(noScript); + div.add(noScript); return div; } @@ -333,8 +333,8 @@ protected void addTagsInfo(Element e, Content htmltree) { TagletWriter.genTagOutput(configuration.tagletManager, e, configuration.tagletManager.getBlockTaglets(e), getTagletWriterInstance(false), output); - dl.addContent(output); - htmltree.addContent(dl); + dl.add(output); + htmltree.add(dl); } /** @@ -472,7 +472,7 @@ public Content getUserHeaderFooter(boolean header) { */ public void addTop(Content htmlTree) { Content top = new RawHtml(replaceDocRootDir(configuration.top)); - fixedNavDiv.addContent(top); + fixedNavDiv.add(top); } /** @@ -484,7 +484,7 @@ public void addBottom(Content htmlTree) { Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom)); Content small = HtmlTree.SMALL(bottom); Content p = HtmlTree.P(HtmlStyle.legalCopy, small); - htmlTree.addContent(p); + htmlTree.add(p); } /** @@ -511,7 +511,7 @@ public Content getTableCaption(Content title) { Content space = Contents.SPACE; Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space); Content caption = HtmlTree.CAPTION(captionSpan); - caption.addContent(tabSpan); + caption.add(tabSpan); return caption; } @@ -662,9 +662,9 @@ public void addSrcLink(Element element, Content label, Content htmltree) { .resolve(docPaths.forClass(te)); Content content = links.createLink(href .fragment(SourceToHTMLConverter.getAnchorName(utils, element)), label, "", ""); - htmltree.addContent(content); + htmltree.add(content); } else { - htmltree.addContent(label); + htmltree.add(label); } } @@ -786,9 +786,9 @@ public Content getPreQualifiedClassLink(LinkInfoImpl.Kind context, ContentBuilder classlink = new ContentBuilder(); PackageElement pkg = utils.containingPackage(typeElement); if (pkg != null && ! configuration.shouldExcludeQualifier(pkg.getSimpleName().toString())) { - classlink.addContent(getEnclosingPackageName(typeElement)); + classlink.add(getEnclosingPackageName(typeElement)); } - classlink.addContent(getLink(new LinkInfoImpl(configuration, + classlink.add(getLink(new LinkInfoImpl(configuration, context, typeElement).label(utils.getSimpleName(typeElement)).strong(isStrong))); return classlink; } @@ -807,13 +807,13 @@ public void addPreQualifiedClassLink(LinkInfoImpl.Kind context, TypeElement typeElement, boolean isStrong, Content contentTree) { PackageElement pkg = utils.containingPackage(typeElement); if(pkg != null && ! configuration.shouldExcludeQualifier(pkg.getSimpleName().toString())) { - contentTree.addContent(getEnclosingPackageName(typeElement)); + contentTree.add(getEnclosingPackageName(typeElement)); } LinkInfoImpl linkinfo = new LinkInfoImpl(configuration, context, typeElement) .label(utils.getSimpleName(typeElement)) .strong(isStrong); Content link = getLink(linkinfo); - contentTree.addContent(link); + contentTree.add(link); } /** @@ -1224,14 +1224,14 @@ private void addCommentTags(Element element, DocTree holderTag, List"); - result.addContent(rawHtml); + result.add(rawHtml); return false; } @Override public Boolean visitEntity(EntityTree node, Content c) { - result.addContent(new RawHtml(node.toString())); + result.add(new RawHtml(node.toString())); return false; } @@ -1427,7 +1427,7 @@ public Boolean visitEntity(EntityTree node, Content c) { public Boolean visitErroneous(ErroneousTree node, Content c) { messages.warning(ch.getDocTreePath(node), "doclet.tag.invalid_usage", node); - result.addContent(new RawHtml(node.toString())); + result.add(new RawHtml(node.toString())); return false; } @@ -1436,7 +1436,7 @@ public Boolean visitInheritDoc(InheritDocTree node, Content c) { Content output = TagletWriter.getInlineTagOutput(element, configuration.tagletManager, holderTag, tag, getTagletWriterInstance(isFirstSentence)); - result.addContent(output); + result.add(output); // if we obtained the first sentence successfully, nothing more to do return (isFirstSentence && !output.isEmpty()); } @@ -1447,7 +1447,7 @@ public Boolean visitIndex(IndexTree node, Content p) { configuration.tagletManager, holderTag, tag, getTagletWriterInstance(isFirstSentence)); if (output != null) { - result.addContent(output); + result.add(output); } return false; } @@ -1455,7 +1455,7 @@ public Boolean visitIndex(IndexTree node, Content p) { @Override public Boolean visitLink(LinkTree node, Content c) { // we need to pass the DocTreeImpl here, so ignore node - result.addContent(seeTagToContent(element, tag)); + result.add(seeTagToContent(element, tag)); return false; } @@ -1465,14 +1465,14 @@ public Boolean visitLiteral(LiteralTree node, Content c) { Content content = new StringContent(utils.normalizeNewlines(s)); if (node.getKind() == CODE) content = HtmlTree.CODE(content); - result.addContent(content); + result.add(content); return false; } @Override public Boolean visitSee(SeeTree node, Content c) { // we need to pass the DocTreeImpl here, so ignore node - result.addContent(seeTagToContent(element, tag)); + result.add(seeTagToContent(element, tag)); return false; } @@ -1480,12 +1480,12 @@ public Boolean visitSee(SeeTree node, Content c) { public Boolean visitStartElement(StartElementTree node, Content c) { String text = "<" + node.getName(); RawHtml rawHtml = new RawHtml(utils.normalizeNewlines(text)); - result.addContent(rawHtml); + result.add(rawHtml); for (DocTree dt : node.getAttributes()) { dt.accept(this, null); } - result.addContent(new RawHtml(node.isSelfClosing() ? "/>" : ">")); + result.add(new RawHtml(node.isSelfClosing() ? "/>" : ">")); return false; } @@ -1494,7 +1494,7 @@ public Boolean visitSummary(SummaryTree node, Content c) { Content output = TagletWriter.getInlineTagOutput(element, configuration.tagletManager, holderTag, tag, getTagletWriterInstance(isFirstSentence)); - result.addContent(output); + result.add(output); return false; } @@ -1516,7 +1516,7 @@ private CharSequence textCleanup(String text, boolean isLast, boolean trimLeader @Override public Boolean visitText(TextTree node, Content c) { String text = node.getBody(); - result.addContent(new RawHtml(textCleanup(text, isLastNode, commentRemoved))); + result.add(new RawHtml(textCleanup(text, isLastNode, commentRemoved))); return false; } @@ -1526,7 +1526,7 @@ protected Boolean defaultAction(DocTree node, Content c) { configuration.tagletManager, holderTag, tag, getTagletWriterInstance(isFirstSentence)); if (output != null) { - result.addContent(output); + result.add(output); } return false; } @@ -1737,8 +1737,8 @@ private boolean addAnnotationInfo(int indent, Element element, return false; } for (Content annotation: annotations) { - htmltree.addContent(sep); - htmltree.addContent(annotation); + htmltree.add(sep); + htmltree.add(annotation); if (!lineBreak) { sep = " "; } @@ -1827,8 +1827,8 @@ protected Void defaultAction(Object o, List p) { String sep = ""; for (AnnotationValue av : annotationTypeValues) { - annotation.addContent(sep); - annotation.addContent(annotationValueToContent(av)); + annotation.add(sep); + annotation.add(annotationValueToContent(av)); sep = " "; } } @@ -1851,8 +1851,8 @@ public Void visitArray(List vals, List vals, List map, int indent, boolean linkBreak) { linkInfo.label = new StringContent("@"); - linkInfo.label.addContent(annotationDoc.getSimpleName()); - annotation.addContent(getLink(linkInfo)); + linkInfo.label.add(annotationDoc.getSimpleName()); + annotation.add(getLink(linkInfo)); if (!map.isEmpty()) { - annotation.addContent("("); + annotation.add("("); boolean isFirst = true; Set keys = map.keySet(); boolean multipleValues = keys.size() > 1; @@ -1899,20 +1899,20 @@ private void addAnnotations(TypeElement annotationDoc, LinkInfoImpl linkInfo, if (isFirst) { isFirst = false; } else { - annotation.addContent(","); + annotation.add(","); if (linkBreak) { - annotation.addContent(DocletConstants.NL); + annotation.add(DocletConstants.NL); int spaces = annotationDoc.getSimpleName().length() + 2; for (int k = 0; k < (spaces + indent); k++) { - annotation.addContent(" "); + annotation.add(" "); } } } String simpleName = element.getSimpleName().toString(); if (multipleValues || !"value".equals(simpleName)) { // Omit "value=" where unnecessary - annotation.addContent(getDocLink(LinkInfoImpl.Kind.ANNOTATION, + annotation.add(getDocLink(LinkInfoImpl.Kind.ANNOTATION, element, simpleName, false)); - annotation.addContent("="); + annotation.add("="); } AnnotationValue annotationValue = map.get(element); List annotationTypeValues = new ArrayList<>(); @@ -1928,17 +1928,17 @@ protected Void defaultAction(Object o, AnnotationValue p) { return null; } }.visit(annotationValue, annotationValue); - annotation.addContent(annotationTypeValues.size() == 1 ? "" : "{"); + annotation.add(annotationTypeValues.size() == 1 ? "" : "{"); String sep = ""; for (AnnotationValue av : annotationTypeValues) { - annotation.addContent(sep); - annotation.addContent(annotationValueToContent(av)); + annotation.add(sep); + annotation.add(annotationValueToContent(av)); sep = ","; } - annotation.addContent(annotationTypeValues.size() == 1 ? "" : "}"); + annotation.add(annotationTypeValues.size() == 1 ? "" : "}"); isContainerDocumented = false; } - annotation.addContent(")"); + annotation.add(")"); } } @@ -2019,7 +2019,7 @@ public Content visitAnnotation(AnnotationMirror a, Void p) { List list = getAnnotations(0, a, false); ContentBuilder buf = new ContentBuilder(); for (Content c : list) { - buf.addContent(c); + buf.add(c); } return buf; } @@ -2033,8 +2033,8 @@ public Content visitArray(List vals, Void p) { ContentBuilder buf = new ContentBuilder(); String sep = ""; for (AnnotationValue av : vals) { - buf.addContent(sep); - buf.addContent(visit(av)); + buf.add(sep); + buf.add(visit(av)); sep = " "; } return buf; @@ -2088,9 +2088,9 @@ public HtmlTree getBody(boolean includeScript, String title) { // and package-frame if (includeScript) { this.mainBodyScript = getWinTitleScript(); - body.addContent(mainBodyScript.asContent()); + body.add(mainBodyScript.asContent()); Content noScript = HtmlTree.NOSCRIPT(HtmlTree.DIV(contents.noScriptMessage)); - body.addContent(noScript); + body.add(noScript); } return body; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java index 10688190640..e3044554aef 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java @@ -110,8 +110,8 @@ public Content getSerializableFields(String heading, Content serializableFieldsT Content headingContent = new StringContent(heading); Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, headingContent); - li.addContent(serialHeading); - li.addContent(serializableFieldsTree); + li.add(serialHeading); + li.add(serializableFieldsTree); } return li; } @@ -121,32 +121,32 @@ public void addMemberHeader(TypeElement fieldType, String fieldTypeStr, String fieldDimensions, String fieldName, Content contentTree) { Content nameContent = new StringContent(fieldName); Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent); - contentTree.addContent(heading); + contentTree.add(heading); Content pre = new HtmlTree(HtmlTag.PRE); if (fieldType == null) { - pre.addContent(fieldTypeStr); + pre.add(fieldTypeStr); } else { Content fieldContent = writer.getLink(new LinkInfoImpl( configuration, LinkInfoImpl.Kind.SERIAL_MEMBER, fieldType)); - pre.addContent(fieldContent); + pre.add(fieldContent); } - pre.addContent(fieldDimensions + " "); - pre.addContent(fieldName); - contentTree.addContent(pre); + pre.add(fieldDimensions + " "); + pre.add(fieldName); + contentTree.add(pre); } @Override public void addMemberHeader(TypeMirror fieldType, String fieldName, Content contentTree) { Content nameContent = new StringContent(fieldName); Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent); - contentTree.addContent(heading); + contentTree.add(heading); Content pre = new HtmlTree(HtmlTag.PRE); Content fieldContent = writer.getLink(new LinkInfoImpl( configuration, LinkInfoImpl.Kind.SERIAL_MEMBER, fieldType)); - pre.addContent(fieldContent); - pre.addContent(" "); - pre.addContent(fieldName); - contentTree.addContent(pre); + pre.add(fieldContent); + pre.add(" "); + pre.add(fieldName); + contentTree.add(pre); } /** @@ -187,7 +187,7 @@ public void addMemberDescription(VariableElement field, DocTree serialFieldTag, if (!description.isEmpty()) { Content serialFieldContent = new RawHtml(ch.getText(description)); Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent); - contentTree.addContent(div); + contentTree.add(div); } } @@ -203,8 +203,8 @@ public void addMemberTags(VariableElement field, Content contentTree) { configuration.tagletManager.getBlockTaglets(field), writer.getTagletWriterInstance(false), tagContent); Content dlTags = new HtmlTree(HtmlTag.DL); - dlTags.addContent(tagContent); - contentTree.addContent(dlTags); // TODO: what if empty? + dlTags.add(tagContent); + contentTree.add(dlTags); // TODO: what if empty? } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java index 070bb7f83bc..0385f3a13f0 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java @@ -98,7 +98,7 @@ public Content getSerializableMethods(String heading, Content serializableMethod Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, headingContent); Content li = HtmlTree.LI(HtmlStyle.blockList, serialHeading); - li.addContent(serializableMethodContent); + li.add(serializableMethodContent); return li; } @@ -120,8 +120,8 @@ public Content getNoCustomizationMsg(String msg) { * @param methodsContentTree the content tree to which the member header will be added */ public void addMemberHeader(ExecutableElement member, Content methodsContentTree) { - methodsContentTree.addContent(getHead(member)); - methodsContentTree.addContent(getSignature(member)); + methodsContentTree.add(getHead(member)); + methodsContentTree.add(getSignature(member)); } /** @@ -158,8 +158,8 @@ public void addMemberTags(ExecutableElement member, Content methodsContentTree) tagletManager.getSerializedFormTaglets(), writer.getTagletWriterInstance(false), tagContent); Content dlTags = new HtmlTree(HtmlTag.DL); - dlTags.addContent(tagContent); - methodsContentTree.addContent(dlTags); + dlTags.add(tagContent); + methodsContentTree.add(dlTags); if (name(member).compareTo("writeExternal") == 0 && utils.getSerialDataTrees(member).isEmpty()) { serialWarning(member, "doclet.MissingSerialDataTag", diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java index b31eb6bd156..7b2635df14f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java @@ -25,9 +25,9 @@ package jdk.javadoc.internal.doclets.formats.html; +import jdk.javadoc.internal.doclets.formats.html.markup.DocType; import jdk.javadoc.internal.doclets.formats.html.markup.Head; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.DocType; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; @@ -40,8 +40,6 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import java.util.Collections; - /** * Writes a file that tries to redirect to an alternate page. * The redirect uses JavaScript, if enabled, falling back on @@ -93,24 +91,24 @@ private void generateIndexFile() throws DocFileIOException { .appendStringLiteral(targetPath, '\'') .append(")"); HtmlTree metaRefresh = new HtmlTree(HtmlTag.META) - .addAttr(HtmlAttr.HTTP_EQUIV, "Refresh") - .addAttr(HtmlAttr.CONTENT, "0;" + targetPath); + .put(HtmlAttr.HTTP_EQUIV, "Refresh") + .put(HtmlAttr.CONTENT, "0;" + targetPath); head.addContent( script.asContent(), configuration.isOutputHtml5() ? HtmlTree.NOSCRIPT(metaRefresh) : metaRefresh); ContentBuilder bodyContent = new ContentBuilder(); - bodyContent.addContent(HtmlTree.NOSCRIPT( + bodyContent.add(HtmlTree.NOSCRIPT( HtmlTree.P(contents.getContent("doclet.No_Script_Message")))); - bodyContent.addContent(HtmlTree.P(HtmlTree.A(targetPath, new StringContent(targetPath)))); + bodyContent.add(HtmlTree.P(HtmlTree.A(targetPath, new StringContent(targetPath)))); Content body = new HtmlTree(HtmlTag.BODY); if (configuration.allowTag(HtmlTag.MAIN)) { HtmlTree main = HtmlTree.MAIN(bodyContent); - body.addContent(main); + body.add(main); } else { - body.addContent(bodyContent); + body.add(bodyContent); } Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head.toContent(), body); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java index 07f7b537fb3..e7658f651df 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -97,14 +97,14 @@ protected Content getClassLink(LinkInfo linkInfo) { DocPath filename = getPath(classLinkInfo); if (linkInfo.linkToSelf || !(docPaths.forName(typeElement)).equals(m_writer.filename)) { - link.addContent(m_writer.links.createLink( + link.add(m_writer.links.createLink( filename.fragment(classLinkInfo.where), label, classLinkInfo.isStrong, title, classLinkInfo.target)); if (noLabel && !classLinkInfo.excludeTypeParameterLinks) { - link.addContent(getTypeParameterLinks(linkInfo)); + link.add(getTypeParameterLinks(linkInfo)); } return link; } @@ -114,17 +114,17 @@ protected Content getClassLink(LinkInfo linkInfo) { typeElement, classLinkInfo.where, label, classLinkInfo.isStrong, true); if (crossLink != null) { - link.addContent(crossLink); + link.add(crossLink); if (noLabel && !classLinkInfo.excludeTypeParameterLinks) { - link.addContent(getTypeParameterLinks(linkInfo)); + link.add(getTypeParameterLinks(linkInfo)); } return link; } } // Can't link so just write label. - link.addContent(label); + link.add(label); if (noLabel && !classLinkInfo.excludeTypeParameterLinks) { - link.addContent(getTypeParameterLinks(linkInfo)); + link.add(getTypeParameterLinks(linkInfo)); } return link; } @@ -157,17 +157,17 @@ protected Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) } if (((linkInfo.includeTypeInClassLinkLabel && isClassLabel) || (linkInfo.includeTypeAsSepLink && !isClassLabel)) && !vars.isEmpty()) { - links.addContent("<"); + links.add("<"); boolean many = false; for (TypeMirror t : vars) { if (many) { - links.addContent(","); - links.addContent(Contents.ZERO_WIDTH_SPACE); + links.add(","); + links.add(Contents.ZERO_WIDTH_SPACE); } - links.addContent(getTypeParameterLink(linkInfo, t)); + links.add(getTypeParameterLink(linkInfo, t)); many = true; } - links.addContent(">"); + links.add(">"); } return links; } @@ -222,13 +222,13 @@ public Content getTypeAnnotationLinks(LinkInfo linkInfo) { boolean isFirst = true; for (Content anno : annos) { if (!isFirst) { - links.addContent(" "); + links.add(" "); } - links.addContent(anno); + links.add(anno); isFirst = false; } if (!annos.isEmpty()) { - links.addContent(" "); + links.add(" "); } return links; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java index 01f1c8b6724..d282e032a19 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java @@ -87,7 +87,7 @@ public MethodWriterImpl(SubWriterHolderWriter writer) { */ @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_METHOD_SUMMARY); + memberSummaryTree.add(HtmlConstants.START_OF_METHOD_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -106,12 +106,12 @@ public void addMemberTree(Content memberSummaryTree, Content memberTree) { */ @Override public Content getMethodDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { - memberDetailsTree.addContent(HtmlConstants.START_OF_METHOD_DETAILS); + memberDetailsTree.add(HtmlConstants.START_OF_METHOD_DETAILS); Content methodDetailsTree = writer.getMemberTreeHeader(); - methodDetailsTree.addContent(links.createAnchor(SectionName.METHOD_DETAIL)); + methodDetailsTree.add(links.createAnchor(SectionName.METHOD_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, contents.methodDetailLabel); - methodDetailsTree.addContent(heading); + methodDetailsTree.add(heading); return methodDetailsTree; } @@ -122,13 +122,13 @@ public Content getMethodDetailsTreeHeader(TypeElement typeElement, Content membe public Content getMethodDocTreeHeader(ExecutableElement method, Content methodDetailsTree) { String erasureAnchor; if ((erasureAnchor = getErasureAnchor(method)) != null) { - methodDetailsTree.addContent(links.createAnchor((erasureAnchor))); + methodDetailsTree.add(links.createAnchor((erasureAnchor))); } - methodDetailsTree.addContent(links.createAnchor(writer.getAnchor(method))); + methodDetailsTree.add(links.createAnchor(writer.getAnchor(method))); Content methodDocTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); - heading.addContent(name(method)); - methodDocTree.addContent(heading); + heading.add(name(method)); + methodDocTree.add(heading); return methodDocTree; } @@ -191,9 +191,9 @@ public void addComments(TypeMirror holderType, ExecutableElement method, Content utils.isClass(holder) ? contents.descfrmClassLabel : contents.descfrmInterfaceLabel); - descfrmLabel.addContent(Contents.SPACE); - descfrmLabel.addContent(codelLink); - methodDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel)); + descfrmLabel.add(Contents.SPACE); + descfrmLabel.add(codelLink); + methodDocTree.add(HtmlTree.DIV(HtmlStyle.block, descfrmLabel)); writer.addInlineComment(method, methodDocTree); } } @@ -235,7 +235,7 @@ public Content getMethodDoc(Content methodDocTree, public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, contents.methodSummary); - memberTree.addContent(label); + memberTree.add(label); } /** @@ -277,7 +277,7 @@ protected Table createSummaryTable() { */ @Override public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { - memberTree.addContent(links.createAnchor(SectionName.METHOD_SUMMARY)); + memberTree.add(links.createAnchor(SectionName.METHOD_SUMMARY)); } /** @@ -285,7 +285,7 @@ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { */ @Override public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) { - inheritedTree.addContent(links.createAnchor( + inheritedTree.add(links.createAnchor( SectionName.METHODS_INHERITANCE, configuration.getClassName(typeElement))); } @@ -308,9 +308,9 @@ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedT } Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); - labelHeading.addContent(Contents.SPACE); - labelHeading.addContent(classLink); - inheritedTree.addContent(labelHeading); + labelHeading.add(Contents.SPACE); + labelHeading.add(classLink); + inheritedTree.add(labelHeading); } /** @@ -354,7 +354,7 @@ protected static void addOverridden(HtmlDocletWriter writer, context = LinkInfoImpl.Kind.METHOD_SPECIFIED_BY; } Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, label)); - dl.addContent(dt); + dl.add(dt); Content overriddenTypeLink = writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType)); Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink); @@ -364,11 +364,11 @@ protected static void addOverridden(HtmlDocletWriter writer, .where(writer.links.getName(writer.getAnchor(method))).label(method.getSimpleName())); Content codeMethLink = HtmlTree.CODE(methlink); Content dd = HtmlTree.DD(codeMethLink); - dd.addContent(Contents.SPACE); - dd.addContent(writer.contents.inClass); - dd.addContent(Contents.SPACE); - dd.addContent(codeOverridenTypeLink); - dl.addContent(dd); + dd.add(Contents.SPACE); + dd.add(writer.contents.inClass); + dd.add(Contents.SPACE); + dd.add(codeOverridenTypeLink); + dl.add(dd); } } @@ -394,17 +394,17 @@ protected static void addImplementsInfo(HtmlDocletWriter writer, writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac)); Content codeIntfacLink = HtmlTree.CODE(intfaclink); Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, contents.specifiedByLabel)); - dl.addContent(dt); + dl.add(dt); Content methlink = writer.getDocLink( LinkInfoImpl.Kind.MEMBER, implementedMeth, implementedMeth.getSimpleName(), false); Content codeMethLink = HtmlTree.CODE(methlink); Content dd = HtmlTree.DD(codeMethLink); - dd.addContent(Contents.SPACE); - dd.addContent(contents.inInterface); - dd.addContent(Contents.SPACE); - dd.addContent(codeIntfacLink); - dl.addContent(dd); + dd.add(Contents.SPACE); + dd.add(contents.inInterface); + dd.add(Contents.SPACE); + dd.add(codeIntfacLink); + dl.add(dd); } } @@ -419,8 +419,8 @@ protected void addReturnType(ExecutableElement method, Content htmltree) { if (type != null) { Content linkContent = writer.getLink( new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type)); - htmltree.addContent(linkContent); - htmltree.addContent(Contents.SPACE); + htmltree.add(linkContent); + htmltree.add(Contents.SPACE); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java index 8ed2efe4c36..c9dadaa6bf8 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java @@ -106,13 +106,13 @@ public static void generate(HtmlConfiguration configuration, ModuleElement modul : configuration.docPaths.moduleSummary(moduleElement); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, mdlgen.links.createLink(moduleSummary, mdlLabel, "", "classFrame")); - htmlTree.addContent(heading); + htmlTree.add(heading); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.indexContainer); mdlgen.addClassListing(div); - htmlTree.addContent(div); + htmlTree.add(div); if (configuration.allowTag(HtmlTag.MAIN)) { - body.addContent(htmlTree); + body.add(htmlTree); } mdlgen.printHtmlDocument( configuration.metakeywords.getMetaKeywordsForModule(moduleElement), false, body); @@ -178,7 +178,7 @@ protected void addClassKindListing(Iterable list, Content labelCont if (!printedHeader) { Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, labelContent); - htmlTree.addContent(heading); + htmlTree.add(heading); printedHeader = true; } Content arr_i_name = new StringContent(utils.getSimpleName(typeElement)); @@ -188,11 +188,11 @@ protected void addClassKindListing(Iterable list, Content labelCont Content link = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.ALL_CLASSES_FRAME, typeElement).label(arr_i_name).target("classFrame")); Content li = HtmlTree.LI(link); - ul.addContent(li); + ul.add(li); } - htmlTree.addContent(ul); + htmlTree.add(ul); if (configuration.allowTag(HtmlTag.SECTION)) { - contentTree.addContent(htmlTree); + contentTree.add(htmlTree); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java index b6a2e8ff2e3..57f33597268 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java @@ -90,10 +90,10 @@ protected void addModulesList(Content main) { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.setTitle(contents.modulesLabel); for (ModuleElement mdle: configuration.modules) { - ul.addContent(getModuleLink(mdle)); + ul.add(getModuleLink(mdle)); } - htmlTree.addContent(ul); - main.addContent(htmlTree); + htmlTree.add(ul); + main.add(htmlTree); } /** @@ -116,8 +116,8 @@ private Content getModuleFramesHyperLink(ModuleElement mdle, Content label, Stri DocLink cFrameLink = new DocLink(docPaths.moduleSummary(mdle)); HtmlTree anchor = HtmlTree.A(mdlLink.toString(), label); String onclickStr = "updateModuleFrame('" + mtFrameLink + "','" + cFrameLink + "');"; - anchor.addAttr(HtmlAttr.TARGET, target); - anchor.addAttr(HtmlAttr.ONCLICK, onclickStr); + anchor.put(HtmlAttr.TARGET, target); + anchor.put(HtmlAttr.ONCLICK, onclickStr); return anchor; } @@ -133,7 +133,7 @@ protected void addNavigationBarHeader(Content header) { } Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.bar, headerContent); - header.addContent(heading); + header.add(heading); } /** @@ -152,7 +152,7 @@ protected void addAllClassesLink(Content ul) { Content linkContent = links.createLink(DocPaths.ALLCLASSES_FRAME, contents.allClassesLabel, "", "packageFrame"); Content li = HtmlTree.LI(linkContent); - ul.addContent(li); + ul.add(li); } /** @@ -165,7 +165,7 @@ protected void addAllPackagesLink(Content ul) { Content linkContent = links.createLink(DocPaths.OVERVIEW_FRAME, contents.allPackagesLabel, "", "packageListFrame"); Content li = HtmlTree.LI(linkContent); - ul.addContent(li); + ul.add(li); } /** @@ -173,7 +173,7 @@ protected void addAllPackagesLink(Content ul) { */ protected void addNavigationBarFooter(Content footer) { Content p = HtmlTree.P(Contents.SPACE); - footer.addContent(p); + footer.add(p); } protected void addModulePackagesList(Map> modules, String text, diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java index 4e427508c82..d49ffd83c1b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java @@ -102,8 +102,8 @@ protected void addIndexContents(Content header, Content main) { if (configuration.showModules) { addAllModulesLink(ul); } - htmltree.addContent(ul); - header.addContent(htmltree); + htmltree.add(ul); + header.add(htmltree); addModulesList(main); } @@ -149,7 +149,7 @@ protected void addModulesList(Content main) { } Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent()); - main.addContent(div); + main.add(div); if (table.needsScript()) { mainBodyScript.append(table.getScript()); @@ -171,7 +171,7 @@ protected void addOverviewHeader(Content main) { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.contentContainer); addOverviewComment(div); - main.addContent(div); + main.add(div); } } @@ -199,7 +199,7 @@ protected void addOverviewComment(Content htmltree) { protected void addNavigationBarHeader(Content header) { addTop(header); navBar.setUserHeader(getUserHeaderFooter(true)); - header.addContent(navBar.getContent(true)); + header.add(navBar.getContent(true)); } /** @@ -211,7 +211,7 @@ protected void addNavigationBarHeader(Content header) { @Override protected void addNavigationBarFooter(Content footer) { navBar.setUserFooter(getUserHeaderFooter(false)); - footer.addContent(navBar.getContent(false)); + footer.add(navBar.getContent(false)); addBottom(footer); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java index 08c16097fdd..1455127c503 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java @@ -88,19 +88,19 @@ protected void addModulePackagesList(Map> mod Content profNameContent = new StringContent(mdle.getQualifiedName().toString()); Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, getTargetModuleLink("classFrame", profNameContent, mdle)); - heading.addContent(Contents.SPACE); - heading.addContent(contents.packagesLabel); + heading.add(Contents.SPACE); + heading.add(contents.packagesLabel); HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading); HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.setTitle(contents.packagesLabel); List packages = new ArrayList<>(modules.get(mdle)); for (PackageElement pkg : packages) { if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) { - ul.addContent(getPackage(pkg, mdle)); + ul.add(getPackage(pkg, mdle)); } } - htmlTree.addContent(ul); - main.addContent(htmlTree); + htmlTree.add(ul); + main.add(htmlTree); } /** @@ -111,8 +111,8 @@ protected void addModulePackagesList(Set modules, String text, Content moduleNameContent = new StringContent(mdle.getQualifiedName().toString()); Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, getTargetModuleLink("classFrame", moduleNameContent, mdle)); - heading.addContent(Contents.SPACE); - heading.addContent(contents.packagesLabel); + heading.add(Contents.SPACE); + heading.add(contents.packagesLabel); HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading) : HtmlTree.DIV(HtmlStyle.indexContainer, heading); @@ -121,11 +121,11 @@ protected void addModulePackagesList(Set modules, String text, Set modulePackages = configuration.modulePackages.get(mdle); for (PackageElement pkg: modulePackages) { if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) { - ul.addContent(getPackage(pkg, mdle)); + ul.add(getPackage(pkg, mdle)); } } - htmlTree.addContent(ul); - body.addContent(htmlTree); + htmlTree.add(ul); + body.add(htmlTree); } /** @@ -164,7 +164,7 @@ protected void addNavigationBarHeader(Content header) { } Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.bar, headerContent); - header.addContent(heading); + header.add(heading); } /** @@ -192,7 +192,7 @@ protected void addAllClassesLink(Content ul) { Content linkContent = links.createLink(allClassesFrame, contents.allClassesLabel, "", "packageFrame"); Content li = HtmlTree.LI(linkContent); - ul.addContent(li); + ul.add(li); } /** @@ -208,7 +208,7 @@ protected void addAllPackagesLink(Content ul) { Content linkContent = links.createLink(overviewFrame, contents.allPackagesLabel, "", "packageListFrame"); Content li = HtmlTree.LI(linkContent); - ul.addContent(li); + ul.add(li); } /** @@ -224,7 +224,7 @@ protected void addAllModulesLink(Content ul) { Content linkContent = links.createLink(moduleOverviewFrame, contents.allModulesLabel, "", "packageListFrame"); Content li = HtmlTree.LI(linkContent); - ul.addContent(li); + ul.add(li); } /** @@ -232,6 +232,6 @@ protected void addAllModulesLink(Content ul) { */ protected void addNavigationBarFooter(Content footer) { Content p = HtmlTree.P(Contents.SPACE); - footer.addContent(p); + footer.add(p); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java index bbc4dfaf725..f33af70574d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java @@ -206,27 +206,27 @@ public Content getModuleHeader(String heading) { || display(indirectOpenPackages)); navBar.setDisplaySummaryServicesLink(displayServices(uses, usesTrees) || displayServices(provides.keySet(), providesTrees)); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.header); Content annotationContent = new HtmlTree(HtmlTag.P); addAnnotationInfo(mdle, annotationContent); - div.addContent(annotationContent); + div.add(annotationContent); Content label = mdle.isOpen() && (configuration.docEnv.getModuleMode() == ModuleMode.ALL) ? contents.openModuleLabel : contents.moduleLabel; Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, label); - tHeading.addContent(Contents.SPACE); + tHeading.add(Contents.SPACE); Content moduleHead = new RawHtml(heading); - tHeading.addContent(moduleHead); - div.addContent(tHeading); + tHeading.add(moduleHead); + div.add(tHeading); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(div); + mainTree.add(div); } else { - bodyTree.addContent(div); + bodyTree.add(div); } return bodyTree; } @@ -467,9 +467,9 @@ private boolean displayServiceDirective(TypeElement typeElement, */ public void addSummaryHeader(Content startMarker, SectionName markerAnchor, Content heading, Content htmltree) { - htmltree.addContent(startMarker); - htmltree.addContent(links.createAnchor(markerAnchor)); - htmltree.addContent(HtmlTree.HEADING(HtmlTag.H3, heading)); + htmltree.add(startMarker); + htmltree.add(links.createAnchor(markerAnchor)); + htmltree.add(HtmlTree.HEADING(HtmlTag.H3, heading)); } /** @@ -531,7 +531,7 @@ public void addModulesSummary(Content summaryContentTree) { Table table = getTable3(caption, tableSummary, HtmlStyle.requiresSummary, requiresTableHeader); addModulesList(requires, table); - li.addContent(table.toContent()); + li.add(table.toContent()); } // Display indirect modules table in both "api" and "all" mode. if (display(indirectModules)) { @@ -543,10 +543,10 @@ public void addModulesSummary(Content summaryContentTree) { Table amrTable = getTable3(amrCaption, amrTableSummary, HtmlStyle.requiresSummary, requiresTableHeader); addModulesList(indirectModules, amrTable); - li.addContent(amrTable.toContent()); + li.add(amrTable.toContent()); } HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); - summaryContentTree.addContent(ul); + summaryContentTree.add(ul); } } @@ -591,7 +591,7 @@ public void addPackagesSummary(Content summaryContentTree) { Table aepTable = getTable2(new StringContent(aepText), aepTableSummary, HtmlStyle.packagesSummary, indirectPackagesHeader); addIndirectPackages(aepTable, indirectPackages); - li.addContent(aepTable.toContent()); + li.add(aepTable.toContent()); } if (display(indirectOpenPackages)) { String aopText = resources.getText("doclet.Indirect_Opens_Summary"); @@ -602,10 +602,10 @@ public void addPackagesSummary(Content summaryContentTree) { Table aopTable = getTable2(new StringContent(aopText), aopTableSummary, HtmlStyle.packagesSummary, indirectPackagesHeader); addIndirectPackages(aopTable, indirectOpenPackages); - li.addContent(aopTable.toContent()); + li.add(aopTable.toContent()); } HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, li); - summaryContentTree.addContent(ul); + summaryContentTree.add(ul); } } @@ -692,7 +692,7 @@ public void addPackageSummary(String tableSummary, HtmlTree li) { table.addRow(pkg, row); } - li.addContent(table.toContent()); + li.add(table.toContent()); if (table.needsScript()) { mainBodyScript.append(table.getScript()); } @@ -722,9 +722,9 @@ private Content getPackageExportOpensTo(Set modules) { Content list = new ContentBuilder(); for (ModuleElement m : modules) { if (!list.isEmpty()) { - list.addContent(new StringContent(", ")); + list.add(new StringContent(", ")); } - list.addContent(getModuleLink(m, new StringContent(m.getQualifiedName()))); + list.add(getModuleLink(m, new StringContent(m.getQualifiedName()))); } return list; } @@ -744,8 +744,8 @@ public void addIndirectPackages(Table table, Map commentTags = ch.getDescription(configuration, deprs.get(0)); if (!commentTags.isEmpty()) { addInlineDeprecatedComment(mdle, deprs.get(0), deprDiv); } } - div.addContent(deprDiv); + div.add(deprDiv); } } @@ -899,11 +899,11 @@ public void addModuleDescription(Content moduleContentTree) { if (!utils.getFullBody(mdle).isEmpty()) { Content tree = configuration.allowTag(HtmlTag.SECTION) ? HtmlTree.SECTION() : moduleContentTree; addDeprecationInfo(tree); - tree.addContent(HtmlConstants.START_OF_MODULE_DESCRIPTION); - tree.addContent(links.createAnchor(SectionName.MODULE_DESCRIPTION)); + tree.add(HtmlConstants.START_OF_MODULE_DESCRIPTION); + tree.add(links.createAnchor(SectionName.MODULE_DESCRIPTION)); addInlineComment(mdle, tree); if (configuration.allowTag(HtmlTag.SECTION)) { - moduleContentTree.addContent(tree); + moduleContentTree.add(tree); } } } @@ -918,7 +918,7 @@ public void addModuleTags(Content moduleContentTree) { : moduleContentTree; addTagsInfo(mdle, tree); if (configuration.allowTag(HtmlTag.SECTION)) { - moduleContentTree.addContent(tree); + moduleContentTree.add(tree); } } @@ -928,10 +928,10 @@ public void addModuleTags(Content moduleContentTree) { @Override public void addModuleContent(Content contentTree, Content moduleContentTree) { if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(moduleContentTree); - contentTree.addContent(mainTree); + mainTree.add(moduleContentTree); + contentTree.add(mainTree); } else { - contentTree.addContent(moduleContentTree); + contentTree.add(moduleContentTree); } } @@ -944,10 +944,10 @@ public void addModuleFooter(Content contentTree) { ? HtmlTree.FOOTER() : contentTree; navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); + htmlTree.add(navBar.getContent(false)); addBottom(htmlTree); if (configuration.allowTag(HtmlTag.FOOTER)) { - contentTree.addContent(htmlTree); + contentTree.add(htmlTree); } } @@ -975,7 +975,7 @@ public void addPackageDeprecationInfo(Content li, PackageElement pkg) { HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); deprDiv.setStyle(HtmlStyle.deprecationBlock); Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(pkg)); - deprDiv.addContent(deprPhrase); + deprDiv.add(deprPhrase); if (!deprs.isEmpty()) { CommentHelper ch = utils.getCommentHelper(pkg); List commentTags = ch.getDescription(configuration, deprs.get(0)); @@ -983,7 +983,7 @@ public void addPackageDeprecationInfo(Content li, PackageElement pkg) { addInlineDeprecatedComment(pkg, deprs.get(0), deprDiv); } } - li.addContent(deprDiv); + li.add(deprDiv); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java index bb38b687027..1ebd4ea9dce 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java @@ -72,7 +72,7 @@ public NestedClassWriterImpl(SubWriterHolderWriter writer) { @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_NESTED_CLASS_SUMMARY); + memberSummaryTree.add(HtmlConstants.START_OF_NESTED_CLASS_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -93,7 +93,7 @@ public void addMemberTree(Content memberSummaryTree, Content memberTree) { public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, contents.nestedClassSummary); - memberTree.addContent(label); + memberTree.add(label); } /** @@ -130,7 +130,7 @@ protected Table createSummaryTable() { */ @Override public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { - memberTree.addContent(links.createAnchor( + memberTree.add(links.createAnchor( SectionName.NESTED_CLASS_SUMMARY)); } @@ -139,7 +139,7 @@ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { */ @Override public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) { - inheritedTree.addContent(links.createAnchor( + inheritedTree.add(links.createAnchor( SectionName.NESTED_CLASSES_INHERITANCE, utils.getFullyQualifiedName(typeElement))); } @@ -163,9 +163,9 @@ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedT } Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); - labelHeading.addContent(Contents.SPACE); - labelHeading.addContent(classLink); - inheritedTree.addContent(labelHeading); + labelHeading.add(Contents.SPACE); + labelHeading.add(classLink); + inheritedTree.add(labelHeading); } /** @@ -177,7 +177,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, writer.getLink(new LinkInfoImpl(configuration, context, (TypeElement)member))); Content code = HtmlTree.CODE(memberLink); - tdSummary.addContent(code); + tdSummary.add(code); } /** @@ -185,7 +185,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement */ @Override protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) { - linksTree.addContent( + linksTree.add( writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, (TypeElement)member))); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java index 7dc971dd1df..7e3330120a2 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java @@ -106,13 +106,13 @@ public static void generate(HtmlConfiguration configuration, PackageElement pack : body; Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, packgen.getTargetPackageLink(packageElement, "classFrame", pkgNameContent)); - htmlTree.addContent(heading); + htmlTree.add(heading); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.indexContainer); packgen.addClassListing(div); - htmlTree.addContent(div); + htmlTree.add(div); if (configuration.allowTag(HtmlTag.MAIN)) { - body.addContent(htmlTree); + body.add(htmlTree); } packgen.printHtmlDocument( configuration.metakeywords.getMetaKeywords(packageElement), false, body); @@ -183,7 +183,7 @@ protected void addClassKindListing(Iterable list, Content labelCont if (!printedHeader) { Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, labelContent); - htmlTree.addContent(heading); + htmlTree.add(heading); printedHeader = true; } Content arr_i_name = new StringContent(utils.getSimpleName(typeElement)); @@ -192,11 +192,11 @@ protected void addClassKindListing(Iterable list, Content labelCont Content link = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE_FRAME, typeElement).label(arr_i_name).target("classFrame")); Content li = HtmlTree.LI(link); - ul.addContent(li); + ul.add(li); } - htmlTree.addContent(ul); + htmlTree.add(ul); if (configuration.allowTag(HtmlTag.SECTION)) { - contentTree.addContent(htmlTree); + contentTree.add(htmlTree); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java index 8005d435451..8e25688bf55 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java @@ -88,11 +88,11 @@ protected void addPackagesList(Content main) { // package is marked as deprecated. if (aPackage != null && (!(configuration.nodeprecated && utils.isDeprecated(aPackage)))) { - ul.addContent(getPackage(aPackage)); + ul.add(getPackage(aPackage)); } } - htmlTree.addContent(ul); - main.addContent(htmlTree); + htmlTree.add(ul); + main.add(htmlTree); } /** @@ -131,7 +131,7 @@ protected void addNavigationBarHeader(Content header) { } Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.bar, headerContent); - header.addContent(heading); + header.add(heading); } /** @@ -152,7 +152,7 @@ protected void addAllClassesLink(Content ul) { Content linkContent = links.createLink(DocPaths.ALLCLASSES_FRAME, contents.allClassesLabel, "", "packageFrame"); Content li = HtmlTree.LI(linkContent); - ul.addContent(li); + ul.add(li); } /** @@ -166,7 +166,7 @@ protected void addAllModulesLink(Content ul) { Content linkContent = links.createLink(DocPaths.MODULE_OVERVIEW_FRAME, contents.allModulesLabel, "", "packageListFrame"); Content li = HtmlTree.LI(linkContent); - ul.addContent(li); + ul.add(li); } /** @@ -175,6 +175,6 @@ protected void addAllModulesLink(Content ul) { @Override protected void addNavigationBarFooter(Content footer) { Content p = HtmlTree.P(Contents.SPACE); - footer.addContent(p); + footer.add(p); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java index 984996cb369..d5dff838106 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java @@ -132,7 +132,7 @@ protected void addPackagesList(Content main) { } Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent()); - main.addContent(div); + main.add(div); if (table.needsScript()) { getMainBodyScript().append(table.getScript()); @@ -154,7 +154,7 @@ protected void addOverviewHeader(Content main) { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.contentContainer); addOverviewComment(div); - main.addContent(div); + main.add(div); } } @@ -182,7 +182,7 @@ protected void addOverviewComment(Content htmltree) { protected void addNavigationBarHeader(Content header) { addTop(header); navBar.setUserHeader(getUserHeaderFooter(true)); - header.addContent(navBar.getContent(true)); + header.add(navBar.getContent(true)); } /** @@ -194,7 +194,7 @@ protected void addNavigationBarHeader(Content header) { @Override protected void addNavigationBarFooter(Content footer) { navBar.setUserFooter(getUserHeaderFooter(false)); - footer.addContent(navBar.getContent(false)); + footer.add(navBar.getContent(false)); addBottom(footer); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java index 063ac738b07..8b3088f9ee0 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java @@ -109,25 +109,25 @@ protected void generatePackageTreeFile() throws DocFileIOException { if (configuration.packages.size() > 1) { addLinkToMainTree(div); } - htmlTree.addContent(div); + htmlTree.add(div); HtmlTree divTree = new HtmlTree(HtmlTag.DIV); divTree.setStyle(HtmlStyle.contentContainer); addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", divTree); addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", divTree); addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree); addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree, true); - htmlTree.addContent(divTree); + htmlTree.add(divTree); if (configuration.allowTag(HtmlTag.MAIN)) { - body.addContent(htmlTree); + body.add(htmlTree); } HtmlTree tree = (configuration.allowTag(HtmlTag.FOOTER)) ? HtmlTree.FOOTER() : body; navBar.setUserFooter(getUserHeaderFooter(false)); - tree.addContent(navBar.getContent(false)); + tree.add(navBar.getContent(false)); addBottom(tree); if (configuration.allowTag(HtmlTag.FOOTER)) { - body.addContent(tree); + body.add(tree); } printHtmlDocument(null, true, body); } @@ -149,9 +149,9 @@ protected HtmlTree getPackageTreeHeader() { contents.moduleLabel); navBar.setNavLinkModule(linkContent); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } return bodyTree; } @@ -164,10 +164,10 @@ protected HtmlTree getPackageTreeHeader() { protected void addLinkToMainTree(Content div) { Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel, contents.packageHierarchies); - div.addContent(span); + div.add(span); HtmlTree ul = new HtmlTree (HtmlTag.UL); ul.setStyle(HtmlStyle.horizontal); - ul.addContent(getNavLinkMainTree(configuration.getText("doclet.All_Packages"))); - div.addContent(ul); + ul.add(getNavLinkMainTree(configuration.getText("doclet.All_Packages"))); + div.add(ul); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java index ebed4a15e10..022d3cc2058 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java @@ -130,24 +130,24 @@ protected void generatePackageUseFile() throws DocFileIOException { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.contentContainer); if (usingPackageToUsedClasses.isEmpty()) { - div.addContent(contents.getContent("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement))); + div.add(contents.getContent("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement))); } else { addPackageUse(div); } if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(div); - body.addContent(mainTree); + mainTree.add(div); + body.add(mainTree); } else { - body.addContent(div); + body.add(div); } HtmlTree tree = (configuration.allowTag(HtmlTag.FOOTER)) ? HtmlTree.FOOTER() : body; navBar.setUserFooter(getUserHeaderFooter(false)); - tree.addContent(navBar.getContent(false)); + tree.add(navBar.getContent(false)); addBottom(tree); if (configuration.allowTag(HtmlTag.FOOTER)) { - body.addContent(tree); + body.add(tree); } printHtmlDocument(null, true, body); } @@ -164,7 +164,7 @@ protected void addPackageUse(Content contentTree) { addPackageList(ul); } addClassList(ul); - contentTree.addContent(ul); + contentTree.add(ul); } /** @@ -189,12 +189,12 @@ protected void addPackageList(Content contentTree) { if (pkg != null && !pkg.isUnnamed()) { addSummaryComment(pkg, summary); } else { - summary.addContent(Contents.SPACE); + summary.add(Contents.SPACE); } table.addRow(packageLink, summary); } Content li = HtmlTree.LI(HtmlStyle.blockList, table.toContent()); - contentTree.addContent(li); + contentTree.add(li); } /** @@ -210,7 +210,7 @@ protected void addClassList(Content contentTree) { HtmlTree li = new HtmlTree(HtmlTag.LI); li.setStyle(HtmlStyle.blockList); if (usingPackage != null) { - li.addContent(links.createAnchor(utils.getPackageName(usingPackage))); + li.add(links.createAnchor(utils.getPackageName(usingPackage))); } String tableSummary = resources.getText("doclet.Use_Table_Summary", resources.getText("doclet.classes")); @@ -234,8 +234,8 @@ protected void addClassList(Content contentTree) { table.addRow(typeContent, summary); } - li.addContent(table.toContent()); - contentTree.addContent(li); + li.add(table.toContent()); + contentTree.add(li); } } @@ -257,21 +257,21 @@ private HtmlTree getPackageUseHeader() { contents.moduleLabel); navBar.setNavLinkModule(linkContent); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } ContentBuilder headContent = new ContentBuilder(); - headContent.addContent(contents.getContent("doclet.ClassUse_Title", packageText)); - headContent.addContent(new HtmlTree(HtmlTag.BR)); - headContent.addContent(name); + headContent.add(contents.getContent("doclet.ClassUse_Title", packageText)); + headContent.add(new HtmlTree(HtmlTag.BR)); + headContent.add(name); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(div); + mainTree.add(div); } else { - bodyTree.addContent(div); + bodyTree.add(div); } return bodyTree; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java index c4e68858fef..2aa5a426902 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java @@ -115,9 +115,9 @@ public Content getPackageHeader(String heading) { contents.moduleLabel); navBar.setNavLinkModule(linkContent); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } HtmlTree div = new HtmlTree(HtmlTag.DIV); div.setStyle(HtmlStyle.header); @@ -125,24 +125,24 @@ public Content getPackageHeader(String heading) { ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(packageElement); Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInPackage, contents.moduleLabel); Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classModuleLabel); - moduleNameDiv.addContent(Contents.SPACE); - moduleNameDiv.addContent(getModuleLink(mdle, + moduleNameDiv.add(Contents.SPACE); + moduleNameDiv.add(getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString()))); - div.addContent(moduleNameDiv); + div.add(moduleNameDiv); } Content annotationContent = new HtmlTree(HtmlTag.P); addAnnotationInfo(packageElement, annotationContent); - div.addContent(annotationContent); + div.add(annotationContent); Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, contents.packageLabel); - tHeading.addContent(Contents.SPACE); + tHeading.add(Contents.SPACE); Content packageHead = new StringContent(heading); - tHeading.addContent(packageHead); - div.addContent(tHeading); + tHeading.add(packageHead); + div.add(tHeading); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(div); + mainTree.add(div); } else { - bodyTree.addContent(div); + bodyTree.add(div); } return bodyTree; } @@ -169,14 +169,14 @@ public void addDeprecationInfo(Content div) { HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); deprDiv.setStyle(HtmlStyle.deprecationBlock); Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(packageElement)); - deprDiv.addContent(deprPhrase); + deprDiv.add(deprPhrase); if (!deprs.isEmpty()) { List commentTags = ch.getDescription(configuration, deprs.get(0)); if (!commentTags.isEmpty()) { addInlineDeprecatedComment(packageElement, deprs.get(0), deprDiv); } } - div.addContent(deprDiv); + div.add(deprDiv); } } @@ -267,7 +267,7 @@ public void addClassesSummary(SortedSet classes, String label, configuration, LinkInfoImpl.Kind.PACKAGE, klass)); ContentBuilder description = new ContentBuilder(); if (utils.isDeprecated(klass)) { - description.addContent(getDeprecatedPhrase(klass)); + description.add(getDeprecatedPhrase(klass)); List tags = utils.getDeprecatedTrees(klass); if (!tags.isEmpty()) { addSummaryDeprecatedComment(klass, tags.get(0), description); @@ -278,7 +278,7 @@ public void addClassesSummary(SortedSet classes, String label, table.addRow(classLink, description); } Content li = HtmlTree.LI(HtmlStyle.blockList, table.toContent()); - summaryContentTree.addContent(li); + summaryContentTree.add(li); } } @@ -289,7 +289,7 @@ public void addClassesSummary(SortedSet classes, String label, public void addPackageDescription(Content packageContentTree) { if (!utils.getBody(packageElement).isEmpty()) { Content tree = configuration.allowTag(HtmlTag.SECTION) ? sectionTree : packageContentTree; - tree.addContent(links.createAnchor(SectionName.PACKAGE_DESCRIPTION)); + tree.add(links.createAnchor(SectionName.PACKAGE_DESCRIPTION)); addDeprecationInfo(tree); addInlineComment(packageElement, tree); } @@ -305,7 +305,7 @@ public void addPackageTags(Content packageContentTree) { : packageContentTree; addTagsInfo(packageElement, htmlTree); if (configuration.allowTag(HtmlTag.SECTION)) { - packageContentTree.addContent(sectionTree); + packageContentTree.add(sectionTree); } } @@ -315,10 +315,10 @@ public void addPackageTags(Content packageContentTree) { @Override public void addPackageContent(Content contentTree, Content packageContentTree) { if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(packageContentTree); - contentTree.addContent(mainTree); + mainTree.add(packageContentTree); + contentTree.add(mainTree); } else { - contentTree.addContent(packageContentTree); + contentTree.add(packageContentTree); } } @@ -331,10 +331,10 @@ public void addPackageFooter(Content contentTree) { ? HtmlTree.FOOTER() : contentTree; navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); + htmlTree.add(navBar.getContent(false)); addBottom(htmlTree); if (configuration.allowTag(HtmlTag.FOOTER)) { - contentTree.addContent(htmlTree); + contentTree.add(htmlTree); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java index de29221538c..610ce13e10b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java @@ -68,7 +68,7 @@ public PropertyWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) */ @Override public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) { - memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY); + memberSummaryTree.add(HtmlConstants.START_OF_PROPERTY_SUMMARY); Content memberTree = writer.getMemberTreeHeader(); writer.addSummaryHeader(this, typeElement, memberTree); return memberTree; @@ -88,12 +88,12 @@ public void addMemberTree(Content memberSummaryTree, Content memberTree) { @Override public Content getPropertyDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) { - memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS); + memberDetailsTree.add(HtmlConstants.START_OF_PROPERTY_DETAILS); Content propertyDetailsTree = writer.getMemberTreeHeader(); - propertyDetailsTree.addContent(links.createAnchor(SectionName.PROPERTY_DETAIL)); + propertyDetailsTree.add(links.createAnchor(SectionName.PROPERTY_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, contents.propertyDetailsLabel); - propertyDetailsTree.addContent(heading); + propertyDetailsTree.add(heading); return propertyDetailsTree; } @@ -103,11 +103,11 @@ public Content getPropertyDetailsTreeHeader(TypeElement typeElement, @Override public Content getPropertyDocTreeHeader(ExecutableElement property, Content propertyDetailsTree) { - propertyDetailsTree.addContent(links.createAnchor(name(property))); + propertyDetailsTree.add(links.createAnchor(name(property))); Content propertyDocTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); - heading.addContent(utils.getPropertyLabel(name(property))); - propertyDocTree.addContent(heading); + heading.add(utils.getPropertyLabel(name(property))); + propertyDocTree.add(heading); return propertyDocTree; } @@ -122,8 +122,8 @@ public Content getSignature(ExecutableElement property) { Content propertylink = writer.getLink(new LinkInfoImpl( configuration, LinkInfoImpl.Kind.MEMBER, utils.getReturnType(property))); - pre.addContent(propertylink); - pre.addContent(" "); + pre.add(propertylink); + pre.add(" "); if (configuration.linksource) { Content propertyName = new StringContent(name(property)); writer.addSrcLink(property, propertyName, pre); @@ -162,9 +162,9 @@ public void addComments(ExecutableElement property, Content propertyDocTree) { utils.isClass(holder) ? contents.descfrmClassLabel : contents.descfrmInterfaceLabel); - descfrmLabel.addContent(Contents.SPACE); - descfrmLabel.addContent(codeLink); - propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel)); + descfrmLabel.add(Contents.SPACE); + descfrmLabel.add(codeLink); + propertyDocTree.add(HtmlTree.DIV(HtmlStyle.block, descfrmLabel)); writer.addInlineComment(property, propertyDocTree); } } @@ -206,7 +206,7 @@ public Content getPropertyDoc(Content propertyDocTree, public void addSummaryLabel(Content memberTree) { Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, contents.propertySummaryLabel); - memberTree.addContent(label); + memberTree.add(label); } /** @@ -241,7 +241,7 @@ protected Table createSummaryTable() { */ @Override public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { - memberTree.addContent(links.createAnchor(SectionName.PROPERTY_SUMMARY)); + memberTree.add(links.createAnchor(SectionName.PROPERTY_SUMMARY)); } /** @@ -249,7 +249,7 @@ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) { */ @Override public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) { - inheritedTree.addContent(links.createAnchor( + inheritedTree.add(links.createAnchor( SectionName.PROPERTIES_INHERITANCE, configuration.getClassName(typeElement))); } @@ -273,9 +273,9 @@ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedT } Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, label); - labelHeading.addContent(Contents.SPACE); - labelHeading.addContent(classLink); - inheritedTree.addContent(labelHeading); + labelHeading.add(Contents.SPACE); + labelHeading.add(classLink); + inheritedTree.add(labelHeading); } /** @@ -292,7 +292,7 @@ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement true)); Content code = HtmlTree.CODE(memberLink); - tdSummary.addContent(code); + tdSummary.add(code); } /** @@ -304,7 +304,7 @@ protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content content = writer.getDocLink(LinkInfoImpl.Kind.MEMBER, typeElement, member, utils.isProperty(mname) ? utils.getPropertyName(mname) : mname, false, true); - linksTree.addContent(content); + linksTree.add(content); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java index f76609cde4c..71d05d1ee0d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java @@ -85,18 +85,18 @@ public Content getHeader(String header) { : bodyTree; addTop(htmlTree); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } Content h1Content = new StringContent(header); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, h1Content); Content div = HtmlTree.DIV(HtmlStyle.header, heading); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(div); + mainTree.add(div); } else { - bodyTree.addContent(div); + bodyTree.add(div); } return bodyTree; } @@ -137,8 +137,8 @@ public Content getPackageSerializedHeader() { public Content getPackageHeader(String packageName) { Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, contents.packageLabel); - heading.addContent(Contents.SPACE); - heading.addContent(packageName); + heading.add(Contents.SPACE); + heading.add(packageName); return heading; } @@ -188,7 +188,7 @@ public Content getClassHeader(TypeElement typeElement) { configuration.getContent( "doclet.Class_0_extends_implements_serializable", classLink, superClassLink); - li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, + li.add(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING, className)); return li; } @@ -215,9 +215,9 @@ public Content getSerialUIDInfoHeader() { public void addSerialUIDInfo(String header, String serialUID, Content serialUidTree) { Content headerContent = new StringContent(header); - serialUidTree.addContent(HtmlTree.DT(headerContent)); + serialUidTree.add(HtmlTree.DT(headerContent)); Content serialContent = new StringContent(serialUID); - serialUidTree.addContent(HtmlTree.DD(serialContent)); + serialUidTree.add(HtmlTree.DD(serialContent)); } /** @@ -241,7 +241,7 @@ public Content getSerializedContent(Content serializedTreeContent) { HtmlTree divContent = HtmlTree.DIV(HtmlStyle.serializedFormContainer, serializedTreeContent); if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(divContent); + mainTree.add(divContent); return mainTree; } else { return divContent; @@ -253,7 +253,7 @@ public Content getSerializedContent(Content serializedTreeContent) { */ public void addPackageSerializedTree(Content serializedSummariesTree, Content packageSerializedTree) { - serializedSummariesTree.addContent((configuration.allowTag(HtmlTag.SECTION)) + serializedSummariesTree.add((configuration.allowTag(HtmlTag.SECTION)) ? HtmlTree.LI(HtmlStyle.blockList, packageSerializedTree) : packageSerializedTree); } @@ -268,10 +268,10 @@ public void addFooter(Content serializedTree) { ? HtmlTree.FOOTER() : serializedTree; navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); + htmlTree.add(navBar.getContent(false)); addBottom(htmlTree); if (configuration.allowTag(HtmlTag.FOOTER)) { - serializedTree.addContent(htmlTree); + serializedTree.add(htmlTree); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java index 2ed89278d14..8eb3fa98844 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java @@ -98,9 +98,9 @@ protected void generateIndexFile() throws DocFileIOException { : body; addTop(htmlTree); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - body.addContent(htmlTree); + body.add(htmlTree); } HtmlTree divTree = new HtmlTree(HtmlTag.DIV); divTree.setStyle(HtmlStyle.contentContainer); @@ -118,17 +118,17 @@ protected void generateIndexFile() throws DocFileIOException { } } addLinksForIndexes(divTree); - body.addContent((configuration.allowTag(HtmlTag.MAIN)) + body.add((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(divTree) : divTree); if (configuration.allowTag(HtmlTag.FOOTER)) { htmlTree = HtmlTree.FOOTER(); } navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); + htmlTree.add(navBar.getContent(false)); addBottom(htmlTree); if (configuration.allowTag(HtmlTag.FOOTER)) { - body.addContent(htmlTree); + body.add(htmlTree); } createSearchIndexFiles(); printHtmlDocument(null, true, body); @@ -142,17 +142,17 @@ protected void generateIndexFile() throws DocFileIOException { protected void addLinksForIndexes(Content contentTree) { for (Object ch : elements) { String unicode = ch.toString(); - contentTree.addContent( + contentTree.add( links.createLink(getNameForIndex(unicode), new StringContent(unicode))); - contentTree.addContent(Contents.SPACE); + contentTree.add(Contents.SPACE); } - contentTree.addContent(new HtmlTree(HtmlTag.BR)); - contentTree.addContent(links.createLink(DocPaths.ALLCLASSES_INDEX, + contentTree.add(new HtmlTree(HtmlTag.BR)); + contentTree.add(links.createLink(DocPaths.ALLCLASSES_INDEX, contents.allClassesLabel)); if (!configuration.packages.isEmpty()) { - contentTree.addContent(Contents.SPACE); - contentTree.addContent(links.createLink(DocPaths.ALLPACKAGES_INDEX, + contentTree.add(Contents.SPACE); + contentTree.add(links.createLink(DocPaths.ALLPACKAGES_INDEX, contents.allPackagesLabel)); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java index 3db73591b29..77b247e17af 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java @@ -195,7 +195,7 @@ public void convertClass(TypeElement te, DocPath outputdir) } addBlankLines(pre); Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre); - body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(div) : div); + body.add((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(div) : div); writeToFile(body, outputdir.resolve(configuration.docPaths.forClass(te))); } catch (IOException e) { String message = resources.getText("doclet.exception.read.file", fo.getName()); @@ -240,7 +240,7 @@ public void addStyleSheetProperties(Content head) { } DocPath p = relativePath.resolve(stylesheet); HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", p.getPath(), "Style"); - head.addContent(link); + head.add(link); addStylesheets(head); } @@ -252,7 +252,7 @@ protected void addStylesheets(Content tree) { DocPath ssheetPath = DocPath.create(file.getName()); HtmlTree slink = HtmlTree.LINK("stylesheet", "text/css", relativePath.resolve(ssheetPath).getPath(), "Style"); - tree.addContent(slink); + tree.add(slink); }); } } @@ -276,13 +276,13 @@ private static void addLineNo(Content pre, int lineno) { HtmlTree span = new HtmlTree(HtmlTag.SPAN); span.setStyle(HtmlStyle.sourceLineNo); if (lineno < 10) { - span.addContent("00" + Integer.toString(lineno)); + span.add("00" + Integer.toString(lineno)); } else if (lineno < 100) { - span.addContent("0" + Integer.toString(lineno)); + span.add("0" + Integer.toString(lineno)); } else { - span.addContent(Integer.toString(lineno)); + span.add(Integer.toString(lineno)); } - pre.addContent(span); + pre.add(span); } /** @@ -297,8 +297,8 @@ private void addLine(Content pre, String line, int currentLineNo) { Content anchor = HtmlTree.A(configuration.htmlVersion, "line." + Integer.toString(currentLineNo), new StringContent(utils.replaceTabs(line))); - pre.addContent(anchor); - pre.addContent(NEW_LINE); + pre.add(anchor); + pre.add(NEW_LINE); } } @@ -309,7 +309,7 @@ private void addLine(Content pre, String line, int currentLineNo) { */ private static void addBlankLines(Content pre) { for (int i = 0; i < NUM_BLANK_LINES; i++) { - pre.addContent(NEW_LINE); + pre.add(NEW_LINE); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java index a2aa5f59f70..f781736f807 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java @@ -126,9 +126,9 @@ protected void generateIndexFile(Character unicode) throws DocFileIOException { : body; addTop(htmlTree); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - body.addContent(htmlTree); + body.add(htmlTree); } HtmlTree divTree = new HtmlTree(HtmlTag.DIV); divTree.setStyle(HtmlStyle.contentContainer); @@ -142,15 +142,15 @@ protected void generateIndexFile(Character unicode) throws DocFileIOException { configuration.tagSearchIndexMap.get(unicode), divTree); } addLinksForIndexes(divTree); - body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(divTree) : divTree); + body.add((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(divTree) : divTree); if (configuration.allowTag(HtmlTag.FOOTER)) { htmlTree = HtmlTree.FOOTER(); } navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); + htmlTree.add(navBar.getContent(false)); addBottom(htmlTree); if (configuration.allowTag(HtmlTag.FOOTER)) { - body.addContent(htmlTree); + body.add(htmlTree); } printHtmlDocument(null, true, body); } @@ -163,16 +163,16 @@ protected void generateIndexFile(Character unicode) throws DocFileIOException { protected void addLinksForIndexes(Content contentTree) { for (int i = 0; i < indexElements.size(); i++) { int j = i + 1; - contentTree.addContent(links.createLink(DocPaths.indexN(j), + contentTree.add(links.createLink(DocPaths.indexN(j), new StringContent(indexElements.get(i).toString()))); - contentTree.addContent(Contents.SPACE); + contentTree.add(Contents.SPACE); } - contentTree.addContent(new HtmlTree(HtmlTag.BR)); - contentTree.addContent(links.createLink(pathToRoot.resolve(DocPaths.ALLCLASSES_INDEX), + contentTree.add(new HtmlTree(HtmlTag.BR)); + contentTree.add(links.createLink(pathToRoot.resolve(DocPaths.ALLCLASSES_INDEX), contents.allClassesLabel)); if (!configuration.packages.isEmpty()) { - contentTree.addContent(Contents.SPACE); - contentTree.addContent(links.createLink(pathToRoot.resolve(DocPaths.ALLPACKAGES_INDEX), + contentTree.add(Contents.SPACE); + contentTree.add(links.createLink(pathToRoot.resolve(DocPaths.ALLPACKAGES_INDEX), contents.allPackagesLabel)); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java index 7eff630a7da..4b2ef2a3278 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -122,14 +122,14 @@ protected void addIndexComment(Element member, List firstSent if (!deprs.isEmpty()) { addSummaryDeprecatedComment(member, deprs.get(0), div); } - tdSummary.addContent(div); + tdSummary.add(div); return; } else { Element te = member.getEnclosingElement(); if (te != null && utils.isTypeElement(te) && utils.isDeprecated(te)) { Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, getDeprecatedPhrase(te)); div = HtmlTree.DIV(HtmlStyle.block, deprLabel); - tdSummary.addContent(div); + tdSummary.add(div); } } addSummaryComment(member, firstSentenceTags, tdSummary); @@ -172,7 +172,7 @@ public void addSummaryLinkComment(AbstractMemberWriter mw, public void addInheritedMemberSummary(AbstractMemberWriter mw, TypeElement typeElement, Element member, boolean isFirst, Content linksTree) { if (! isFirst) { - linksTree.addContent(", "); + linksTree.add(", "); } mw.addInheritedSummaryLink(typeElement, member, linksTree); } @@ -196,10 +196,10 @@ public Content getContentHeader() { */ public void addClassContentTree(Content contentTree, Content classContentTree) { if (configuration.allowTag(HtmlTag.MAIN)) { - mainTree.addContent(classContentTree); - contentTree.addContent(mainTree); + mainTree.add(classContentTree); + contentTree.add(mainTree); } else { - contentTree.addContent(classContentTree); + contentTree.add(classContentTree); } } @@ -233,9 +233,9 @@ public Content getMemberTreeHeader() { public void addMemberTree(Content memberSummaryTree, Content memberTree) { if (configuration.allowTag(HtmlTag.SECTION)) { HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(memberTree)); - memberSummaryTree.addContent(htmlTree); + memberSummaryTree.add(htmlTree); } else { - memberSummaryTree.addContent(getMemberTree(memberTree)); + memberSummaryTree.add(getMemberTree(memberTree)); } } 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 7079ce69b2d..db102820db2 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -179,29 +179,29 @@ public Content deprecatedTagOutput(Element element) { List deprs = utils.getBlockTags(element, DocTree.Kind.DEPRECATED); if (utils.isTypeElement(element)) { if (utils.isDeprecated(element)) { - result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, + result.add(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, htmlWriter.getDeprecatedPhrase(element))); if (!deprs.isEmpty()) { List commentTags = ch.getDescription(configuration, deprs.get(0)); if (!commentTags.isEmpty()) { - result.addContent(commentTagsToOutput(null, element, commentTags, false)); + result.add(commentTagsToOutput(null, element, commentTags, false)); } } } } else { if (utils.isDeprecated(element)) { - result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, + result.add(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, htmlWriter.getDeprecatedPhrase(element))); if (!deprs.isEmpty()) { List bodyTags = ch.getBody(configuration, deprs.get(0)); Content body = commentTagsToOutput(null, element, bodyTags, false); if (!body.isEmpty()) - result.addContent(HtmlTree.DIV(HtmlStyle.deprecationComment, body)); + result.add(HtmlTree.DIV(HtmlStyle.deprecationComment, body)); } } else { Element ee = utils.getEnclosingTypeElement(element); if (utils.isDeprecated(ee)) { - result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, + result.add(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, htmlWriter.getDeprecatedPhrase(ee))); } } @@ -233,10 +233,10 @@ public Content getParamHeader(String header) { public Content paramTagOutput(Element element, DocTree paramTag, String paramName) { ContentBuilder body = new ContentBuilder(); CommentHelper ch = utils.getCommentHelper(element); - body.addContent(HtmlTree.CODE(new RawHtml(paramName))); - body.addContent(" - "); + body.add(HtmlTree.CODE(new RawHtml(paramName))); + body.add(" - "); List description = ch.getDescription(configuration, paramTag); - body.addContent(htmlWriter.commentTagsToContent(paramTag, element, description, false)); + body.add(htmlWriter.commentTagsToContent(paramTag, element, description, false)); HtmlTree result = HtmlTree.DD(body); return result; } @@ -247,10 +247,10 @@ public Content paramTagOutput(Element element, DocTree paramTag, String paramNam public Content propertyTagOutput(Element element, DocTree tag, String prefix) { Content body = new ContentBuilder(); CommentHelper ch = utils.getCommentHelper(element); - body.addContent(new RawHtml(prefix)); - body.addContent(" "); - body.addContent(HtmlTree.CODE(new RawHtml(ch.getText(tag)))); - body.addContent("."); + body.add(new RawHtml(prefix)); + body.add(" "); + body.add(HtmlTree.CODE(new RawHtml(ch.getText(tag)))); + body.add("."); Content result = HtmlTree.P(body); return result; } @@ -261,9 +261,9 @@ public Content propertyTagOutput(Element element, DocTree tag, String prefix) { public Content returnTagOutput(Element element, DocTree returnTag) { ContentBuilder result = new ContentBuilder(); CommentHelper ch = utils.getCommentHelper(element); - result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.returnLabel, + result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.returnLabel, new StringContent(configuration.getText("doclet.Returns"))))); - result.addContent(HtmlTree.DD(htmlWriter.commentTagsToContent( + result.add(HtmlTree.DD(htmlWriter.commentTagsToContent( returnTag, element, ch.getDescription(configuration, returnTag), false))); return result; } @@ -275,7 +275,7 @@ public Content seeTagOutput(Element holder, List seeTags) { ContentBuilder body = new ContentBuilder(); for (DocTree dt : seeTags) { appendSeparatorIfNotEmpty(body); - body.addContent(htmlWriter.seeTagToContent(holder, dt)); + body.add(htmlWriter.seeTagToContent(holder, dt)); } if (utils.isVariableElement(holder) && ((VariableElement)holder).getConstantValue() != null && htmlWriter instanceof ClassWriterImpl) { @@ -287,7 +287,7 @@ public Content seeTagOutput(Element holder, List seeTags) { ((ClassWriterImpl) htmlWriter).getTypeElement().getQualifiedName() + "." + utils.getSimpleName(holder); DocLink link = constantsPath.fragment(whichConstant); - body.addContent(htmlWriter.links.createLink(link, + body.add(htmlWriter.links.createLink(link, new StringContent(configuration.getText("doclet.Constants_Summary")))); } if (utils.isClass(holder) && utils.isSerializable((TypeElement)holder)) { @@ -297,7 +297,7 @@ public Content seeTagOutput(Element holder, List seeTags) { appendSeparatorIfNotEmpty(body); DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM); DocLink link = serialPath.fragment(utils.getFullyQualifiedName(holder)); - body.addContent(htmlWriter.links.createLink(link, + body.add(htmlWriter.links.createLink(link, new StringContent(configuration.getText("doclet.Serialized_Form")))); } } @@ -305,17 +305,17 @@ public Content seeTagOutput(Element holder, List seeTags) { return body; ContentBuilder result = new ContentBuilder(); - result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.seeLabel, + result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.seeLabel, new StringContent(configuration.getText("doclet.See_Also"))))); - result.addContent(HtmlTree.DD(body)); + result.add(HtmlTree.DD(body)); return result; } private void appendSeparatorIfNotEmpty(ContentBuilder body) { if (!body.isEmpty()) { - body.addContent(", "); - body.addContent(DocletConstants.NL); + body.add(", "); + body.add(DocletConstants.NL); } } @@ -325,18 +325,18 @@ private void appendSeparatorIfNotEmpty(ContentBuilder body) { public Content simpleTagOutput(Element element, List simpleTags, String header) { CommentHelper ch = utils.getCommentHelper(element); ContentBuilder result = new ContentBuilder(); - result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header)))); + result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header)))); ContentBuilder body = new ContentBuilder(); boolean many = false; for (DocTree simpleTag : simpleTags) { if (many) { - body.addContent(", "); + body.add(", "); } List bodyTags = ch.getBody(configuration, simpleTag); - body.addContent(htmlWriter.commentTagsToContent(simpleTag, element, bodyTags, false)); + body.add(htmlWriter.commentTagsToContent(simpleTag, element, bodyTags, false)); many = true; } - result.addContent(HtmlTree.DD(body)); + result.add(HtmlTree.DD(body)); return result; } @@ -345,11 +345,11 @@ public Content simpleTagOutput(Element element, List simpleTa */ public Content simpleTagOutput(Element element, DocTree simpleTag, String header) { ContentBuilder result = new ContentBuilder(); - result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header)))); + result.add(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header)))); CommentHelper ch = utils.getCommentHelper(element); List description = ch.getDescription(configuration, simpleTag); Content body = htmlWriter.commentTagsToContent(simpleTag, element, description, false); - result.addContent(HtmlTree.DD(body)); + result.add(HtmlTree.DD(body)); return result; } @@ -380,12 +380,12 @@ public Content throwsTagOutput(Element element, DocTree throwsTag) { link.excludeTypeBounds = true; excName = htmlWriter.getLink(link); } - body.addContent(HtmlTree.CODE(excName)); + body.add(HtmlTree.CODE(excName)); List description = ch.getDescription(configuration, throwsTag); Content desc = htmlWriter.commentTagsToContent(throwsTag, element, description, false); if (desc != null && !desc.isEmpty()) { - body.addContent(" - "); - body.addContent(desc); + body.add(" - "); + body.add(desc); } HtmlTree result = HtmlTree.DD(body); return result; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java index 62fad1d47ed..85185b81ae8 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java @@ -115,16 +115,16 @@ public void generateTreeFile() throws DocFileIOException { HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN() : body; - htmlTree.addContent(div); + htmlTree.add(div); HtmlTree divTree = new HtmlTree(HtmlTag.DIV); divTree.setStyle(HtmlStyle.contentContainer); addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", divTree); addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", divTree); addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree); addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree, true); - htmlTree.addContent(divTree); + htmlTree.add(divTree); if (configuration.allowTag(HtmlTag.MAIN)) { - body.addContent(htmlTree); + body.add(htmlTree); } if (configuration.allowTag(HtmlTag.FOOTER)) { htmlTree = HtmlTree.FOOTER(); @@ -132,10 +132,10 @@ public void generateTreeFile() throws DocFileIOException { htmlTree = body; } navBar.setUserFooter(getUserHeaderFooter(false)); - htmlTree.addContent(navBar.getContent(false)); + htmlTree.add(navBar.getContent(false)); addBottom(htmlTree); if (configuration.allowTag(HtmlTag.FOOTER)) { - body.addContent(htmlTree); + body.add(htmlTree); } printHtmlDocument(null, true, body); } @@ -153,7 +153,7 @@ protected void addPackageTreeLinks(Content contentTree) { if (!classesOnly) { Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel, contents.packageHierarchies); - contentTree.addContent(span); + contentTree.add(span); HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.setStyle(HtmlStyle.horizontal); int i = 0; @@ -170,12 +170,12 @@ protected void addPackageTreeLinks(Content contentTree) { Content li = HtmlTree.LI(links.createLink(link, new StringContent(utils.getPackageName(pkg)))); if (i < packages.size() - 1) { - li.addContent(", "); + li.add(", "); } - ul.addContent(li); + ul.add(li); i++; } - contentTree.addContent(ul); + contentTree.add(ul); } } @@ -192,9 +192,9 @@ protected HtmlTree getTreeHeader() { : bodyTree; addTop(htmlTree); navBar.setUserHeader(getUserHeaderFooter(true)); - htmlTree.addContent(navBar.getContent(true)); + htmlTree.add(navBar.getContent(true)); if (configuration.allowTag(HtmlTag.HEADER)) { - bodyTree.addContent(htmlTree); + bodyTree.add(htmlTree); } return bodyTree; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java index b2f134b0686..d0749622906 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -60,7 +60,7 @@ public Comment(String comment) { * @param content content that needs to be added * @throws UnsupportedOperationException always */ - public void addContent(Content content) { + public void add(Content content) { throw new UnsupportedOperationException(); } @@ -71,7 +71,7 @@ public void addContent(Content content) { * @throws UnsupportedOperationException always */ @Override - public void addContent(CharSequence stringContent) { + public void add(CharSequence stringContent) { throw new UnsupportedOperationException(); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java index f91ebc98631..0ac92d3ccf4 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -43,12 +43,12 @@ public ContentBuilder() { } public ContentBuilder(Content... contents) { for (Content c : contents) { - addContent(c); + add(c); } } @Override - public void addContent(Content content) { + public void add(Content content) { nullCheck(content); ensureMutableContents(); if (content instanceof ContentBuilder) { @@ -58,7 +58,7 @@ public void addContent(Content content) { } @Override - public void addContent(CharSequence text) { + public void add(CharSequence text) { if (text.length() == 0) return; ensureMutableContents(); @@ -69,7 +69,7 @@ public void addContent(CharSequence text) { } else { contents.add(sc = new StringContent()); } - sc.addContent(text); + sc.add(text); } @Override diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java index 358b0d40023..343cf205dbe 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -59,7 +59,7 @@ public FixedStringContent(CharSequence content) { * @throws UnsupportedOperationException always */ @Override - public void addContent(Content content) { + public void add(Content content) { throw new UnsupportedOperationException(); } @@ -71,7 +71,7 @@ public void addContent(Content content) { * @throws UnsupportedOperationException always */ @Override - public void addContent(CharSequence strContent) { + public void add(CharSequence strContent) { throw new UnsupportedOperationException(); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java index 85ee310f0be..b227ef5fb8b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java @@ -259,34 +259,34 @@ public Content toContent() { HtmlTree tree = new HtmlTree(HtmlTag.HEAD); if (showGeneratedBy) { - tree.addContent(getGeneratedBy(showTimestamp, now)); + tree.add(getGeneratedBy(showTimestamp, now)); } - tree.addContent(HtmlTree.TITLE(title)); + tree.add(HtmlTree.TITLE(title)); if (charset != null) { // compatibility; should this be allowed? - tree.addContent(HtmlTree.META("Content-Type", "text/html", charset)); + tree.add(HtmlTree.META("Content-Type", "text/html", charset)); } if (showMetaCreated) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - tree.addContent(HtmlTree.META( + tree.add(HtmlTree.META( (htmlVersion == HtmlVersion.HTML5) ? "dc.created" : "date", dateFormat.format(now))); } for (String k : keywords) { - tree.addContent(HtmlTree.META("keywords", k)); + tree.add(HtmlTree.META("keywords", k)); } for (Content c : extraContent) { - tree.addContent(c); + tree.add(c); } if (canonicalLink != null) { HtmlTree link = new HtmlTree(HtmlTag.LINK); - link.addAttr(HtmlAttr.REL, "canonical"); - link.addAttr(HtmlAttr.HREF, canonicalLink.getPath()); - tree.addContent(link); + link.put(HtmlAttr.REL, "canonical"); + link.put(HtmlAttr.HREF, canonicalLink.getPath()); + tree.add(link); } addStylesheets(tree); @@ -324,13 +324,13 @@ private void addStylesheets(HtmlTree tree) { } private void addStylesheet(HtmlTree tree, DocPath stylesheet) { - tree.addContent(HtmlTree.LINK("stylesheet", "text/css", + tree.add(HtmlTree.LINK("stylesheet", "text/css", pathToRoot.resolve(stylesheet).getPath(), "Style")); } private void addScripts(HtmlTree tree) { if (addDefaultScript) { - tree.addContent(HtmlTree.SCRIPT(pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath())); + tree.add(HtmlTree.SCRIPT(pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath())); } if (index) { if (pathToRoot != null && mainBodyScript != null) { @@ -343,19 +343,19 @@ private void addScripts(HtmlTree tree) { } addJQueryFile(tree, DocPaths.JSZIP_MIN); addJQueryFile(tree, DocPaths.JSZIPUTILS_MIN); - tree.addContent(new RawHtml("")); + tree.add(new RawHtml("")); addJQueryFile(tree, DocPaths.JQUERY_JS); addJQueryFile(tree, DocPaths.JQUERY_UI_JS); } for (Script script : scripts) { - tree.addContent(script.asContent()); + tree.add(script.asContent()); } } private void addJQueryFile(HtmlTree tree, DocPath filePath) { DocPath jqueryFile = pathToRoot.resolve(DocPaths.JQUERY_FILES.resolve(filePath)); - tree.addContent(HtmlTree.SCRIPT(jqueryFile.getPath())); + tree.add(HtmlTree.SCRIPT(jqueryFile.getPath())); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java index 337551dff02..201328a26bd 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -75,7 +75,7 @@ public HtmlTree(HtmlTag tag) { public HtmlTree(HtmlTag tag, Content... contents) { this(tag); for (Content c: contents) - addContent(c); + add(c); } /** @@ -87,7 +87,7 @@ public HtmlTree(HtmlTag tag, Content... contents) { public HtmlTree(HtmlTag tag, List contents) { this(tag); for (Content c: contents) - addContent(c); + add(c); } /** @@ -97,7 +97,7 @@ public HtmlTree(HtmlTag tag, List contents) { * @param attrValue value of the attribute * @return this object */ - public HtmlTree addAttr(HtmlAttr attrName, String attrValue) { + public HtmlTree put(HtmlAttr attrName, String attrValue) { if (attrs.isEmpty()) attrs = new LinkedHashMap<>(3); attrs.put(nullCheck(attrName), escapeHtmlChars(attrValue)); @@ -112,7 +112,7 @@ public HtmlTree addAttr(HtmlAttr attrName, String attrValue) { * @return this object */ public HtmlTree setTitle(Content body) { - addAttr(HtmlAttr.TITLE, stripHtml(body)); + put(HtmlAttr.TITLE, stripHtml(body)); return this; } @@ -123,7 +123,7 @@ public HtmlTree setTitle(Content body) { * @return this object */ public HtmlTree setRole(Role role) { - addAttr(HtmlAttr.ROLE, role.toString()); + put(HtmlAttr.ROLE, role.toString()); return this; } @@ -134,7 +134,7 @@ public HtmlTree setRole(Role role) { * @return this object */ public HtmlTree setStyle(HtmlStyle style) { - addAttr(HtmlAttr.CLASS, style.toString()); + put(HtmlAttr.CLASS, style.toString()); return this; } @@ -144,10 +144,10 @@ public HtmlTree setStyle(HtmlStyle style) { * @param tagContent tag content to be added */ @Override - public void addContent(Content tagContent) { + public void add(Content tagContent) { if (tagContent instanceof ContentBuilder) { for (Content c: ((ContentBuilder)tagContent).contents) { - addContent(c); + add(c); } } else if (tagContent == HtmlTree.EMPTY || tagContent.isValid()) { @@ -165,16 +165,16 @@ else if (tagContent == HtmlTree.EMPTY || tagContent.isValid()) { * @param stringContent string content that needs to be added */ @Override - public void addContent(CharSequence stringContent) { + public void add(CharSequence stringContent) { if (!content.isEmpty()) { Content lastContent = content.get(content.size() - 1); if (lastContent instanceof StringContent) - lastContent.addContent(stringContent); + lastContent.add(stringContent); else - addContent(new StringContent(stringContent)); + add(new StringContent(stringContent)); } else - addContent(new StringContent(stringContent)); + add(new StringContent(stringContent)); } /** @@ -294,7 +294,7 @@ public static String encodeURL(String url) { */ public static HtmlTree A(String ref, Content body) { HtmlTree htmltree = new HtmlTree(HtmlTag.A, nullCheck(body)); - htmltree.addAttr(HtmlAttr.HREF, encodeURL(ref)); + htmltree.put(HtmlAttr.HREF, encodeURL(ref)); return htmltree; } @@ -308,11 +308,11 @@ public static HtmlTree A(String ref, Content body) { */ public static HtmlTree A(HtmlVersion htmlVersion, String attr, Content body) { HtmlTree htmltree = new HtmlTree(HtmlTag.A); - htmltree.addAttr((htmlVersion == HtmlVersion.HTML4) + htmltree.put((htmlVersion == HtmlVersion.HTML4) ? HtmlAttr.NAME : HtmlAttr.ID, nullCheck(attr)); - htmltree.addContent(nullCheck(body)); + htmltree.add(nullCheck(body)); return htmltree; } @@ -325,8 +325,8 @@ public static HtmlTree A(HtmlVersion htmlVersion, String attr, Content body) { */ public static HtmlTree A_ID(String id, Content body) { HtmlTree htmltree = new HtmlTree(HtmlTag.A); - htmltree.addAttr(HtmlAttr.ID, nullCheck(id)); - htmltree.addContent(nullCheck(body)); + htmltree.put(HtmlAttr.ID, nullCheck(id)); + htmltree.add(nullCheck(body)); return htmltree; } @@ -515,7 +515,7 @@ public static HtmlTree HEADING(HtmlTag headingTag, Content body) { */ public static HtmlTree HTML(String lang, Content head, Content body) { HtmlTree htmltree = new HtmlTree(HtmlTag.HTML, nullCheck(head), nullCheck(body)); - htmltree.addAttr(HtmlAttr.LANG, nullCheck(lang)); + htmltree.put(HtmlAttr.LANG, nullCheck(lang)); return htmltree; } @@ -529,9 +529,9 @@ public static HtmlTree HTML(String lang, Content head, Content body) { */ public static HtmlTree IFRAME(String src, String name, String title) { HtmlTree htmltree = new HtmlTree(HtmlTag.IFRAME); - htmltree.addAttr(HtmlAttr.SRC, nullCheck(src)); - htmltree.addAttr(HtmlAttr.NAME, nullCheck(name)); - htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title)); + htmltree.put(HtmlAttr.SRC, nullCheck(src)); + htmltree.put(HtmlAttr.NAME, nullCheck(name)); + htmltree.put(HtmlAttr.TITLE, nullCheck(title)); return htmltree; } @@ -545,10 +545,10 @@ public static HtmlTree IFRAME(String src, String name, String title) { */ public static HtmlTree INPUT(String type, String id, String value) { HtmlTree htmltree = new HtmlTree(HtmlTag.INPUT); - htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type)); - htmltree.addAttr(HtmlAttr.ID, nullCheck(id)); - htmltree.addAttr(HtmlAttr.VALUE, nullCheck(value)); - htmltree.addAttr(HtmlAttr.DISABLED, "disabled"); + htmltree.put(HtmlAttr.TYPE, nullCheck(type)); + htmltree.put(HtmlAttr.ID, nullCheck(id)); + htmltree.put(HtmlAttr.VALUE, nullCheck(value)); + htmltree.put(HtmlAttr.DISABLED, "disabled"); return htmltree; } @@ -561,7 +561,7 @@ public static HtmlTree INPUT(String type, String id, String value) { */ public static HtmlTree LABEL(String forLabel, Content body) { HtmlTree htmltree = new HtmlTree(HtmlTag.LABEL, nullCheck(body)); - htmltree.addAttr(HtmlAttr.FOR, nullCheck(forLabel)); + htmltree.put(HtmlAttr.FOR, nullCheck(forLabel)); return htmltree; } @@ -600,10 +600,10 @@ public static HtmlTree LI(HtmlStyle styleClass, Content body) { */ public static HtmlTree LINK(String rel, String type, String href, String title) { HtmlTree htmltree = new HtmlTree(HtmlTag.LINK); - htmltree.addAttr(HtmlAttr.REL, nullCheck(rel)); - htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type)); - htmltree.addAttr(HtmlAttr.HREF, nullCheck(href)); - htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title)); + htmltree.put(HtmlAttr.REL, nullCheck(rel)); + htmltree.put(HtmlAttr.TYPE, nullCheck(type)); + htmltree.put(HtmlAttr.HREF, nullCheck(href)); + htmltree.put(HtmlAttr.TITLE, nullCheck(title)); return htmltree; } @@ -656,8 +656,8 @@ public static HtmlTree MAIN(HtmlStyle styleClass, Content body) { public static HtmlTree META(String httpEquiv, String content, String charSet) { HtmlTree htmltree = new HtmlTree(HtmlTag.META); String contentCharset = content + "; charset=" + charSet; - htmltree.addAttr(HtmlAttr.HTTP_EQUIV, nullCheck(httpEquiv)); - htmltree.addAttr(HtmlAttr.CONTENT, contentCharset); + htmltree.put(HtmlAttr.HTTP_EQUIV, nullCheck(httpEquiv)); + htmltree.put(HtmlAttr.CONTENT, contentCharset); return htmltree; } @@ -670,8 +670,8 @@ public static HtmlTree META(String httpEquiv, String content, String charSet) { */ public static HtmlTree META(String name, String content) { HtmlTree htmltree = new HtmlTree(HtmlTag.META); - htmltree.addAttr(HtmlAttr.NAME, nullCheck(name)); - htmltree.addAttr(HtmlAttr.CONTENT, nullCheck(content)); + htmltree.put(HtmlAttr.NAME, nullCheck(name)); + htmltree.put(HtmlAttr.CONTENT, nullCheck(content)); return htmltree; } @@ -729,8 +729,8 @@ public static HtmlTree P(HtmlStyle styleClass, Content body) { */ public static HtmlTree SCRIPT(String src) { HtmlTree htmltree = new HtmlTree(HtmlTag.SCRIPT); - htmltree.addAttr(HtmlAttr.TYPE, "text/javascript"); - htmltree.addAttr(HtmlAttr.SRC, nullCheck(src)); + htmltree.put(HtmlAttr.TYPE, "text/javascript"); + htmltree.put(HtmlAttr.SRC, nullCheck(src)); return htmltree; } @@ -799,7 +799,7 @@ public static HtmlTree SPAN(HtmlStyle styleClass, Content body) { */ public static HtmlTree SPAN(String id, HtmlStyle styleClass, Content body) { HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body)); - htmltree.addAttr(HtmlAttr.ID, nullCheck(id)); + htmltree.put(HtmlAttr.ID, nullCheck(id)); if (styleClass != null) htmltree.setStyle(styleClass); return htmltree; @@ -817,7 +817,7 @@ public static HtmlTree TABLE(HtmlStyle styleClass, String summary, Content body) HtmlTree htmltree = new HtmlTree(HtmlTag.TABLE, nullCheck(body)); if (styleClass != null) htmltree.setStyle(styleClass); - htmltree.addAttr(HtmlAttr.SUMMARY, nullCheck(summary)); + htmltree.put(HtmlAttr.SUMMARY, nullCheck(summary)); return htmltree; } @@ -872,7 +872,7 @@ public static HtmlTree TH(HtmlStyle styleClass, String scope, Content body) { HtmlTree htmltree = new HtmlTree(HtmlTag.TH, nullCheck(body)); if (styleClass != null) htmltree.setStyle(styleClass); - htmltree.addAttr(HtmlAttr.SCOPE, nullCheck(scope)); + htmltree.put(HtmlAttr.SCOPE, nullCheck(scope)); return htmltree; } @@ -930,9 +930,9 @@ public static HtmlTree TR(Content body) { */ public static HtmlTree UL(HtmlStyle styleClass, Content first, Content... more) { HtmlTree htmlTree = new HtmlTree(HtmlTag.UL); - htmlTree.addContent(nullCheck(first)); + htmlTree.add(nullCheck(first)); for (Content c : more) { - htmlTree.addContent(nullCheck(c)); + htmlTree.add(nullCheck(c)); } htmlTree.setStyle(nullCheck(styleClass)); return htmlTree; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Links.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Links.java index 5fa8157a121..d1f73969a25 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Links.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Links.java @@ -241,10 +241,10 @@ public Content createLink(DocLink link, Content label) { public Content createLink(DocLink link, Content label, String title, String target) { HtmlTree anchor = HtmlTree.A(link.relativizeAgainst(file).toString(), label); if (title != null && title.length() != 0) { - anchor.addAttr(HtmlAttr.TITLE, title); + anchor.put(HtmlAttr.TITLE, title); } if (target != null && target.length() != 0) { - anchor.addAttr(HtmlAttr.TARGET, target); + anchor.put(HtmlAttr.TARGET, target); } return anchor; } @@ -287,10 +287,10 @@ public Content createLink(DocLink link, Content label, boolean strong, } HtmlTree l = HtmlTree.A(link.relativizeAgainst(file).toString(), body); if (title != null && title.length() != 0) { - l.addAttr(HtmlAttr.TITLE, title); + l.put(HtmlAttr.TITLE, title); } if (target != null && target.length() != 0) { - l.addAttr(HtmlAttr.TARGET, target); + l.put(HtmlAttr.TARGET, target); } if (isExternal) { l.setStyle(HtmlStyle.externalLink); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java index 79b588b7a0d..28ca848db23 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Navigation.java @@ -448,8 +448,8 @@ private void addSummaryLinks(Content tree) { } if (!listContents.isEmpty()) { Content li = HtmlTree.LI(contents.summaryLabel); - li.addContent(Contents.SPACE); - tree.addContent(li); + li.add(Contents.SPACE); + tree.add(li); addListToNav(listContents, tree); } break; @@ -480,8 +480,8 @@ private void addSummaryLinks(Content tree) { } if (!listContents.isEmpty()) { Content li = HtmlTree.LI(contents.moduleSubNavLabel); - li.addContent(Contents.SPACE); - tree.addContent(li); + li.add(Contents.SPACE); + tree.add(li); addListToNav(listContents, tree); } break; @@ -684,8 +684,8 @@ private void addDetailLinks(Content tree) { } if (!listContents.isEmpty()) { Content li = HtmlTree.LI(contents.detailLabel); - li.addContent(Contents.SPACE); - tree.addContent(li); + li.add(Contents.SPACE); + tree.add(li); addListToNav(listContents, tree); } break; @@ -813,37 +813,37 @@ private void addContentToList(List listContents, Content tree) { } private void addContentToTree(Content tree, Content content) { - tree.addContent(HtmlTree.LI(content)); + tree.add(HtmlTree.LI(content)); } private void addListToNav(List listContents, Content tree) { int count = 0; for (Content liContent : listContents) { if (count < listContents.size() - 1) { - liContent.addContent(Contents.SPACE); - liContent.addContent("|"); - liContent.addContent(Contents.SPACE); + liContent.add(Contents.SPACE); + liContent.add("|"); + liContent.add(Contents.SPACE); } - tree.addContent(liContent); + tree.add(liContent); count++; } } private void addActivePageLink(Content tree, Content label, boolean display) { if (display) { - tree.addContent(HtmlTree.LI(HtmlStyle.navBarCell1Rev, label)); + tree.add(HtmlTree.LI(HtmlStyle.navBarCell1Rev, label)); } } private void addPageLabel(Content tree, Content label, boolean display) { if (display) { - tree.addContent(HtmlTree.LI(label)); + tree.add(HtmlTree.LI(label)); } } private void addOverviewLink(Content tree) { if (configuration.createoverview) { - tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.overviewSummary(configuration.frames)), + tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.overviewSummary(configuration.frames)), contents.overviewLabel, "", ""))); } } @@ -853,7 +853,7 @@ private void addModuleLink(Content tree) { if (configuration.modules.size() == 1) { ModuleElement mdle = configuration.modules.first(); boolean included = configuration.utils.isIncluded(mdle); - tree.addContent(HtmlTree.LI((included) + tree.add(HtmlTree.LI((included) ? links.createLink(pathToRoot.resolve(configuration.docPaths.moduleSummary(mdle)), contents.moduleLabel, "", "") : contents.moduleLabel)); } else if (!configuration.modules.isEmpty()) { @@ -864,7 +864,7 @@ private void addModuleLink(Content tree) { private void addModuleOfElementLink(Content tree) { if (configuration.showModules) { - tree.addContent(HtmlTree.LI(navLinkModule)); + tree.add(HtmlTree.LI(navLinkModule)); } } @@ -881,16 +881,16 @@ private void addPackageLink(Content tree) { } } if (included || packageElement == null) { - tree.addContent(HtmlTree.LI(links.createLink( + tree.add(HtmlTree.LI(links.createLink( pathToRoot.resolve(configuration.docPaths.forPackage(packageElement).resolve(DocPaths.PACKAGE_SUMMARY)), contents.packageLabel))); } else { DocLink crossPkgLink = configuration.extern.getExternalLink( packageElement, pathToRoot, DocPaths.PACKAGE_SUMMARY.getPath()); if (crossPkgLink != null) { - tree.addContent(HtmlTree.LI(links.createLink(crossPkgLink, contents.packageLabel))); + tree.add(HtmlTree.LI(links.createLink(crossPkgLink, contents.packageLabel))); } else { - tree.addContent(HtmlTree.LI(contents.packageLabel)); + tree.add(HtmlTree.LI(contents.packageLabel)); } } } else if (!configuration.packages.isEmpty()) { @@ -899,12 +899,12 @@ private void addPackageLink(Content tree) { } private void addPackageOfElementLink(Content tree) { - tree.addContent(HtmlTree.LI(links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), + tree.add(HtmlTree.LI(links.createLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), contents.packageLabel))); } private void addPackageSummaryLink(Content tree) { - tree.addContent(HtmlTree.LI(links.createLink(DocPaths.PACKAGE_SUMMARY, contents.packageLabel))); + tree.add(HtmlTree.LI(links.createLink(DocPaths.PACKAGE_SUMMARY, contents.packageLabel))); } private void addTreeLink(Content tree) { @@ -913,20 +913,20 @@ private void addTreeLink(Content tree) { DocPath docPath = packages.size() == 1 && configuration.getSpecifiedTypeElements().isEmpty() ? pathToRoot.resolve(configuration.docPaths.forPackage(packages.get(0)).resolve(DocPaths.PACKAGE_TREE)) : pathToRoot.resolve(DocPaths.OVERVIEW_TREE); - tree.addContent(HtmlTree.LI(links.createLink(docPath, contents.treeLabel, "", ""))); + tree.add(HtmlTree.LI(links.createLink(docPath, contents.treeLabel, "", ""))); } } private void addDeprecatedLink(Content tree) { if (!(configuration.nodeprecated || configuration.nodeprecatedlist)) { - tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST), + tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST), contents.deprecatedLabel, "", ""))); } } private void addIndexLink(Content tree) { if (configuration.createindex) { - tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve( + tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve( (configuration.splitindex ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)) : DocPaths.INDEX_ALL)), @@ -944,7 +944,7 @@ private void addHelpLink(Content tree) { DocFile file = DocFile.createFileForInput(configuration, helpfile); helpfilenm = DocPath.create(file.getName()); } - tree.addContent(HtmlTree.LI(links.createLink(pathToRoot.resolve(helpfilenm), + tree.add(HtmlTree.LI(links.createLink(pathToRoot.resolve(helpfilenm), contents.helpLabel, "", ""))); } } @@ -957,7 +957,7 @@ private void addHelpLink(Content tree) { private void addNavShowLists(Content tree) { DocLink dl = new DocLink(pathToRoot.resolve(DocPaths.INDEX), path.getPath(), null); Content framesContent = links.createLink(dl, contents.framesLabel, "", "_top"); - tree.addContent(HtmlTree.LI(framesContent)); + tree.add(HtmlTree.LI(framesContent)); } /** @@ -967,14 +967,14 @@ private void addNavShowLists(Content tree) { */ private void addNavHideLists(Content tree) { Content noFramesContent = links.createLink(path.basename(), contents.noFramesLabel, "", "_top"); - tree.addContent(HtmlTree.LI(noFramesContent)); + tree.add(HtmlTree.LI(noFramesContent)); } private void addNavLinkClassIndex(Content tree) { Content allClassesContent = links.createLink(pathToRoot.resolve( DocPaths.AllClasses(configuration.frames)), contents.allClassesLabel, "", ""); - tree.addContent(HtmlTree.LI(allClassesContent)); + tree.add(HtmlTree.LI(allClassesContent)); } private void addSearch(Content tree) { @@ -983,10 +983,10 @@ private void addSearch(Content tree) { HtmlTree inputText = HtmlTree.INPUT("text", searchValueId, searchValueId); HtmlTree inputReset = HtmlTree.INPUT(reset, reset, reset); HtmlTree liInput = HtmlTree.LI(HtmlTree.LABEL(searchValueId, searchLabel)); - liInput.addContent(inputText); - liInput.addContent(inputReset); + liInput.add(inputText); + liInput.add(inputReset); HtmlTree ulSearch = HtmlTree.UL(HtmlStyle.navListSearch, liInput); - tree.addContent(ulSearch); + tree.add(ulSearch); } private void addAllClassesLinkScript(Content tree, boolean top) { @@ -995,12 +995,12 @@ private void addAllClassesLinkScript(Content tree, boolean top) { : Position.BOTTOM.allClassesLinkScript().asContent()); Content div_noscript = HtmlTree.DIV(contents.noScriptMessage); Content noScript = HtmlTree.NOSCRIPT(div_noscript); - div.addContent(noScript); - tree.addContent(div); + div.add(noScript); + tree.add(div); } private void addFixedNavScript(Content tree) { - tree.addContent(FIXED_NAV_SCRIPT.asContent()); + tree.add(FIXED_NAV_SCRIPT.asContent()); } /** @@ -1019,29 +1019,29 @@ public Content getContent(boolean top) { HtmlTree navDiv = new HtmlTree(HtmlTag.DIV); if (top) { queue = topBottomNavContents.get(Position.TOP); - fixedNavDiv.addContent(Position.TOP.startOfNav()); + fixedNavDiv.add(Position.TOP.startOfNav()); navDiv.setStyle(HtmlStyle.topNav); } else { queue = topBottomNavContents.get(Position.BOTTOM); - tree.addContent(Position.BOTTOM.startOfNav()); + tree.add(Position.BOTTOM.startOfNav()); navDiv.setStyle(HtmlStyle.bottomNav); } - navDiv.addContent(queue.poll()); + navDiv.add(queue.poll()); HtmlTree skipLinkDiv = HtmlTree.DIV(HtmlStyle.skipNav, queue.poll()); - navDiv.addContent(skipLinkDiv); - navDiv.addContent(queue.poll()); + navDiv.add(skipLinkDiv); + navDiv.add(queue.poll()); HtmlTree navList = new HtmlTree(HtmlTag.UL); navList.setStyle(HtmlStyle.navList); - navList.addAttr(HtmlAttr.TITLE, rowListTitle); + navList.put(HtmlAttr.TITLE, rowListTitle); fixedNavDiv.setStyle(HtmlStyle.fixedNav); addMainNavLinks(navList); - navDiv.addContent(navList); + navDiv.add(navList); Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, top ? userHeader : userFooter); - navDiv.addContent(aboutDiv); + navDiv.add(aboutDiv); if (top) { - fixedNavDiv.addContent(navDiv); + fixedNavDiv.add(navDiv); } else { - tree.addContent(navDiv); + tree.add(navDiv); } HtmlTree subDiv = new HtmlTree(HtmlTag.DIV); subDiv.setStyle(HtmlStyle.subNav); @@ -1053,14 +1053,14 @@ public Content getContent(boolean top) { addNavHideLists(ulFrames); } } - subDiv.addContent(ulFrames); + subDiv.add(ulFrames); HtmlTree ulAllClasses = new HtmlTree(HtmlTag.UL); ulAllClasses.setStyle(HtmlStyle.navList); - ulAllClasses.addAttr(HtmlAttr.ID, top + ulAllClasses.put(HtmlAttr.ID, top ? Position.TOP.allClassesLinkId() : Position.BOTTOM.allClassesLinkId()); addNavLinkClassIndex(ulAllClasses); - subDiv.addContent(ulAllClasses); + subDiv.add(ulAllClasses); if (top && configuration.createindex) { addSearch(subDiv); } @@ -1070,24 +1070,24 @@ public Content getContent(boolean top) { HtmlTree ulNavSummary = new HtmlTree(HtmlTag.UL); ulNavSummary.setStyle(HtmlStyle.subNavList); addSummaryLinks(ulNavSummary); - div.addContent(ulNavSummary); + div.add(ulNavSummary); // Add the detail links if present. HtmlTree ulNavDetail = new HtmlTree(HtmlTag.UL); ulNavDetail.setStyle(HtmlStyle.subNavList); addDetailLinks(ulNavDetail); - div.addContent(ulNavDetail); - subDiv.addContent(div); - subDiv.addContent(queue.poll()); + div.add(ulNavDetail); + subDiv.add(div); + subDiv.add(queue.poll()); if (top) { - fixedNavDiv.addContent(subDiv); - fixedNavDiv.addContent(Position.TOP.endOfNav()); - tree.addContent(fixedNavDiv); + fixedNavDiv.add(subDiv); + fixedNavDiv.add(Position.TOP.endOfNav()); + tree.add(fixedNavDiv); HtmlTree paddingDiv = HtmlTree.DIV(HtmlStyle.navPadding, Contents.SPACE); - tree.addContent(paddingDiv); + tree.add(paddingDiv); addFixedNavScript(tree); } else { - tree.addContent(subDiv); - tree.addContent(Position.BOTTOM.endOfNav()); + tree.add(subDiv); + tree.add(Position.BOTTOM.endOfNav()); } return tree; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java index a374531f722..afb00f34a6a 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -64,7 +64,7 @@ public RawHtml(CharSequence rawHtml) { * @param content content that needs to be added * @throws UnsupportedOperationException always */ - public void addContent(Content content) { + public void add(Content content) { throw new UnsupportedOperationException(); } @@ -75,7 +75,7 @@ public void addContent(Content content) { * @throws UnsupportedOperationException always */ @Override - public void addContent(CharSequence stringContent) { + public void add(CharSequence stringContent) { throw new UnsupportedOperationException(); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Script.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Script.java index 2656fa11502..9ac61660cd8 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Script.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Script.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -108,19 +108,19 @@ public Content asContent() { ScriptContent scriptContent = new ScriptContent(sb); HtmlTree tree = new HtmlTree(HtmlTag.SCRIPT) { @Override - public void addContent(CharSequence s) { + public void add(CharSequence s) { throw new UnsupportedOperationException(); } @Override - public void addContent(Content c) { + public void add(Content c) { if (c != scriptContent) { throw new IllegalArgumentException(); } - super.addContent(scriptContent); + super.add(scriptContent); } }; - tree.addAttr(HtmlAttr.TYPE, "text/javascript"); - tree.addContent(scriptContent); + tree.put(HtmlAttr.TYPE, "text/javascript"); + tree.add(scriptContent); return tree; } @@ -200,12 +200,12 @@ private static class ScriptContent extends Content { } @Override - public void addContent(Content content) { + public void add(Content content) { throw new UnsupportedOperationException(); } @Override - public void addContent(CharSequence code) { + public void add(CharSequence code) { sb.append(code); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java index 912e876bc13..e8c3ed162c5 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -69,7 +69,7 @@ public StringContent(CharSequence initialContent) { * @throws UnsupportedOperationException always */ @Override - public void addContent(Content content) { + public void add(Content content) { throw new UnsupportedOperationException(); } @@ -80,7 +80,7 @@ public void addContent(Content content) { * @param strContent string content to be added */ @Override - public void addContent(CharSequence strContent) { + public void add(CharSequence strContent) { appendChars(strContent); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java index 3f11974f03c..e17937303aa 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -40,7 +40,6 @@ import jdk.javadoc.internal.doclets.formats.html.Contents; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; /** * A builder for HTML tables, such as the summary tables for various @@ -401,12 +400,12 @@ public void addRow(Element element, List contents) { if (putIdFirst && tabMap != null) { int index = bodyRows.size(); - row.addAttr(HtmlAttr.ID, (rowIdPrefix + index)); + row.put(HtmlAttr.ID, (rowIdPrefix + index)); } if (stripedStyles != null) { int rowIndex = bodyRows.size(); - row.addAttr(HtmlAttr.CLASS, stripedStyles.get(rowIndex % 2).name()); + row.put(HtmlAttr.CLASS, stripedStyles.get(rowIndex % 2).name()); } int colIndex = 0; for (Content c : contents) { @@ -416,7 +415,7 @@ public void addRow(Element element, List contents) { HtmlTree cell = (colIndex == rowScopeColumnIndex) ? HtmlTree.TH(cellStyle, "row", c) : HtmlTree.TD(cellStyle, c); - row.addContent(cell); + row.add(cell); colIndex++; } bodyRows.add(row); @@ -424,7 +423,7 @@ public void addRow(Element element, List contents) { if (tabMap != null) { if (!putIdFirst) { int index = bodyRows.size() - 1; - row.addAttr(HtmlAttr.ID, (rowIdPrefix + index)); + row.put(HtmlAttr.ID, (rowIdPrefix + index)); } int mask = 0; int maskBit = 1; @@ -460,21 +459,21 @@ public Content toContent() { HtmlTree table = new HtmlTree(HtmlTag.TABLE); table.setStyle(tableStyle); if (summary != null) { - table.addAttr(HtmlAttr.SUMMARY, summary); + table.put(HtmlAttr.SUMMARY, summary); } if (tabMap != null) { if (tabs.size() == 1) { String tabName = tabs.iterator().next(); - table.addContent(getCaption(new StringContent(tabName))); + table.add(getCaption(new StringContent(tabName))); } else { ContentBuilder cb = new ContentBuilder(); int tabIndex = 0; HtmlTree defaultTabSpan = new HtmlTree(HtmlTag.SPAN, HtmlTree.SPAN(new StringContent(defaultTab)), HtmlTree.SPAN(tabEnd, Contents.SPACE)) - .addAttr(HtmlAttr.ID, tabId.apply(tabIndex)) + .put(HtmlAttr.ID, tabId.apply(tabIndex)) .setStyle(activeTabStyle); - cb.addContent(defaultTabSpan); + cb.add(defaultTabSpan); for (String tabName : tabMap.keySet()) { tabIndex++; if (tabs.contains(tabName)) { @@ -482,23 +481,23 @@ public Content toContent() { HtmlTree link = HtmlTree.A(script, new StringContent(tabName)); HtmlTree tabSpan = new HtmlTree(HtmlTag.SPAN, HtmlTree.SPAN(link), HtmlTree.SPAN(tabEnd, Contents.SPACE)) - .addAttr(HtmlAttr.ID, tabId.apply(tabIndex)) + .put(HtmlAttr.ID, tabId.apply(tabIndex)) .setStyle(tabStyle); - cb.addContent(tabSpan); + cb.add(tabSpan); } } - table.addContent(HtmlTree.CAPTION(cb)); + table.add(HtmlTree.CAPTION(cb)); } } else { - table.addContent(caption); + table.add(caption); } - table.addContent(header.toContent()); + table.add(header.toContent()); if (useTBody) { Content tbody = new HtmlTree(HtmlTag.TBODY); - bodyRows.forEach(row -> tbody.addContent(row)); - table.addContent(tbody); + bodyRows.forEach(row -> tbody.add(row)); + table.add(tbody); } else { - bodyRows.forEach(row -> table.addContent(row)); + bodyRows.forEach(row -> table.add(row)); } return table; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/TableHeader.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/TableHeader.java index 7ce8f0fd25d..6fb9923604e 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/TableHeader.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/TableHeader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -127,7 +127,7 @@ public Content toContent() { : (i == 1) ? HtmlStyle.colSecond : null; Content cell = (style == null) ? HtmlTree.TH(scope, cellContent) : HtmlTree.TH(style, scope, cellContent); - tr.addContent(cell); + tr.add(cell); i++; } return tr; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java index 1544076bd7a..d69c82c6cc8 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -64,14 +64,14 @@ public String toString() { * * @param content content that needs to be added */ - public abstract void addContent(Content content); + public abstract void add(Content content); /** * Adds a string content to the existing content. * * @param stringContent the string content to be added */ - public abstract void addContent(CharSequence stringContent); + public abstract void add(CharSequence stringContent); /** * Writes content to a writer. diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java index 15d8628c9b7..c9b1c60b99d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -156,7 +156,7 @@ protected void buildAnnotationTypeInfo(Content annotationContentTree) buildAnnotationTypeDescription(annotationInfoTree); buildAnnotationTypeTagInfo(annotationInfoTree); - annotationContentTree.addContent(writer.getAnnotationInfo(annotationInfoTree)); + annotationContentTree.add(writer.getAnnotationInfo(annotationInfoTree)); } /** @@ -205,7 +205,7 @@ protected void buildAnnotationTypeTagInfo(Content annotationInfoTree) { protected void buildMemberSummary(Content annotationContentTree) throws DocletException { Content memberSummaryTree = writer.getMemberTreeHeader(); builderFactory.getMemberSummaryBuilder(writer).build(memberSummaryTree); - annotationContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree)); + annotationContentTree.add(writer.getMemberSummaryTree(memberSummaryTree)); } /** @@ -223,7 +223,7 @@ protected void buildAnnotationTypeMemberDetails(Content annotationContentTree) buildAnnotationTypeOptionalMemberDetails(memberDetailsTree); if (memberDetailsTree.isValid()) { - annotationContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree)); + annotationContentTree.add(writer.getMemberDetailsTree(memberDetailsTree)); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java index 8e69ca00b0c..0c79b37b582 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -153,9 +153,9 @@ protected void buildAnnotationTypeMember(Content memberDetailsTree) buildMemberComments(annotationDocTree); buildTagInfo(annotationDocTree); - detailsTree.addContent(writer.getAnnotationDoc( + detailsTree.add(writer.getAnnotationDoc( annotationDocTree, currentMember == lastElement)); - memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree)); + memberDetailsTree.add(writer.getAnnotationDetails(detailsTree)); } } } @@ -166,7 +166,7 @@ protected void buildAnnotationTypeMember(Content memberDetailsTree) * @param annotationDocTree the content tree to which the documentation will be added */ protected void buildSignature(Content annotationDocTree) { - annotationDocTree.addContent( + annotationDocTree.add( writer.getSignature(currentMember)); } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java index f87090339e1..d64362d6000 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -152,9 +152,9 @@ protected void buildAnnotationTypeMember(Content memberDetailsTree) buildAnnotationTypeMemberChildren(annotationDocTree); - detailsTree.addContent(writer.getAnnotationDoc( + detailsTree.add(writer.getAnnotationDoc( annotationDocTree, currentMember == lastMember)); - memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree)); + memberDetailsTree.add(writer.getAnnotationDetails(detailsTree)); } } } @@ -172,7 +172,7 @@ protected void buildAnnotationTypeMemberChildren(Content annotationDocTree) { * @param annotationDocTree the content tree to which the documentation will be added */ protected void buildSignature(Content annotationDocTree) { - annotationDocTree.addContent(writer.getSignature(currentMember)); + annotationDocTree.add(writer.getSignature(currentMember)); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java index 0af3d5d1fe9..32fa3df4788 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -181,7 +181,7 @@ protected void buildClassInfo(Content classContentTree) throws DocletException { buildClassDescription(classInfoTree); buildClassTagInfo(classInfoTree); - classContentTree.addContent(writer.getClassInfo(classInfoTree)); + classContentTree.add(writer.getClassInfo(classInfoTree)); } /** @@ -322,7 +322,7 @@ protected void buildClassTagInfo(Content classInfoTree) { protected void buildMemberSummary(Content classContentTree) throws DocletException { Content memberSummaryTree = writer.getMemberTreeHeader(); builderFactory.getMemberSummaryBuilder(writer).build(memberSummaryTree); - classContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree)); + classContentTree.add(writer.getMemberSummaryTree(memberSummaryTree)); } /** @@ -340,7 +340,7 @@ protected void buildMemberDetails(Content classContentTree) throws DocletExcepti buildConstructorDetails(memberDetailsTree); buildMethodDetails(memberDetailsTree); - classContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree)); + classContentTree.add(writer.getMemberDetailsTree(memberDetailsTree)); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java index 73a18e3c54a..ef4f3c66186 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -148,10 +148,10 @@ protected void buildConstructorDoc(Content memberDetailsTree) throws DocletExcep buildConstructorComments(constructorDocTree); buildTagInfo(constructorDocTree); - constructorDetailsTree.addContent(writer.getConstructorDoc(constructorDocTree, + constructorDetailsTree.add(writer.getConstructorDoc(constructorDocTree, currentConstructor == lastElement)); } - memberDetailsTree.addContent( + memberDetailsTree.add( writer.getConstructorDetails(constructorDetailsTree)); } } @@ -162,7 +162,7 @@ protected void buildConstructorDoc(Content memberDetailsTree) throws DocletExcep * @param constructorDocTree the content tree to which the documentation will be added */ protected void buildSignature(Content constructorDocTree) { - constructorDocTree.addContent(writer.getSignature(currentConstructor)); + constructorDocTree.add(writer.getSignature(currentConstructor)); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java index 11241855a63..0bc384c40b6 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -136,10 +136,10 @@ protected void buildEnumConstant(Content memberDetailsTree) throws DocletExcepti buildEnumConstantComments(enumConstantsTree); buildTagInfo(enumConstantsTree); - enumConstantsDetailsTree.addContent(writer.getEnumConstants( + enumConstantsDetailsTree.add(writer.getEnumConstants( enumConstantsTree, currentElement == lastElement)); } - memberDetailsTree.addContent( + memberDetailsTree.add( writer.getEnumConstantsDetails(enumConstantsDetailsTree)); } } @@ -150,7 +150,7 @@ protected void buildEnumConstant(Content memberDetailsTree) throws DocletExcepti * @param enumConstantsTree the content tree to which the documentation will be added */ protected void buildSignature(Content enumConstantsTree) { - enumConstantsTree.addContent(writer.getSignature(currentElement)); + enumConstantsTree.add(writer.getSignature(currentElement)); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java index 5e98252c001..700f41f3b68 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -137,10 +137,10 @@ protected void buildFieldDoc(Content memberDetailsTree) throws DocletException { buildFieldComments(fieldDocTree); buildTagInfo(fieldDocTree); - fieldDetailsTree.addContent(writer.getFieldDoc( + fieldDetailsTree.add(writer.getFieldDoc( fieldDocTree, currentElement == lastElement)); } - memberDetailsTree.addContent( + memberDetailsTree.add( writer.getFieldDetails(fieldDetailsTree)); } } @@ -151,7 +151,7 @@ protected void buildFieldDoc(Content memberDetailsTree) throws DocletException { * @param fieldDocTree the content tree to which the documentation will be added */ protected void buildSignature(Content fieldDocTree) { - fieldDocTree.addContent(writer.getSignature(currentElement)); + fieldDocTree.add(writer.getSignature(currentElement)); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java index c9e11c461d8..737871615e9 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -464,7 +464,7 @@ private void buildInheritedSummary(MemberSummaryWriter writer, Content inheritedTree = writer.getInheritedSummaryHeader(inheritedClass); Content linksTree = writer.getInheritedSummaryLinksTree(); addSummaryFootNote(inheritedClass, inheritedMembers, linksTree, writer); - inheritedTree.addContent(linksTree); + inheritedTree.add(linksTree); summaryTreeList.add(writer.getMemberTree(inheritedTree)); } } @@ -497,7 +497,7 @@ private void addSummary(MemberSummaryWriter writer, buildInheritedSummary(writer, kind, summaryTreeList); if (!summaryTreeList.isEmpty()) { Content memberTree = writer.getMemberSummaryHeader(typeElement, memberSummaryTree); - summaryTreeList.stream().forEach(memberTree::addContent); + summaryTreeList.stream().forEach(memberTree::add); writer.addMemberTree(memberSummaryTree, memberTree); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java index 0f72dd671f7..b774aff6884 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -139,10 +139,10 @@ protected void buildMethodDoc(Content memberDetailsTree) throws DocletException buildMethodComments(methodDocTree); buildTagInfo(methodDocTree); - methodDetailsTree.addContent(writer.getMethodDoc( + methodDetailsTree.add(writer.getMethodDoc( methodDocTree, currentMethod == lastElement)); } - memberDetailsTree.addContent(writer.getMethodDetails(methodDetailsTree)); + memberDetailsTree.add(writer.getMethodDetails(methodDetailsTree)); } } @@ -152,7 +152,7 @@ protected void buildMethodDoc(Content memberDetailsTree) throws DocletException * @param methodDocTree the content tree to which the documentation will be added */ protected void buildSignature(Content methodDocTree) { - methodDocTree.addContent(writer.getSignature(currentMethod)); + methodDocTree.add(writer.getSignature(currentMethod)); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java index 97e6d77ca1c..2ff5055d937 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -152,7 +152,7 @@ protected void buildSummary(Content moduleContentTree) throws DocletException { buildModulesSummary(summaryContentTree); buildServicesSummary(summaryContentTree); - moduleContentTree.addContent(moduleWriter.getSummaryTree(summaryContentTree)); + moduleContentTree.add(moduleWriter.getSummaryTree(summaryContentTree)); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java index 1267b9282df..b48b3c70e00 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -163,7 +163,7 @@ protected void buildSummary(Content packageContentTree) throws DocletException { buildErrorSummary(summaryContentTree); buildAnnotationTypeSummary(summaryContentTree); - packageContentTree.addContent(summaryContentTree); + packageContentTree.add(summaryContentTree); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java index 4cc106b9517..7e9b91a5f3f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -35,7 +35,6 @@ import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.PropertyWriter; -import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable; import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable.Kind.*; @@ -138,10 +137,10 @@ protected void buildPropertyDoc(Content memberDetailsTree) throws DocletExceptio buildPropertyComments(propertyDocTree); buildTagInfo(propertyDocTree); - propertyDetailsTree.addContent(writer.getPropertyDoc( + propertyDetailsTree.add(writer.getPropertyDoc( propertyDocTree, currentProperty == lastElement)); } - memberDetailsTree.addContent( + memberDetailsTree.add( writer.getPropertyDetails(propertyDetailsTree)); } } @@ -152,7 +151,7 @@ protected void buildPropertyDoc(Content memberDetailsTree) throws DocletExceptio * @param propertyDocTree the content tree to which the documentation will be added */ protected void buildSignature(Content propertyDocTree) { - propertyDocTree.addContent(writer.getSignature(currentProperty)); + propertyDocTree.add(writer.getSignature(currentProperty)); } /** diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java index 57a707a1e09..a43b4c786e3 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java @@ -170,7 +170,7 @@ protected void buildSerializedFormSummaries(Content serializedTree) buildPackageSerializedForm(serializedSummariesTree); } - serializedTree.addContent(writer.getSerializedContent( + serializedTree.add(writer.getSerializedContent( serializedSummariesTree)); } @@ -205,7 +205,7 @@ protected void buildPackageSerializedForm(Content serializedSummariesTree) throw * @param packageSerializedTree content tree to which the documentation will be added */ protected void buildPackageHeader(Content packageSerializedTree) { - packageSerializedTree.addContent(writer.getPackageHeader( + packageSerializedTree.add(writer.getPackageHeader( utils.getPackageName(currentPackage))); } @@ -232,10 +232,10 @@ protected void buildClassSerializedForm(Content packageSerializedTree) buildSerialUIDInfo(classTree); buildClassContent(classTree); - classSerializedTree.addContent(classTree); + classSerializedTree.add(classTree); } } - packageSerializedTree.addContent(classSerializedTree); + packageSerializedTree.add(classSerializedTree); } /** @@ -254,7 +254,7 @@ protected void buildSerialUIDInfo(Content classTree) { break; } } - classTree.addContent(serialUidTree); + classTree.add(serialUidTree); } /** @@ -270,7 +270,7 @@ protected void buildClassContent(Content classTree) throws DocletException { buildFieldHeader(classContentTree); buildSerializableFields(classContentTree); - classTree.addContent(classContentTree); + classTree.add(classContentTree); } /** @@ -292,18 +292,18 @@ protected void buildSerializableMethods(Content classContentTree) throws DocletE buildDeprecatedMethodInfo(methodsContentTree); buildMethodInfo(methodsContentTree); - serializableMethodTree.addContent(methodsContentTree); + serializableMethodTree.add(methodsContentTree); } } if (!utils.serializationMethods(currentTypeElement).isEmpty()) { - classContentTree.addContent(methodWriter.getSerializableMethods( + classContentTree.add(methodWriter.getSerializableMethods( configuration.getText("doclet.Serialized_Form_methods"), serializableMethodTree)); if (utils.isSerializable(currentTypeElement) && !utils.isExternalizable(currentTypeElement)) { if (utils.serializationMethods(currentTypeElement).isEmpty()) { Content noCustomizationMsg = methodWriter.getNoCustomizationMsg( configuration.getText("doclet.Serializable_no_customization")); - classContentTree.addContent(methodWriter.getSerializableMethods( + classContentTree.add(methodWriter.getSerializableMethods( configuration.getText("doclet.Serialized_Form_methods"), noCustomizationMsg)); } @@ -402,8 +402,8 @@ public void buildFieldSerializationOverview(TypeElement typeElement, Content cla fieldWriter.addMemberDescription(ve, fieldsOverviewContentTree); fieldWriter.addMemberTags(ve, fieldsOverviewContentTree); } - serializableFieldsTree.addContent(fieldsOverviewContentTree); - classContentTree.addContent(fieldWriter.getSerializableFields( + serializableFieldsTree.add(fieldsOverviewContentTree); + classContentTree.add(fieldWriter.getSerializableFields( configuration.getText("doclet.Serialized_Form_class"), serializableFieldsTree)); } @@ -431,12 +431,12 @@ protected void buildSerializableFields(Content classContentTree) buildFieldDeprecationInfo(fieldsContentTree); buildFieldInfo(fieldsContentTree); - serializableFieldsTree.addContent(fieldsContentTree); + serializableFieldsTree.add(fieldsContentTree); } else { buildSerialFieldTagsInfo(serializableFieldsTree); } } - classContentTree.addContent(fieldWriter.getSerializableFields( + classContentTree.add(fieldWriter.getSerializableFields( configuration.getText("doclet.Serialized_Form_fields"), serializableFieldsTree)); } @@ -511,7 +511,7 @@ protected void buildSerialFieldTagsInfo(Content serializableFieldsTree) { fieldWriter.addMemberHeader(te, fieldType, "", tag.getName().getName().toString(), fieldsContentTree); fieldWriter.addMemberDescription(field, tag, fieldsContentTree); - serializableFieldsTree.addContent(fieldsContentTree); + serializableFieldsTree.add(fieldsContentTree); } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java index 24dc922e518..35e73ade39f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -134,7 +134,7 @@ public Content getTagletOutput(Element holder, TagletWriter writer) { ExecutableElement member = (ExecutableElement) holder; Content output = getTagletOutput(false, member, writer, member.getTypeParameters(), utils.getTypeParamTrees(member)); - output.addContent(getTagletOutput(true, member, writer, + output.add(getTagletOutput(true, member, writer, member.getParameters(), utils.getParamTrees(member))); return output; } else { @@ -160,7 +160,7 @@ private Content getTagletOutput(boolean isParameters, Element holder, Content result = writer.getOutputInstance(); Set alreadyDocumented = new HashSet<>(); if (!paramTags.isEmpty()) { - result.addContent( + result.add( processParamTags(holder, isParameters, paramTags, getRankMap(writer.configuration().utils, formalParameters), writer, alreadyDocumented) ); @@ -168,7 +168,7 @@ private Content getTagletOutput(boolean isParameters, Element holder, if (alreadyDocumented.size() != formalParameters.size()) { //Some parameters are missing corresponding @param tags. //Try to inherit them. - result.addContent(getInheritedTagletOutput(isParameters, holder, + result.add(getInheritedTagletOutput(isParameters, holder, writer, formalParameters, alreadyDocumented)); } return result; @@ -204,7 +204,7 @@ private Content getInheritedTagletOutput(boolean isParameters, Element holder, inheritedDoc.holderTag, lname, alreadyDocumented.isEmpty()); - result.addContent(content); + result.add(content); } alreadyDocumented.add(String.valueOf(i)); } @@ -256,7 +256,7 @@ private Content processParamTags(Element e, boolean isParams, : "doclet.Type_Parameters_dup_warn", paramName); } - result.addContent(processParamTag(e, isParams, writer, dt, + result.add(processParamTag(e, isParams, writer, dt, ch.getParameterName(dt), alreadyDocumented.isEmpty())); alreadyDocumented.add(rank); } @@ -284,9 +284,9 @@ private Content processParamTag(Element e, boolean isParams, String header = writer.configuration().getText( isParams ? "doclet.Parameters" : "doclet.TypeParameters"); if (isFirstParam) { - result.addContent(writer.getParamHeader(header)); + result.add(writer.getParamHeader(header)); } - result.addContent(writer.paramTagOutput(e, paramTag, name)); + result.add(writer.paramTagOutput(e, paramTag, name)); return result; } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java index 637ea6e9ce9..5f8e445a1af 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -250,7 +250,7 @@ public static void genTagOutput(TagletManager tagletManager, Element element, } if (currentOutput != null) { tagletManager.seenCustomTag(taglet.getName()); - output.addContent(currentOutput); + output.add(currentOutput); } } } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ThrowsTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ThrowsTaglet.java index 679e9a85881..3b73462283b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ThrowsTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ThrowsTaglet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -104,9 +104,9 @@ private Content linkToUndocumentedDeclaredExceptions(List !alreadyDocumented.contains(utils.getSimpleName(klass)) && !alreadyDocumented.contains(utils.getFullyQualifiedName(klass))) { if (alreadyDocumented.isEmpty()) { - result.addContent(writer.getThrowsHeader()); + result.add(writer.getThrowsHeader()); } - result.addContent(writer.throwsTagOutput(declaredExceptionType)); + result.add(writer.throwsTagOutput(declaredExceptionType)); alreadyDocumented.add(utils.getSimpleName(klass)); } } @@ -140,7 +140,7 @@ private Content inheritThrowsDocumentation(Element holder, declaredExceptionTags.put(inheritedDoc.tagList, (ExecutableElement)inheritedDoc.holder); } } - result.addContent(throwsTagsOutput(declaredExceptionTags, writer, alreadyDocumented, false)); + result.add(throwsTagsOutput(declaredExceptionTags, writer, alreadyDocumented, false)); } return result; } @@ -156,11 +156,11 @@ public Content getTagletOutput(Element holder, TagletWriter writer) { Content result = writer.getOutputInstance(); HashSet alreadyDocumented = new HashSet<>(); if (!tagsMap.isEmpty()) { - result.addContent(throwsTagsOutput(tagsMap, writer, alreadyDocumented, true)); + result.add(throwsTagsOutput(tagsMap, writer, alreadyDocumented, true)); } - result.addContent(inheritThrowsDocumentation(holder, + result.add(inheritThrowsDocumentation(holder, execHolder.getThrownTypes(), alreadyDocumented, writer)); - result.addContent(linkToUndocumentedDeclaredExceptions( + result.add(linkToUndocumentedDeclaredExceptions( execHolder.getThrownTypes(), alreadyDocumented, writer)); return result; } @@ -192,9 +192,9 @@ protected Content throwsTagsOutput(Map, ExecutableElemen continue; } if (alreadyDocumented.isEmpty()) { - result.addContent(writer.getThrowsHeader()); + result.add(writer.getThrowsHeader()); } - result.addContent(writer.throwsTagOutput(e, dt)); + result.add(writer.throwsTagOutput(e, dt)); alreadyDocumented.add(te != null ? utils.getFullyQualifiedName(te) : excName); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/UserTaglet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/UserTaglet.java index cb6ebb6edf6..541a29a6187 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/UserTaglet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/UserTaglet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -132,7 +132,7 @@ public String getName() { */ public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer){ Content output = writer.getOutputInstance(); - output.addContent(new RawHtml(userTaglet.toString(Collections.singletonList(tag), element))); + output.add(new RawHtml(userTaglet.toString(Collections.singletonList(tag), element))); return output; } @@ -146,7 +146,7 @@ public Content getTagletOutput(Element holder, TagletWriter writer) { if (!tags.isEmpty()) { String tagString = userTaglet.toString(tags, holder); if (tagString != null) { - output.addContent(new RawHtml(tagString)); + output.add(new RawHtml(tagString)); } } return output; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java index 92d0b9a61ac..d1bbbc99b46 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -81,7 +81,7 @@ public Content getLink(LinkInfo linkInfo) { // handles primitives, no types and error types @Override protected Content defaultAction(TypeMirror type, LinkInfo linkInfo) { - link.addContent(utils.getTypeName(type, false)); + link.add(utils.getTypeName(type, false)); return link; } @@ -96,14 +96,14 @@ public Content visitArray(ArrayType type, LinkInfo linkInfo) { currentDepth--; if (utils.isAnnotated(type)) { linkInfo.type = type; - link.addContent(" "); - link.addContent(getTypeAnnotationLinks(linkInfo)); + link.add(" "); + link.add(getTypeAnnotationLinks(linkInfo)); } // use vararg if required if (linkInfo.isVarArg && currentDepth == 0) { - link.addContent("..."); + link.add("..."); } else { - link.addContent("[]"); + link.add("[]"); } return link; } @@ -111,25 +111,25 @@ public Content visitArray(ArrayType type, LinkInfo linkInfo) { @Override public Content visitWildcard(WildcardType type, LinkInfo linkInfo) { linkInfo.isTypeBound = true; - link.addContent("?"); + link.add("?"); TypeMirror extendsBound = type.getExtendsBound(); if (extendsBound != null) { - link.addContent(" extends "); + link.add(" extends "); setBoundsLinkInfo(linkInfo, extendsBound); - link.addContent(getLink(linkInfo)); + link.add(getLink(linkInfo)); } TypeMirror superBound = type.getSuperBound(); if (superBound != null) { - link.addContent(" super "); + link.add(" super "); setBoundsLinkInfo(linkInfo, superBound); - link.addContent(getLink(linkInfo)); + link.add(getLink(linkInfo)); } return link; } @Override public Content visitTypeVariable(TypeVariable type, LinkInfo linkInfo) { - link.addContent(getTypeAnnotationLinks(linkInfo)); + link.add(getTypeAnnotationLinks(linkInfo)); linkInfo.isTypeBound = true; TypeVariable typevariable = (utils.isArrayType(type)) ? (TypeVariable) componentType @@ -138,12 +138,12 @@ public Content visitTypeVariable(TypeVariable type, LinkInfo linkInfo) { if ((!linkInfo.excludeTypeParameterLinks) && utils.isTypeElement(owner)) { linkInfo.typeElement = (TypeElement) owner; Content label = newContent(); - label.addContent(utils.getTypeName(type, false)); + label.add(utils.getTypeName(type, false)); linkInfo.label = label; - link.addContent(getClassLink(linkInfo)); + link.add(getClassLink(linkInfo)); } else { // No need to link method type parameters. - link.addContent(utils.getTypeName(typevariable, false)); + link.add(utils.getTypeName(typevariable, false)); } if (!linkInfo.excludeTypeBounds) { @@ -159,9 +159,9 @@ public Content visitTypeVariable(TypeVariable type, LinkInfo linkInfo) { !utils.isAnnotated(bound)) { continue; } - link.addContent(more ? " & " : " extends "); + link.add(more ? " & " : " extends "); setBoundsLinkInfo(linkInfo, bound); - link.addContent(getLink(linkInfo)); + link.add(getLink(linkInfo)); more = true; } } @@ -173,16 +173,16 @@ public Content visitDeclared(DeclaredType type, LinkInfo linkInfo) { if (linkInfo.isTypeBound && linkInfo.excludeTypeBoundsLinks) { // Since we are excluding type parameter links, we should not // be linking to the type bound. - link.addContent(utils.getTypeName(type, false)); - link.addContent(getTypeParameterLinks(linkInfo)); + link.add(utils.getTypeName(type, false)); + link.add(getTypeParameterLinks(linkInfo)); return link; } else { link = newContent(); - link.addContent(getTypeAnnotationLinks(linkInfo)); + link.add(getTypeAnnotationLinks(linkInfo)); linkInfo.typeElement = utils.asTypeElement(type); - link.addContent(getClassLink(linkInfo)); + link.add(getClassLink(linkInfo)); if (linkInfo.includeTypeAsSepLink) { - link.addContent(getTypeParameterLinks(linkInfo, false)); + link.add(getTypeParameterLinks(linkInfo, false)); } } return link; @@ -191,9 +191,9 @@ public Content visitDeclared(DeclaredType type, LinkInfo linkInfo) { return linkVisitor.visit(linkInfo.type, linkInfo); } else if (linkInfo.typeElement != null) { Content link = newContent(); - link.addContent(getClassLink(linkInfo)); + link.add(getClassLink(linkInfo)); if (linkInfo.includeTypeAsSepLink) { - link.addContent(getTypeParameterLinks(linkInfo, false)); + link.add(getTypeParameterLinks(linkInfo, false)); } return link; } else { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java index 0038f375ce1..d1b3982a7cc 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -145,11 +145,11 @@ public Content getClassLinkLabel(BaseConfiguration configuration) { return label; } else if (isLinkable()) { Content tlabel = newContent(); - tlabel.addContent(configuration.utils.getSimpleName(typeElement)); + tlabel.add(configuration.utils.getSimpleName(typeElement)); return tlabel; } else { Content tlabel = newContent(); - tlabel.addContent(configuration.getClassName(typeElement)); + tlabel.add(configuration.getClassName(typeElement)); return tlabel; } } diff --git a/test/langtools/jdk/javadoc/doclet/testHtmlDocument/TestHtmlDocument.java b/test/langtools/jdk/javadoc/doclet/testHtmlDocument/TestHtmlDocument.java index 27bdcfa4ce7..cab7900ddf4 100644 --- a/test/langtools/jdk/javadoc/doclet/testHtmlDocument/TestHtmlDocument.java +++ b/test/langtools/jdk/javadoc/doclet/testHtmlDocument/TestHtmlDocument.java @@ -75,31 +75,31 @@ public static String generateHtmlTree() { HtmlTree title = new HtmlTree(HtmlTag.TITLE); // String content within the document StringContent titleContent = new StringContent("Markup test"); - title.addContent(titleContent); - head.addContent(title); + title.add(titleContent); + head.add(title); // Test META tag HtmlTree meta = new HtmlTree(HtmlTag.META); - meta.addAttr(HtmlAttr.NAME, "keywords"); - meta.addAttr(HtmlAttr.CONTENT, "testContent"); - head.addContent(meta); + meta.put(HtmlAttr.NAME, "keywords"); + meta.put(HtmlAttr.CONTENT, "testContent"); + head.add(meta); // Test invalid META tag HtmlTree invmeta = new HtmlTree(HtmlTag.META); - head.addContent(invmeta); + head.add(invmeta); // Test LINK tag HtmlTree link = new HtmlTree(HtmlTag.LINK); - link.addAttr(HtmlAttr.REL, "testRel"); - link.addAttr(HtmlAttr.HREF, "testLink.html"); - head.addContent(link); + link.put(HtmlAttr.REL, "testRel"); + link.put(HtmlAttr.HREF, "testLink.html"); + head.add(link); // Test invalid LINK tag HtmlTree invlink = new HtmlTree(HtmlTag.LINK); - head.addContent(invlink); - html.addContent(head); + head.add(invlink); + html.add(head); // Comment within the document Comment bodyMarker = new Comment("======== START OF BODY ========"); - html.addContent(bodyMarker); + html.add(bodyMarker); HtmlTree body = new HtmlTree(HtmlTag.BODY); Comment pMarker = new Comment("======== START OF PARAGRAPH ========"); - body.addContent(pMarker); + body.add(pMarker); HtmlTree p = new HtmlTree(HtmlTag.P); StringContent bodyContent = new StringContent( "This document is generated from sample source code and HTML " + @@ -107,41 +107,41 @@ public static String generateHtmlTree() { "subclasses, subinterfaces, nested classes, nested interfaces," + "inheriting from other packages, constructors, fields," + "methods, and so forth. "); - p.addContent(bodyContent); + p.add(bodyContent); StringContent anchorContent = new StringContent("Click Here"); - p.addContent(HtmlTree.A("testLink.html", anchorContent)); + p.add(HtmlTree.A("testLink.html", anchorContent)); StringContent pContent = new StringContent(" to out a link."); - p.addContent(pContent); - body.addContent(p); + p.add(pContent); + body.add(p); HtmlTree p1 = new HtmlTree(HtmlTag.P); // Test another version of A tag. HtmlTree anchor = new HtmlTree(HtmlTag.A); - anchor.addAttr(HtmlAttr.HREF, "testLink.html"); - anchor.addAttr(HtmlAttr.ID, "Another version of a tag"); - p1.addContent(anchor); - body.addContent(p1); + anchor.put(HtmlAttr.HREF, "testLink.html"); + anchor.put(HtmlAttr.ID, "Another version of a tag"); + p1.add(anchor); + body.add(p1); // Test for empty tags. HtmlTree dl = new HtmlTree(HtmlTag.DL); - html.addContent(dl); + html.add(dl); // Test for empty nested tags. HtmlTree dlTree = new HtmlTree(HtmlTag.DL); - dlTree.addContent(new HtmlTree(HtmlTag.DT)); - dlTree.addContent(new HtmlTree (HtmlTag.DD)); - html.addContent(dlTree); + dlTree.add(new HtmlTree(HtmlTag.DT)); + dlTree.add(new HtmlTree (HtmlTag.DD)); + html.add(dlTree); HtmlTree dlDisplay = new HtmlTree(HtmlTag.DL); - dlDisplay.addContent(new HtmlTree(HtmlTag.DT)); + dlDisplay.add(new HtmlTree(HtmlTag.DT)); HtmlTree dd = new HtmlTree (HtmlTag.DD); StringContent ddContent = new StringContent("Test DD"); - dd.addContent(ddContent); - dlDisplay.addContent(dd); - body.addContent(dlDisplay); + dd.add(ddContent); + dlDisplay.add(dd); + body.add(dlDisplay); StringContent emptyString = new StringContent(""); - body.addContent(emptyString); + body.add(emptyString); Comment emptyComment = new Comment(""); - body.addContent(emptyComment); + body.add(emptyComment); HtmlTree hr = new HtmlTree(HtmlTag.HR); - body.addContent(hr); - html.addContent(body); + body.add(hr); + html.add(body); HtmlDocument htmlDoc = new HtmlDocument(htmlDocType, html); return htmlDoc.toString(); } From f3d0f2bac0a01c992760826bc006f4f4c55584ed Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Fri, 26 Apr 2024 05:50:42 +0000 Subject: [PATCH 109/149] 8306031: Update IANA Language Subtag Registry to Version 2023-04-13 Reviewed-by: lucy Backport-of: 261e45a973db0ad56b9ffe0901a63114a78a5e52 --- .../data/lsrdata/language-subtag-registry.txt | 4 +-- .../EquivMapsGenerator.java | 36 ++++++++++++++----- .../Locale/LanguageSubtagRegistryTest.java | 6 ++-- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/make/data/lsrdata/language-subtag-registry.txt b/make/data/lsrdata/language-subtag-registry.txt index 1a29e6f0450..4fbc0c16806 100644 --- a/make/data/lsrdata/language-subtag-registry.txt +++ b/make/data/lsrdata/language-subtag-registry.txt @@ -1,4 +1,4 @@ -File-Date: 2023-03-22 +File-Date: 2023-04-13 %% Type: language Subtag: aa @@ -42986,7 +42986,7 @@ Subtag: ajp Description: South Levantine Arabic Added: 2009-07-29 Deprecated: 2023-03-17 -Preferred-Value: apc +Preferred-Value: ajp Prefix: ar Macrolanguage: ar %% diff --git a/make/jdk/src/classes/build/tools/generatelsrequivmaps/EquivMapsGenerator.java b/make/jdk/src/classes/build/tools/generatelsrequivmaps/EquivMapsGenerator.java index 7d1b7b261d5..cffaed7186a 100644 --- a/make/jdk/src/classes/build/tools/generatelsrequivmaps/EquivMapsGenerator.java +++ b/make/jdk/src/classes/build/tools/generatelsrequivmaps/EquivMapsGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020, 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 @@ -39,6 +39,7 @@ import java.util.Map; import java.util.TreeMap; import java.util.stream.Collectors; +import java.util.regex.Pattern; /** * This tool reads the IANA Language Subtag Registry data file downloaded from @@ -134,10 +135,29 @@ private static void processDeprecatedData(String type, } } else { // language, extlang, legacy, and redundant if (!initialLanguageMap.containsKey(preferred)) { - sb = new StringBuilder(preferred); - sb.append(','); - sb.append(tag); - initialLanguageMap.put(preferred, sb); + // IANA update 4/13 introduced case where a preferred value + // can have a preferred value itself. + // eg: ar-ajp has pref ajp which has pref apc + boolean foundInOther = false; + Pattern pattern = Pattern.compile(","+preferred+"(,|$)"); + // Check if current pref exists inside a value for another pref + List doublePrefs = initialLanguageMap + .values() + .stream() + .filter(e -> pattern.matcher(e.toString()).find()) + .collect(Collectors.toList()); + for (StringBuilder otherPrefVal : doublePrefs) { + otherPrefVal.append(","); + otherPrefVal.append(tag); + foundInOther = true; + } + if (!foundInOther) { + // does not exist in any other pref's values, so add as new entry + sb = new StringBuilder(preferred); + sb.append(','); + sb.append(tag); + initialLanguageMap.put(preferred, sb); + } } else { sb = initialLanguageMap.get(preferred); sb.append(','); @@ -263,11 +283,11 @@ private static void generateSourceCode(String fileName) { Paths.get(fileName))) { writer.write(getOpenJDKCopyright()); writer.write(headerText - + (int)(sortedLanguageMap1.size() / 0.75f + 1) + ");\n" + + sortedLanguageMap1.size() + ");\n" + " multiEquivsMap = new HashMap<>(" - + (int)(sortedLanguageMap2.size() / 0.75f + 1) + ");\n" + + sortedLanguageMap2.size() + ");\n" + " regionVariantEquivMap = new HashMap<>(" - + (int)(sortedRegionVariantMap.size() / 0.75f + 1) + ");\n\n" + + sortedRegionVariantMap.size() + ");\n\n" + " // This is an auto-generated file and should not be manually edited.\n" + " // LSR Revision: " + LSRrevisionDate); writer.newLine(); diff --git a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java index 50fc824beb8..9722823430f 100644 --- a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java +++ b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java @@ -24,9 +24,9 @@ /* * @test * @bug 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432 - * 8258795 8267038 8287180 8302512 8304761 + * 8258795 8267038 8287180 8302512 8304761 8306031 * @summary Checks the IANA language subtag registry data update - * (LSR Revision: 2023-03-22) with Locale and Locale.LanguageRange + * (LSR Revision: 2023-04-13) with Locale and Locale.LanguageRange * class methods. * @run main LanguageSubtagRegistryTest */ @@ -44,7 +44,7 @@ public class LanguageSubtagRegistryTest { static boolean err = false; private static final String ACCEPT_LANGUAGE = - "Accept-Language: aam, adp, aeb, ajs, aog, apc, aue, bcg, bic, bpp, cey, cbr, cnp, cqu, crr, csp, csx, dif, dmw, dsz, ehs, ema," + "Accept-Language: aam, adp, aeb, ajs, aog, apc, ajp, aue, bcg, bic, bpp, cey, cbr, cnp, cqu, crr, csp, csx, dif, dmw, dsz, ehs, ema," + " en-gb-oed, gti, iba, jks, kdz, kjh, kmb, koj, kru, ksp, kwq, kxe, kzk, lgs, lii, lmm, lsb, lsc, lsn, lsv, lsw, lvi, mtm," + " ngv, nns, ola, oyb, pat, phr, plu, pnd, pub, rib, rnb, rsn, scv, snz, sqx, suj, szy, taj, tdg, tjj, tjp, tpn, tvx," + " umi, uss, uth, ysm, zko, wkr;q=0.9, ar-hyw;q=0.8, yug;q=0.5, gfx;q=0.4"; From 7c047564b1038fa7e95b814447a4a7a1628fd14a Mon Sep 17 00:00:00 2001 From: Sonia Zaldana Calles Date: Sun, 28 Apr 2024 20:12:29 +0000 Subject: [PATCH 110/149] 8159927: Add a test to verify JMOD files created in the images do not have debug symbols Reviewed-by: lucy Backport-of: 6c0bebccb0092d9726eb89a054e023e92edf7ca6 --- .../jdk/modules/etc/JmodExcludedFiles.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 test/jdk/jdk/modules/etc/JmodExcludedFiles.java diff --git a/test/jdk/jdk/modules/etc/JmodExcludedFiles.java b/test/jdk/jdk/modules/etc/JmodExcludedFiles.java new file mode 100644 index 00000000000..5922bb61b86 --- /dev/null +++ b/test/jdk/jdk/modules/etc/JmodExcludedFiles.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024, 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. + * + * 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. + */ + +/** + * @test + * @bug 8159927 + * @modules java.base/jdk.internal.util + * @run main JmodExcludedFiles + * @summary Test that JDK JMOD files do not include native debug symbols + */ + +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +public class JmodExcludedFiles { + public static void main(String[] args) throws Exception { + String javaHome = System.getProperty("java.home"); + Path jmods = Path.of(javaHome, "jmods"); + try (DirectoryStream stream = Files.newDirectoryStream(jmods, "*.jmod")) { + for (Path jmodFile : stream) { + try (ZipFile zip = new ZipFile(jmodFile.toFile())) { + if (zip.stream().map(ZipEntry::getName) + .anyMatch(JmodExcludedFiles::isNativeDebugSymbol)) { + throw new RuntimeException(jmodFile + " is expected not to include native debug symbols"); + } + } + } + } + } + + private static boolean isNativeDebugSymbol(String name) { + int index = name.indexOf("/"); + if (index < 0) { + throw new RuntimeException("unexpected entry name: " + name); + } + String section = name.substring(0, index); + if (section.equals("lib") || section.equals("bin")) { + if (System.getProperty("os.name").toLowerCase().contains("os x")) { + String n = name.substring(index+1); + int i = n.indexOf("/"); + if (i != -1) { + return n.substring(0, i).endsWith(".dSYM"); + } + } + return name.endsWith(".diz") + || name.endsWith(".debuginfo") + || name.endsWith(".map") + || name.endsWith(".pdb"); + } + return false; + } +} From ac43e680ddb3f81e7350dd7f5af033e1395383b9 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Sun, 28 Apr 2024 21:16:52 +0000 Subject: [PATCH 111/149] 8255031: Update java/util/prefs/AddNodeChangeListener.java to report more failure info Backport-of: 8afdcaee1ce28647dadffcdf41f938af0602d8f1 --- .../util/prefs/AddNodeChangeListener.java | 72 ++++++++++++++----- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/test/jdk/java/util/prefs/AddNodeChangeListener.java b/test/jdk/java/util/prefs/AddNodeChangeListener.java index 97532772bc9..d63ffed36b7 100644 --- a/test/jdk/java/util/prefs/AddNodeChangeListener.java +++ b/test/jdk/java/util/prefs/AddNodeChangeListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, 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,6 +23,7 @@ /* @test * @bug 7160252 7197662 + * @key intermittent * @summary Checks if events are delivered to a listener * when a child node is added or removed * @run main/othervm -Djava.util.prefs.userRoot=. AddNodeChangeListener @@ -30,15 +31,15 @@ import java.util.prefs.*; - public class AddNodeChangeListener { +public class AddNodeChangeListener { - private static boolean failed = false; - private static Preferences userRoot, N2; - private static NodeChangeListenerAdd ncla; + private static final int SLEEP_ITRS = 10; + private static boolean failed = false; + private static Preferences userRoot, N2; + private static NodeChangeListenerAdd ncla; - public static void main(String[] args) - throws BackingStoreException, InterruptedException - { + public static void main(String[] args) + throws BackingStoreException, InterruptedException { userRoot = Preferences.userRoot(); ncla = new NodeChangeListenerAdd(); userRoot.addNodeChangeListener(ncla); @@ -49,28 +50,61 @@ public static void main(String[] args) //Should initate a child removed event removeNode(); - if (failed) + if (failed) { throw new RuntimeException("Failed"); + } } private static void addNode() - throws BackingStoreException, InterruptedException - { + throws BackingStoreException, InterruptedException { N2 = userRoot.node("N2"); userRoot.flush(); - Thread.sleep(3000); - if (ncla.getAddNumber() != 1) - failed = true; + int passItr = -1; + + for (int i = 0; i < SLEEP_ITRS; i++) { + System.out.print("addNode sleep iteration " + i + "..."); + Thread.sleep(3000); + System.out.println("done."); + if (ncla.getAddNumber() == 1) { + passItr = i; + break; + } + } + checkPassItr(passItr, "addNode()"); } private static void removeNode() - throws BackingStoreException, InterruptedException - { + throws BackingStoreException, InterruptedException { N2.removeNode(); userRoot.flush(); - Thread.sleep(3000); - if (ncla.getAddNumber() != 0) + int passItr = -1; + + for (int i = 0; i < SLEEP_ITRS; i++) { + System.out.print("removeNode sleep iteration " + i + "..."); + Thread.sleep(3000); + System.out.println("done."); + if (ncla.getAddNumber() == 0) { + passItr = i; + break; + } + } + checkPassItr(passItr, "removeNode()"); + } + + /* If the listener wasn't notified on iteration 0, throw a RuntimeException + * with some contextual information + */ + private static void checkPassItr(int itr, String methodName) { + if (itr == 0) { + System.out.println(methodName + " test passed"); + } else { failed = true; + if (itr == -1) { + throw new RuntimeException("Failed in " + methodName + " - change listener never notified"); + } else { + throw new RuntimeException("Failed in " + methodName + " - listener notified on iteration " + itr); + } + } } private static class NodeChangeListenerAdd implements NodeChangeListener { @@ -90,4 +124,4 @@ public int getAddNumber(){ return totalNode; } } - } +} From f29aa4d62c3715acb56c88f3ebb0234f640b72a0 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Sun, 28 Apr 2024 21:48:29 +0000 Subject: [PATCH 112/149] 8324733: [macos14] Problem list tests which fail due to macOS bug described in JDK-8322653 Backport-of: d1e676360d5143cf12655ab1175a4a60bf402473 --- test/jdk/ProblemList.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 5bf69113f80..01d06a00cb5 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -477,13 +477,16 @@ java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java 8233568 macosx-all java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java 8233568 macosx-all java/awt/TrayIcon/RightClickWhenBalloonDisplayed/RightClickWhenBalloonDisplayed.java 8238720 windows-all java/awt/PopupMenu/PopupMenuLocation.java 8238720 windows-all -java/awt/GridLayout/ComponentPreferredSize/ComponentPreferredSize.java 8238720 windows-all -java/awt/GridLayout/ChangeGridSize/ChangeGridSize.java 8238720 windows-all +java/awt/GridLayout/ComponentPreferredSize/ComponentPreferredSize.java 8238720,8324782 windows-all,macosx-all +java/awt/GridLayout/ChangeGridSize/ChangeGridSize.java 8238720,8324782 windows-all,macosx-all java/awt/event/MouseEvent/FrameMouseEventAbsoluteCoordsTest/FrameMouseEventAbsoluteCoordsTest.java 8238720 windows-all # Several tests which fail sometimes on macos11 java/awt/Dialog/MakeWindowAlwaysOnTop/MakeWindowAlwaysOnTop.java 8266243 macosx-aarch64 +# This test fails on macOS 14 +java/awt/Choice/SelectNewItemTest/SelectNewItemTest.java 8324782 macosx-all + ############################################################################ # jdk_beans @@ -655,6 +658,9 @@ javax/sound/midi/Sequencer/Recording.java 8167580,8265485 linux-all,solaris-all, # jdk_imageio +# This test fails on macOS 14 +javax/swing/plaf/synth/7158712/bug7158712.java 8324782 macosx-all + ############################################################################ # jdk_swing From 9df5688e87e90cd88beea468b00c3557dce7078a Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Sun, 28 Apr 2024 21:50:23 +0000 Subject: [PATCH 113/149] 8327136: javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java fails on libgraal Backport-of: 8f0fb27decec28f32e4d88341237189ba4a340fb --- .../remote/mandatory/notif/NotifReconnectDeadlockTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java b/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java index 3f16ed00369..72ae5766307 100644 --- a/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java +++ b/test/jdk/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java @@ -176,7 +176,7 @@ public void handleNotification(Notification n, Object hb) { // serverTimeout increased to avoid occasional problems with initial connect. // Not using Utils.adjustTimeout to avoid accidentally making it too long. - private static final long serverTimeout = 2000; + private static final long serverTimeout = 3000; private static final long listenerSleep = serverTimeout*6; private volatile static String clientState = null; From d8b297fa7bbfbff6fda60e2a937eba4cbc2ccd13 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Sun, 28 Apr 2024 21:50:44 +0000 Subject: [PATCH 114/149] 8306067: Open source AWT Graphics,GridBagLayout related tests 8306838: GetGraphicsTest needs to be headful Backport-of: cb32c8221a1f0f30300813a49b03cf2838bbbf01 --- .../java/awt/Graphics/DrawNullStringTest.java | 57 ++++++++ .../java/awt/Graphics/GetGraphicsTest.java | 51 ++++++++ .../GridBagLayoutButtonsOverlapTest.java | 123 ++++++++++++++++++ .../GridBagLayoutOutOfBoundsTest.java | 69 ++++++++++ 4 files changed, 300 insertions(+) create mode 100644 test/jdk/java/awt/Graphics/DrawNullStringTest.java create mode 100644 test/jdk/java/awt/Graphics/GetGraphicsTest.java create mode 100644 test/jdk/java/awt/GridBagLayout/GridBagLayoutButtonsOverlapTest.java create mode 100644 test/jdk/java/awt/GridBagLayout/GridBagLayoutOutOfBoundsTest.java diff --git a/test/jdk/java/awt/Graphics/DrawNullStringTest.java b/test/jdk/java/awt/Graphics/DrawNullStringTest.java new file mode 100644 index 00000000000..7ae2d066fa9 --- /dev/null +++ b/test/jdk/java/awt/Graphics/DrawNullStringTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +/** + * @test + * @bug 4166809 + * @summary Make sure NPE is thrown when calling + * Graphics.drawString(null, int, int) + * @run main DrawNullStringTest + */ +import java.awt.image.BufferedImage; +import java.awt.EventQueue; +import java.awt.Graphics; + +public class DrawNullStringTest { + static String s = null; + static boolean passed = false; + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> { + BufferedImage img = new BufferedImage(100, 100, + BufferedImage.TYPE_INT_RGB); + Graphics g = (Graphics)(img.getGraphics()); + try { + g.drawString(s, 30, 30); + } catch (NullPointerException npe) { + System.out.println("NPE thrown - test passes"); + passed = true; + } + + if (passed == false) { + throw new Error("No Exception was thrown - should be an NPE"); + } + }); + } + + }// class DrawNullStringTest diff --git a/test/jdk/java/awt/Graphics/GetGraphicsTest.java b/test/jdk/java/awt/Graphics/GetGraphicsTest.java new file mode 100644 index 00000000000..7a80e1fd0df --- /dev/null +++ b/test/jdk/java/awt/Graphics/GetGraphicsTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2002, 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. + * + * 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. + */ +/* + * @test + * @bug 4746122 + * @key headful + * @summary Checks getGraphics doesn't throw NullPointerExcepton for invalid colors and font. + * @run main GetGraphicsTest +*/ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Graphics; + +public class GetGraphicsTest extends Frame { + public Color getBackground() { + return null; + } + public Color getForeground() { + return null; + } + public Font getFont() { + return null; + } + + public static void main(String[] args) throws Exception { + GetGraphicsTest test = new GetGraphicsTest(); + Graphics g = test.getGraphics(); + } +}// class GetGraphicsTest diff --git a/test/jdk/java/awt/GridBagLayout/GridBagLayoutButtonsOverlapTest.java b/test/jdk/java/awt/GridBagLayout/GridBagLayoutButtonsOverlapTest.java new file mode 100644 index 00000000000..dda70992889 --- /dev/null +++ b/test/jdk/java/awt/GridBagLayout/GridBagLayoutButtonsOverlapTest.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +/* + @test + @bug 4930685 + @summary Test effect of GridBagConstraints on padding / layout + @key headful + @run main GridBagLayoutButtonsOverlapTest +*/ + +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.Font; +import java.awt.Frame; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; + +public class GridBagLayoutButtonsOverlapTest { + public static GridBagLayout gridbag; + public static GridBagConstraints c; + public static Button b1; + public static Button b2; + public static Button b4; + public static Button b5; + public static Button b6; + public static Button b7; + public static Button b8; + public static Button b9; + public static Button b10; + public static Frame frame; + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> { + try { + createUI(); + test(); + } finally { + if (frame != null) { + frame.dispose(); + } + } + }); + } + + public static void createUI() { + frame = new Frame(); + gridbag = new GridBagLayout(); + GridBagConstraints c = new GridBagConstraints(); + frame.setFont(new Font(Font.DIALOG, Font.PLAIN, 14)); + frame.setLayout(gridbag); + c.fill = GridBagConstraints.BOTH; + c.weightx = 1.0; + b1 = makeButton("button1", gridbag, c); + b2 = makeButton("button2", gridbag, c); + + c.gridwidth = GridBagConstraints.REMAINDER; + b4 = makeButton("button4", gridbag, c); + + c.weightx = 0.0; + b5 = makeButton("button5", gridbag, c); + + c.gridwidth = GridBagConstraints.RELATIVE; + b6 = makeButton("button6", gridbag, c); + + c.gridwidth = GridBagConstraints.REMAINDER; + b7 = makeButton("button7", gridbag, c); + + c.gridwidth = 1; + c.gridheight = 2; + c.weighty = 1.0; + b8 = makeButton("button8", gridbag, c); + + c.weighty = 0.0; + c.gridwidth = GridBagConstraints.REMAINDER; + c.gridheight = 1; + b9 = makeButton("button9", gridbag, c); + b10 = makeButton("button10", gridbag, c); + } + + public static void test() { + frame.setLocationRelativeTo(null); + frame.setVisible(true); + frame.validate(); + + int b1Corner = b1.getLocation().y + b1.getHeight(); + int b5Corner = b5.getLocation().y; + if (b1Corner > b5Corner) { //they are equals each other in best case + throw new RuntimeException("Buttons are overlapped when container is small enough"); + } + System.out.println("Test passed."); + } + + protected static Button makeButton(String name, + GridBagLayout gridbag, + GridBagConstraints c) { + Button button = new Button(name); + gridbag.setConstraints(button, c); + frame.add(button); + return button; + } + +}// class diff --git a/test/jdk/java/awt/GridBagLayout/GridBagLayoutOutOfBoundsTest.java b/test/jdk/java/awt/GridBagLayout/GridBagLayoutOutOfBoundsTest.java new file mode 100644 index 00000000000..1f68dbb8620 --- /dev/null +++ b/test/jdk/java/awt/GridBagLayout/GridBagLayoutOutOfBoundsTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2004, 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. + * + * 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. + */ + +/* + @test + @bug 5055696 + @summary REGRESSION: GridBagLayout throws ArrayIndexOutOfBoundsExceptions + @key headful + @run main GridBagLayoutOutOfBoundsTest +*/ +import java.awt.Button; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GridBagLayout; +import java.awt.GridBagConstraints; +import java.awt.Panel; + +public class GridBagLayoutOutOfBoundsTest { + final static int L=2; + static Frame frame; + + public static void main(String[] args) throws Exception { + EventQueue.invokeAndWait(() -> { + try { + frame = new Frame("GridBagLayoutOutOfBoundsTestFrame"); + frame.validate(); + GridBagLayout layout = new GridBagLayout(); + frame.setLayout(layout); + GridBagConstraints gridBagConstraints; + + Button[] mb = new Button[L]; + for (int i = 0; i Date: Sun, 28 Apr 2024 21:51:01 +0000 Subject: [PATCH 115/149] 8294137: Review running times of java.math tests Backport-of: 51035a75e493f64b26f78e7fc87f6f6e536e4f56 --- .../java/math/BigInteger/BigIntegerTest.java | 86 ++++++++------ .../math/BigInteger/LargeValueExceptions.java | 11 +- .../largeMemory/SymmetricRangeTests.java | 106 +++++++++++------- 3 files changed, 124 insertions(+), 79 deletions(-) diff --git a/test/jdk/java/math/BigInteger/BigIntegerTest.java b/test/jdk/java/math/BigInteger/BigIntegerTest.java index 8d043c57649..d11d58c2719 100644 --- a/test/jdk/java/math/BigInteger/BigIntegerTest.java +++ b/test/jdk/java/math/BigInteger/BigIntegerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -1212,6 +1212,17 @@ public static void serialize() throws Exception { * */ public static void main(String[] args) throws Exception { + // subset zero indicates to run all subsets + int subset = Integer.valueOf(System.getProperty("subset", + String.valueOf(1 + random.nextInt(3)))); + if (subset < 0 || subset > 3) { + throw new RuntimeException("Unknown subset " + subset); + } + if (subset == 0) + System.out.println("Testing all subsets"); + else + System.out.println("Testing subset " + subset); + // Some variables for sizing test numbers in bits int order1 = ORDER_MEDIUM; int order2 = ORDER_SMALL; @@ -1227,52 +1238,57 @@ public static void main(String[] args) throws Exception { if (args.length >3) order4 = (int)((Integer.parseInt(args[3]))* 3.333); - constructor(); - - prime(); - nextProbablePrime(); + if (subset == 0 || subset == 1) { + constructor(); - arithmetic(order1); // small numbers - arithmetic(order3); // Karatsuba range - arithmetic(order4); // Toom-Cook / Burnikel-Ziegler range + prime(); + nextProbablePrime(); - divideAndRemainder(order1); // small numbers - divideAndRemainder(order3); // Karatsuba range - divideAndRemainder(order4); // Toom-Cook / Burnikel-Ziegler range + arithmetic(order1); // small numbers + arithmetic(order3); // Karatsuba range + arithmetic(order4); // Toom-Cook / Burnikel-Ziegler range - pow(order1); - pow(order3); - pow(order4); + divideAndRemainder(order1); // small numbers + divideAndRemainder(order3); // Karatsuba range + divideAndRemainder(order4); // Toom-Cook / Burnikel-Ziegler range - square(ORDER_MEDIUM); - square(ORDER_KARATSUBA_SQUARE); - square(ORDER_TOOM_COOK_SQUARE); + pow(order1); + pow(order3); + pow(order4); - squareRoot(); - squareRootAndRemainder(); + square(ORDER_MEDIUM); + square(ORDER_KARATSUBA_SQUARE); + square(ORDER_TOOM_COOK_SQUARE); - bitCount(); - bitLength(); - bitOps(order1); - bitwise(order1); + squareRoot(); + squareRootAndRemainder(); - shift(order1); + bitCount(); + bitLength(); + bitOps(order1); + bitwise(order1); - byteArrayConv(order1); + shift(order1); - modInv(order1); // small numbers - modInv(order3); // Karatsuba range - modInv(order4); // Toom-Cook / Burnikel-Ziegler range + byteArrayConv(order1); - modExp(order1, order2); - modExp2(order1); + modInv(order1); // small numbers + modInv(order3); // Karatsuba range + } + if (subset == 0 || subset == 2) { + modInv(order4); // Toom-Cook / Burnikel-Ziegler range - stringConv(); - serialize(); + modExp(order1, order2); + modExp2(order1); + } + if (subset == 0 || subset == 3) { + stringConv(); + serialize(); - multiplyLarge(); - squareLarge(); - divideLarge(); + multiplyLarge(); + squareLarge(); + divideLarge(); + } if (failure) throw new RuntimeException("Failure in BigIntegerTest."); diff --git a/test/jdk/java/math/BigInteger/LargeValueExceptions.java b/test/jdk/java/math/BigInteger/LargeValueExceptions.java index 961f87f3f61..bba3a23b438 100644 --- a/test/jdk/java/math/BigInteger/LargeValueExceptions.java +++ b/test/jdk/java/math/BigInteger/LargeValueExceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -30,6 +30,8 @@ */ import java.math.BigInteger; import static java.math.BigInteger.ONE; +import org.testng.ITestResult; +import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; // @@ -62,6 +64,13 @@ public class LargeValueExceptions { // Half BigInteger.MAX_MAG_LENGTH private static final int MAX_INTS_HALF = MAX_INTS / 2; + // Print the run time of each sub-test in milliseconds + @AfterMethod + public void getRunTime(ITestResult tr) { + long time = tr.getEndMillis() - tr.getStartMillis(); + System.out.printf("Run time: %d ms%n", time); + } + // --- squaring --- // Largest no overflow determined by examining data lengths alone. diff --git a/test/jdk/java/math/BigInteger/largeMemory/SymmetricRangeTests.java b/test/jdk/java/math/BigInteger/largeMemory/SymmetricRangeTests.java index e71afe6a028..cb8f5b04b83 100644 --- a/test/jdk/java/math/BigInteger/largeMemory/SymmetricRangeTests.java +++ b/test/jdk/java/math/BigInteger/largeMemory/SymmetricRangeTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -46,6 +46,8 @@ public class SymmetricRangeTests { private static final BigInteger MAX_VALUE = makeMaxValue(); private static final BigInteger MIN_VALUE = MAX_VALUE.negate(); + private static final Random RANDOM = RandomFactory.getRandom(); + private static BigInteger makeMaxValue() { byte[] ba = new byte[1 << 28]; Arrays.fill(ba, (byte) 0xFF); @@ -117,8 +119,7 @@ private static void testOverflowInBitSieve() { System.out.println("Testing overflow in BitSieve.sieveSingle"); int bitLength = (5 << 27) - 1; try { - Random random = RandomFactory.getRandom(); - BigInteger actual = new BigInteger(bitLength, 0, random); + BigInteger actual = new BigInteger(bitLength, 0, RANDOM); throw new RuntimeException("new BigInteger(bitLength, 0, null).bitLength()=" + actual.bitLength()); } catch (ArithmeticException e) { // expected @@ -621,45 +622,64 @@ private static void testByteValueExact() { } public static void main(String... args) { - testOverflowInMakePositive(); - testBug8021204(); - testOverflowInBitSieve(); - testAdd(); - testSubtract(); - testMultiply(); - testDivide(); - testDivideAndRemainder(); - testBug9005933(); - testRemainder(); - testPow(); - testGcd(); - testAbs(); - testNegate(); - testMod(); - testModPow(); -// testModInverse(); - testShiftLeft(); - testShiftRight(); - testAnd(); - testOr(); - testXor(); - testNot(); - testSetBit(); - testClearBit(); - testFlipBit(); - testGetLowestSetBit(); - testBitLength(); - testBitCount(); - testToString(); - testToByteArrayWithConstructor(); - testIntValue(); - testLongValue(); - testFloatValue(); - testDoubleValue(); - testSerialization(); - testLongValueExact(); - testIntValueExact(); - testShortValueExact(); - testByteValueExact(); + // subset zero indicates to run all subsets + int subset = Integer.valueOf(System.getProperty("subset", + String.valueOf(1 + RANDOM.nextInt(4)))); + if (subset < 0 || subset > 4) { + throw new RuntimeException("Unknown subset " + subset); + } + if (subset == 0) + System.out.println("Testing all subsets"); + else + System.out.println("Testing subset " + subset); + + if (subset == 0 || subset == 1) { + testOverflowInMakePositive(); + testBug8021204(); + testOverflowInBitSieve(); + testAdd(); + testSubtract(); + } + if (subset == 0 || subset == 2) { + testMultiply(); + testDivide(); + testDivideAndRemainder(); + testBug9005933(); + } + if (subset == 0 || subset == 3) { + testRemainder(); + testPow(); + testGcd(); + testAbs(); + testNegate(); + testMod(); + testModPow(); + // testModInverse(); + testShiftLeft(); + testShiftRight(); + testAnd(); + testOr(); + testXor(); + testNot(); + testSetBit(); + testClearBit(); + testFlipBit(); + testGetLowestSetBit(); + testBitLength(); + testBitCount(); + } + if (subset == 0 || subset == 4) { + testToString(); + testToByteArrayWithConstructor(); + testIntValue(); + testLongValue(); + testFloatValue(); + testDoubleValue(); + testSerialization(); + testLongValueExact(); + testIntValueExact(); + testShortValueExact(); + testByteValueExact(); + } } } From f7d05223d21bd8f4d2dda7546d72b17d069d5304 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Sun, 28 Apr 2024 21:51:19 +0000 Subject: [PATCH 116/149] 8315889: Open source several Swing HTMLDocument related tests Backport-of: 8f46abc938ffe338e25d5fdbdcfa0aaa12edfa58 --- .../text/html/HTMLDocument/bug4226914.java | 52 ++++++++++++++ .../text/html/HTMLDocument/bug4251593.java | 64 +++++++++++++++++ .../text/html/HTMLDocument/bug4687405.java | 72 +++++++++++++++++++ .../text/html/HTMLEditorKit/bug4213373.java | 62 ++++++++++++++++ 4 files changed, 250 insertions(+) create mode 100644 test/jdk/javax/swing/text/html/HTMLDocument/bug4226914.java create mode 100644 test/jdk/javax/swing/text/html/HTMLDocument/bug4251593.java create mode 100644 test/jdk/javax/swing/text/html/HTMLDocument/bug4687405.java create mode 100644 test/jdk/javax/swing/text/html/HTMLEditorKit/bug4213373.java diff --git a/test/jdk/javax/swing/text/html/HTMLDocument/bug4226914.java b/test/jdk/javax/swing/text/html/HTMLDocument/bug4226914.java new file mode 100644 index 00000000000..8bfaae935a2 --- /dev/null +++ b/test/jdk/javax/swing/text/html/HTMLDocument/bug4226914.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + + +import javax.swing.JEditorPane; +import java.io.ByteArrayOutputStream; +import java.io.ObjectOutputStream; + +/* + * @test + * @bug 4226914 + * @summary Tests if HTMLDocument streaming is broken + */ + +public class bug4226914 { + + public static void main(String[] args) throws Exception { + ObjectOutputStream oos = null; + try { + JEditorPane jtp = new JEditorPane("text/html", ""); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + oos = new ObjectOutputStream(baos); + oos.writeObject(jtp.getDocument()); + oos.flush(); + baos.toByteArray(); + } finally { + if (oos != null) { + oos.close(); + } + } + } +} diff --git a/test/jdk/javax/swing/text/html/HTMLDocument/bug4251593.java b/test/jdk/javax/swing/text/html/HTMLDocument/bug4251593.java new file mode 100644 index 00000000000..bdd51d68a2e --- /dev/null +++ b/test/jdk/javax/swing/text/html/HTMLDocument/bug4251593.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +import java.awt.event.ActionEvent; +import javax.swing.Action; +import javax.swing.JTextPane; +import javax.swing.SwingUtilities; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLEditorKit; + +/* + * @test + * @bug 4251593 + * @summary Tests that hyperlinks can be inserted into JTextPane + * via InsertHTMLTextAction. + */ + +public class bug4251593 { + private static JTextPane editor; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + editor = new JTextPane(); + editor.setContentType("text/html"); + editor.setEditable(true); + + int beforeLen = editor.getDocument().getLength(); + + String href = "javasoft "; + Action a = new HTMLEditorKit.InsertHTMLTextAction("Tester", href, HTML.Tag.BODY, HTML.Tag.A); + a.actionPerformed(new ActionEvent(editor, 0, null)); + + int afterLen = editor.getDocument().getLength(); + try { + Thread.sleep(300); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if ((afterLen - beforeLen) < 8) { + throw new RuntimeException("Test Failed: link not inserted!!"); + } + }); + } +} diff --git a/test/jdk/javax/swing/text/html/HTMLDocument/bug4687405.java b/test/jdk/javax/swing/text/html/HTMLDocument/bug4687405.java new file mode 100644 index 00000000000..5e549477072 --- /dev/null +++ b/test/jdk/javax/swing/text/html/HTMLDocument/bug4687405.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2003, 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. + * + * 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. + */ + +import javax.swing.JEditorPane; +import javax.swing.SwingUtilities; +import javax.swing.text.AttributeSet; +import javax.swing.text.View; +import javax.swing.text.html.CSS; +import javax.swing.text.html.HTMLEditorKit; + +/* + * @test + * @bug 4687405 + * @summary Tests if HTMLDocument very first paragraph doesn't have top margin. + */ + +public class bug4687405 { + private static JEditorPane jep; + private static volatile boolean passed = false; + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(bug4687405::createHTMLEditor); + Thread.sleep(200); + + SwingUtilities.invokeAndWait(bug4687405::testEditorPane); + Thread.sleep(500); + + if (!passed) { + throw new RuntimeException("Test failed!!" + + " Top margin present in HTMLDocument"); + } + } + + public static void createHTMLEditor() { + jep = new JEditorPane(); + jep.setEditorKit(new HTMLEditorKit()); + jep.setEditable(false); + } + + private static void testEditorPane() { + View v = jep.getUI().getRootView(jep); + while (!(v instanceof javax.swing.text.html.ParagraphView)) { + int n = v.getViewCount(); + v = v.getView(n - 1); + } + AttributeSet attrs = v.getAttributes(); + String marginTop = attrs.getAttribute(CSS.Attribute.MARGIN_TOP).toString(); + // MARGIN_TOP of the very first paragraph of the default html + // document should be 0. + passed = "0".equals(marginTop); + } +} diff --git a/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4213373.java b/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4213373.java new file mode 100644 index 00000000000..621547faca5 --- /dev/null +++ b/test/jdk/javax/swing/text/html/HTMLEditorKit/bug4213373.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1999, 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. + * + * 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. + */ + +import javax.swing.text.html.HTMLEditorKit; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +/* + * @test + * @bug 4213373 + * @summary Serialization bug on HTMLEditorKit. + */ + +public class bug4213373 { + + public static void main(String[] args) throws Exception { + HTMLEditorKit ekr = null; + ObjectOutputStream oos = null; + ObjectInputStream ois = null; + + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + HTMLEditorKit ekw = new HTMLEditorKit(); + oos = new ObjectOutputStream(baos); + oos.writeObject(ekw); + byte[] buf = baos.toByteArray(); + + ByteArrayInputStream bais = new ByteArrayInputStream(buf); + ois = new ObjectInputStream(bais); + ekr = (HTMLEditorKit) ois.readObject(); + } finally { + if (oos != null) { + oos.close(); + } + if (ois != null) { + ois.close(); + } + } + } +} From 81f2413af5207fd52e23d26e33bc73dca96649a2 Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Sun, 28 Apr 2024 21:51:45 +0000 Subject: [PATCH 117/149] 8318809: java/util/concurrent/ConcurrentLinkedQueue/WhiteBox.java shows intermittent failures on linux ppc64le and aarch64 Backport-of: 50d1839d54f13631946925d8ecf03ce71f31bab8 --- .../ConcurrentLinkedQueue/WhiteBox.java | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/test/jdk/java/util/concurrent/ConcurrentLinkedQueue/WhiteBox.java b/test/jdk/java/util/concurrent/ConcurrentLinkedQueue/WhiteBox.java index 63fd29a8a9a..2ea188aed46 100644 --- a/test/jdk/java/util/concurrent/ConcurrentLinkedQueue/WhiteBox.java +++ b/test/jdk/java/util/concurrent/ConcurrentLinkedQueue/WhiteBox.java @@ -281,36 +281,6 @@ public void pollActionsOneNodeSlack( assertInvariants(q); } - /** - * Actions that append an element, and are expected to - * leave at most one slack node at tail. - */ - @DataProvider - public Object[][] addActions() { - return List.>of( - q -> q.add(1), - q -> q.offer(1)) - .stream().map(x -> new Object[]{ x }).toArray(Object[][]::new); - } - - @Test(dataProvider = "addActions") - public void addActionsOneNodeSlack( - Consumer addAction) { - ConcurrentLinkedQueue q = new ConcurrentLinkedQueue(); - int n = 1 + rnd.nextInt(5); - for (int i = 0; i < n; i++) { - boolean slack = next(tail(q)) != null; - addAction.accept(q); - if (slack) - assertNull(next(tail(q))); - else { - assertNotNull(next(tail(q))); - assertNull(next(next(tail(q)))); - } - assertInvariants(q); - } - } - byte[] serialBytes(Object o) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); From 93630950c24d4e9c30507484aeecc91b6b57a584 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 29 Apr 2024 04:15:10 +0000 Subject: [PATCH 118/149] 8328194: Add a test to check default rendering engine Backport-of: c013fa18119bbd2e355d5c0d13cd8c172892800a --- .../java2d/marlin/DefaultRenderingEngine.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/jdk/sun/java2d/marlin/DefaultRenderingEngine.java diff --git a/test/jdk/sun/java2d/marlin/DefaultRenderingEngine.java b/test/jdk/sun/java2d/marlin/DefaultRenderingEngine.java new file mode 100644 index 00000000000..8ba6945d903 --- /dev/null +++ b/test/jdk/sun/java2d/marlin/DefaultRenderingEngine.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020, 2024, 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. + * + * 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. + */ + +import sun.java2d.pipe.RenderingEngine; + +/** + * @test + * @bug 8241307 + * @summary Verifies that the Marlin renderer is the default RenderingEngine + * @modules java.desktop/sun.java2d.pipe + */ +public final class DefaultRenderingEngine { + + public static void main(String[] argv) { + + final RenderingEngine engine = RenderingEngine.getInstance(); + + if (!engine.getClass().getSimpleName().contains("Marlin")) { + throw new RuntimeException("Marlin must be the default RenderingEngine"); + } + } +} From d42634bdacb1b98cf3740f0fc73562385661f6ef Mon Sep 17 00:00:00 2001 From: Amos Shi Date: Mon, 29 Apr 2024 06:20:18 +0000 Subject: [PATCH 119/149] 8263940: NPE when creating default file system when default file system provider is packaged as JAR file on class path Reviewed-by: lucy, goetz Backport-of: 717792c3b728584413572e7aede83290779be2a2 --- .../share/classes/java/util/zip/ZipFile.java | 11 ++++- .../java/nio/file/spi/SetDefaultProvider.java | 45 ++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/classes/java/util/zip/ZipFile.java b/src/java.base/share/classes/java/util/zip/ZipFile.java index 2b58547a6ae..649ee9ec8ab 100644 --- a/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -66,6 +66,7 @@ import jdk.internal.ref.CleanerFactory; import jdk.internal.vm.annotation.Stable; import sun.nio.cs.UTF_8; +import sun.nio.fs.DefaultFileSystemProvider; import sun.security.action.GetPropertyAction; import java.security.AccessController; @@ -1405,13 +1406,19 @@ public boolean equals(Object obj) { } } private static final HashMap files = new HashMap<>(); - + /** + * Use the platform's default file system to avoid + * issues when the VM is configured to use a custom file system provider. + */ + private static final java.nio.file.FileSystem builtInFS = + DefaultFileSystemProvider.theFileSystem(); static Source get(File file, boolean toDelete, ZipCoder zc) throws IOException { final Key key; try { key = new Key(file, - Files.readAttributes(file.toPath(), BasicFileAttributes.class)); + Files.readAttributes(builtInFS.getPath(file.getPath()), + BasicFileAttributes.class)); } catch (InvalidPathException ipe) { throw new IOException(ipe); } diff --git a/test/jdk/java/nio/file/spi/SetDefaultProvider.java b/test/jdk/java/nio/file/spi/SetDefaultProvider.java index 263557e93fe..3f2bce91f3d 100644 --- a/test/jdk/java/nio/file/spi/SetDefaultProvider.java +++ b/test/jdk/java/nio/file/spi/SetDefaultProvider.java @@ -23,6 +23,7 @@ /** * @test + * @bug 4313887 7006126 8142968 8178380 8183320 8210112 8266345 8263940 * @modules jdk.jartool * @library /test/lib * @build SetDefaultProvider TestProvider m/* jdk.test.lib.process.ProcessTools @@ -36,11 +37,14 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; import java.util.spi.ToolProvider; +import java.util.stream.Collectors; +import java.util.stream.Stream; import jdk.test.lib.process.ProcessTools; -import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import static org.testng.Assert.*; @@ -72,6 +76,45 @@ public void testClassPath() throws Exception { assertTrue(exitValue == 0); } + /** + * Test override of default FileSystemProvider with a + * FileSystemProvider jar and the main application on the class path. + */ + public void testClassPathWithFileSystemProviderJar() throws Exception { + String testClasses = System.getProperty("test.classes"); + Path jar = Path.of("testFileSystemProvider.jar"); + Files.deleteIfExists(jar); + createFileSystemProviderJar(jar, Path.of(testClasses)); + String classpath = jar + File.pathSeparator + testClasses + + File.separator + "modules" + File.separator + "m"; + int exitValue = exec(SET_DEFAULT_FSP, "-cp", classpath, "p.Main"); + assertTrue(exitValue == 0); + } + + /** + * Creates a JAR containing the FileSystemProvider used to override the + * default FileSystemProvider + */ + private void createFileSystemProviderJar(Path jar, Path dir) throws IOException { + + List args = new ArrayList<>(); + args.add("--create"); + args.add("--file=" + jar); + try (Stream stream = Files.list(dir)) { + List paths = stream + .map(path -> path.getFileName().toString()) + .filter(f -> f.startsWith("TestProvider")) + .collect(Collectors.toList()); + for(var p : paths) { + args.add("-C"); + args.add(dir.toString()); + args.add(p); + } + } + int ret = JAR_TOOL.run(System.out, System.out, args.toArray(new String[0])); + assertTrue(ret == 0); + } + /** * Test override of default FileSystemProvider with the main application * on the module path as an exploded module. From 137a8b9dcfaad4a96dfd22f57c759dfc4ea71f05 Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Mon, 29 Apr 2024 07:07:29 +0000 Subject: [PATCH 120/149] 8308021: Update IANA Language Subtag Registry to Version 2023-05-11 Backport-of: b96339f5e38c2c0e2f3d894d77d29554052cb1f1 --- .../data/lsrdata/language-subtag-registry.txt | 19 ++++++++++++++++++- .../Locale/LanguageSubtagRegistryTest.java | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/make/data/lsrdata/language-subtag-registry.txt b/make/data/lsrdata/language-subtag-registry.txt index 4fbc0c16806..48ba4d1d9aa 100644 --- a/make/data/lsrdata/language-subtag-registry.txt +++ b/make/data/lsrdata/language-subtag-registry.txt @@ -1,4 +1,4 @@ -File-Date: 2023-04-13 +File-Date: 2023-05-11 %% Type: language Subtag: aa @@ -47612,6 +47612,23 @@ Added: 2010-07-28 Prefix: sa %% Type: variant +Subtag: bciav +Description: BCI Blissymbolics AV +Added: 2023-05-11 +Prefix: zbl +Comments: Name given to a subset of the variety of Blissymbolics curated + by Blissymbolics Communication International, as represented by + entries in the BCI Authorized Vocabulary +%% +Type: variant +Subtag: bcizbl +Description: BCI Blissymbolics +Added: 2023-05-11 +Prefix: zbl +Comments: Name given to the variety of Blissymbolics curated by + Blissymbolics Communication International +%% +Type: variant Subtag: biscayan Description: Biscayan dialect of Basque Added: 2010-04-13 diff --git a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java index 9722823430f..009be2ad847 100644 --- a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java +++ b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java @@ -24,9 +24,9 @@ /* * @test * @bug 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432 - * 8258795 8267038 8287180 8302512 8304761 8306031 + * 8258795 8267038 8287180 8302512 8304761 8306031 8308021 * @summary Checks the IANA language subtag registry data update - * (LSR Revision: 2023-04-13) with Locale and Locale.LanguageRange + * (LSR Revision: 2023-05-11) with Locale and Locale.LanguageRange * class methods. * @run main LanguageSubtagRegistryTest */ From cabaf7482681fb17cb7722377da6baab0ed2fed3 Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Tue, 30 Apr 2024 16:57:16 +0000 Subject: [PATCH 121/149] 8305931: jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java failed with "Expected chains but found none" Backport-of: 65be5e0c547d74ca7de288b164aa9bd6d6855685 --- .../jfr/jcmd/TestJcmdDumpPathToGCRoots.java | 71 ++++++++++--------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/test/jdk/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java b/test/jdk/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java index ea1eba1c621..322e1146871 100644 --- a/test/jdk/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java +++ b/test/jdk/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -76,43 +76,50 @@ public static void main(String[] args) throws Exception { } private static void testDump(String pathToGcRoots, Map settings, boolean expectedChains) throws Exception { - try (Recording r = new Recording()) { - Map p = new HashMap<>(settings); - p.put(EventNames.OldObjectSample + "#" + Enabled.NAME, "true"); - r.setName("dodo"); - r.setSettings(p); - r.setToDisk(true); - r.start(); - clearLeak(); - System.out.println("Recording id: " + r.getId()); - System.out.println("Settings: " + settings.toString()); - System.out.println("Command: JFR.dump " + pathToGcRoots); - System.out.println("Chains expected: " + expectedChains); - buildLeak(); - System.gc(); - System.gc(); - File recording = new File("TestJcmdDumpPathToGCRoots" + r.getId() + ".jfr"); - recording.delete(); - JcmdHelper.jcmd("JFR.dump", "name=dodo", pathToGcRoots, "filename=" + recording.getAbsolutePath()); - r.setSettings(Collections.emptyMap()); - List events = RecordingFile.readAllEvents(recording.toPath()); - if (events.isEmpty()) { - throw new Exception("No events found in recoding"); - } - boolean chains = hasChains(events); - if (expectedChains && !chains) { - System.out.println(events); - throw new Exception("Expected chains but found none"); - } - if (!expectedChains && chains) { - System.out.println(events); - throw new Exception("Didn't expect chains but found some"); + while (true) { + try (Recording r = new Recording()) { + Map p = new HashMap<>(settings); + p.put(EventNames.OldObjectSample + "#" + Enabled.NAME, "true"); + r.setName("dodo"); + r.setSettings(p); + r.setToDisk(true); + r.start(); + clearLeak(); + System.out.println("Recording id: " + r.getId()); + System.out.println("Settings: " + settings.toString()); + System.out.println("Command: JFR.dump " + pathToGcRoots); + System.out.println("Chains expected: " + expectedChains); + buildLeak(); + System.gc(); + System.gc(); + File recording = new File("TestJcmdDumpPathToGCRoots" + r.getId() + ".jfr"); + recording.delete(); + JcmdHelper.jcmd("JFR.dump", "name=dodo", pathToGcRoots, "filename=" + recording.getAbsolutePath()); + r.setSettings(Collections.emptyMap()); + List events = RecordingFile.readAllEvents(recording.toPath()); + if (events.isEmpty()) { + System.out.println("No events found in recording. Retrying."); + continue; + } + boolean chains = hasChains(events); + if (expectedChains && !chains) { + System.out.println(events); + System.out.println("Expected chains but found none. Retrying."); + continue; + } + if (!expectedChains && chains) { + System.out.println(events); + System.out.println("Didn't expect chains but found some. Retrying."); + continue; + } + return; // Success } } } private static void clearLeak() { leak.clear(); + System.gc(); } private static boolean hasChains(List events) throws IOException { From 1da8fd845cbed721ecc418d44573dd66743b639c Mon Sep 17 00:00:00 2001 From: Andrew Lu Date: Mon, 6 May 2024 07:41:05 +0000 Subject: [PATCH 122/149] 8295343: sun/security/pkcs11 tests fail on Linux RHEL 8.6 and newer 8231351: Add notes for PKCS11 tests in the test doc Reviewed-by: lucy Backport-of: 6ce0ebb858d3112f136e12d3ad595f805f6871a0 --- doc/testing.html | 20 ++-- doc/testing.md | 16 +++ test/jdk/ProblemList.txt | 7 +- test/jdk/sun/security/pkcs11/PKCS11Test.java | 101 ++---------------- test/jdk/sun/security/pkcs11/README | 13 +-- .../sun/security/tools/keytool/NssTest.java | 9 +- .../sun/security/tools/keytool/p11-nss.txt | 2 +- 7 files changed, 52 insertions(+), 116 deletions(-) diff --git a/doc/testing.html b/doc/testing.html index 18ba3e2baf6..c3e8ca956b0 100644 --- a/doc/testing.html +++ b/doc/testing.html @@ -5,7 +5,7 @@ Testing the JDK -